forked from CGM_Public/pretix_original
Allow to define ticket validity through a product (#3105)
This commit is contained in:
@@ -618,6 +618,14 @@ class ItemUpdateForm(I18nModelForm):
|
||||
"admission ticket. Otherwise customers might not be able to use the membership later. If you "
|
||||
"want the membership to be non-personalized, set the membership type to be transferable.")
|
||||
)
|
||||
|
||||
if d.get('validity_mode') == Item.VALIDITY_MODE_FIXED and d.get('validity_fixed_from') and d.get('validity_fixed_until'):
|
||||
if d.get('validity_fixed_from') > d.get('validity_fixed_until'):
|
||||
self.add_error(
|
||||
'validity_fixed_from',
|
||||
_("The start of validity must be before the end of validity.")
|
||||
)
|
||||
|
||||
return d
|
||||
|
||||
def clean_picture(self):
|
||||
@@ -667,10 +675,21 @@ class ItemUpdateForm(I18nModelForm):
|
||||
'grant_membership_duration_like_event',
|
||||
'grant_membership_duration_days',
|
||||
'grant_membership_duration_months',
|
||||
'validity_mode',
|
||||
'validity_fixed_from',
|
||||
'validity_fixed_until',
|
||||
'validity_dynamic_duration_minutes',
|
||||
'validity_dynamic_duration_hours',
|
||||
'validity_dynamic_duration_days',
|
||||
'validity_dynamic_duration_months',
|
||||
'validity_dynamic_start_choice',
|
||||
'validity_dynamic_start_choice_day_limit',
|
||||
]
|
||||
field_classes = {
|
||||
'available_from': SplitDateTimeField,
|
||||
'available_until': SplitDateTimeField,
|
||||
'validity_fixed_from': SplitDateTimeField,
|
||||
'validity_fixed_until': SplitDateTimeField,
|
||||
'hidden_if_available': SafeModelChoiceField,
|
||||
'grant_membership_type': SafeModelChoiceField,
|
||||
'require_membership_types': SafeModelMultipleChoiceField,
|
||||
@@ -678,6 +697,8 @@ class ItemUpdateForm(I18nModelForm):
|
||||
widgets = {
|
||||
'available_from': SplitDateTimePickerWidget(),
|
||||
'available_until': SplitDateTimePickerWidget(attrs={'data-date-after': '#id_available_from_0'}),
|
||||
'validity_fixed_from': SplitDateTimePickerWidget(),
|
||||
'validity_fixed_until': SplitDateTimePickerWidget(attrs={'data-date-after': '#id_validity_fixed_from_0'}),
|
||||
'require_membership_types': forms.CheckboxSelectMultiple(attrs={
|
||||
'class': 'scrolling-multiple-choice'
|
||||
}),
|
||||
|
||||
@@ -176,14 +176,55 @@
|
||||
</fieldset>
|
||||
{% endfor %}
|
||||
<fieldset>
|
||||
<legend>{% trans "Tickets & check-in" %}</legend>
|
||||
<legend>{% trans "Tickets & Badges" %}</legend>
|
||||
{% bootstrap_field form.generate_tickets layout="control" %}
|
||||
{% for f in plugin_forms %}
|
||||
{% if f.is_layouts %}
|
||||
{% bootstrap_form f layout="control" %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{% trans "Check-in & Validity" %}</legend>
|
||||
{% bootstrap_field form.checkin_attention layout="control" %}
|
||||
{% bootstrap_field form.validity_mode layout="control" %}
|
||||
<div data-display-dependency="#{{ form.validity_mode.id_for_label }}" data-display-dependency-value="fixed">
|
||||
{% bootstrap_field form.validity_fixed_from layout="control" %}
|
||||
{% bootstrap_field form.validity_fixed_until layout="control" %}
|
||||
</div>
|
||||
<div data-display-dependency="#{{ form.validity_mode.id_for_label }}" data-display-dependency-value="dynamic">
|
||||
<div class="form-group metadata-group">
|
||||
<label class="col-md-3 control-label">{% trans "Duration" %}</label>
|
||||
<div class="col-md-9">
|
||||
{% trans "minutes" as t_minutes %}
|
||||
{% trans "hours" as t_hours %}
|
||||
{% trans "days" as t_days %}
|
||||
{% trans "months" as t_months %}
|
||||
{% trans "years" as t_years %}
|
||||
{% bootstrap_field form.validity_dynamic_duration_months layout="control" addon_after=t_months horizontal_field_class="" horizontal_label_class="sr-only" %}
|
||||
{% bootstrap_field form.validity_dynamic_duration_days layout="control" addon_after=t_days addon_before="+" horizontal_field_class="" horizontal_label_class="sr-only" %}
|
||||
{% bootstrap_field form.validity_dynamic_duration_hours layout="control" addon_after=t_hours addon_before="+" horizontal_field_class="" horizontal_label_class="sr-only" %}
|
||||
{% bootstrap_field form.validity_dynamic_duration_minutes layout="control" addon_after=t_minutes addon_before="+" horizontal_field_class="" horizontal_label_class="sr-only" %}
|
||||
<div class="help-block">
|
||||
{% blocktrans trimmed %}
|
||||
If you select a duration given in days, months or years, the validity will always end at the
|
||||
end of a full day (midnight), plus the number of minutes and hours selected above.
|
||||
The start date is included in the calculation, so if you enter "1 day", the ticket
|
||||
will be valid until the end of the day it starts on.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% bootstrap_field form.validity_dynamic_start_choice layout="control" %}
|
||||
<div data-display-dependency="#{{ form.validity_dynamic_start_choice.id_for_label }}">
|
||||
{% trans "days" as t_days %}
|
||||
{% bootstrap_field form.validity_dynamic_start_choice_day_limit addon_after=t_days layout="control" %}
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>{% trans "Additional settings" %}</legend>
|
||||
{% bootstrap_field form.issue_giftcard layout="control" %}
|
||||
{% bootstrap_field form.show_quota_left layout="control" %}
|
||||
{% if form.grant_membership_type %}
|
||||
{% bootstrap_field form.grant_membership_type layout="control" %}
|
||||
<div data-display-dependency="#id_grant_membership_type">
|
||||
@@ -206,8 +247,11 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% bootstrap_field form.show_quota_left layout="control" %}
|
||||
{% for f in plugin_forms %}
|
||||
{% bootstrap_form f layout="control" %}
|
||||
{% if not f.is_layouts %}
|
||||
{% bootstrap_form f layout="control" %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
@@ -236,7 +236,7 @@
|
||||
{% if position.valid_from %}
|
||||
<br />
|
||||
{% endif %}
|
||||
{% blocktrans trimmed with datetime=position.valid_from|date:"SHORT_DATETIME_FORMAT" %}
|
||||
{% blocktrans trimmed with datetime=position.valid_until|date:"SHORT_DATETIME_FORMAT" %}
|
||||
Valid until {{ datetime }}
|
||||
{% endblocktrans %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{% extends "pretixcontrol/event/base.html" %}
|
||||
{% load i18n %}
|
||||
{% load bootstrap3 %}
|
||||
{% load daterange %}
|
||||
{% load eventurl %}
|
||||
{% load money %}
|
||||
{% load rich_text %}
|
||||
@@ -446,8 +447,8 @@
|
||||
<dd>
|
||||
<span class="fa fa-clock-o fa-fw" aria-hidden="true"></span>
|
||||
{% if line.valid_from and line.valid_until %}
|
||||
{% blocktrans trimmed with datetime_from=line.valid_from|date:"SHORT_DATETIME_FORMAT" datetime_until=line.valid_until|date:"SHORT_DATETIME_FORMAT" %}
|
||||
Valid from {{ datetime_from }} until {{ datetime_until }}
|
||||
{% blocktrans trimmed with datetime_range=line.valid_from|datetimerange:line.valid_until %}
|
||||
Valid {{ datetime_range }}
|
||||
{% endblocktrans %}
|
||||
{% elif line.valid_from %}
|
||||
{% blocktrans trimmed with datetime=line.valid_from|date:"SHORT_DATETIME_FORMAT" %}
|
||||
|
||||
Reference in New Issue
Block a user