drf-appkit 1.3.6__tar.gz → 1.3.8__tar.gz
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.
- {drf-appkit-1.3.6/drf_appkit.egg-info → drf-appkit-1.3.8}/PKG-INFO +2 -2
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/forms/widgets.py +1 -1
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/models.py +19 -40
- drf-appkit-1.3.8/appkit/notification.py +80 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/shortcuts.py +9 -17
- drf-appkit-1.3.8/appkit/tests.py +20 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/util.py +19 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8/drf_appkit.egg-info}/PKG-INFO +2 -2
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/drf_appkit.egg-info/SOURCES.txt +2 -1
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/setup.cfg +2 -2
- drf-appkit-1.3.6/appkit/email.py +0 -48
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/LICENSE +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/MANIFEST.in +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/README.md +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/__init__.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/api/__init__.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/api/filters.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/api/mixins.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/api/pagination.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/api/relations.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/api/renderers.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/api/serializers.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/api/tests.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/api/views.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/auth/__init__.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/auth/backends.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/auth/decorators.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/auth/email.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/auth/permissions.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/debug.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf/__init__.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf/adapters.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf/authentication.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf/backends.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf/endpoints.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf/exceptions.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf/fields.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf/filters.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf/mixins.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf/permissions.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf/serializers.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf_appkit.egg-info/PKG-INFO +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf_appkit.egg-info/SOURCES.txt +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf_appkit.egg-info/dependency_links.txt +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/drf_appkit.egg-info/top_level.txt +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/forms/__init__.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/jinja2/appkit/forms/widgets/money_widget.html +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/managers.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0001_initial.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0002_arrangement_tags.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0003_auto_20210221_0852.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0004_auto_20210309_0655.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0005_auto_20210324_1046.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0006_sitealias.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0007_auto_20211021_1901.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0008_update_autofields.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0009_alter_arrangement_unique_together_and_more.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0010_arrangement_name.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0011_alter_sitealias_options.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0012_alter_sitealias_site.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0013_usergroup.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0014_remove_note_notes_note_content_type_note_object_id.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0015_alter_note_content_type_alter_note_object_id.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0016_alter_arrangementitem_unique_together_and_more.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0017_alter_imageattachment_image.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0018_place_geoposition.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0019_alter_place_geoposition.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0020_remove_arrangement_type_arrangement_content_type.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0021_rename_content_type_arrangement_item_type.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/0022_imageattachment_rendition_key_imageattachment_warm.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/migrations/__init__.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/settings.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/storages.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/tasks.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/transformers.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/appkit/views.py +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/drf_appkit.egg-info/dependency_links.txt +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/drf_appkit.egg-info/top_level.txt +0 -0
- {drf-appkit-1.3.6 → drf-appkit-1.3.8}/setup.py +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: drf-appkit
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.8
|
|
4
4
|
Summary: A Django app providing generic CRUD functionality
|
|
5
5
|
Author: Allan Hart
|
|
6
6
|
License: BSD
|
|
7
7
|
Classifier: Environment :: Web Environment
|
|
8
8
|
Classifier: Framework :: Django
|
|
9
|
-
Classifier: Framework :: Django ::
|
|
9
|
+
Classifier: Framework :: Django :: 4.2
|
|
10
10
|
Classifier: Intended Audience :: Developers
|
|
11
11
|
Classifier: License :: OSI Approved :: BSD License
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
@@ -12,12 +12,14 @@ from django.core.signing import Signer
|
|
|
12
12
|
from django.dispatch import Signal
|
|
13
13
|
from django.db import models
|
|
14
14
|
from django.urls import reverse
|
|
15
|
+
from django.utils import timezone
|
|
15
16
|
from django.utils.text import slugify
|
|
16
17
|
from django.utils.translation import gettext_lazy as _
|
|
17
18
|
|
|
18
19
|
from django.contrib.gis.db.models import PointField
|
|
19
20
|
|
|
20
21
|
from djmoney.models.fields import MoneyField
|
|
22
|
+
from notificationcenter.models import default_center as notification_center
|
|
21
23
|
from treebeard.mp_tree import MP_Node
|
|
22
24
|
from versatileimagefield.fields import VersatileImageField
|
|
23
25
|
|
|
@@ -33,7 +35,7 @@ from .settings import appkit_settings
|
|
|
33
35
|
|
|
34
36
|
|
|
35
37
|
class ModelBase(models.Model):
|
|
36
|
-
|
|
38
|
+
notification_classes = {}
|
|
37
39
|
|
|
38
40
|
class Meta:
|
|
39
41
|
abstract = True
|
|
@@ -102,8 +104,11 @@ class ModelBase(models.Model):
|
|
|
102
104
|
duplicate.save()
|
|
103
105
|
return duplicate
|
|
104
106
|
|
|
107
|
+
@property
|
|
108
|
+
def related_users(self):
|
|
109
|
+
return set()
|
|
110
|
+
|
|
105
111
|
def notification_subscribers(self, event_name=None, digest=None):
|
|
106
|
-
from notificationcenter.models import default_center as notification_center
|
|
107
112
|
notification_name = self.notification_name_for_event(event_name)
|
|
108
113
|
if digest is None:
|
|
109
114
|
return notification_center.subscribers(notification_name, sender=self, digest=True) | \
|
|
@@ -123,13 +128,9 @@ class ModelBase(models.Model):
|
|
|
123
128
|
def digest_subscribers(self):
|
|
124
129
|
return self.notification_subscribers(digest=True)
|
|
125
130
|
|
|
126
|
-
@property
|
|
127
|
-
def notification_mail_classes(self):
|
|
128
|
-
return {}
|
|
129
|
-
|
|
130
131
|
def notification_name_for_event(self, event_name=None):
|
|
131
132
|
content_type = ContentType.objects.get_for_model(self)
|
|
132
|
-
name_components = [content_type.model]
|
|
133
|
+
name_components = [content_type.app_label, content_type.model]
|
|
133
134
|
if event_name is not None:
|
|
134
135
|
if isinstance(event_name, str):
|
|
135
136
|
name_components.append(event_name)
|
|
@@ -138,45 +139,23 @@ class ModelBase(models.Model):
|
|
|
138
139
|
|
|
139
140
|
return ':'.join(name_components)
|
|
140
141
|
|
|
141
|
-
def send_notification_email(self, event_type, **kwargs):
|
|
142
|
-
from notificationcenter.models import default_center as notification_center
|
|
143
|
-
|
|
144
|
-
request = kwargs['request']
|
|
145
|
-
|
|
146
|
-
EmailClass = self.notification_mail_classes.get(event_type)
|
|
147
|
-
if not EmailClass:
|
|
148
|
-
return
|
|
149
142
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
143
|
+
def notify_users(self, event_type, date_scheduled=None, **kwargs):
|
|
144
|
+
"""
|
|
145
|
+
Perform notification(s) in response to the given event type.
|
|
146
|
+
"""
|
|
147
|
+
created_by = None
|
|
148
|
+
request = kwargs.get('request')
|
|
149
|
+
if request and request.user.is_authenticated:
|
|
150
|
+
created_by = request.user
|
|
157
151
|
|
|
158
|
-
# Let the NotificationCenter handle the actual sending of the email
|
|
159
|
-
# TODO: introduce an argument to control the notify_immediately behavior
|
|
160
|
-
notification_name = self.notification_name_for_event(event_type)
|
|
161
152
|
notification_center.post_notification(
|
|
162
|
-
|
|
153
|
+
self.notification_name_for_event(event_type),
|
|
154
|
+
created_by,
|
|
163
155
|
self,
|
|
164
|
-
|
|
165
|
-
text=email.body,
|
|
166
|
-
html=email.html,
|
|
167
|
-
context=notification_context,
|
|
168
|
-
notify_immediately=False
|
|
156
|
+
context={'date_scheduled': date_scheduled}
|
|
169
157
|
)
|
|
170
158
|
|
|
171
|
-
def notify_users(self, event_type, **kwargs):
|
|
172
|
-
"""
|
|
173
|
-
Perform email notification in response to the given event type. Subclasses
|
|
174
|
-
may customize the behavior of this method (if necessary) by overriding
|
|
175
|
-
one or more of the following related methods:
|
|
176
|
-
- send_notification_email
|
|
177
|
-
"""
|
|
178
|
-
self.send_notification_email(event_type, **kwargs)
|
|
179
|
-
|
|
180
159
|
|
|
181
160
|
class Place(ModelBase):
|
|
182
161
|
place_id = models.CharField(max_length=255, unique=True)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import plivo
|
|
3
|
+
|
|
4
|
+
from django.conf import settings
|
|
5
|
+
from django.templatetags.static import static
|
|
6
|
+
|
|
7
|
+
from mail_templated import EmailMessage
|
|
8
|
+
|
|
9
|
+
from .shortcuts import site_url_base
|
|
10
|
+
from .util import to_gsm7
|
|
11
|
+
|
|
12
|
+
SMS_SRC_NUMBER = os.environ.get('PLIVO_SMS_SOURCE_NUMBER')
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AppkitEmailMessage(EmailMessage):
|
|
16
|
+
sender = settings.DEFAULT_FROM_EMAIL_SENDER
|
|
17
|
+
|
|
18
|
+
def __init__(self, template_name=None, site=None, context=None, *args, **kwargs):
|
|
19
|
+
email_context = context or {}
|
|
20
|
+
|
|
21
|
+
app_site_url = site_url_base(None)
|
|
22
|
+
email_context.update({
|
|
23
|
+
'app_name': settings.PROJECT_NAME,
|
|
24
|
+
'app_site_url': app_site_url,
|
|
25
|
+
'app_icon_url': f'{app_site_url}{static("images/icon/android-chrome-192x192.png")}',
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
if site:
|
|
29
|
+
self.sender = site.name
|
|
30
|
+
email_context.update({
|
|
31
|
+
'site_name': site.name,
|
|
32
|
+
'site_url': site_url_base(site),
|
|
33
|
+
})
|
|
34
|
+
if site.profile.icon:
|
|
35
|
+
email_context['site_icon_url'] = site.profile.icon_renditions['192']
|
|
36
|
+
|
|
37
|
+
if 'sender' in kwargs:
|
|
38
|
+
self.sender = kwargs.pop('sender')
|
|
39
|
+
|
|
40
|
+
super().__init__(template_name, email_context, *args, **kwargs)
|
|
41
|
+
|
|
42
|
+
def send(self, *args, **kwargs):
|
|
43
|
+
if self.sender:
|
|
44
|
+
self.from_email = f"{self.sender} <{self.from_email}>"
|
|
45
|
+
|
|
46
|
+
self.to = list(*args)
|
|
47
|
+
self.cc = kwargs.pop('cc', self.cc)
|
|
48
|
+
self.bcc = kwargs.pop('bcc', self.bcc)
|
|
49
|
+
self.reply_to = kwargs.pop('reply_to', self.reply_to)
|
|
50
|
+
|
|
51
|
+
self.context['allow_reply'] = True if self.reply_to else False
|
|
52
|
+
|
|
53
|
+
super(AppkitEmailMessage, self).send(*args, **kwargs)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class AppkitSMSMessage:
|
|
57
|
+
def __init__(self, message, recipients, *args, **kwargs):
|
|
58
|
+
self.recipients = recipients
|
|
59
|
+
self.message = to_gsm7(message)
|
|
60
|
+
|
|
61
|
+
def send(self, *args, **kwargs):
|
|
62
|
+
if not self.recipients:
|
|
63
|
+
return
|
|
64
|
+
|
|
65
|
+
if os.environ.get('TESTING'):
|
|
66
|
+
return
|
|
67
|
+
|
|
68
|
+
dst_phone = '<'.join(self.recipients)
|
|
69
|
+
with plivo.RestClient() as sms_client:
|
|
70
|
+
try:
|
|
71
|
+
sms_client.messages.create(
|
|
72
|
+
src=SMS_SRC_NUMBER,
|
|
73
|
+
dst=dst_phone,
|
|
74
|
+
text=self.message
|
|
75
|
+
)
|
|
76
|
+
# log(f'Delivered inventory announcement {announcement.uuid} via SMS to {dst_phone}')
|
|
77
|
+
except plivo.exceptions.PlivoRestError as e:
|
|
78
|
+
print('Log SMS delivery failure')
|
|
79
|
+
# log(str(e), level=logging.ERROR)
|
|
80
|
+
|
|
@@ -16,8 +16,6 @@ from django.utils import timezone
|
|
|
16
16
|
|
|
17
17
|
from rest_framework.reverse import reverse
|
|
18
18
|
|
|
19
|
-
from .models import Place
|
|
20
|
-
|
|
21
19
|
|
|
22
20
|
def get_current_site(request):
|
|
23
21
|
origin = request.META.get("HTTP_ORIGIN")
|
|
@@ -95,6 +93,15 @@ def email_address_for_user(user, verbose=False):
|
|
|
95
93
|
return email_address
|
|
96
94
|
|
|
97
95
|
|
|
96
|
+
|
|
97
|
+
def phone_number_for_user(user):
|
|
98
|
+
try:
|
|
99
|
+
phone = user.profile.phone
|
|
100
|
+
return str(phone) if phone else None
|
|
101
|
+
except AttributeError:
|
|
102
|
+
return None
|
|
103
|
+
|
|
104
|
+
|
|
98
105
|
def base_url(request):
|
|
99
106
|
if not request:
|
|
100
107
|
return settings.BASE_URL
|
|
@@ -292,18 +299,3 @@ def formatted_user_email(user):
|
|
|
292
299
|
recipient_name = user.get_full_name()
|
|
293
300
|
recipient_email = getattr(user, user.get_email_field_name())
|
|
294
301
|
return f'"{recipient_name}" <{recipient_email}>'
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
def place_with_info(place_info):
|
|
298
|
-
if not place_info:
|
|
299
|
-
return None
|
|
300
|
-
|
|
301
|
-
try:
|
|
302
|
-
return Place.objects.get(place_id=place_info['place_id'])
|
|
303
|
-
except Place.DoesNotExist:
|
|
304
|
-
location = place_info['geometry']['location']
|
|
305
|
-
return Place.objects.create(
|
|
306
|
-
place_id=place_info['place_id'],
|
|
307
|
-
geoposition=Point(location['lng'], location['lat']),
|
|
308
|
-
info=place_info
|
|
309
|
-
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from django.test import TestCase
|
|
2
|
+
|
|
3
|
+
from .util import to_gsm7
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
VALID_GSM_STRING = 'This message contains only GSM-7 characters'
|
|
7
|
+
INVALID_GSM_STRING = "🥳 [It's] a $#!T 🥳 party 🥳"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class GSMTestCase(TestCase):
|
|
11
|
+
def test_gsm7_to_gsm7(self):
|
|
12
|
+
self.assertEqual(VALID_GSM_STRING, to_gsm7(VALID_GSM_STRING))
|
|
13
|
+
|
|
14
|
+
def test_emoji_to_gsm7(self):
|
|
15
|
+
# Note that leading and trailing whitespace are valid and therefore _NOT_ removed
|
|
16
|
+
self.assertEqual(to_gsm7(INVALID_GSM_STRING), " [It's] a $#!T party ")
|
|
17
|
+
|
|
18
|
+
def test_to_gsm7_max_length(self):
|
|
19
|
+
gsm_msg = to_gsm7(to_gsm7(INVALID_GSM_STRING), max_length=18)
|
|
20
|
+
self.assertEqual(gsm_msg, " [It's] a $#!T pa")
|
|
@@ -21,6 +21,25 @@ from django.contrib.contenttypes.fields import GenericRelation
|
|
|
21
21
|
from django.db.models import JSONField
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
GSM_7_CODES = {'0x40', '0xa3', '0x24', '0xa5', '0xe8', '0xe9', '0xf9', '0xec', '0xf2', '0xe7', '0x0a', '0xd8', '0xf8', '0x0d', '0xc5', '0xe5', '0x0394', '0x5f', '0x03a6', '0x0393', '0x039b', '0x03a9', '0x03a0', '0x03a8', '0x03a3', '0x0398', '0x039e', '0xa0', '0x0c', '0x5e', '0x7b', '0x7d', '0x5c', '0x5b', '0x7e', '0x5d', '0x7c', '0x20ac', '0xc6', '0xe6', '0xdf', '0xc9', '0x20', '0x21', '0x22', '0x23', '0xa4', '0x25', '0x26', '0x27', '0x28', '0x29', '0x2a', '0x2b', '0x2c', '0x2d', '0x2e', '0x2f', '0x30', '0x31', '0x32', '0x33', '0x34', '0x35', '0x36', '0x37', '0x38', '0x39', '0x3a', '0x3b', '0x3c', '0x3d', '0x3e', '0x3f', '0xa1', '0x41', '0x42', '0x43', '0x44', '0x45', '0x46', '0x47', '0x48', '0x49', '0x4a', '0x4b', '0x4c', '0x4d', '0x4e', '0x4f', '0x50', '0x51', '0x52', '0x53', '0x54', '0x55', '0x56', '0x57', '0x58', '0x59', '0x5a', '0xc4', '0xd6', '0xd1', '0xdc', '0xa7', '0xbf', '0x61', '0x62', '0x63', '0x64', '0x65', '0x66', '0x67', '0x68', '0x69', '0x6a', '0x6b', '0x6c', '0x6d', '0x6e', '0x6f', '0x70', '0x71', '0x72', '0x73', '0x74', '0x75', '0x76', '0x77', '0x78', '0x79', '0x7a', '0xe4', '0xf6', '0xf1', '0xfc', '0xe0', '0xa'}
|
|
25
|
+
GSM_7_SMS_UNIT_LENGTH = 160
|
|
26
|
+
|
|
27
|
+
def to_gsm7(val, max_length=None):
|
|
28
|
+
gsm7_chars = []
|
|
29
|
+
gsm7_length = 0
|
|
30
|
+
|
|
31
|
+
for char in val:
|
|
32
|
+
char_hex = hex(ord(char))
|
|
33
|
+
if char_hex in GSM_7_CODES:
|
|
34
|
+
gsm7_chars.append(char)
|
|
35
|
+
gsm7_length += 1
|
|
36
|
+
|
|
37
|
+
if max_length and gsm7_length == max_length:
|
|
38
|
+
break
|
|
39
|
+
|
|
40
|
+
return ''.join(gsm7_chars)
|
|
41
|
+
|
|
42
|
+
|
|
24
43
|
def bumpy_case_words(string):
|
|
25
44
|
return [s for s in re.findall('([A-Z]*[a-z]*)', string) if len(s) > 0]
|
|
26
45
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: drf-appkit
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.8
|
|
4
4
|
Summary: A Django app providing generic CRUD functionality
|
|
5
5
|
Author: Allan Hart
|
|
6
6
|
License: BSD
|
|
7
7
|
Classifier: Environment :: Web Environment
|
|
8
8
|
Classifier: Framework :: Django
|
|
9
|
-
Classifier: Framework :: Django ::
|
|
9
|
+
Classifier: Framework :: Django :: 4.2
|
|
10
10
|
Classifier: Intended Audience :: Developers
|
|
11
11
|
Classifier: License :: OSI Approved :: BSD License
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
@@ -5,13 +5,14 @@ setup.cfg
|
|
|
5
5
|
setup.py
|
|
6
6
|
appkit/__init__.py
|
|
7
7
|
appkit/debug.py
|
|
8
|
-
appkit/email.py
|
|
9
8
|
appkit/managers.py
|
|
10
9
|
appkit/models.py
|
|
10
|
+
appkit/notification.py
|
|
11
11
|
appkit/settings.py
|
|
12
12
|
appkit/shortcuts.py
|
|
13
13
|
appkit/storages.py
|
|
14
14
|
appkit/tasks.py
|
|
15
|
+
appkit/tests.py
|
|
15
16
|
appkit/transformers.py
|
|
16
17
|
appkit/util.py
|
|
17
18
|
appkit/views.py
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[metadata]
|
|
2
2
|
name = drf-appkit
|
|
3
|
-
version = 1.3.
|
|
3
|
+
version = 1.3.8
|
|
4
4
|
description = A Django app providing generic CRUD functionality
|
|
5
5
|
license = BSD
|
|
6
6
|
long_description = file: README.md
|
|
@@ -8,7 +8,7 @@ author = Allan Hart
|
|
|
8
8
|
classifiers =
|
|
9
9
|
Environment :: Web Environment
|
|
10
10
|
Framework :: Django
|
|
11
|
-
Framework :: Django ::
|
|
11
|
+
Framework :: Django :: 4.2
|
|
12
12
|
Intended Audience :: Developers
|
|
13
13
|
License :: OSI Approved :: BSD License
|
|
14
14
|
Operating System :: OS Independent
|
drf-appkit-1.3.6/appkit/email.py
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
from django.conf import settings
|
|
2
|
-
from django.templatetags.static import static
|
|
3
|
-
|
|
4
|
-
from mail_templated import EmailMessage
|
|
5
|
-
|
|
6
|
-
from .settings import appkit_settings
|
|
7
|
-
from .shortcuts import site_url_base
|
|
8
|
-
|
|
9
|
-
get_current_site = appkit_settings.CURRENT_SITE_ACCESSOR
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class AppkitEmailMessage(EmailMessage):
|
|
13
|
-
sender = settings.DEFAULT_FROM_EMAIL_SENDER
|
|
14
|
-
|
|
15
|
-
def __init__(self, template_name=None, site=None, context=None, *args, **kwargs):
|
|
16
|
-
email_context = dict(context) if context else {}
|
|
17
|
-
|
|
18
|
-
app_site_url = site_url_base(None)
|
|
19
|
-
email_context.update({
|
|
20
|
-
'app_name': settings.PROJECT_NAME,
|
|
21
|
-
'app_site_url': app_site_url,
|
|
22
|
-
'app_icon_url': f'{app_site_url}{static("images/icon/android-chrome-192x192.png")}',
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
if site:
|
|
26
|
-
email_context.update({
|
|
27
|
-
'site_name': site.name,
|
|
28
|
-
'site_url': site_url_base(site),
|
|
29
|
-
})
|
|
30
|
-
if site.profile.icon:
|
|
31
|
-
email_context['site_icon_url'] = site.profile.icon.image.thumbnail['192x192']
|
|
32
|
-
|
|
33
|
-
super().__init__(template_name, email_context, *args, **kwargs)
|
|
34
|
-
|
|
35
|
-
def send(self, *args, **kwargs):
|
|
36
|
-
if not self.sender and 'site' in self.context:
|
|
37
|
-
self.sender = self.context['site'].name
|
|
38
|
-
|
|
39
|
-
self.from_email = f"{self.sender} <{self.from_email}>"
|
|
40
|
-
|
|
41
|
-
self.to = list(*args)
|
|
42
|
-
self.cc = kwargs.pop('cc', [])
|
|
43
|
-
self.bcc = kwargs.pop('bcc', [])
|
|
44
|
-
self.reply_to = kwargs.pop('reply_to', [])
|
|
45
|
-
|
|
46
|
-
self.context['allow_reply'] = True if self.reply_to else False
|
|
47
|
-
|
|
48
|
-
super(AppkitEmailMessage, self).send(*args, **kwargs)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|