Assigner les disciplines et régions en bloc dans l'admin
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage / sitotheque / admin.py
CommitLineData
61fb0b58
AJ
1# -*- encoding: utf-8 -*-
2from django.contrib import admin
264a3210
EMS
3from django.core.urlresolvers import reverse as url
4from django.http import HttpResponseRedirect
61fb0b58
AJ
5from models import Site
6
264a3210
EMS
7class SiteAdmin(admin.ModelAdmin):
8 actions = ['assigner_regions', 'assigner_disciplines']
61fb0b58 9
264a3210
EMS
10 def assigner_regions(self, request, queryset):
11 selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME)
12 return HttpResponseRedirect(url('assigner_regions', kwargs=dict(app_name='sitotheque', model_name='site')) + '?ids=' + ','.join(selected))
13 assigner_regions.short_description = u'Assigner des régions'
61fb0b58 14
264a3210
EMS
15 def assigner_disciplines(self, request, queryset):
16 selected = request.POST.getlist(admin.ACTION_CHECKBOX_NAME)
17 return HttpResponseRedirect(url('assigner_disciplines', kwargs=dict(app_name='sitotheque', model_name='site')) + '?ids=' + ','.join(selected))
18 assigner_disciplines.short_description = u'Assigner des disciplines'
19
20admin.site.register(Site, SiteAdmin)