Skip to content

Commit

Permalink
Merge pull request #542 from coders4help/develop
Browse files Browse the repository at this point in the history
Apply fixes for release
  • Loading branch information
pitpalme authored Apr 1, 2022
2 parents 2dfa64b + 8728952 commit 7766f5b
Show file tree
Hide file tree
Showing 44 changed files with 896 additions and 248 deletions.
2 changes: 1 addition & 1 deletion accounts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)
no_consequtive = RegexValidator(
r"[_.]{2,}",
_("Username must not contain consecutive . or _ characters."),
_('Username must not contain consecutive "." or "_" characters.'),
inverse_match=True,
)

Expand Down
47 changes: 45 additions & 2 deletions common/admin.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,45 @@
# coding=utf-8
# Register your models here.
import logging

from django.contrib import messages
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.utils.html import escape
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _

logger = logging.getLogger(__name__)


class RedirectOnAdminPermissionDenied403:
def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):
response = self.get_response(request)
return response

def process_exception(self, request, exception):
admin_index = reverse("admin:index")
if (
hasattr(request, "user")
and getattr(request.user, "is_authenticated", False)
and getattr(request.user, "is_staff", False)
and request.path != admin_index
and request.path.startswith(admin_index)
and isinstance(exception, PermissionDenied)
):
redirect_path = admin_index
error_code = 403
error = _("Error {error_code}").format(error_code=error_code)
permission_denied = _("Permission denied")
error = f"{error}: {permission_denied}"
note = _(
"You are not allowed to do this and have been redirected to {redirect_path}." # noqa: E501
).format(redirect_path=redirect_path)
messages.error(
request,
mark_safe(f"<strong>{note}</strong><br/> {error} - ")
+ escape(f"{request.method} {request.path}"),
)
return HttpResponseRedirect(redirect_path)
35 changes: 35 additions & 0 deletions content/migrations/0005_alter_flatpagetranslation_language.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 4.0.3 on 2022-03-30 08:42

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("content", "0004_alter_flatpagetranslation_language"),
]

operations = [
migrations.AlterField(
model_name="flatpagetranslation",
name="language",
field=models.CharField(
choices=[
("uk", "Ukrainian"),
("en", "English"),
("de", "German"),
("cs", "Czech"),
("el", "Greek"),
("fr", "French"),
("hu", "Hungarian"),
("pl", "Polish"),
("pt", "Portuguese"),
("ru", "Russian"),
("sv", "Swedish"),
("tr", "Turkish"),
],
max_length=20,
verbose_name="language",
),
),
]
23 changes: 20 additions & 3 deletions locale/ar/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-29 11:54+0200\n"
"POT-Creation-Date: 2022-03-30 18:28+0200\n"
"PO-Revision-Date: 2022-03-15 17:56+0000\n"
"Last-Translator: Christoph Meißner\n"
"Language-Team: Arabic (http://www.transifex.com/coders4help/volunteer-planner/language/ar/)\n"
Expand Down Expand Up @@ -45,7 +45,7 @@ msgstr ""
msgid "Username must end with a letter, a number or \"_\"."
msgstr ""

msgid "Username must not contain consecutive . or _ characters."
msgid "Username must not contain consecutive \".\" or \"_\" characters."
msgstr ""

msgid "Accept privacy policy"
Expand Down Expand Up @@ -129,6 +129,17 @@ msgstr "مسح الحساب"
msgid "Your user account has been deleted."
msgstr "لقد تم مسح حسابك"

#, python-brace-format
msgid "Error {error_code}"
msgstr ""

msgid "Permission denied"
msgstr ""

#, python-brace-format
msgid "You are not allowed to do this and have been redirected to {redirect_path}."
msgstr ""

msgid "additional CSS"
msgstr ""

Expand Down Expand Up @@ -1243,18 +1254,24 @@ msgstr ""
msgid "Sign-up"
msgstr ""

msgid "Ukrainian"
msgstr ""

msgid "English"
msgstr ""

msgid "German"
msgstr ""

msgid "French"
msgid "Czech"
msgstr ""

msgid "Greek"
msgstr ""

msgid "French"
msgstr ""

msgid "Hungarian"
msgstr ""

Expand Down
23 changes: 20 additions & 3 deletions locale/bg/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-29 11:54+0200\n"
"POT-Creation-Date: 2022-03-30 18:28+0200\n"
"PO-Revision-Date: 2022-03-15 17:56+0000\n"
"Last-Translator: Christoph Meißner\n"
"Language-Team: Bulgarian (http://www.transifex.com/coders4help/volunteer-planner/language/bg/)\n"
Expand Down Expand Up @@ -41,7 +41,7 @@ msgstr ""
msgid "Username must end with a letter, a number or \"_\"."
msgstr ""

msgid "Username must not contain consecutive . or _ characters."
msgid "Username must not contain consecutive \".\" or \"_\" characters."
msgstr ""

msgid "Accept privacy policy"
Expand Down Expand Up @@ -125,6 +125,17 @@ msgstr ""
msgid "Your user account has been deleted."
msgstr ""

#, python-brace-format
msgid "Error {error_code}"
msgstr ""

msgid "Permission denied"
msgstr ""

#, python-brace-format
msgid "You are not allowed to do this and have been redirected to {redirect_path}."
msgstr ""

msgid "additional CSS"
msgstr ""

Expand Down Expand Up @@ -1227,18 +1238,24 @@ msgstr ""
msgid "Sign-up"
msgstr ""

msgid "Ukrainian"
msgstr ""

msgid "English"
msgstr ""

msgid "German"
msgstr ""

msgid "French"
msgid "Czech"
msgstr ""

msgid "Greek"
msgstr ""

msgid "French"
msgstr ""

msgid "Hungarian"
msgstr ""

Expand Down
Loading

0 comments on commit 7766f5b

Please sign in to comment.