|
@@ -16,16 +16,31 @@ from tracim.models.context_models import LoginCredentials
|
16
|
16
|
from tracim.models.data import UserRoleInWorkspace
|
17
|
17
|
|
18
|
18
|
|
19
|
|
-class UserSchema(marshmallow.Schema):
|
20
|
|
-
|
|
19
|
+class UserDigestSchema(marshmallow.Schema):
|
|
20
|
+ """
|
|
21
|
+ Simple user schema
|
|
22
|
+ """
|
21
|
23
|
user_id = marshmallow.fields.Int(dump_only=True, example=3)
|
22
|
|
- email = marshmallow.fields.Email(
|
23
|
|
- required=True,
|
24
|
|
- example='suri.cate@algoo.fr'
|
|
24
|
+ avatar_url = marshmallow.fields.Url(
|
|
25
|
+ allow_none=True,
|
|
26
|
+ example="/api/v2/assets/avatars/suri-cate.jpg",
|
|
27
|
+ description="avatar_url is the url to the image file. "
|
|
28
|
+ "If no avatar, then set it to null "
|
|
29
|
+ "(and frontend will interpret this with a default avatar)",
|
25
|
30
|
)
|
26
|
31
|
public_name = marshmallow.fields.String(
|
27
|
32
|
example='Suri Cate',
|
28
|
33
|
)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+class UserSchema(UserDigestSchema):
|
|
37
|
+ """
|
|
38
|
+ Complete user schema
|
|
39
|
+ """
|
|
40
|
+ email = marshmallow.fields.Email(
|
|
41
|
+ required=True,
|
|
42
|
+ example='suri.cate@algoo.fr'
|
|
43
|
+ )
|
29
|
44
|
created = marshmallow.fields.DateTime(
|
30
|
45
|
format='%Y-%m-%dT%H:%M:%SZ',
|
31
|
46
|
description='User account creation date',
|
|
@@ -46,13 +61,6 @@ class UserSchema(marshmallow.Schema):
|
46
|
61
|
example="/api/v2/calendar/user/3.ics/",
|
47
|
62
|
description="The url for calendar CalDAV direct access",
|
48
|
63
|
)
|
49
|
|
- avatar_url = marshmallow.fields.Url(
|
50
|
|
- allow_none=True,
|
51
|
|
- example="/api/v2/assets/avatars/suri-cate.jpg",
|
52
|
|
- description="avatar_url is the url to the image file. "
|
53
|
|
- "If no avatar, then set it to null "
|
54
|
|
- "(and frontend will interpret this with a default avatar)",
|
55
|
|
- )
|
56
|
64
|
profile = marshmallow.fields.String(
|
57
|
65
|
attribute='profile',
|
58
|
66
|
validate=OneOf(Profile._NAME),
|
|
@@ -62,7 +70,6 @@ class UserSchema(marshmallow.Schema):
|
62
|
70
|
class Meta:
|
63
|
71
|
description = 'User account of Tracim'
|
64
|
72
|
|
65
|
|
-
|
66
|
73
|
# Path Schemas
|
67
|
74
|
|
68
|
75
|
|
|
@@ -78,12 +85,23 @@ class ContentIdPathSchema(marshmallow.Schema):
|
78
|
85
|
content_id = marshmallow.fields.Int(example=6, required=True)
|
79
|
86
|
|
80
|
87
|
|
81
|
|
-class WorkspaceAndContentIdPathSchema(WorkspaceIdPathSchema, ContentIdPathSchema):
|
|
88
|
+class WorkspaceAndContentIdPathSchema(
|
|
89
|
+ WorkspaceIdPathSchema,
|
|
90
|
+ ContentIdPathSchema
|
|
91
|
+):
|
82
|
92
|
@post_load
|
83
|
93
|
def make_path_object(self, data):
|
84
|
94
|
return WorkspaceAndContentPath(**data)
|
85
|
95
|
|
86
|
96
|
|
|
97
|
+class CommentsPathSchema(WorkspaceAndContentIdPathSchema):
|
|
98
|
+ comment_id = marshmallow.fields.Int(
|
|
99
|
+ example=6,
|
|
100
|
+ description='id of a comment related to content content_id',
|
|
101
|
+ required=True
|
|
102
|
+ )
|
|
103
|
+
|
|
104
|
+
|
87
|
105
|
class FilterContentQuerySchema(marshmallow.Schema):
|
88
|
106
|
parent_id = marshmallow.fields.Int(
|
89
|
107
|
example=2,
|
|
@@ -116,6 +134,7 @@ class FilterContentQuerySchema(marshmallow.Schema):
|
116
|
134
|
'The reason for this parameter to exist is for example '
|
117
|
135
|
'to allow to show only archived documents'
|
118
|
136
|
)
|
|
137
|
+
|
119
|
138
|
@post_load
|
120
|
139
|
def make_content_filter(self, data):
|
121
|
140
|
return ContentFilter(**data)
|
|
@@ -335,7 +354,7 @@ class ContentDigestSchema(marshmallow.Schema):
|
335
|
354
|
validate=OneOf([content.slug for content in CONTENT_DEFAULT_TYPE]),
|
336
|
355
|
)
|
337
|
356
|
sub_content_types = marshmallow.fields.List(
|
338
|
|
- marshmallow.fields.Str,
|
|
357
|
+ marshmallow.fields.String(),
|
339
|
358
|
description='list of content types allowed as sub contents. '
|
340
|
359
|
'This field is required for folder contents, '
|
341
|
360
|
'set it to empty list in other cases'
|
|
@@ -355,3 +374,92 @@ class ContentDigestSchema(marshmallow.Schema):
|
355
|
374
|
'for sub-contents. Default is True. '
|
356
|
375
|
'In first version of the API, this field is always True',
|
357
|
376
|
)
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+#####
|
|
380
|
+# Content
|
|
381
|
+#####
|
|
382
|
+
|
|
383
|
+class ContentSchema(ContentDigestSchema):
|
|
384
|
+ current_revision_id = marshmallow.fields.Int(example=12)
|
|
385
|
+ created = marshmallow.fields.DateTime(
|
|
386
|
+ format='%Y-%m-%dT%H:%M:%SZ',
|
|
387
|
+ description='Content creation date',
|
|
388
|
+ )
|
|
389
|
+ author = marshmallow.fields.Nested(UserDigestSchema)
|
|
390
|
+ modified = marshmallow.fields.DateTime(
|
|
391
|
+ format='%Y-%m-%dT%H:%M:%SZ',
|
|
392
|
+ description='date of last modification of content',
|
|
393
|
+ )
|
|
394
|
+ last_modifier = marshmallow.fields.Nested(UserDigestSchema)
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+class ThreadContentSchema(ContentSchema):
|
|
398
|
+ raw_content = marshmallow.fields.String('Description of Thread')
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+class HtmlDocumentContentSchema(ContentSchema):
|
|
402
|
+ raw_content = marshmallow.fields.String('<p>Html page Content !</p>')
|
|
403
|
+
|
|
404
|
+#####
|
|
405
|
+# Revision
|
|
406
|
+#####
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+class RevisionSchema(ContentDigestSchema):
|
|
410
|
+ comments_id = marshmallow.fields.List(marshmallow.fields.Int(example=4))
|
|
411
|
+ revision_id = marshmallow.fields.Int(example=12)
|
|
412
|
+ created = marshmallow.fields.DateTime(
|
|
413
|
+ format='%Y-%m-%dT%H:%M:%SZ',
|
|
414
|
+ description='Content creation date',
|
|
415
|
+ )
|
|
416
|
+ author = marshmallow.fields.Nested(UserDigestSchema)
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+class ThreadRevisionSchema(RevisionSchema):
|
|
420
|
+ raw_content = marshmallow.fields.String('Description of Thread')
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+class HtmlDocumentRevisionSchema(RevisionSchema):
|
|
424
|
+ raw_content = marshmallow.fields.String('<p>Html page Content !</p>')
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+####
|
|
428
|
+
|
|
429
|
+class CommentSchema(marshmallow.Schema):
|
|
430
|
+ content_id = marshmallow.fields.Int(example=6)
|
|
431
|
+ parent_id = marshmallow.fields.Int(example=34)
|
|
432
|
+ raw_content = marshmallow.fields.String(
|
|
433
|
+ example='<p>This is just an html comment !</p>'
|
|
434
|
+ )
|
|
435
|
+ author = marshmallow.fields.Nested(UserDigestSchema)
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+class ContentModifySchema(marshmallow.Schema):
|
|
439
|
+ label = marshmallow.fields.String(
|
|
440
|
+ example='contract for client XXX',
|
|
441
|
+ description='New title of the content'
|
|
442
|
+ )
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+class HtmlDocumentModifySchema(ContentModifySchema):
|
|
446
|
+ raw_content = marshmallow.fields.String('<p>Html page Content !</p>')
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+class ThreadModifySchema(ContentModifySchema):
|
|
450
|
+ raw_content = marshmallow.fields.String('Description of Thread')
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+class SetCommentSchema(marshmallow.Schema):
|
|
454
|
+ raw_content = marshmallow.fields.String(
|
|
455
|
+ example='<p>This is just an html comment !</p>'
|
|
456
|
+ )
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+class SetContentStatusSchema(marshmallow.Schema):
|
|
460
|
+ status = marshmallow.fields.Str(
|
|
461
|
+ example='closed-deprecated',
|
|
462
|
+ validate=OneOf([status.slug for status in CONTENT_DEFAULT_STATUS]),
|
|
463
|
+ description='this slug is found in content_type available statuses',
|
|
464
|
+ default=open_status
|
|
465
|
+ )
|