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