diff options
Diffstat (limited to 'app/posts')
-rw-r--r-- | app/posts/build.py | 32 | ||||
-rw-r--r-- | app/posts/models.py | 6 | ||||
-rw-r--r-- | app/posts/templates/posts/src_detail.html | 1 | ||||
-rw-r--r-- | app/posts/views/src_views.py | 5 |
4 files changed, 31 insertions, 13 deletions
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 |