summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/models.py1
-rw-r--r--ishtar_common/templates/ishtar/blocks/window_nav.html6
-rw-r--r--ishtar_common/templatetags/window_header.py13
-rw-r--r--ishtar_common/urls.py2
-rw-r--r--ishtar_common/views.py8
5 files changed, 26 insertions, 4 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 39d949ece..4f82a1663 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -4142,6 +4142,7 @@ class Person(Address, Merge, OwnPerms, ValueGetter, MainItem):
'profiles_list', 'attached_to', 'town')
SHOW_URL = 'show-person'
MODIFY_URL = 'person_modify'
+ DELETE_URL = 'person_delete'
BASE_SEARCH_VECTORS = [
SearchVectorConfig('name'),
SearchVectorConfig('surname'),
diff --git a/ishtar_common/templates/ishtar/blocks/window_nav.html b/ishtar_common/templates/ishtar/blocks/window_nav.html
index 19b70ccd6..c248bae82 100644
--- a/ishtar_common/templates/ishtar/blocks/window_nav.html
+++ b/ishtar_common/templates/ishtar/blocks/window_nav.html
@@ -56,6 +56,12 @@
<i class="{{icon}}"></i> {{extra_text}}
</a>
{% endfor %}
+ {% if delete_url and not item.locked %}
+ <a class="btn btn-danger wait-button" href='{% url delete_url item.pk %}'
+ title="{% trans 'Delete' %}">
+ <i class="fa fa-trash" aria-hidden="true"></i>
+ </a>
+ {% endif %}
</div>
<div class="btn-group btn-group-sm" role="group"
diff --git a/ishtar_common/templatetags/window_header.py b/ishtar_common/templatetags/window_header.py
index bbd923d41..e215426e1 100644
--- a/ishtar_common/templatetags/window_header.py
+++ b/ishtar_common/templatetags/window_header.py
@@ -1,4 +1,5 @@
from django import template
+from django.core.urlresolvers import reverse
from django.utils.safestring import mark_safe
register = template.Library()
@@ -19,12 +20,16 @@ def window_nav(context, item, window_id, show_url, modify_url='', histo_url='',
slug = item.LONG_SLUG
elif hasattr(item, "SLUG"):
slug = item.SLUG
- if modify_url and hasattr(item, 'can_do') and slug and \
- not item.can_do(context['request'], 'change_' + slug):
- modify_url = ""
+ modify_url_value, delete_url = None, None
+ can_edit = hasattr(item, 'can_do') and slug and \
+ item.can_do(context['request'], 'change_' + slug)
+ if can_edit:
+ modify_url_value = modify_url
+ delete_url = getattr(item, "DELETE_URL", False)
return {
'show_url': show_url,
- 'modify_url': modify_url,
+ 'modify_url': modify_url_value,
+ 'delete_url': delete_url,
'histo_url': histo_url,
'revert_url': revert_url,
'item': item,
diff --git a/ishtar_common/urls.py b/ishtar_common/urls.py
index b8ccb5172..1c0ddc495 100644
--- a/ishtar_common/urls.py
+++ b/ishtar_common/urls.py
@@ -63,6 +63,8 @@ urlpatterns = [
url(r'person_deletion/(?P<step>.+)?$',
check_rights(['change_person', 'change_own_person'])(
views.person_deletion_wizard), name='person_deletion'),
+ url(r'person_delete/(?P<pk>.+)/$', views.person_delete,
+ name='person_delete'),
url(r'^person-edit/$',
check_rights(['add_person'])(
views.PersonCreate.as_view()), name='person_create'),
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index 157f7ecc3..5a4abdc38 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -148,6 +148,14 @@ person_deletion_wizard = wizards.PersonDeletionWizard.as_view(
label=_(u"Person deletion"),
url_name='person_deletion',)
+
+def person_delete(request, pk):
+ person_deletion_wizard(request)
+ wizards.PersonDeletionWizard.session_set_value(
+ request, 'selec-person_deletion', 'pk', pk, reset=True)
+ return redirect(reverse('person_deletion',
+ kwargs={'step': 'final-person_deletion'}))
+
organization_search_wizard = wizards.OrganizationSearch.as_view(
[('general-organization_search', forms.OrganizationFormSelection)],
label=_(u"Organization search"),