Commit e9d3b8a3 authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

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

Fix registration problems

See merge request !864
parents 77d9b01c ae5f6288
...@@ -38,13 +38,16 @@ class RegistrationAdmin(admin.ModelAdmin): ...@@ -38,13 +38,16 @@ class RegistrationAdmin(admin.ModelAdmin):
'length', 'length',
'membership_type', 'membership_type',
'status', 'status',
'remarks',) 'payment',
'remarks')
}), }),
(_('Personal information'), { (_('Personal information'), {
'fields': ('first_name', 'fields': ('first_name',
'last_name', 'last_name',
'birthday', 'birthday',
'optin_birthday',
'email', 'email',
'optin_mailinglist',
'phone_number',) 'phone_number',)
}), }),
(_('Address'), { (_('Address'), {
...@@ -90,7 +93,7 @@ class RegistrationAdmin(admin.ModelAdmin): ...@@ -90,7 +93,7 @@ class RegistrationAdmin(admin.ModelAdmin):
def get_readonly_fields(self, request, obj=None): def get_readonly_fields(self, request, obj=None):
if obj is None or not (obj.status == Entry.STATUS_REJECTED or if obj is None or not (obj.status == Entry.STATUS_REJECTED or
obj.status == Entry.STATUS_ACCEPTED): obj.status == Entry.STATUS_ACCEPTED):
return ['status', 'created_at', 'updated_at'] return ['status', 'created_at', 'updated_at', 'payment']
else: else:
return [field.name for field in self.model._meta.get_fields() return [field.name for field in self.model._meta.get_fields()
if field.editable] if field.editable]
......
...@@ -122,6 +122,9 @@ def accept_entries(queryset): ...@@ -122,6 +122,9 @@ def accept_entries(queryset):
continue continue
payment = _create_payment_for_entry(entry) payment = _create_payment_for_entry(entry)
entry.refresh_from_db()
try: try:
if entry.registration.username is None: if entry.registration.username is None:
entry.registration.username = _generate_username( entry.registration.username = _generate_username(
......
...@@ -145,12 +145,14 @@ class RegistrationAdminTest(TestCase): ...@@ -145,12 +145,14 @@ class RegistrationAdminTest(TestCase):
request = _get_mock_request([]) request = _get_mock_request([])
fields = self.admin.get_readonly_fields(request) fields = self.admin.get_readonly_fields(request)
self.assertEqual(fields, ['status', 'created_at', 'updated_at']) self.assertEqual(fields, ['status', 'created_at',
'updated_at', 'payment'])
fields = self.admin.get_readonly_fields(request, Registration( fields = self.admin.get_readonly_fields(request, Registration(
status=Entry.STATUS_CONFIRM status=Entry.STATUS_CONFIRM
)) ))
self.assertEqual(fields, ['status', 'created_at', 'updated_at']) self.assertEqual(fields, ['status', 'created_at',
'updated_at', 'payment'])
fields = self.admin.get_readonly_fields(request, Registration( fields = self.admin.get_readonly_fields(request, Registration(
status=Entry.STATUS_REJECTED status=Entry.STATUS_REJECTED
...@@ -282,13 +284,14 @@ class RenewalAdminTest(TestCase): ...@@ -282,13 +284,14 @@ class RenewalAdminTest(TestCase):
request = _get_mock_request([]) request = _get_mock_request([])
fields = self.admin.get_readonly_fields(request) fields = self.admin.get_readonly_fields(request)
self.assertEqual(fields, ['status', 'created_at', 'updated_at']) self.assertEqual(fields, ['status', 'created_at',
'updated_at', 'payment'])
fields = self.admin.get_readonly_fields(request, Renewal( fields = self.admin.get_readonly_fields(request, Renewal(
status=Entry.STATUS_CONFIRM status=Entry.STATUS_CONFIRM
)) ))
self.assertEqual(fields, ['status', 'created_at', self.assertEqual(fields, ['status', 'created_at',
'updated_at', 'member']) 'updated_at', 'payment', 'member'])
fields = self.admin.get_readonly_fields(request, Renewal( fields = self.admin.get_readonly_fields(request, Renewal(
status=Entry.STATUS_REJECTED status=Entry.STATUS_REJECTED
......
...@@ -183,6 +183,11 @@ class ServicesTest(TestCase): ...@@ -183,6 +183,11 @@ class ServicesTest(TestCase):
rows_updated = services.accept_entries(Entry.objects.all()) rows_updated = services.accept_entries(Entry.objects.all())
self.e2.refresh_from_db() self.e2.refresh_from_db()
self.e3.refresh_from_db()
self.assertNotEqual(self.e2.payment, None)
self.assertNotEqual(self.e3.payment, None)
self.assertEqual(self.e2.username, 'ptest') self.assertEqual(self.e2.username, 'ptest')
self.assertEqual(rows_updated, 3) self.assertEqual(rows_updated, 3)
......
Markdown is supported
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