-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84cdddb
commit 5b48e1d
Showing
15 changed files
with
222 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
integreat_cms/cms/templates/release_notes/latest_release_widget.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{% extends "_collapsible_box.html" %} | ||
{% load i18n %} | ||
{% load static %} | ||
{% block collapsible_box_icon %} | ||
scroll | ||
{% endblock collapsible_box_icon %} | ||
{% block collapsible_box_title %} | ||
{% if version == "unreleased" %} | ||
{% translate "Changes that will be released soon" %} | ||
{% else %} | ||
{% blocktranslate trimmed %} | ||
What's new in version {{ version}}? | ||
{% endblocktranslate %} | ||
{% endif %} | ||
{% endblock collapsible_box_title %} | ||
{% block collapsible_box_content %} | ||
{% include "release_notes/version.html" %} | ||
<a href="{% url "release_notes" %}" class="btn"> | ||
<i icon-name="scroll"></i> | ||
{% translate "Display all release notes" %} | ||
</a> | ||
{% endblock collapsible_box_content %} |
27 changes: 27 additions & 0 deletions
27
integreat_cms/cms/templates/release_notes/release_notes.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% extends "_base.html" %} | ||
{% load i18n %} | ||
{% load widget_tweaks %} | ||
{% block content %} | ||
<div> | ||
<h1 class="heading !mb-3"> | ||
<i icon-name="scroll"></i> {% translate "Release notes" %} | ||
</h1> | ||
{% for year, versions in release_notes.items %} | ||
{% for version, notes in versions.items %} | ||
{% if version == "unreleased" %} | ||
<h2 class="text-xl mb-2"> | ||
<span class="italic">{% translate "Unreleased" %}</span> | ||
</h2> | ||
{% else %} | ||
<h2 class="text-2xl mb-2"> | ||
<a href="https://github.com/digitalfabrik/integreat-cms/releases/tag/{{ version }}" | ||
class="hover:underline" | ||
target="_blank" | ||
rel="noopener noreferrer">{{ version }}</a> | ||
</h2> | ||
{% endif %} | ||
{% include "release_notes/version.html" %} | ||
{% endfor %} | ||
{% endfor %} | ||
</div> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<ul class="ml-6 mb-3 list-disc"> | ||
{% for issue, note in notes.items %} | ||
<li> | ||
<span class="inline-block w-20">[ | ||
<a href="https://github.com/digitalfabrik/integreat-cms/issues/{{ issue }}" | ||
class="text-blue-500 hover:underline" | ||
target="_blank" | ||
rel="noopener noreferrer">#{{ issue }}</a> | ||
]</span> {{ note }} | ||
</li> | ||
{% endfor %} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .release_notes_view import ReleaseNotesView |
79 changes: 79 additions & 0 deletions
79
integreat_cms/cms/views/release_notes/release_notes_context_mixin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import logging | ||
from contextlib import ExitStack | ||
from pathlib import Path | ||
|
||
import yaml | ||
from django.conf import settings | ||
from django.utils.translation import get_language_from_request | ||
from django.views.generic.base import ContextMixin | ||
from natsort import natsorted | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class ReleaseNotesContextMixin(ContextMixin): | ||
""" | ||
This mixin provides the release notes context (see :class:`~django.views.generic.base.ContextMixin`) | ||
""" | ||
|
||
#: Whether only the latest release notes should be included | ||
only_latest_release = False | ||
|
||
def __init__(self): | ||
self.slice = 1 if self.only_latest_release else None | ||
|
||
def get_context_data(self, **kwargs): | ||
r""" | ||
Extend context by release notes | ||
:param \**kwargs: The supplied keyword arguments | ||
:type \**kwargs: dict | ||
:return: The context dictionary | ||
:rtype: dict | ||
""" | ||
context = super().get_context_data(**kwargs) | ||
context["release_notes"] = self.get_release_notes() | ||
return context | ||
|
||
def get_release_notes(self): | ||
""" | ||
Get all release notes | ||
:return: The release note dict | ||
:rtype: dict | ||
""" | ||
return { | ||
year.name: self.get_versions(year) | ||
for year in sorted( | ||
Path(settings.RELEASE_NOTES_DIRS).iterdir(), reverse=True | ||
)[: self.slice] | ||
} | ||
|
||
def get_versions(self, year): | ||
""" | ||
Get all versions of one year | ||
:return: The version dict | ||
:rtype: dict | ||
""" | ||
return { | ||
version.name: self.get_entries(version) | ||
for version in natsorted(year.iterdir(), reverse=True)[: self.slice] | ||
} | ||
|
||
def get_entries(self, version): | ||
""" | ||
Get all entries of one version | ||
:return: The entry dict | ||
:rtype: dict | ||
""" | ||
# Use exit stack to close file descriptors after list comprehension | ||
with ExitStack() as stack: | ||
return { | ||
note.stem: yaml.safe_load( | ||
stack.enter_context(open(note, encoding="UTF-8")) | ||
)[get_language_from_request(self.request)] | ||
for note in natsorted(version.iterdir()) | ||
} |
12 changes: 12 additions & 0 deletions
12
integreat_cms/cms/views/release_notes/release_notes_view.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.views.generic.base import TemplateView | ||
|
||
from .release_notes_context_mixin import ReleaseNotesContextMixin | ||
|
||
|
||
class ReleaseNotesView(TemplateView, ReleaseNotesContextMixin): | ||
""" | ||
View for retrieving the release notes | ||
""" | ||
|
||
#: The template to render (see :class:`~django.views.generic.base.TemplateResponseMixin`) | ||
template_name = "release_notes/release_notes.html" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
en: The release notes are now displayed in the CMS | ||
de: Das Änderungsprotokoll wird jetzt im CMS angezeigt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters