udata 7.0.7.dev28410__py2.py3-none-any.whl → 7.0.7.dev28435__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.

Files changed (99) hide show
  1. udata/api/oauth2.py +1 -1
  2. udata/app.py +2 -1
  3. udata/commands/db.py +1 -1
  4. udata/core/activity/models.py +1 -1
  5. udata/core/badges/models.py +1 -1
  6. udata/core/badges/tests/test_commands.py +2 -1
  7. udata/core/badges/tests/test_model.py +1 -1
  8. udata/core/contact_point/models.py +1 -1
  9. udata/core/dataset/api.py +3 -2
  10. udata/core/dataset/api_fields.py +2 -5
  11. udata/core/dataset/apiv2.py +2 -3
  12. udata/core/dataset/commands.py +5 -5
  13. udata/core/dataset/constants.py +82 -0
  14. udata/core/dataset/forms.py +2 -0
  15. udata/core/dataset/models.py +2 -87
  16. udata/core/dataset/rdf.py +2 -1
  17. udata/core/dataset/search.py +2 -3
  18. udata/core/dataset/tasks.py +2 -1
  19. udata/core/discussions/constants.py +1 -0
  20. udata/core/discussions/forms.py +2 -1
  21. udata/core/discussions/models.py +1 -5
  22. udata/core/followers/models.py +1 -1
  23. udata/core/jobs/models.py +1 -1
  24. udata/core/metrics/models.py +1 -1
  25. udata/core/organization/api.py +2 -1
  26. udata/core/organization/api_fields.py +1 -4
  27. udata/core/organization/constants.py +29 -0
  28. udata/core/organization/forms.py +2 -4
  29. udata/core/organization/models.py +2 -34
  30. udata/core/organization/tasks.py +2 -1
  31. udata/core/post/constants.py +9 -0
  32. udata/core/post/forms.py +2 -1
  33. udata/core/post/models.py +2 -12
  34. udata/core/reuse/api.py +2 -1
  35. udata/core/reuse/api_fields.py +1 -1
  36. udata/core/reuse/constants.py +37 -0
  37. udata/core/reuse/factories.py +2 -1
  38. udata/core/reuse/forms.py +3 -2
  39. udata/core/reuse/models.py +2 -38
  40. udata/core/spam/api.py +1 -1
  41. udata/core/spam/constants.py +5 -0
  42. udata/core/spam/fields.py +1 -1
  43. udata/core/spam/models.py +2 -6
  44. udata/core/spam/tests/test_spam.py +3 -3
  45. udata/core/spatial/constants.py +9 -0
  46. udata/core/spatial/models.py +4 -15
  47. udata/core/spatial/tests/test_fields.py +1 -1
  48. udata/core/tags/models.py +1 -1
  49. udata/core/user/api_fields.py +1 -3
  50. udata/core/user/constants.py +2 -0
  51. udata/core/user/forms.py +1 -1
  52. udata/core/user/models.py +1 -1
  53. udata/factories.py +2 -2
  54. udata/features/transfer/models.py +1 -1
  55. udata/frontend/csv.py +1 -1
  56. udata/linkchecker/models.py +1 -1
  57. udata/models/__init__.py +1 -118
  58. udata/mongo/__init__.py +42 -0
  59. udata/mongo/engine.py +73 -0
  60. udata/routing.py +1 -1
  61. udata/search/__init__.py +1 -1
  62. udata/tests/api/test_datasets_api.py +2 -3
  63. udata/tests/api/test_reuses_api.py +2 -1
  64. udata/tests/dataset/test_dataset_model.py +3 -4
  65. udata/tests/dataset/test_dataset_rdf.py +1 -1
  66. udata/tests/forms/test_basic_fields.py +1 -1
  67. udata/tests/forms/test_daterange_field.py +1 -1
  68. udata/tests/forms/test_dict_field.py +1 -1
  69. udata/tests/forms/test_extras_fields.py +1 -1
  70. udata/tests/forms/test_form_field.py +1 -1
  71. udata/tests/forms/test_image_field.py +1 -1
  72. udata/tests/forms/test_model_field.py +1 -1
  73. udata/tests/forms/test_model_list_field.py +1 -1
  74. udata/tests/forms/test_nested_model_list_field.py +1 -1
  75. udata/tests/forms/test_reference_field.py +1 -1
  76. udata/tests/forms/test_uuid_field.py +1 -1
  77. udata/tests/frontend/test_csv.py +1 -1
  78. udata/tests/plugin.py +1 -1
  79. udata/tests/search/__init__.py +1 -1
  80. udata/tests/site/test_site_metrics.py +2 -1
  81. udata/tests/test_model.py +2 -1
  82. udata/tests/test_owned.py +1 -1
  83. udata/tests/test_routing.py +2 -2
  84. {udata-7.0.7.dev28410.dist-info → udata-7.0.7.dev28435.dist-info}/METADATA +3 -1
  85. {udata-7.0.7.dev28410.dist-info → udata-7.0.7.dev28435.dist-info}/RECORD +99 -89
  86. /udata/{models → mongo}/badges_field.py +0 -0
  87. /udata/{models → mongo}/datetime_fields.py +0 -0
  88. /udata/{models → mongo}/document.py +0 -0
  89. /udata/{models → mongo}/extras_fields.py +0 -0
  90. /udata/{models → mongo}/owned.py +0 -0
  91. /udata/{models → mongo}/queryset.py +0 -0
  92. /udata/{models → mongo}/slug_fields.py +0 -0
  93. /udata/{models → mongo}/taglist_field.py +0 -0
  94. /udata/{models → mongo}/url_field.py +0 -0
  95. /udata/{models → mongo}/uuid_fields.py +0 -0
  96. {udata-7.0.7.dev28410.dist-info → udata-7.0.7.dev28435.dist-info}/LICENSE +0 -0
  97. {udata-7.0.7.dev28410.dist-info → udata-7.0.7.dev28435.dist-info}/WHEEL +0 -0
  98. {udata-7.0.7.dev28410.dist-info → udata-7.0.7.dev28435.dist-info}/entry_points.txt +0 -0
  99. {udata-7.0.7.dev28410.dist-info → udata-7.0.7.dev28435.dist-info}/top_level.txt +0 -0
udata/api/oauth2.py CHANGED
@@ -35,7 +35,7 @@ from werkzeug.security import gen_salt
35
35
  from udata.app import csrf
36
36
  from udata.auth import current_user, login_required, login_user
37
37
  from udata.i18n import I18nBlueprint, lazy_gettext as _
38
- from udata.models import db
38
+ from udata.mongo import db
39
39
  from udata.core.user.models import User
40
40
  from udata.core.storages import images, default_image_basename
41
41
 
udata/app.py CHANGED
@@ -206,11 +206,12 @@ def standalone(app):
206
206
 
207
207
  def register_extensions(app):
208
208
  from udata import (
209
- models, routing, tasks, mail, i18n, auth, search, sitemap,
209
+ models, mongo, routing, tasks, mail, i18n, auth, search, sitemap,
210
210
  sentry, notifications
211
211
  )
212
212
  tasks.init_app(app)
213
213
  i18n.init_app(app)
214
+ mongo.init_app(app)
214
215
  models.init_app(app)
215
216
  routing.init_app(app)
216
217
  auth.init_app(app)
udata/commands/db.py CHANGED
@@ -9,7 +9,7 @@ from udata import migrations, models as core_models
9
9
  from udata.api import oauth2 as oauth2_models
10
10
  from udata.commands import cli, green, yellow, cyan, red, magenta, white, echo
11
11
  from udata.harvest import models as harvest_models
12
- from udata.models import db
12
+ from udata.mongo import db
13
13
 
14
14
 
15
15
  # Date format used to for display
@@ -3,7 +3,7 @@ from datetime import datetime
3
3
  from blinker import Signal
4
4
  from mongoengine.signals import post_save
5
5
 
6
- from udata.models import db
6
+ from udata.mongo import db
7
7
  from udata.auth import current_user
8
8
 
9
9
  from .signals import new_activity
@@ -6,7 +6,7 @@ from datetime import datetime
6
6
  from mongoengine.signals import post_save
7
7
 
8
8
  from udata.auth import current_user
9
- from udata.models import db
9
+ from udata.mongo import db
10
10
 
11
11
  from .signals import on_badge_added, on_badge_removed
12
12
 
@@ -2,7 +2,8 @@ import pytest
2
2
 
3
3
  from tempfile import NamedTemporaryFile
4
4
 
5
- from udata.models import Badge, CERTIFIED, PUBLIC_SERVICE
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
 
@@ -1,5 +1,5 @@
1
1
  from udata.auth import login_user
2
- from udata.models import db
2
+ from udata.mongo import db
3
3
  from udata.tests import TestCase, DBTestMixin
4
4
  from udata.core.user.factories import UserFactory
5
5
 
@@ -1,4 +1,4 @@
1
- from udata.models import db
1
+ from udata.mongo import db
2
2
 
3
3
 
4
4
  __all__ = ('ContactPoint', )
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, UPDATE_FREQUENCIES,
61
- CommunityResource, RESOURCE_TYPES, ResourceSchema, get_resource
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
@@ -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.models import LOGO_SIZES
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 .models import (
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',
@@ -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
- Dataset, UPDATE_FREQUENCIES, DEFAULT_FREQUENCY, DEFAULT_LICENSE, CommunityResource
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
@@ -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, DEFAULT_LICENSE, Dataset
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
@@ -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
  )
@@ -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, UPDATE_FREQUENCIES
31
+ from .models import Dataset, Resource, Checksum, License
32
+ from .constants import UPDATE_FREQUENCIES
32
33
 
33
34
  log = logging.getLogger(__name__)
34
35
 
@@ -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
- admin_levels, ADMIN_LEVEL_MAX
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
 
@@ -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, UPDATE_FREQUENCIES, Checksum
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
@@ -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, COMMENT_SIZE_LIMIT
4
+ from .models import Discussion
5
+ from .constants import COMMENT_SIZE_LIMIT
5
6
 
6
7
  __all__ = ('DiscussionCreateForm', 'DiscussionCommentForm')
7
8
 
@@ -1,17 +1,13 @@
1
1
  import logging
2
2
  from datetime import datetime
3
3
 
4
- from udata.models import db
4
+ from udata.mongo 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)
@@ -1,6 +1,6 @@
1
1
  from datetime import datetime
2
2
 
3
- from udata.models import db
3
+ from udata.mongo import db
4
4
  from .signals import on_follow, on_unfollow
5
5
 
6
6
 
udata/core/jobs/models.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from celerybeatmongo.models import PeriodicTask as BasePeriodicTask, PERIODS
2
2
 
3
3
  from udata.i18n import lazy_gettext as _
4
- from udata.models import db
4
+ from udata.mongo import db
5
5
 
6
6
 
7
7
  __all__ = ('PeriodicTask', 'PERIODS')
@@ -1,6 +1,6 @@
1
1
  from datetime import date, timedelta
2
2
 
3
- from udata.models import db
3
+ from udata.mongo import db
4
4
 
5
5
 
6
6
  __all__ = ('WithMetrics',)
@@ -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, ORG_ROLES
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 .models import ORG_ROLES, DEFAULT_ROLE, MEMBERSHIP_STATUS, LOGO_SIZES
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
@@ -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
- Organization, MembershipRequest, Member, LOGO_SIZES, ORG_ROLES,
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)
@@ -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, CERTIFIED, PUBLIC_SERVICE, COMPANY, ASSOCIATION, LOCAL_AUTHORITY
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
 
@@ -0,0 +1,9 @@
1
+ from udata.i18n import lazy_gettext as _
2
+ from collections import OrderedDict
3
+
4
+ IMAGE_SIZES = [400, 100, 50]
5
+
6
+ BODY_TYPES = OrderedDict([
7
+ ('markdown', _('Markdown')),
8
+ ('html', _('HTML')),
9
+ ])
udata/core/post/forms.py CHANGED
@@ -1,7 +1,8 @@
1
1
  from udata.forms import ModelForm, fields, validators, widgets
2
2
  from udata.i18n import lazy_gettext as _
3
3
 
4
- from .models import Post, IMAGE_SIZES
4
+ from .models import Post
5
+ from .constants import IMAGE_SIZES
5
6
 
6
7
 
7
8
  __all__ = ('PostForm', )
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
- from udata.models import db
8
-
5
+ from udata.mongo import db
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, REUSE_TYPES, REUSE_TOPICS
26
+ from .models import Reuse
27
+ from .constants import REUSE_TYPES, REUSE_TOPICS
27
28
  from .permissions import ReuseEditPermission
28
29
 
29
30
 
@@ -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 .models import REUSE_TOPICS, REUSE_TYPES, IMAGE_SIZES
8
+ from .constants import REUSE_TOPICS, REUSE_TYPES, IMAGE_SIZES
9
9
 
10
10
  BIGGEST_IMAGE_SIZE = IMAGE_SIZES[0]
11
11