diff --git a/module-server/src/main/java/de/twomartens/wahlrecht/configuration/WebSecurityConfiguration.java b/module-server/src/main/java/de/twomartens/wahlrecht/configuration/WebSecurityConfiguration.java index 94e87ee..241c751 100644 --- a/module-server/src/main/java/de/twomartens/wahlrecht/configuration/WebSecurityConfiguration.java +++ b/module-server/src/main/java/de/twomartens/wahlrecht/configuration/WebSecurityConfiguration.java @@ -3,6 +3,7 @@ package de.twomartens.wahlrecht.configuration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpMethod; import org.springframework.lang.NonNull; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; @@ -23,8 +24,7 @@ public class WebSecurityConfiguration { http .csrf().disable() .authorizeHttpRequests() - .requestMatchers("/wahlrecht/v1/election", "/wahlrecht/v1/party/**", - "/wahlrecht/v1/nomination/**") + .requestMatchers(HttpMethod.PUT, "/wahlrecht/v1/**") .authenticated() .and() .authorizeHttpRequests() diff --git a/module-server/src/main/java/de/twomartens/wahlrecht/controller/v1/PartyController.java b/module-server/src/main/java/de/twomartens/wahlrecht/controller/v1/PartyController.java index 50008d1..056306d 100644 --- a/module-server/src/main/java/de/twomartens/wahlrecht/controller/v1/PartyController.java +++ b/module-server/src/main/java/de/twomartens/wahlrecht/controller/v1/PartyController.java @@ -1,11 +1,8 @@ package de.twomartens.wahlrecht.controller.v1; -import de.twomartens.wahlrecht.mapper.v1.ElectionMapper; import de.twomartens.wahlrecht.mapper.v1.PartyInElectionMapper; import de.twomartens.wahlrecht.model.dto.ErrorMessage; -import de.twomartens.wahlrecht.model.dto.v1.Election; import de.twomartens.wahlrecht.model.dto.v1.PartyInElection; -import de.twomartens.wahlrecht.service.ElectionService; import de.twomartens.wahlrecht.service.PartyService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -24,11 +21,8 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -41,9 +35,7 @@ import org.springframework.web.bind.annotation.RequestMapping; public class PartyController { private final PartyInElectionMapper mapper = Mappers.getMapper(PartyInElectionMapper.class); - private final ElectionMapper electionMapper = Mappers.getMapper(ElectionMapper.class); private final PartyService service; - private final ElectionService electionService; @Operation( summary = "Returns all stored parties for given election name", @@ -97,49 +89,4 @@ public class PartyController { ? new ResponseEntity<>(HttpStatus.CREATED) : new ResponseEntity<>(HttpStatus.OK); } - - @PostMapping("/party") - public String submitCreatePartyForm(@ModelAttribute PartyInElection party, Model model) { - service.storeParty(mapper.mapToDB(party)); - model.addAttribute("party", party); - model.addAttribute("isCreate", false); - return "partyUpdate"; - } - - @GetMapping("/party") - public String createPartyForm(Model model) { - model.addAttribute("party", new PartyInElection()); - model.addAttribute("isCreate", true); - return "partyCreate"; - } - - @PostMapping("/party/{electionName}/{abbreviation}") - public String submitUpdatePartyForm( - @PathVariable String electionName, - @PathVariable String abbreviation, - @ModelAttribute PartyInElection party, - Model model) { - return submitCreatePartyForm(party, model); - } - - - @GetMapping("/party/{electionName}/{abbreviation}") - public String updatePartyForm( - @PathVariable String electionName, - @PathVariable String abbreviation, - Model model) { - PartyInElection party = mapper.mapToExternal( - service.getPartyByElectionNameAndAbbreviation(electionName, abbreviation)); - model.addAttribute("party", party); - model.addAttribute("isCreate", false); - - return "partyUpdate"; - } - - @ModelAttribute("elections") - Collection elections() { - return electionService.getElections().stream() - .map(electionMapper::mapToExternal) - .toList(); - } } diff --git a/module-server/src/main/resources/templates/partyCreate.html b/module-server/src/main/resources/templates/partyCreate.html deleted file mode 100644 index 8a3cfa7..0000000 --- a/module-server/src/main/resources/templates/partyCreate.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - -
-
-
-
-
- - -
-
- - -
-
- - -
-
- -
-
-
-
-
- - - \ No newline at end of file diff --git a/module-server/src/main/resources/templates/partyUpdate.html b/module-server/src/main/resources/templates/partyUpdate.html deleted file mode 100644 index 21f8e26..0000000 --- a/module-server/src/main/resources/templates/partyUpdate.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - -
-
-
-
-
- - -
-
- - -
-
- - -
-
- -
-
-
-
-
- - - \ No newline at end of file