drf-appkit 1.4.7__tar.gz → 1.4.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.
- {drf_appkit-1.4.7/drf_appkit.egg-info → drf_appkit-1.4.9}/PKG-INFO +1 -1
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/api/views.py +3 -1
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/notification.py +6 -1
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/shortcuts.py +25 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/util.py +0 -70
- {drf_appkit-1.4.7 → drf_appkit-1.4.9/drf_appkit.egg-info}/PKG-INFO +1 -1
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/setup.cfg +1 -1
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/LICENSE +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/MANIFEST.in +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/README.md +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/__init__.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/api/__init__.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/api/filters.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/api/mixins.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/api/pagination.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/api/relations.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/api/renderers.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/api/serializers.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/api/tests.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/apps.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/auth/__init__.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/auth/backends.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/auth/decorators.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/auth/email.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/auth/permissions.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/debug.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf/__init__.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf/adapters.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf/authentication.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf/backends.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf/endpoints.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf/exceptions.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf/fields.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf/filters.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf/mixins.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf/permissions.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf/serializers.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf_appkit.egg-info/PKG-INFO +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf_appkit.egg-info/SOURCES.txt +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf_appkit.egg-info/dependency_links.txt +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/drf_appkit.egg-info/top_level.txt +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/forms/__init__.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/forms/widgets.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/handlers.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/jinja2/appkit/forms/widgets/money_widget.html +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/managers.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0001_initial.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0002_arrangement_tags.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0003_auto_20210221_0852.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0004_auto_20210309_0655.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0005_auto_20210324_1046.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0006_sitealias.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0007_auto_20211021_1901.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0008_update_autofields.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0009_alter_arrangement_unique_together_and_more.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0010_arrangement_name.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0011_alter_sitealias_options.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0012_alter_sitealias_site.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0013_usergroup.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0014_remove_note_notes_note_content_type_note_object_id.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0015_alter_note_content_type_alter_note_object_id.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0016_alter_arrangementitem_unique_together_and_more.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0017_alter_imageattachment_image.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0018_place_geoposition.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0019_alter_place_geoposition.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0020_remove_arrangement_type_arrangement_content_type.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0021_rename_content_type_arrangement_item_type.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0022_imageattachment_rendition_key_imageattachment_warm.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0023_delete_usergroup.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/0024_place_city_place_country_place_postal_code_and_more.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/migrations/__init__.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/models.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/settings.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/storages.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/tasks.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/tests.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/transformers.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/appkit/views.py +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/drf_appkit.egg-info/SOURCES.txt +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/drf_appkit.egg-info/dependency_links.txt +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/drf_appkit.egg-info/top_level.txt +0 -0
- {drf_appkit-1.4.7 → drf_appkit-1.4.9}/setup.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from django.contrib.auth.models import Group
|
|
2
2
|
from django.core.exceptions import FieldError
|
|
3
|
-
|
|
3
|
+
from django.core.exceptions import ObjectDoesNotExist
|
|
4
|
+
from django.db import transaction
|
|
4
5
|
from rest_framework import exceptions, viewsets, status
|
|
5
6
|
from rest_framework.decorators import action
|
|
6
7
|
from rest_framework.filters import (
|
|
@@ -244,6 +245,7 @@ class MasterDetailViewSet(
|
|
|
244
245
|
|
|
245
246
|
super().perform_create(serializer)
|
|
246
247
|
|
|
248
|
+
@transaction.atomic
|
|
247
249
|
def create(self, request, *args, **kwargs):
|
|
248
250
|
"""
|
|
249
251
|
When a record is created we want to send back its full details
|
|
@@ -48,7 +48,12 @@ class AppkitEmailMessage(EmailMessage):
|
|
|
48
48
|
|
|
49
49
|
self.context['allow_reply'] = True if self.reply_to else False
|
|
50
50
|
|
|
51
|
-
super(
|
|
51
|
+
send_result = super().send(*args, **kwargs)
|
|
52
|
+
if send_result:
|
|
53
|
+
print('send success')
|
|
54
|
+
else:
|
|
55
|
+
print('send fail')
|
|
56
|
+
|
|
52
57
|
|
|
53
58
|
|
|
54
59
|
class AppkitSMSMessage:
|
|
@@ -322,3 +322,28 @@ def send_sms(destination, message):
|
|
|
322
322
|
logger = logging.getLogger("plivo")
|
|
323
323
|
logger.log(logging.ERROR, str(e))
|
|
324
324
|
return False
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
def pagination_links(request, page):
|
|
328
|
+
pagination_querydict = request.GET.copy()
|
|
329
|
+
if 'page' in pagination_querydict:
|
|
330
|
+
del pagination_querydict['page']
|
|
331
|
+
pagination_querystring = pagination_querydict.urlencode()
|
|
332
|
+
|
|
333
|
+
paginator = page.paginator
|
|
334
|
+
|
|
335
|
+
previous_page = None
|
|
336
|
+
if page.has_previous():
|
|
337
|
+
previous_page = f'?page={page.previous_page_number()}&{pagination_querystring}'.rstrip('&')
|
|
338
|
+
|
|
339
|
+
next_page = None
|
|
340
|
+
if page.has_next():
|
|
341
|
+
next_page = f'?page={page.next_page_number()}&{pagination_querystring}'.rstrip('&')
|
|
342
|
+
|
|
343
|
+
return {
|
|
344
|
+
'first': f'?page=1&{pagination_querystring}'.rstrip('&'),
|
|
345
|
+
'last': f'?page={paginator.num_pages}&{pagination_querystring}'.rstrip('&'),
|
|
346
|
+
'previous': previous_page or '',
|
|
347
|
+
'next': next_page or '',
|
|
348
|
+
}
|
|
349
|
+
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
import hashlib
|
|
3
|
-
import imp
|
|
4
3
|
import inspect
|
|
5
4
|
import ipaddress
|
|
6
5
|
import json
|
|
@@ -104,75 +103,6 @@ def path_components(string, separator='/'):
|
|
|
104
103
|
return [element] + path_components(rest, separator)
|
|
105
104
|
|
|
106
105
|
|
|
107
|
-
def get_module_from_path(module_path, search_path=None):
|
|
108
|
-
"""
|
|
109
|
-
Return the module associate with the given path (e.g. 'django.db'), loading the
|
|
110
|
-
module if necessary. Returns None if the named module cannot be found.
|
|
111
|
-
"""
|
|
112
|
-
if module_path is None:
|
|
113
|
-
return None
|
|
114
|
-
|
|
115
|
-
# Lookup the module path in python's dictionary of loaded modules...
|
|
116
|
-
module = sys.modules.get(module_path)
|
|
117
|
-
if module is None:
|
|
118
|
-
def _get_module(module_name, parent_module=None):
|
|
119
|
-
module_path = parent_module.__name__ + '.' + module_name if parent_module else module_name
|
|
120
|
-
module = sys.modules.get(module_path)
|
|
121
|
-
if module is None:
|
|
122
|
-
(file, path, desc) = imp.find_module(module_name, parent_module.__path__ if parent_module else search_path)
|
|
123
|
-
if file or path:
|
|
124
|
-
try:
|
|
125
|
-
module = imp.load_module(module_path, file, path, desc)
|
|
126
|
-
except Exception as e:
|
|
127
|
-
raise Exception("failed to load '%s' -- %s" % (path, e.message))
|
|
128
|
-
finally:
|
|
129
|
-
if file:
|
|
130
|
-
file.close()
|
|
131
|
-
return module
|
|
132
|
-
for component in path_components(module_path, '.'):
|
|
133
|
-
parent_module = module
|
|
134
|
-
module = _get_module(component, parent_module)
|
|
135
|
-
if module is None:
|
|
136
|
-
logger = logging.getLogger('alpha')
|
|
137
|
-
if parent_module:
|
|
138
|
-
logger.info("module '%s' has no component named '%s'" % (parent_module.__path__, component))
|
|
139
|
-
else:
|
|
140
|
-
logger.info("unknown top-level module '%s"'' % component)
|
|
141
|
-
break
|
|
142
|
-
|
|
143
|
-
return module
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
def get_path_from_class(cls):
|
|
147
|
-
"""
|
|
148
|
-
Return the relative path of the given class in the form <module-path>.<class-name>.
|
|
149
|
-
"""
|
|
150
|
-
return '{}.{}'.format(cls.__module__, cls.__name__)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
def get_class_from_path(path, superclass=None, search_path=None):
|
|
154
|
-
"""
|
|
155
|
-
Return the class object corresponding to the given path, which has the
|
|
156
|
-
form <module-path>.<class-name>.
|
|
157
|
-
"""
|
|
158
|
-
module_path, class_name = string.rsplit(path, '.', 1)
|
|
159
|
-
module = get_module_from_path(module_path, search_path)
|
|
160
|
-
return get_class_from_module(module, class_name, superclass) if module else None
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
def get_class_from_module(module, class_name, superclass=None):
|
|
164
|
-
"""
|
|
165
|
-
Return the named class from the given module; optionally require the class
|
|
166
|
-
be derived from the given superclass.
|
|
167
|
-
"""
|
|
168
|
-
cls = module.__dict__.get(class_name)
|
|
169
|
-
if not inspect.isclass(cls):
|
|
170
|
-
raise Exception("module '{}' has no class-valued attribute '{}'".format(module.__name__, class_name))
|
|
171
|
-
if superclass and not issubclass(cls, superclass):
|
|
172
|
-
raise Exception("class '{}' of module '{}' is not derived from class '{}'".format(class_name, module.__name__, superclass.__name__))
|
|
173
|
-
return cls
|
|
174
|
-
|
|
175
|
-
|
|
176
106
|
def assign_timestamps(obj, date_created, date_modified):
|
|
177
107
|
with connections[obj._state.db].cursor() as cursor:
|
|
178
108
|
query_template = "UPDATE {trg_table_name} SET date_created='{date_created}',date_modified='{date_modified}' WHERE id={pk}"
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|