@@ -148,6 +148,17 @@ def queryset(self, request, queryset):
148
148
return queryset .filter (tags = v )
149
149
150
150
151
+ def mtypes_choices ():
152
+ return itertools .chain ((('' , '----' ), ), ((x .pk , x .label ) for x in MemberType .objects .all ()))
153
+
154
+
155
+ class MembershipApplicationsForm (admin .helpers .ActionForm ):
156
+ mtypes = forms .MultipleChoiceField (
157
+ label = _ ("Membership types" ), # TODO: Read from the member model meta ?
158
+ choices = lazy (mtypes_choices , tuple )
159
+ )
160
+
161
+
151
162
class MembershipApplicationAdmin (VersionAdmin ):
152
163
list_display = (
153
164
'rname' ,
@@ -156,12 +167,23 @@ class MembershipApplicationAdmin(VersionAdmin):
156
167
'tags_formatted' ,
157
168
)
158
169
list_filter = (TagListFilter ,)
170
+ actions = ['approve_selected' ]
171
+ action_form = MembershipApplicationsForm
159
172
search_fields = ['lname' , 'fname' , 'email' , 'nick' ]
160
173
161
174
def tags_formatted (self , obj ):
162
175
return ', ' .join ((x .label for x in obj .tags .all ()))
163
176
tags_formatted .short_description = _ ("Tags" )
164
177
178
+ def approve_selected (modeladmin , request , queryset ):
179
+ add_types = []
180
+ for x in request .POST .getlist ('mtypes' ):
181
+ if x :
182
+ add_types .append (int (x ))
183
+ for a in queryset .all ():
184
+ a .approve (add_types )
185
+ approve_selected .short_description = _ ("Approve selected applications" )
186
+
165
187
166
188
class MembershipApplicationTagAdmin (VersionAdmin ):
167
189
pass
0 commit comments