diff options
author | 2011-10-17 01:34:04 +0200 | |
---|---|---|
committer | 2011-10-17 01:34:04 +0200 | |
commit | 4b29603d79cc1f79c66786684f27ec9abfbaa825 (patch) | |
tree | 655c321b7ee3b0cc919ab3b7bf937b50fc13c69c /projects/models.py | |
download | dotfiles-4b29603d79cc1f79c66786684f27ec9abfbaa825.tar.gz dotfiles-4b29603d79cc1f79c66786684f27ec9abfbaa825.zip |
Initial commit
Diffstat (limited to 'projects/models.py')
-rw-r--r-- | projects/models.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/projects/models.py b/projects/models.py new file mode 100644 index 0000000..4b2b49a --- /dev/null +++ b/projects/models.py @@ -0,0 +1,59 @@ +from django.db import models +from main.models import Tag, Activity +from django.db.models.signals import post_save, post_delete + +class Language(models.Model): + name = models.CharField(max_length=100) + + def __unicode__(self): + return self.name + +class Screenshot(models.Model): + url = models.URLField(max_length=255) + description = models.CharField(max_length=300) + + def __unicode__(self): + return self.description + +class Project(models.Model): + STATUS_CHOICES = ( + ('active', "Active"), + ('onhold', "On Hold"), + ('dropped', "Dropped"), + ) + + slug = models.SlugField(max_length=255, primary_key=True) + name = models.CharField(max_length=300) + status = models.CharField(max_length=8, choices=STATUS_CHOICES) + tagline = models.CharField(max_length=140, null=True, blank=True) + languages = models.ManyToManyField(Language, null=True, blank=True) + source_url = models.URLField(max_length=255, null=True, blank=True) + bugtracker_url = models.URLField(max_length=255, null=True, blank=True) + wiki_url = models.URLField(max_length=255, null=True, blank=True) + description = models.TextField() + screenshots = models.ForeignKey(Screenshot, null=True, blank=True) +# tags = models.ManyToManyField(Tag, null=True, blank=True) + + def __unicode__(self): + return self.name + +def project_saved_callback(sender, **kwargs): + if kwargs['created']: + acttype = 'add' + else: + acttype = 'edit' + + a = Activity(actcategory='project', + actdescription=kwargs["instance"].name, + acttype = acttype, + objpk = kwargs["instance"].pk) + a.save() + +def project_deleted_callback(sender, **kwargs): + a = Activity(actcategory='project', + actdescription=kwargs["instance"].name, + acttype = 'delete') + a.save() + +post_save.connect(project_saved_callback, sender=Project) +post_delete.connect(project_deleted_callback, sender=Project) |