浏览代码

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

Damien ACCORSI 10 年前
父节点
当前提交
29280a00bb
共有 1 个文件被更改,包括 13 次插入4 次删除
  1. 13 4
      tracim/tracim/controllers/content.py

+ 13 - 4
tracim/tracim/controllers/content.py 查看文件

195
         try:
195
         try:
196
             api = ContentApi(tmpl_context.current_user)
196
             api = ContentApi(tmpl_context.current_user)
197
             item = api.get_one(int(item_id), self._item_type, workspace)
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
             if isinstance(file_data, FieldStorage):
203
             if isinstance(file_data, FieldStorage):
202
                 api.update_file_data(item, file_data.filename, file_data.type, file_data.file.read())
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
             msg = _('{} updated').format(self._item_type_label)
209
             msg = _('{} updated').format(self._item_type_label)
207
             tg.flash(msg, CST.STATUS_OK)
210
             tg.flash(msg, CST.STATUS_OK)
431
         :param item_id:
434
         :param item_id:
432
         :return:
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
         item_id = int(item_id)
440
         item_id = int(item_id)
436
         user = tmpl_context.current_user
441
         user = tmpl_context.current_user
440
         item = content_api.get_one(item_id, ContentType.Any, workspace)
445
         item = content_api.get_one(item_id, ContentType.Any, workspace)
441
 
446
 
442
         dictified_item = Context(CTX.DEFAULT).toDict(item, 'item')
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
     @tg.require(current_user_is_content_manager())
455
     @tg.require(current_user_is_content_manager())