summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
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()