diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-03-25 17:17:34 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2024-04-16 16:43:03 +0200 |
commit | ed871697d607a1a00b36be0c787b56e5f34a1e17 (patch) | |
tree | 22b0ed04f1e647ffb042f84c6007bda2cfa68e5f /ishtar_common/models.py | |
parent | cf0390dcedfcec2c33e989251dbe25afd71cdbee (diff) | |
download | Ishtar-ed871697d607a1a00b36be0c787b56e5f34a1e17.tar.bz2 Ishtar-ed871697d607a1a00b36be0c787b56e5f34a1e17.zip |
✨ Biographical notes edit form
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 4d9225a3a..110ac9a50 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -3194,7 +3194,7 @@ class Person(Address, Merge, OwnPerms, ValueGetter, MainItem): fle.save() # force update of raw_general_contractor def get_extra_actions(self, request): - actions = super(Person, self).get_extra_actions(request) + actions = super().get_extra_actions(request) # for admin only if not request.user.is_staff: @@ -3270,9 +3270,22 @@ class BiographicalNote(BaseHistorizedItem, ValueGetter, MainItem): related_name="biographical_notes" ) + QA_EDIT = QuickAction( + url="biographicalnote-qa-edit", + icon_class="fa fa-pencil", + text=_("Edit biographical note"), + rights=["change_biographicalnote", "change_own_biographicalnote"], + ) + class Meta: verbose_name = _("Biographical note") verbose_name_plural = _("Biographical notes") + permissions = ( + ("view_own_biographicalnote", "Can view own Biographical note"), + ("add_own_biographicalnote", "Can add own Biographical note"), + ("change_own_biographicalnote", "Can change own Biographical note"), + ("delete_own_biographicalnote", "Can delete own Biographical note"), + ) ADMIN_SECTION = _("Directory") @property @@ -3300,6 +3313,27 @@ class BiographicalNote(BaseHistorizedItem, ValueGetter, MainItem): def set_slug(self): self.slug = create_slug(self.__class__, self.denomination, max_length=250, pk=self.pk) + def get_extra_actions(self, request): + """ + For sheet template + """ + # url, base_text, icon, extra_text, extra css class, is a quick action, + actions = super().get_extra_actions(request) + can_edit = self.can_do(request, "change_biographicalnote") + if not can_edit: + return actions + actions += [ + ( + reverse("biographicalnote-qa-edit", args=[self.pk]), + _("Edit"), + "fa fa-pencil", + "", + "", + True, + ), + ] + return actions + def save(self, *args, **kwargs): if not self.slug: self.set_slug() |