Skip to content

Commit

Permalink
fix: set publish as display
Browse files Browse the repository at this point in the history
Tried to go back in the history to see when this field disappeared but
could not see anything. Do you think it could be related to the switch
from prometheus, @Herkarl? Anyway, no it is being set explicitly on a
post to `admin/edit`.

Resolves #40
  • Loading branch information
niklasvatn committed Mar 31, 2023
1 parent 7d0889f commit 41eba82
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,22 @@ public String editForm(@RequestParam(name = "id") Long id, Model model) {
}

@PostMapping("/admin/edit")
public String doEdit(@RequestParam(required = false) String publish, @Valid Item item, BindingResult bindingResult, Model model) {
public String doEdit(Authentication auth, @RequestParam(required = false) String publish, @Valid Item item, BindingResult bindingResult, Model model) {
model.addAttribute("now", LocalDateTime.now().format(formatter));
model.addAttribute("formatter", formatter);

// Check for form errors
if (bindingResult.hasErrors())
return "edit";


if (item.getPublishAs() != null && !item.getPublishAs().isEmpty()) {
var mandates = ((DAuthUserDetails) auth.getPrincipal()).getMandates();
String mandateDisplay = mandates.get(item.getPublishAs());
if (mandateDisplay != null)
item.setPublishAsDisplay(mandateDisplay);
}

// If the special publish param (name of a submit button) is present, we publish
if (publish != null)
item.setPublishDate(LocalDateTime.now());
Expand Down

0 comments on commit 41eba82

Please sign in to comment.