summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2020-08-06 22:12:11 -0400
committerluxagraf <sng@luxagraf.net>2020-08-06 22:12:11 -0400
commitb21ee9e325cd71e2061222b06b7929068bdb79ae (patch)
treeca0f5d6ad34eaf4dbf155d8249af0b91c7862591 /app
parent21b0006e218f27af8eb7cba81a1b854892bfd5a8 (diff)
added builder for src and guides via posts
Diffstat (limited to 'app')
-rw-r--r--app/builder/views.py15
-rw-r--r--app/fieldnotes/templates/fieldnotes/fieldnote_detail.html19
-rw-r--r--app/fieldnotes/views.py3
-rw-r--r--app/posts/build.py32
-rw-r--r--app/posts/models.py6
-rw-r--r--app/posts/templates/posts/src_detail.html1
-rw-r--r--app/posts/views/src_views.py5
-rw-r--r--app/src/build.py3
8 files changed, 58 insertions, 26 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 @@
</article>
</main>
{% endblock %}
+
+{% block js %}
+<script>
+document.addEventListener("DOMContentLoaded", function(event) {
+ var leaflet = document.createElement('script');
+ leaflet.src = "/media/js/leaflet-master/leaflet-mod.js";
+ document.body.appendChild(leaflet);
+ leaflet.onload = function(){
+ var detail = document.createElement('script');
+ detail.src = "/media/js/detail.min.js";
+ document.body.appendChild(detail);
+ detail.onload = function(){
+ createMap();
+ var open = false;
+ }
+ }
+});
+</script>
+{%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 @@
<h2 class="post-subtitle">{{object.meta_description|smartypants|safe}}</h2>
<div class="post-linewrapper">
{% if object.originally_published_by %}<h4 class="post-source">Originally Published By: <a href="{{object.originally_published_by_url}}" title="View {{object.title}} on {{object.originally_published_by}}">{{object.originally_published_by}}</a></h4>{%endif%}
- {% for topic in object.topics.all%}{% if forloop.counter0 == 0 %}<h4 class="post-source">Topics: {%endif%} <a href="/src/topic/{{topic.slug}}">{{topic.name}}</a>{%if forloop.last%}{%else%}, {%endif%}{%endfor%}{% if forloop.counter0 == 0 %}</h4>{%endif%}
<time class="dt-published published dt-updated post-date" datetime="{{object.pub_date|date:'c'}}" itemprop="datePublished">{{object.pub_date|date:"F"}} <span>{{object.pub_date|date:"j, Y"}}</span></time>
<span class="hide" itemprop="author" itemscope itemtype="http://schema.org/Person">by <a class="p-author h-card" href="/about"><span itemprop="name">Scott Gilbertson</span></a></span>
</div>
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')