Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
thalia
concrexit
Commits
41024626
Verified
Commit
41024626
authored
Feb 03, 2018
by
Sébastiaan Versteeg
Browse files
Add inline for pizza events to events app
parent
af14f498
Changes
1
Hide whitespace changes
Inline
Side-by-side
website/events/admin.py
View file @
41024626
...
...
@@ -10,6 +10,7 @@ from django.utils.translation import ugettext_lazy as _
from
events
import
services
from
members.models
import
Member
from
pizzas.models
import
PizzaEvent
from
utils.translation
import
TranslatedModelAdmin
from
.
import
forms
,
models
...
...
@@ -48,9 +49,15 @@ class RegistrationInformationFieldInline(admin.StackedInline):
return
formset
class
PizzaEventInline
(
admin
.
StackedInline
):
model
=
PizzaEvent
extra
=
0
max_num
=
1
@
admin
.
register
(
models
.
Event
)
class
EventAdmin
(
DoNextModelAdmin
):
inlines
=
(
RegistrationInformationFieldInline
,)
inlines
=
(
RegistrationInformationFieldInline
,
PizzaEventInline
,
)
fields
=
(
'title'
,
'description'
,
'start'
,
'end'
,
'organiser'
,
'category'
,
'registration_start'
,
'registration_end'
,
'cancel_deadline'
,
'send_cancel_email'
,
'location'
,
'map_location'
,
'price'
,
'fine'
,
...
...
@@ -123,9 +130,13 @@ class EventAdmin(DoNextModelAdmin):
"""Save formsets with their order"""
formset
.
save
()
informationfield_forms
=
(
x
for
x
in
formset
.
forms
if
isinstance
(
x
,
forms
.
RegistrationInformationFieldForm
)
)
form
.
instance
.
set_registrationinformationfield_order
([
f
.
instance
.
pk
for
f
in
sorted
(
form
set
.
forms
,
for
f
in
sorted
(
in
form
ationfield_
forms
,
key
=
lambda
x
:
(
x
.
cleaned_data
[
'order'
],
x
.
instance
.
pk
))
])
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment