summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ishtar/furnitures/forms.py3
-rw-r--r--ishtar/furnitures/urls.py2
-rw-r--r--ishtar/furnitures/views.py12
-rw-r--r--ishtar/furnitures/widgets.py2
-rw-r--r--static/js/ishtar.js4
5 files changed, 13 insertions, 10 deletions
diff --git a/ishtar/furnitures/forms.py b/ishtar/furnitures/forms.py
index b88fa19af..cb584ad01 100644
--- a/ishtar/furnitures/forms.py
+++ b/ishtar/furnitures/forms.py
@@ -95,8 +95,9 @@ class WarehouseForm(forms.Form):
mobile_phone = forms.CharField(label=_(u"Town"), max_length=18,
required=False)
- def save(self):
+ def save(self, user):
dct = self.cleaned_data
+ dct['history_modifier'] = user
dct['warehouse_type'] = models.WarehouseType.objects.get(
pk=dct['warehouse_type'])
if 'person_in_charge' in dct and dct['person_in_charge']:
diff --git a/ishtar/furnitures/urls.py b/ishtar/furnitures/urls.py
index 59e9ae6f2..5132e2f55 100644
--- a/ishtar/furnitures/urls.py
+++ b/ishtar/furnitures/urls.py
@@ -121,6 +121,6 @@ urlpatterns += patterns('ishtar.furnitures.views',
name='get-contextrecord'),
url(BASE_URL + r'get-item/(?P<type>.+)?$', 'get_archaeologicalitem',
name='get-item'),
- url(BASE_URL + r'new-warehouse/(?P<parent_name>.+)?/(?P<parent_pk>.+)?$',
+ url(BASE_URL + r'new-warehouse/(?P<parent_name>.+)?/$',
'new_warehouse', name='new-warehouse'),
)
diff --git a/ishtar/furnitures/views.py b/ishtar/furnitures/views.py
index 894a8f0cf..1af2e3991 100644
--- a/ishtar/furnitures/views.py
+++ b/ishtar/furnitures/views.py
@@ -407,10 +407,8 @@ def autocomplete_warehouse(request):
return HttpResponse(data, mimetype='text/plain')
def new_item(model):
- def func(request, parent_name='', parent_pk=''):
+ def func(request, parent_name):
model_name = model._meta.object_name
- if not parent_name:
- parent_name = model_name.lower()
if not check_permission(request, 'add_'+model_name.lower()):
not_permitted_msg = ugettext(u"Operation not permitted.")
return HttpResponse(not_permitted_msg)
@@ -419,11 +417,15 @@ def new_item(model):
if request.method == 'POST':
dct['form'] = frm(request.POST)
if dct['form'].is_valid():
- new_item = dct['form'].save()
+ new_item = dct['form'].save(request.user)
dct['new_item_label'] = unicode(new_item)
dct['new_item_pk'] = new_item.pk
dct['parent_name'] = parent_name
- dct['parent_pk'] = parent_pk
+ dct['parent_pk'] = parent_name
+ if '_select_' in dct['parent_pk']:
+ parents = dct['parent_pk'].split('_')
+ dct['parent_pk'] = "_".join([parents[0]] + parents[2:])
+ print dct
return render_to_response('window.html', dct,
context_instance=RequestContext(request))
else:
diff --git a/ishtar/furnitures/widgets.py b/ishtar/furnitures/widgets.py
index 5d2fc7c38..346cbd5a5 100644
--- a/ishtar/furnitures/widgets.py
+++ b/ishtar/furnitures/widgets.py
@@ -117,7 +117,7 @@ objects.get(pk=value))
if self.new:
model_name = self.associated_model._meta.object_name.lower()
new = u' <a href="#" onclick="open_window(\'%s\');">%s</a>' % \
- (reverse('new-' + model_name, args=[attrs_select['id'], attrs_hidden['id']]),
+ (reverse('new-' + model_name, args=[attrs_select['id']]),
unicode(_(u"Add")))
html = u'''<input%(attrs_select)s/>%(new)s\
<input type="hidden"%(attrs_hidden)s/>\
diff --git a/static/js/ishtar.js b/static/js/ishtar.js
index e32d2f1fa..e52ba69db 100644
--- a/static/js/ishtar.js
+++ b/static/js/ishtar.js
@@ -69,8 +69,8 @@ function open_window(url){
function save_and_close_window(name_label, name_pk, item_name, item_pk){
var main_page = opener.document.wizard;
- main_page[name_label] = item_name;
- main_page[name_pk] = item_pk;
+ jQuery(main_page).find("#"+name_label).val(item_name);
+ jQuery(main_page).find("#"+name_pk).val(item_pk);
opener.focus();
self.close();
}