admin.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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_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 Contact_Admin(admin.ModelAdmin):
  46. pass
  47. list_display = ('c_type', 'c_name', 'c_email', 'c_description', 'c_statut',)
  48. search_fields = ['c_name', 'c_email', 'c_description']
  49. list_filter = ('c_type', 'c_statut',)
  50. admin.site.register(Contact, Contact_Admin)