diff options
author | luxagraf <sng@luxagraf.net> | 2015-11-15 08:27:16 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2015-11-15 08:27:16 -0500 |
commit | 10402b86a75c83a02945b5528010dcefab41fc37 (patch) | |
tree | 7a6f7f22f44d15757b805b45d0649b867c3c2ccb /app/resume/models.py | |
parent | 623974bd1b0a130be71f5db7b41c38c43b0bf613 (diff) |
added resume and income apps
Diffstat (limited to 'app/resume/models.py')
-rw-r--r-- | app/resume/models.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/app/resume/models.py b/app/resume/models.py new file mode 100644 index 0000000..4df639e --- /dev/null +++ b/app/resume/models.py @@ -0,0 +1,40 @@ +from django.db import models +from django.core.urlresolvers import reverse + +# http://freewisdom.org/projects/python-markdown/ +import markdown + + +class Publisher(models.Model): + name = models.CharField(max_length=200) + slug = models.SlugField(max_length=50) + body_markdown = models.TextField(null=True, blank=True) + body_html = models.TextField(null=True, blank=True) + url = models.CharField(max_length=200, blank=True, null=True) + + def __str__(self): + return self.name + + +class PubItem(models.Model): + title = models.CharField(max_length=200) + slug = models.CharField(max_length=50) + body_markdown = models.TextField(null=True, blank=True) + body_html = models.TextField(null=True, blank=True) + url = models.CharField(max_length=200, blank=True, null=True) + pub_date = models.CharField(max_length=40, blank=True, null=True) + publisher = models.ForeignKey(Publisher) + + class Meta: + ordering = ('-pub_date',) + + def __str__(self): + return self.title + + def get_absolute_url(self): + return reverse("resume:detail", kwargs={"publisher": self.publisher.slug, "slug": self.slug}) + + def save(self, *args, **kwargs): + if self.body_markdown: + self.body_html = markdown.markdown(self.body_markdown, extensions=['extra'], safe_mode=False) + super(PubItem, self).save() |