diff options
author | luxagraf <sng@luxagraf.net> | 2019-01-31 10:01:38 -0600 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2019-01-31 10:01:38 -0600 |
commit | 34f95ec85a7956515f810c9fda7d9650edc7da30 (patch) | |
tree | cdccda2120974cd4d14e594c4509450206313711 /app/publications/models.py | |
parent | e19d3b03440f09b925b8a9fb6e2218823c959f3d (diff) |
added url and section to publications
Diffstat (limited to 'app/publications/models.py')
-rw-r--r-- | app/publications/models.py | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/app/publications/models.py b/app/publications/models.py index d47d5f6..a7f0c1a 100644 --- a/app/publications/models.py +++ b/app/publications/models.py @@ -8,8 +8,26 @@ from taggit.managers import TaggableManager from taxonomy.models import TaggedItems +class Section(models.Model): + """ Generic model for Categories """ + name = models.CharField(max_length=250) + slug = models.SlugField(blank=True) + date_created = models.DateTimeField(blank=True, auto_now_add=True, editable=False) + date_updated = models.DateTimeField(blank=True, auto_now=True, editable=False) + + def __str__(self): + return self.name + + def save(self, *args, **kwargs): + if self._state.adding: + self.slug = slugify(self.name)[:50] + super(Section, self).save() + + class Publication(models.Model): name = models.CharField(max_length=250) + url = models.CharField(max_length=250, blank=True) + section = models.ManyToManyField(Section, blank=True) slug = models.SlugField(unique_for_date='pub_date', blank=True) notes = models.TextField(blank=True) tags = TaggableManager(through=TaggedItems, blank=True, help_text='Topics Covered') @@ -37,22 +55,6 @@ class Publication(models.Model): super(Publication, self).save() -class Section(models.Model): - """ Generic model for Categories """ - name = models.CharField(max_length=250) - slug = models.SlugField(blank=True) - date_created = models.DateTimeField(blank=True, auto_now_add=True, editable=False) - date_updated = models.DateTimeField(blank=True, auto_now=True, editable=False) - - def __str__(self): - return self.name - - def save(self, *args, **kwargs): - if self._state.adding: - self.slug = slugify(self.name)[:50] - super(Section, self).save() - - class Editor(models.Model): first_name = models.CharField(max_length=250) last_name = models.CharField(max_length=250) |