This commit is contained in:
@@ -491,17 +491,17 @@ Wichtig: das System verschickt keine Bestätigung an dich oder den neuen Teilneh
|
||||
<button disabled="disabled"
|
||||
class="btn btn-link no-padding" title="Bei dieser Anmeldung hast du bereits
|
||||
am {{ registration.status.updated_at|date:'d. F Y, G:i' }}
|
||||
auf {% if registration.status.accepted %}Plus{% else %}Minus{% endif %} geklickt.
|
||||
auf {% if registration.status.accepted == True %}Plus{% elif registration.status.accepted == False %}Minus{% else %}Plus oder Minus{% endif %} geklickt.
|
||||
">
|
||||
<span class="{% if registration.status.accepted %}text-success{% else %}text-muted{% endif %}">{% bootstrap_icon 'plus-sign' %}</span>
|
||||
<span class="{% if registration.status.accepted == True %}text-success{% else %}text-muted{% endif %}">{% bootstrap_icon 'plus-sign' %}</span>
|
||||
</button>
|
||||
|
||||
<button disabled="disabled"
|
||||
class="btn btn-link no-padding" title="Bei dieser Anmeldung hast du bereits
|
||||
am {{ registration.status.updated_at|date:'d. F Y, G:i' }}
|
||||
auf {% if registration.status.accepted %}Plus{% else %}Minus{% endif %} geklickt.
|
||||
auf {% if registration.status.accepted == True %}Plus{% elif registration.status.accepted == False %}Minus{% else %}Plus oder Minus{% endif %} geklickt.
|
||||
">
|
||||
<span class="{% if not registration.status.accepted %}text-danger{% else %}text-muted{% endif %}">{% bootstrap_icon 'minus-sign' %}</span>
|
||||
<span class="{% if registration.status.accepted == False %}text-danger{% else %}text-muted{% endif %}">{% bootstrap_icon 'minus-sign' %}</span>
|
||||
</button>
|
||||
|
||||
<span class="text-muted">
|
||||
|
||||
@@ -293,16 +293,14 @@ class EventRegistrationsView(EventPermissionMixin, generic.DetailView):
|
||||
'purge_at': registration.purge_at,
|
||||
}
|
||||
participant = models.Participant.objects.create(**data)
|
||||
registration.accepted()
|
||||
registration.status.set_accepted()
|
||||
messages.success(request, _(u'Teilnehmer hinzugefügt: {}'.format(participant.get_full_name())))
|
||||
|
||||
def _reject_registration(self, registration):
|
||||
registration.rejected()
|
||||
registration.status.set_rejected()
|
||||
|
||||
def _reset_registration(self, registration):
|
||||
registration.status.accepted = None
|
||||
registration.status.answered = False
|
||||
registration.status.save()
|
||||
registration.status.reset()
|
||||
|
||||
def _swap_participants_position(self, participant1, participant2):
|
||||
event = participant1.event
|
||||
|
||||
@@ -27,11 +27,6 @@ class Migration(migrations.Migration):
|
||||
'ordering': ['updated_at'],
|
||||
},
|
||||
),
|
||||
migrations.RenameField(
|
||||
model_name='registration',
|
||||
old_name='answered',
|
||||
new_name='answered_2migrate',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='registrationstatus',
|
||||
name='registration',
|
||||
|
||||
26
dav_registration/migrations/0007_auto_20201208_1853.py
Normal file
26
dav_registration/migrations/0007_auto_20201208_1853.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-12-08 17:53
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def migrate_registration_status(apps, schema_editor):
|
||||
Registration = apps.get_model('dav_registration', 'Registration')
|
||||
RegistrationStatus = apps.get_model('dav_registration', 'RegistrationStatus')
|
||||
db_alias = schema_editor.connection.alias
|
||||
for r in Registration.objects.using(db_alias).all():
|
||||
s = RegistrationStatus(registration=r)
|
||||
s.answered = r.answered
|
||||
s.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dav_registration', '0006_auto_20201203_1144'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(migrate_registration_status),
|
||||
]
|
||||
20
dav_registration/migrations/0008_auto_20201208_1906.py
Normal file
20
dav_registration/migrations/0008_auto_20201208_1906.py
Normal file
@@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.29 on 2020-12-08 18:06
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('dav_registration', '0007_auto_20201208_1853'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='registration',
|
||||
old_name='answered',
|
||||
new_name='answered_obsolete',
|
||||
),
|
||||
]
|
||||
@@ -72,7 +72,7 @@ class Registration(models.Model):
|
||||
verbose_name=_('Einwilligung zur Datenspeicherung'))
|
||||
purge_at = models.DateTimeField(_('Zeitpunkt der Datenlöschung'))
|
||||
|
||||
answered_2migrate = models.BooleanField(default=False, verbose_name=_('Durch Tourleitung beantwortet'))
|
||||
answered_obsolete = models.BooleanField(default=False, verbose_name=_('Durch Tourleitung beantwortet'))
|
||||
|
||||
@staticmethod
|
||||
def pk2hexstr(pk):
|
||||
@@ -156,24 +156,6 @@ Anmerkung:
|
||||
logger.info('Registration stored: %s', self)
|
||||
signals.registration_created.send(sender=self.__class__, registration=self)
|
||||
|
||||
def answered(self, accepted):
|
||||
if accepted is not True and accepted is not False:
|
||||
raise ValueError('boolean parameter expected')
|
||||
if hasattr(self, 'status'):
|
||||
status = self.status
|
||||
else:
|
||||
status = RegistrationStatus(registration=self)
|
||||
|
||||
status.accepted = accepted
|
||||
status.answered = True
|
||||
status.save()
|
||||
|
||||
def accepted(self):
|
||||
return self.answered(accepted=True)
|
||||
|
||||
def rejected(self):
|
||||
return self.answered(accepted=False)
|
||||
|
||||
@classmethod
|
||||
def calc_purge_at(cls, event):
|
||||
if event.alt_last_day:
|
||||
@@ -217,11 +199,24 @@ class RegistrationStatus(models.Model):
|
||||
return '{} (Updated: {})'.format(self.registration, self.updated_at.strftime('%d.%m.%Y %H:%M:%S'))
|
||||
|
||||
def clean(self):
|
||||
if self.answered and self.accepted is None:
|
||||
raise ValidationError({'accepted': 'if answered is true, accepted must not be none'})
|
||||
elif not self.answered and self.accepted is not None:
|
||||
raise ValidationError({'answered': 'if answered is false, accepted must be none'})
|
||||
if self.accepted is not None and self.answered is not True:
|
||||
raise ValidationError({'answered': 'if accepted is not None, answered must be True'})
|
||||
|
||||
def save(self, **kwargs):
|
||||
self.full_clean()
|
||||
super(RegistrationStatus, self).save(**kwargs)
|
||||
|
||||
def set_accepted(self):
|
||||
self.accepted = True
|
||||
self.answered = True
|
||||
self.save()
|
||||
|
||||
def set_rejected(self):
|
||||
self.accepted = False
|
||||
self.answered = True
|
||||
self.save()
|
||||
|
||||
def reset(self):
|
||||
self.accepted = None
|
||||
self.answered = False
|
||||
self.save()
|
||||
|
||||
Reference in New Issue
Block a user