diff --git a/dav_events/templates/dav_events/event_registrations.html b/dav_events/templates/dav_events/event_registrations.html
index 9944752..99c8330 100644
--- a/dav_events/templates/dav_events/event_registrations.html
+++ b/dav_events/templates/dav_events/event_registrations.html
@@ -491,17 +491,17 @@ Wichtig: das System verschickt keine Bestätigung an dich oder den neuen Teilneh
diff --git a/dav_events/views/events.py b/dav_events/views/events.py
index b9ccdb7..b4e21f8 100644
--- a/dav_events/views/events.py
+++ b/dav_events/views/events.py
@@ -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
diff --git a/dav_registration/migrations/0006_auto_20201203_1144.py b/dav_registration/migrations/0006_auto_20201203_1144.py
index 13d155a..a9f9bf4 100644
--- a/dav_registration/migrations/0006_auto_20201203_1144.py
+++ b/dav_registration/migrations/0006_auto_20201203_1144.py
@@ -27,10 +27,6 @@ class Migration(migrations.Migration):
'ordering': ['updated_at'],
},
),
- migrations.RemoveField(
- model_name='registration',
- name='answered',
- ),
migrations.AddField(
model_name='registrationstatus',
name='registration',
diff --git a/dav_registration/migrations/0007_auto_20201208_1853.py b/dav_registration/migrations/0007_auto_20201208_1853.py
new file mode 100644
index 0000000..4485362
--- /dev/null
+++ b/dav_registration/migrations/0007_auto_20201208_1853.py
@@ -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),
+ ]
diff --git a/dav_registration/migrations/0008_auto_20201208_1906.py b/dav_registration/migrations/0008_auto_20201208_1906.py
new file mode 100644
index 0000000..5495b04
--- /dev/null
+++ b/dav_registration/migrations/0008_auto_20201208_1906.py
@@ -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',
+ ),
+ ]
diff --git a/dav_registration/models.py b/dav_registration/models.py
index 38b614c..62737ef 100644
--- a/dav_registration/models.py
+++ b/dav_registration/models.py
@@ -72,6 +72,8 @@ class Registration(models.Model):
verbose_name=_('Einwilligung zur Datenspeicherung'))
purge_at = models.DateTimeField(_('Zeitpunkt der Datenlöschung'))
+ answered_obsolete = models.BooleanField(default=False, verbose_name=_('Durch Tourleitung beantwortet'))
+
@staticmethod
def pk2hexstr(pk):
return hex(pk * 113)[2:] # 113 has no meaning, but it produce nice looking hex codes.
@@ -154,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:
@@ -215,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()