Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 447 contribute highlight #451

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 19 additions & 21 deletions wagtailio/blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def posts(self):
return (
BlogPage.objects.live()
.descendant_of(self)
.select_related("author", "author__image", "category")
.select_related("category")
.prefetch_related("authors", "authors__image")
.order_by("-date", "pk")
)

Expand Down Expand Up @@ -126,24 +127,21 @@ def __str__(self):
]


class BlogPage(Page, SocialMediaMixin, CrossPageMixin):
template = "patterns/pages/blog/blog_page.html"
subpage_types = []
canonical_url = models.URLField(blank=True)
class BlogPageAuthor(Orderable):
page = ParentalKey("blog.BlogPage", related_name="authors")
author = models.ForeignKey(
"blog.Author",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="+",
)
main_image = models.ForeignKey(
"images.WagtailIOImage",
null=True,
blank=True,
on_delete=models.SET_NULL,
on_delete=models.CASCADE,
related_name="+",
)

panels = [FieldPanel("author")]


class BlogPage(Page, SocialMediaMixin, CrossPageMixin):
template = "patterns/pages/blog/blog_page.html"
subpage_types = []
canonical_url = models.URLField(blank=True)
date = models.DateField()
introduction = models.CharField(max_length=511)
category = models.ForeignKey(
Expand All @@ -155,16 +153,16 @@ class BlogPage(Page, SocialMediaMixin, CrossPageMixin):
)
body = StreamField(BlogStoryBlock(), use_json_field=True)

@property
def siblings(self):
return self.__class__.objects.live().sibling_of(self).order_by("-date")

content_panels = Page.content_panels + [
FieldPanel("author"),
FieldPanel("main_image"),
FieldPanel("date"),
FieldPanel("category"),
FieldPanel("introduction"),
InlinePanel(
"authors",
heading="Authors",
label="Author",
max_num=3,
),
FieldPanel("body"),
InlinePanel(
"related_posts",
Expand Down
41 changes: 25 additions & 16 deletions wagtailio/blog/templates/blog/blog_index_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@
{% block content %}

<div class="container">
<div class="hero">
<div class="hero__inner">
<h1 aria-hidden="true">Latest Chirps</h1>
<span class="u-sr-only">Latest blog posts</span>
</div>
</div>
<h1>{{ page.title }}</h1>
<p>By:
{% for author in page.authors.all %}
{{ author.name }}
{% if not forloop.last %}, {% endif %}
{% endfor %}
</p>
{{ page.body }}
</div>

{% endblock %}

<section class="blog-listing">
{% for post in posts %}
Expand All @@ -25,18 +30,22 @@ <h1 aria-hidden="true">Latest Chirps</h1>
{% endfor %}
</section>

{% if posts.has_previous %}
<a href="?page=1">&laquo; first</a>
<a href="?page={{ posts.previous_page_number }}">previous</a>
{% endif %}
{% if posts.paginator.num_pages > 1 %}
<div class="pagination">
{% if posts.has_previous %}
<a href="?page=1">&laquo; first</a>
<a href="?page={{ posts.previous_page_number }}">previous</a>
{% endif %}

<span class="current">
Page {{ posts.number }} of {{ posts.paginator.num_pages }}
</span>
<span class="current">
Page {{ posts.number }} of {{ posts.paginator.num_pages }}
</span>

{% if posts.has_next %}
<a href="?page={{ posts.next_page_number }}">next</a>
<a href="?page={{ posts.paginator.num_pages }}">last &raquo;</a>
{% if posts.has_next %}
<a href="?page={{ posts.next_page_number }}">next</a>
<a href="?page={{ posts.paginator.num_pages }}">last &raquo;</a>
{% endif %}
</div>
{% endif %}
</div>
{% endblock %}
10 changes: 5 additions & 5 deletions wagtailio/roadmap/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
from django.urls import reverse
from django.utils.dateparse import parse_datetime
from django.views.generic import FormView

from wagtail.admin import messages

import requests

from wagtailio.roadmap.forms import ImportForm
from wagtailio.roadmap.models import Milestone, MilestoneItem

Expand Down Expand Up @@ -71,7 +68,6 @@
"variables": {},
}


def process(token=""):
if not token:
token = settings.GITHUB_ROADMAP_ACCESS_TOKEN
Expand Down Expand Up @@ -123,14 +119,18 @@ def process(token=""):
item.full_clean()
item.save()

# Check if the issue needs contributions
if "Contribute to this" in labels:
item.needs_contributions = True
item.save()

# Remove items that are no longer attached to the seen milestones.
(
MilestoneItem.objects.filter(milestone__number__in=seen_milestone_numbers)
.exclude(number__in=seen_item_numbers)
.delete()
)


class ImportView(FormView):
template_name = "roadmap/import.html"
form_class = ImportForm
Expand Down