gavel-team team mailing list archive
-
gavel-team team
-
Mailing list archive
-
Message #00021
[Branch ~gavel-team/gavel/simple_gavel] Rev 4: Models for Motion and Vote at a useable level.
------------------------------------------------------------
revno: 4
committer: Joshua Gardner <mellowcellofellow@xxxxxxxxx>
branch nick: simple_gavel
timestamp: Wed 2010-03-31 18:12:17 -0600
message:
Models for Motion and Vote at a useable level.
modified:
gavel/rules/models.py
gavel/settings.py
--
lp:gavel
https://code.launchpad.net/~gavel-team/gavel/simple_gavel
Your team Gavel Team is subscribed to branch lp:gavel.
To unsubscribe from this branch go to https://code.launchpad.net/~gavel-team/gavel/simple_gavel/+edit-subscription
=== modified file 'gavel/rules/models.py'
--- gavel/rules/models.py 2010-03-31 19:20:09 +0000
+++ gavel/rules/models.py 2010-04-01 00:12:17 +0000
@@ -1,3 +1,47 @@
+import re
+
from django.db import models
+from django.core.exceptions import PermissionDenied
# Create your models here.
+
+class Motion(models.Model):
+ """
+ A motion is a proposition that the assembled body do something. It can
+ be voted on and subsidiary motions can be applied to it.
+ """
+ title = models.CharField("Motion Title", max_length=50)
+ slug = models.SlugField("Slug", max_length=50)
+ text = models.TextField("Motion Text", max_length=10240)
+
+ def save(self, *args, **kwargs):
+ self.slug = re.sub(r'[^\w-]', '',
+ re.sub(r'\s+', '-', self.title.lower()))
+
+ super(Motion, self).save(*args, **kwargs)
+
+ def __unicode__(self):
+ return u'%s' % self.title
+
+class Vote(models.Model):
+ """
+ A vote is a record of the votes made on a motion.
+ """
+
+ motion = models.ForeignKey("Motion")
+ passed = models.BooleanField("Vote Passed/Failed")
+ datetime = models.DateTimeField("Time of Vote", auto_now_add=True)
+ positive = models.IntegerField("Positive Votes", blank=True, null=True)
+ negative = models.IntegerField("Negative Votes", blank=True, null=True)
+ abstain = models.IntegerField("Abstained from Voting", blank=True,
+ null=True)
+
+ def __unicode__(self):
+ return u'%s: %s' % (self.motion.title,
+ "Passed" if self.passed else "Failed")
+
+ def save(self, *args, **kwargs):
+ if self.id:
+ raise PermissionDenied("Vote cannot be modified")
+
+ super(Vote, self).save(*args, **kwargs)
=== modified file 'gavel/settings.py'
--- gavel/settings.py 2010-03-31 19:19:02 +0000
+++ gavel/settings.py 2010-04-01 00:12:17 +0000
@@ -9,8 +9,8 @@
MANAGERS = ADMINS
-DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
-DATABASE_NAME = '' # Or path to database file if using sqlite3.
+DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+DATABASE_NAME = 'database.sqlite' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
@@ -76,4 +76,5 @@
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
+ 'gavel.rules',
)