Coverage for gui/admin.py: 100%
39 statements
« prev ^ index » next coverage.py v7.2.1, created at 2023-03-14 06:24 +0000
« prev ^ index » next coverage.py v7.2.1, created at 2023-03-14 06:24 +0000
1from django.contrib import admin
2from .models import Link, Profile, MembershipPeriod, Membership, Ballot
3from .models import BallotSelectQuestion, BallotSelectQuestionPossibleAnswer
4from .models import BallotRankingQuestion, BallotRankingQuestionOption
7class LinkModel(admin.ModelAdmin):
8 list_display = ('short_name', )
9 search_fields = ['short_name', 'description']
12admin.site.register(Link, LinkModel)
15class ProfileModel(admin.ModelAdmin):
16 list_display = ('user', )
17 search_fields = ['user', 'affiliation']
20admin.site.register(Profile, ProfileModel)
23class MembershipPeriodModel(admin.ModelAdmin):
24 list_display = ('short_name', 'start')
25 search_fields = ['short_name', 'description']
28admin.site.register(MembershipPeriod, MembershipPeriodModel)
31class MembershipModel(admin.ModelAdmin):
32 list_display = ('user_profile', 'period', 'applied_on', 'approved_on', 'rejected_on')
33 search_fields = ['user_profile__user__first_name', 'user_profile__user__last_name',
34 'period__short_name', 'rejection_reason']
37admin.site.register(Membership, MembershipModel)
40class BallotModel(admin.ModelAdmin):
41 list_display = ('short_name', 'created_on', 'opening_on', 'closing_on')
42 search_fields = ['short_name', 'description', 'created_on', 'opening_on', 'closing_on']
43 exclude = ('voters',)
46admin.site.register(Ballot, BallotModel)
49class BallotSelectQuestionPossibleAnswerModelInline(admin.TabularInline):
50 model = BallotSelectQuestionPossibleAnswer
53class BallotSelectQuestionModel(admin.ModelAdmin):
54 list_display = ('ballot', 'question')
55 search_fields = ['ballot__short_name', 'question']
56 inlines = [BallotSelectQuestionPossibleAnswerModelInline]
59admin.site.register(BallotSelectQuestion, BallotSelectQuestionModel)
62class BallotRankingQuestionOptionModelInline(admin.TabularInline):
63 model = BallotRankingQuestionOption
66class BallotRankingQuestionModel(admin.ModelAdmin):
67 list_display = ('ballot', 'question')
68 search_fields = ['ballot__short_name', 'question']
69 inlines = [BallotRankingQuestionOptionModelInline]
72admin.site.register(BallotRankingQuestion, BallotRankingQuestionModel)