Browse Source

Rolls back explicitly in case of content invalid path

Adrien Panay 7 years ago
parent
commit
6371fbd7ef
1 changed files with 10 additions and 7 deletions
  1. 10 7
      tracim/tracim/controllers/content.py

+ 10 - 7
tracim/tracim/controllers/content.py View File

343
                                  file_data.file.read())
343
                                  file_data.file.read())
344
             # Display error page to user if chosen label is in conflict
344
             # Display error page to user if chosen label is in conflict
345
             if not self._path_validation.validate_new_content(file):
345
             if not self._path_validation.validate_new_content(file):
346
+                DBSession.rollback()
346
                 return render_invalid_integrity_chosen_path(
347
                 return render_invalid_integrity_chosen_path(
347
                     file.get_label_as_file(),
348
                     file.get_label_as_file(),
348
                 )
349
                 )
555
             page.description = content
556
             page.description = content
556
 
557
 
557
             if not self._path_validation.validate_new_content(page):
558
             if not self._path_validation.validate_new_content(page):
559
+                DBSession.rollback()
558
                 return render_invalid_integrity_chosen_path(
560
                 return render_invalid_integrity_chosen_path(
559
                     page.get_label(),
561
                     page.get_label(),
560
                 )
562
                 )
671
                                 workspace,
673
                                 workspace,
672
                                 tmpl_context.folder,
674
                                 tmpl_context.folder,
673
                                 label)
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
             if not self._path_validation.validate_new_content(thread):
677
             if not self._path_validation.validate_new_content(thread):
678
+                DBSession.rollback()
683
                 return render_invalid_integrity_chosen_path(
679
                 return render_invalid_integrity_chosen_path(
684
                     thread.get_label(),
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
         api.save(comment, ActionDescription.COMMENT, do_notify=False)
689
         api.save(comment, ActionDescription.COMMENT, do_notify=False)
688
         api.do_notify(thread)
690
         api.do_notify(thread)
689
 
691
 
1008
                 api.set_allowed_content(folder, subcontent)
1010
                 api.set_allowed_content(folder, subcontent)
1009
 
1011
 
1010
                 if not self._path_validation.validate_new_content(folder):
1012
                 if not self._path_validation.validate_new_content(folder):
1013
+                    DBSession.rollback()
1011
                     return render_invalid_integrity_chosen_path(
1014
                     return render_invalid_integrity_chosen_path(
1012
                         folder.get_label(),
1015
                         folder.get_label(),
1013
                     )
1016
                     )