Skip to content

Commit

Permalink
Merge pull request #1368 from digitalfabrik/develop
Browse files Browse the repository at this point in the history
Release `2022.4.2`
  • Loading branch information
timobrembeck authored Apr 23, 2022
2 parents a9b5d42 + ac8fb94 commit 723641a
Show file tree
Hide file tree
Showing 77 changed files with 1,051 additions and 496 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
UNRELEASED
----------

* [ [#1366](https://github.com/digitalfabrik/integreat-cms/issues/1366) ] Fix monthly recurring events on mondays
* [ [#1365](https://github.com/digitalfabrik/integreat-cms/issues/1365) ] Add timezone setting to region model
* [ [#1093](https://github.com/digitalfabrik/integreat-cms/issues/1093) ] Add Malte and Aschaffenburg brandings


2022.4.1
--------
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ cd integreat-cms
For detailed instructions, tutorials and the source code reference have a look at our great documentation:

<p align="center">:notebook: https://digitalfabrik.github.io/integreat-cms/</p>


## License

This project is licensed under the Apache 2.0 License, see [LICENSE.txt](./LICENSE.txt)

All files in [./integreat_cms/static/src/logos/](./integreat_cms/static/src/logos/) are not covered by this license and may only be used with specific permission of the copyright holder.
6 changes: 6 additions & 0 deletions example-configs/integreat-cms.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
DEBUG = False
# The timezone of the server [optional, defaults to "Europe/Berlin"]
CURRENT_TIME_ZONE = Europe/Berlin
# The company operating this CMS [optional, defaults to "Tür an Tür – Digitalfabrik gGmbH"]
COMPANY = Tür an Tür – Digitalfabrik gGmbH
# The URL to the company's website [optional, defaults to "https://tuerantuer.de/digitalfabrik/"]
COMPANY_URL = https://tuerantuer.de/digitalfabrik/
# The branding of the CMS [optional, defaults to "integreat", must be one of ["integreat", "malte", "aschaffenburg"]]
BRANDING = integreat

[secrets]
# The secret key for this installation [required]
Expand Down
1 change: 1 addition & 0 deletions integreat_cms/cms/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,6 @@
from .users.user_email_form import UserEmailForm
from .users.user_form import UserForm
from .users.user_password_form import UserPasswordForm
from .users.password_reset_form import CustomPasswordResetForm

from .object_search_form import ObjectSearchForm
2 changes: 1 addition & 1 deletion integreat_cms/cms/forms/events/recurrence_rule_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def clean(self):
),
)
elif cleaned_data.get("frequency") == frequency.MONTHLY:
if not cleaned_data.get("weekday_for_monthly"):
if cleaned_data.get("weekday_for_monthly") is None:
self.add_error(
"weekday_for_monthly",
forms.ValidationError(
Expand Down
51 changes: 50 additions & 1 deletion integreat_cms/cms/forms/regions/region_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from copy import deepcopy

from zoneinfo import available_timezones
from django import forms
from django.conf import settings
from django.utils.translation import override, ugettext_lazy as _
Expand All @@ -15,9 +16,48 @@
from ..icon_widget import IconWidget
from ..custom_model_form import CustomModelForm


logger = logging.getLogger(__name__)


def get_timezone_choices():
"""
This method generates the options for the second timezone dropdown
:return: A list of all available timezones
:rtype: list
"""
timezones = list(available_timezones())
timezones.sort()
return [("", "---------")] + [
(tz, tz.split("/", 1)[1].replace("_", " ")) for tz in timezones if "/" in tz
]


def get_timezone_area_choices():
"""
This method generates the options for the first timezone dropdown.
It displays the general area of a country or city. Often the continent.
:return: A list of the general areas of the timezones
:rtype: list
"""
timezone_regions = list(
{
tz.split("/")[0]
for tz in available_timezones()
if "/" in tz and "Etc" not in tz and "SystemV" not in tz
}
)
timezone_regions.sort()
return (
[("", "---------")]
+ [(tzr, tzr) for tzr in timezone_regions]
+ [("Etc", _("Other timezones"))]
)


class RegionForm(CustomModelForm):
"""
Form for creating and modifying region objects
Expand All @@ -29,6 +69,12 @@ class RegionForm(CustomModelForm):
required=False,
)

timezone_area = forms.ChoiceField(
choices=get_timezone_area_choices,
label=_("Timezone area"),
required=False,
)

class Meta:
"""
This class contains additional meta configuration of the form class, see the :class:`django.forms.ModelForm`
Expand Down Expand Up @@ -62,9 +108,11 @@ class Meta:
"short_urls_enabled",
"custom_prefix",
"tunews_enabled",
"timezone",
]
#: The widgets which are used in this form
widgets = {
"timezone": forms.Select(choices=get_timezone_choices()),
"icon": IconWidget(),
"offers": forms.CheckboxSelectMultiple(),
}
Expand All @@ -80,7 +128,8 @@ def __init__(self, *args, **kwargs):
:type \**kwargs: dict
"""
super().__init__(*args, **kwargs)

if self.instance and "/" in self.instance.timezone:
self.fields["timezone_area"].initial = self.instance.timezone.split("/")[0]
self.fields["slug"].required = False

def save(self, commit=True):
Expand Down
67 changes: 67 additions & 0 deletions integreat_cms/cms/forms/users/password_reset_form.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import logging

from django import forms
from django.conf import settings
from django.utils.text import capfirst
from django.utils.translation import gettext_lazy as _

from django.contrib.auth.forms import PasswordResetForm

from ...utils.email_utils import send_mail

logger = logging.getLogger(__name__)


class CustomPasswordResetForm(PasswordResetForm):
"""
A custom form to attach the logo to the password reset email
"""

email = forms.EmailField(
label=_("Email"),
max_length=254,
widget=forms.EmailInput(attrs={"autocomplete": "email"}),
)

def send_mail(
self,
subject_template_name,
email_template_name,
context,
from_email,
to_email,
html_email_template_name=None,
):
"""
Send a django.core.mail.EmailMultiAlternatives to `to_email`.
:param subject_template_name: The template to be used to render the subject of the email
:type subject_template_name: str
:param email_template_name: The template to be used to render the text email
:type email_template_name: str
:param context: The template context variables
:type context: dict
:param from_email: The email address of the sender
:type from_email: str
:param to_email: The email address of the recipient
:type to_email: str
:param html_email_template_name: The template to be used to render the HTML email
:type html_email_template_name: str
"""
subject = f"{capfirst(settings.BRANDING)} - {_('Reset password')}"
send_mail(
subject,
email_template_name,
html_email_template_name,
context,
to_email,
)
logger.info(
"A password reset link was sent to email %r.",
to_email,
)
1 change: 0 additions & 1 deletion integreat_cms/cms/middleware/__init__.py

This file was deleted.

23 changes: 23 additions & 0 deletions integreat_cms/cms/migrations/0017_region_timezone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.12 on 2022-04-23 12:26

from django.db import migrations, models


class Migration(migrations.Migration):
"""
This is the migration file for the timezones
"""

dependencies = [
("cms", "0016_region_tunews_enabled"),
]

operations = [
migrations.AddField(
model_name="region",
name="timezone",
field=models.CharField(
default="Europe/Berlin", max_length=150, verbose_name="timezone"
),
),
]
12 changes: 9 additions & 3 deletions integreat_cms/cms/models/regions/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
from django.contrib.auth import get_user_model
from django.db import models
from django.http import Http404
from django.utils import timezone
from django.utils import timezone as django_timezone
from django.utils.functional import cached_property
from django.utils.safestring import mark_safe
from django.utils.translation import override, ugettext, ugettext_lazy as _
from django.conf import settings


from ...constants import region_status, administrative_division
from ...utils.translation_utils import ugettext_many_lazy as __
Expand Down Expand Up @@ -128,7 +130,6 @@ class Region(AbstractBaseModel):
verbose_name=_("activate push notifications"),
help_text=_("Whether or not push notifications are enabled in the region"),
)

latitude = models.FloatField(
null=True,
verbose_name=_("latitude"),
Expand All @@ -145,8 +146,13 @@ class Region(AbstractBaseModel):
verbose_name=_("email address of the administrator"),
)

timezone = models.CharField(
max_length=150,
default=settings.CURRENT_TIME_ZONE,
verbose_name=_("timezone"),
)
created_date = models.DateTimeField(
default=timezone.now,
default=django_timezone.now,
verbose_name=_("creation date"),
)
last_updated = models.DateTimeField(
Expand Down
6 changes: 3 additions & 3 deletions integreat_cms/cms/templates/_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
fill="none"
width="21"
height="21"
src="{% static 'images/integreat-icon-contur-only.png' %}"/>
src="{% static 'logos/integreat/integreat-icon-flat.svg' %}"/>
{% trans 'Documentation (Wiki)' %}
</a>
<div id="region-selector"
Expand Down Expand Up @@ -93,10 +93,10 @@
class="w-56 h-full fixed left-0 inset-y-0 text-gray-200 bg-gray-700 z-50">
<div class="w-full p-1 h-14 bg-gray-800">
<a href="/">
<div class="h-full w-full bg-logo-white hover:bg-logo-yellow bg-contain bg-center bg-no-repeat"></div>
<div class="h-full w-full bg-{{ BRANDING }}-logo-white hover:bg-{{ BRANDING }}-logo-hover bg-contain bg-center bg-no-repeat"></div>
</a>
</div>
<div id="menu" class="pb-2 overflow-y-auto">
<div id="menu" class="pb-2 overflow-y-auto {{ BRANDING }}-branding">
{% if request.region %}
<a href="{% url 'dashboard' region_slug=request.region.slug %}"
class="{% if current_menu_item == 'region_dashboard' %} active{% endif %}">
Expand Down
4 changes: 2 additions & 2 deletions integreat_cms/cms/templates/_raw.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, shrink-to-fit=no, user-scalable=no" />
<title>{% trans 'Integreat Editorial System' %}</title>
<link rel="shortcut icon" type="image/png" href="{% static 'images/integreat-icon.png' %}">
<title>{{ BRANDING|title }} {% trans 'Editorial System' %}</title>
<link rel="shortcut icon" type="image/png" href="{% static 'logos/'|add:BRANDING|add:'/'|add:BRANDING|add:'-icon.svg' %}">

{% render_bundle 'main' 'js' %}
{% render_bundle 'main' 'css' %}
Expand Down
11 changes: 7 additions & 4 deletions integreat_cms/cms/templates/analytics/_website_size_widget.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@

{% block collapsible_box_content %}
<div class="flex flex-wrap justify-between gap-2">
<p class="py-3">{% trans 'The chart below shows the current size of the Integreat app.' %}</p>
<a href="{% url 'app_size' region_slug=request.region.slug %}" class="btn">
{% trans "Details" %}
</a>
<p class="py-3">
{% blocktrans trimmed with BRANDING=BRANDING|title %}
The chart below shows the current size of the {{ BRANDING }} app.
{% endblocktrans %}
<a href="{% url 'app_size' region_slug=request.region.slug %}" class="btn">
{% trans "Details" %}
</a>
</div>
<div class="p-3 w-full">
<!-- TODO -->
Expand Down
6 changes: 3 additions & 3 deletions integreat_cms/cms/templates/authentication/_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="min-h-screen min-w-screen flex flex-col justify-center bg-gray-100 px-3 py-10">
<div class="mx-auto w-136">
<a href="/">
<div class="h-36 mb-3 bg-logo hover:bg-logo-yellow bg-contain bg-center bg-no-repeat"></div>
<div class="h-36 mb-3 bg-{{ BRANDING }}-logo hover:bg-{{ BRANDING }}-logo-hover bg-contain bg-center bg-no-repeat"></div>
</a>
<div class="bg-white shadow-md rounded p-6 mb-4">
<h1 class="heading text-center mb-4">{% block heading %}{% endblock %}</h1>
Expand All @@ -16,11 +16,11 @@ <h1 class="heading text-center mb-4">{% block heading %}{% endblock %}</h1>
</div>
<p class="text-center text-gray-400">
&copy;2016 - {% now "Y" %}
<a href="https://tuerantuer.de/digitalfabrik/"
<a href="{{ COMPANY_URL }}"
class="text-gray-600 hover:text-gray-800"
target="_blank"
rel="noopener noreferrer">
Tür an Tür - Digitalfabrik gGmbH
{{ COMPANY }}
</a>
</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion integreat_cms/cms/templates/authentication/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{% trans 'Log in' %}
</button>
<div class="text-right mt-4">
<a href="{% url 'public:password_reset' %}" class="text-right font-bold text-gray-600 hover:text-integreat-500 hover:bg-gray-600 py-2 px-4 rounded">
<a href="{% url 'public:password_reset' %}" class="text-right font-bold text-gray-600 hover:text-gray-200 hover:bg-gray-600 py-2 px-4 rounded">
<i data-feather="lock" class="align-top"></i> {% trans 'Forgot your password?' %}
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{% trans 'Set new password' %}
</button>
<div class="text-right mt-4">
<a href="{% url 'public:login' %}" class="text-gray-600 hover:text-integreat-500 hover:bg-gray-600 rounded py-2 px-3 font-bold">
<a href="{% url 'public:login' %}" class="text-gray-600 hover:text-gray-200 hover:bg-gray-600 rounded py-2 px-3 font-bold">
<i data-feather="arrow-left-circle" class="align-top"></i> {% trans 'Back to log in' %}
</a>
</div>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</button>
</form>
<div class="text-right mt-4">
<a href="{% url 'public:login' %}" class="text-gray-600 hover:text-integreat-500 hover:bg-gray-600 rounded py-2 px-3 font-bold">
<a href="{% url 'public:login' %}" class="text-gray-600 hover:text-gray-200 hover:bg-gray-600 rounded py-2 px-3 font-bold">
<i data-feather="arrow-left-circle" class="align-top"></i> {% trans 'Back to log in' %}
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion integreat_cms/cms/templates/chat/_chat_messages.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% for message in chat_messages %}
<div class="chat-message p-2 {% if not forloop.last or not chat_form %}border-t border-gray-300{% endif %} {% if chat_last_visited < message.sent_datetime %}bg-border-left from-yellow-400 to-yellow-100{% endif %}">
{% if message.sender.is_superuser or message.sender.is_staff %}
<span class="inline-block h-5 w-5 align-text-top bg-icon bg-contain bg-center bg-no-repeat"></span>
<span class="inline-block h-5 w-5 align-text-top bg-integreat-icon bg-contain bg-center bg-no-repeat"></span>
{% endif %}
<span class="font-bold">
{{ message.sender.full_user_name }}
Expand Down
Loading

0 comments on commit 723641a

Please sign in to comment.