diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/essays/migrations/0010_essay_field_notes.py | 19 | ||||
-rw-r--r-- | app/guides/__init__.py | 0 | ||||
-rw-r--r-- | app/guides/admin.py | 50 | ||||
-rw-r--r-- | app/guides/build.py | 22 | ||||
-rw-r--r-- | app/guides/migrations/0001_initial.py | 60 | ||||
-rw-r--r-- | app/guides/migrations/__init__.py | 0 | ||||
-rw-r--r-- | app/guides/models.py | 88 | ||||
-rw-r--r-- | app/guides/urls.py | 34 | ||||
-rw-r--r-- | app/guides/views.py | 55 | ||||
-rw-r--r-- | app/jrnl/migrations/0042_auto_20190412_1805.py | 24 | ||||
-rw-r--r-- | app/jrnl/migrations/0043_auto_20190704_0903.py | 21 | ||||
-rw-r--r-- | app/locations/migrations/0018_auto_20190414_2124.py | 23 | ||||
-rw-r--r-- | app/locations/models.py | 3 | ||||
-rw-r--r-- | app/photos/migrations/0019_auto_20190704_0903.py | 17 | ||||
-rw-r--r-- | app/sightings/models.py | 2 |
15 files changed, 418 insertions, 0 deletions
diff --git a/app/essays/migrations/0010_essay_field_notes.py b/app/essays/migrations/0010_essay_field_notes.py new file mode 100644 index 0000000..ca15b38 --- /dev/null +++ b/app/essays/migrations/0010_essay_field_notes.py @@ -0,0 +1,19 @@ +# Generated by Django 2.1.7 on 2019-07-04 09:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fieldnotes', '0002_auto_20190303_1222'), + ('essays', '0009_merge_20190414_1500'), + ] + + operations = [ + migrations.AddField( + model_name='essay', + name='field_notes', + field=models.ManyToManyField(blank=True, to='fieldnotes.FieldNote'), + ), + ] diff --git a/app/guides/__init__.py b/app/guides/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/guides/__init__.py diff --git a/app/guides/admin.py b/app/guides/admin.py new file mode 100644 index 0000000..e424385 --- /dev/null +++ b/app/guides/admin.py @@ -0,0 +1,50 @@ +from django.contrib import admin + +from utils.widgets import LGEntryForm + +from .models import Guide + +@admin.register(Guide) +class GuideAdmin(admin.ModelAdmin): + form = LGEntryForm + list_display = ('title', 'pub_date', 'enable_comments', 'status') + list_filter = ('pub_date', 'enable_comments', 'status') + prepopulated_fields = {"slug": ('title',)} + fieldsets = ( + ('Entry', { + 'fields': ( + 'title', + ('sub_title', 'category'), + 'body_markdown', + ('pub_date', 'status'), + 'meta_description', + 'dek', + 'tags', + 'preamble_markdown', + 'featured_image', + 'has_video', + ('slug', 'enable_comments'), + ), + 'classes': ( + 'show', + 'extrapretty', + 'wide' + ) + }), + ('meta', { + 'fields': ( + 'point', + 'afterword', + ('field_notes', 'books'), + ('essays', 'jrnl'), + ), + 'classes': ( + 'hide', + 'extrapretty', + 'wide' + ) + }), + ) + + class Media: + js = ('image-loader.js', 'next-prev-links.js') diff --git a/app/guides/build.py b/app/guides/build.py new file mode 100644 index 0000000..392e991 --- /dev/null +++ b/app/guides/build.py @@ -0,0 +1,22 @@ +import os +from builder.base import BuildNew +from django.urls import reverse +from . import models + + +class BuildEssays(BuildNew): + + def build(self): + self.build_list_view() + self.build_detail_view() + # These are the unique classes for this model: + #self.build_feed("src:feed") + + def build_list_view(self): + response = self.client.get('/essays/') + self.write_file('essays/', response.content) + + +def essaybuilder(): + j = BuildEssays("essays", "essay") + j.build() diff --git a/app/guides/migrations/0001_initial.py b/app/guides/migrations/0001_initial.py new file mode 100644 index 0000000..833dfbe --- /dev/null +++ b/app/guides/migrations/0001_initial.py @@ -0,0 +1,60 @@ +# Generated by Django 2.1.7 on 2019-07-04 09:03 + +import django.contrib.gis.db.models.fields +from django.db import migrations, models +import django.db.models.deletion +import taggit.managers + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('jrnl', '0043_auto_20190704_0903'), + ('books', '0009_book_afflink'), + ('photos', '0019_auto_20190704_0903'), + ('fieldnotes', '0002_auto_20190303_1222'), + ('locations', '0018_auto_20190414_2124'), + ('essays', '0010_essay_field_notes'), + ('taxonomy', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Guide', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=200)), + ('sub_title', models.CharField(blank=True, max_length=200)), + ('dek', models.TextField(blank=True)), + ('preamble_markdown', models.TextField(blank=True)), + ('preamble_html', models.TextField(blank=True)), + ('slug', models.SlugField(unique_for_date='pub_date')), + ('body_html', models.TextField(blank=True)), + ('body_markdown', models.TextField()), + ('pub_date', models.DateTimeField(verbose_name='Date published')), + ('last_updated', models.DateTimeField(auto_now=True)), + ('enable_comments', models.BooleanField(default=False)), + ('status', models.IntegerField(choices=[(0, 'Draft'), (1, 'Published')], default=0)), + ('meta_description', models.CharField(blank=True, max_length=256, null=True)), + ('has_video', models.BooleanField(blank=True, default=False)), + ('point', django.contrib.gis.db.models.fields.PointField(blank=True, null=True, srid=4326)), + ('afterword', models.TextField(blank=True)), + ('afterword_html', models.TextField(blank=True)), + ('books', models.ManyToManyField(blank=True, to='books.Book')), + ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='taxonomy.Category')), + ('essays', models.ManyToManyField(blank=True, to='essays.Essay')), + ('featured_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='photos.LuxImage')), + ('field_notes', models.ManyToManyField(blank=True, to='fieldnotes.FieldNote')), + ('jrnl', models.ManyToManyField(blank=True, to='jrnl.Entry')), + ('location', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='locations.Location')), + ('tags', taggit.managers.TaggableManager(blank=True, help_text='Topics Covered', through='taxonomy.TaggedItems', to='taxonomy.LuxTag', verbose_name='Tags')), + ], + options={ + 'verbose_name_plural': 'Guides', + 'ordering': ('-pub_date',), + 'get_latest_by': 'pub_date', + }, + ), + ] diff --git a/app/guides/migrations/__init__.py b/app/guides/migrations/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/guides/migrations/__init__.py diff --git a/app/guides/models.py b/app/guides/models.py new file mode 100644 index 0000000..1583bee --- /dev/null +++ b/app/guides/models.py @@ -0,0 +1,88 @@ +from django.contrib.gis.db import models +from django.urls import reverse +from django.contrib.sitemaps import Sitemap +import datetime +from itertools import chain + +from taggit.managers import TaggableManager + +from taxonomy.models import TaggedItems, Category +from utils.util import render_images, markdown_to_html +from fieldnotes.models import FieldNote +from books.models import Book +from locations.models import Location +from photos.models import LuxImage +from essays.models import Essay +from jrnl.models import Entry + + +class Guide(models.Model): + title = models.CharField(max_length=200) + sub_title = models.CharField(max_length=200, blank=True) + dek = models.TextField(blank=True) + preamble_markdown = models.TextField(blank=True) + preamble_html = models.TextField(blank=True) + slug = models.SlugField(unique_for_date='pub_date') + body_html = models.TextField(blank=True) + body_markdown = models.TextField() + pub_date = models.DateTimeField('Date published') + last_updated = models.DateTimeField(auto_now=True) + enable_comments = models.BooleanField(default=False) + PUB_STATUS = ( + (0, 'Draft'), + (1, 'Published'), + ) + status = models.IntegerField(choices=PUB_STATUS, default=0) + meta_description = models.CharField(max_length=256, null=True, blank=True) + tags = TaggableManager(through=TaggedItems, blank=True, help_text='Topics Covered') + category = models.ForeignKey(Category, on_delete=models.CASCADE) + featured_image = models.ForeignKey(LuxImage, on_delete=models.CASCADE, null=True, blank=True) + has_video = models.BooleanField(blank=True, default=False) + field_notes = models.ManyToManyField(FieldNote, blank=True) + books = models.ManyToManyField(Book, blank=True) + essays = models.ManyToManyField(Essay, blank=True) + jrnl = models.ManyToManyField(Entry, blank=True) + point = models.PointField(null=True, blank=True) + location = models.ForeignKey(Location, on_delete=models.CASCADE, null=True, blank=True) + afterword = models.TextField(blank=True) + afterword_html = models.TextField(blank=True) + + class Meta: + ordering = ('-pub_date',) + get_latest_by = 'pub_date' + verbose_name_plural = 'Guides' + + def __str__(self): + return self.title + + def get_absolute_url(self): + return reverse('guides:detail', kwargs={"category": self.category, "slug": self.slug}) + + def comment_period_open(self): + return self.enable_comments and datetime.datetime.today() - datetime.timedelta(30) <= self.pub_date + + @property + def get_previous_published(self): + return self.get_previous_by_pub_date(status__exact=1) + + @property + def get_next_published(self): + return self.get_next_by_pub_date(status__exact=1) + + def save(self): + md = render_images(self.body_markdown) + self.body_html = markdown_to_html(md) + self.afterword_html = markdown_to_html(self.afterword) + super(Guide, self).save() + + +class GuideSitemap(Sitemap): + changefreq = "never" + priority = 1.0 + protocol = "https" + + def items(self): + return Guide.objects.filter(status=1) + + def lastmod(self, obj): + return obj.pub_date diff --git a/app/guides/urls.py b/app/guides/urls.py new file mode 100644 index 0000000..c91a5b5 --- /dev/null +++ b/app/guides/urls.py @@ -0,0 +1,34 @@ +from django.urls import path, re_path + +from . import views + +app_name = "guides" + +urlpatterns = [ + path( + r'', + views.GuideListView.as_view(), + {'page': 1}, + name="list" + ), + path( + r'<int:page>/', + views.GuideListView.as_view(), + name="list" + ), + path( + r'<str:category>/<str:slug>', + views.GuideDetailView.as_view(), + name="detail" + ), + path( + r'<str:category>/<str:slug>', + views.GuideDetailViewTXT.as_view(), + name="detail-txt" + ), + path( + r'<str:category>', + views.GuideCatListView.as_view(), + name="list-cat" + ), +] diff --git a/app/guides/views.py b/app/guides/views.py new file mode 100644 index 0000000..8b5aeaa --- /dev/null +++ b/app/guides/views.py @@ -0,0 +1,55 @@ +from django.views.generic import ListView +from django.views.generic.detail import DetailView +from django.contrib.syndication.views import Feed + +from utils.views import PaginatedListView + +from .models import Guide + + +class GuideListView(PaginatedListView): + model = Guide + + def get_queryset(self, **kwargs): + qs = Guide.objects.filter(status=1) + return qs + +class GuideCatListView(PaginatedListView): + model = Guide + + def get_queryset(self, **kwargs): + cat = Category.objects.get(slug=self.kwargs['slug']) + qs = Guide.objects.filter(status=1, category=cat) + return qs + +class GuideDetailView(DetailView): + model = Guide + + +class GuideDetailViewTXT(GuideDetailView): + template_name = "essays/entry_detail.txt" + + +''' +class TopicListView(ListView): + template_name = 'archives/src_home.html' + + def queryset(self): + return Post.objects.filter(topics__slug=self.kwargs['slug']) + + def get_context_data(self, **kwargs): + # Call the base implementation first to get a context + context = super(TopicListView, self).get_context_data(**kwargs) + context['topic'] = Topic.objects.get(slug__exact=self.kwargs['slug']) + return context + + +class SrcRSSFeedView(Feed): + title = "luxagraf:src Code and Technology" + link = "/src/" + description = "Latest postings to luxagraf.net/src" + description_template = 'feeds/blog_description.html' + + def items(self): + return Post.objects.filter(status__exact=1).order_by('-pub_date')[:10] +''' diff --git a/app/jrnl/migrations/0042_auto_20190412_1805.py b/app/jrnl/migrations/0042_auto_20190412_1805.py new file mode 100644 index 0000000..71c0d51 --- /dev/null +++ b/app/jrnl/migrations/0042_auto_20190412_1805.py @@ -0,0 +1,24 @@ +# Generated by Django 2.1.7 on 2019-04-12 18:05 + +import django.contrib.postgres.indexes +import django.contrib.postgres.search +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('jrnl', '0041_auto_20190315_2240'), + ] + + operations = [ + migrations.AddField( + model_name='entry', + name='search_document', + field=django.contrib.postgres.search.SearchVectorField(null=True), + ), + migrations.AddIndex( + model_name='entry', + index=django.contrib.postgres.indexes.GinIndex(fields=['search_document'], name='jrnl_entry_search__a7a10f_gin'), + ), + ] diff --git a/app/jrnl/migrations/0043_auto_20190704_0903.py b/app/jrnl/migrations/0043_auto_20190704_0903.py new file mode 100644 index 0000000..758499a --- /dev/null +++ b/app/jrnl/migrations/0043_auto_20190704_0903.py @@ -0,0 +1,21 @@ +# Generated by Django 2.1.7 on 2019-07-04 09:03 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('jrnl', '0042_auto_20190412_1805'), + ] + + operations = [ + migrations.RemoveIndex( + model_name='entry', + name='jrnl_entry_search__a7a10f_gin', + ), + migrations.RemoveField( + model_name='entry', + name='search_document', + ), + ] diff --git a/app/locations/migrations/0018_auto_20190414_2124.py b/app/locations/migrations/0018_auto_20190414_2124.py new file mode 100644 index 0000000..3d8a02c --- /dev/null +++ b/app/locations/migrations/0018_auto_20190414_2124.py @@ -0,0 +1,23 @@ +# Generated by Django 2.1.7 on 2019-04-14 21:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('locations', '0017_auto_20190217_1849'), + ] + + operations = [ + migrations.AddField( + model_name='location', + name='description', + field=models.TextField(blank=True), + ), + migrations.AddField( + model_name='location', + name='description_html', + field=models.TextField(blank=True), + ), + ] diff --git a/app/locations/models.py b/app/locations/models.py index 50fda3d..f160b1f 100644 --- a/app/locations/models.py +++ b/app/locations/models.py @@ -134,6 +134,8 @@ class Location(models.Model): country_slug = models.CharField(max_length=50, blank=True) region_name = models.CharField(max_length=50, blank=True) region_slug = models.CharField(max_length=50, blank=True) + description = models.TextField(blank=True) + description_html = models.TextField(blank=True) class Meta: ordering = ('-pub_date',) @@ -170,6 +172,7 @@ class Location(models.Model): self.country_slug = self.state.country.slug self.region_name = self.state.country.lux_region.name self.region_slug = self.state.country.lux_region.slug + self.description_html = markdown_to_html(self.description) super(Location, self).save() class Route(models.Model): diff --git a/app/photos/migrations/0019_auto_20190704_0903.py b/app/photos/migrations/0019_auto_20190704_0903.py new file mode 100644 index 0000000..833ee69 --- /dev/null +++ b/app/photos/migrations/0019_auto_20190704_0903.py @@ -0,0 +1,17 @@ +# Generated by Django 2.1.7 on 2019-07-04 09:03 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('photos', '0018_auto_20161130_1218'), + ] + + operations = [ + migrations.AlterModelOptions( + name='luximagesize', + options={'ordering': ('-name', 'id'), 'verbose_name_plural': 'Image Sizes'}, + ), + ] diff --git a/app/sightings/models.py b/app/sightings/models.py index 7527615..2a14e85 100644 --- a/app/sightings/models.py +++ b/app/sightings/models.py @@ -201,6 +201,8 @@ class Sighting(models.Model): self.location = Location.objects.filter(geometry__contains=self.point).get() except Location.MultipleObjectsReturned: for l in Location.objects.filter(geometry__contains=self.point): + print(l) + print(l.parent) if l.parent: self.location = l break |