use of alfio.model.user.Organization in project alf.io by alfio-event.
the class TicketReservationManager method prepareModelForReservationEmail.
@Transactional(readOnly = true)
public Map<String, Object> prepareModelForReservationEmail(Event event, TicketReservation reservation, Optional<String> vat, OrderSummary summary) {
Organization organization = organizationRepository.getById(event.getOrganizationId());
List<Ticket> tickets = findTicketsInReservation(reservation.getId());
String reservationUrl = reservationUrl(reservation.getId());
String reservationShortID = getShortReservationID(event, reservation.getId());
Optional<String> invoiceAddress = configurationManager.getStringConfigValue(Configuration.from(event.getOrganizationId(), event.getId(), ConfigurationKeys.INVOICE_ADDRESS));
Optional<String> bankAccountNr = configurationManager.getStringConfigValue(Configuration.from(event.getOrganizationId(), event.getId(), ConfigurationKeys.BANK_ACCOUNT_NR));
Optional<String> bankAccountOwner = configurationManager.getStringConfigValue(Configuration.from(event.getOrganizationId(), event.getId(), ConfigurationKeys.BANK_ACCOUNT_OWNER));
return TemplateResource.prepareModelForConfirmationEmail(organization, event, reservation, vat, tickets, summary, reservationUrl, reservationShortID, invoiceAddress, bankAccountNr, bankAccountOwner);
}
use of alfio.model.user.Organization in project alf.io by alfio-event.
the class DataMigratorIntegrationTest method initEvent.
private Pair<Event, String> initEvent(List<TicketCategoryModification> categories, String displayName) {
String organizationName = UUID.randomUUID().toString();
String username = UUID.randomUUID().toString();
String eventName = UUID.randomUUID().toString();
organizationRepository.create(organizationName, "org", "email@example.com");
Organization organization = organizationRepository.findByName(organizationName).get();
userManager.insertUser(organization.getId(), username, "test", "test", "test@example.com", Role.OPERATOR, User.Type.INTERNAL);
Map<String, String> desc = new HashMap<>();
desc.put("en", "muh description");
desc.put("it", "muh description");
desc.put("de", "muh description");
EventModification em = new EventModification(null, Event.EventType.INTERNAL, "url", "url", "url", null, null, eventName, displayName, organization.getId(), "muh location", "0.0", "0.0", ZoneId.systemDefault().getId(), desc, new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now()), new DateTimeModification(LocalDate.now().plusDays(5), LocalTime.now().plusHours(1)), BigDecimal.TEN, "CHF", AVAILABLE_SEATS, BigDecimal.ONE, true, null, categories, false, new LocationDescriptor("", "", "", ""), 7, null, null);
eventManager.createEvent(em);
return Pair.of(eventManager.getSingleEvent(eventName, username), username);
}
use of alfio.model.user.Organization in project alf.io by alfio-event.
the class ExtensionApiController method bulkUpdateEvent.
@PostMapping("/setting/organization/{orgShortName}/event/{shortName}/bulk-update")
public void bulkUpdateEvent(@PathVariable("orgShortName") String orgShortName, @PathVariable("shortName") String eventShortName, @RequestBody List<ExtensionMetadataValue> toUpdate, Principal principal) {
Organization org = organizationRepository.findByName(orgShortName).orElseThrow(IllegalStateException::new);
ensureOrganization(principal, org);
Event event = eventRepository.findByShortName(eventShortName);
ensureEventInOrganization(org, event);
String pattern = String.format("-%d-%d", org.getId(), event.getId());
ensureIdsArePresent(toUpdate, extensionService.getConfigurationParametersFor(pattern, pattern, "EVENT"));
extensionService.bulkUpdateEventSettings(org, event, toUpdate);
}
use of alfio.model.user.Organization in project alf.io by alfio-event.
the class ExtensionApiController method bulkUpdateOrganization.
@PostMapping("/setting/organization/{orgShortName}/bulk-update")
public void bulkUpdateOrganization(@PathVariable("orgShortName") String orgShortName, @RequestBody List<ExtensionMetadataValue> toUpdate, Principal principal) {
Organization org = organizationRepository.findByName(orgShortName).orElseThrow(IllegalStateException::new);
ensureOrganization(principal, org);
ensureIdsArePresent(toUpdate, extensionService.getConfigurationParametersFor("-" + org.getId(), "-" + org.getId() + "-%", "ORGANIZATION"));
extensionService.bulkUpdateOrganizationSettings(org, toUpdate);
}
use of alfio.model.user.Organization in project alf.io by alfio-event.
the class ResourceController method previewTemplate.
@RequestMapping(value = "/overridable-template/{name}/{locale}/preview", method = RequestMethod.POST)
public void previewTemplate(@PathVariable("name") TemplateResource name, @PathVariable("locale") String locale, @RequestParam(required = false, value = "organizationId") Integer organizationId, @RequestParam(required = false, value = "eventId") Integer eventId, @RequestBody UploadBase64FileModification template, Principal principal, HttpServletResponse response) throws IOException {
Locale loc = Locale.forLanguageTag(locale);
if (organizationId != null && eventId != null) {
checkAccess(organizationId, eventId, principal);
Event event = eventRepository.findById(eventId);
Organization organization = organizationRepository.getById(organizationId);
Optional<TemplateResource.ImageData> image = TemplateProcessor.extractImageModel(event, fileUploadManager);
Map<String, Object> model = name.prepareSampleModel(organization, event, image);
String renderedTemplate = templateManager.renderString(template.getFileAsString(), model, loc, name.getTemplateOutput());
if ("text/plain".equals(name.getRenderedContentType())) {
response.addHeader("Content-Disposition", "attachment; filename=" + name.name() + ".txt");
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");
try (OutputStream os = response.getOutputStream()) {
StreamUtils.copy(renderedTemplate, StandardCharsets.UTF_8, os);
}
} else if ("application/pdf".equals(name.getRenderedContentType())) {
response.setContentType("application/pdf");
response.addHeader("Content-Disposition", "attachment; filename=" + name.name() + ".pdf");
try (OutputStream os = response.getOutputStream()) {
TemplateProcessor.prepareItextRenderer(renderedTemplate).createPDF(os);
}
} else {
throw new IllegalStateException("cannot enter here!");
}
}
}
Aggregations