summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2024-03-25 17:17:34 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2024-03-25 17:17:34 +0100
commit60843f670447b8359c633e05f0ebff3018db17bf (patch)
tree16072dbb77ab9e8d7278b9fc3d5fc1b77136f852 /ishtar_common/models.py
parentff94189c385699852ba71a4f54f2b41352058b30 (diff)
downloadIshtar-60843f670447b8359c633e05f0ebff3018db17bf.tar.bz2
Ishtar-60843f670447b8359c633e05f0ebff3018db17bf.zip
✨ Biographical notes edit form
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py36
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()