use of alfio.model.user.Organization in project alf.io by alfio-event.
the class ExtensionApiController method deleteOrganizationSettingValue.
@DeleteMapping("/setting/organization/{orgShortName}/{id}")
public void deleteOrganizationSettingValue(@PathVariable("orgShortName") String orgShortName, @PathVariable("id") int id, Principal principal) {
Organization org = organizationRepository.findByName(orgShortName).orElseThrow(IllegalStateException::new);
ensureOrganization(principal, org);
extensionService.deleteSettingValue(id, "-" + org.getId());
}
use of alfio.model.user.Organization in project alf.io by alfio-event.
the class TicketController method internalShowTicket.
private String internalShowTicket(String eventName, String ticketIdentifier, boolean ticketEmailSent, Model model, String backSuffix, Locale locale) {
Optional<Triple<Event, TicketReservation, Ticket>> oData = ticketReservationManager.fetchCompleteAndAssigned(eventName, ticketIdentifier);
if (!oData.isPresent()) {
return "redirect:/event/" + eventName;
}
Triple<Event, TicketReservation, Ticket> data = oData.get();
TicketCategory ticketCategory = ticketCategoryRepository.getByIdAndActive(data.getRight().getCategoryId(), data.getLeft().getId());
Organization organization = organizationRepository.getById(data.getLeft().getOrganizationId());
Event event = data.getLeft();
TicketReservation reservation = data.getMiddle();
//
model.addAttribute("ticket", data.getRight()).addAttribute("reservation", //
reservation).addAttribute("event", //
event).addAttribute("ticketCategory", //
ticketCategory).addAttribute("organization", //
organization).addAttribute("ticketEmailSent", ticketEmailSent).addAttribute("reservationId", ticketReservationManager.getShortReservationID(event, reservation.getId())).addAttribute("deskPaymentRequired", Optional.ofNullable(reservation.getPaymentMethod()).orElse(PaymentProxy.STRIPE).isDeskPaymentRequired()).addAttribute("backSuffix", backSuffix).addAttribute("userLanguage", locale.getLanguage()).addAttribute("pageTitle", "show-ticket.header.title").addAttribute("useFirstAndLastName", event.mustUseFirstAndLastName()).addAttribute("validityStart", Optional.ofNullable(ticketCategory.getTicketValidityStart(event.getZoneId())).orElse(event.getBegin())).addAttribute("validityEnd", Optional.ofNullable(ticketCategory.getTicketValidityEnd(event.getZoneId())).orElse(event.getEnd())).addAttribute("ticketIdParam", "ticketId=" + ticketIdentifier);
return "/event/show-ticket";
}
use of alfio.model.user.Organization in project alf.io by alfio-event.
the class TicketController method showTicketForUpdate.
@RequestMapping(value = "/event/{eventName}/ticket/{ticketIdentifier}/update", method = RequestMethod.GET)
public String showTicketForUpdate(@PathVariable("eventName") String eventName, @PathVariable("ticketIdentifier") String ticketIdentifier, Model model, Locale locale) {
Optional<Triple<Event, TicketReservation, Ticket>> oData = ticketReservationManager.fetchCompleteAndAssigned(eventName, ticketIdentifier);
if (!oData.isPresent()) {
return "redirect:/event/" + eventName;
}
Triple<Event, TicketReservation, Ticket> data = oData.get();
Event event = data.getLeft();
TicketCategory ticketCategory = ticketCategoryRepository.getByIdAndActive(data.getRight().getCategoryId(), event.getId());
Organization organization = organizationRepository.getById(event.getOrganizationId());
boolean enableFreeCancellation = configurationManager.getBooleanConfigValue(Configuration.from(event.getOrganizationId(), event.getId(), ticketCategory.getId(), ALLOW_FREE_TICKETS_CANCELLATION), false);
Ticket ticket = data.getRight();
//
model.addAttribute("ticketAndCategory", Pair.of(eventManager.getTicketCategoryById(ticket.getCategoryId(), event.getId()), new TicketDecorator(ticket, enableFreeCancellation, eventManager.checkTicketCancellationPrerequisites().apply(ticket), "ticket/" + ticket.getUuid() + "/view", ticketHelper.findTicketFieldConfigurationAndValue(event.getId(), ticket, locale), true, ""))).addAttribute("reservation", //
data.getMiddle()).addAttribute("reservationId", ticketReservationManager.getShortReservationID(event, data.getMiddle().getId())).addAttribute("event", //
event).addAttribute("ticketCategory", //
ticketCategory).addAttribute("countries", TicketHelper.getLocalizedCountries(locale)).addAttribute("organization", //
organization).addAttribute("pageTitle", "show-ticket.header.title").addAttribute("useFirstAndLastName", event.mustUseFirstAndLastName());
return "/event/update-ticket";
}
use of alfio.model.user.Organization in project alf.io by alfio-event.
the class SpecialPriceManager method sendCodeToAssignee.
public boolean sendCodeToAssignee(List<SendCodeModification> input, String eventName, int categoryId, String username) {
final Event event = eventManager.getSingleEvent(eventName, username);
final Organization organization = eventManager.loadOrganizer(event, username);
Set<SendCodeModification> set = new LinkedHashSet<>(input);
checkCodeAssignment(set, categoryId, event, username);
Validate.isTrue(set.stream().allMatch(IS_CODE_PRESENT), "There are missing codes. Please check input file.");
List<ContentLanguage> eventLanguages = i18nManager.getEventLanguages(event.getLocales());
Validate.isTrue(!eventLanguages.isEmpty(), "No locales have been defined for the event. Please check the configuration");
ContentLanguage defaultLocale = eventLanguages.contains(ContentLanguage.ENGLISH) ? ContentLanguage.ENGLISH : eventLanguages.get(0);
set.forEach(m -> {
Locale locale = Locale.forLanguageTag(StringUtils.defaultString(StringUtils.trimToNull(m.getLanguage()), defaultLocale.getLanguage()));
Map<String, Object> model = TemplateResource.prepareModelForSendReservedCode(organization, event, m, eventManager.getEventUrl(event));
notificationManager.sendSimpleEmail(event, m.getEmail(), messageSource.getMessage("email-code.subject", new Object[] { event.getDisplayName() }, locale), () -> templateManager.renderTemplate(event, TemplateResource.SEND_RESERVED_CODE, model, locale));
int marked = specialPriceRepository.markAsSent(ZonedDateTime.now(event.getZoneId()), m.getAssignee().trim(), m.getEmail().trim(), m.getCode().trim());
Validate.isTrue(marked == 1, "Expected exactly one row updated, got " + marked);
});
return true;
}
use of alfio.model.user.Organization in project alf.io by alfio-event.
the class TicketReservationManager method updateTicketOwner.
public void updateTicketOwner(Ticket ticket, Locale locale, Event event, UpdateTicketOwnerForm updateTicketOwner, PartialTicketTextGenerator confirmationTextBuilder, PartialTicketTextGenerator ownerChangeTextBuilder, Optional<UserDetails> userDetails) {
Ticket preUpdateTicket = ticketRepository.findByUUID(ticket.getUuid());
Map<String, String> preUpdateTicketFields = ticketFieldRepository.findAllByTicketId(ticket.getId()).stream().collect(Collectors.toMap(TicketFieldValue::getName, TicketFieldValue::getValue));
String newEmail = updateTicketOwner.getEmail().trim();
CustomerName customerName = new CustomerName(updateTicketOwner.getFullName(), updateTicketOwner.getFirstName(), updateTicketOwner.getLastName(), event);
ticketRepository.updateTicketOwner(ticket.getUuid(), newEmail, customerName.getFullName(), customerName.getFirstName(), customerName.getLastName());
//
Locale userLocale = Optional.ofNullable(StringUtils.trimToNull(updateTicketOwner.getUserLanguage())).map(Locale::forLanguageTag).orElse(locale);
ticketRepository.updateOptionalTicketInfo(ticket.getUuid(), userLocale.getLanguage());
ticketFieldRepository.updateOrInsert(updateTicketOwner.getAdditional(), ticket.getId(), event.getId());
Ticket newTicket = ticketRepository.findByUUID(ticket.getUuid());
if (newTicket.getStatus() == TicketStatus.ACQUIRED && (!StringUtils.equalsIgnoreCase(newEmail, ticket.getEmail()) || !StringUtils.equalsIgnoreCase(customerName.getFullName(), ticket.getFullName()))) {
sendTicketByEmail(newTicket, userLocale, event, confirmationTextBuilder);
}
boolean admin = isAdmin(userDetails);
if (!admin && StringUtils.isNotBlank(ticket.getEmail()) && !StringUtils.equalsIgnoreCase(newEmail, ticket.getEmail()) && ticket.getStatus() == TicketStatus.ACQUIRED) {
Locale oldUserLocale = Locale.forLanguageTag(ticket.getUserLanguage());
String subject = messageSource.getMessage("ticket-has-changed-owner-subject", new Object[] { event.getDisplayName() }, oldUserLocale);
notificationManager.sendSimpleEmail(event, ticket.getEmail(), subject, () -> ownerChangeTextBuilder.generate(newTicket));
if (event.getBegin().isBefore(ZonedDateTime.now(event.getZoneId()))) {
Organization organization = organizationRepository.getById(event.getOrganizationId());
notificationManager.sendSimpleEmail(event, organization.getEmail(), "WARNING: Ticket has been reassigned after event start", () -> ownerChangeTextBuilder.generate(newTicket));
}
}
if (admin) {
TicketReservation reservation = findById(ticket.getTicketsReservationId()).orElseThrow(IllegalStateException::new);
// if the current user is admin, then it would be good to update also the name of the Reservation Owner
String username = userDetails.get().getUsername();
log.warn("Reservation {}: forced assignee replacement old: {} new: {}", reservation.getId(), reservation.getFullName(), username);
ticketReservationRepository.updateAssignee(reservation.getId(), username);
}
extensionManager.handleTicketAssignment(newTicket);
Ticket postUpdateTicket = ticketRepository.findByUUID(ticket.getUuid());
Map<String, String> postUpdateTicketFields = ticketFieldRepository.findAllByTicketId(ticket.getId()).stream().collect(Collectors.toMap(TicketFieldValue::getName, TicketFieldValue::getValue));
auditUpdateTicket(preUpdateTicket, preUpdateTicketFields, postUpdateTicket, postUpdateTicketFields, event.getId());
}
Aggregations