Browse Source

Improves comments and readability for #270

Adrien Panay 7 years ago
parent
commit
eca2f15d25

+ 2 - 0
tracim/tracim/controllers/page.py View File

@@ -22,6 +22,7 @@ class PagesController(TIMRestController):
22 22
         file_id = int(tg.request.controller_state.routing_args.get('file_id'))
23 23
         return 'all the pages of document {}'.format(file_id)
24 24
 
25
+    # FIXME https://github.com/tracim/tracim/issues/271
25 26
     @expose(content_type='image/jpeg')
26 27
     def get_one(self,
27 28
                 page_id: str='-1',
@@ -71,6 +72,7 @@ class PagesController(TIMRestController):
71 72
                                      revision_id=revision_id,
72 73
                                      args=args, kwargs=kwargs)
73 74
 
75
+    # FIXME https://github.com/tracim/tracim/issues/271
74 76
     @expose(content_type='application/pdf')
75 77
     def download_pdf_one(self,
76 78
                          page_id: str,

+ 2 - 0
tracim/tracim/controllers/previews.py View File

@@ -7,6 +7,8 @@ from tracim.controllers.page import PagesController
7 7
 __all__ = ['PreviewsController']
8 8
 
9 9
 
10
+# FIXME https://github.com/tracim/tracim/issues/272
11
+# unused, future removal planned
10 12
 class PreviewsController(TIMRestController):
11 13
 
12 14
     pages = PagesController()

+ 7 - 9
tracim/tracim/lib/content.py View File

@@ -452,6 +452,9 @@ class ContentApi(object):
452 452
 
453 453
         return revision
454 454
 
455
+    # INFO - A.P - 2017-07-03 - python file object getter
456
+    # in case of we cook a version of preview manager that allows a pythonic
457
+    # access to files
455 458
     # def get_one_revision_file(self, revision_id: int = None):
456 459
     #     """
457 460
     #     This function allows us to directly get a Python file object from its
@@ -470,15 +473,10 @@ class ContentApi(object):
470 473
         :return: The corresponding filepath
471 474
         """
472 475
         revision = self.get_one_revision(revision_id)
473
-
474
-        dpt = DepotManager.get()
475
-        # python 3.6 PEP 526 -- Syntax for Variable Annotations
476
-        # https://www.python.org/dev/peps/pep-0526/
477
-        # dpt_file_path: str = dpt.get(dpt_stored_file)._file_path
478
-        dpt_stored_file = dpt.get(revision.depot_file)
479
-        dpt_file_path = dpt.get(dpt_stored_file)._file_path
480
-
481
-        return dpt_file_path
476
+        depot = DepotManager.get()
477
+        depot_stored_file = depot.get(revision.depot_file)  # type: StoredFile
478
+        depot_file_path = depot_stored_file._file_path  # type: str
479
+        return depot_file_path
482 480
 
483 481
     def get_one_by_label_and_parent(
484 482
             self,

+ 20 - 0
tracim/tracim/model/data.py View File

@@ -545,7 +545,27 @@ class ContentRevisionRO(DeclarativeBase):
545 545
         server_default='',
546 546
     )
547 547
     file_mimetype = Column(Unicode(255),  unique=False, nullable=False, default='')
548
+    # TODO - A.P - 2017-07-03 - future removal planned
549
+    # file_content is to be replaced by depot_file, for now both coexist as
550
+    # this:
551
+    # - file_content data is still setted
552
+    # - newly created revision also gets depot_file data setted
553
+    # - access to the file of a revision from depot_file exclusively
554
+    # Here is the tasks workflow of the DB to OnDisk Switch :
555
+    # - Add depot_file "prototype style"
556
+    #   https://github.com/tracim/tracim/issues/233 - DONE
557
+    # - Integrate preview generator feature "prototype style"
558
+    #   https://github.com/tracim/tracim/issues/232 - DONE
559
+    # - Write migrations
560
+    #   https://github.com/tracim/tracim/issues/245
561
+    #   https://github.com/tracim/tracim/issues/246
562
+    # - Stabilize preview generator integration
563
+    #   includes dropping DB file content
564
+    #   https://github.com/tracim/tracim/issues/249
548 565
     file_content = deferred(Column(LargeBinary(), unique=False, nullable=True))
566
+    # INFO - A.P - 2017-07-03 - Depot Doc
567
+    # http://depot.readthedocs.io/en/latest/#attaching-files-to-models
568
+    # http://depot.readthedocs.io/en/latest/api.html#module-depot.fields
549 569
     depot_file = Column(UploadedFileField, unique=False, nullable=True)
550 570
     properties = Column('properties', Text(), unique=False, nullable=False, default='')
551 571
 

+ 3 - 3
tracim/tracim/model/serializers.py View File

@@ -409,12 +409,12 @@ def serialize_node_for_page(content: Content, context: Context):
409 409
         )
410 410
 
411 411
         if content.type == ContentType.File:
412
-            dpt = DepotManager.get()
413
-            dpt_file = dpt.get(data_container.depot_file)
412
+            depot = DepotManager.get()
413
+            depot_stored_file = depot.get(data_container.depot_file)
414 414
             result.label = content.label
415 415
             result['file'] = DictLikeClass(
416 416
                 name=data_container.file_name,
417
-                size=dpt_file.content_length,
417
+                size=depot_stored_file.content_length,
418 418
                 mimetype=data_container.file_mimetype)
419 419
         return result
420 420