udata 7.0.7.dev28351__py2.py3-none-any.whl → 7.0.7.dev28426__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of udata might be problematic. Click here for more details.
- udata/core/badges/tests/test_commands.py +2 -1
- udata/core/dataset/api.py +3 -2
- udata/core/dataset/api_fields.py +2 -5
- udata/core/dataset/apiv2.py +2 -3
- udata/core/dataset/commands.py +5 -5
- udata/core/dataset/constants.py +82 -0
- udata/core/dataset/forms.py +2 -0
- udata/core/dataset/models.py +2 -87
- udata/core/dataset/rdf.py +2 -1
- udata/core/dataset/search.py +2 -3
- udata/core/dataset/tasks.py +2 -1
- udata/core/discussions/constants.py +1 -0
- udata/core/discussions/forms.py +2 -1
- udata/core/discussions/models.py +0 -4
- udata/core/organization/api.py +2 -1
- udata/core/organization/api_fields.py +1 -4
- udata/core/organization/constants.py +29 -0
- udata/core/organization/forms.py +2 -4
- udata/core/organization/models.py +2 -34
- udata/core/organization/tasks.py +2 -1
- udata/core/post/constants.py +9 -0
- udata/core/post/forms.py +2 -1
- udata/core/post/models.py +1 -11
- udata/core/reuse/api.py +2 -1
- udata/core/reuse/api_fields.py +1 -1
- udata/core/reuse/constants.py +37 -0
- udata/core/reuse/factories.py +2 -1
- udata/core/reuse/forms.py +3 -2
- udata/core/reuse/models.py +2 -38
- udata/core/spam/api.py +1 -1
- udata/core/spam/constants.py +5 -0
- udata/core/spam/fields.py +1 -1
- udata/core/spam/models.py +1 -5
- udata/core/spam/tests/test_spam.py +2 -2
- udata/core/spatial/constants.py +9 -0
- udata/core/spatial/models.py +3 -14
- udata/core/topic/factories.py +1 -0
- udata/core/topic/parsers.py +24 -1
- udata/core/user/api_fields.py +1 -3
- udata/core/user/constants.py +2 -0
- udata/core/user/forms.py +1 -1
- udata/core/user/models.py +1 -1
- udata/tests/api/test_datasets_api.py +2 -3
- udata/tests/api/test_reuses_api.py +2 -1
- udata/tests/api/test_topics_api.py +40 -3
- udata/tests/apiv2/test_topics.py +42 -4
- udata/tests/dataset/test_dataset_model.py +3 -4
- udata/tests/site/test_site_metrics.py +2 -1
- {udata-7.0.7.dev28351.dist-info → udata-7.0.7.dev28426.dist-info}/METADATA +3 -2
- {udata-7.0.7.dev28351.dist-info → udata-7.0.7.dev28426.dist-info}/RECORD +54 -46
- {udata-7.0.7.dev28351.dist-info → udata-7.0.7.dev28426.dist-info}/LICENSE +0 -0
- {udata-7.0.7.dev28351.dist-info → udata-7.0.7.dev28426.dist-info}/WHEEL +0 -0
- {udata-7.0.7.dev28351.dist-info → udata-7.0.7.dev28426.dist-info}/entry_points.txt +0 -0
- {udata-7.0.7.dev28351.dist-info → udata-7.0.7.dev28426.dist-info}/top_level.txt +0 -0
|
@@ -2,7 +2,8 @@ import pytest
|
|
|
2
2
|
|
|
3
3
|
from tempfile import NamedTemporaryFile
|
|
4
4
|
|
|
5
|
-
from udata.models import Badge
|
|
5
|
+
from udata.models import Badge
|
|
6
|
+
from udata.core.organization.constants import CERTIFIED, PUBLIC_SERVICE
|
|
6
7
|
from udata.core.organization.factories import OrganizationFactory
|
|
7
8
|
|
|
8
9
|
|
udata/core/dataset/api.py
CHANGED
|
@@ -57,9 +57,10 @@ from .api_fields import (
|
|
|
57
57
|
from udata.linkchecker.checker import check_resource
|
|
58
58
|
from udata.core.topic.models import Topic
|
|
59
59
|
from .models import (
|
|
60
|
-
Dataset, Resource, Checksum, License,
|
|
61
|
-
CommunityResource,
|
|
60
|
+
Dataset, Resource, Checksum, License,
|
|
61
|
+
CommunityResource, ResourceSchema, get_resource
|
|
62
62
|
)
|
|
63
|
+
from .constants import UPDATE_FREQUENCIES, RESOURCE_TYPES
|
|
63
64
|
from .permissions import DatasetEditPermission, ResourceEditPermission
|
|
64
65
|
from .forms import (
|
|
65
66
|
ResourceForm, DatasetForm, CommunityResourceForm, ResourcesListForm
|
udata/core/dataset/api_fields.py
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
from udata.api import api, fields, base_reference
|
|
2
2
|
from udata.core.badges.api import badge_fields
|
|
3
3
|
from udata.core.organization.api_fields import org_ref_fields
|
|
4
|
-
from udata.core.organization.
|
|
4
|
+
from udata.core.organization.constants import BIGGEST_LOGO_SIZE
|
|
5
5
|
from udata.core.spatial.api_fields import spatial_coverage_fields
|
|
6
6
|
from udata.core.user.api_fields import user_ref_fields
|
|
7
7
|
from udata.core.contact_point.api_fields import contact_point_fields
|
|
8
8
|
|
|
9
|
-
from .
|
|
9
|
+
from .constants import (
|
|
10
10
|
UPDATE_FREQUENCIES, RESOURCE_FILETYPES, DEFAULT_FREQUENCY,
|
|
11
11
|
CHECKSUM_TYPES, DEFAULT_CHECKSUM_TYPE, DEFAULT_LICENSE, RESOURCE_TYPES
|
|
12
12
|
)
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
BIGGEST_LOGO_SIZE = LOGO_SIZES[0]
|
|
16
|
-
|
|
17
|
-
|
|
18
15
|
checksum_fields = api.model('Checksum', {
|
|
19
16
|
'type': fields.String(
|
|
20
17
|
description='The hashing algorithm used to compute the checksum',
|
udata/core/dataset/apiv2.py
CHANGED
|
@@ -25,9 +25,8 @@ from .api_fields import (
|
|
|
25
25
|
)
|
|
26
26
|
from udata.core.spatial.api_fields import geojson
|
|
27
27
|
from udata.core.contact_point.api_fields import contact_point_fields
|
|
28
|
-
from .models import
|
|
29
|
-
|
|
30
|
-
)
|
|
28
|
+
from .models import Dataset, CommunityResource
|
|
29
|
+
from .constants import UPDATE_FREQUENCIES, DEFAULT_FREQUENCY, DEFAULT_LICENSE
|
|
31
30
|
from .api import ResourceMixin
|
|
32
31
|
from .permissions import DatasetEditPermission, ResourceEditPermission
|
|
33
32
|
from .search import DatasetSearch
|
udata/core/dataset/commands.py
CHANGED
|
@@ -6,12 +6,16 @@ import requests
|
|
|
6
6
|
from bson import ObjectId
|
|
7
7
|
|
|
8
8
|
from udata.commands import cli, success, exit_with_error
|
|
9
|
-
from udata.models import License,
|
|
9
|
+
from udata.models import License, Dataset
|
|
10
|
+
from udata.core.dataset.constants import DEFAULT_LICENSE
|
|
10
11
|
from .tasks import send_frequency_reminder
|
|
11
12
|
from . import actions
|
|
12
13
|
|
|
13
14
|
log = logging.getLogger(__name__)
|
|
14
15
|
|
|
16
|
+
# Use CKAN license group from opendefinition as default license list
|
|
17
|
+
DEFAULT_LICENSE_FILE = 'http://licenses.opendefinition.org/licenses/groups/ckan.json' # noqa
|
|
18
|
+
|
|
15
19
|
FLAGS_MAP = {
|
|
16
20
|
'domain_content': 'domain_content',
|
|
17
21
|
'domain_data': 'domain_data',
|
|
@@ -21,10 +25,6 @@ FLAGS_MAP = {
|
|
|
21
25
|
'is_osi_compliant': 'osi_compliant',
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
# Use CKAN license group from opendefinition as default license list
|
|
25
|
-
DEFAULT_LICENSE_FILE = 'http://licenses.opendefinition.org/licenses/groups/ckan.json' # noqa
|
|
26
|
-
|
|
27
|
-
|
|
28
28
|
@cli.command()
|
|
29
29
|
@click.argument('source', default=DEFAULT_LICENSE_FILE)
|
|
30
30
|
def licenses(source=DEFAULT_LICENSE_FILE):
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
from collections import OrderedDict
|
|
2
|
+
from udata.i18n import lazy_gettext as _
|
|
3
|
+
|
|
4
|
+
#: Udata frequencies with their labels
|
|
5
|
+
#:
|
|
6
|
+
#: See: http://dublincore.org/groups/collections/frequency/
|
|
7
|
+
UPDATE_FREQUENCIES = OrderedDict([ # Dublin core equivalent
|
|
8
|
+
('unknown', _('Unknown')), # N/A
|
|
9
|
+
('punctual', _('Punctual')), # N/A
|
|
10
|
+
('continuous', _('Real time')), # freq:continuous
|
|
11
|
+
('hourly', _('Hourly')), # N/A
|
|
12
|
+
('fourTimesADay', _('Four times a day')), # N/A
|
|
13
|
+
('threeTimesADay', _('Three times a day')), # N/A
|
|
14
|
+
('semidaily', _('Semidaily')), # N/A
|
|
15
|
+
('daily', _('Daily')), # freq:daily
|
|
16
|
+
('fourTimesAWeek', _('Four times a week')), # N/A
|
|
17
|
+
('threeTimesAWeek', _('Three times a week')), # freq:threeTimesAWeek
|
|
18
|
+
('semiweekly', _('Semiweekly')), # freq:semiweekly
|
|
19
|
+
('weekly', _('Weekly')), # freq:weekly
|
|
20
|
+
('biweekly', _('Biweekly')), # freq:bimonthly
|
|
21
|
+
('threeTimesAMonth', _('Three times a month')), # freq:threeTimesAMonth
|
|
22
|
+
('semimonthly', _('Semimonthly')), # freq:semimonthly
|
|
23
|
+
('monthly', _('Monthly')), # freq:monthly
|
|
24
|
+
('bimonthly', _('Bimonthly')), # freq:bimonthly
|
|
25
|
+
('quarterly', _('Quarterly')), # freq:quarterly
|
|
26
|
+
('threeTimesAYear', _('Three times a year')), # freq:threeTimesAYear
|
|
27
|
+
('semiannual', _('Biannual')), # freq:semiannual
|
|
28
|
+
('annual', _('Annual')), # freq:annual
|
|
29
|
+
('biennial', _('Biennial')), # freq:biennial
|
|
30
|
+
('triennial', _('Triennial')), # freq:triennial
|
|
31
|
+
('quinquennial', _('Quinquennial')), # N/A
|
|
32
|
+
('irregular', _('Irregular')), # freq:irregular
|
|
33
|
+
])
|
|
34
|
+
|
|
35
|
+
#: Map legacy frequencies to currents
|
|
36
|
+
LEGACY_FREQUENCIES = {
|
|
37
|
+
'fortnighly': 'biweekly',
|
|
38
|
+
'biannual': 'semiannual',
|
|
39
|
+
'realtime': 'continuous',
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
DEFAULT_FREQUENCY = 'unknown'
|
|
43
|
+
|
|
44
|
+
DEFAULT_LICENSE = {
|
|
45
|
+
'id': 'notspecified',
|
|
46
|
+
'title': "License Not Specified",
|
|
47
|
+
'flags': ["generic"],
|
|
48
|
+
'maintainer': None,
|
|
49
|
+
'url': None,
|
|
50
|
+
'active': True,
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
RESOURCE_TYPES = OrderedDict([
|
|
54
|
+
('main', _('Main file')),
|
|
55
|
+
('documentation', _('Documentation')),
|
|
56
|
+
('update', _('Update')),
|
|
57
|
+
('api', _('API')),
|
|
58
|
+
('code', _('Code repository')),
|
|
59
|
+
('other', _('Other')),
|
|
60
|
+
])
|
|
61
|
+
|
|
62
|
+
RESOURCE_FILETYPE_FILE = 'file'
|
|
63
|
+
RESOURCE_FILETYPES = OrderedDict([
|
|
64
|
+
(RESOURCE_FILETYPE_FILE, _('Uploaded file')),
|
|
65
|
+
('remote', _('Remote file')),
|
|
66
|
+
])
|
|
67
|
+
|
|
68
|
+
CHECKSUM_TYPES = ('sha1', 'sha2', 'sha256', 'md5', 'crc')
|
|
69
|
+
DEFAULT_CHECKSUM_TYPE = 'sha1'
|
|
70
|
+
|
|
71
|
+
PIVOTAL_DATA = 'pivotal-data'
|
|
72
|
+
CLOSED_FORMATS = ('pdf', 'doc', 'docx', 'word', 'xls', 'excel', 'xlsx')
|
|
73
|
+
|
|
74
|
+
# Maximum acceptable Damerau-Levenshtein distance
|
|
75
|
+
# used to guess license
|
|
76
|
+
# (ie. number of allowed character changes)
|
|
77
|
+
MAX_DISTANCE = 2
|
|
78
|
+
|
|
79
|
+
SCHEMA_CACHE_DURATION = 60 * 5 # In seconds
|
|
80
|
+
|
|
81
|
+
TITLE_SIZE_LIMIT = 350
|
|
82
|
+
DESCRIPTION_SIZE_LIMIT = 100000
|
udata/core/dataset/forms.py
CHANGED
|
@@ -8,6 +8,8 @@ from udata.core.spatial.forms import SpatialCoverageField
|
|
|
8
8
|
|
|
9
9
|
from .models import (
|
|
10
10
|
Dataset, Resource, Schema, License, Checksum, CommunityResource,
|
|
11
|
+
)
|
|
12
|
+
from .constants import (
|
|
11
13
|
UPDATE_FREQUENCIES, DEFAULT_FREQUENCY, RESOURCE_FILETYPES, CHECKSUM_TYPES,
|
|
12
14
|
LEGACY_FREQUENCIES, RESOURCE_TYPES, TITLE_SIZE_LIMIT, DESCRIPTION_SIZE_LIMIT,
|
|
13
15
|
)
|
udata/core/dataset/models.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
|
|
3
3
|
from datetime import datetime, timedelta
|
|
4
|
-
from collections import OrderedDict
|
|
5
4
|
from urllib.parse import urlparse
|
|
6
5
|
|
|
7
6
|
from blinker import signal
|
|
@@ -24,101 +23,17 @@ from udata.i18n import lazy_gettext as _
|
|
|
24
23
|
from udata.utils import get_by, hash_url, to_naive_datetime
|
|
25
24
|
from udata.uris import ValidationError, endpoint_for
|
|
26
25
|
from udata.uris import validate as validate_url
|
|
26
|
+
from .constants import CHECKSUM_TYPES, CLOSED_FORMATS, DEFAULT_LICENSE, LEGACY_FREQUENCIES, MAX_DISTANCE, PIVOTAL_DATA, RESOURCE_FILETYPES, RESOURCE_TYPES, SCHEMA_CACHE_DURATION, UPDATE_FREQUENCIES
|
|
27
27
|
|
|
28
28
|
from .preview import get_preview_url
|
|
29
29
|
from .exceptions import (
|
|
30
30
|
SchemasCatalogNotFoundException, SchemasCacheUnavailableException
|
|
31
31
|
)
|
|
32
32
|
|
|
33
|
-
__all__ = (
|
|
34
|
-
'License', 'Resource', 'Schema', 'Dataset', 'Checksum', 'CommunityResource',
|
|
35
|
-
'UPDATE_FREQUENCIES', 'LEGACY_FREQUENCIES', 'RESOURCE_FILETYPES',
|
|
36
|
-
'PIVOTAL_DATA', 'DEFAULT_LICENSE', 'RESOURCE_TYPES',
|
|
37
|
-
'ResourceSchema'
|
|
38
|
-
)
|
|
33
|
+
__all__ = ('License', 'Resource', 'Schema', 'Dataset', 'Checksum', 'CommunityResource', 'ResourceSchema')
|
|
39
34
|
|
|
40
35
|
log = logging.getLogger(__name__)
|
|
41
36
|
|
|
42
|
-
#: Udata frequencies with their labels
|
|
43
|
-
#:
|
|
44
|
-
#: See: http://dublincore.org/groups/collections/frequency/
|
|
45
|
-
UPDATE_FREQUENCIES = OrderedDict([ # Dublin core equivalent
|
|
46
|
-
('unknown', _('Unknown')), # N/A
|
|
47
|
-
('punctual', _('Punctual')), # N/A
|
|
48
|
-
('continuous', _('Real time')), # freq:continuous
|
|
49
|
-
('hourly', _('Hourly')), # N/A
|
|
50
|
-
('fourTimesADay', _('Four times a day')), # N/A
|
|
51
|
-
('threeTimesADay', _('Three times a day')), # N/A
|
|
52
|
-
('semidaily', _('Semidaily')), # N/A
|
|
53
|
-
('daily', _('Daily')), # freq:daily
|
|
54
|
-
('fourTimesAWeek', _('Four times a week')), # N/A
|
|
55
|
-
('threeTimesAWeek', _('Three times a week')), # freq:threeTimesAWeek
|
|
56
|
-
('semiweekly', _('Semiweekly')), # freq:semiweekly
|
|
57
|
-
('weekly', _('Weekly')), # freq:weekly
|
|
58
|
-
('biweekly', _('Biweekly')), # freq:bimonthly
|
|
59
|
-
('threeTimesAMonth', _('Three times a month')), # freq:threeTimesAMonth
|
|
60
|
-
('semimonthly', _('Semimonthly')), # freq:semimonthly
|
|
61
|
-
('monthly', _('Monthly')), # freq:monthly
|
|
62
|
-
('bimonthly', _('Bimonthly')), # freq:bimonthly
|
|
63
|
-
('quarterly', _('Quarterly')), # freq:quarterly
|
|
64
|
-
('threeTimesAYear', _('Three times a year')), # freq:threeTimesAYear
|
|
65
|
-
('semiannual', _('Biannual')), # freq:semiannual
|
|
66
|
-
('annual', _('Annual')), # freq:annual
|
|
67
|
-
('biennial', _('Biennial')), # freq:biennial
|
|
68
|
-
('triennial', _('Triennial')), # freq:triennial
|
|
69
|
-
('quinquennial', _('Quinquennial')), # N/A
|
|
70
|
-
('irregular', _('Irregular')), # freq:irregular
|
|
71
|
-
])
|
|
72
|
-
|
|
73
|
-
#: Map legacy frequencies to currents
|
|
74
|
-
LEGACY_FREQUENCIES = {
|
|
75
|
-
'fortnighly': 'biweekly',
|
|
76
|
-
'biannual': 'semiannual',
|
|
77
|
-
'realtime': 'continuous',
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
DEFAULT_FREQUENCY = 'unknown'
|
|
81
|
-
|
|
82
|
-
DEFAULT_LICENSE = {
|
|
83
|
-
'id': 'notspecified',
|
|
84
|
-
'title': "License Not Specified",
|
|
85
|
-
'flags': ["generic"],
|
|
86
|
-
'maintainer': None,
|
|
87
|
-
'url': None,
|
|
88
|
-
'active': True,
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
RESOURCE_TYPES = OrderedDict([
|
|
92
|
-
('main', _('Main file')),
|
|
93
|
-
('documentation', _('Documentation')),
|
|
94
|
-
('update', _('Update')),
|
|
95
|
-
('api', _('API')),
|
|
96
|
-
('code', _('Code repository')),
|
|
97
|
-
('other', _('Other')),
|
|
98
|
-
])
|
|
99
|
-
|
|
100
|
-
RESOURCE_FILETYPE_FILE = 'file'
|
|
101
|
-
RESOURCE_FILETYPES = OrderedDict([
|
|
102
|
-
(RESOURCE_FILETYPE_FILE, _('Uploaded file')),
|
|
103
|
-
('remote', _('Remote file')),
|
|
104
|
-
])
|
|
105
|
-
|
|
106
|
-
CHECKSUM_TYPES = ('sha1', 'sha2', 'sha256', 'md5', 'crc')
|
|
107
|
-
DEFAULT_CHECKSUM_TYPE = 'sha1'
|
|
108
|
-
|
|
109
|
-
PIVOTAL_DATA = 'pivotal-data'
|
|
110
|
-
CLOSED_FORMATS = ('pdf', 'doc', 'docx', 'word', 'xls', 'excel', 'xlsx')
|
|
111
|
-
|
|
112
|
-
# Maximum acceptable Damerau-Levenshtein distance
|
|
113
|
-
# used to guess license
|
|
114
|
-
# (ie. number of allowed character changes)
|
|
115
|
-
MAX_DISTANCE = 2
|
|
116
|
-
|
|
117
|
-
SCHEMA_CACHE_DURATION = 60 * 5 # In seconds
|
|
118
|
-
|
|
119
|
-
TITLE_SIZE_LIMIT = 350
|
|
120
|
-
DESCRIPTION_SIZE_LIMIT = 100000
|
|
121
|
-
|
|
122
37
|
|
|
123
38
|
def get_json_ld_extra(key, value):
|
|
124
39
|
'''Serialize an extras key, value pair into JSON-LD'''
|
udata/core/dataset/rdf.py
CHANGED
|
@@ -28,7 +28,8 @@ from udata.rdf import (
|
|
|
28
28
|
from udata.utils import get_by, safe_unicode
|
|
29
29
|
from udata.uris import endpoint_for
|
|
30
30
|
|
|
31
|
-
from .models import Dataset, Resource, Checksum, License
|
|
31
|
+
from .models import Dataset, Resource, Checksum, License
|
|
32
|
+
from .constants import UPDATE_FREQUENCIES
|
|
32
33
|
|
|
33
34
|
log = logging.getLogger(__name__)
|
|
34
35
|
|
udata/core/dataset/search.py
CHANGED
|
@@ -7,9 +7,8 @@ from udata.search import (
|
|
|
7
7
|
ModelTermsFilter, BoolFilter, Filter,
|
|
8
8
|
TemporalCoverageFilter
|
|
9
9
|
)
|
|
10
|
-
from udata.core.spatial.models import
|
|
11
|
-
|
|
12
|
-
)
|
|
10
|
+
from udata.core.spatial.models import admin_levels
|
|
11
|
+
from udata.core.spatial.constants import ADMIN_LEVEL_MAX
|
|
13
12
|
from udata.core.dataset.api import DatasetApiParser, DEFAULT_SORTING
|
|
14
13
|
from udata.utils import to_iso_datetime
|
|
15
14
|
|
udata/core/dataset/tasks.py
CHANGED
|
@@ -17,7 +17,8 @@ from udata.models import (Follow, Discussion, Activity, Topic,
|
|
|
17
17
|
Organization, Transfer, db)
|
|
18
18
|
from udata.tasks import job
|
|
19
19
|
|
|
20
|
-
from .models import Dataset, Resource, CommunityResource,
|
|
20
|
+
from .models import Dataset, Resource, CommunityResource, Checksum
|
|
21
|
+
from .constants import UPDATE_FREQUENCIES
|
|
21
22
|
|
|
22
23
|
log = get_task_logger(__name__)
|
|
23
24
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
COMMENT_SIZE_LIMIT = 50000
|
udata/core/discussions/forms.py
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from udata.forms import ModelForm, Form, fields, validators
|
|
2
2
|
from udata.i18n import lazy_gettext as _
|
|
3
3
|
|
|
4
|
-
from .models import Discussion
|
|
4
|
+
from .models import Discussion
|
|
5
|
+
from .constants import COMMENT_SIZE_LIMIT
|
|
5
6
|
|
|
6
7
|
__all__ = ('DiscussionCreateForm', 'DiscussionCommentForm')
|
|
7
8
|
|
udata/core/discussions/models.py
CHANGED
|
@@ -5,13 +5,9 @@ from udata.models import db
|
|
|
5
5
|
from udata.core.spam.models import SpamMixin, spam_protected
|
|
6
6
|
from .signals import (on_new_discussion, on_discussion_closed, on_new_discussion_comment)
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
log = logging.getLogger(__name__)
|
|
10
9
|
|
|
11
10
|
|
|
12
|
-
COMMENT_SIZE_LIMIT = 50000
|
|
13
|
-
|
|
14
|
-
|
|
15
11
|
class Message(SpamMixin, db.EmbeddedDocument):
|
|
16
12
|
content = db.StringField(required=True)
|
|
17
13
|
posted_on = db.DateTimeField(default=datetime.utcnow, required=True)
|
udata/core/organization/api.py
CHANGED
|
@@ -16,7 +16,8 @@ from udata.rdf import (
|
|
|
16
16
|
from .forms import (
|
|
17
17
|
OrganizationForm, MembershipRequestForm, MembershipRefuseForm, MemberForm
|
|
18
18
|
)
|
|
19
|
-
from .models import Organization, MembershipRequest, Member
|
|
19
|
+
from .models import Organization, MembershipRequest, Member
|
|
20
|
+
from .constants import ORG_ROLES
|
|
20
21
|
from .permissions import (
|
|
21
22
|
EditOrganizationPermission, OrganizationPrivatePermission
|
|
22
23
|
)
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
from udata.api import api, fields, base_reference
|
|
2
2
|
from udata.core.badges.api import badge_fields
|
|
3
3
|
|
|
4
|
-
from .
|
|
5
|
-
|
|
6
|
-
BIGGEST_LOGO_SIZE = LOGO_SIZES[0]
|
|
7
|
-
|
|
4
|
+
from .constants import ORG_ROLES, DEFAULT_ROLE, MEMBERSHIP_STATUS, BIGGEST_LOGO_SIZE
|
|
8
5
|
|
|
9
6
|
org_ref_fields = api.inherit('OrganizationReference', base_reference, {
|
|
10
7
|
'name': fields.String(description='The organization name', readonly=True),
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from udata.i18n import lazy_gettext as _
|
|
2
|
+
|
|
3
|
+
ORG_ROLES = {
|
|
4
|
+
'admin': _('Administrator'),
|
|
5
|
+
'editor': _('Editor'),
|
|
6
|
+
}
|
|
7
|
+
DEFAULT_ROLE = 'editor'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
MEMBERSHIP_STATUS = {
|
|
11
|
+
'pending': _('Pending'),
|
|
12
|
+
'accepted': _('Accepted'),
|
|
13
|
+
'refused': _('Refused'),
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
LOGO_MAX_SIZE = 500
|
|
17
|
+
LOGO_SIZES = [100, 60, 25]
|
|
18
|
+
BIGGEST_LOGO_SIZE = LOGO_SIZES[0]
|
|
19
|
+
|
|
20
|
+
PUBLIC_SERVICE = 'public-service'
|
|
21
|
+
CERTIFIED = 'certified'
|
|
22
|
+
ASSOCIATION = 'Association'
|
|
23
|
+
COMPANY = 'Company'
|
|
24
|
+
LOCAL_AUTHORITY = 'Local authority'
|
|
25
|
+
|
|
26
|
+
TITLE_SIZE_LIMIT = 350
|
|
27
|
+
DESCRIPTION_SIZE_LIMIT = 100000
|
|
28
|
+
|
|
29
|
+
ORG_BID_SIZE_LIMIT = 14
|
udata/core/organization/forms.py
CHANGED
|
@@ -4,10 +4,8 @@ from udata.auth import current_user
|
|
|
4
4
|
from udata.forms import Form, ModelForm, fields, validators
|
|
5
5
|
from udata.i18n import lazy_gettext as _
|
|
6
6
|
|
|
7
|
-
from .models import
|
|
8
|
-
|
|
9
|
-
TITLE_SIZE_LIMIT, DESCRIPTION_SIZE_LIMIT
|
|
10
|
-
)
|
|
7
|
+
from .models import Organization, MembershipRequest, Member
|
|
8
|
+
from .constants import DESCRIPTION_SIZE_LIMIT, LOGO_SIZES, ORG_ROLES, TITLE_SIZE_LIMIT
|
|
11
9
|
|
|
12
10
|
__all__ = (
|
|
13
11
|
'OrganizationForm',
|
|
@@ -10,42 +10,10 @@ from udata.frontend.markdown import mdstrip
|
|
|
10
10
|
from udata.models import db, BadgeMixin, WithMetrics
|
|
11
11
|
from udata.i18n import lazy_gettext as _
|
|
12
12
|
from udata.uris import endpoint_for
|
|
13
|
+
from .constants import ASSOCIATION, CERTIFIED, COMPANY, LOCAL_AUTHORITY, LOGO_SIZES, ORG_BID_SIZE_LIMIT, ORG_ROLES, DEFAULT_ROLE, MEMBERSHIP_STATUS, LOGO_MAX_SIZE, PUBLIC_SERVICE
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
__all__ = (
|
|
16
|
-
'Organization', 'Team', 'Member', 'MembershipRequest',
|
|
17
|
-
'ORG_ROLES', 'MEMBERSHIP_STATUS', 'PUBLIC_SERVICE', 'CERTIFIED',
|
|
18
|
-
'ASSOCIATION', 'COMPANY', 'LOCAL_AUTHORITY'
|
|
19
|
-
)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
ORG_ROLES = {
|
|
23
|
-
'admin': _('Administrator'),
|
|
24
|
-
'editor': _('Editor'),
|
|
25
|
-
}
|
|
26
|
-
DEFAULT_ROLE = 'editor'
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
MEMBERSHIP_STATUS = {
|
|
30
|
-
'pending': _('Pending'),
|
|
31
|
-
'accepted': _('Accepted'),
|
|
32
|
-
'refused': _('Refused'),
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
LOGO_MAX_SIZE = 500
|
|
36
|
-
LOGO_SIZES = [100, 60, 25]
|
|
37
|
-
|
|
38
|
-
PUBLIC_SERVICE = 'public-service'
|
|
39
|
-
CERTIFIED = 'certified'
|
|
40
|
-
ASSOCIATION = 'Association'
|
|
41
|
-
COMPANY = 'Company'
|
|
42
|
-
LOCAL_AUTHORITY = 'Local authority'
|
|
43
|
-
|
|
44
|
-
TITLE_SIZE_LIMIT = 350
|
|
45
|
-
DESCRIPTION_SIZE_LIMIT = 100000
|
|
46
|
-
|
|
47
|
-
ORG_BID_SIZE_LIMIT = 14
|
|
48
|
-
|
|
16
|
+
__all__ = ('Organization', 'Team', 'Member', 'MembershipRequest')
|
|
49
17
|
|
|
50
18
|
class Team(db.EmbeddedDocument):
|
|
51
19
|
name = db.StringField(required=True)
|
udata/core/organization/tasks.py
CHANGED
|
@@ -7,7 +7,8 @@ from udata.tasks import job, task, get_logger
|
|
|
7
7
|
|
|
8
8
|
from udata.core.badges.tasks import notify_new_badge
|
|
9
9
|
|
|
10
|
-
from .models import Organization
|
|
10
|
+
from .models import Organization
|
|
11
|
+
from .constants import CERTIFIED, PUBLIC_SERVICE, COMPANY, ASSOCIATION, LOCAL_AUTHORITY
|
|
11
12
|
|
|
12
13
|
log = get_logger(__name__)
|
|
13
14
|
|
udata/core/post/forms.py
CHANGED
udata/core/post/models.py
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
from collections import OrderedDict
|
|
2
|
-
|
|
3
1
|
from flask import url_for
|
|
4
2
|
|
|
5
3
|
from udata.core.storages import images, default_image_basename
|
|
6
4
|
from udata.i18n import lazy_gettext as _
|
|
7
5
|
from udata.models import db
|
|
8
|
-
|
|
6
|
+
from .constants import BODY_TYPES, IMAGE_SIZES
|
|
9
7
|
|
|
10
8
|
__all__ = ('Post', )
|
|
11
9
|
|
|
12
10
|
|
|
13
|
-
IMAGE_SIZES = [400, 100, 50]
|
|
14
|
-
|
|
15
|
-
BODY_TYPES = OrderedDict([
|
|
16
|
-
('markdown', _('Markdown')),
|
|
17
|
-
('html', _('HTML')),
|
|
18
|
-
])
|
|
19
|
-
|
|
20
|
-
|
|
21
11
|
class PostQuerySet(db.BaseQuerySet):
|
|
22
12
|
def published(self):
|
|
23
13
|
return self(published__ne=None).order_by('-published')
|
udata/core/reuse/api.py
CHANGED
|
@@ -23,7 +23,8 @@ from .api_fields import (
|
|
|
23
23
|
reuse_topic_fields
|
|
24
24
|
)
|
|
25
25
|
from .forms import ReuseForm
|
|
26
|
-
from .models import Reuse
|
|
26
|
+
from .models import Reuse
|
|
27
|
+
from .constants import REUSE_TYPES, REUSE_TOPICS
|
|
27
28
|
from .permissions import ReuseEditPermission
|
|
28
29
|
|
|
29
30
|
|
udata/core/reuse/api_fields.py
CHANGED
|
@@ -5,7 +5,7 @@ from udata.core.dataset.api_fields import dataset_fields
|
|
|
5
5
|
from udata.core.organization.api_fields import org_ref_fields
|
|
6
6
|
from udata.core.user.api_fields import user_ref_fields
|
|
7
7
|
|
|
8
|
-
from .
|
|
8
|
+
from .constants import REUSE_TOPICS, REUSE_TYPES, IMAGE_SIZES
|
|
9
9
|
|
|
10
10
|
BIGGEST_IMAGE_SIZE = IMAGE_SIZES[0]
|
|
11
11
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from udata.i18n import lazy_gettext as _
|
|
2
|
+
|
|
3
|
+
REUSE_TYPES = {
|
|
4
|
+
'api': _('API'),
|
|
5
|
+
'application': _('Application'),
|
|
6
|
+
'idea': _('Idea'),
|
|
7
|
+
'news_article': _('News Article'),
|
|
8
|
+
'paper': _('Paper'),
|
|
9
|
+
'post': _('Post'),
|
|
10
|
+
'visualization': _('Visualization'),
|
|
11
|
+
'hardware': _('Connected device'),
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
REUSE_TOPICS = {
|
|
15
|
+
'health': _('Health'),
|
|
16
|
+
'transport_and_mobility': _('Transport and mobility'),
|
|
17
|
+
'housing_and_development': _('Housing and development'),
|
|
18
|
+
'food_and_agriculture': _('Food and agriculture'),
|
|
19
|
+
'culture_and_recreation': _('Culture and recreation'),
|
|
20
|
+
'economy_and_business': _('Economy and business'),
|
|
21
|
+
'environment_and_energy': _('Environment and energy'),
|
|
22
|
+
'work_and_training': _('Work and training'),
|
|
23
|
+
'politics_and_public_life': _('Politics and public life'),
|
|
24
|
+
'safety_and_security': _('Safety and security'),
|
|
25
|
+
'education_and_research': _('Education and research'),
|
|
26
|
+
'society_and_demography': _('Society and demography'),
|
|
27
|
+
'law_and_justice': _('Law and justice'),
|
|
28
|
+
'open_data_tools': _('Open data tools'),
|
|
29
|
+
'others': _('Others'),
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
IMAGE_SIZES = [500, 100, 50, 25]
|
|
34
|
+
IMAGE_MAX_SIZE = 800
|
|
35
|
+
|
|
36
|
+
TITLE_SIZE_LIMIT = 350
|
|
37
|
+
DESCRIPTION_SIZE_LIMIT = 100000
|
udata/core/reuse/factories.py
CHANGED
|
@@ -6,7 +6,8 @@ from udata.core.dataset.factories import DatasetFactory
|
|
|
6
6
|
from udata.factories import ModelFactory
|
|
7
7
|
from udata.utils import faker
|
|
8
8
|
|
|
9
|
-
from .models import Reuse
|
|
9
|
+
from .models import Reuse
|
|
10
|
+
from .constants import REUSE_TYPES, REUSE_TOPICS
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class ReuseFactory(ModelFactory):
|
udata/core/reuse/forms.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from udata.forms import ModelForm, fields, validators
|
|
2
2
|
from udata.i18n import lazy_gettext as _
|
|
3
|
-
from udata.models import Reuse
|
|
3
|
+
from udata.models import Reuse
|
|
4
|
+
from udata.core.reuse.constants import REUSE_TYPES, REUSE_TOPICS
|
|
4
5
|
|
|
5
|
-
from .
|
|
6
|
+
from .constants import IMAGE_SIZES, TITLE_SIZE_LIMIT, DESCRIPTION_SIZE_LIMIT
|
|
6
7
|
|
|
7
8
|
__all__ = ('ReuseForm', )
|
|
8
9
|
|
udata/core/reuse/models.py
CHANGED
|
@@ -8,45 +8,9 @@ from udata.i18n import lazy_gettext as _
|
|
|
8
8
|
from udata.models import db, BadgeMixin, WithMetrics
|
|
9
9
|
from udata.utils import hash_url
|
|
10
10
|
from udata.uris import endpoint_for
|
|
11
|
+
from .constants import IMAGE_MAX_SIZE, IMAGE_SIZES, REUSE_TOPICS, REUSE_TYPES
|
|
11
12
|
|
|
12
|
-
__all__ = ('Reuse',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
REUSE_TYPES = {
|
|
16
|
-
'api': _('API'),
|
|
17
|
-
'application': _('Application'),
|
|
18
|
-
'idea': _('Idea'),
|
|
19
|
-
'news_article': _('News Article'),
|
|
20
|
-
'paper': _('Paper'),
|
|
21
|
-
'post': _('Post'),
|
|
22
|
-
'visualization': _('Visualization'),
|
|
23
|
-
'hardware': _('Connected device'),
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
REUSE_TOPICS = {
|
|
27
|
-
'health': _('Health'),
|
|
28
|
-
'transport_and_mobility': _('Transport and mobility'),
|
|
29
|
-
'housing_and_development': _('Housing and development'),
|
|
30
|
-
'food_and_agriculture': _('Food and agriculture'),
|
|
31
|
-
'culture_and_recreation': _('Culture and recreation'),
|
|
32
|
-
'economy_and_business': _('Economy and business'),
|
|
33
|
-
'environment_and_energy': _('Environment and energy'),
|
|
34
|
-
'work_and_training': _('Work and training'),
|
|
35
|
-
'politics_and_public_life': _('Politics and public life'),
|
|
36
|
-
'safety_and_security': _('Safety and security'),
|
|
37
|
-
'education_and_research': _('Education and research'),
|
|
38
|
-
'society_and_demography': _('Society and demography'),
|
|
39
|
-
'law_and_justice': _('Law and justice'),
|
|
40
|
-
'open_data_tools': _('Open data tools'),
|
|
41
|
-
'others': _('Others'),
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
IMAGE_SIZES = [500, 100, 50, 25]
|
|
46
|
-
IMAGE_MAX_SIZE = 800
|
|
47
|
-
|
|
48
|
-
TITLE_SIZE_LIMIT = 350
|
|
49
|
-
DESCRIPTION_SIZE_LIMIT = 100000
|
|
13
|
+
__all__ = ('Reuse',)
|
|
50
14
|
|
|
51
15
|
|
|
52
16
|
class ReuseQuerySet(db.OwnedQuerySet):
|