Commit 7aec1a31 authored by Luko van der Maas's avatar Luko van der Maas
Browse files

Merge branch 'fix/registration-uniqueness' into 'master'

Make member-event combination unique for event registrations

Closes #487

See merge request !1051
parents fa70c155 c02ad6c7
# Generated by Django 2.0.9 on 2018-11-11 16:12
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('members', '0027_auto_20181024_2000'),
('events', '0027_merge_20180618_1438'),
]
operations = [
migrations.AlterUniqueTogether(
name='registration',
unique_together={('member', 'event')},
),
]
......@@ -495,7 +495,7 @@ class Registration(models.Model):
class Meta:
ordering = ('date',)
unique_together = (('member', 'event', 'name', 'date_cancelled'),)
unique_together = (('member', 'event'),)
class RegistrationInformationField(models.Model, metaclass=ModelTranslateMeta):
......
......@@ -292,11 +292,12 @@ class RegistrationTest(TestCase):
map_location='test map location',
price=0.00,
fine=0.00)
cls.member = Member.objects.first()
cls.member1 = Member.objects.first()
cls.member2 = Member.objects.all()[1]
cls.r1 = Registration.objects.create(event=cls.event,
member=cls.member)
member=cls.member1)
cls.r2 = Registration.objects.create(event=cls.event,
member=cls.member)
member=cls.member2)
def setUp(self):
self.r1.refresh_from_db()
......@@ -328,13 +329,14 @@ class RegistrationTest(TestCase):
self.assertEqual(self.r2.queue_position, 1)
def test_registration_either_name_or_member(self):
self.r2.delete()
self.r1.clean()
r2 = Registration.objects.create(event=self.event, name='test name')
r2.clean()
with self.assertRaises(ValidationError):
r3 = Registration.objects.create(event=self.event,
name='test name',
member=self.member)
member=self.member2)
r3.clean()
def test_would_cancel_after_deadline(self):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment