|
@@ -17,37 +17,42 @@ from tracim.models.contents import ContentTypeLegacy as ContentType
|
17
|
17
|
|
18
|
18
|
class MoveParams(object):
|
19
|
19
|
"""
|
20
|
|
- Json body params for move action
|
|
20
|
+ Json body params for move action model
|
21
|
21
|
"""
|
22
|
|
- def __init__(self, new_parent_id: str, new_workspace_id: str = None):
|
|
22
|
+ def __init__(self, new_parent_id: str, new_workspace_id: str = None) -> None: # nopep8
|
23
|
23
|
self.new_parent_id = new_parent_id
|
24
|
24
|
self.new_workspace_id = new_workspace_id
|
25
|
25
|
|
26
|
26
|
|
27
|
27
|
class LoginCredentials(object):
|
28
|
28
|
"""
|
29
|
|
- Login credentials model for login
|
|
29
|
+ Login credentials model for login model
|
30
|
30
|
"""
|
31
|
31
|
|
32
|
|
- def __init__(self, email: str, password: str):
|
|
32
|
+ def __init__(self, email: str, password: str) -> None:
|
33
|
33
|
self.email = email
|
34
|
34
|
self.password = password
|
35
|
35
|
|
36
|
36
|
|
37
|
37
|
class WorkspaceAndContentPath(object):
|
38
|
38
|
"""
|
39
|
|
- Paths params with workspace id and content_id
|
|
39
|
+ Paths params with workspace id and content_id model
|
40
|
40
|
"""
|
41
|
|
- def __init__(self, workspace_id: int, content_id: int):
|
|
41
|
+ def __init__(self, workspace_id: int, content_id: int) -> None:
|
42
|
42
|
self.content_id = content_id
|
43
|
43
|
self.workspace_id = workspace_id
|
44
|
44
|
|
45
|
45
|
|
46
|
46
|
class CommentPath(object):
|
47
|
47
|
"""
|
48
|
|
- Paths params with workspace id and content_id
|
|
48
|
+ Paths params with workspace id and content_id and comment_id model
|
49
|
49
|
"""
|
50
|
|
- def __init__(self, workspace_id: int, content_id: int, comment_id: int):
|
|
50
|
+ def __init__(
|
|
51
|
+ self,
|
|
52
|
+ workspace_id: int,
|
|
53
|
+ content_id: int,
|
|
54
|
+ comment_id: int
|
|
55
|
+ ) -> None:
|
51
|
56
|
self.content_id = content_id
|
52
|
57
|
self.workspace_id = workspace_id
|
53
|
58
|
self.comment_id = comment_id
|
|
@@ -63,7 +68,7 @@ class ContentFilter(object):
|
63
|
68
|
show_archived: int = 0,
|
64
|
69
|
show_deleted: int = 0,
|
65
|
70
|
show_active: int = 1,
|
66
|
|
- ):
|
|
71
|
+ ) -> None:
|
67
|
72
|
self.parent_id = parent_id
|
68
|
73
|
self.show_archived = bool(show_archived)
|
69
|
74
|
self.show_deleted = bool(show_deleted)
|
|
@@ -78,7 +83,7 @@ class ContentCreation(object):
|
78
|
83
|
self,
|
79
|
84
|
label: str,
|
80
|
85
|
content_type: str,
|
81
|
|
- ):
|
|
86
|
+ ) -> None:
|
82
|
87
|
self.label = label
|
83
|
88
|
self.content_type = content_type
|
84
|
89
|
|
|
@@ -90,7 +95,7 @@ class CommentCreation(object):
|
90
|
95
|
def __init__(
|
91
|
96
|
self,
|
92
|
97
|
raw_content: str,
|
93
|
|
- ):
|
|
98
|
+ ) -> None:
|
94
|
99
|
self.raw_content = raw_content
|
95
|
100
|
|
96
|
101
|
|
|
@@ -101,7 +106,7 @@ class SetContentStatus(object):
|
101
|
106
|
def __init__(
|
102
|
107
|
self,
|
103
|
108
|
status: str,
|
104
|
|
- ):
|
|
109
|
+ ) -> None:
|
105
|
110
|
self.status = status
|
106
|
111
|
|
107
|
112
|
|
|
@@ -113,7 +118,7 @@ class HTMLDocumentUpdate(object):
|
113
|
118
|
self,
|
114
|
119
|
label: str,
|
115
|
120
|
raw_content: str,
|
116
|
|
- ):
|
|
121
|
+ ) -> None:
|
117
|
122
|
self.label = label
|
118
|
123
|
self.raw_content = raw_content
|
119
|
124
|
|
|
@@ -126,7 +131,7 @@ class ThreadUpdate(object):
|
126
|
131
|
self,
|
127
|
132
|
label: str,
|
128
|
133
|
raw_content: str,
|
129
|
|
- ):
|
|
134
|
+ ) -> None:
|
130
|
135
|
self.label = label
|
131
|
136
|
self.raw_content = raw_content
|
132
|
137
|
|
|
@@ -367,14 +372,11 @@ class ContentInContext(object):
|
367
|
372
|
@property
|
368
|
373
|
def content_type(self) -> str:
|
369
|
374
|
content_type = ContentType(self.content.type)
|
370
|
|
- if content_type:
|
371
|
|
- return content_type.slug
|
372
|
|
- else:
|
373
|
|
- return None
|
|
375
|
+ return content_type.slug
|
374
|
376
|
|
375
|
377
|
@property
|
376
|
378
|
def sub_content_types(self) -> typing.List[str]:
|
377
|
|
- return [_type.slug for _type in self.content.get_allowed_content_types()]
|
|
379
|
+ return [_type.slug for _type in self.content.get_allowed_content_types()] # nopep8
|
378
|
380
|
|
379
|
381
|
@property
|
380
|
382
|
def status(self) -> str:
|
|
@@ -444,8 +446,9 @@ class RevisionInContext(object):
|
444
|
446
|
Interface to get Content data and Content data related to context.
|
445
|
447
|
"""
|
446
|
448
|
|
447
|
|
- def __init__(self, content: ContentRevisionRO, dbsession: Session, config: CFG):
|
448
|
|
- self.revision = content
|
|
449
|
+ def __init__(self, content_revision: ContentRevisionRO, dbsession: Session, config: CFG):
|
|
450
|
+ assert content_revision is not None
|
|
451
|
+ self.revision = content_revision
|
449
|
452
|
self.dbsession = dbsession
|
450
|
453
|
self.config = config
|
451
|
454
|
|
|
@@ -491,19 +494,19 @@ class RevisionInContext(object):
|
491
|
494
|
return self.revision.status
|
492
|
495
|
|
493
|
496
|
@property
|
494
|
|
- def is_archived(self):
|
|
497
|
+ def is_archived(self) -> bool:
|
495
|
498
|
return self.revision.is_archived
|
496
|
499
|
|
497
|
500
|
@property
|
498
|
|
- def is_deleted(self):
|
|
501
|
+ def is_deleted(self) -> bool:
|
499
|
502
|
return self.revision.is_deleted
|
500
|
503
|
|
501
|
504
|
@property
|
502
|
|
- def raw_content(self):
|
|
505
|
+ def raw_content(self) -> str:
|
503
|
506
|
return self.revision.description
|
504
|
507
|
|
505
|
508
|
@property
|
506
|
|
- def author(self):
|
|
509
|
+ def author(self) -> UserInContext:
|
507
|
510
|
return UserInContext(
|
508
|
511
|
dbsession=self.dbsession,
|
509
|
512
|
config=self.config,
|
|
@@ -511,23 +514,27 @@ class RevisionInContext(object):
|
511
|
514
|
)
|
512
|
515
|
|
513
|
516
|
@property
|
514
|
|
- def revision_id(self):
|
|
517
|
+ def revision_id(self) -> int:
|
515
|
518
|
return self.revision.revision_id
|
516
|
519
|
|
517
|
520
|
@property
|
518
|
|
- def created(self):
|
|
521
|
+ def created(self) -> datetime:
|
519
|
522
|
return self.updated
|
520
|
523
|
|
521
|
524
|
@property
|
522
|
|
- def modified(self):
|
|
525
|
+ def modified(self) -> datetime:
|
523
|
526
|
return self.updated
|
524
|
527
|
|
525
|
528
|
@property
|
526
|
|
- def updated(self):
|
|
529
|
+ def updated(self) -> datetime:
|
527
|
530
|
return self.revision.updated
|
528
|
531
|
|
529
|
532
|
@property
|
530
|
|
- def next_revision(self):
|
|
533
|
+ def next_revision(self) -> typing.Optional[ContentRevisionRO]:
|
|
534
|
+ """
|
|
535
|
+ Get next revision (later revision)
|
|
536
|
+ :return: next_revision
|
|
537
|
+ """
|
531
|
538
|
next_revision = None
|
532
|
539
|
revisions = self.revision.node.revisions
|
533
|
540
|
# INFO - G.M - 2018-06-177 - Get revisions more recent that
|
|
@@ -548,7 +555,7 @@ class RevisionInContext(object):
|
548
|
555
|
return None
|
549
|
556
|
|
550
|
557
|
@property
|
551
|
|
- def comments_ids(self):
|
|
558
|
+ def comments_ids(self) -> typing.List[int]:
|
552
|
559
|
comments = self.revision.node.get_comments()
|
553
|
560
|
# INFO - G.M - 2018-06-177 - Get comments more recent than revision.
|
554
|
561
|
revisions_comments = [
|
|
@@ -575,7 +582,7 @@ class RevisionInContext(object):
|
575
|
582
|
|
576
|
583
|
# Context-related
|
577
|
584
|
@property
|
578
|
|
- def show_in_ui(self):
|
|
585
|
+ def show_in_ui(self) -> bool:
|
579
|
586
|
# TODO - G.M - 31-05-2018 - Enable Show_in_ui params
|
580
|
587
|
# if false, then do not show content in the treeview.
|
581
|
588
|
# This may his maybe used for specific contents or for sub-contents.
|
|
@@ -584,5 +591,5 @@ class RevisionInContext(object):
|
584
|
591
|
return True
|
585
|
592
|
|
586
|
593
|
@property
|
587
|
|
- def slug(self):
|
|
594
|
+ def slug(self) -> str:
|
588
|
595
|
return slugify(self.revision.label)
|