From b21ee9e325cd71e2061222b06b7929068bdb79ae Mon Sep 17 00:00:00 2001 From: luxagraf Date: Thu, 6 Aug 2020 22:12:11 -0400 Subject: added builder for src and guides via posts --- app/builder/views.py | 15 +++------- .../templates/fieldnotes/fieldnote_detail.html | 19 +++++++++++++ app/fieldnotes/views.py | 3 +- app/posts/build.py | 32 ++++++++++++++++------ app/posts/models.py | 6 ++-- app/posts/templates/posts/src_detail.html | 1 - app/posts/views/src_views.py | 5 ++-- app/src/build.py | 3 ++ design/sass/_header.scss | 4 +-- design/templates/admin/buttons.html | 8 ++---- design/templates/base.html | 2 +- 11 files changed, 63 insertions(+), 35 deletions(-) diff --git a/app/builder/views.py b/app/builder/views.py index a32d384..7203d41 100644 --- a/app/builder/views.py +++ b/app/builder/views.py @@ -1,7 +1,6 @@ from django.shortcuts import render from django.template import RequestContext from builder.base import BuildWriting, BuildWritingFeed, BuildMap, BuildPhotos, BuildProjects, BuildSitemap -from src.build import builder as src_builder from jrnl.build import archive_builder, detail_builder, home_builder, rss_builder, map_builder from resume.build import pub_builder, resume_builder from books.build import builder as book_builder @@ -11,7 +10,7 @@ from notes.build import builder as notes_builder from pages.build import builder as page_builder from fieldnotes.build import builder as fieldnotes_builder from photos.build import dailybuilder -from posts.build import posts_builder +from posts.build import src_builder, guide_builder options = { 'writing': BuildWriting, @@ -55,18 +54,15 @@ def do_build(request): elif section == 'src': context = {'message': 'Writing src section to Disk'} src_builder() + elif section == 'guide': + context = {'message': 'Writing guide section to Disk'} + guide_builder() elif section == 'luxphotos': context = {'message': 'Writing galleries to Disk'} photo_builder() - elif section == 'dailyphotos': - context = {'message': 'Writing galleries to Disk'} - photo_builder() elif section == 'figments': context = {'message': 'Writing figments to Disk'} figments_builder() - elif section == 'notes': - context = {'message': 'Writing notes to Disk'} - notes_builder() elif section == 'pages': context = {'message': 'Writing Pages to Disk'} page_builder() @@ -76,9 +72,6 @@ def do_build(request): elif section == 'fieldnotes': context = {'message': 'Writing FieldNotes to Disk'} fieldnotes_builder() - elif section == 'buildposts': - context = {'message': 'Writing Posts to Disk'} - posts_builder() else: options[section]().build() context = {'message': 'Writing %s to Disk' % section} diff --git a/app/fieldnotes/templates/fieldnotes/fieldnote_detail.html b/app/fieldnotes/templates/fieldnotes/fieldnote_detail.html index 0d25108..d1c648b 100644 --- a/app/fieldnotes/templates/fieldnotes/fieldnote_detail.html +++ b/app/fieldnotes/templates/fieldnotes/fieldnote_detail.html @@ -74,3 +74,22 @@ {% endblock %} + +{% block js %} + +{%endblock%} diff --git a/app/fieldnotes/views.py b/app/fieldnotes/views.py index 47fe353..f22cfeb 100644 --- a/app/fieldnotes/views.py +++ b/app/fieldnotes/views.py @@ -17,9 +17,8 @@ class FieldNoteListView(PaginatedListView): def dispatch(self, request, *args, **kwargs): path = request.path.split('/')[1:-1] - if int(path[-1]) == self.kwargs['page']: + if path[-1] == str(self.kwargs['page']): path = "/".join(t for t in path[:-1]) - print(path) request.page_url = "/" + path + '/%d/' else: request.page_url = request.path + '%d/' diff --git a/app/posts/build.py b/app/posts/build.py index 5cf552b..77611f9 100644 --- a/app/posts/build.py +++ b/app/posts/build.py @@ -4,24 +4,40 @@ from builder.base import BuildNew from itertools import chain from django.conf import settings +from .models import PostType -class BuildPosts(BuildNew): +class BuildSrc(BuildNew): + + def get_model_queryset(self): + return self.model.objects.filter(post_type=PostType.SRC).filter(status__exact=1).order_by('-pub_date') def build(self): self.build_list_view( - base_path=reverse("essay-list:list"), - paginate_by=50 - ) - self.build_list_view( - base_path=reverse("guide-list:list"), + base_path=reverse("src:list"), paginate_by=50 ) self.build_detail_view() +def src_builder(): + j = BuildSrc("posts", "post") + j.build() + + +class BuildGuide(BuildNew): + def get_model_queryset(self): + return self.model.objects.filter(post_type__in=[PostType.FIELD_TEST, PostType.REVIEW]).filter(status__exact=1).order_by('-pub_date') + + def build(self): + self.build_list_view( + base_path=reverse("guides:guide-base"), + paginate_by=50 + ) + self.build_detail_view() + -def posts_builder(): - j = BuildPosts("posts", "post") +def guide_builder(): + j = BuildGuide("posts", "post") j.build() diff --git a/app/posts/models.py b/app/posts/models.py index 8312040..226f91b 100644 --- a/app/posts/models.py +++ b/app/posts/models.py @@ -40,6 +40,7 @@ class PostType(models.IntegerChoices): SRC = 3, ('src') JRNL = 4, ('jrnl') + class Post(models.Model): old_id = models.IntegerField(blank=True, null=True) title = models.CharField(max_length=200) @@ -111,7 +112,7 @@ class Post(models.Model): @property def get_previous_published(self): - return self.get_previous_by_pub_date(status__exact=1) + return self.get_previous_by_pub_date(status__exact=1,post_type=self.post_type) @property def get_previous_admin_url(self): @@ -120,7 +121,7 @@ class Post(models.Model): @property def get_next_published(self): - return self.get_next_by_pub_date(status__exact=1) + return self.get_next_by_pub_date(status__exact=1,post_type=self.post_type) @property def get_next_admin_url(self): @@ -187,6 +188,7 @@ class Post(models.Model): related.slug = self.slug related.save() + class PostModerator(CommentModerator): ''' Moderate everything except people with multiple approvals diff --git a/app/posts/templates/posts/src_detail.html b/app/posts/templates/posts/src_detail.html index 7f87f5c..9e146e4 100644 --- a/app/posts/templates/posts/src_detail.html +++ b/app/posts/templates/posts/src_detail.html @@ -43,7 +43,6 @@

{{object.meta_description|smartypants|safe}}

{% if object.originally_published_by %}

Originally Published By: {{object.originally_published_by}}

{%endif%} - {% for topic in object.topics.all%}{% if forloop.counter0 == 0 %}

Topics: {%endif%} {{topic.name}}{%if forloop.last%}{%else%}, {%endif%}{%endfor%}{% if forloop.counter0 == 0 %}

{%endif%}
diff --git a/app/posts/views/src_views.py b/app/posts/views/src_views.py index afb6a6d..5265707 100644 --- a/app/posts/views/src_views.py +++ b/app/posts/views/src_views.py @@ -7,6 +7,7 @@ from django.conf import settings #from paypal.standard.forms import PayPalPaymentsForm from utils.views import PaginatedListView from ..models import Post, PostType +from taxonomy.models import Category class SrcListView(PaginatedListView): @@ -39,12 +40,12 @@ class TopicListView(ListView): template_name = 'src/topic_list.html' def get_queryset(self): - return SrcPost.objects.filter(topics__slug=self.kwargs['slug']) + return Post.objects.filter(topics__slug=self.kwargs['slug'],post_type=PostType.SRC) 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']) + context['topic'] = Category.objects.get(slug__exact=self.kwargs['slug']) return context diff --git a/app/src/build.py b/app/src/build.py index d1d3042..a16bdaf 100644 --- a/app/src/build.py +++ b/app/src/build.py @@ -23,6 +23,9 @@ class BuildSrc(BuildNew): def build_topic_view(self): for topic in models.Topic.objects.all(): + ctype = ContentType.objects.get(app_label='posts', model='post') + for cat in Category.objects.all(): + url = reverse("src:list_topics", kwargs={'slug': topic.slug, }) path, slug = os.path.split(url) response = self.client.get(url, HTTP_HOST='127.0.0.1') diff --git a/design/sass/_header.scss b/design/sass/_header.scss index 9eb9b1b..87cd180 100644 --- a/design/sass/_header.scss +++ b/design/sass/_header.scss @@ -53,9 +53,9 @@ padding: 0.25em 0.5em; a { text-decoration: none; - color: lighten(#505050, 15); + color: lighten(#505050, 5); &:visited { - color: lighten(#505050, 20); + color: lighten(#505050, 5); } } ul { diff --git a/design/templates/admin/buttons.html b/design/templates/admin/buttons.html index 483f942..32e2778 100644 --- a/design/templates/admin/buttons.html +++ b/design/templates/admin/buttons.html @@ -42,16 +42,12 @@
  • Build Writing Details
  • Build Writing Archives
  • Build Homepage
  • -
  • Build Map
  • Build Sitemap
  • Build RSS
  • -
  • Build All Pages
  • +
  • Build Guide
  • +
  • Build Pages
  • Build FieldNotes
  • -
  • Build Daily Photo
  • Build Essays
  • -
  • Build Posts
  • -
  • Build Photo Galleries
  • -
  • Build Project Pages
  • Build Books
  • Build Dialogues
  • Build Publications
  • diff --git a/design/templates/base.html b/design/templates/base.html index 6a74d54..01d6905 100644 --- a/design/templates/base.html +++ b/design/templates/base.html @@ -96,7 +96,7 @@ _paq.push(["disableCookies"]); _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function() { - var u="//stats.luxagraf.net/"; + var u="https://stats.luxagraf.net/"; _paq.push(['setTrackerUrl', u+'piwik.php']); _paq.push(['setSiteId', 1]); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; -- cgit v1.2.3-70-g09d2