Coverage for gui/admin.py: 100%

39 statements  

« 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 

5 

6 

7class LinkModel(admin.ModelAdmin): 

8 list_display = ('short_name', ) 

9 search_fields = ['short_name', 'description'] 

10 

11 

12admin.site.register(Link, LinkModel) 

13 

14 

15class ProfileModel(admin.ModelAdmin): 

16 list_display = ('user', ) 

17 search_fields = ['user', 'affiliation'] 

18 

19 

20admin.site.register(Profile, ProfileModel) 

21 

22 

23class MembershipPeriodModel(admin.ModelAdmin): 

24 list_display = ('short_name', 'start') 

25 search_fields = ['short_name', 'description'] 

26 

27 

28admin.site.register(MembershipPeriod, MembershipPeriodModel) 

29 

30 

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'] 

35 

36 

37admin.site.register(Membership, MembershipModel) 

38 

39 

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',) 

44 

45 

46admin.site.register(Ballot, BallotModel) 

47 

48 

49class BallotSelectQuestionPossibleAnswerModelInline(admin.TabularInline): 

50 model = BallotSelectQuestionPossibleAnswer 

51 

52 

53class BallotSelectQuestionModel(admin.ModelAdmin): 

54 list_display = ('ballot', 'question') 

55 search_fields = ['ballot__short_name', 'question'] 

56 inlines = [BallotSelectQuestionPossibleAnswerModelInline] 

57 

58 

59admin.site.register(BallotSelectQuestion, BallotSelectQuestionModel) 

60 

61 

62class BallotRankingQuestionOptionModelInline(admin.TabularInline): 

63 model = BallotRankingQuestionOption 

64 

65 

66class BallotRankingQuestionModel(admin.ModelAdmin): 

67 list_display = ('ballot', 'question') 

68 search_fields = ['ballot__short_name', 'question'] 

69 inlines = [BallotRankingQuestionOptionModelInline] 

70 

71 

72admin.site.register(BallotRankingQuestion, BallotRankingQuestionModel)