From dd09ca3810ea0798899870930c3efb388b776a7c Mon Sep 17 00:00:00 2001 From: lxf Date: Sat, 25 May 2019 15:10:38 +0000 Subject: made some changes to use new checkin model --- app/builder/views.py | 1 - .../migrations/0006_remove_essay_has_video.py | 17 ++++ app/essays/migrations/0007_essay_has_video.py | 18 ++++ app/essays/migrations/0008_merge_20190303_1638.py | 14 ++++ app/essays/migrations/0009_merge_20190414_1500.py | 14 ++++ app/figments/admin.py | 46 ---------- app/figments/build.py | 17 ---- app/figments/ebook.py | 79 ------------------ app/figments/models.py | 97 ---------------------- app/figments/urls.py | 38 --------- app/figments/views.py | 42 ---------- app/jrnl/build.py | 3 +- app/links/forms.py | 1 - app/locations/models.py | 9 +- app/photos/models.py | 1 + app/sightings/models.py | 9 +- app/unused_apps/figments/admin.py | 46 ++++++++++ app/unused_apps/figments/build.py | 17 ++++ app/unused_apps/figments/ebook.py | 79 ++++++++++++++++++ app/unused_apps/figments/models.py | 97 ++++++++++++++++++++++ app/unused_apps/figments/urls.py | 38 +++++++++ app/unused_apps/figments/views.py | 42 ++++++++++ app/utils/util.py | 7 +- 23 files changed, 401 insertions(+), 331 deletions(-) create mode 100644 app/essays/migrations/0006_remove_essay_has_video.py create mode 100644 app/essays/migrations/0007_essay_has_video.py create mode 100644 app/essays/migrations/0008_merge_20190303_1638.py create mode 100644 app/essays/migrations/0009_merge_20190414_1500.py delete mode 100644 app/figments/admin.py delete mode 100644 app/figments/build.py delete mode 100644 app/figments/ebook.py delete mode 100644 app/figments/models.py delete mode 100644 app/figments/urls.py delete mode 100644 app/figments/views.py create mode 100644 app/unused_apps/figments/admin.py create mode 100644 app/unused_apps/figments/build.py create mode 100644 app/unused_apps/figments/ebook.py create mode 100644 app/unused_apps/figments/models.py create mode 100644 app/unused_apps/figments/urls.py create mode 100644 app/unused_apps/figments/views.py (limited to 'app') diff --git a/app/builder/views.py b/app/builder/views.py index c0bb5c0..ca4a876 100644 --- a/app/builder/views.py +++ b/app/builder/views.py @@ -7,7 +7,6 @@ from resume.build import pub_builder, resume_builder from books.build import builder as book_builder from sightings.build import builder as sightings_builder from photos.build import builder as photo_builder -from figments.build import builder as figments_builder from notes.build import builder as notes_builder from pages.build import builder as page_builder from fieldnotes.build import builder as fieldnotes_builder diff --git a/app/essays/migrations/0006_remove_essay_has_video.py b/app/essays/migrations/0006_remove_essay_has_video.py new file mode 100644 index 0000000..0842d8b --- /dev/null +++ b/app/essays/migrations/0006_remove_essay_has_video.py @@ -0,0 +1,17 @@ +# Generated by Django 2.1.2 on 2019-02-27 21:22 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('essays', '0005_auto_20190208_0946'), + ] + + operations = [ + migrations.RemoveField( + model_name='essay', + name='has_video', + ), + ] diff --git a/app/essays/migrations/0007_essay_has_video.py b/app/essays/migrations/0007_essay_has_video.py new file mode 100644 index 0000000..0057e95 --- /dev/null +++ b/app/essays/migrations/0007_essay_has_video.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.2 on 2019-02-27 21:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('essays', '0006_remove_essay_has_video'), + ] + + operations = [ + migrations.AddField( + model_name='essay', + name='has_video', + field=models.BooleanField(blank=True, default=False), + ), + ] diff --git a/app/essays/migrations/0008_merge_20190303_1638.py b/app/essays/migrations/0008_merge_20190303_1638.py new file mode 100644 index 0000000..7c155d8 --- /dev/null +++ b/app/essays/migrations/0008_merge_20190303_1638.py @@ -0,0 +1,14 @@ +# Generated by Django 2.1.2 on 2019-03-03 16:38 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('essays', '0007_essay_has_video'), + ('essays', '0006_auto_20190303_1625'), + ] + + operations = [ + ] diff --git a/app/essays/migrations/0009_merge_20190414_1500.py b/app/essays/migrations/0009_merge_20190414_1500.py new file mode 100644 index 0000000..83a8323 --- /dev/null +++ b/app/essays/migrations/0009_merge_20190414_1500.py @@ -0,0 +1,14 @@ +# Generated by Django 2.1.2 on 2019-04-14 15:00 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('essays', '0008_merge_20190303_1638'), + ('essays', '0007_auto_20190414_1455'), + ] + + operations = [ + ] diff --git a/app/figments/admin.py b/app/figments/admin.py deleted file mode 100644 index 34452bd..0000000 --- a/app/figments/admin.py +++ /dev/null @@ -1,46 +0,0 @@ -from django.contrib import admin -from .models import Figment, Series -from utils.widgets import LGEntryForm - - -class FigmentAdmin(admin.ModelAdmin): - form = LGEntryForm - list_display = ('title', 'pub_date', 'get_series') - prepopulated_fields = {"slug": ('title',)} - fieldsets = ( - ('Figment', { - 'fields': ( - 'title', - 'body_markdown', - ('slug', 'status'), - 'pub_date', - ), - 'classes': ( - 'show', - 'extrapretty', - 'wide' - ) - } - ), - ('Extra', { - 'fields': ( - 'dek', - 'prologue', - 'series', - 'published_link', - ), - 'classes': ( - 'collapse', - 'extrapretty', - 'wide' - ) - } - ), - ) - - -class SeriesAdmin(admin.ModelAdmin): - pass - -admin.site.register(Figment, FigmentAdmin) -admin.site.register(Series, SeriesAdmin) diff --git a/app/figments/build.py b/app/figments/build.py deleted file mode 100644 index b656ab0..0000000 --- a/app/figments/build.py +++ /dev/null @@ -1,17 +0,0 @@ -from django.urls import reverse -from builder.base import BuildNew - - -class BuildFigments(BuildNew): - def build(self): - self.build_list_view( - base_path=reverse('figments:list'), - paginate_by=99999 - ) - self.build_detail_view() - self.build_feed('figments:feed') - - -def builder(): - j = BuildFigments("figments", "figment") - j.build() diff --git a/app/figments/ebook.py b/app/figments/ebook.py deleted file mode 100644 index 81210a4..0000000 --- a/app/figments/ebook.py +++ /dev/null @@ -1,79 +0,0 @@ -import os -from ebooklib import epub - -from django.conf import settings -from typogrify.filters import typogrify - - -def generate_epub_file(f): - book = epub.EpubBook() - - # add metadata - book.set_identifier('lux23') - book.set_title(f.title) - book.set_language('en') - - book.add_author('Scott Gilbertson') - - # intro chapter - c1 = epub.EpubHtml(title='Introduction', file_name='intro.xhtml', lang='en') - c1.content = u'

Forward

Thank you for downloading my story %s. I hope you enjoy it and please feel free to email me if you have any questions or comments.

If you enjoy this story and would like to read more, head on over to luxagraf.net.

– Scott Gilbertson
  sng@luxagraf.net

' % f.title - - # chapter - c2 = epub.EpubHtml(title=f.title, file_name='story.xhtml') - c2.content = '

%s

' % f.title - c2.content += typogrify(f.body_html) - - # add chapters to the book - book.add_item(c1) - book.add_item(c2) - # create table of contents - # - add section - # - add auto created links to chapters - - book.toc = (epub.Link('intro.xhtml', 'Introduction', 'intro'), - epub.Link('story.xhtml', f.title, 'story'), - ) - - # add navigation files - book.add_item(epub.EpubNcx()) - book.add_item(epub.EpubNav()) - - # define css style - style = ''' -@namespace epub "http://www.idpf.org/2007/ops"; -body { - font-family: Georgia, Times, Times New Roman, serif; -} -h2 { - text-align: left; - text-transform: uppercase; - font-weight: 200; -} -ol { - list-style-type: none; -} -ol > li:first-child { - margin-top: 0.3em; -} -nav[epub|type~='toc'] > ol > li > ol { - list-style-type:square; -} -nav[epub|type~='toc'] > ol > li > ol > li { - margin-top: 0.3em; -} -''' - - # add css file - nav_css = epub.EpubItem(uid="style_nav", file_name="style/nav.css", media_type="text/css", content=style) - book.add_item(nav_css) - - # create spine - book.spine = ['nav', c1, c2] - path, filename = os.path.split(f.get_absolute_url()) - fpath = '%s%s/' % (settings.FLATFILES_ROOT, path) - if not os.path.isdir(fpath): - os.makedirs(fpath) - bk = '%s%s.epub' % (fpath, f.slug) - # create epub file - epub.write_epub(bk, book, {}) diff --git a/app/figments/models.py b/app/figments/models.py deleted file mode 100644 index 8b22049..0000000 --- a/app/figments/models.py +++ /dev/null @@ -1,97 +0,0 @@ -import datetime -from itertools import chain -from django.db import models -from django.urls import reverse -from django.contrib.sitemaps import Sitemap -from django.contrib.syndication.views import Feed -from django.db.models.signals import post_save -from django.dispatch import receiver - -from utils.util import markdown_to_html - -from .ebook import generate_epub_file - - -class Series(models.Model): - title = models.CharField(max_length=200) - slug = models.CharField(max_length=50) - is_book = models.BooleanField(default=False) - body_markdown = models.TextField(null=True, blank=True) - body_html = models.TextField(null=True, blank=True) - pub_date = models.DateTimeField(auto_now_add=True) - - class Meta: - verbose_name_plural = 'Series' - - def __str__(self): - return self.title - - -class Figment(models.Model): - title = models.CharField(max_length=200) - slug = models.CharField(max_length=50) - pub_date = models.DateTimeField(blank=True) - body_markdown = models.TextField(null=True, blank=True) - prologue = models.TextField(null=True, blank=True) - dek = models.TextField(null=True, blank=True) - body_html = models.TextField(null=True, blank=True) - PUB_STATUS = ( - (0, 'Draft'), - (1, 'Published'), - ) - status = models.IntegerField(choices=PUB_STATUS, default=0) - series = models.ManyToManyField(Series, related_name="series", blank=True) - TEMPLATES = ( - (0, 'default'), - ) - template_name = models.IntegerField(choices=TEMPLATES, default=0) - published_link = models.CharField(max_length=300, help_text="link to online pub", blank=True, null=True) - - class Meta: - ordering = ('-pub_date',) - - def __str__(self): - return self.title - - def get_absolute_url(self): - return reverse("figments:detail", kwargs={"slug": self.slug}) - - def get_series(self): - return "\n".join([s.title for s in self.series.all()]) - - def save(self, *args, **kwargs): - if not self.id and not self.pub_date: - self.pub_date = datetime.datetime.now() - self.body_html = markdown_to_html(self.body_markdown) - super(Figment, self).save() - - -@receiver(post_save, sender=Figment) -def post_save_events(sender, instance, **kwargs): - if instance.body_markdown != instance._loaded_values['body_markdown']: - print("you updated") - generate_epub_file(instance) - else: - print("no update found, not buidling") - - -class LatestFull(Feed): - title = "luxagraf figments: stories less literally true." - link = "/figments/" - description = "Latest postings to luxagraf.net/figments" - description_template = 'feeds/blog_description.html' - - def items(self): - return Figment.objects.filter(status__exact=1).order_by('-pub_date')[:10] - - -class FigmentSitemap(Sitemap): - changefreq = "never" - priority = 0.7 - protocol = "https" - - def items(self): - return list(chain(Figment.objects.filter(status__exact=1), Series.objects.all())) - - def lastmod(self, obj): - return obj.pub_date diff --git a/app/figments/urls.py b/app/figments/urls.py deleted file mode 100644 index 4a37cf5..0000000 --- a/app/figments/urls.py +++ /dev/null @@ -1,38 +0,0 @@ -from django.conf.urls import url - -from . import views - -app_name = "figments" - -urlpatterns = [ - url( - r'^feed.xml', - views.FigRSSFeedView(), - name="feed" - ), - url( - r'series/$', - views.SeriesListView.as_view(), - name='list_series' - ), - url( - r'(?P[-\w]+).txt$', - views.FigmentDetailViewTXT.as_view(), - name="detail-txt" - ), - url( - r'(?P[-\w]+).amp$', - views.FigmentDetailViewAMP.as_view(), - name="detail-amp" - ), - url( - r'(?P[-\w]+)$', - views.FigmentDetailView.as_view(), - name='detail' - ), - url( - r'^$', - views.FigmentListView.as_view(), - name='list' - ), -] diff --git a/app/figments/views.py b/app/figments/views.py deleted file mode 100644 index 6521c29..0000000 --- a/app/figments/views.py +++ /dev/null @@ -1,42 +0,0 @@ -from django.views.generic import ListView, DetailView -from django.contrib.syndication.views import Feed - -from .models import Figment, Series - - -class FigmentListView(ListView): - model = Figment - template_name = "archives/figments.html" - context_object_name = 'object_list' - - def get_queryset(self): - return Figment.objects.filter(status__exact=1).order_by('-pub_date') - - -class SeriesListView(ListView): - model = Series - template_name = "archives/figments_series.html" - context_object_name = 'object_list' - - -class FigmentDetailView(DetailView): - model = Figment - template_name = "details/figments.html" - - -class FigmentDetailViewTXT(FigmentDetailView): - template_name = "details/entry.txt" - - -class FigmentDetailViewAMP(FigmentDetailView): - template_name = "details/entry.amp" - - -class FigRSSFeedView(Feed): - title = "luxagraf figments: stories less literally true." - link = "/figments/" - description = "Latest postings to luxagraf.net/figments" - description_template = 'feeds/blog_description.html' - - def items(self): - return Figment.objects.filter(status__exact=1).order_by('-pub_date')[:10] diff --git a/app/jrnl/build.py b/app/jrnl/build.py index 0b3826a..dcebace 100644 --- a/app/jrnl/build.py +++ b/app/jrnl/build.py @@ -46,13 +46,14 @@ class BuildJrnl(BuildNew): status__exact=1, location__state__country__lux_region=c.id ) + print(c) pages = self.get_pages(qs, 24) for page in range(pages): base_path = reverse("jrnl:list_country", kwargs={'slug': c.slug, 'page': page + 1}) response = self.client.get(base_path) print(response.content) if page == 0: - self.write_file(base_path[:-2], response.content) + self.write_file(base_path, response.content) else: self.write_file(base_path, response.content) diff --git a/app/links/forms.py b/app/links/forms.py index b7a2343..8755401 100644 --- a/app/links/forms.py +++ b/app/links/forms.py @@ -1,4 +1,3 @@ from django import forms from .models import Link -from dal import autocomplete diff --git a/app/locations/models.py b/app/locations/models.py index 6e8db7c..50fda3d 100644 --- a/app/locations/models.py +++ b/app/locations/models.py @@ -245,10 +245,11 @@ class LuxCheckIn(models.Model): return self.point.y def save(self): - try: - self.location = Location.objects.filter(geometry__contains=self.point).get() - except Location.DoesNotExist: - raise forms.ValidationError("There is no location associated with that point, add it: %sadmin/locations/location/add/" % (settings.BASE_URL)) + if not self.location: + try: + self.location = Location.objects.filter(geometry__contains=self.point).get() + except Location.DoesNotExist: + raise forms.ValidationError("There is no location associated with that point, add it: %sadmin/locations/location/add/" % (settings.BASE_URL)) self.location_name = self.location.name self.state_name = self.location.state.name self.country_name = self.location.state.country.name diff --git a/app/photos/models.py b/app/photos/models.py index df8eac4..fd924f3 100644 --- a/app/photos/models.py +++ b/app/photos/models.py @@ -39,6 +39,7 @@ class LuxImageSize(models.Model): quality = models.IntegerField() class Meta: + ordering = ('-name', 'id') verbose_name_plural = 'Image Sizes' def __str__(self): diff --git a/app/sightings/models.py b/app/sightings/models.py index 3852b1c..7527615 100644 --- a/app/sightings/models.py +++ b/app/sightings/models.py @@ -198,9 +198,12 @@ class Sighting(models.Model): if not self.point: self.point = Sighting.objects.latest().point try: - self.location = Location.objects.filter( - geometry__contains=self.point - ).get() + self.location = Location.objects.filter(geometry__contains=self.point).get() + except Location.MultipleObjectsReturned: + for l in Location.objects.filter(geometry__contains=self.point): + if l.parent: + self.location = l + break except Location.DoesNotExist: raise forms.ValidationError("There is no location associated with that point, add it: %sadmin/locations/location/add/" % (settings.BASE_URL)) self.ap_common_name = self.ap.common_name diff --git a/app/unused_apps/figments/admin.py b/app/unused_apps/figments/admin.py new file mode 100644 index 0000000..34452bd --- /dev/null +++ b/app/unused_apps/figments/admin.py @@ -0,0 +1,46 @@ +from django.contrib import admin +from .models import Figment, Series +from utils.widgets import LGEntryForm + + +class FigmentAdmin(admin.ModelAdmin): + form = LGEntryForm + list_display = ('title', 'pub_date', 'get_series') + prepopulated_fields = {"slug": ('title',)} + fieldsets = ( + ('Figment', { + 'fields': ( + 'title', + 'body_markdown', + ('slug', 'status'), + 'pub_date', + ), + 'classes': ( + 'show', + 'extrapretty', + 'wide' + ) + } + ), + ('Extra', { + 'fields': ( + 'dek', + 'prologue', + 'series', + 'published_link', + ), + 'classes': ( + 'collapse', + 'extrapretty', + 'wide' + ) + } + ), + ) + + +class SeriesAdmin(admin.ModelAdmin): + pass + +admin.site.register(Figment, FigmentAdmin) +admin.site.register(Series, SeriesAdmin) diff --git a/app/unused_apps/figments/build.py b/app/unused_apps/figments/build.py new file mode 100644 index 0000000..b656ab0 --- /dev/null +++ b/app/unused_apps/figments/build.py @@ -0,0 +1,17 @@ +from django.urls import reverse +from builder.base import BuildNew + + +class BuildFigments(BuildNew): + def build(self): + self.build_list_view( + base_path=reverse('figments:list'), + paginate_by=99999 + ) + self.build_detail_view() + self.build_feed('figments:feed') + + +def builder(): + j = BuildFigments("figments", "figment") + j.build() diff --git a/app/unused_apps/figments/ebook.py b/app/unused_apps/figments/ebook.py new file mode 100644 index 0000000..81210a4 --- /dev/null +++ b/app/unused_apps/figments/ebook.py @@ -0,0 +1,79 @@ +import os +from ebooklib import epub + +from django.conf import settings +from typogrify.filters import typogrify + + +def generate_epub_file(f): + book = epub.EpubBook() + + # add metadata + book.set_identifier('lux23') + book.set_title(f.title) + book.set_language('en') + + book.add_author('Scott Gilbertson') + + # intro chapter + c1 = epub.EpubHtml(title='Introduction', file_name='intro.xhtml', lang='en') + c1.content = u'

Forward

Thank you for downloading my story %s. I hope you enjoy it and please feel free to email me if you have any questions or comments.

If you enjoy this story and would like to read more, head on over to luxagraf.net.

– Scott Gilbertson
  sng@luxagraf.net

' % f.title + + # chapter + c2 = epub.EpubHtml(title=f.title, file_name='story.xhtml') + c2.content = '

%s

' % f.title + c2.content += typogrify(f.body_html) + + # add chapters to the book + book.add_item(c1) + book.add_item(c2) + # create table of contents + # - add section + # - add auto created links to chapters + + book.toc = (epub.Link('intro.xhtml', 'Introduction', 'intro'), + epub.Link('story.xhtml', f.title, 'story'), + ) + + # add navigation files + book.add_item(epub.EpubNcx()) + book.add_item(epub.EpubNav()) + + # define css style + style = ''' +@namespace epub "http://www.idpf.org/2007/ops"; +body { + font-family: Georgia, Times, Times New Roman, serif; +} +h2 { + text-align: left; + text-transform: uppercase; + font-weight: 200; +} +ol { + list-style-type: none; +} +ol > li:first-child { + margin-top: 0.3em; +} +nav[epub|type~='toc'] > ol > li > ol { + list-style-type:square; +} +nav[epub|type~='toc'] > ol > li > ol > li { + margin-top: 0.3em; +} +''' + + # add css file + nav_css = epub.EpubItem(uid="style_nav", file_name="style/nav.css", media_type="text/css", content=style) + book.add_item(nav_css) + + # create spine + book.spine = ['nav', c1, c2] + path, filename = os.path.split(f.get_absolute_url()) + fpath = '%s%s/' % (settings.FLATFILES_ROOT, path) + if not os.path.isdir(fpath): + os.makedirs(fpath) + bk = '%s%s.epub' % (fpath, f.slug) + # create epub file + epub.write_epub(bk, book, {}) diff --git a/app/unused_apps/figments/models.py b/app/unused_apps/figments/models.py new file mode 100644 index 0000000..8b22049 --- /dev/null +++ b/app/unused_apps/figments/models.py @@ -0,0 +1,97 @@ +import datetime +from itertools import chain +from django.db import models +from django.urls import reverse +from django.contrib.sitemaps import Sitemap +from django.contrib.syndication.views import Feed +from django.db.models.signals import post_save +from django.dispatch import receiver + +from utils.util import markdown_to_html + +from .ebook import generate_epub_file + + +class Series(models.Model): + title = models.CharField(max_length=200) + slug = models.CharField(max_length=50) + is_book = models.BooleanField(default=False) + body_markdown = models.TextField(null=True, blank=True) + body_html = models.TextField(null=True, blank=True) + pub_date = models.DateTimeField(auto_now_add=True) + + class Meta: + verbose_name_plural = 'Series' + + def __str__(self): + return self.title + + +class Figment(models.Model): + title = models.CharField(max_length=200) + slug = models.CharField(max_length=50) + pub_date = models.DateTimeField(blank=True) + body_markdown = models.TextField(null=True, blank=True) + prologue = models.TextField(null=True, blank=True) + dek = models.TextField(null=True, blank=True) + body_html = models.TextField(null=True, blank=True) + PUB_STATUS = ( + (0, 'Draft'), + (1, 'Published'), + ) + status = models.IntegerField(choices=PUB_STATUS, default=0) + series = models.ManyToManyField(Series, related_name="series", blank=True) + TEMPLATES = ( + (0, 'default'), + ) + template_name = models.IntegerField(choices=TEMPLATES, default=0) + published_link = models.CharField(max_length=300, help_text="link to online pub", blank=True, null=True) + + class Meta: + ordering = ('-pub_date',) + + def __str__(self): + return self.title + + def get_absolute_url(self): + return reverse("figments:detail", kwargs={"slug": self.slug}) + + def get_series(self): + return "\n".join([s.title for s in self.series.all()]) + + def save(self, *args, **kwargs): + if not self.id and not self.pub_date: + self.pub_date = datetime.datetime.now() + self.body_html = markdown_to_html(self.body_markdown) + super(Figment, self).save() + + +@receiver(post_save, sender=Figment) +def post_save_events(sender, instance, **kwargs): + if instance.body_markdown != instance._loaded_values['body_markdown']: + print("you updated") + generate_epub_file(instance) + else: + print("no update found, not buidling") + + +class LatestFull(Feed): + title = "luxagraf figments: stories less literally true." + link = "/figments/" + description = "Latest postings to luxagraf.net/figments" + description_template = 'feeds/blog_description.html' + + def items(self): + return Figment.objects.filter(status__exact=1).order_by('-pub_date')[:10] + + +class FigmentSitemap(Sitemap): + changefreq = "never" + priority = 0.7 + protocol = "https" + + def items(self): + return list(chain(Figment.objects.filter(status__exact=1), Series.objects.all())) + + def lastmod(self, obj): + return obj.pub_date diff --git a/app/unused_apps/figments/urls.py b/app/unused_apps/figments/urls.py new file mode 100644 index 0000000..4a37cf5 --- /dev/null +++ b/app/unused_apps/figments/urls.py @@ -0,0 +1,38 @@ +from django.conf.urls import url + +from . import views + +app_name = "figments" + +urlpatterns = [ + url( + r'^feed.xml', + views.FigRSSFeedView(), + name="feed" + ), + url( + r'series/$', + views.SeriesListView.as_view(), + name='list_series' + ), + url( + r'(?P[-\w]+).txt$', + views.FigmentDetailViewTXT.as_view(), + name="detail-txt" + ), + url( + r'(?P[-\w]+).amp$', + views.FigmentDetailViewAMP.as_view(), + name="detail-amp" + ), + url( + r'(?P[-\w]+)$', + views.FigmentDetailView.as_view(), + name='detail' + ), + url( + r'^$', + views.FigmentListView.as_view(), + name='list' + ), +] diff --git a/app/unused_apps/figments/views.py b/app/unused_apps/figments/views.py new file mode 100644 index 0000000..6521c29 --- /dev/null +++ b/app/unused_apps/figments/views.py @@ -0,0 +1,42 @@ +from django.views.generic import ListView, DetailView +from django.contrib.syndication.views import Feed + +from .models import Figment, Series + + +class FigmentListView(ListView): + model = Figment + template_name = "archives/figments.html" + context_object_name = 'object_list' + + def get_queryset(self): + return Figment.objects.filter(status__exact=1).order_by('-pub_date') + + +class SeriesListView(ListView): + model = Series + template_name = "archives/figments_series.html" + context_object_name = 'object_list' + + +class FigmentDetailView(DetailView): + model = Figment + template_name = "details/figments.html" + + +class FigmentDetailViewTXT(FigmentDetailView): + template_name = "details/entry.txt" + + +class FigmentDetailViewAMP(FigmentDetailView): + template_name = "details/entry.amp" + + +class FigRSSFeedView(Feed): + title = "luxagraf figments: stories less literally true." + link = "/figments/" + description = "Latest postings to luxagraf.net/figments" + description_template = 'feeds/blog_description.html' + + def items(self): + return Figment.objects.filter(status__exact=1).order_by('-pub_date')[:10] diff --git a/app/utils/util.py b/app/utils/util.py index 1779baa..b765e78 100644 --- a/app/utils/util.py +++ b/app/utils/util.py @@ -35,7 +35,7 @@ def convertll(lat, lon): def get_latlon(): - loc = apps.get_model('locations', 'CheckIn').objects.latest() + loc = apps.get_model('locations', 'LuxCheckIn').objects.latest() lat_converted, lon_converted = convertll(loc.lat, loc.lon) return lat_converted, lon_converted @@ -55,8 +55,11 @@ def parse_image(s): for img in soup.find_all('img'): try: cl = img['class'] - if cl[0] == 'postpic' or cl[0] == 'postpicright': + #if cl[0] == 'postpic' or cl[0] == 'postpicright': + replacer = "[[base_url]]" + if replacer in str(img): s = str(img).replace('[[base_url]]', settings.IMAGES_URL) + print(s) return s else: try: -- cgit v1.2.3-70-g09d2