Browse Source

allow to update file label without comment + fixes last_action associated with

Damien ACCORSI 10 years ago
parent
commit
29280a00bb
1 changed files with 13 additions and 4 deletions
  1. 13 4
      tracim/tracim/controllers/content.py

+ 13 - 4
tracim/tracim/controllers/content.py View File

@@ -195,13 +195,16 @@ class UserWorkspaceFolderFileRestController(TIMWorkspaceContentRestController):
195 195
         try:
196 196
             api = ContentApi(tmpl_context.current_user)
197 197
             item = api.get_one(int(item_id), self._item_type, workspace)
198
-            if comment:
199
-                api.update_content(item, label if label else item.label, comment)
198
+            if comment or label:
199
+                api.update_content(item, label if label else item.label, comment if comment else '')
200
+                action_description = ActionDescription.EDITION
201
+                # The action_description is overwritten by ActionDescription.REVISION if the file content is also updated
200 202
 
201 203
             if isinstance(file_data, FieldStorage):
202 204
                 api.update_file_data(item, file_data.filename, file_data.type, file_data.file.read())
205
+                action_description = ActionDescription.REVISION
203 206
 
204
-            api.save(item, ActionDescription.REVISION)
207
+            api.save(item, action_description)
205 208
 
206 209
             msg = _('{} updated').format(self._item_type_label)
207 210
             tg.flash(msg, CST.STATUS_OK)
@@ -431,6 +434,8 @@ class ItemLocationController(TIMWorkspaceContentRestController, BaseController):
431 434
         :param item_id:
432 435
         :return:
433 436
         """
437
+        current_user_content = Context(CTX.CURRENT_USER).toDict(tmpl_context.current_user)
438
+        fake_api = Context(CTX.FOLDER).toDict(DictLikeClass(current_user=current_user_content))
434 439
 
435 440
         item_id = int(item_id)
436 441
         user = tmpl_context.current_user
@@ -440,7 +445,11 @@ class ItemLocationController(TIMWorkspaceContentRestController, BaseController):
440 445
         item = content_api.get_one(item_id, ContentType.Any, workspace)
441 446
 
442 447
         dictified_item = Context(CTX.DEFAULT).toDict(item, 'item')
443
-        return DictLikeClass(result = dictified_item)
448
+        return DictLikeClass(result = dictified_item, fake_api=fake_api)
449
+
450
+
451
+
452
+
444 453
 
445 454
 
446 455
     @tg.require(current_user_is_content_manager())