Corporate member change.
authorgniibe <gniibe@fsij.org>
Tue, 4 Aug 2009 08:02:37 +0000 (17:02 +0900)
committergniibe <gniibe@fsij.org>
Tue, 4 Aug 2009 08:02:37 +0000 (17:02 +0900)
+migrate+/20090804_membership.sql [new file with mode: 0644]
ChangeLog
membership/models.py
utils/check_member_id.py [new file with mode: 0644]

diff --git a/+migrate+/20090804_membership.sql b/+migrate+/20090804_membership.sql
new file mode 100644 (file)
index 0000000..7252948
--- /dev/null
@@ -0,0 +1,9 @@
+alter table "membership_corporatemember" rename to "membership_corporatemember20090804";
+
+create table "membership_corporatemember" (
+    "member_id" integer NOT NULL PRIMARY KEY REFERENCES "membership_member" ("id"),
+    "corporate_name" varchar(50) NOT NULL,
+    "contribution" integer NOT NULL
+);
+
+-- no need to copy table (it has zero content)
index 667779e..6813177 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2009-08-04  Niibe Yutaka  <gniibe@fsij.org>
 
+       * membership/models.py (Member.name): Handle corp case.
+       (CorporateMember): Remove contact_person field.
+
+       * utils/check_member_id.py: New file.
+
+       * +migrate+/20090804_membership.sql: New file.
+
        * membership/models.py (MemberPayment.__unicode__): Bug fix,
        adding self.
 
index fa407a0..5f5bb0c 100644 (file)
@@ -26,18 +26,15 @@ class Member(models.Model):
     def name(self):
         if self.member_type == 'A':
             try:
-                corp = self.corporatemember
+                return self.corporatemember.__unicode__()
             except ObjectDoesNotExist:
-                corp = None
-            if corp:
-                return corp.corporate_name
+                return "A: " + self.last_name + " " + self.first_name
         else:
             return self.last_name + " " + self.first_name
 
 class CorporateMember(models.Model):
-    member = models.OneToOneField(Member)
+    member = models.OneToOneField(Member,primary_key=True)
     corporate_name = models.CharField(max_length=50)
-    contact_person = models.CharField(max_length=50)
     contribution = models.IntegerField() # Kuchi-Suu in Japanese
     def __unicode__(self):
         return self.corporate_name
diff --git a/utils/check_member_id.py b/utils/check_member_id.py
new file mode 100644 (file)
index 0000000..ef49901
--- /dev/null
@@ -0,0 +1,18 @@
+from fsij.membership.models import Member
+import md5
+
+for m in Member.objects.all():
+    hash = md5.md5(m.member_id[0:-2])
+    md5hex = hash.hexdigest()
+    if md5hex[-2:] == m.member_id[-2:]:
+        print "%s: end 2" % m.member_id
+    elif md5hex[0:2] == m.member_id[-2:]:
+        print "%s: start 2" % m.member_id
+    else:
+        orig_member_id = m.member_id[0:-2]
+        hash = md5.md5(orig_member_id[0:4]+orig_member_id[5:])
+        md5hex = hash.hexdigest()
+        if md5hex[0:2] == m.member_id[-2:]:
+            print "%s: start 2, wrong data" % m.member_id
+        else:
+            print "%s: ??" % m.member_id