|
@@ -26,6 +26,7 @@ from sqlalchemy.types import Text
|
26
|
26
|
from sqlalchemy.types import Unicode
|
27
|
27
|
from depot.fields.sqlalchemy import UploadedFileField
|
28
|
28
|
from depot.fields.upload import UploadedFile
|
|
29
|
+from depot.io.utils import FileIntent
|
29
|
30
|
|
30
|
31
|
from tracim.lib.utils import lazy_ugettext as l_
|
31
|
32
|
from tracim.lib.exception import ContentRevisionUpdateError
|
|
@@ -545,23 +546,6 @@ class ContentRevisionRO(DeclarativeBase):
|
545
|
546
|
server_default='',
|
546
|
547
|
)
|
547
|
548
|
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
|
565
|
549
|
file_content = deferred(Column(LargeBinary(), unique=False, nullable=True))
|
566
|
550
|
# INFO - A.P - 2017-07-03 - Depot Doc
|
567
|
551
|
# http://depot.readthedocs.io/en/latest/#attaching-files-to-models
|
|
@@ -592,7 +576,6 @@ class ContentRevisionRO(DeclarativeBase):
|
592
|
576
|
'content_id',
|
593
|
577
|
'created',
|
594
|
578
|
'description',
|
595
|
|
- 'file_content',
|
596
|
579
|
'file_mimetype',
|
597
|
580
|
'file_extension',
|
598
|
581
|
'is_archived',
|
|
@@ -649,10 +632,12 @@ class ContentRevisionRO(DeclarativeBase):
|
649
|
632
|
setattr(new_rev, column_name, column_value)
|
650
|
633
|
|
651
|
634
|
new_rev.updated = datetime.utcnow()
|
652
|
|
- # TODO APY tweaks here depot_file
|
653
|
|
- # import pudb; pu.db
|
654
|
|
- # new_rev.depot_file = DepotManager.get().get(revision.depot_file)
|
655
|
|
- new_rev.depot_file = revision.file_content
|
|
635
|
+ if revision.depot_file:
|
|
636
|
+ new_rev.depot_file = FileIntent(
|
|
637
|
+ revision.depot_file.file.read(),
|
|
638
|
+ revision.file_name,
|
|
639
|
+ revision.file_mimetype,
|
|
640
|
+ )
|
656
|
641
|
|
657
|
642
|
return new_rev
|
658
|
643
|
|
|
@@ -861,18 +846,6 @@ class Content(DeclarativeBase):
|
861
|
846
|
return ContentRevisionRO.file_mimetype
|
862
|
847
|
|
863
|
848
|
@hybrid_property
|
864
|
|
- def file_content(self):
|
865
|
|
- return self.revision.file_content
|
866
|
|
-
|
867
|
|
- @file_content.setter
|
868
|
|
- def file_content(self, value):
|
869
|
|
- self.revision.file_content = value
|
870
|
|
-
|
871
|
|
- @file_content.expression
|
872
|
|
- def file_content(cls) -> InstrumentedAttribute:
|
873
|
|
- return ContentRevisionRO.file_content
|
874
|
|
-
|
875
|
|
- @hybrid_property
|
876
|
849
|
def _properties(self) -> str:
|
877
|
850
|
return self.revision.properties
|
878
|
851
|
|