datatracker/ietf/nomcom/admin.py
Robert Sparks d9cc26be96
feat: replace references to User with references to Person (#6024)
* refactor: change references from User to Person (#5821)

* refactor: Change CommunityList reference from User to Person

* refactor: Convert more user references to person

* refactor: Change augment_docs_and_user_with_user_info to person

* refactor: Change Nomination and Feedback references from User to Person

* refactor: Change a few test case function signatures to be more pythonic

* refactor: Harmonize how profile and photo views look up email_or_name

* refactor: Rework community views to operate on Person instead of User (#5859)

* test: Update tests to try all of the person's emails and aliases

* fix: Recode a test case to avoid an exception if there's Unicode in the URL

This only happens using the form-filling and submission feature of
WebTest, which is only used in this one test case, so just it rip out.

* test: Add duplicate-person tests

* fix: If there are multiple matching users, prefer the logged-in one.

* chore: We no longer use WebTest, so don't include it.

* fix: Address review comments

* fix: case-insensitive person name or email matching (#6096)

* chore: Renumber migrations

* fix: Update merged code so tests pass (#6887)

* fix: Use refactored method

* fix: Don't assume user has person

* fix: Use new view param name

* chore: Drop community lists w/o person; cleanup (#6896)

* fix: Don't assume user has person

* fix: user->person in update_community_list_index.py

* feat: Remove CommunityLists without Person

* refactor: Speed up nomcom migrations

---------

Co-authored-by: Paul Selkirk <paul@painless-security.com>
Co-authored-by: Jennifer Richards <jennifer@staff.ietf.org>
2024-01-24 11:00:19 -06:00

80 lines
3.3 KiB
Python

# Copyright The IETF Trust 2012-2021, All Rights Reserved
# -*- coding: utf-8 -*-
from django.contrib import admin
from ietf.nomcom.models import ( ReminderDates, NomCom, Nomination, Nominee, NomineePosition,
Position, Feedback, FeedbackLastSeen, TopicFeedbackLastSeen,
Volunteer, )
class ReminderDatesAdmin(admin.ModelAdmin):
list_display = ['id', 'date', 'nomcom']
list_filter = ['date', 'nomcom']
admin.site.register(ReminderDates, ReminderDatesAdmin)
class NomComAdmin(admin.ModelAdmin):
list_display = ['id', 'group', 'send_questionnaire', 'reminder_interval', 'initial_text', 'show_nominee_pictures']
list_filter = ['send_questionnaire', 'show_nominee_pictures']
raw_id_fields = ['group']
admin.site.register(NomCom, NomComAdmin)
class NominationAdmin(admin.ModelAdmin):
list_display = ['id', 'position', 'candidate_name', 'candidate_email', 'candidate_phone', 'nominee', 'comments', 'nominator_email', 'person', 'time', 'share_nominator']
list_filter = ['time', 'share_nominator']
raw_id_fields = ['nominee', 'comments', 'person']
admin.site.register(Nomination, NominationAdmin)
class NomineeAdmin(admin.ModelAdmin):
list_display = ('email', 'person', 'duplicated', 'nomcom')
search_fields = ('email__address', 'person__name', )
list_filter = ('nomcom', )
raw_id_fields = ['nominee_position', 'email', 'person', 'duplicated']
admin.site.register(Nominee, NomineeAdmin)
class NomineePositionAdmin(admin.ModelAdmin):
list_display = ['id', 'position', 'nominee', 'state', 'time']
list_filter = ['state', 'position', 'time']
raw_id_fields = ['nominee']
admin.site.register(NomineePosition, NomineePositionAdmin)
class PositionAdmin(admin.ModelAdmin):
list_display = ('name', 'nomcom', 'is_open', 'accepting_nominations', 'accepting_feedback')
list_filter = ['nomcom', 'is_open', 'accepting_nominations', 'accepting_feedback']
raw_id_fields = ['requirement', 'questionnaire']
search_fields = ['name']
admin.site.register(Position, PositionAdmin)
class FeedbackAdmin(admin.ModelAdmin):
def nominee(self, obj):
return ", ".join(n.person.ascii for n in obj.nominees.all())
nominee.admin_order_field = 'nominees__person__ascii' # type: ignore # https://github.com/python/mypy/issues/2087
list_display = ['id', 'nomcom', 'author', 'nominee', 'subject', 'type', 'person', 'time']
list_filter = ['nomcom', 'type', 'time', ]
raw_id_fields = ['positions', 'topics', 'person']
admin.site.register(Feedback, FeedbackAdmin)
class FeedbackLastSeenAdmin(admin.ModelAdmin):
list_display = ['id', 'reviewer', 'nominee', 'time']
list_filter = ['time']
raw_id_fields = ['reviewer', 'nominee']
admin.site.register(FeedbackLastSeen, FeedbackLastSeenAdmin)
class TopicFeedbackLastSeenAdmin(admin.ModelAdmin):
list_display = ['id', 'reviewer', 'topic', 'time']
list_filter = ['topic', 'time']
raw_id_fields = ['reviewer']
admin.site.register(TopicFeedbackLastSeen, TopicFeedbackLastSeenAdmin)
class VolunteerAdmin(admin.ModelAdmin):
list_display = ['id', 'nomcom','person','affiliation']
list_filter = ['nomcom']
search_fields = ['person__name', 'nomcom__group__acronym', 'affiliation']
raw_id_fields = ['person']
admin.site.register(Volunteer, VolunteerAdmin)