django-codenerix-email 4.0.20__py2.py3-none-any.whl → 4.0.21__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.
@@ -1,4 +1,4 @@
1
- __version__ = "4.0.20"
1
+ __version__ = "4.0.21"
2
2
 
3
3
  __authors__ = [
4
4
  "Juan Miguel Taboada Godoy <juanmi@juanmitaboada.com>",
codenerix_email/forms.py CHANGED
@@ -96,6 +96,7 @@ class EmailMessageForm(GenModelForm):
96
96
  ["eto", 3],
97
97
  ["subject", 3],
98
98
  ["opened", 3],
99
+ ["content_subtype", 3],
99
100
  ),
100
101
  (
101
102
  _("System"),
@@ -106,6 +107,8 @@ class EmailMessageForm(GenModelForm):
106
107
  ["retries", 3],
107
108
  ["priority", 3],
108
109
  ["log", 3],
110
+ ["unsubscribe_url", 3],
111
+ ["headers", 3],
109
112
  ),
110
113
  (
111
114
  _("Body"),
@@ -0,0 +1,18 @@
1
+ # Generated by Django 5.1.2 on 2024-10-15 06:20
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+
8
+ dependencies = [
9
+ ("codenerix_email", "0012_emailmessage_unsubscribe_url"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AddField(
14
+ model_name="emailmessage",
15
+ name="headers",
16
+ field=models.JSONField(blank=True, null=True, verbose_name="Headers"),
17
+ ),
18
+ ]
codenerix_email/models.py CHANGED
@@ -49,6 +49,12 @@ CONTENT_SUBTYPES = (
49
49
  )
50
50
 
51
51
 
52
+ def ensure_header(headers, key, value):
53
+ if key not in headers:
54
+ headers[key] = value
55
+ return headers
56
+
57
+
52
58
  class EmailMessage(CodenerixModel, Debugger):
53
59
  uuid = models.UUIDField(
54
60
  _("UUID"),
@@ -95,6 +101,7 @@ class EmailMessage(CodenerixModel, Debugger):
95
101
  unsubscribe_url = models.URLField(
96
102
  _("Unsubscribe URL"), blank=True, null=True
97
103
  )
104
+ headers = models.JSONField(_("Headers"), blank=True, null=True)
98
105
 
99
106
  def __fields__(self, info):
100
107
  fields = []
@@ -111,9 +118,9 @@ class EmailMessage(CodenerixModel, Debugger):
111
118
  fields.append(("retries", _("Retries")))
112
119
  fields.append(("next_retry", _("Next retry")))
113
120
  fields.append(("pk", _("ID")))
114
- fields.append(("content_subtype", _("Content Subtype")))
115
121
  fields.append(("uuid", _("UUID")))
116
- fields.append(("unsubscribe_url", _("Unsubscribe URL")))
122
+ fields.append(("unsubscribe_url", _("Unsubscribe")))
123
+ fields.append(("content_subtype", _("Content Subtype")))
117
124
  return fields
118
125
 
119
126
  def __searchQ__(self, info, search): # noqa: N802
@@ -160,31 +167,36 @@ class EmailMessage(CodenerixModel, Debugger):
160
167
  "eto": (_("To"), lambda x: Q(eto__icontains=x), "input"),
161
168
  "retries": (_("Retries"), lambda x: Q(retries=x), "input"),
162
169
  "pk": (_("ID"), lambda x: Q(pk=x), "input"),
163
- "unsubscribe_url": (
164
- _("Unsubscribe URL"),
165
- lambda x: Q(unsubscribe_url__icontains=x),
166
- "input",
167
- ),
168
170
  }
169
171
 
170
172
  def __unicode__(self):
171
173
  return "{} ({})".format(self.eto, self.pk)
172
174
 
175
+ def clean(self):
176
+ if not isinstance(self.headers, dict):
177
+ raise ValidationError(_("HEADERS must be a Dictionary"))
178
+
173
179
  def set_opened(self):
174
180
  if not self.opened:
175
181
  self.opened = timezone.now()
176
182
  self.save()
177
183
 
178
- @property
179
- def headers(self):
180
- headers = {}
184
+ def get_headers(self):
185
+
186
+ # Get headers
187
+ headers = self.headers or {}
188
+
189
+ # Ensure unsubscribe headers
181
190
  if self.unsubscribe_url:
182
- headers["List-Unsubscribe"] = f"<{self.unsubscribe_url}>"
183
- headers[
184
- "List-Unsubscribe-Post"
185
- ] = "List-Unsubscribe=One-Click"
186
- return headers
191
+ ensure_header(
192
+ headers, "List-Unsubscribe", f"<{self.unsubscribe_url}>"
193
+ )
194
+ ensure_header(
195
+ headers, "List-Unsubscribe-Post", "List-Unsubscribe=One-Click"
196
+ )
187
197
 
198
+ # Return headers
199
+ return headers
188
200
 
189
201
  @classmethod
190
202
  def process_queue(
@@ -370,7 +382,7 @@ class EmailMessage(CodenerixModel, Debugger):
370
382
  from_email=self.efrom,
371
383
  to=[self.eto],
372
384
  connection=connection,
373
- headers = self.headers
385
+ headers=self.get_headers(),
374
386
  )
375
387
  email.content_subtype = self.content_subtype
376
388
  for at in self.attachments.all():
@@ -17,7 +17,13 @@
17
17
  <td><center>{{row.retries|codenerix}}</center></td>
18
18
  <td class="text-nowrap">{{row.next_retry|codenerix}}</td>
19
19
  <td><center>{{row.pk|codenerix}}</center></td>
20
- <td>
20
+ <td ng-click="$event.stopPropagation();" align="center">
21
+ <nobr><i title="{{row.uuid}}" codenerix-html-compile="row.uuid|codenerix:'copytoclipboard:UUID:UUID copiado al portapapales...'"></i></nobr>
22
+ </td>
23
+ <td ng-click="$event.stopPropagation();" align="center">
24
+ <i codenerix-html-compile="row.unsubscribe_url|codenerix:'link:blank:onlyicon'"></i>
25
+ </td>
26
+ <td ng-click="$event.stopPropagation();">
21
27
  <center>
22
28
  <button class="btn" title="{{row.content_subtype|codenerix}}">
23
29
  <i ng-show="row.content_subtype=='plain'" class="fa fa-file-text-o" aria-hidden="true"></i>
@@ -26,11 +32,3 @@
26
32
  </button>
27
33
  </center>
28
34
  </td>
29
- <td ng-click="$event.stopPropagation();" align="center">
30
- <span codenerix-html-compile="row.uuid|codenerix:'copytoclipboard:UUID:UUID copiado al portapapales...':codenerix_inner_element">
31
- <span class="fa fa-barcode"></span>
32
- </span>
33
- </td>
34
- <td ng-click="$event.stopPropagation();" align="center">
35
- <span codenerix-html-compile="row.unsubscribe_url|codenerix:'link:blank:onlyicon'">
36
- </td>
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django-codenerix-email
3
- Version: 4.0.20
3
+ Version: 4.0.21
4
4
  Summary: Codenerix Email is a module that enables CODENERIX to set send emails in a general manner.
5
5
  Home-page: https://github.com/codenerix/django-codenerix-email
6
6
  Author: Juan Miguel Taboada Godoy <juanmi@juanmitaboada.com>, Juan Soler Ruiz <soleronline@gmail.com>
@@ -1,8 +1,8 @@
1
- codenerix_email/__init__.py,sha256=NznooP8z0g_kglbIBGRpXa3c7ipFWR0sxUZIt0zQxeU,149
1
+ codenerix_email/__init__.py,sha256=mHUnjHp4HJsUYsr4BO4cUVdpkqNEWSU_cvGu6zN4Jek,149
2
2
  codenerix_email/admin.py,sha256=o3b-MaD7xsWeta0yfU9YNeKBmHQIcmHqXmP2t-hrrWc,1208
3
3
  codenerix_email/apps.py,sha256=WXqu1XQibDDyCvvQYt2JbTK4GIpW8BNv5DCbRJS2mmk,149
4
- codenerix_email/forms.py,sha256=n-UrVPI7NMXNImEdJ4uB0HWHEvBNv71YKZ_RPLW4FSg,4075
5
- codenerix_email/models.py,sha256=LSMScSZquMFgNM3zke9BZKwXm41qJ3B4aR8CapSUrtQ,20138
4
+ codenerix_email/forms.py,sha256=oVI58ZfDPr2aoA41xPS8yeU5H_JsYXwiEzWVMMnxM7A,4187
5
+ codenerix_email/models.py,sha256=SimsoQ1g0f-woPlUTnEEo1ejjkSn8QL3ACKHWx876RU,20442
6
6
  codenerix_email/urls.py,sha256=QYrSJdhCp2PLrcfv_Y7X4OzxqQ0Q2-z7ObDPE-_WLdw,2595
7
7
  codenerix_email/urls_frontend.py,sha256=DG5WS_fGQJC9sezNebPwG-E_WtUWy3Kwz4VUxh82xuc,873
8
8
  codenerix_email/views.py,sha256=Bx990LC04HOdytHJoO_T0z0R_u6qm6I2Q9bXtnmf5vw,4822
@@ -28,6 +28,7 @@ codenerix_email/migrations/0009_emailmessage_opened_emailmessage_uuid.py,sha256=
28
28
  codenerix_email/migrations/0010_emailmessage_content_subtype_and_more.py,sha256=Zy9OwxcQCPoVdemJRlotfpGVyTLuzNkCNQYfoEVnvB0,1001
29
29
  codenerix_email/migrations/0011_alter_emailmessage_content_subtype_and_more.py,sha256=Ki38KPngeeTIhrki57OXEwCB5P7JnI1Hv58dwRYLO7w,957
30
30
  codenerix_email/migrations/0012_emailmessage_unsubscribe_url.py,sha256=tPQt1W2LJcXMvt_ecB-2npu7wQ-Og29M99ZJjukYnWA,501
31
+ codenerix_email/migrations/0013_emailmessage_headers.py,sha256=1T0lryajjfXhnMgU-aqJUW-CKDvVe6zLrYu_FygcFE4,441
31
32
  codenerix_email/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
33
  codenerix_email/migrations/__pycache__/0001_initial.cpython-310.pyc,sha256=Sm54OKfGHUMvSVgbXiFAe9E2d85HqlLoMEaBEBP53mE,2005
33
34
  codenerix_email/migrations/__pycache__/0001_initial.cpython-311.pyc,sha256=mOTNcz_iff63bExW7wNyR_HXU-e8ON-Au03YpCL_cCw,3682
@@ -67,13 +68,14 @@ codenerix_email/migrations/__pycache__/0010_emailmessage_content_subtype_and_mor
67
68
  codenerix_email/migrations/__pycache__/0010_emailmessage_opened_emailmessage_uuid_and_more.cpython-311.pyc,sha256=ZoBI5fyc5vTdGSejQl5953krxh_BXl17tuft5ZmdH6U,3104
68
69
  codenerix_email/migrations/__pycache__/0011_alter_emailmessage_content_subtype_and_more.cpython-311.pyc,sha256=rWr5NdYUVeF71WxMUPIzUN67Ua6fhWWjci5dAG7mpRg,1195
69
70
  codenerix_email/migrations/__pycache__/0012_emailmessage_unsubscribe_url.cpython-311.pyc,sha256=NghZueCAhFtAwmKhkYzICGMX0uv44-VA5xhHCPp_O-M,936
71
+ codenerix_email/migrations/__pycache__/0013_emailmessage_headers.cpython-311.pyc,sha256=-fFwK7UWVLCbaVh3ej4EQbee44wVC3hBezdgW875ncg,891
70
72
  codenerix_email/migrations/__pycache__/__init__.cpython-310.pyc,sha256=PdaaABMdLCzCMnJmxaylT_jnLb8l7rr6n5C4CGDX37A,151
71
73
  codenerix_email/migrations/__pycache__/__init__.cpython-311.pyc,sha256=RbbUUEhcJ_eAVNFAdNbkjv60hyF7BsnNOlti5xplQsY,195
72
74
  codenerix_email/migrations/__pycache__/__init__.cpython-35.pyc,sha256=2g70xiMW6oJNkIpRM-0Dr5h7AUac-3xyCXPONxp9BBw,147
73
75
  codenerix_email/migrations/__pycache__/__init__.cpython-39.pyc,sha256=qNj2NH0YvoWPnCKxkVZPsEFsbM05y7t1njMskNISdVQ,168
74
- codenerix_email/static/codenerix_email/partials/emailmessages_rows.html,sha256=e-57Lh_Ozh8uX8nx98vE0OSqFwi1CvcdMApTDUfa8lw,2142
75
- django_codenerix_email-4.0.20.dist-info/LICENSE,sha256=IXMIpi75XsrJt1Sznt4EftT9c_4X0C9eqK4tHhH8H48,11339
76
- django_codenerix_email-4.0.20.dist-info/METADATA,sha256=yqB25aU80ttOXaFDL5wGK0bqez6yXVSdwrpVERVn9jQ,2640
77
- django_codenerix_email-4.0.20.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
78
- django_codenerix_email-4.0.20.dist-info/top_level.txt,sha256=lljSA0iKE_UBEM5gIrGQwioC_i8Jjnp-aR1LFElENgw,16
79
- django_codenerix_email-4.0.20.dist-info/RECORD,,
76
+ codenerix_email/static/codenerix_email/partials/emailmessages_rows.html,sha256=U0YDiFe-JaHri0VFv84jNbpbjgQXX0BVkg66FQybanw,2135
77
+ django_codenerix_email-4.0.21.dist-info/LICENSE,sha256=IXMIpi75XsrJt1Sznt4EftT9c_4X0C9eqK4tHhH8H48,11339
78
+ django_codenerix_email-4.0.21.dist-info/METADATA,sha256=3HETrOQFuUHbDtuKDhM3c3glgvau3e99bXh7aigbKcc,2640
79
+ django_codenerix_email-4.0.21.dist-info/WHEEL,sha256=z9j0xAa_JmUKMpmz72K0ZGALSM_n-wQVmGbleXx2VHg,110
80
+ django_codenerix_email-4.0.21.dist-info/top_level.txt,sha256=lljSA0iKE_UBEM5gIrGQwioC_i8Jjnp-aR1LFElENgw,16
81
+ django_codenerix_email-4.0.21.dist-info/RECORD,,