summaryrefslogtreecommitdiff
path: root/ishtar/furnitures
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar/furnitures')
-rw-r--r--ishtar/furnitures/urls.py6
-rw-r--r--ishtar/furnitures/views.py16
2 files changed, 20 insertions, 2 deletions
diff --git a/ishtar/furnitures/urls.py b/ishtar/furnitures/urls.py
index 5a155b5b5..e7e9ff85a 100644
--- a/ishtar/furnitures/urls.py
+++ b/ishtar/furnitures/urls.py
@@ -96,7 +96,7 @@ actions = r"|".join(actions)
urlpatterns += patterns('ishtar.furnitures.views',
url(BASE_URL + r'(?P<action_slug>' + actions + r')/$', 'action',
name='action'),
- url(BASE_URL + r'autocomplete-persone/([0-9_]+)?$', 'autocomplete_person',
+ url(BASE_URL + r'autocomplete-person/([0-9_]+)?$', 'autocomplete_person',
name='autocomplete-person'),
url(BASE_URL + r'autocomplete-town/$', 'autocomplete_town',
name='autocomplete-town'),
@@ -113,10 +113,14 @@ urlpatterns += patterns('ishtar.furnitures.views',
name='show-file'),
url(BASE_URL + r'show-historized-file/(?P<pk>.+)?/(?P<date>.+)?$',
'show_file', name='show-historized-file'),
+ url(BASE_URL + r'revert-file/(?P<pk>.+)/(?P<date>.+)$',
+ 'revert_file', name='revert-file'),
url(BASE_URL + r'autocomplete-operation/$', 'autocomplete_operation',
name='autocomplete-operation'),
url(BASE_URL + r'get-operation/(?P<type>.+)?$', 'get_operation',
name='get-operation'),
+ url(BASE_URL + r'revert-operation/(?P<pk>.+)/(?P<date>.+)$',
+ 'revert_operation', name='revert-operation'),
url(BASE_URL + r'show-operation/(?P<pk>.+)?/(?P<type>.+)?$',
'show_operation',
name='show-operation'),
diff --git a/ishtar/furnitures/views.py b/ishtar/furnitures/views.py
index 8dea8cb2f..107d9f3ea 100644
--- a/ishtar/furnitures/views.py
+++ b/ishtar/furnitures/views.py
@@ -289,7 +289,7 @@ def show_item(model, name):
datetime.datetime.now().strftime('%M%s'))
if date:
try:
- date = datetime.datetime.strptime(date, '%Y-%m-%d %H:%M:%S.%f')
+ date = datetime.datetime.strptime(date, '%Y-%m-%dT%H:%M:%S.%f')
item = item.get_previous(date=date)
assert item != None
except (ValueError, AssertionError):
@@ -369,8 +369,21 @@ def show_item(model, name):
return HttpResponse(content, content_type="application/xhtml")
return func
+def revert_item(model):
+ def func(request, pk, date, **dct):
+ try:
+ item = model.objects.get(pk=pk)
+ date = datetime.datetime.strptime(date, '%Y-%m-%dT%H:%M:%S.%f')
+ item.rollback(date)
+ except (ObjectDoesNotExist, ValueError, HistoryError):
+ return HttpResponse(None, mimetype='text/plain')
+ return HttpResponse("True", mimetype='text/plain')
+ return func
+
+
get_file = get_item(models.File, 'get_file', 'file')
show_file = show_item(models.File, 'file')
+revert_file = revert_item(models.File)
def autocomplete_operation(request, non_closed=True):
if not request.user.has_perm('furnitures.view_operation', models.Operation)\
@@ -399,6 +412,7 @@ def autocomplete_operation(request, non_closed=True):
get_operation = get_item(models.Operation, 'get_operation', 'operation')
show_operation = show_item(models.Operation, 'operation')
+revert_operation = revert_item(models.Operation)
get_administrativeactfile = get_item(models.AdministrativeAct,
'get_administrativeactfile', 'administrativeactfile',