More work on planned publish date and internal note. improved event
detail page and some form code.
This commit is contained in:
@@ -648,25 +648,29 @@ class RegistrationForm(EventCreateForm):
|
||||
widget=forms.Textarea(attrs={'rows': 2}),
|
||||
)
|
||||
|
||||
def get_initial_for_field(self, field, field_name):
|
||||
value = super(RegistrationForm, self).get_initial_for_field(field, field_name)
|
||||
if field_name == 'registration_howto':
|
||||
trainer_fullname = u'%s %s' % (self._session_data.get('trainer_firstname'),
|
||||
self._session_data.get('trainer_familyname'))
|
||||
value = value % {'name': trainer_fullname, 'emailaddr': self._session_data.get('trainer_email')}
|
||||
elif field_name in ('min_participants', 'max_participants'):
|
||||
trainer_2 = bool(self._session_data.get('trainer_2_fullname', False))
|
||||
trainer_3 = bool(self._session_data.get('trainer_3_fullname', False))
|
||||
matrix_key, matrix_config = self._get_matrix_config(self._session_data)
|
||||
n_trainer = 1
|
||||
if trainer_2:
|
||||
n_trainer += 1
|
||||
if trainer_3:
|
||||
n_trainer += 1
|
||||
value = n_trainer * matrix_config[field_name]
|
||||
|
||||
return value
|
||||
|
||||
def _proceed_session_data(self, session_data):
|
||||
super(RegistrationForm, self)._proceed_session_data(session_data)
|
||||
|
||||
first_day = session_data.get('first_day', None)
|
||||
trainer_fullname = u'%s %s' % (session_data.get('trainer_firstname'), session_data.get('trainer_familyname'))
|
||||
trainer_email = session_data.get('trainer_email')
|
||||
trainer_2_fullname = session_data.get('trainer_2_fullname', None)
|
||||
trainer_3_fullname = session_data.get('trainer_3_fullname', None)
|
||||
|
||||
matrix_key, matrix_config = self._get_matrix_config(session_data)
|
||||
|
||||
n_trainer = 1
|
||||
if trainer_2_fullname:
|
||||
n_trainer += 1
|
||||
if trainer_3_fullname:
|
||||
n_trainer += 1
|
||||
|
||||
self.fields['min_participants'].initial = matrix_config['min_participants'] * n_trainer
|
||||
self.fields['max_participants'].initial = matrix_config['max_participants'] * n_trainer
|
||||
|
||||
if first_day:
|
||||
new_choices = []
|
||||
@@ -690,13 +694,6 @@ class RegistrationForm(EventCreateForm):
|
||||
new_choices.append((key, desc))
|
||||
self.fields['deadline'].choices = new_choices
|
||||
|
||||
if self.fields['registration_howto'].initial:
|
||||
initial = self.fields['registration_howto'].initial % {'name': trainer_fullname,
|
||||
'emailaddr': trainer_email}
|
||||
self.fields['registration_howto'].initial = initial
|
||||
else:
|
||||
self.fields['registration_howto'].widget = forms.HiddenInput()
|
||||
|
||||
|
||||
class ChargesForm(EventCreateForm):
|
||||
_form_title = _(u'Kosten')
|
||||
@@ -818,63 +815,59 @@ class ChargesForm(EventCreateForm):
|
||||
class SummaryForm(EventCreateForm):
|
||||
_form_title = _(u'Zusammenfassung')
|
||||
|
||||
publish_date = forms.CharField(disabled=True,
|
||||
initial=_(u'Unverzüglich'),
|
||||
label=_(u'Voraussichtliche Veröffentlichung'),
|
||||
)
|
||||
planned_publish_date = forms.DateField(required=False,
|
||||
label=_(u'Voraussichtliche Veröffentlichung'),
|
||||
widget=forms.HiddenInput())
|
||||
planned_publish_issue = forms.CharField(required=False)
|
||||
|
||||
def get_initial_for_field(self, field, field_name):
|
||||
value = super(SummaryForm, self).get_initial_for_field(field, field_name)
|
||||
if field_name == 'publish_date':
|
||||
max_participants = self._session_data.get('max_participants', 0)
|
||||
if max_participants:
|
||||
deadline = self._session_data.get('deadline', None)
|
||||
if deadline == 'OTHER':
|
||||
deadline = self._session_data.get('deadline_other', None)
|
||||
internal_note = forms.CharField(required=False,
|
||||
label=_(u'Bearbeitungshinweis'),
|
||||
help_text=_(u'Hier kannst du einen Hinweis'
|
||||
u' für Tourenreferenten und Redakteure eingeben.'),
|
||||
widget=forms.Textarea(attrs={'rows': 5}))
|
||||
|
||||
def _proceed_session_data(self, session_data):
|
||||
max_participants = self._session_data.get('max_participants', 0)
|
||||
if max_participants:
|
||||
deadline = self._session_data.get('deadline', None)
|
||||
if deadline == 'OTHER':
|
||||
deadline = self._session_data.get('deadline_other', None)
|
||||
else:
|
||||
deadline_field_name = 'deadline_%s' % deadline
|
||||
if deadline_field_name in self._session_data:
|
||||
deadline = self._session_data.get(deadline_field_name)
|
||||
else:
|
||||
deadline_field_name = 'deadline_%s' % deadline
|
||||
if deadline_field_name in self._session_data:
|
||||
deadline = self._session_data.get(deadline_field_name)
|
||||
else:
|
||||
raise Exception(deadline)
|
||||
logger.error('SummaryForm._proceed_session_data(): invalid value for deadline.')
|
||||
deadline = None
|
||||
|
||||
if deadline:
|
||||
publish_deadline = deadline - datetime.timedelta(app_config.settings.publish_before_deadline_days)
|
||||
else:
|
||||
first_day = self._session_data.get('first_day')
|
||||
publish_deadline = first_day - datetime.timedelta(app_config.settings.publish_before_begin_days)
|
||||
if deadline:
|
||||
publish_deadline = deadline - datetime.timedelta(app_config.settings.publish_before_deadline_days)
|
||||
else:
|
||||
first_day = self._session_data.get('first_day')
|
||||
publish_deadline = first_day - datetime.timedelta(app_config.settings.publish_before_begin_days)
|
||||
|
||||
today = datetime.date.today()
|
||||
today = datetime.date.today()
|
||||
|
||||
break_outer_loop = False
|
||||
for year in (today.year, today.year + 1):
|
||||
for issue in app_config.settings.publish_issues:
|
||||
if not ('issue' in issue and 'release' in issue and 'deadline' in issue):
|
||||
continue
|
||||
issue_name = issue['issue']
|
||||
issue_release_day = issue['release'][0]
|
||||
issue_release_month = issue['release'][1]
|
||||
issue_deadline_day = issue['deadline'][0]
|
||||
issue_deadline_month = issue['deadline'][1]
|
||||
break_outer_loop = False
|
||||
for year in (today.year, today.year + 1):
|
||||
for issue in app_config.settings.publish_issues:
|
||||
if not ('issue' in issue and 'release' in issue and 'deadline' in issue):
|
||||
logger.error('SummaryForm._proceed_session_data(): invalid configured issue.')
|
||||
continue
|
||||
|
||||
issue_release_date = datetime.date(year, issue_release_month, issue_release_day)
|
||||
if issue_release_date < today:
|
||||
continue
|
||||
issue_release = datetime.date(year, issue['release'][1], issue['release'][0])
|
||||
if issue_release < today:
|
||||
continue
|
||||
|
||||
issue_deadline_date = datetime.date(year, issue_deadline_month, issue_deadline_day)
|
||||
if issue_deadline_date > issue_release_date:
|
||||
issue_deadline_date = datetime.date(year - 1, issue_deadline_month, issue_deadline_day)
|
||||
issue_deadline = datetime.date(year, issue['deadline'][1], issue['deadline'][0])
|
||||
if issue_deadline > issue_release:
|
||||
issue_deadline = datetime.date(year - 1, issue['deadline'][1], issue['deadline'][0])
|
||||
|
||||
if publish_deadline > issue_release_date and today < issue_deadline_date:
|
||||
value = u'{issue} / {year} - {date}'.format(issue=issue_name,
|
||||
year=year,
|
||||
date=format_date(issue_release_date,
|
||||
'EEEE, d. MMMM yyyy',
|
||||
locale=get_language()[0:2]))
|
||||
break_outer_loop = True
|
||||
break
|
||||
|
||||
if break_outer_loop:
|
||||
if publish_deadline > issue_release and today < issue_deadline:
|
||||
self.fields['planned_publish_date'].initial = issue_release
|
||||
self.fields['planned_publish_issue'].initial = u'%s/%s' % (issue['issue'], year)
|
||||
break_outer_loop = True
|
||||
break
|
||||
|
||||
return value
|
||||
if break_outer_loop:
|
||||
break
|
||||
|
||||
30
dav_events/migrations/0014_auto_20180225_1757.py
Normal file
30
dav_events/migrations/0014_auto_20180225_1757.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.9 on 2018-02-25 17:57
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dav_events', '0013_auto_20180224_1401'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='event',
|
||||
name='internal_note',
|
||||
field=models.TextField(blank=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='event',
|
||||
name='planned_publish_date',
|
||||
field=models.DateField(blank=True, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='oneclickaction',
|
||||
name='command',
|
||||
field=models.CharField(choices=[(b'EA', b'accept event'), (b'EP', b'report publishing of an event'), (b'EL', b'login and go to event list')], max_length=2),
|
||||
),
|
||||
]
|
||||
@@ -162,6 +162,11 @@ class Event(models.Model):
|
||||
additional_costs = models.CharField(max_length=config.ADDITIONAL_COSTS_MAX_LENGTH,
|
||||
blank=True)
|
||||
|
||||
# SummaryForm
|
||||
planned_publish_date = models.DateField(blank=True,
|
||||
null=True)
|
||||
internal_note = models.TextField(blank=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _(u'Veranstaltung')
|
||||
verbose_name_plural = _(u'Veranstaltungen')
|
||||
@@ -408,6 +413,8 @@ class Event(models.Model):
|
||||
'trainer_3_email': self.trainer_3_email,
|
||||
'trainer_3_phone': self.trainer_3_phone,
|
||||
'registration_howto': self.registration_howto,
|
||||
'planned_publish_date': self.planned_publish_date,
|
||||
'internal_note': self.internal_note,
|
||||
}
|
||||
return context
|
||||
|
||||
|
||||
@@ -2,6 +2,17 @@
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<div class="pull-right">
|
||||
{% if status == 'expired' %}
|
||||
<span class="label label-info">{% trans 'Ausgelaufen' %}</span>
|
||||
{% elif status == 'published' %}
|
||||
<span class="label label-success">{% trans 'Veröffentlicht' %}</span>
|
||||
{% elif status == 'accepted' %}
|
||||
<span class="label label-warning">{% trans 'Freigegeben' %}</span>
|
||||
{% elif status == 'submitted' %}
|
||||
<span class="label label-danger">{% trans 'Eingereicht' %}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<span class="panel-title">{{ number }} - {{ title }}</span>
|
||||
</div>
|
||||
<ul class="list-group">
|
||||
|
||||
@@ -3,10 +3,26 @@
|
||||
{% load i18n %}
|
||||
|
||||
{% block form-fields-visible %}
|
||||
{{ event.render_as_html }}
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
{% bootstrap_field form.publish_date %}
|
||||
<div class="col-sm-8">
|
||||
{{ event.render_as_html }}
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<label>{{ form.planned_publish_date.label }}</label>
|
||||
{% if form.planned_publish_date.value %}
|
||||
<p>{{ form.planned_publish_date.value|date:'l, d. F Y' }} ({{ form.planned_publish_issue.value }})</p>
|
||||
{% else %}
|
||||
<p>{% trans 'In wenigen Tagen' %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
{% bootstrap_field form.internal_note %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock form-fields-visible %}
|
||||
|
||||
@@ -113,57 +113,67 @@
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-sm-9">
|
||||
<div class="col-sm-5">
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
<strong>{% trans 'Eingereicht' %}:</strong>
|
||||
<div class="col-sm-4">
|
||||
<span class="text-danger">{% bootstrap_icon 'check' %}</span>
|
||||
 <strong>{% trans 'Eingereicht' %}:</strong>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<div class="col-sm-8">
|
||||
{{ event.created_at|date:'l, d. F Y, H:i' }} {% trans 'Uhr' %}<br />
|
||||
{% trans 'von' %} {{ event.owner.get_full_name }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
<strong>{% trans 'Freigegeben' %}:</strong>
|
||||
<div class="col-sm-4">
|
||||
{% if event.accepted %}
|
||||
<span class="text-warning">{% bootstrap_icon 'check' %}</span>
|
||||
{% else %}
|
||||
{% bootstrap_icon 'unchecked' %}
|
||||
{% endif %}
|
||||
 <strong>{% trans 'Freigegeben' %}:</strong>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<div class="col-sm-8">
|
||||
{% if event.accepted %}
|
||||
{{ event.accepted_at|date:'l, d. F Y, H:i' }} {% trans 'Uhr' %}<br />
|
||||
{% trans 'von' %} {{ event.accepted_by.get_full_name }}
|
||||
{% else %}
|
||||
-
|
||||
<br /><br />
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
<strong>{% trans 'Veröffentlicht' %}:</strong>
|
||||
<div class="col-sm-4">
|
||||
{% if event.published %}
|
||||
<span class="text-success">{% bootstrap_icon 'check' %}</span>
|
||||
{% else %}
|
||||
{% bootstrap_icon 'unchecked' %}
|
||||
{% endif %}
|
||||
 <strong>{% trans 'Veröffentlicht' %}:</strong>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<div class="col-sm-8">
|
||||
{% if event.published %}
|
||||
{{ event.published_at|date:'l, d. F Y, H:i' }} {% trans 'Uhr' %}<br />
|
||||
{% trans 'von' %} {{ event.published_by.get_full_name }}
|
||||
{% else %}
|
||||
-
|
||||
<br /><br />
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3">
|
||||
<div class="pull-right">
|
||||
{% if event.get_status == 'expired' %}
|
||||
<span class="label label-info">{% trans 'Ausgelaufen' %}</span>
|
||||
{% elif event.get_status == 'published' %}
|
||||
<span class="label label-success">{% trans 'Veröffentlicht' %}</span>
|
||||
{% elif event.get_status == 'accepted' %}
|
||||
<span class="label label-warning">{% trans 'Freigegeben' %}</span>
|
||||
{% elif event.get_status == 'submitted' %}
|
||||
<span class="label label-danger">{% trans 'Eingereicht' %}</span>
|
||||
{% else %}
|
||||
<span class="label label-default">{% trans 'Kaputt' %} ({{ event.get_status }})</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<strong>{% trans 'Veröffentlichen' %}</strong><br />
|
||||
{% if event.planned_publish_date %}
|
||||
{{ event.planned_publish_date|date:'l, d. F Y' }}
|
||||
{% else %}
|
||||
{% trans 'Sofort' %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
{% if event.internal_note %}
|
||||
<strong>{% trans 'Bearbeitungshinweis' %}</strong>
|
||||
<div class="well well-sm"><small>{{ event.internal_note|linebreaksbr }}</small></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user