Skip to content

Commit

Permalink
implement #436 force ticket owner assignment at registration (#454)
Browse files Browse the repository at this point in the history
* #436 initial work for forcing assignment at reservation

* #436 override check in form on submit with correct value if configured

(cherry picked from commit f26cd67)
  • Loading branch information
syjer authored and cbellone committed May 26, 2018
1 parent 0470777 commit 53903cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/alfio/controller/ReservationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ public String showPaymentPage(@PathVariable("eventName") String eventName,
return redirectReservation(Optional.of(reservation), eventName, reservationId);
}

Configuration.ConfigurationPathKey forceAssignmentKey = Configuration.from(event.getOrganizationId(), event.getId(), ConfigurationKeys.FORCE_TICKET_OWNER_ASSIGNMENT_AT_RESERVATION);
boolean forceAssignment = configurationManager.getBooleanConfigValue(forceAssignmentKey, false);

List<Ticket> ticketsInReservation = ticketReservationManager.findTicketsInReservation(reservationId);
if (Boolean.TRUE.equals(isPaypalSuccess) && paypalPayerID != null && paypalPaymentId != null) {
model.addAttribute("paypalPaymentId", paypalPaymentId)
Expand All @@ -126,11 +129,11 @@ public String showPaymentPage(@PathVariable("eventName") String eventName,
.addAttribute("hmac", hmac)
.addAttribute("postponeAssignment", Boolean.TRUE.equals(postponeAssignment))
.addAttribute("invoiceRequested", Boolean.TRUE.equals(invoiceRequested))
.addAttribute("showPostpone", Boolean.TRUE.equals(postponeAssignment));
.addAttribute("showPostpone", !forceAssignment && Boolean.TRUE.equals(postponeAssignment));
} else {
model.addAttribute("paypalCheckoutConfirmation", false)
.addAttribute("postponeAssignment", false)
.addAttribute("showPostpone", ticketsInReservation.size() > 1);
.addAttribute("showPostpone", !forceAssignment && ticketsInReservation.size() > 1);
}

try {
Expand Down Expand Up @@ -421,6 +424,11 @@ public String handleReservation(@PathVariable("eventName") String eventName,
bindingResult.reject(ErrorsCode.STEP_2_CAPTCHA_VALIDATION_FAILED);
}

Configuration.ConfigurationPathKey forceAssignmentKey = Configuration.from(event.getOrganizationId(), event.getId(), ConfigurationKeys.FORCE_TICKET_OWNER_ASSIGNMENT_AT_RESERVATION);
boolean forceAssignment = configurationManager.getBooleanConfigValue(forceAssignmentKey, false);
if(forceAssignment) {
paymentForm.setPostponeAssignment(false);
}
if(paymentForm.getPaymentMethod() != PaymentProxy.PAYPAL || !paymentForm.hasPaypalTokens()) {
if(!paymentForm.isPostponeAssignment() && !ticketRepository.checkTicketUUIDs(reservationId, paymentForm.getTickets().keySet())) {
bindingResult.reject(ErrorsCode.STEP_2_MISSING_ATTENDEE_DATA);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/alfio/model/system/ConfigurationKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public enum ConfigurationKeys {
ASSIGNMENT_REMINDER_INTERVAL("How long should be the 'quiet period' (in days) between the reminders? (default: 3 days)", false, SettingCategory.GENERAL, ComponentType.TEXT, false, EnumSet.of(SYSTEM, ORGANIZATION, EVENT), true),
OPTIONAL_DATA_REMINDER_ENABLED("Send a reminder for optional data? (default: true)", false, SettingCategory.GENERAL, ComponentType.BOOLEAN, false, EnumSet.of(SYSTEM, ORGANIZATION, EVENT), true),
RESERVATION_TIMEOUT("The amount of time, in MINUTES, that the user have to complete the reservation process (default: 25 min)", false, SettingCategory.GENERAL, ComponentType.TEXT, false, EnumSet.of(SYSTEM, ORGANIZATION, EVENT), true),
FORCE_TICKET_OWNER_ASSIGNMENT_AT_RESERVATION("Force ticket owner assignment at reservation time", false, SettingCategory.GENERAL, ComponentType.BOOLEAN, false, EnumSet.of(SYSTEM, ORGANIZATION, EVENT), true),

//
MAILER_TYPE("Mailer type (if not set, default will be disabled)", false, SettingCategory.MAIL, ComponentType.TEXT, true, EnumSet.of(SYSTEM), true),//valid values: smtp | mailgun
Expand Down

0 comments on commit 53903cd

Please sign in to comment.