Skip to content

Commit

Permalink
Merge pull request #1659 from digitalfabrik/develop
Browse files Browse the repository at this point in the history
Release `2022.8.3`
  • Loading branch information
ulliholtgrave authored Aug 31, 2022
2 parents 9bc0251 + e366f21 commit d2f2ebe
Show file tree
Hide file tree
Showing 18 changed files with 292 additions and 221 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
UNRELEASED
----------

* [ [#1635](https://github.com/digitalfabrik/integreat-cms/issues/1635) ] Show Matomo actions in statistics instead of visitors
* [ [#1449](https://github.com/digitalfabrik/integreat-cms/issues/1449) ] Show diff to last source version in side-by-side view
* [ [#1656](https://github.com/digitalfabrik/integreat-cms/issues/1656) ] Only validate event duration if dates are valid
* [ [#1638](https://github.com/digitalfabrik/integreat-cms/issues/1638) ] Change help text of visibility for language nodes
* [ [#1615](https://github.com/digitalfabrik/integreat-cms/issues/1615) ] Streamline navbar structure and remove analytics dashboard


2022.8.2
--------
Expand Down
20 changes: 10 additions & 10 deletions integreat_cms/cms/forms/events/event_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@ def clean(self):
# make self.data mutable to allow values to be changed manually
self.data = self.data.copy()

if cleaned_data["end_date"] - cleaned_data["start_date"] > timedelta(6):
self.add_error(
"end_date",
forms.ValidationError(
_(
"The maximum duration for events is 7 days. Consider using recurring events if the event is not continuous."
),
code="invalid",
),
)
if cleaned_data.get("is_all_day"):
cleaned_data["start_time"] = time.min
self.data["start_time"] = time.min
Expand Down Expand Up @@ -160,6 +150,16 @@ def clean(self):
code="invalid",
),
)
elif cleaned_data["end_date"] - cleaned_data["start_date"] > timedelta(6):
self.add_error(
"end_date",
forms.ValidationError(
_(
"The maximum duration for events is 7 days. Consider using recurring events if the event is not continuous."
),
code="invalid",
),
)

logger.debug("EventForm validated [2] with cleaned data %r", cleaned_data)
return cleaned_data
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.2.14 on 2022-08-31 12:07

from django.db import migrations, models


class Migration(migrations.Migration):
"""
Update help text of visibility field.
"""

dependencies = [
("cms", "0032_region_bounding_box"),
]

operations = [
migrations.AlterField(
model_name="languagetreenode",
name="visible",
field=models.BooleanField(
default=True,
help_text="Defines whether the language is displayed to the users of the app",
verbose_name="visible",
),
),
]
4 changes: 3 additions & 1 deletion integreat_cms/cms/models/languages/language_tree_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class LanguageTreeNode(AbstractTreeNode):
visible = models.BooleanField(
default=True,
verbose_name=_("visible"),
help_text=_("Defined if this language should be delivered via the API"),
help_text=_(
"Defines whether the language is displayed to the users of the app"
),
)
active = models.BooleanField(
default=True,
Expand Down
46 changes: 21 additions & 25 deletions integreat_cms/cms/templates/_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,32 +104,28 @@
{% trans 'My Dashboard' %}
</a>
<!-- Analytics Section -->
<div class="{% if current_menu_item|in_list:'analytics,statistics,translation_coverage,linkcheck' %} active {% endif %}">
<a href="{% url 'analytics' region_slug=request.region.slug %}"
class="{% if current_menu_item == 'analytics' %} active{% endif %}">
<i data-feather="activity"></i>
{% trans 'Analytics' %}
</a>
<div class="dropdown-container">
{% if request.region.statistics_enabled %}
<a href="{% url 'statistics' region_slug=request.region.slug %}"
class="{% if current_menu_item == 'statistics' %} active{% endif %}">
<i data-feather="bar-chart"></i>
{% trans 'Statistics' %}
</a>
{% endif %}
<a href="{% url 'translation_coverage' region_slug=request.region.slug %}"
class="{% if current_menu_item == 'translation_coverage' %} active{% endif %}">
<i data-feather="check-circle"></i>
{% trans 'Translation Report' %}
</a>
<a href="{% url 'linkcheck_landing' region_slug=request.region.slug %}"
class="{% if current_menu_item == 'linkcheck' %} active{% endif %}">
<i data-feather="link"></i>
{% trans 'Broken Links' %}
</a>
</div>
<div class="min-h-3 pl-2">
<p class="font-bold">
{% trans "Analytics" %}
</p>
</div>
{% if request.region.statistics_enabled %}
<a href="{% url 'statistics' region_slug=request.region.slug %}"
class="{% if current_menu_item == 'statistics' %} active{% endif %}">
<i data-feather="trending-up"></i>
{% trans 'Statistics' %}
</a>
{% endif %}
<a href="{% url 'translation_coverage' region_slug=request.region.slug %}"
class="{% if current_menu_item == 'translation_coverage' %} active{% endif %}">
<i data-feather="check-circle"></i>
{% trans 'Translation Report' %}
</a>
<a href="{% url 'linkcheck_landing' region_slug=request.region.slug %}"
class="{% if current_menu_item == 'linkcheck' %} active{% endif %}">
<i data-feather="link"></i>
{% trans 'Broken Links' %}
</a>
<!-- Content Section -->
<div class="min-h-3 pl-2">
<p class="font-bold">
Expand Down
9 changes: 6 additions & 3 deletions integreat_cms/cms/templates/_tinymce_config.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
{% get_files 'editor_content' 'css' as editor_content_css_files %}

{% if language.slug == 'zh-CN' %}
{% firstof "body { font-family: 'Noto Sans SC', sans-serif; }" as content_style %}
{% firstof "body { font-family: 'Noto Sans SC', sans-serif; }" as font_style %}
{% elif right_to_left %}
{% firstof "body { font-family: 'Lateef', sans-serif; font-size: 1.2rem; }" as content_style %}
{% firstof "body { font-family: 'Lateef', sans-serif; font-size: 1.2rem; }" as font_style %}
{% else %}
{% firstof "body { font-family: 'Open Sans', sans-serif; }" as content_style %}
{% firstof "body { font-family: 'Open Sans', sans-serif; }" as font_style %}
{% endif %}

{% comment %} Styling for text diff taken from style.scss {% endcomment %}
{% firstof font_style|add:"del { background-color: rgb(252 165 165); } ins { background-color: rgb(134 239 172); text-decoration-line: none; }" as content_style %}

<div
id="tinymce-config-options"
data-webapp-url="{% get_webapp_url %}"
Expand Down
25 changes: 0 additions & 25 deletions integreat_cms/cms/templates/analytics/analytics_overview.html

This file was deleted.

43 changes: 31 additions & 12 deletions integreat_cms/cms/templates/pages/page_sbs.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,38 @@ <h1 class="heading">
type="text"
value="{{ source_page_translation.title }}"
disabled>
<div class="mt-4">
<label class="block mt-4 font-bold">{{ page_translation_form.content.label }}</label>
<textarea id="source_translation_tinymce" cols="40" rows="10" class="tinymce_textarea" disabled>{{source_page_translation.content}}</textarea>
<div>
<label class="block font-bold">{{ page_translation_form.content.label }}</label>
<textarea
id="source_translation_tinymce"
cols="40"
rows="10"
class="tinymce_textarea"
disabled
data-old="{{ old_translation_content }}"
data-new="{{ source_page_translation.content }}"
>
{{source_page_translation.content}}
</textarea>
</div>
<label>{% trans 'Actions' %}</label>
<div class="flex flex-wrap gap-4">
<button id="toggle-translation-diff"
class="btn grow bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded"
title="{% if page_translation_form.instance.is_up_to_date %}{% trans 'No changes have been made to the source translation.' %}{% else %}{% trans 'Toggle source translation differences' %}{% endif %}"
{% if page_translation_form.instance.is_up_to_date %}disabled{% endif %}>
<div class="hidden toggle">{% trans 'Hide source translation differences' %}</div>
<div>{% trans 'Show source translation differences' %}</div>
</button>
<button id="copy-translation-content"
title="{% trans 'Copy content' %}"
class="btn grow bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded">
{% with source_language=source_page_translation.language.translated_name target_language_name=target_language.translated_name %}
{% blocktrans %}Copy content of {{ source_language }} to {{ target_language_name }}{% endblocktrans %}
{% endwith %}
<i data-feather="arrow-right-circle" class="mr-2"></i>
</button>
</div>
<label>{% trans 'Copy content' %}</label>
<button id="copy-translation-content"
title="{% trans 'Copy content' %}"
class="btn w-full bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded">
{% with source_language=source_page_translation.language.translated_name target_language_name=target_language.translated_name %}
{% blocktrans %}Copy content of {{ source_language }} to {{ target_language_name }}{% endblocktrans %}
{% endwith %}
<i data-feather="arrow-right-circle" class="mr-2"></i>
</button>
</div>
</div>
<div class="border border-blue-500 rounded shadow-2xl">
Expand Down
5 changes: 0 additions & 5 deletions integreat_cms/cms/urls/protected.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,11 +622,6 @@
"analytics/",
include(
[
path(
"",
analytics.AnalyticsView.as_view(),
name="analytics",
),
path(
"statistics/",
statistics.AnalyticsView.as_view(),
Expand Down
4 changes: 2 additions & 2 deletions integreat_cms/cms/utils/matomo_api_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def get_total_visits(self, start_date, end_date, period=matomo_periods.DAY):
query_params = {
"date": f"{start_date},{end_date}",
"idSite": self.matomo_id,
"method": "VisitsSummary.getVisits",
"method": "VisitsSummary.getActions",
"period": period,
}

Expand Down Expand Up @@ -298,7 +298,7 @@ def get_visits_per_language(self, start_date, end_date, period):
"filter_limit": "-1",
"format_metrics": "1",
"idSite": self.matomo_id,
"method": "VisitsSummary.getVisits",
"method": "VisitsSummary.getActions",
"period": period,
}
logger.debug(
Expand Down
1 change: 0 additions & 1 deletion integreat_cms/cms/views/analytics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
This package contains views related to the quality-analysis of the content
"""
from .translation_coverage_view import TranslationCoverageView
from .analytics_overview import AnalyticsView
from .app_size_view import AppSizeView
12 changes: 0 additions & 12 deletions integreat_cms/cms/views/analytics/analytics_overview.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TranslationCoverageView(TemplateView):

def get_context_data(self, **kwargs):
r"""
Extend context by traanslation coverage data
Extend context by translation coverage data
:param \**kwargs: The supplied keyword arguments
:type \**kwargs: dict
Expand Down
47 changes: 47 additions & 0 deletions integreat_cms/cms/views/pages/page_sbs_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ def get(self, request, *args, **kwargs):
disabled=disabled,
)

old_translation_content = get_old_source_content(
page, source_language, target_language
)

return render(
request,
self.template_name,
Expand All @@ -109,6 +113,7 @@ def get(self, request, *args, **kwargs):
"page_translation_form": page_translation_form,
"source_page_translation": source_page_translation,
"target_language": target_language,
"old_translation_content": old_translation_content,
},
)

Expand Down Expand Up @@ -214,6 +219,10 @@ def post(self, request, *args, **kwargs):
# Add the success message
page_translation_form.add_success_message(request)

old_translation_content = get_old_source_content(
page, source_language_node.language, target_language
)

return render(
request,
self.template_name,
Expand All @@ -222,5 +231,43 @@ def post(self, request, *args, **kwargs):
"page_translation_form": page_translation_form,
"source_page_translation": source_page_translation,
"target_language": target_language,
"old_translation_content": old_translation_content,
},
)


def get_old_source_content(page, source_language, target_language):
"""
This function returns the content of the source language translation that was up to date when the latest (no minor edit)
target language translation was created.
:param page: The page
:type page: ~integreat_cms.cms.models.pages.page.Page
:param source_language: The source language of the page
:type source_language: ~integreat_cms.cms.models.languages.language.Language
:param target_language: The target language of the page
:type target_language: ~integreat_cms.cms.models.languages.language.Language
:return: The content of the translation
:rtype: str
"""
# For the text diff, use the latest source translation that was created before the latest no minor edit target translation
major_target_page_translation = page.translations.filter(
language__slug=target_language.slug, minor_edit=False
).first()

if major_target_page_translation:
source_previous_translation = (
page.translations.filter(
language=source_language,
last_updated__lte=major_target_page_translation.last_updated,
)
.order_by("-last_updated")
.first()
)
if source_previous_translation:
return source_previous_translation.content

return ""
Loading

0 comments on commit d2f2ebe

Please sign in to comment.