Skip to content
Snippets Groups Projects
Verified Commit f9edc18a authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Remove persons_accounts view

parent eefe8e04
No related branches found
No related tags found
1 merge request!750Resolve "person_accounts view hangs while rendering template"
......@@ -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",
......
......@@ -952,7 +952,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")),
......
......@@ -80,10 +80,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)
......@@ -161,7 +157,6 @@ rules.add_perm(
& (
view_persons_predicate
| view_groups_predicate
| link_persons_accounts_predicate
| assign_child_groups_to_groups_predicate
),
)
......
{# -*- 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.edit_person, name="create_person"),
path("person/<int:id_>", views.person, name="person_by_id"),
......
......@@ -361,27 +361,6 @@ def groups(request: HttpRequest) -> HttpResponse:
return render(request, "core/group/list.html", context)
@never_cache
@permission_required("core.link_persons_accounts_rule")
def persons_accounts(request: HttpRequest) -> HttpResponse:
"""View allowing to batch-process linking of users to persons."""
context = {}
# Get all persons
persons_qs = Person.objects.all()
# Form set with one form per known person
persons_accounts_formset = PersonsAccountsFormSet(request.POST or None, queryset=persons_qs)
if request.method == "POST":
if persons_accounts_formset.is_valid():
persons_accounts_formset.save()
context["persons_accounts_formset"] = persons_accounts_formset
return render(request, "core/person/accounts.html", context)
@never_cache
@permission_required("core.assign_child_groups_to_groups_rule")
def groups_child_groups(request: HttpRequest) -> HttpResponse:
......
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