Skip to content
Snippets Groups Projects
Verified Commit 22564d33 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Merge branch 'master' into 483-caching-issues

parents a5f1408b 88982d14
No related branches found
No related tags found
1 merge request!747Resolve "Caching issues"
Pipeline #38503 failed
Showing
with 1768 additions and 2014 deletions
......@@ -29,6 +29,13 @@ Fixed
* Users weren't able to edit the allowed fields although they were configured correctly.
* Provide `style.css` and icon files without any authentication to avoid caching issues.
Removed
~~~~~~~
* Remove mass linking of persons to accounts, bevcause the view had performance issues,
but was practically unused.
`2.0rc7`_ - 2021-10-18
----------------------
......
......@@ -33,54 +33,6 @@ from .registries import (
from .util.core_helpers import get_site_preferences
class PersonAccountForm(forms.ModelForm):
"""Form to assign user accounts to persons in the frontend."""
class Meta:
model = Person
fields = ["last_name", "first_name", "user"]
widgets = {"user": Select2Widget(attrs={"class": "browser-default"})}
new_user = forms.CharField(required=False)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Fields displayed only for informational purposes
self.fields["first_name"].disabled = True
self.fields["last_name"].disabled = True
def clean(self) -> None:
user = get_user_model()
if self.cleaned_data.get("new_user", None):
if self.cleaned_data.get("user", None):
# The user selected both an existing user and provided a name to create a new one
self.add_error(
"new_user",
_("You cannot set a new username when also selecting an existing user."),
)
elif user.objects.filter(username=self.cleaned_data["new_user"]).exists():
# The user tried to create a new user with the name of an existing user
self.add_error("new_user", _("This username is already in use."))
else:
# Create new User object and assign to form field for existing user
new_user_obj = user.objects.create_user(
self.cleaned_data["new_user"],
self.instance.email,
first_name=self.instance.first_name,
last_name=self.instance.last_name,
)
self.cleaned_data["user"] = new_user_obj
# Formset for batch-processing of assignments of users to persons
PersonsAccountsFormSet = forms.modelformset_factory(
Person, form=PersonAccountForm, max_num=0, extra=0
)
class PersonForm(ExtensibleForm):
"""Form to edit or add a person object in the frontend."""
......@@ -162,8 +114,28 @@ class PersonForm(ExtensibleForm):
self.fields[field].disabled = False
def clean(self) -> None:
# Use code implemented in dedicated form to verify user selection
return PersonAccountForm.clean(self)
user = get_user_model()
if self.cleaned_data.get("new_user", None):
if self.cleaned_data.get("user", None):
# The user selected both an existing user and provided a name to create a new one
self.add_error(
"new_user",
_("You cannot set a new username when also selecting an existing user."),
)
elif user.objects.filter(username=self.cleaned_data["new_user"]).exists():
# The user tried to create a new user with the name of an existing user
self.add_error("new_user", _("This username is already in use."))
else:
# Create new User object and assign to form field for existing user
new_user_obj = user.objects.create_user(
self.cleaned_data["new_user"],
self.instance.email,
first_name=self.instance.first_name,
last_name=self.instance.last_name,
)
self.cleaned_data["user"] = new_user_obj
class EditGroupForm(SchoolTermRelatedExtensibleForm):
......
This diff is collapsed.
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-28 17:53+0200\n"
"POT-Creation-Date: 2021-10-28 16:18+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......
This diff is collapsed.
......@@ -3,32 +3,36 @@
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-28 17:53+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"PO-Revision-Date: 2021-10-28 14:37+0000\n"
"Last-Translator: Jonathan Weth <teckids@jonathanweth.de>\n"
"Language-Team: German <https://translate.edugit.org/projects/aleksis/"
"aleksis-core-js/de/>\n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.8\n"
#: aleksis/core/static/js/main.js:15
msgid "Today"
msgstr ""
msgstr "Heute"
#: aleksis/core/static/js/main.js:16
msgid "Cancel"
msgstr ""
msgstr "Abbrechen"
#: aleksis/core/static/js/main.js:17
msgid "OK"
msgstr ""
msgstr "OK"
#: aleksis/core/static/js/main.js:127
msgid "This page may contain outdated information since there is no internet connection."
msgstr ""
"Diese Seite enthält vielleicht veraltete Informationen, da es keine "
"Internetverbindung gibt."
This diff is collapsed.
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-28 17:53+0200\n"
"POT-Creation-Date: 2021-10-28 16:18+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......
This diff is collapsed.
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-28 17:53+0200\n"
"POT-Creation-Date: 2021-10-28 16:18+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......
This diff is collapsed.
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-28 17:53+0200\n"
"POT-Creation-Date: 2021-10-28 16:18+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......
This diff is collapsed.
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-08-28 17:53+0200\n"
"POT-Creation-Date: 2021-10-28 16:18+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......
......@@ -267,17 +267,6 @@ MENUS = {
)
],
},
{
"name": _("Persons and accounts"),
"url": "persons_accounts",
"icon": "person_add",
"validators": [
(
"aleksis.core.util.predicates.permission_validator",
"core.link_persons_accounts_rule",
)
],
},
{
"name": _("Groups and child groups"),
"url": "groups_child_groups",
......
# Generated by Django 3.2.8 on 2021-10-24 13:43
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0020_pdf_file_person_optional'),
]
operations = [
migrations.AlterModelOptions(
name='globalpermissions',
options={'default_permissions': (), 'managed': False, 'permissions': (('view_system_status', 'Can view system status'), ('manage_data', 'Can manage data'), ('impersonate', 'Can impersonate'), ('search', 'Can use search'), ('change_site_preferences', 'Can change site preferences'), ('change_person_preferences', 'Can change person preferences'), ('change_group_preferences', 'Can change group preferences'), ('add_oauth_applications', 'Can add oauth applications'), ('list_oauth_applications', 'Can list oauth applications'), ('view_oauth_applications', 'Can view oauth applications'), ('update_oauth_applications', 'Can update oauth applications'), ('delete_oauth_applications', 'Can delete oauth applications'), ('test_pdf', 'Can test PDF generation'))},
),
]
......@@ -969,7 +969,6 @@ class GlobalPermissions(GlobalPermissionModel):
class Meta(GlobalPermissionModel.Meta):
permissions = (
("view_system_status", _("Can view system status")),
("link_persons_accounts", _("Can link persons to accounts")),
("manage_data", _("Can manage data")),
("impersonate", _("Can impersonate")),
("search", _("Can use search")),
......
......@@ -79,10 +79,6 @@ delete_person_predicate = has_person & (
)
rules.add_perm("core.delete_person_rule", delete_person_predicate)
# Link persons with accounts
link_persons_accounts_predicate = has_person & has_global_perm("core.link_persons_accounts")
rules.add_perm("core.link_persons_accounts_rule", link_persons_accounts_predicate)
# View groups
view_groups_predicate = has_person & (
has_global_perm("core.view_group") | has_any_object("core.view_group", Group)
......@@ -157,12 +153,7 @@ rules.add_perm("core.view_system_status_rule", view_system_status_predicate)
rules.add_perm(
"core.view_people_menu_rule",
has_person
& (
view_persons_predicate
| view_groups_predicate
| link_persons_accounts_predicate
| assign_child_groups_to_groups_predicate
),
& (view_persons_predicate | view_groups_predicate | assign_child_groups_to_groups_predicate),
)
# View person personal details
......
{# -*- engine:django -*- #}
{% extends "core/base.html" %}
{% load i18n any_js %}
{% block extra_head %}
{{ persons_accounts_formset.media.css }}
{% include_css "select2-materialize" %}
{% endblock %}
{% block browser_title %}{% blocktrans %}Link persons to accounts{% endblocktrans %}{% endblock %}
{% block page_title %}
{% blocktrans %}Link persons to accounts{% endblocktrans %}
{% endblock %}
{% block content %}
<div class="alert info">
<p>
<i class="material-icons left">info</i>
{% blocktrans %}
You can use this form to assign user accounts to persons. Use the
dropdowns to select existing accounts; use the text fields to create new
accounts on-the-fly. The latter will create a new account with the
entered username and copy all other details from the person.
{% endblocktrans %}
</p>
</div>
<form method="post">
{% csrf_token %}
{{ persons_accounts_formset.management_form }}
<button type="submit" class="btn green waves-effect waves-light">
<i class="material-icons left">save</i>
{% blocktrans %}Update{% endblocktrans %}
</button>
<table>
<tr>
<th>{% blocktrans %}Person{% endblocktrans %}</th>
<th>{% blocktrans %}Existing account{% endblocktrans %}</th>
<th>{% blocktrans %}New account{% endblocktrans %}</th>
</tr>
{% for form in persons_accounts_formset %}
{{ form.id }}
<tr>
<td>
{{ form.last_name }}
{{ form.first_name }}
</td>
<td>{{ form.user }}</td>
<td>{{ form.new_user }}</td>
</tr>
{% endfor %}
</table>
<button type="submit" class="btn green waves-effect waves-light">
<i class="material-icons left">save</i>
{% blocktrans %}Update{% endblocktrans %}
</button>
</form>
{% include_js "select2-materialize" %}
{{ persons_accounts_formset.media.js }}
{% endblock %}
......@@ -46,7 +46,6 @@ urlpatterns = [
path("school_terms/create/", views.SchoolTermCreateView.as_view(), name="create_school_term"),
path("school_terms/<int:pk>/", views.SchoolTermEditView.as_view(), name="edit_school_term"),
path("persons", views.persons, name="persons"),
path("persons/accounts", views.persons_accounts, name="persons_accounts"),
path("person/", views.person, name="person"),
path("person/create/", views.CreatePersonView.as_view(), name="create_person"),
path("person/<int:id_>/", views.person, name="person_by_id"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment