Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1from wagtail.contrib.modeladmin.options import ( 

2 ModelAdmin, 

3 ModelAdminGroup, 

4 modeladmin_register, 

5) 

6from discuss_data.dddatasets.models import ( 

7 DataType, 

8 Category, 

9 CollectionMethodsTagged, 

10 AnalysisMethodsTagged, 

11 DisciplinesTagged, 

12) 

13 

14from discuss_data.core.models import ( 

15 KeywordTagged, 

16 LanguageTagged, 

17) 

18 

19""" 

20Register Django models for administration in wagtail. 

21Needs also FieldPanel definitions in the Django models 

22 

23Models from core are added here as they also belong into 

24the TagsGroup 

25""" 

26 

27 

28class DataTypeAdmin(ModelAdmin): 

29 model = DataType 

30 menu_label = "Data types" # ditch this to use verbose_name_plural from model 

31 menu_icon = "cogs" # change as required 

32 menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd) 

33 add_to_settings_menu = False # or True to add your model to the Settings sub-menu 

34 exclude_from_explorer = ( 

35 False # or True to exclude pages of this type from Wagtail's explorer view 

36 ) 

37 list_display = ("name",) 

38 list_filter = ("name",) 

39 search_fields = ("name",) 

40 

41 

42class CategoryAdmin(ModelAdmin): 

43 model = Category 

44 menu_label = "Categories" # ditch this to use verbose_name_plural from model 

45 menu_icon = "cogs" # change as required 

46 menu_order = 300 # will put in 3rd place (000 being 1st, 100 2nd) 

47 add_to_settings_menu = False # or True to add your model to the Settings sub-menu 

48 exclude_from_explorer = ( 

49 False # or True to exclude pages of this type from Wagtail's explorer view 

50 ) 

51 list_display = ("name",) 

52 list_filter = ("name",) 

53 search_fields = ("name", "curators__last_name", "curators__first_name") 

54 

55 

56class CuratedItemsGroup(ModelAdminGroup): 

57 menu_label = "DD Curated Items" 

58 menu_icon = "cogs" # change as required 

59 menu_order = 200 # will put in 3rd place (000 being 1st, 100 2nd) 

60 items = (DataTypeAdmin, CategoryAdmin) 

61 

62 

63class CollectionMethodsTaggedAdmin(ModelAdmin): 

64 model = CollectionMethodsTagged 

65 menu_icon = "tag" # change as required 

66 menu_order = 300 # will put in 3rd place (000 being 1st, 100 2nd) 

67 add_to_settings_menu = False # or True to add your model to the Settings sub-menu 

68 exclude_from_explorer = ( 

69 False # or True to exclude pages of this type from Wagtail's explorer view 

70 ) 

71 list_display = ("name",) 

72 list_filter = ("name",) 

73 search_fields = ("name",) 

74 

75 

76class AnalysisMethodsTaggedAdmin(ModelAdmin): 

77 model = AnalysisMethodsTagged 

78 menu_icon = "tag" # change as required 

79 menu_order = 400 # will put in 3rd place (000 being 1st, 100 2nd) 

80 add_to_settings_menu = False # or True to add your model to the Settings sub-menu 

81 exclude_from_explorer = ( 

82 False # or True to exclude pages of this type from Wagtail's explorer view 

83 ) 

84 list_display = ("name",) 

85 list_filter = ("name",) 

86 search_fields = ("name",) 

87 

88 

89class DisciplinesTaggedAdmin(ModelAdmin): 

90 model = DisciplinesTagged 

91 menu_icon = "tag" # change as required 

92 menu_order = 500 # will put in 3rd place (000 being 1st, 100 2nd) 

93 add_to_settings_menu = False # or True to add your model to the Settings sub-menu 

94 exclude_from_explorer = ( 

95 False # or True to exclude pages of this type from Wagtail's explorer view 

96 ) 

97 list_display = ("name",) 

98 list_filter = ("name",) 

99 search_fields = ("name",) 

100 

101 

102class KeywordTaggedAdmin(ModelAdmin): 

103 model = KeywordTagged 

104 menu_icon = "tag" # change as required 

105 menu_order = 600 # will put in 3rd place (000 being 1st, 100 2nd) 

106 add_to_settings_menu = False # or True to add your model to the Settings sub-menu 

107 exclude_from_explorer = ( 

108 False # or True to exclude pages of this type from Wagtail's explorer view 

109 ) 

110 list_display = ("name",) 

111 list_filter = ("name",) 

112 search_fields = ("name",) 

113 

114 

115class LanguageTaggedAdmin(ModelAdmin): 

116 model = LanguageTagged 

117 menu_icon = "tag" # change as required 

118 menu_order = 700 # will put in 3rd place (000 being 1st, 100 2nd) 

119 add_to_settings_menu = False # or True to add your model to the Settings sub-menu 

120 exclude_from_explorer = ( 

121 False # or True to exclude pages of this type from Wagtail's explorer view 

122 ) 

123 list_display = ("name",) 

124 list_filter = ("name",) 

125 search_fields = ("name",) 

126 

127 

128class TagsGroup(ModelAdminGroup): 

129 menu_label = "DD Tags" 

130 menu_icon = "tag" # change as required 

131 menu_order = 300 # will put in 3rd place (000 being 1st, 100 2nd) 

132 items = ( 

133 CollectionMethodsTaggedAdmin, 

134 AnalysisMethodsTaggedAdmin, 

135 DisciplinesTaggedAdmin, 

136 KeywordTaggedAdmin, 

137 LanguageTaggedAdmin, 

138 ) 

139 

140 

141# register as a single menu entry for every admin 

142# modeladmin_register(DataTypeAdmin) 

143# modeladmin_register(CategoryAdmin) 

144 

145# register as a admin group 

146modeladmin_register(CuratedItemsGroup) 

147modeladmin_register(TagsGroup)