drf-appkit 1.3.7__tar.gz → 1.3.9__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.
Files changed (82) hide show
  1. {drf-appkit-1.3.7/drf_appkit.egg-info → drf-appkit-1.3.9}/PKG-INFO +2 -2
  2. drf-appkit-1.3.9/appkit/__init__.py +1 -0
  3. drf-appkit-1.3.9/appkit/apps.py +9 -0
  4. drf-appkit-1.3.9/appkit/handlers.py +10 -0
  5. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/models.py +20 -53
  6. drf-appkit-1.3.9/appkit/notification.py +80 -0
  7. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/shortcuts.py +9 -17
  8. drf-appkit-1.3.9/appkit/tests.py +20 -0
  9. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/util.py +19 -0
  10. {drf-appkit-1.3.7 → drf-appkit-1.3.9/drf_appkit.egg-info}/PKG-INFO +2 -2
  11. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/drf_appkit.egg-info/SOURCES.txt +4 -1
  12. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/setup.cfg +2 -2
  13. drf-appkit-1.3.7/appkit/email.py +0 -48
  14. drf-appkit-1.3.7/appkit/migrations/__init__.py +0 -0
  15. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/LICENSE +0 -0
  16. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/MANIFEST.in +0 -0
  17. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/README.md +0 -0
  18. {drf-appkit-1.3.7/appkit → drf-appkit-1.3.9/appkit/api}/__init__.py +0 -0
  19. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/api/filters.py +0 -0
  20. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/api/mixins.py +0 -0
  21. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/api/pagination.py +0 -0
  22. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/api/relations.py +0 -0
  23. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/api/renderers.py +0 -0
  24. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/api/serializers.py +0 -0
  25. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/api/tests.py +0 -0
  26. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/api/views.py +0 -0
  27. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/auth/__init__.py +0 -0
  28. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/auth/backends.py +0 -0
  29. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/auth/decorators.py +0 -0
  30. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/auth/email.py +0 -0
  31. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/auth/permissions.py +0 -0
  32. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/debug.py +0 -0
  33. {drf-appkit-1.3.7/appkit/api → drf-appkit-1.3.9/appkit/drf}/__init__.py +0 -0
  34. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/drf/adapters.py +0 -0
  35. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/drf/authentication.py +0 -0
  36. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/drf/backends.py +0 -0
  37. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/drf/endpoints.py +0 -0
  38. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/drf/exceptions.py +0 -0
  39. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/drf/fields.py +0 -0
  40. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/drf/filters.py +0 -0
  41. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/drf/mixins.py +0 -0
  42. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/drf/permissions.py +0 -0
  43. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/drf/serializers.py +0 -0
  44. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/drf_appkit.egg-info/PKG-INFO +0 -0
  45. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/drf_appkit.egg-info/SOURCES.txt +0 -0
  46. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/drf_appkit.egg-info/dependency_links.txt +0 -0
  47. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/drf_appkit.egg-info/top_level.txt +0 -0
  48. {drf-appkit-1.3.7/appkit/drf → drf-appkit-1.3.9/appkit/forms}/__init__.py +0 -0
  49. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/forms/widgets.py +0 -0
  50. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/jinja2/appkit/forms/widgets/money_widget.html +0 -0
  51. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/managers.py +0 -0
  52. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0001_initial.py +0 -0
  53. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0002_arrangement_tags.py +0 -0
  54. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0003_auto_20210221_0852.py +0 -0
  55. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0004_auto_20210309_0655.py +0 -0
  56. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0005_auto_20210324_1046.py +0 -0
  57. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0006_sitealias.py +0 -0
  58. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0007_auto_20211021_1901.py +0 -0
  59. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0008_update_autofields.py +0 -0
  60. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0009_alter_arrangement_unique_together_and_more.py +0 -0
  61. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0010_arrangement_name.py +0 -0
  62. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0011_alter_sitealias_options.py +0 -0
  63. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0012_alter_sitealias_site.py +0 -0
  64. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0013_usergroup.py +0 -0
  65. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0014_remove_note_notes_note_content_type_note_object_id.py +0 -0
  66. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0015_alter_note_content_type_alter_note_object_id.py +0 -0
  67. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0016_alter_arrangementitem_unique_together_and_more.py +0 -0
  68. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0017_alter_imageattachment_image.py +0 -0
  69. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0018_place_geoposition.py +0 -0
  70. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0019_alter_place_geoposition.py +0 -0
  71. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0020_remove_arrangement_type_arrangement_content_type.py +0 -0
  72. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0021_rename_content_type_arrangement_item_type.py +0 -0
  73. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/migrations/0022_imageattachment_rendition_key_imageattachment_warm.py +0 -0
  74. {drf-appkit-1.3.7/appkit/forms → drf-appkit-1.3.9/appkit/migrations}/__init__.py +0 -0
  75. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/settings.py +0 -0
  76. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/storages.py +0 -0
  77. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/tasks.py +0 -0
  78. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/transformers.py +0 -0
  79. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/appkit/views.py +0 -0
  80. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/drf_appkit.egg-info/dependency_links.txt +0 -0
  81. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/drf_appkit.egg-info/top_level.txt +0 -0
  82. {drf-appkit-1.3.7 → drf-appkit-1.3.9}/setup.py +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: drf-appkit
3
- Version: 1.3.7
3
+ Version: 1.3.9
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 :: 3.1
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
@@ -0,0 +1 @@
1
+ default_app_config = 'appkit.apps.AppConfig'
@@ -0,0 +1,9 @@
1
+ from django import apps
2
+
3
+ class AppConfig(apps.AppConfig):
4
+ name = 'appkit'
5
+ verbose_name = 'AppKit'
6
+
7
+ def ready(self):
8
+ # Makes sure all signal handlers are connected
9
+ from . import handlers # noqa
@@ -0,0 +1,10 @@
1
+ from django.dispatch import receiver
2
+ from .models import document_event
3
+
4
+ @receiver(document_event, sender=None)
5
+ def document_event_signal_receiver(sender, type, **kwargs):
6
+ """
7
+ Send notification email to users subscribed and/or concerned with the event
8
+ of "type" that occurred on the given sender (Document)
9
+ """
10
+ sender.notify_users(type, **kwargs)
@@ -9,8 +9,8 @@ from django.contrib.sites.models import Site
9
9
  from django.core.files.storage import FileSystemStorage
10
10
  from django.core.serializers.json import DjangoJSONEncoder
11
11
  from django.core.signing import Signer
12
- from django.dispatch import Signal
13
12
  from django.db import models
13
+ from django.db.models.signals import ModelSignal
14
14
  from django.urls import reverse
15
15
  from django.utils.text import slugify
16
16
  from django.utils.translation import gettext_lazy as _
@@ -18,6 +18,7 @@ from django.utils.translation import gettext_lazy as _
18
18
  from django.contrib.gis.db.models import PointField
19
19
 
20
20
  from djmoney.models.fields import MoneyField
21
+ from notificationcenter.models import default_center as notification_center
21
22
  from treebeard.mp_tree import MP_Node
22
23
  from versatileimagefield.fields import VersatileImageField
23
24
 
@@ -33,7 +34,7 @@ from .settings import appkit_settings
33
34
 
34
35
 
35
36
  class ModelBase(models.Model):
36
- email_classes = {}
37
+ notification_classes = {}
37
38
 
38
39
  class Meta:
39
40
  abstract = True
@@ -102,8 +103,11 @@ class ModelBase(models.Model):
102
103
  duplicate.save()
103
104
  return duplicate
104
105
 
106
+ @property
107
+ def related_users(self):
108
+ return set()
109
+
105
110
  def notification_subscribers(self, event_name=None, digest=None):
106
- from notificationcenter.models import default_center as notification_center
107
111
  notification_name = self.notification_name_for_event(event_name)
108
112
  if digest is None:
109
113
  return notification_center.subscribers(notification_name, sender=self, digest=True) | \
@@ -123,13 +127,9 @@ class ModelBase(models.Model):
123
127
  def digest_subscribers(self):
124
128
  return self.notification_subscribers(digest=True)
125
129
 
126
- @property
127
- def notification_mail_classes(self):
128
- return {}
129
-
130
130
  def notification_name_for_event(self, event_name=None):
131
131
  content_type = ContentType.objects.get_for_model(self)
132
- name_components = [content_type.model]
132
+ name_components = [content_type.app_label, content_type.model]
133
133
  if event_name is not None:
134
134
  if isinstance(event_name, str):
135
135
  name_components.append(event_name)
@@ -138,45 +138,23 @@ class ModelBase(models.Model):
138
138
 
139
139
  return ':'.join(name_components)
140
140
 
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
-
150
- email = EmailClass(self, request=request)
151
- email.render()
152
141
 
153
- notification_context = {
154
- 'creator': request.user.id,
155
- #'headers': email.extra_headers,
156
- }
142
+ def notify_users(self, event_type, date_scheduled=None, **kwargs):
143
+ """
144
+ Perform notification(s) in response to the given event type.
145
+ """
146
+ created_by = None
147
+ request = kwargs.get('request')
148
+ if request and request.user.is_authenticated:
149
+ created_by = request.user
157
150
 
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
151
  notification_center.post_notification(
162
- notification_name,
152
+ self.notification_name_for_event(event_type),
153
+ created_by,
163
154
  self,
164
- email.subject,
165
- text=email.body,
166
- html=email.html,
167
- context=notification_context,
168
- notify_immediately=False
155
+ context={'date_scheduled': date_scheduled}
169
156
  )
170
157
 
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
158
 
181
159
  class Place(ModelBase):
182
160
  place_id = models.CharField(max_length=255, unique=True)
@@ -433,17 +411,6 @@ class UserGroup(Document):
433
411
 
434
412
 
435
413
  # ------------------------------------------------------------------------------
436
- document_event = Signal()
437
- def document_event_signal_receiver(sender, type, **kwargs):
438
- """
439
- Send notification email to users subscribed and/or concerned with the event
440
- of "type" that occurred on the given sender (Document)
441
- """
442
- sender.notify_users(type, **kwargs)
443
- document_event.connect(
444
- document_event_signal_receiver,
445
- dispatch_uid='document_event_signal_receiver'
446
- )
447
-
414
+ document_event = ModelSignal(use_caching=True)
448
415
 
449
416
  get_current_site = appkit_settings.CURRENT_SITE_ACCESSOR
@@ -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.7
3
+ Version: 1.3.9
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 :: 3.1
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
@@ -4,14 +4,17 @@ README.md
4
4
  setup.cfg
5
5
  setup.py
6
6
  appkit/__init__.py
7
+ appkit/apps.py
7
8
  appkit/debug.py
8
- appkit/email.py
9
+ appkit/handlers.py
9
10
  appkit/managers.py
10
11
  appkit/models.py
12
+ appkit/notification.py
11
13
  appkit/settings.py
12
14
  appkit/shortcuts.py
13
15
  appkit/storages.py
14
16
  appkit/tasks.py
17
+ appkit/tests.py
15
18
  appkit/transformers.py
16
19
  appkit/util.py
17
20
  appkit/views.py
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = drf-appkit
3
- version = 1.3.7
3
+ version = 1.3.9
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 :: 3.1
11
+ Framework :: Django :: 4.2
12
12
  Intended Audience :: Developers
13
13
  License :: OSI Approved :: BSD License
14
14
  Operating System :: OS Independent
@@ -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