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 | |
parent | e19d3b03440f09b925b8a9fb6e2218823c959f3d (diff) |
added url and section to publications
-rw-r--r-- | app/publications/admin.py | 2 | ||||
-rw-r--r-- | app/publications/migrations/0005_auto_20190131_1100.py | 23 | ||||
-rw-r--r-- | app/publications/models.py | 34 |
3 files changed, 42 insertions, 17 deletions
diff --git a/app/publications/admin.py b/app/publications/admin.py index 96a93ec..c9c30ba 100644 --- a/app/publications/admin.py +++ b/app/publications/admin.py @@ -12,7 +12,7 @@ class PublicationAdmin(admin.ModelAdmin): search_fields = ['name'] fieldsets = ( ('', { - 'fields': ('name', 'notes', 'status'), + 'fields': ('name', 'url', 'notes', 'section', 'status'), 'classes': ('show', 'extrapretty', 'wide') }), ) diff --git a/app/publications/migrations/0005_auto_20190131_1100.py b/app/publications/migrations/0005_auto_20190131_1100.py new file mode 100644 index 0000000..a800dcf --- /dev/null +++ b/app/publications/migrations/0005_auto_20190131_1100.py @@ -0,0 +1,23 @@ +# Generated by Django 2.1.1 on 2019-01-31 11:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('publications', '0004_pitchidea'), + ] + + operations = [ + migrations.AddField( + model_name='publication', + name='section', + field=models.ManyToManyField(blank=True, to='publications.Section'), + ), + migrations.AddField( + model_name='publication', + name='url', + field=models.CharField(blank=True, max_length=250), + ), + ] 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) |