Merged in [19920] from rjsparks@nostrum.com:
Make working with session purpose easier in the admin. - Legacy-Id: 19928 Note: SVN reference [19920] has been migrated to Git commit 191d5b134fdab8782280eb9769beec793818975f
This commit is contained in:
parent
844890eadc
commit
d3a91b4b19
|
@ -96,10 +96,10 @@ class SchedulingEventInline(admin.TabularInline):
|
||||||
raw_id_fields = ["by"]
|
raw_id_fields = ["by"]
|
||||||
|
|
||||||
class SessionAdmin(admin.ModelAdmin):
|
class SessionAdmin(admin.ModelAdmin):
|
||||||
list_display = ["meeting", "name", "group", "attendees", "requested", "current_status"]
|
list_display = ["meeting", "name", "group_acronym", "purpose", "attendees", "requested", "current_status"]
|
||||||
list_filter = ["meeting", ]
|
list_filter = ["purpose", "meeting", ]
|
||||||
raw_id_fields = ["meeting", "group", "materials", "joint_with_groups", "tombstone_for"]
|
raw_id_fields = ["meeting", "group", "materials", "joint_with_groups", "tombstone_for"]
|
||||||
search_fields = ["meeting__number", "name", "group__name", "group__acronym", ]
|
search_fields = ["meeting__number", "name", "group__name", "group__acronym", "purpose__name"]
|
||||||
ordering = ["-id"]
|
ordering = ["-id"]
|
||||||
inlines = [SchedulingEventInline]
|
inlines = [SchedulingEventInline]
|
||||||
|
|
||||||
|
@ -108,10 +108,13 @@ class SessionAdmin(admin.ModelAdmin):
|
||||||
qs = super(SessionAdmin, self).get_queryset(request)
|
qs = super(SessionAdmin, self).get_queryset(request)
|
||||||
return qs.prefetch_related('schedulingevent_set')
|
return qs.prefetch_related('schedulingevent_set')
|
||||||
|
|
||||||
|
def group_acronym(self, instance):
|
||||||
|
return instance.group and instance.group.acronym
|
||||||
|
|
||||||
def current_status(self, instance):
|
def current_status(self, instance):
|
||||||
events = sorted(instance.schedulingevent_set.all(), key=lambda e: (e.time, e.id))
|
events = sorted(instance.schedulingevent_set.all(), key=lambda e: (e.time, e.id))
|
||||||
if events:
|
if events:
|
||||||
return events[-1].time
|
return f'{events[-1].status} ({events[-1].time:%Y-%m-%d %H:%M})'
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -166,11 +166,12 @@ api.meeting.register(ScheduleResource())
|
||||||
|
|
||||||
from ietf.group.resources import GroupResource
|
from ietf.group.resources import GroupResource
|
||||||
from ietf.doc.resources import DocumentResource
|
from ietf.doc.resources import DocumentResource
|
||||||
from ietf.name.resources import TimeSlotTypeNameResource
|
from ietf.name.resources import TimeSlotTypeNameResource, SessionPurposeNameResource
|
||||||
from ietf.person.resources import PersonResource
|
from ietf.person.resources import PersonResource
|
||||||
class SessionResource(ModelResource):
|
class SessionResource(ModelResource):
|
||||||
meeting = ToOneField(MeetingResource, 'meeting')
|
meeting = ToOneField(MeetingResource, 'meeting')
|
||||||
type = ToOneField(TimeSlotTypeNameResource, 'type')
|
type = ToOneField(TimeSlotTypeNameResource, 'type')
|
||||||
|
purpose = ToOneField(SessionPurposeNameResource, 'purpose')
|
||||||
group = ToOneField(GroupResource, 'group')
|
group = ToOneField(GroupResource, 'group')
|
||||||
materials = ToManyField(DocumentResource, 'materials', null=True)
|
materials = ToManyField(DocumentResource, 'materials', null=True)
|
||||||
resources = ToManyField(ResourceAssociationResource, 'resources', null=True)
|
resources = ToManyField(ResourceAssociationResource, 'resources', null=True)
|
||||||
|
@ -195,6 +196,7 @@ class SessionResource(ModelResource):
|
||||||
"modified": ALL,
|
"modified": ALL,
|
||||||
"meeting": ALL_WITH_RELATIONS,
|
"meeting": ALL_WITH_RELATIONS,
|
||||||
"type": ALL_WITH_RELATIONS,
|
"type": ALL_WITH_RELATIONS,
|
||||||
|
"purpose": ALL_WITH_RELATIONS,
|
||||||
"group": ALL_WITH_RELATIONS,
|
"group": ALL_WITH_RELATIONS,
|
||||||
"requested_by": ALL_WITH_RELATIONS,
|
"requested_by": ALL_WITH_RELATIONS,
|
||||||
"status": ALL_WITH_RELATIONS,
|
"status": ALL_WITH_RELATIONS,
|
||||||
|
|
Loading…
Reference in a new issue