admin.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. from django.contrib import admin
  2. from core.models import *
  3. def bt_p_publier(modeladmin, request, queryset):
  4. queryset.update(p_publier=True)
  5. bt_p_publier.short_description = "Passer en Public"
  6. def bt_p_not_publier(modeladmin, request, queryset):
  7. queryset.update(p_publier=True)
  8. bt_p_not_publier.short_description = "Passer en Priver"
  9. def bt_p_menu_poid_plus(modeladmin, request, queryset):
  10. for obj in queryset:
  11. obj.p_menu_poid=obj.p_menu_poid+5
  12. obj.save()
  13. bt_p_menu_poid_plus.short_description = "Augmenter le poid de 5"
  14. def bt_p_menu_poid_moin(modeladmin, request, queryset):
  15. for obj in queryset:
  16. obj.p_menu_poid=obj.p_menu_poid-5
  17. obj.save()
  18. bt_p_menu_poid_moin.short_description = "Diminuer le poid de 5"
  19. def bt_sd_poid_plus(modeladmin, request, queryset):
  20. for obj in queryset:
  21. obj.sd_poid=obj.sd_poid+5
  22. obj.save()
  23. bt_sd_poid_plus.short_description = "Augmenter le poid de 5"
  24. def bt_sd_poid_moin(modeladmin, request, queryset):
  25. for obj in queryset:
  26. obj.sd_poid=obj.sd_poid-5
  27. obj.save()
  28. bt_sd_poid_moin.short_description = "Diminuer le poid de 5"
  29. class Page_Admin(admin.ModelAdmin):
  30. form = Page_Admin_Form
  31. list_display = ('p_titre', 'p_titre_slugify', 'p_adresse', 'p_contenu', 'p_right', 'p_type', 'p_menu_poid', 'p_publier','p_see_title_and_des_in_templates')
  32. list_filter = ('p_type', 'p_menu_parent', 'p_publier', 'p_see_title_and_des_in_templates')
  33. actions = [bt_p_menu_poid_plus, bt_p_menu_poid_moin, bt_p_publier, bt_p_not_publier]
  34. admin.site.register(Page, Page_Admin)
  35. class Speed_Dial_Admin(admin.ModelAdmin):
  36. pass
  37. list_display = ('sd_titre', 'sd_adresse' ,'sd_groupe', 'sd_icone', 'sd_color', 'sd_poid')
  38. actions = [bt_sd_poid_plus, bt_sd_poid_moin]
  39. admin.site.register(Speed_Dial, Speed_Dial_Admin)
  40. class Data_Admin(admin.ModelAdmin):
  41. pass
  42. exclude = ('d_titre_slugify',)
  43. list_display = ('d_titre', 'd_titre_slugify', 'd_type', 'd_variable',)
  44. admin.site.register(Data, Data_Admin)
  45. class Groupe_Admin(admin.ModelAdmin):
  46. pass
  47. exclude = ('g_nom_slugify',)
  48. list_display = ('g_nom', 'g_description')
  49. admin.site.register(Groupe, Groupe_Admin)
  50. class Contact_Admin(admin.ModelAdmin):
  51. pass
  52. list_display = ('c_type', 'c_name', 'c_email', 'c_description', 'c_statut',)
  53. search_fields = ['c_name', 'c_email', 'c_description']
  54. list_filter = ('c_type', 'c_statut',)
  55. admin.site.register(Contact, Contact_Admin)
  56. class Fichier_Admin(admin.ModelAdmin):
  57. list_display = ('f_nom', 'f_date',)
  58. search_fields = ['f_nom',]
  59. list_filter = ('f_date',)
  60. admin.site.register(Fichier, Fichier_Admin)