udata 10.0.3.dev32541__py2.py3-none-any.whl → 10.0.3.dev32594__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/dataset/models.py +6 -0
- udata/core/discussions/models.py +8 -0
- udata/core/organization/models.py +6 -0
- udata/core/post/models.py +6 -0
- udata/core/reuse/models.py +6 -0
- udata/core/spatial/models.py +6 -0
- udata/core/user/models.py +6 -0
- udata/features/territories/models.py +6 -0
- udata/mail.py +17 -1
- udata/static/chunks/{11.ffe19f0319ffd1bc9737.js → 11.727465d72948bc466d43.js} +3 -3
- udata/static/chunks/{11.ffe19f0319ffd1bc9737.js.map → 11.727465d72948bc466d43.js.map} +1 -1
- udata/static/chunks/{13.645dd0b7c0b9210f1b56.js → 13.bef5fdb3e147e94fea99.js} +2 -2
- udata/static/chunks/{13.645dd0b7c0b9210f1b56.js.map → 13.bef5fdb3e147e94fea99.js.map} +1 -1
- udata/static/chunks/{17.8e19985c4d12a3b7b0c0.js → 17.b91d28f550dc44bc4979.js} +2 -2
- udata/static/chunks/{17.8e19985c4d12a3b7b0c0.js.map → 17.b91d28f550dc44bc4979.js.map} +1 -1
- udata/static/chunks/{19.825a43c330157e351fca.js → 19.4f7a5b71ef006ac268c1.js} +3 -3
- udata/static/chunks/{19.825a43c330157e351fca.js.map → 19.4f7a5b71ef006ac268c1.js.map} +1 -1
- udata/static/chunks/{5.860362216c0ce3ec565f.js → 5.448ccace1bf3389d9b38.js} +3 -3
- udata/static/chunks/{5.860362216c0ce3ec565f.js.map → 5.448ccace1bf3389d9b38.js.map} +1 -1
- udata/static/chunks/{6.6617c697f229f362d732.js → 6.037369868acc94a7533f.js} +3 -3
- udata/static/chunks/{6.6617c697f229f362d732.js.map → 6.037369868acc94a7533f.js.map} +1 -1
- udata/static/chunks/{8.05a0db37aa4ed53ea45e.js → 8.60610fd40b95ca119141.js} +2 -2
- udata/static/chunks/{8.05a0db37aa4ed53ea45e.js.map → 8.60610fd40b95ca119141.js.map} +1 -1
- udata/static/common.js +1 -1
- udata/static/common.js.map +1 -1
- udata/templates/mail/badge_added_association.html +3 -3
- udata/templates/mail/badge_added_association.txt +2 -2
- udata/templates/mail/badge_added_certified.html +3 -3
- udata/templates/mail/badge_added_certified.txt +1 -1
- udata/templates/mail/badge_added_company.html +3 -3
- udata/templates/mail/badge_added_company.txt +2 -2
- udata/templates/mail/badge_added_local_authority.html +3 -3
- udata/templates/mail/badge_added_local_authority.txt +2 -2
- udata/templates/mail/badge_added_public_service.html +3 -3
- udata/templates/mail/badge_added_public_service.txt +1 -1
- udata/templates/mail/discussion_closed.html +3 -3
- udata/templates/mail/discussion_closed.txt +1 -1
- udata/templates/mail/frequency_reminder.html +1 -1
- udata/templates/mail/frequency_reminder.txt +1 -1
- udata/templates/mail/membership_refused.html +1 -1
- udata/templates/mail/membership_request.html +3 -3
- udata/templates/mail/membership_request.txt +1 -1
- udata/templates/mail/new_discussion.html +3 -3
- udata/templates/mail/new_discussion.txt +1 -1
- udata/templates/mail/new_discussion_comment.html +3 -3
- udata/templates/mail/new_discussion_comment.txt +1 -1
- udata/templates/mail/new_member.html +2 -2
- udata/templates/mail/new_member.txt +1 -1
- udata/templates/mail/new_reuse.html +3 -3
- udata/templates/mail/new_reuse.txt +2 -2
- udata/templates/mail/user_mail_card.html +1 -1
- udata/tests/test_mail.py +61 -1
- {udata-10.0.3.dev32541.dist-info → udata-10.0.3.dev32594.dist-info}/METADATA +2 -2
- {udata-10.0.3.dev32541.dist-info → udata-10.0.3.dev32594.dist-info}/RECORD +58 -58
- {udata-10.0.3.dev32541.dist-info → udata-10.0.3.dev32594.dist-info}/LICENSE +0 -0
- {udata-10.0.3.dev32541.dist-info → udata-10.0.3.dev32594.dist-info}/WHEEL +0 -0
- {udata-10.0.3.dev32541.dist-info → udata-10.0.3.dev32594.dist-info}/entry_points.txt +0 -0
- {udata-10.0.3.dev32541.dist-info → udata-10.0.3.dev32594.dist-info}/top_level.txt +0 -0
udata/core/dataset/models.py
CHANGED
|
@@ -21,6 +21,7 @@ from udata.core import storages
|
|
|
21
21
|
from udata.core.owned import Owned, OwnedQuerySet
|
|
22
22
|
from udata.frontend.markdown import mdstrip
|
|
23
23
|
from udata.i18n import lazy_gettext as _
|
|
24
|
+
from udata.mail import get_mail_campaign_dict
|
|
24
25
|
from udata.models import Badge, BadgeMixin, BadgesList, SpatialCoverage, WithMetrics, db
|
|
25
26
|
from udata.mongo.errors import FieldValidationError
|
|
26
27
|
from udata.uris import ValidationError, endpoint_for
|
|
@@ -689,6 +690,11 @@ class Dataset(WithMetrics, DatasetBadgeMixin, Owned, db.Document):
|
|
|
689
690
|
def external_url(self):
|
|
690
691
|
return self.url_for(_external=True)
|
|
691
692
|
|
|
693
|
+
@property
|
|
694
|
+
def external_url_with_campaign(self):
|
|
695
|
+
extras = get_mail_campaign_dict()
|
|
696
|
+
return self.url_for(_external=True, **extras)
|
|
697
|
+
|
|
692
698
|
@property
|
|
693
699
|
def image_url(self):
|
|
694
700
|
if self.organization:
|
udata/core/discussions/models.py
CHANGED
|
@@ -4,6 +4,7 @@ from datetime import datetime
|
|
|
4
4
|
from flask_login import current_user
|
|
5
5
|
|
|
6
6
|
from udata.core.spam.models import SpamMixin, spam_protected
|
|
7
|
+
from udata.mail import get_mail_campaign_dict
|
|
7
8
|
from udata.mongo import db
|
|
8
9
|
|
|
9
10
|
from .signals import on_discussion_closed, on_new_discussion, on_new_discussion_comment
|
|
@@ -94,6 +95,13 @@ class Discussion(SpamMixin, db.Document):
|
|
|
94
95
|
def external_url(self):
|
|
95
96
|
return self.subject.url_for(_anchor="discussion-{id}".format(id=self.id), _external=True)
|
|
96
97
|
|
|
98
|
+
@property
|
|
99
|
+
def external_url_with_campaign(self):
|
|
100
|
+
extras = get_mail_campaign_dict()
|
|
101
|
+
return self.subject.url_for(
|
|
102
|
+
_anchor="discussion-{id}".format(id=self.id), _external=True, **extras
|
|
103
|
+
)
|
|
104
|
+
|
|
97
105
|
def spam_report_message(self, breadcrumb):
|
|
98
106
|
message = f"Spam potentiel sur la discussion « [{self.title}]({self.external_url}) »"
|
|
99
107
|
if self.user:
|
|
@@ -11,6 +11,7 @@ from udata.core.metrics.models import WithMetrics
|
|
|
11
11
|
from udata.core.storages import avatars, default_image_basename
|
|
12
12
|
from udata.frontend.markdown import mdstrip
|
|
13
13
|
from udata.i18n import lazy_gettext as _
|
|
14
|
+
from udata.mail import get_mail_campaign_dict
|
|
14
15
|
from udata.mongo import db
|
|
15
16
|
from udata.uris import endpoint_for
|
|
16
17
|
|
|
@@ -188,6 +189,11 @@ class Organization(WithMetrics, OrganizationBadgeMixin, db.Datetimed, db.Documen
|
|
|
188
189
|
def external_url(self):
|
|
189
190
|
return self.url_for(_external=True)
|
|
190
191
|
|
|
192
|
+
@property
|
|
193
|
+
def external_url_with_campaign(self):
|
|
194
|
+
extras = get_mail_campaign_dict()
|
|
195
|
+
return self.url_for(_external=True, **extras)
|
|
196
|
+
|
|
191
197
|
@property
|
|
192
198
|
def pending_requests(self):
|
|
193
199
|
return [r for r in self.requests if r.status == "pending"]
|
udata/core/post/models.py
CHANGED
|
@@ -2,6 +2,7 @@ from flask import url_for
|
|
|
2
2
|
|
|
3
3
|
from udata.core.storages import default_image_basename, images
|
|
4
4
|
from udata.i18n import lazy_gettext as _
|
|
5
|
+
from udata.mail import get_mail_campaign_dict
|
|
5
6
|
from udata.mongo import db
|
|
6
7
|
|
|
7
8
|
from .constants import BODY_TYPES, IMAGE_SIZES
|
|
@@ -61,6 +62,11 @@ class Post(db.Datetimed, db.Document):
|
|
|
61
62
|
def external_url(self):
|
|
62
63
|
return self.url_for(_external=True)
|
|
63
64
|
|
|
65
|
+
@property
|
|
66
|
+
def external_url_with_campaign(self):
|
|
67
|
+
extras = get_mail_campaign_dict()
|
|
68
|
+
return self.url_for(_external=True, **extras)
|
|
69
|
+
|
|
64
70
|
def count_discussions(self):
|
|
65
71
|
# There are no metrics on Post to store discussions count
|
|
66
72
|
pass
|
udata/core/reuse/models.py
CHANGED
|
@@ -9,6 +9,7 @@ from udata.core.reuse.api_fields import BIGGEST_IMAGE_SIZE
|
|
|
9
9
|
from udata.core.storages import default_image_basename, images
|
|
10
10
|
from udata.frontend.markdown import mdstrip
|
|
11
11
|
from udata.i18n import lazy_gettext as _
|
|
12
|
+
from udata.mail import get_mail_campaign_dict
|
|
12
13
|
from udata.models import Badge, BadgeMixin, BadgesList, WithMetrics, db
|
|
13
14
|
from udata.mongo.errors import FieldValidationError
|
|
14
15
|
from udata.uris import endpoint_for
|
|
@@ -218,6 +219,11 @@ class Reuse(db.Datetimed, WithMetrics, ReuseBadgeMixin, Owned, db.Document):
|
|
|
218
219
|
def external_url(self):
|
|
219
220
|
return self.url_for(_external=True)
|
|
220
221
|
|
|
222
|
+
@property
|
|
223
|
+
def external_url_with_campaign(self):
|
|
224
|
+
extras = get_mail_campaign_dict()
|
|
225
|
+
return self.url_for(_external=True, **extras)
|
|
226
|
+
|
|
221
227
|
@property
|
|
222
228
|
def type_label(self):
|
|
223
229
|
return REUSE_TYPES[self.type]
|
udata/core/spatial/models.py
CHANGED
|
@@ -5,6 +5,7 @@ from werkzeug.utils import cached_property
|
|
|
5
5
|
from udata.app import cache
|
|
6
6
|
from udata.core.metrics.models import WithMetrics
|
|
7
7
|
from udata.i18n import _, get_locale, language
|
|
8
|
+
from udata.mail import get_mail_campaign_dict
|
|
8
9
|
from udata.mongo import db
|
|
9
10
|
from udata.uris import endpoint_for
|
|
10
11
|
|
|
@@ -97,6 +98,11 @@ class GeoZone(WithMetrics, db.Document):
|
|
|
97
98
|
def external_url(self):
|
|
98
99
|
return endpoint_for("territories.territory", territory=self, _external=True)
|
|
99
100
|
|
|
101
|
+
@property
|
|
102
|
+
def external_url_with_campaign(self):
|
|
103
|
+
extras = get_mail_campaign_dict()
|
|
104
|
+
return endpoint_for("territories.territory", territory=self, _external=True, **extras)
|
|
105
|
+
|
|
100
106
|
def count_datasets(self):
|
|
101
107
|
from udata.models import Dataset
|
|
102
108
|
|
udata/core/user/models.py
CHANGED
|
@@ -17,6 +17,7 @@ from udata.core.discussions.models import Discussion
|
|
|
17
17
|
from udata.core.storages import avatars, default_image_basename
|
|
18
18
|
from udata.frontend.markdown import mdstrip
|
|
19
19
|
from udata.i18n import lazy_gettext as _
|
|
20
|
+
from udata.mail import get_mail_campaign_dict
|
|
20
21
|
from udata.models import Follow, WithMetrics, db
|
|
21
22
|
from udata.uris import endpoint_for
|
|
22
23
|
|
|
@@ -128,6 +129,11 @@ class User(WithMetrics, UserMixin, db.Document):
|
|
|
128
129
|
def external_url(self):
|
|
129
130
|
return self.url_for(_external=True)
|
|
130
131
|
|
|
132
|
+
@property
|
|
133
|
+
def external_url_with_campaign(self):
|
|
134
|
+
extras = get_mail_campaign_dict()
|
|
135
|
+
return self.url_for(_external=True, **extras)
|
|
136
|
+
|
|
131
137
|
@property
|
|
132
138
|
def visible(self):
|
|
133
139
|
count = self.metrics.get("datasets", 0) + self.metrics.get("reuses", 0)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from flask import url_for
|
|
2
2
|
|
|
3
|
+
from udata.mail import get_mail_campaign_dict
|
|
3
4
|
from udata.models import License, Organization
|
|
4
5
|
|
|
5
6
|
__all__ = ("TerritoryDataset", "ResourceBasedTerritoryDataset", "TERRITORY_DATASETS")
|
|
@@ -59,3 +60,8 @@ class ResourceBasedTerritoryDataset(TerritoryDataset):
|
|
|
59
60
|
@property
|
|
60
61
|
def external_url(self):
|
|
61
62
|
return self.url_for(external=True)
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def external_url_with_campaign(self):
|
|
66
|
+
extras = get_mail_campaign_dict()
|
|
67
|
+
return self.url_for(_external=True, **extras)
|
udata/mail.py
CHANGED
|
@@ -50,6 +50,7 @@ def send(subject, recipients, template_base, **kwargs):
|
|
|
50
50
|
debug = current_app.config.get("DEBUG", False)
|
|
51
51
|
send_mail = current_app.config.get("SEND_MAIL", not debug)
|
|
52
52
|
connection = send_mail and mail.connect or dummyconnection
|
|
53
|
+
extras = get_mail_campaign_dict()
|
|
53
54
|
|
|
54
55
|
with connection() as conn:
|
|
55
56
|
for recipient in recipients:
|
|
@@ -58,16 +59,31 @@ def send(subject, recipients, template_base, **kwargs):
|
|
|
58
59
|
log.debug('Sending mail "%s" to recipient "%s"', subject, recipient)
|
|
59
60
|
msg = Message(subject, sender=sender, recipients=[recipient.email])
|
|
60
61
|
msg.body = render_template(
|
|
61
|
-
f"{tpl_path}.txt",
|
|
62
|
+
f"{tpl_path}.txt",
|
|
63
|
+
subject=subject,
|
|
64
|
+
sender=sender,
|
|
65
|
+
recipient=recipient,
|
|
66
|
+
extras=extras,
|
|
67
|
+
**kwargs,
|
|
62
68
|
)
|
|
63
69
|
msg.html = render_template(
|
|
64
70
|
f"{tpl_path}.html",
|
|
65
71
|
subject=subject,
|
|
66
72
|
sender=sender,
|
|
67
73
|
recipient=recipient,
|
|
74
|
+
extras=extras,
|
|
68
75
|
**kwargs,
|
|
69
76
|
)
|
|
70
77
|
try:
|
|
71
78
|
conn.send(msg)
|
|
72
79
|
except SMTPException as e:
|
|
73
80
|
log.error(f"Error sending mail {e}")
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def get_mail_campaign_dict() -> dict:
|
|
84
|
+
"""Return a dict with the `mtm_campaign` key set if there is a `MAIL_CAMPAIGN` configured in udata.cfg."""
|
|
85
|
+
extras = {}
|
|
86
|
+
mail_campaign = current_app.config.get("MAIL_CAMPAIGN")
|
|
87
|
+
if mail_campaign:
|
|
88
|
+
extras["mtm_campaign"] = mail_campaign
|
|
89
|
+
return extras
|