from django.contrib import admin
from core.models import *

def bt_p_publier(modeladmin, request, queryset):
	queryset.update(p_publier=True)
bt_p_publier.short_description = "Passer en Public"
def bt_p_not_publier(modeladmin, request, queryset):
	queryset.update(p_publier=True)
bt_p_not_publier.short_description = "Passer en Priver"
def bt_p_menu_poid_plus(modeladmin, request, queryset):
	for obj in queryset:
		obj.p_menu_poid=obj.p_menu_poid+5
		obj.save()
bt_p_menu_poid_plus.short_description = "Augmenter le poid de 5"
def bt_p_menu_poid_moin(modeladmin, request, queryset):
	for obj in queryset:
		obj.p_menu_poid=obj.p_menu_poid-5
		obj.save()
bt_p_menu_poid_moin.short_description = "Diminuer le poid de 5"


class Page_Admin(admin.ModelAdmin):
	form = Page_Admin_Form
	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')
	list_filter = ('p_type', 'p_publier', 'p_see_title_and_des_in_templates')
	actions = [bt_p_menu_poid_plus, bt_p_menu_poid_moin, bt_p_publier, bt_p_not_publier]
admin.site.register(Page, Page_Admin)

class Contact_Admin(admin.ModelAdmin):
	pass
	list_display = ('c_type', 'c_name', 'c_email', 'c_description', 'c_statut',)
	search_fields = ['c_name', 'c_email', 'c_description']
	list_filter = ('c_type', 'c_statut',)

admin.site.register(Contact, Contact_Admin)


