1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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()
|