Membership model fixes.
authorgniibe <gniibe@atom.fsij.org>
Tue, 4 Aug 2009 01:36:47 +0000 (10:36 +0900)
committergniibe <gniibe@atom.fsij.org>
Tue, 4 Aug 2009 01:36:47 +0000 (10:36 +0900)
ChangeLog
membership/models.py

index 0a61bb5..d50d41f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-08-04  Niibe Yutaka  <gniibe@fsij.org>
+
+       * membership/models.py: Import django.core.exceptions.
+       (Member): first_name and last_name can be blank.
+       (Member.name): Returns first_name concatinated with last_name.
+
 2009-08-03  NIIBE Yutaka  <gniibe@fsij.org>
 
        * apache-setting.cfg: New file.
index ca59eeb..b611c88 100644 (file)
@@ -4,6 +4,7 @@ from django.db import models
 from django.contrib.auth.models import User
 from fsij.accounting.models import LedgerEntry
 from django.utils.translation import ugettext_lazy as _
+from django.core.exceptions import ObjectDoesNotExist
 
 MEMBER_TYPE = ( ('M', u'正会員'), ('S', u'学生会員'), ('A', u'賛助会員'), )
 
@@ -12,8 +13,8 @@ class Member(models.Model):
     member_id = models.CharField(max_length=10)
     member_type = models.CharField(max_length=1, choices=MEMBER_TYPE)
     name_in_alphabet = models.CharField(max_length=50, blank=True)
-    first_name = models.CharField(max_length=30)
-    last_name = models.CharField(max_length=30)
+    first_name = models.CharField(max_length=30, blank=True)
+    last_name = models.CharField(max_length=30, blank=True)
     email = models.EmailField(_('e-mail address'), blank=True)
     date_joined = models.DateField('date joined', blank=True, null=True)
     date_quit = models.DateField('date quit', blank=True, null=True)
@@ -26,13 +27,12 @@ class Member(models.Model):
         if self.member_type == 'A':
             try:
                 corp = self.corporatemember
-            except (Corporatemember.DoesNotExist):
+            except ObjectDoesNotExist:
                 corp = None
             if corp:
                 return corp.corporate_name
-        elif self.user:
+        else:
             return self.last_name + " " + self.first_name
-        return self.name_in_alphabet
 
 class CorporateMember(models.Model):
     member = models.OneToOneField(Member)