2017-07-15 14:48:30 +00:00
|
|
|
from django.contrib import (
|
|
|
|
admin,
|
|
|
|
messages
|
|
|
|
)
|
|
|
|
from django.core.exceptions import ValidationError
|
2016-07-13 17:13:47 +00:00
|
|
|
|
2017-07-15 14:48:30 +00:00
|
|
|
|
|
|
|
from .models import (
|
|
|
|
Event,
|
|
|
|
Speaker,
|
|
|
|
EventType,
|
|
|
|
EventInstance,
|
|
|
|
EventLocation,
|
2018-05-20 16:16:20 +00:00
|
|
|
EventTrack,
|
2017-07-15 14:48:30 +00:00
|
|
|
SpeakerProposal,
|
|
|
|
EventProposal,
|
2018-05-23 21:28:27 +00:00
|
|
|
Favorite,
|
|
|
|
UrlType,
|
|
|
|
Url
|
2017-07-15 14:48:30 +00:00
|
|
|
)
|
2017-03-12 14:43:41 +00:00
|
|
|
|
|
|
|
|
2017-03-12 18:06:03 +00:00
|
|
|
@admin.register(SpeakerProposal)
|
|
|
|
class SpeakerProposalAdmin(admin.ModelAdmin):
|
2017-03-15 23:30:59 +00:00
|
|
|
def mark_speakerproposal_as_approved(self, request, queryset):
|
|
|
|
for sp in queryset:
|
2018-05-26 08:24:52 +00:00
|
|
|
sp.mark_as_approved(request)
|
2017-03-15 23:30:59 +00:00
|
|
|
mark_speakerproposal_as_approved.description = 'Approve and create Speaker object(s)'
|
|
|
|
|
|
|
|
actions = ['mark_speakerproposal_as_approved']
|
2017-07-09 15:00:29 +00:00
|
|
|
list_filter = ('camp', 'proposal_status', 'user')
|
2017-03-12 14:43:41 +00:00
|
|
|
|
|
|
|
|
2017-03-12 18:06:03 +00:00
|
|
|
@admin.register(EventProposal)
|
|
|
|
class EventProposalAdmin(admin.ModelAdmin):
|
2017-03-15 23:30:59 +00:00
|
|
|
def mark_eventproposal_as_approved(self, request, queryset):
|
|
|
|
for ep in queryset:
|
2017-07-15 14:48:30 +00:00
|
|
|
if not ep.speakers.all():
|
|
|
|
messages.error(
|
|
|
|
request,
|
|
|
|
'Event cant be approved as it has no speaker(s).'
|
|
|
|
)
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
try:
|
2018-05-26 08:24:52 +00:00
|
|
|
ep.mark_as_approved(request)
|
2017-07-15 14:48:30 +00:00
|
|
|
except ValidationError as e:
|
|
|
|
messages.error(request, e)
|
|
|
|
return False
|
2017-03-15 23:30:59 +00:00
|
|
|
mark_eventproposal_as_approved.description = 'Approve and create Event object(s)'
|
|
|
|
|
|
|
|
actions = ['mark_eventproposal_as_approved']
|
2018-05-20 16:16:20 +00:00
|
|
|
list_filter = ('track', 'proposal_status', 'user')
|
2017-02-16 20:03:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
@admin.register(EventLocation)
|
2017-02-21 14:59:38 +00:00
|
|
|
class EventLocationAdmin(admin.ModelAdmin):
|
2017-07-12 09:07:11 +00:00
|
|
|
list_filter = ('camp',)
|
|
|
|
list_display = ('name', 'camp')
|
2016-07-13 19:44:09 +00:00
|
|
|
|
|
|
|
|
2018-05-20 16:16:20 +00:00
|
|
|
@admin.register(EventTrack)
|
|
|
|
class EventTrackAdmin(admin.ModelAdmin):
|
|
|
|
list_filter = ('camp',)
|
|
|
|
list_display = ('name', 'camp')
|
|
|
|
|
2017-01-22 11:59:57 +00:00
|
|
|
@admin.register(EventInstance)
|
|
|
|
class EventInstanceAdmin(admin.ModelAdmin):
|
2018-08-16 16:25:33 +00:00
|
|
|
list_display = ('event', 'when', 'location')
|
|
|
|
list_filter = ('event__track__camp', 'event')
|
|
|
|
search_fields = ['event__title']
|
2017-01-22 11:59:57 +00:00
|
|
|
|
2017-02-16 20:03:24 +00:00
|
|
|
|
2016-07-13 19:44:09 +00:00
|
|
|
@admin.register(EventType)
|
|
|
|
class EventTypeAdmin(admin.ModelAdmin):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2016-08-04 21:03:39 +00:00
|
|
|
@admin.register(Speaker)
|
|
|
|
class SpeakerAdmin(admin.ModelAdmin):
|
2017-07-09 13:48:29 +00:00
|
|
|
list_filter = ('camp',)
|
2018-06-03 13:34:04 +00:00
|
|
|
readonly_fields = ['proposal']
|
2016-08-04 21:03:39 +00:00
|
|
|
|
|
|
|
|
2017-04-16 00:10:24 +00:00
|
|
|
@admin.register(Favorite)
|
|
|
|
class FavoriteAdmin(admin.ModelAdmin):
|
|
|
|
raw_id_fields = ('event_instance',)
|
|
|
|
|
|
|
|
|
2016-08-04 21:03:39 +00:00
|
|
|
class SpeakerInline(admin.StackedInline):
|
|
|
|
model = Speaker.events.through
|
|
|
|
|
|
|
|
|
2016-07-13 19:44:09 +00:00
|
|
|
@admin.register(Event)
|
|
|
|
class EventAdmin(admin.ModelAdmin):
|
2018-05-20 16:16:20 +00:00
|
|
|
list_filter = ('track', 'speakers')
|
2016-07-13 20:37:20 +00:00
|
|
|
list_display = [
|
|
|
|
'title',
|
|
|
|
'event_type',
|
|
|
|
]
|
|
|
|
|
2016-08-04 21:03:39 +00:00
|
|
|
inlines = [
|
|
|
|
SpeakerInline
|
|
|
|
]
|
2018-05-20 16:16:20 +00:00
|
|
|
|
2018-06-03 13:34:04 +00:00
|
|
|
readonly_fields = ['proposal']
|
|
|
|
|
2018-05-23 21:28:27 +00:00
|
|
|
@admin.register(UrlType)
|
|
|
|
class UrlTypeAdmin(admin.ModelAdmin):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@admin.register(Url)
|
|
|
|
class UrlAdmin(admin.ModelAdmin):
|
|
|
|
pass
|
|
|
|
|