summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/photos/urls.py2
-rw-r--r--app/publications/__init__.py0
-rw-r--r--app/publications/admin.py65
-rw-r--r--app/publications/migrations/0001_initial.py73
-rw-r--r--app/publications/migrations/0002_editor_section.py18
-rw-r--r--app/publications/migrations/0003_auto_20190131_0923.py37
-rw-r--r--app/publications/migrations/__init__.py0
-rw-r--r--app/publications/models.py107
-rw-r--r--app/publications/urls.py24
-rw-r--r--app/publications/views.py20
-rw-r--r--app/taxonomy/migrations/0001_initial.py52
-rw-r--r--app/taxonomy/migrations/__init__.py0
-rw-r--r--app/taxonomy/models.py39
13 files changed, 436 insertions, 1 deletions
diff --git a/app/photos/urls.py b/app/photos/urls.py
index 5f2a5de..6673135 100644
--- a/app/photos/urls.py
+++ b/app/photos/urls.py
@@ -18,7 +18,7 @@ urlpatterns = [
name="daily_photo_list"
),
path(
- r'data/(<str:slug>/$',
+ r'data/(<str:slug>/',
views.photo_json
),
re_path(
diff --git a/app/publications/__init__.py b/app/publications/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/publications/__init__.py
diff --git a/app/publications/admin.py b/app/publications/admin.py
new file mode 100644
index 0000000..a09e7d5
--- /dev/null
+++ b/app/publications/admin.py
@@ -0,0 +1,65 @@
+from django.contrib import admin
+from utils.widgets import LGEntryForm
+
+from .models import Publication, Editor, Pitch, Section
+
+
+@admin.register(Publication)
+class PublicationAdmin(admin.ModelAdmin):
+ form = LGEntryForm
+ list_display = ('name', 'status')
+ list_filter = ('status',)
+ search_fields = ['name']
+ fieldsets = (
+ ('', {
+ 'fields': ('name', 'notes', 'status'),
+ 'classes': ('show', 'extrapretty', 'wide')
+ }),
+ )
+
+
+@admin.register(Editor)
+class EditorAdmin(admin.ModelAdmin):
+ list_display = ('last_name', 'first_name', 'publication', 'sections')
+ list_filter = ('publication', 'section')
+ search_fields = ['first_name', 'last_name', 'publication__name', 'section']
+ filter_horizontal = ('section',)
+
+ def sections(self, obj):
+ return [section for section in obj.section.all()]
+ sections.boolean = False
+
+ fieldsets = (
+ ('', {
+ 'fields': ('first_name', 'last_name', 'email', 'publication', 'section', 'notes', 'phone', 'twitter'),
+ 'classes': ('show', 'extrapretty', 'wide')
+ }),
+ )
+
+
+@admin.register(Pitch)
+class PitchAdmin(admin.ModelAdmin):
+ list_display = ('title', 'date_sent', 'accepted', 'editor', 'publication')
+ list_filter = ('editor__publication', 'editor__section')
+
+ def publication(self, obj):
+ return obj.editor.publication
+ publication.boolean = False
+
+ fieldsets = (
+ ('', {
+ 'fields': ('title', 'pitch', 'editor', 'accepted', 'date_sent'),
+ 'classes': ('show', 'extrapretty', 'wide')
+ }),
+ )
+
+
+@admin.register(Section)
+class SectionAdmin(admin.ModelAdmin):
+ list_display = ('name',)
+ fieldsets = (
+ ('', {
+ 'fields': ('name',),
+ 'classes': ('show', 'extrapretty', 'wide')
+ }),
+ )
diff --git a/app/publications/migrations/0001_initial.py b/app/publications/migrations/0001_initial.py
new file mode 100644
index 0000000..9212571
--- /dev/null
+++ b/app/publications/migrations/0001_initial.py
@@ -0,0 +1,73 @@
+# Generated by Django 2.1.1 on 2019-01-31 08:56
+
+from django.db import migrations, models
+import django.db.models.deletion
+import taggit.managers
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ('taxonomy', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Editor',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('first_name', models.CharField(max_length=250)),
+ ('last_name', models.CharField(max_length=250)),
+ ('email', models.CharField(blank=True, max_length=250)),
+ ('phone', models.CharField(blank=True, max_length=250)),
+ ('twitter', models.CharField(blank=True, max_length=250)),
+ ('slug', models.SlugField(blank=True)),
+ ('notes', models.TextField(blank=True)),
+ ('date_created', models.DateTimeField(auto_now_add=True)),
+ ('date_updated', models.DateTimeField(auto_now=True)),
+ ],
+ options={
+ 'ordering': ('-last_name', '-date_created'),
+ },
+ ),
+ migrations.CreateModel(
+ name='Pitch',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('title', models.CharField(max_length=250)),
+ ('pitch', models.TextField()),
+ ('slug', models.SlugField(blank=True)),
+ ('accepted', models.BooleanField(blank=True, null=True)),
+ ('date_sent', models.DateTimeField(blank=True, null=True)),
+ ('date_created', models.DateTimeField(auto_now_add=True)),
+ ('date_updated', models.DateTimeField(auto_now=True)),
+ ('editor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='publications.Editor')),
+ ],
+ options={
+ 'ordering': ('-title', '-date_sent'),
+ },
+ ),
+ migrations.CreateModel(
+ name='Publication',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=250)),
+ ('slug', models.SlugField(blank=True, unique_for_date='pub_date')),
+ ('notes', models.TextField(blank=True)),
+ ('status', models.IntegerField(choices=[(0, 'Have Published With'), (1, 'Published')], default=0)),
+ ('date_created', models.DateTimeField(auto_now_add=True)),
+ ('date_updated', models.DateTimeField(auto_now=True)),
+ ('tags', taggit.managers.TaggableManager(blank=True, help_text='Topics Covered', through='taxonomy.TaggedItems', to='taxonomy.LuxTag', verbose_name='Tags')),
+ ],
+ options={
+ 'ordering': ('-name', '-date_created'),
+ },
+ ),
+ migrations.AddField(
+ model_name='editor',
+ name='publication',
+ field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='publications.Publication'),
+ ),
+ ]
diff --git a/app/publications/migrations/0002_editor_section.py b/app/publications/migrations/0002_editor_section.py
new file mode 100644
index 0000000..a4675ae
--- /dev/null
+++ b/app/publications/migrations/0002_editor_section.py
@@ -0,0 +1,18 @@
+# Generated by Django 2.1.1 on 2019-01-31 09:00
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('publications', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='editor',
+ name='section',
+ field=models.CharField(blank=True, max_length=50),
+ ),
+ ]
diff --git a/app/publications/migrations/0003_auto_20190131_0923.py b/app/publications/migrations/0003_auto_20190131_0923.py
new file mode 100644
index 0000000..6844c55
--- /dev/null
+++ b/app/publications/migrations/0003_auto_20190131_0923.py
@@ -0,0 +1,37 @@
+# Generated by Django 2.1.1 on 2019-01-31 09:23
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('publications', '0002_editor_section'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Section',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=250)),
+ ('slug', models.SlugField(blank=True)),
+ ('date_created', models.DateTimeField(auto_now_add=True)),
+ ('date_updated', models.DateTimeField(auto_now=True)),
+ ],
+ ),
+ migrations.RemoveField(
+ model_name='editor',
+ name='section',
+ ),
+ migrations.AlterField(
+ model_name='publication',
+ name='status',
+ field=models.IntegerField(choices=[(0, 'Not Published'), (1, 'Published')], default=0),
+ ),
+ migrations.AddField(
+ model_name='editor',
+ name='section',
+ field=models.ManyToManyField(blank=True, to='publications.Section'),
+ ),
+ ]
diff --git a/app/publications/migrations/__init__.py b/app/publications/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/publications/migrations/__init__.py
diff --git a/app/publications/models.py b/app/publications/models.py
new file mode 100644
index 0000000..9163602
--- /dev/null
+++ b/app/publications/models.py
@@ -0,0 +1,107 @@
+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 Publication(models.Model):
+ name = models.CharField(max_length=250)
+ 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)
+
+ 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 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)
+ 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()
diff --git a/app/publications/urls.py b/app/publications/urls.py
new file mode 100644
index 0000000..3f43b32
--- /dev/null
+++ b/app/publications/urls.py
@@ -0,0 +1,24 @@
+from django.urls import path
+
+from . import views
+
+app_name = "publications"
+
+urlpatterns = [
+ path(
+ r'',
+ views.PubListView.as_view(),
+ {'page': 1},
+ name="list"
+ ),
+ path(
+ r'<int:page>/',
+ views.PubListView.as_view(),
+ name="list"
+ ),
+ path(
+ r'<str:slug>',
+ views.PubsDetailView.as_view(),
+ name="pub-detail"
+ ),
+]
diff --git a/app/publications/views.py b/app/publications/views.py
new file mode 100644
index 0000000..0398dcb
--- /dev/null
+++ b/app/publications/views.py
@@ -0,0 +1,20 @@
+from django.views.generic.detail import DetailView
+
+from utils.views import PaginatedListView
+
+from .models import Publication
+
+
+class PubListView(PaginatedListView):
+ """
+ Return a list of Publications
+ """
+ queryset = Publication.objects.all()
+
+
+class PubDetailView(DetailView):
+ """
+ Return a detail view of Publication
+ """
+ model = Publication
+ slug_field = "slug"
diff --git a/app/taxonomy/migrations/0001_initial.py b/app/taxonomy/migrations/0001_initial.py
new file mode 100644
index 0000000..184a5f0
--- /dev/null
+++ b/app/taxonomy/migrations/0001_initial.py
@@ -0,0 +1,52 @@
+# Generated by Django 2.1.5 on 2019-01-25 02:12
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ('contenttypes', '0002_remove_content_type_name'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Category',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=250)),
+ ('color_rgb', models.CharField(blank=True, max_length=20)),
+ ('slug', models.SlugField(blank=True)),
+ ('date_created', models.DateTimeField(auto_now_add=True)),
+ ('date_updated', models.DateTimeField(auto_now=True)),
+ ],
+ ),
+ migrations.CreateModel(
+ name='LuxTag',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('name', models.CharField(max_length=100, unique=True, verbose_name='Name')),
+ ('slug', models.SlugField(max_length=100, unique=True, verbose_name='Slug')),
+ ('color_rgb', models.CharField(blank=True, max_length=20)),
+ ],
+ options={
+ 'verbose_name': 'Tag',
+ 'verbose_name_plural': 'Tags',
+ },
+ ),
+ migrations.CreateModel(
+ name='TaggedItems',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('object_id', models.IntegerField(db_index=True, verbose_name='Object id')),
+ ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='taxonomy_taggeditems_tagged_items', to='contenttypes.ContentType', verbose_name='Content type')),
+ ('tag', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='taxonomy_taggeditems_items', to='taxonomy.LuxTag')),
+ ],
+ options={
+ 'abstract': False,
+ },
+ ),
+ ]
diff --git a/app/taxonomy/migrations/__init__.py b/app/taxonomy/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/taxonomy/migrations/__init__.py
diff --git a/app/taxonomy/models.py b/app/taxonomy/models.py
new file mode 100644
index 0000000..38f1bf7
--- /dev/null
+++ b/app/taxonomy/models.py
@@ -0,0 +1,39 @@
+from django.contrib.gis.db import models
+from django.urls import reverse
+from django.utils.translation import ugettext_lazy as _
+from django.utils.functional import cached_property
+
+from taggit.models import TagBase, GenericTaggedItemBase
+
+
+class LuxTag(TagBase):
+ ''' override the default taggit model to add some color '''
+ color_rgb = models.CharField(max_length=20, blank=True)
+
+ class Meta:
+ verbose_name = _("Tag")
+ verbose_name_plural = _("Tags")
+
+ @cached_property
+ def get_absolute_url(self):
+ return reverse("taxonomy:tags", kwargs={"slug": self.slug})
+
+
+class TaggedItems(GenericTaggedItemBase):
+ ''' necessary with custom tag model, lets you still use TaggableManager'''
+ tag = models.ForeignKey(LuxTag, related_name="%(app_label)s_%(class)s_items", on_delete=models.CASCADE)
+
+
+class Category(models.Model):
+ """ Generic model for Categories """
+ name = models.CharField(max_length=250)
+ color_rgb = models.CharField(max_length=20, blank=True)
+ 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 get_absolute_url(self):
+ return reverse("taxonomy:categories", kwargs={"slug": self.slug})