Projet

Général

Profil

0001-cmis-include-descriptions-in-file-upload-schema-5466.patch

Valentin Deniaud, 08 juillet 2021 15:12

Télécharger (3,62 ko)

Voir les différences:

Subject: [PATCH] cmis: include descriptions in file upload schema (#54661)

 passerelle/apps/cmis/models.py | 27 +++++++++++++++++++++++----
 passerelle/views.py            |  8 +++++++-
 2 files changed, 30 insertions(+), 5 deletions(-)
passerelle/apps/cmis/models.py
45 45

  
46 46
UPLOAD_SCHEMA = {
47 47
    'type': 'object',
48
    'title': _('CMIS file upload'),
48 49
    'properties': {
49 50
        'file': {
51
            'title': _('File object'),
50 52
            'type': 'object',
51 53
            'properties': {
52 54
                'filename': {
53 55
                    'type': 'string',
56
                    'description': _('Filename (numbers, letters and special caracters "%s" are allowed)')
57
                    % SPECIAL_CHARS,
54 58
                    'pattern': FILE_NAME_PATTERN,
55 59
                },
56
                'content': {'type': 'string'},
57
                'content_type': {'type': 'string'},
60
                'content': {
61
                    'type': 'string',
62
                    'description': _('Content'),
63
                },
64
                'content_type': {
65
                    'type': 'string',
66
                    'description': _('Content type'),
67
                },
58 68
            },
59 69
            'required': ['content'],
60 70
        },
61 71
        'filename': {
62 72
            'type': 'string',
73
            'description': _('Filename (takes precendence over filename in "file" object)'),
63 74
            'pattern': FILE_NAME_PATTERN,
64 75
        },
65 76
        'path': {
66 77
            'type': 'string',
78
            'description': _('File path (with leading but not trailing slash)'),
67 79
            'pattern': FILE_PATH_PATTERN,
68 80
        },
69
        'object_type': {'type': 'string'},
70
        'properties': {'type': 'object', 'additionalProperties': {'type': 'string'}},
81
        'object_type': {
82
            'type': 'string',
83
            'description': _('CMIS object type'),
84
        },
85
        'properties': {
86
            'type': 'object',
87
            'title': _('CMIS properties'),
88
            'additionalProperties': {'type': 'string'},
89
        },
71 90
    },
72 91
    'required': ['file', 'path'],
73 92
    'unflatten': True,
passerelle/views.py
50 50
    View,
51 51
)
52 52
from django.views.generic.detail import SingleObjectMixin
53
from jsonschema import ValidationError, validate
53
from jsonschema import ValidationError, validate, validators
54 54

  
55 55
from passerelle.base.models import BaseResource, ResourceLog
56 56
from passerelle.compat import json_loads
......
403 403
                    data.update(data.pop('extra', {}))
404 404
                if pre_process is not None:
405 405
                    pre_process(self.endpoint.__self__, data)
406

  
407
                # disable validation on description and title in order to allow lazy translation strings
408
                validator = validators.validator_for(json_schema)
409
                validator.META_SCHEMA['properties'].pop('description', None)
410
                validator.META_SCHEMA['properties'].pop('title', None)
411

  
406 412
                try:
407 413
                    validate(data, json_schema)
408 414
                except ValidationError as e:
409
-