Multi-line location field, new field for admission time

This commit is contained in:
Raphael Michel
2017-05-10 12:58:57 +02:00
parent c9ae65a9a8
commit aac05727ed
10 changed files with 126 additions and 22 deletions

View File

@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-05-10 10:27
from __future__ import unicode_literals
import i18nfield.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pretixbase', '0059_checkin_nonce'),
]
operations = [
migrations.AddField(
model_name='event',
name='date_admission',
field=models.DateTimeField(blank=True, null=True, verbose_name='Admission time'),
),
migrations.AlterField(
model_name='event',
name='location',
field=i18nfield.fields.I18nTextField(blank=True, max_length=200, null=True, verbose_name='Location'),
),
]

View File

@@ -13,7 +13,7 @@ from django.template.defaultfilters import date as _date
from django.utils.crypto import get_random_string
from django.utils.timezone import make_aware, now
from django.utils.translation import ugettext_lazy as _
from i18nfield.fields import I18nCharField
from i18nfield.fields import I18nCharField, I18nTextField
from pretix.base.email import CustomSMTPBackend
from pretix.base.models.base import LoggedModel
@@ -85,6 +85,8 @@ class Event(LoggedModel):
date_from = models.DateTimeField(verbose_name=_("Event start time"))
date_to = models.DateTimeField(null=True, blank=True,
verbose_name=_("Event end time"))
date_admission = models.DateTimeField(null=True, blank=True,
verbose_name=_("Admission time"))
is_public = models.BooleanField(default=False,
verbose_name=_("Visible in public lists"),
help_text=_("If selected, this event may show up on the ticket system's start page "
@@ -99,7 +101,7 @@ class Event(LoggedModel):
verbose_name=_("Start of presale"),
help_text=_("No products will be sold before this date."),
)
location = I18nCharField(
location = I18nTextField(
null=True, blank=True,
max_length=200,
verbose_name=_("Location"),

View File

@@ -143,6 +143,7 @@ class EventUpdateForm(I18nModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['slug'].widget.attrs['readonly'] = 'readonly'
self.fields['location'].widget.attrs['rows'] = '3'
class Meta:
model = Event
@@ -153,6 +154,7 @@ class EventUpdateForm(I18nModelForm):
'currency',
'date_from',
'date_to',
'date_admission',
'is_public',
'presale_start',
'presale_end',
@@ -161,6 +163,7 @@ class EventUpdateForm(I18nModelForm):
widgets = {
'date_from': forms.DateTimeInput(attrs={'class': 'datetimepicker'}),
'date_to': forms.DateTimeInput(attrs={'class': 'datetimepicker', 'data-date-after': '#id_date_from'}),
'date_admission': forms.DateTimeInput(attrs={'class': 'datetimepicker'}),
'presale_start': forms.DateTimeInput(attrs={'class': 'datetimepicker'}),
'presale_end': forms.DateTimeInput(attrs={'class': 'datetimepicker',
'data-date-after': '#id_presale_start'}),

View File

@@ -12,6 +12,7 @@
{% bootstrap_field form.date_from layout="horizontal" %}
{% bootstrap_field form.date_to layout="horizontal" %}
{% bootstrap_field form.location layout="horizontal" %}
{% bootstrap_field form.date_admission layout="horizontal" %}
{% bootstrap_field form.currency layout="horizontal" %}
{% bootstrap_field form.is_public layout="horizontal" %}
</fieldset>

View File

@@ -1,3 +1,4 @@
# Date according to https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
SHORT_DATE_FORMAT = 'Y-m-d'
SHORT_DATETIME_FORMAT = 'Y-m-d H:i'
TIME_FORMAT = 'H:i'

View File

@@ -82,7 +82,7 @@ class PdfTicketOutput(BaseTicketOutput):
elif o['content'] == 'event_name':
return str(order.event)
elif o['content'] == 'event_location':
return str(order.event.location)
return str(order.event.location).replace("\n", "<br/>\n")
elif o['content'] == 'event_date':
return order.event.get_date_from_display(show_times=False)
elif o['content'] == 'event_begin_time':

View File

@@ -28,7 +28,8 @@
<div class="col-md-4 col-xs-12">
<form method="post" data-asynctask action="{% eventurl request.event "presale:event.cart.clear" %}">
{% csrf_token %}
<button class="btn btn-block btn-default btn-lg" type="submit"><i class="fa fa-close"></i> {% trans "Empty cart" %}</button>
<button class="btn btn-block btn-default btn-lg" type="submit">
<i class="fa fa-close"></i> {% trans "Empty cart" %}</button>
</form>
</div>
<div class="col-md-4 col-md-offset-4 col-xs-12">
@@ -66,15 +67,57 @@
{% endif %}
<div>
{% if frontpage_text %}
<div>
{{ frontpage_text|rich_text }}
</div>
<div>
{{ frontpage_text|rich_text }}
</div>
{% endif %}
<p class="text-right">
<a href="{% eventurl event "presale:event.ical.download" %}" class="btn btn-link btn-xs">
<i class="fa fa-calendar"></i> {% trans "Add to Calendar" %}
</a>
</p>
{% if event.location %}
<div class="info-row">
<span class="fa fa-map-marker fa-fw"></span>
<p>
{{ event.location|linebreaksbr }}
</p>
</div>
{% endif %}
{% if event.settings.show_times or event.date_admission %}
<div class="info-row">
<span class="fa fa-clock-o fa-fw"></span>
<p>
{% if event.settings.show_times %}
{% blocktrans trimmed with time=event.date_from|date:"TIME_FORMAT" %}
Begin: {{ time }}
{% endblocktrans %}
{% endif %}
{% if event.date_admission and event.settings.show_times %}
<br>
{% endif %}
{% if event.date_admission %}
{% if event.date_admission|date:"SHORT_DATE_FORMAT" == event.date_from|date:"SHORT_DATE_FORMAT" %}
{% blocktrans trimmed with time=event.date_admission|date:"TIME_FORMAT" %}
Admission: {{ time }}
{% endblocktrans %}
{% else %}
{% blocktrans trimmed with datetime=event.date_admission|date:"SHORT_DATETIME_FORMAT" %}
Admission: {{ datetime }}
{% endblocktrans %}
{% endif %}
{% endif %}
<br>
<a href="{% eventurl event "presale:event.ical.download" %}">
<i class="fa fa-calendar"></i> {% trans "Add to Calendar" %}
</a>
</p>
</div>
{% else %}
<p class="text-right">
<a href="{% eventurl event "presale:event.ical.download" %}" class="btn-xs">
<i class="fa fa-calendar"></i> {% trans "Add to Calendar" %}
</a>
</p>
{% endif %}
</div>
{% eventsignal event "pretix.presale.signals.front_page_top" %}
@@ -112,11 +155,13 @@
</div>
{% endif %}
{% if item.min_per_order %}
<p><small>
{% blocktrans trimmed with num=item.min_per_order %}
minimum amount to order: {{ num }}
{% endblocktrans %}
</small></p>
<p>
<small>
{% blocktrans trimmed with num=item.min_per_order %}
minimum amount to order: {{ num }}
{% endblocktrans %}
</small>
</p>
{% endif %}
</div>
<div class="col-md-2 col-xs-6 price">
@@ -222,11 +267,13 @@
{% include "pretixpresale/event/fragment_quota_left.html" with avail=item.cached_availability %}
{% endif %}
{% if item.min_per_order %}
<p><small>
{% blocktrans trimmed with num=item.min_per_order %}
minimum amount to order: {{ num }}
{% endblocktrans %}
</small></p>
<p>
<small>
{% blocktrans trimmed with num=item.min_per_order %}
minimum amount to order: {{ num }}
{% endblocktrans %}
</small>
</p>
{% endif %}
</div>
<div class="col-md-2 col-xs-6 price">

View File

@@ -10,6 +10,7 @@ from django.db.models import Count, Prefetch, Q
from django.http import Http404, HttpResponse
from django.shortcuts import redirect
from django.utils.decorators import method_decorator
from django.utils.formats import date_format
from django.utils.functional import cached_property
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
@@ -149,6 +150,11 @@ class EventIcalDownload(EventViewMixin, View):
else:
vevent.add('dtend').value = event.date_to.astimezone(self.event_timezone).date()
if event.date_admission:
vevent.add('description').value = str(_('Admission: {datetime}')).format(
datetime=date_format(event.date_admission.astimezone(self.event_timezone), 'SHORT_DATETIME_FORMAT')
)
resp = HttpResponse(cal.serialize(), content_type='text/calendar')
resp['Content-Disposition'] = 'attachment; filename="{}-{}.ics"'.format(
event.organizer.slug, event.slug

View File

@@ -116,6 +116,22 @@ body.loading .container {
-webkit-transition: opacity .5s ease-in-out;
}
.info-row {
& > .fa {
font-size: 26px;
color: $brand-primary;
float: left;
margin-top: 3px;
}
p {
min-height: 30px;
margin-left: 40px;
}
p:first-child {
margin-top: 0;
}
}
@media (min-width: $screen-md-min) {
.thank-you {
min-height: 170px;

View File

@@ -1,5 +1,7 @@
from datetime import date
from django.utils import translation
from pretix.helpers.daterange import daterange