summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_operations/urls.py6
-rw-r--r--archaeological_operations/wizards.py2
-rw-r--r--ishtar_common/static/media/style.css1
-rw-r--r--ishtar_common/views.py4
-rw-r--r--ishtar_common/wizards.py18
5 files changed, 28 insertions, 3 deletions
diff --git a/archaeological_operations/urls.py b/archaeological_operations/urls.py
index a6c4bd7b3..68ac0bad0 100644
--- a/archaeological_operations/urls.py
+++ b/archaeological_operations/urls.py
@@ -89,10 +89,16 @@ urlpatterns += patterns(
'archaeological_operations.views',
url(r'autocomplete-operation/$', 'autocomplete_operation',
name='autocomplete-operation'),
+ url(r'get-operation/own/(?P<type>.+)?$',
+ 'get_operation', name='get-own-operation',
+ kwargs={'force_own': True}),
url(r'get-operation/(?P<type>.+)?$', 'get_operation',
name='get-operation'),
url(r'get-operation-full/(?P<type>.+)?$', 'get_operation',
name='get-operation-full', kwargs={'full': True}),
+ url(r'get-operation-full/own/(?P<type>.+)?$',
+ 'get_operation', name='get-own-operation-full',
+ kwargs={'full': True, 'force_own': True}),
url(r'get-available-operation-code/(?P<year>.+)?$',
'get_available_operation_code', name='get_available_operation_code'),
url(r'revert-operation/(?P<pk>.+)/(?P<date>.+)$',
diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py
index 6f4a6583a..78a5c3350 100644
--- a/archaeological_operations/wizards.py
+++ b/archaeological_operations/wizards.py
@@ -270,6 +270,7 @@ class OperationWizard(Wizard):
class OperationModificationWizard(OperationWizard):
modification = True
+ filter_owns = {'selec-operation_modification': ['pk']}
class OperationClosingWizard(ClosingWizard):
@@ -282,6 +283,7 @@ class OperationClosingWizard(ClosingWizard):
class OperationDeletionWizard(DeletionWizard):
model = models.Operation
fields = OperationClosingWizard.fields
+ filter_owns = {'selec-operation_deletion': ['pk']}
class OperationSourceWizard(SourceWizard):
diff --git a/ishtar_common/static/media/style.css b/ishtar_common/static/media/style.css
index 46ee8c331..fdde40cb0 100644
--- a/ishtar_common/static/media/style.css
+++ b/ishtar_common/static/media/style.css
@@ -898,6 +898,7 @@ div.form p.alert{
#window p.alert{
background-color:#EEE;
+ padding-left: 30px;
}
#window p.alert label{
diff --git a/ishtar_common/views.py b/ishtar_common/views.py
index 79e816bcb..a18673b44 100644
--- a/ishtar_common/views.py
+++ b/ishtar_common/views.py
@@ -321,7 +321,7 @@ def get_item(model, func_name, default_name, extra_request_keys=[],
"""
Generic treatment of tables
"""
- def func(request, data_type='json', full=False, **dct):
+ def func(request, data_type='json', full=False, force_own=False, **dct):
# check rights
own = True # more restrictive by default
allowed = False
@@ -337,6 +337,8 @@ def get_item(model, func_name, default_name, extra_request_keys=[],
if "_own_" not in perm:
own = False
break # max right reach
+ if force_own:
+ own = True
EMPTY = ''
if 'type' in dct:
data_type = dct.pop('type')
diff --git a/ishtar_common/wizards.py b/ishtar_common/wizards.py
index 23469c659..29496d21b 100644
--- a/ishtar_common/wizards.py
+++ b/ishtar_common/wizards.py
@@ -85,10 +85,8 @@ def check_rights_condition(rights):
if request.user.ishtaruser.has_right('administrator', request.session):
return True
for right in rights:
- print(right)
if request.user.ishtaruser.has_right(right, request.session):
return True
- print('hop')
return False
return func
@@ -104,6 +102,7 @@ class Wizard(NamedUrlWizardView):
wizard_done_window = ''
wizard_confirm = 'ishtar/wizard/confirm_wizard.html'
wizard_templates = {}
+ filter_owns = {}
@staticmethod
def _check_right(step, condition=True):
@@ -153,6 +152,10 @@ class Wizard(NamedUrlWizardView):
current_object and not current_object.is_own(request.user):
self.session_reset(request, self.url_name)
return HttpResponseRedirect('/')
+ # extra filter on forms
+ self.filter_owns_items = True
+ else:
+ self.filter_owns_items = False
return super(Wizard, self).dispatch(request, *args, **kwargs)
@@ -671,10 +674,21 @@ class Wizard(NamedUrlWizardView):
and form.forms[0].fields.keys():
frm = form.forms[0]
if frm:
+ # autofocus on first field
first_field = frm.fields[frm.fields.keyOrder[0]]
attrs = first_field.widget.attrs
attrs.update({'autofocus': "autofocus"})
first_field.widget.attrs = attrs
+ if not step:
+ step = self.steps.current
+ if self.filter_owns_items and self.filter_owns \
+ and step in self.filter_owns:
+ for key in self.filter_owns[step]:
+ frm.fields[key].widget.source = unicode(
+ frm.fields[key].widget.source) + "own/"
+ if frm.fields[key].widget.source_full is not None:
+ frm.fields[key].widget.source_full = unicode(
+ frm.fields[key].widget.source_full) + "own/"
return form
def render_next_step(self, form, **kwargs):