@@ -0,0 +1,3024 @@
+from django.db import models%0A%0Afrom django import forms%0Afrom django.forms import ModelForm%0Afrom django.contrib.auth.models import User%0A%0A%0Afrom django.db import models%0Afrom config.settings import common%0A%0A%0Aclass Thread(models.Model):%0A    title = models.CharField(max_length=30)%0A    description = models.CharField(max_length=1000)%0A    #date = models.DateTimeField(auto_now_add=True)%0A    def __unicode__(self):%0A        return self.description%0A%0Aclass Comment(models.Model):%0A    content = models.CharField(max_length=30)%0A    thread = models.ForeignKey(Thread)%0A    user = models.ForeignKey(common.AUTH_USER_MODEL)%0A    #date = models.DateTimeField(auto_now_add=True)%0A    #path = IntegerArrayField(blank=True, editable=False)%0A    depth = models.PositiveSmallIntegerField(default=0)%0A%0A    def __unicode__(self):%0A        return self.description%0A%0A%0A%0Aclass Topic(models.Model):%0A    name = models.CharField(max_length=200, default=%22Topic Name%22)%0A    subtopic = models.ForeignKey(%22self%22, blank=True, null=True)%0A%0A    def __unicode__(self):%0A        return self.name%0A%0Aclass Project(models.Model):%0A    thread = models.ForeignKey(Thread)%0A    topics = models.ManyToManyField(Topic, verbose_name=%22list of topics%22, through='ProjectTopicWeight', through_fields=('project', 'topic'))%0A%0A    def __unicode__(self):%0A        return self.thread.title%0A%0A    def pollResults():%0A        return%0A%0Aclass ProjectTopicWeight(models.Model):%0A    project = models.ForeignKey(Project)%0A    topic = models.ForeignKey(Topic)%0A    weight = models.DecimalField(max_digits=3, decimal_places=2)%0A%0A    def save(self, *args, **kwargs):%0A        self.validateWeith()%0A        return super(ProjectTopicWeight, self).save(*args, **kwargs)%0A%0A    def validateWeith(self):%0A        total = 100%0A        if total %3E 100:%0A            raise ValueError('The weight assigned for this topic is incorrect. The total weight exceeds 100')%0A        # validate the weight according the topics in the project%0A        # save many%0A%0A%0Aclass Vote(models.Model):%0A    user = models.ForeignKey(common.AUTH_USER_MODEL)%0A    weight = models.DecimalField(max_digits=3, decimal_places=2)%0A    agree = models.BooleanField()%0A%0A    class Meta:%0A        abstract = True%0A%0A%0Aclass ProjectVote(Vote):%0A    project = models.ForeignKey(Project)%0A%0A    def save(self, *args, **kwargs):%0A        self.calculateWeight();%0A        self.updateFollowing()%0A        return super(Vote, self).save(*args, **kwargs)%0A%0A    def calculateWeight(self):%0A        pass%0A        # self.weight = 100%0A        # Call users to get followers and calculate price%0A        # based on topic of the Project%0A        # Take into account the votes%0A%0A    def updateFollowing(self):%0A        pass%0A        # Call user to get following and update Projects with%0A        # saveAll%0A%0A%0Aclass CommentVote(Vote):%0A    comment = models.ForeignKey(Project)%0A%0A%0Aclass Delegate(models.Model):%0A    user = models.ForeignKey(common.AUTH_USER_MODEL, related_name=%22user_set%22)%0A    delegate = models.ForeignKey(common.AUTH_USER_MODEL, related_name=%22delegate_set%22)%0A    topic = models.ForeignKey(Topic)%0A

Create a simple thread