Browse Source

PEP

Signed-off-by: CapsLock <faimaison@legeox.net>
CapsLock 10 years ago
parent
commit
e2900e4bbc
2 changed files with 17 additions and 17 deletions
  1. 2 0
      .gitignore
  2. 15 17
      coin/members/models.py

+ 2 - 0
.gitignore

@@ -8,3 +8,5 @@ coin/settings_local.py
 .pydevproject
 .settings/*
 /static
+.idea
+venv

+ 15 - 17
coin/members/models.py

@@ -1,17 +1,12 @@
 # -*- coding: utf-8 -*-
 import ldapdb.models
-import pprint
-import os
-import base64
-import hashlib
 import unicodedata
 import string
 import datetime
 from django.db import models
 from django.db.models import Q
-from django.db.models.signals import post_save, pre_save, post_delete
+from django.db.models.signals import pre_save
 from django.dispatch import receiver
-from django.core import exceptions
 from ldapdb.models.fields import CharField, IntegerField, ListField
 from south.modelsinspector import add_ignored_fields
 from coin.offers.models import OfferSubscription
@@ -20,6 +15,7 @@ from coin import utils
 from django.contrib.auth.signals import user_logged_in
 from django.conf import settings
 
+
 class Member(CoinLdapSyncModel):
 
     MEMBER_TYPE_CHOICES = (
@@ -32,9 +28,11 @@ class Member(CoinLdapSyncModel):
         ('demande_adhesion', "Demande d'adhésion"),
     )
 
-    user = models.OneToOneField(settings.AUTH_USER_MODEL, null=True, default=None,
-                             verbose_name='Utilisateur Django',
-                             on_delete=models.SET_NULL)
+    user = models.OneToOneField(settings.AUTH_USER_MODEL,
+                                null=True,
+                                default=None,
+                                verbose_name='Utilisateur Django',
+                                on_delete=models.SET_NULL)
     status = models.CharField(max_length=50, choices=MEMBER_STATUS_CHOICES,
                               default='non_adherent')
     type = models.CharField(max_length=20, choices=MEMBER_TYPE_CHOICES,
@@ -74,7 +72,7 @@ class Member(CoinLdapSyncModel):
 
     def __unicode__(self):
         name = self.first_name + ' ' + self.last_name
-        if (self.organization_name):
+        if self.organization_name:
             name += ' (%s)' % self.organization_name
         return name
 
@@ -82,6 +80,7 @@ class Member(CoinLdapSyncModel):
     def end_date_of_membership(self):
         try:
             return self.membership_fees.order_by('-end_date')[0].end_date
+        #TODO: bad practice de tout matcher comme ca
         except:
             return None
 
@@ -89,9 +88,8 @@ class Member(CoinLdapSyncModel):
         """
         True si le membre est à jour de cotisation. False sinon
         """
-        if (self.end_date_of_membership()
-            and self.end_date_of_membership() >= datetime.date.today()):
-                return True
+        if self.end_date_of_membership() and self.end_date_of_membership() >= datetime.date.today():
+            return True
         else:
             return False
 
@@ -139,13 +137,13 @@ class Member(CoinLdapSyncModel):
                 ldap_user = LdapUser.objects.get(pk=self.ldap_cn)
 
         if creation:
-            max_uidNumber = LdapUser.objects.order_by('-uidNumber')[0].uidNumber
+            max_uid_number = LdapUser.objects.order_by('-uidNumber')[0].uidNumber
 
             ldap_user = LdapUser()
             ldap_user.pk = self.ldap_cn
             ldap_user.uid = self.ldap_cn
             ldap_user.nick_name = self.ldap_cn
-            ldap_user.uidNumber = max_uidNumber + 1
+            ldap_user.uidNumber = max_uid_number + 1
 
         ldap_user.last_name = self.last_name
         ldap_user.first_name = self.first_name
@@ -207,8 +205,7 @@ class MembershipFee(models.Model):
         verbose_name='Date de fin de cotisation')
 
     def __unicode__(self):
-        return (u'%s - %s - %i€' % (self.member, self.start_date,
-                                    self.amount))
+        return u'%s - %s - %i€' % (self.member, self.start_date, self.amount)
 
     class Meta:
         verbose_name = 'cotisation'
@@ -244,6 +241,7 @@ class LdapGroup(ldapdb.models.Model):
     """
     Class for representing an LDAP group entry.
     """
+    #TODO: config à externaliser
     # LDAP meta-data
     base_dn = "ou=groups,ou=unix,o=ILLYSE,l=Villeurbanne,st=RHA,c=FR"
     object_classes = ['posixGroup']