Browse Source

fixed transaction problems

Dimitri Korsch 3 years ago
parent
commit
ade5ab33e6

+ 11 - 0
package-lock.json

@@ -0,0 +1,11 @@
+{
+  "requires": true,
+  "lockfileVersion": 1,
+  "dependencies": {
+    "vue-debounce": {
+      "version": "3.0.2",
+      "resolved": "https://registry.npmjs.org/vue-debounce/-/vue-debounce-3.0.2.tgz",
+      "integrity": "sha512-+shuc9Ry+AFqJbN7BMfagazB81/bTiPWvUZ4KBjambgrd3B5EQBojxeGzeNZ21xRflnwB098BG1d0HtWv8WyzA=="
+    }
+  }
+}

+ 1 - 1
pycs/database/File.py

@@ -246,7 +246,7 @@ class File(NamedBaseModel):
             if isinstance(label, Label):
                 label = label.id
 
-            result.set_label(label)
+            result.set_label(label, commit=False)
 
         return result
 

+ 5 - 4
pycs/database/Result.py

@@ -98,7 +98,7 @@ class Result(BaseModel):
 
         self.origin = origin
         self.origin_user = origin_user
-        self.reset_confirmations()
+        self.reset_confirmations(commit=False)
 
     @commit_on_return
     def set_label(self, label: int):
@@ -109,7 +109,7 @@ class Result(BaseModel):
         :return:
         """
         if self.label_id != label:
-            self.reset_confirmations()
+            self.reset_confirmations(commit=False)
             self.label_id = label
 
     @property
@@ -130,6 +130,7 @@ class Result(BaseModel):
 
         return _confirmations
 
+    @commit_on_return
     def reset_confirmations(self) -> T.List[ResultConfirmation]:
         """
         Resets all confirmations
@@ -139,8 +140,8 @@ class Result(BaseModel):
         confirmations = ResultConfirmation.query.filter(
                 ResultConfirmation.result_id == self.id)
 
-        _confirmations = [c.serialize() for c in confirmations.all()]
-        confirmations.delete()
+        # delete returns the serialized object
+        _confirmations = [c.delete(commit=False) for c in confirmations.all()]
 
         return _confirmations
 

+ 5 - 5
pycs/frontend/endpoints/results/CopyResults.py

@@ -21,25 +21,25 @@ class CopyResults(View):
         # pylint: disable=invalid-name
         self.nm = nm
 
-    def dispatch_request(self, file_id: int):
+    def dispatch_request(self, user: str, file_id: int):
 
-        file = File.get_or_404(file_id)
         request_data = request.get_json(force=True)
 
         if 'copy_from' not in request_data:
             abort(400, "copy_from argument is missing")
 
-        other_file = File.get_or_404(request_data.get('copy_from'))
-
         new = []
         # start transaction
         with db.session.begin_nested():
+            file = File.get_or_404(file_id)
+            other_file = File.get_or_404(request_data.get('copy_from'))
 
             for result in other_file.results.all():
                 new_result = file.create_result(
                     origin='pipeline',
                     result_type=result.type,
-                    label=result.label,
+                    origin_user=None,
+                    label=result.label_id,
                     data=result.data,
                     commit=False)
                 new.append(new_result)

+ 2 - 0
webui/src/components/media/cropped-image.vue

@@ -222,6 +222,8 @@ export default {
   text-align: center;
   border-left: 2px solid;
   margin-left: 0.5rem;
+
+  box-shadow: -5px 0px 15px gray;
 }
 
 h3 {