Search in sources :

Example 21 with Organization

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);
}
Also used : Organization(alfio.model.user.Organization) Transactional(org.springframework.transaction.annotation.Transactional)

Example 22 with Organization

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);
}
Also used : Organization(alfio.model.user.Organization) LocationDescriptor(alfio.model.modification.support.LocationDescriptor)

Example 23 with Organization

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);
}
Also used : Organization(alfio.model.user.Organization) Event(alfio.model.Event)

Example 24 with Organization

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);
}
Also used : Organization(alfio.model.user.Organization)

Example 25 with Organization

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!");
        }
    }
}
Also used : Locale(java.util.Locale) Organization(alfio.model.user.Organization) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) Event(alfio.model.Event)

Aggregations

Organization (alfio.model.user.Organization)30 Event (alfio.model.Event)13 TicketCategory (alfio.model.TicketCategory)7 Ticket (alfio.model.Ticket)6 Triple (org.apache.commons.lang3.tuple.Triple)6 TicketReservation (alfio.model.TicketReservation)4 java.util (java.util)4 Collectors (java.util.stream.Collectors)4 Log4j2 (lombok.extern.log4j.Log4j2)4 Component (org.springframework.stereotype.Component)4 DateTimeModification (alfio.model.modification.DateTimeModification)3 LocationDescriptor (alfio.model.modification.support.LocationDescriptor)3 ZonedDateTime (java.time.ZonedDateTime)3 Collections.singletonList (java.util.Collections.singletonList)3 Transactional (org.springframework.transaction.annotation.Transactional)3 EventManager (alfio.manager.EventManager)2 NotificationManager (alfio.manager.NotificationManager)2 TicketReservationManager (alfio.manager.TicketReservationManager)2 Mailer (alfio.manager.system.Mailer)2 alfio.model (alfio.model)2