Skip to content

Commit

Permalink
#66 - redesign ticket assignee GUI: add gender (and remove misleading…
Browse files Browse the repository at this point in the history
… gender-specific T-Shirt sizes)
  • Loading branch information
cbellone committed Aug 6, 2015
1 parent f8ea029 commit b667887
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class UpdateTicketOwnerForm {
private String address;
private String country;
private String tShirtSize;
private String gender;
private String userLanguage;
private String notes;
}
6 changes: 4 additions & 2 deletions src/main/java/alfio/manager/TicketReservationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -714,12 +714,14 @@ public void updateTicketOwner(Ticket ticket,
ticketRepository.updateTicketOwner(ticket.getUuid(), newEmail, newFullName);
//
Locale userLocale = Optional.ofNullable(StringUtils.trimToNull(updateTicketOwner.getUserLanguage())).map(Locale::forLanguageTag).orElse(locale);
ticketRepository.updateOptionalTicketInfo(ticket.getUuid(), updateTicketOwner.getJobTitle(),

ticketRepository.updateOptionalTicketInfo(ticket.getUuid(), updateTicketOwner.getJobTitle(),
updateTicketOwner.getCompany(),
updateTicketOwner.getPhoneNumber(),
updateTicketOwner.getAddress(),
updateTicketOwner.getCountry(),
updateTicketOwner.getTShirtSize(),
updateTicketOwner.getTShirtSize(),
updateTicketOwner.getGender(),
updateTicketOwner.getNotes(),
userLocale.getLanguage());

Expand Down
15 changes: 13 additions & 2 deletions src/main/java/alfio/manager/system/DataMigrator.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package alfio.manager.system;

import alfio.model.Event;
import alfio.model.Ticket;
import alfio.model.system.EventMigration;
import alfio.repository.EventRepository;
import alfio.repository.TicketRepository;
Expand All @@ -29,7 +30,6 @@
import org.springframework.jdbc.core.namedparam.EmptySqlParameterSource;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.stereotype.Component;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
Expand All @@ -39,8 +39,8 @@

import java.math.BigDecimal;
import java.time.ZonedDateTime;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -85,6 +85,7 @@ public void migrateEventsToCurrentVersion() {
.filter(e -> ZonedDateTime.now(e.getZoneId()).isBefore(e.getEnd()))
.forEach(this::migrateEventToCurrentVersion);
fillReservationsLanguage();
fillTicketsGender();
}

void migrateEventToCurrentVersion(Event event) {
Expand Down Expand Up @@ -120,6 +121,16 @@ void fillReservationsLanguage() {
});
}

void fillTicketsGender() {
List<String> ticketIds = jdbc.queryForList("select uuid from ticket where status not in ('FREE','PENDING', 'PRE_RESERVED') and gender is null and tshirt_size is not null", new EmptySqlParameterSource(), String.class);
ticketIds.forEach(uuid -> transactionTemplate.execute(status -> {
Ticket ticket = ticketRepository.findByUUID(uuid);
String gender = ticket.getTshirtSize().endsWith("-F") ? "F" : "M";
jdbc.update("update ticket set gender = :gender where uuid = :uuid", new MapSqlParameterSource("uuid", uuid).addValue("gender", gender));
return null;
}));
}

private void fillDescriptions(Event event) {
int result = eventRepository.fillDisplayNameIfRequired(event.getId());
if(result > 0) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/alfio/model/FullTicketInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public FullTicketInfo(@Column("t_id") int id,
@Column("t_address") String address,
@Column("t_country") String country,
@Column("t_tshirt_size") String tshirtSize,
@Column("t_gender") String gender,
@Column("t_notes") String notes,
@Column("t_user_language") String userLanguage,
//
Expand Down Expand Up @@ -87,7 +88,7 @@ public FullTicketInfo(@Column("t_id") int id,

this.ticket = new Ticket(id, uuid, creation, categoryId, status, eventId, originalPriceInCents, paidPriceInCents,
ticketsReservationId, fullName, email, lockedAssignment, jobTitle, company, phoneNumber, address, country,
tshirtSize, notes, userLanguage);
tshirtSize, gender, notes, userLanguage);
this.ticketReservation = new TicketReservation(trId, trValidity, trStatus, trFullName, trEmail, trBillingAddress,
trConfirmationTimestamp, trLatestReminder, trPaymentMethod, trReminderSent, trPromoCodeDiscountId, trAutomatic, resUserLanguage);
this.ticketCategory = new TicketCategory(tcId, tcUtcInception, tcUtcExpiration, tcMaxTickets, tcName, tcDescription,
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/alfio/model/Ticket.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public enum TicketStatus {
private final String address;
private final String country;
private final String tshirtSize;
private final String gender;
private final String notes;
private final String userLanguage;

Expand All @@ -83,6 +84,7 @@ public Ticket(@Column("id") int id,
@Column("address") String address,
@Column("country") String country,
@Column("tshirt_size") String tshirtSize,
@Column("gender") String gender,
@Column("notes") String notes,
@Column("user_language") String userLanguage) {
this.id = id;
Expand All @@ -106,6 +108,7 @@ public Ticket(@Column("id") int id,
this.address = address;
this.country = country;
this.tshirtSize = tshirtSize;
this.gender = gender;
}

public boolean getAssigned() {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/alfio/repository/TicketRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,15 @@ public interface TicketRepository {
@Query("update ticket set locked_assignment = :lockedAssignment where id = :id and category_id = :categoryId")
int toggleTicketLocking(@Bind("id") int ticketId, @Bind("categoryId") int categoryId, @Bind("lockedAssignment") boolean locked);

@Query("update ticket set job_title = :jobTitle, company = :company, phone_number = :phoneNumber, address = :address, country = :country, tshirt_size = :tShirtSize, notes = :notes, user_language = :userLanguage where uuid = :ticketIdentifier")
@Query("update ticket set job_title = :jobTitle, company = :company, phone_number = :phoneNumber, address = :address, country = :country, tshirt_size = :tShirtSize, gender = :gender, notes = :notes, user_language = :userLanguage where uuid = :ticketIdentifier")
int updateOptionalTicketInfo(@Bind("ticketIdentifier") String ticketIdentifier,
@Bind("jobTitle") String jobTitle,
@Bind("company") String company,
@Bind("phoneNumber") String phoneNumber,
@Bind("address") String address,
@Bind("country") String country,
@Bind("tShirtSize") String tShirtSize,
@Bind("gender") String gender,
@Bind("notes") String notes,
@Bind("userLanguage") String userLanguage);

Expand All @@ -136,7 +137,7 @@ int updateOptionalTicketInfo(@Bind("ticketIdentifier") String ticketIdentifier,
" t.id t_id, t.uuid t_uuid, t.creation t_creation, t.category_id t_category_id, t.status t_status, t.event_id t_event_id," +
" t.original_price_cts t_original_price_cts, t.paid_price_cts t_paid_price_cts, t.tickets_reservation_id t_tickets_reservation_id," +
" t.full_name t_full_name, t.email_address t_email_address, t.locked_assignment t_locked_assignment, t.job_title t_job_title, t.company t_company," +
" t.phone_number t_phone_number, t.address t_address, t.country t_country, t.tshirt_size t_tshirt_size," +
" t.phone_number t_phone_number, t.address t_address, t.country t_country, t.tshirt_size t_tshirt_size, t.gender t_gender" +
" t.notes t_notes, t.user_language t_user_language," +
" tr.id tr_id, tr.validity tr_validity, tr.status tr_status, tr.full_name tr_full_name, tr.email_address tr_email_address, tr.billing_address tr_billing_address," +
" tr.confirmation_ts tr_confirmation_ts, tr.latest_reminder_ts tr_latest_reminder_ts, tr.payment_method tr_payment_method, tr.offline_payment_reminder_sent tr_offline_payment_reminder_sent, tr.promo_code_id_fk tr_promo_code_id_fk, tr.automatic tr_automatic, tr.user_language tr_user_language," +
Expand Down
1 change: 0 additions & 1 deletion src/main/java/alfio/util/EventUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import alfio.model.Ticket;
import alfio.model.TicketCategory;
import alfio.model.system.Configuration;
import alfio.model.system.ConfigurationKeys;
import lombok.experimental.UtilityClass;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--
-- This file is part of alf.io.
--
-- alf.io is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- alf.io is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with alf.io. If not, see <http://www.gnu.org/licenses/>.
--

alter table ticket ADD COLUMN gender VARCHAR(1);
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--
-- This file is part of alf.io.
--
-- alf.io is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- alf.io is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with alf.io. If not, see <http://www.gnu.org/licenses/>.
--

alter table ticket ADD COLUMN gender VARCHAR(1);
6 changes: 4 additions & 2 deletions src/main/resources/alfio/i18n/public.properties
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ reservation-page-complete.t-shirt-size=T-Shirt size
reservation-page-complete.notes=Notes
reservation-page-complete.notes.placeholder=Should you have any special need (such as but not limited to diet or accessibility requirements) please let us know
reservation-page-complete.please-check-input-fields=Please check input values.
reservation-page-complete.women=Women
reservation-page-complete.men=Men
reservation-page-complete.women=a woman
reservation-page-complete.men=a man
reservation-page-complete.other=Other
reservation-page-complete.i-am=I am
reservation-page-complete.confirm-cancellation.title=Confirm ticket cancellation
reservation-page-complete.confirm-cancellation.text=Your ticket will be invalidated and released. Are you sure?
reservation-page-complete.confirm-cancellation.button.yes=Yes
Expand Down
8 changes: 5 additions & 3 deletions src/main/resources/alfio/i18n/public_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ reservation-page-complete.t-shirt-size=T-Shirt-Gr\u00F6\u00DFe
reservation-page-complete.notes=Aufzeichnungen
reservation-page-complete.notes.placeholder=Gerne nehmen wir auf Ihre Bed\u00FCrfnisse R\u00FCcksicht, falls Sie aussergew\u00F6hnliche Essensgewohnheiten oder eingeschr\u00E4nkte Zutrittsm\u00F6glichkeiten haben. Informieren Sie uns bitte.
reservation-page-complete.please-check-input-fields=Bitte \u00FCberpr\u00FCfen Sie Ihre Eingabewerte.
reservation-page-complete.women=Frauen
reservation-page-complete.men=M\u00E4nner
reservation-page-complete.women=eine Frau
reservation-page-complete.men=einen Mann
reservation-page-complete.confirm-cancellation.title=Best\u00E4tigung der Ticketstornierung
reservation-page-complete.confirm-cancellation.text=Ihr Ticket wird f\u00FCr ung\u00FCltig erkl\u00E4rt und freigegeben werden. Sind Sie sicher?
reservation-page-complete.confirm-cancellation.button.yes=Ja
Expand Down Expand Up @@ -260,4 +260,6 @@ email-waiting-queue.subscribed.admin.subject=[{0}] In der Warteschlange eingetra
email-waiting-queue.subscribed.admin.text=Jemand trat der Warteschlange {0} bei {1}. Bitte \u00FCberpr\u00FCfen Sie die Admin-Anwendungen f\u00FCr weitere Details.
event-days.single-day.hours=von {0} bis {1}
show.optional.fields=Optionale Felder zeigen
hide.optional.fields=Optionale Felder verstecken
hide.optional.fields=Optionale Felder verstecken
reservation-page-complete.other=Andere
reservation-page-complete.i-am=Ich bin
1 change: 1 addition & 0 deletions src/main/resources/alfio/i18n/public_en.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
reservation-page-complete.other=
8 changes: 5 additions & 3 deletions src/main/resources/alfio/i18n/public_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ reminder.ticket-not-assigned.subject=Attenzione\! Non hai assegnato i biglietti
reminder.ticket-not-assigned.text=Questo \u00E8 un messaggio automatico da {0}.\nLa tua prenotazione n. {1} contiene uno o pi\u00F9 biglietti che non sono stati ancora assegnati.\nTieni presente che per accedere all''evento \u00E8 necessario che i biglietti siano stati assegnati ai partecipanti.\nPer assegnare i tuoi biglietti, per favore usa il seguente link\: {2} e segui le istruzioni.\nGrazie\!
reservation-page-complete.language=Lingua
email-confirmation.reservationURL=Puoi controllare/modificare la tua prenotazione qui\: {0}
reservation-page-complete.men=Uomini
reservation-page-complete.women=Donne
reservation-page-complete.men=un uomo
reservation-page-complete.women=una donna
reservation-page-complete.confirm-cancellation.text=Stai per annullare il tuo biglietto. Sei sicuro/a?
reservation-page-complete.confirm-cancellation.title=Conferma annullamento
reservation-page-complete.confirm-cancellation.button=Conferma
Expand All @@ -250,4 +250,6 @@ email-waiting-queue.subscribed.text=Come richiesto, abbiamo aggiunto il tuo nome
event-days.single-day.hours=dalle {0} alle {1}
show.optional.fields=Visualizza campi opzionali
hide.optional.fields=Nascondi campi opzionali
show.more=
show.more=
reservation-page-complete.other=Altro
reservation-page-complete.i-am=Sono
29 changes: 16 additions & 13 deletions src/main/webapp/WEB-INF/templates/event/assign-ticket-form.ms
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,27 @@
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="gender-{{uuid}}">{{#i18n}}reservation-page-complete.i-am{{/i18n}}</label>
<div class="col-sm-9">
<select name="gender" value="{{gender}}" class="form-control">
<option value=""></option>
<option value="F">{{#i18n}}reservation-page-complete.women{{/i18n}}</option>
<option value="M">{{#i18n}}reservation-page-complete.men{{/i18n}}</option>
<option value="X">{{#i18n}}reservation-page-complete.other{{/i18n}}</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="t-shirt-size-{{uuid}}">{{#i18n}}reservation-page-complete.t-shirt-size{{/i18n}}</label>
<div class="col-sm-9">
<select name="tShirtSize" value="{{tshirtSize}}" id="t-shirt-size-{{uuid}}" class="form-control">
<option value=""></option>
<optgroup label="{{#i18n}}reservation-page-complete.women{{/i18n}}">
<option value="SMALL-F">Small</option>
<option value="MEDIUM-F">Medium</option>
<option value="LARGE-F">Large</option>
<option value="X-LARGE-F">X-Large</option>
</optgroup>
<optgroup label="{{#i18n}}reservation-page-complete.men{{/i18n}}">
<option value="SMALL">Small</option>
<option value="MEDIUM">Medium</option>
<option value="LARGE">Large</option>
<option value="X-LARGE">X-Large</option>
<option value="2X-LARGE">2X-Large</option>
</optgroup>
<option value="SMALL">Small</option>
<option value="MEDIUM">Medium</option>
<option value="LARGE">Large</option>
<option value="X-LARGE">X-Large</option>
<option value="2X-LARGE">2X-Large</option>
</select>
</div>
</div>
Expand Down
Loading

0 comments on commit b667887

Please sign in to comment.