From 8b1e49fa998d7a6b82118c63b21bea51ed6d5984 Mon Sep 17 00:00:00 2001 From: Cefin Date: Mon, 22 Nov 2021 11:50:47 +0100 Subject: rapid action on person create new user #5216 --- ishtar_common/models.py | 19 +++++++++++++++++++ ishtar_common/urls.py | 1 + ishtar_common/views.py | 11 +++++++++++ 3 files changed, 31 insertions(+) diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 6bfffd0cf..cb0da7ba7 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2910,6 +2910,25 @@ class Person(Address, Merge, OwnPerms, ValueGetter, MainItem): for fle in self.general_contractor.all(): fle.save() # force update of raw_general_contractor + def get_extra_actions(self, request): + actions = super(Person, self).get_extra_actions(request) + + can_create_person = self.can_do(request, "change_person") + if not can_create_person: + return actions + actions += [ + ( + reverse("person_create", args=[self.pk]), + _("Create new user"), + "fa fa-user", + "", + "", + False, + ), + ] + return actions + + @classmethod def get_query_owns(cls, ishtaruser): return ( diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py index 9e120a945..7bbdc189f 100644 --- a/ishtar_common/urls.py +++ b/ishtar_common/urls.py @@ -82,6 +82,7 @@ urlpatterns = [ name="person_modification", ), url(r"person_modify/(?P.+)/$", views.person_modify, name="person_modify"), + url(r"person_create/(?P.+)/$", views.person_create, name="person_create"), url( r"person_deletion/(?P.+)?$", check_rights(["change_person", "change_own_person"])( diff --git a/ishtar_common/views.py b/ishtar_common/views.py index 2cf09e66f..1363684a7 100644 --- a/ishtar_common/views.py +++ b/ishtar_common/views.py @@ -210,6 +210,17 @@ def person_modify(request, pk): ) +def person_create(request, pk): + if not wizard_is_available(person_creation_wizard, request, models.Person, pk): + return HttpResponseRedirect("/") + wizards.PersonWizard.session_set_value( + request, "selec-person_creation", "pk", pk, reset=True + ) + return redirect( + reverse("person_creation", kwargs={"step": "identity-person_creation"}) + ) + + person_deletion_wizard = wizards.PersonDeletionWizard.as_view( [ ("selec-person_deletion", forms.PersonFormMultiSelection), -- cgit v1.2.3