Dimitri Korsch пре 3 година
родитељ
комит
06659adafe
2 измењених фајлова са 5 додато и 21 уклоњено
  1. 2 13
      pycs/frontend/WebServer.py
  2. 3 8
      pycs/frontend/endpoints/data/GetCroppedFile.py

+ 2 - 13
pycs/frontend/WebServer.py

@@ -224,7 +224,7 @@ class WebServer:
         )
         self.app.add_url_rule(
             '/data/<int:file_id>/<resolution>/<crop_box>',
-            view_func=GetCroppedFile.as_view('crop_result', database)
+            view_func=GetCroppedFile.as_view('crop_result')
         )
         self.app.add_url_rule(
             '/data/<int:file_id>/previous_next',
@@ -256,18 +256,7 @@ class WebServer:
             '/results/<int:result_id>/confirm',
             view_func=ConfirmResult.as_view('confirm_result', notifications)
         )
-        self.app.add_url_rule(
-            '/results/<int:result_id>/crop',
-            view_func=ResultAsCrop.as_view('crop_result')
-        )
-        self.app.add_url_rule(
-            '/results/<int:result_id>/crop/<int:max_width>',
-            view_func=ResultAsCrop.as_view('crop_result_resized_by_width')
-        )
-        self.app.add_url_rule(
-            '/results/<int:result_id>/crop/<int:max_width>x<int:max_height>',
-            view_func=ResultAsCrop.as_view('crop_result_resized')
-        )
+
         self.app.add_url_rule(
             '/results/<int:result_id>/label',
             view_func=EditResultLabel.as_view('edit_result_label', notifications)

+ 3 - 8
pycs/frontend/endpoints/data/GetCroppedFile.py

@@ -6,7 +6,7 @@ from flask import abort
 from flask import send_from_directory
 from flask.views import View
 
-from pycs.database.Database import Database
+from pycs.database.File import File
 from pycs.util.FileOperations import crop_file
 
 
@@ -17,17 +17,12 @@ class GetCroppedFile(View):
     # pylint: disable=arguments-differ
     methods = ['GET']
 
-    def __init__(self, db: Database):
-        # pylint: disable=invalid-name
-        self.db = db
 
     def dispatch_request(self, file_id: int, resolution: str, crop_box: str):
         # get file from database
-        file = self.db.file(file_id)
-        if file is None:
-            return abort(404)
+        file = File.get_or_404(file_id)
 
-        project = file.project()
+        project = file.project
 
         if not os.path.exists(file.absolute_path):
             abort(404, "File not found!")