summaryrefslogtreecommitdiff
path: root/bak/unused_apps/publications/models.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2023-07-28 13:39:02 -0500
committerluxagraf <sng@luxagraf.net>2023-07-28 13:39:02 -0500
commit9a620cf42bf1fe6977e378bd834b41ff4a593dde (patch)
treecf41a0582681cecaf88a30bfe409f9c2be57972a /bak/unused_apps/publications/models.py
parent6e5897117124cd60ae81efb1574c6347f48e60e5 (diff)
main: removed some apps I wasn't using and added bak to git to preserve
a copy of old apps
Diffstat (limited to 'bak/unused_apps/publications/models.py')
-rw-r--r--bak/unused_apps/publications/models.py133
1 files changed, 133 insertions, 0 deletions
diff --git a/bak/unused_apps/publications/models.py b/bak/unused_apps/publications/models.py
new file mode 100644
index 0000000..05f7267
--- /dev/null
+++ b/bak/unused_apps/publications/models.py
@@ -0,0 +1,133 @@
+from django.contrib.gis.db import models
+from django.utils import timezone
+from django.utils.text import slugify
+from django.urls import reverse
+
+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')
+ PUB_STATUS = (
+ (0, 'Not Published'),
+ (1, 'Published'),
+ )
+ status = models.IntegerField(choices=PUB_STATUS, default=0)
+ date_created = models.DateTimeField(blank=True, auto_now_add=True, editable=False)
+ date_updated = models.DateTimeField(blank=True, auto_now=True, editable=False)
+ pays = models.BooleanField(default=True)
+ pays_amount = models.CharField(max_length=100, blank=True)
+ submission_period_start = models.DateField(blank=True, null=True)
+ submission_period_end = models.DateField(blank=True, null=True)
+
+ class Meta:
+ ordering = ('-name', '-date_created')
+
+ def __str__(self):
+ return self.name
+
+ def get_absolute_url(self):
+ return reverse("publications:pub-detail", kwargs={"slug": self.slug})
+
+ def save(self, *args, **kwargs):
+ if not self.id:
+ self.date_created = timezone.now()
+ self.date_updated = timezone.now()
+ super(Publication, self).save()
+
+
+class Editor(models.Model):
+ first_name = models.CharField(max_length=250)
+ last_name = models.CharField(max_length=250)
+ email = models.CharField(max_length=250, blank=True)
+ phone = models.CharField(max_length=250, blank=True)
+ twitter = models.CharField(max_length=250, blank=True)
+ slug = models.SlugField(blank=True)
+ notes = models.TextField(blank=True)
+ publication = models.ForeignKey(Publication, on_delete=models.SET_NULL, blank=True, null=True)
+ section = models.ManyToManyField(Section, 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)
+
+ class Meta:
+ ordering = ('-last_name', '-date_created')
+
+ def __str__(self):
+ return "{0} {1}".format(self.first_name, self.last_name)
+
+ def get_absolute_url(self):
+ return reverse("publications:pub-detail", kwargs={"slug": self.slug})
+
+ def save(self, *args, **kwargs):
+ if self._state.adding:
+ self.slug = slugify('%s %s' % (self.first_name, self.last_name))[:50]
+ self.date_created = timezone.now()
+ self.date_updated = timezone.now()
+ super(Editor, self).save()
+
+
+class Pitch(models.Model):
+ title = models.CharField(max_length=250)
+ pitch = models.TextField()
+ slug = models.SlugField(blank=True)
+ editor = models.ForeignKey(Editor, on_delete=models.SET_NULL, blank=True, null=True)
+ accepted = models.BooleanField(null=True, blank=True)
+ date_sent = models.DateTimeField(blank=True, null=True)
+ date_created = models.DateTimeField(blank=True, auto_now_add=True, editable=False)
+ date_updated = models.DateTimeField(blank=True, auto_now=True, editable=False)
+
+ class Meta:
+ ordering = ('-title', '-date_sent')
+
+ def __str__(self):
+ return self.title
+
+ def save(self, *args, **kwargs):
+ if self._state.adding:
+ self.slug = slugify(self.title)[:50]
+ self.date_created = timezone.now()
+ self.date_updated = timezone.now()
+ super(Pitch, self).save()
+
+
+class PitchIdea(models.Model):
+ title = models.CharField(max_length=250)
+ pitch = models.TextField()
+ publication = models.ForeignKey(Publication, on_delete=models.SET_NULL, blank=True, null=True)
+ date_created = models.DateTimeField(blank=True, auto_now_add=True, editable=False)
+ date_updated = models.DateTimeField(blank=True, auto_now=True, editable=False)
+
+ class Meta:
+ ordering = ('-title', '-date_created')
+
+ def __str__(self):
+ return self.title
+
+ def save(self, *args, **kwargs):
+ if self._state.adding:
+ self.date_created = timezone.now()
+ self.date_updated = timezone.now()
+ super(PitchIdea, self).save()