Просмотр исходного кода

Rolls back explicitly in case of content invalid path

Adrien Panay 7 лет назад
Родитель
Сommit
6371fbd7ef
1 измененных файлов: 10 добавлений и 7 удалений
  1. 10 7
      tracim/tracim/controllers/content.py

+ 10 - 7
tracim/tracim/controllers/content.py Просмотреть файл

@@ -343,6 +343,7 @@ class UserWorkspaceFolderFileRestController(TIMWorkspaceContentRestController):
343 343
                                  file_data.file.read())
344 344
             # Display error page to user if chosen label is in conflict
345 345
             if not self._path_validation.validate_new_content(file):
346
+                DBSession.rollback()
346 347
                 return render_invalid_integrity_chosen_path(
347 348
                     file.get_label_as_file(),
348 349
                 )
@@ -555,6 +556,7 @@ class UserWorkspaceFolderPageRestController(TIMWorkspaceContentRestController):
555 556
             page.description = content
556 557
 
557 558
             if not self._path_validation.validate_new_content(page):
559
+                DBSession.rollback()
558 560
                 return render_invalid_integrity_chosen_path(
559 561
                     page.get_label(),
560 562
                 )
@@ -671,19 +673,19 @@ class UserWorkspaceFolderThreadRestController(TIMWorkspaceContentRestController)
671 673
                                 workspace,
672 674
                                 tmpl_context.folder,
673 675
                                 label)
674
-            # FIXME - DO NOT DUPLCIATE FIRST MESSAGE
675
-            # thread.description = content
676
-            api.save(thread, ActionDescription.CREATION, do_notify=False)
677
-
678
-            comment = api.create(ContentType.Comment, workspace, thread, label)
679
-            comment.label = ''
680
-            comment.description = content
681 676
 
682 677
             if not self._path_validation.validate_new_content(thread):
678
+                DBSession.rollback()
683 679
                 return render_invalid_integrity_chosen_path(
684 680
                     thread.get_label(),
685 681
                 )
686 682
 
683
+        # FIXME - DO NOT DUPLICATE FIRST MESSAGE
684
+        # thread.description = content
685
+        api.save(thread, ActionDescription.CREATION, do_notify=False)
686
+        comment = api.create(ContentType.Comment, workspace, thread, label)
687
+        comment.label = ''
688
+        comment.description = content
687 689
         api.save(comment, ActionDescription.COMMENT, do_notify=False)
688 690
         api.do_notify(thread)
689 691
 
@@ -1008,6 +1010,7 @@ class UserWorkspaceFolderRestController(TIMRestControllerWithBreadcrumb):
1008 1010
                 api.set_allowed_content(folder, subcontent)
1009 1011
 
1010 1012
                 if not self._path_validation.validate_new_content(folder):
1013
+                    DBSession.rollback()
1011 1014
                     return render_invalid_integrity_chosen_path(
1012 1015
                         folder.get_label(),
1013 1016
                     )