Commit 8efe3fd1 authored by Fabs's avatar Fabs

Add some default values

parent da926ec6
# -*- coding: utf-8 -*-
from django.contrib import admin
from coin.members.models import Member, CryptoKey, LdapUser
from coin.members.models import Member, CryptoKey, LdapUser, MembershipFee
from django import forms
import pprint
class LdapUserAdmin(admin.ModelAdmin):
exclude = ['dn']
list_display = ['uid','first_name', 'last_name']
search_fields = ['first_name', 'last_name']
# class LdapUserAdmin(admin.ModelAdmin):
# exclude = ['dn']
# list_display = ['uid','first_name', 'last_name']
# search_fields = ['first_name', 'last_name']
#TODO : Déplacer dans LdapUser model (pre_save ?)
#def save_model(self, request, obj, form, change):
......@@ -36,7 +36,11 @@ class MemberAdmin(admin.ModelAdmin):
form = MemberAdminForm
inlines = [CryptoKeyInline]
class MembershipFeeAdmin(admin.ModelAdmin):
list_display = ('member', 'date', 'amount')
admin.site.register(Member, MemberAdmin)
admin.site.register(LdapUser, LdapUserAdmin)
admin.site.register(MembershipFee, MembershipFeeAdmin)
# admin.site.register(LdapUser, LdapUserAdmin)
......@@ -6,6 +6,7 @@ from ldapdb.models.fields import CharField, IntegerField, ListField
from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver
from south.modelsinspector import add_ignored_fields
from datetime import date
class LdapUser(ldapdb.models.Model):
base_dn = "ou=users,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR" #TODO déplacer dans settings.py
......@@ -31,6 +32,7 @@ class Member(models.Model):
MEMBER_TYPE_CHOICES =(('personne_physique','Personne physique'),('personne_morale','Personne morale'))
MEMBER_STATUS_CHOICES = (('adherent','Adhérent'),('non_adherent','Non adhérent'),('demande_adhesion','Demande d\'adhésion'))
status = models.CharField(max_length=50, choices=MEMBER_STATUS_CHOICES, default='non_adherent');
type = models.CharField(max_length=20, choices=MEMBER_TYPE_CHOICES, default='personne_physique');
first_name = models.CharField(max_length=200);
last_name = models.CharField(max_length=200);
......@@ -40,11 +42,10 @@ class Member(models.Model):
home_phone_number = models.CharField(max_length=25, blank=True);
mobile_phone_number = models.CharField(max_length=25, blank=True);
address = models.TextField();
postal_code = models.CharField(max_length=15);
postal_code = models.CharField(max_length=15);
city = models.CharField(max_length=200);
country = models.CharField(max_length=200);
status = models.CharField(max_length=50, choices=MEMBER_STATUS_CHOICES, default='non_adherent');
entry_date = models.DateField(null=True, blank=True);
entry_date = models.DateField(null=False, blank=False, default=date.today);
resign_date = models.DateField(null=True, blank=True);
def __unicode__(self):
......@@ -62,6 +63,11 @@ class CryptoKey(models.Model):
def __unicode__(self):
return self.member.__str__();
class MembershipFee(models.Model):
member = models.ForeignKey('Member');
amount = models.IntegerField(null=False, default='20');
date = models.DateField(null=False, blank=False, default=date.today);
#~ Lors de la sauvegarde d'un membre, cette fonction est exécutée pour mettre à jour les données dans le LDAP
@receiver(post_save, sender=Member)
......
File mode changed from 100644 to 100755
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment