slthcore 0.8.0__tar.gz → 0.8.2__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.
- {slthcore-0.8.0/slthcore.egg-info → slthcore-0.8.2}/PKG-INFO +1 -1
- {slthcore-0.8.0 → slthcore-0.8.2}/setup.py +1 -1
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/components.py +2 -1
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/models.py +1 -1
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/queryset.py +61 -25
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/serializer.py +2 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/static/js/slth.min.js +13 -13
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/templates/index.html +4 -1
- {slthcore-0.8.0 → slthcore-0.8.2/slthcore.egg-info}/PKG-INFO +1 -1
- {slthcore-0.8.0 → slthcore-0.8.2}/MANIFEST.in +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/setup.cfg +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/application.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/apps.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/configure/__main__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/__main__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/__pycache__/__main__.cpython-312.pyc +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/.DS_Store +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/.gitignore +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/backend/api/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/backend/api/asgi.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/backend/api/endpoints/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/backend/api/models.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/backend/api/settings.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/backend/api/tests.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/backend/api/urls.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/backend/api/wsgi.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/backend/entrypoint.sh +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/backend/manage.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/backend/requirements.txt +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/base.env +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/docker-compose.yml +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/frontend/package.json +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/frontend/src/main.jsx +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/frontend/vite.config.js +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/local.env +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/run.sh +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/selenium/run.sh +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/cmd/init/boilerplate/test.sh +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/db/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/db/generic.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/db/models.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/auth.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/deletion.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/dev.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/email.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/job.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/log.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/profile.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/pushsubscription.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/report.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/role.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/settings.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/task.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/timezone.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/user.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/endpoints/whatsappnotification.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/exceptions.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/factory.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/forms.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/geo/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/integrations/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/integrations/deepseek/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/integrations/google/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/integrations/google/gemini.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/integrations/google/places.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/integrations/google/vision.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/integrations/justvoip/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/integrations/mercadopago/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/integrations/openai/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/integrations/openai/chatgpt.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/integrations/viacep/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/integrations/whatsapp/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/management/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/management/commands/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/management/commands/api.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/management/commands/integration_test.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/management/commands/sync.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/management/commands/worker.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/middleware/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/middleware/timezone.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0001_initial.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0002_email_role_pushsubscription_error.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0003_rename_photo_profile_alter_profile_options.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0004_alter_profile_photo.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0005_alter_profile_photo.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0006_user.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0007_deletion_log.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0008_alter_deletion_datetime_alter_log_datetime.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0009_remove_email_from_email_email_action_email_attempt_and_more.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0010_email_key_alter_email_action_alter_email_attempt_and_more.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0011_usertimezone.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0012_timezone_remove_usertimezone_key_and_more.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0013_whatsappnotification.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0014_settings.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/0015_auto_20250412_1126.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/migrations/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/notifications.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/oauth.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/pdf/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/pdf/tests.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/permissions.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/printer.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/roles.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/selenium/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/selenium/browser.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/static/.DS_Store +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/static/css/.DS_Store +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/static/css/slth.css +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/static/images/placeholder.png +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/static/js/index.min.js +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/static/js/react.min.js +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/statistics.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/storage/__init__.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/storage/s3.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/tasks.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/templates/email.html +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/templates/report.html +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/templates/service-worker.js +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/templates/signature.html +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/tests.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/threadlocal.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/timezone.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/urls.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/utils.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slth/views.py +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slthcore.egg-info/SOURCES.txt +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slthcore.egg-info/dependency_links.txt +0 -0
- {slthcore-0.8.0 → slthcore-0.8.2}/slthcore.egg-info/top_level.txt +0 -0
|
@@ -186,7 +186,7 @@ class TemplateContent(dict):
|
|
|
186
186
|
|
|
187
187
|
class GeoMap(dict):
|
|
188
188
|
|
|
189
|
-
def __init__(self, lat=0, lon=0, zoom=10, min_zoom=None, max_zoom=None, title=None):
|
|
189
|
+
def __init__(self, lat=0, lon=0, zoom=10, min_zoom=None, max_zoom=None, title=None, heatmap=False):
|
|
190
190
|
self["type"] = "geomap"
|
|
191
191
|
self["title"] = title
|
|
192
192
|
self["lat"] = lat
|
|
@@ -196,6 +196,7 @@ class GeoMap(dict):
|
|
|
196
196
|
self["max_zoom"] = max_zoom or zoom
|
|
197
197
|
self["polygons"] = []
|
|
198
198
|
self["points"] = []
|
|
199
|
+
self["heatmap"] = heatmap
|
|
199
200
|
|
|
200
201
|
def to_html(self, info):
|
|
201
202
|
if isinstance(info, dict):
|
|
@@ -626,7 +626,7 @@ class TimeZone(models.Model):
|
|
|
626
626
|
return self.name
|
|
627
627
|
|
|
628
628
|
def localtime(self, value):
|
|
629
|
-
return timezone.get_timezone(self.name).localize(value).astimezone(timezone.
|
|
629
|
+
return timezone.get_timezone(self.name).localize(value).astimezone(timezone.get_current_timezone()).replace(tzinfo=None) if value else None
|
|
630
630
|
|
|
631
631
|
|
|
632
632
|
class UserTimeZone(models.Model):
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import csv
|
|
1
3
|
import slth
|
|
2
4
|
import pickle
|
|
3
5
|
import base64
|
|
4
6
|
import zlib
|
|
7
|
+
import zipfile
|
|
8
|
+
from django.conf import settings
|
|
5
9
|
from django.apps import apps
|
|
6
10
|
from django.db import models
|
|
7
11
|
from django.db.models import manager, Q, CharField, CASCADE
|
|
@@ -226,7 +230,7 @@ class QuerySet(models.QuerySet):
|
|
|
226
230
|
conditions = []
|
|
227
231
|
for term in terms:
|
|
228
232
|
queries = [
|
|
229
|
-
Q(**{lookup: term})
|
|
233
|
+
Q(**{lookup.replace('__icontains', '__unaccent__icontains'): term}) if 'django.contrib.postgres' in settings.INSTALLED_APPS else Q(**{lookup: term})
|
|
230
234
|
for lookup in lookups
|
|
231
235
|
]
|
|
232
236
|
conditions.append(reduce(operator.or_, queries))
|
|
@@ -243,6 +247,60 @@ class QuerySet(models.QuerySet):
|
|
|
243
247
|
if debug:
|
|
244
248
|
print(json.dumps(e.data, indent=2, ensure_ascii=False))
|
|
245
249
|
return e.data
|
|
250
|
+
|
|
251
|
+
def to_rows(self, chunk_size=1000):
|
|
252
|
+
header = []
|
|
253
|
+
rows = []
|
|
254
|
+
serializer = Serializer(None, self.request).fields(*self.metadata['xlsx'])
|
|
255
|
+
for i, obj in enumerate(self.iterator(chunk_size=chunk_size)):
|
|
256
|
+
if i % 1000 == 0: print(i)
|
|
257
|
+
row = []
|
|
258
|
+
serializer.obj = obj
|
|
259
|
+
serialized = serializer.serialize(forward_exception=True)
|
|
260
|
+
for item in serialized['data']:
|
|
261
|
+
if i == 0:
|
|
262
|
+
header.append(item['label'])
|
|
263
|
+
if item.get('type') == 'field':
|
|
264
|
+
row.append(item['value'])
|
|
265
|
+
if i == 0:
|
|
266
|
+
rows.append(header)
|
|
267
|
+
rows.append(row)
|
|
268
|
+
return rows
|
|
269
|
+
|
|
270
|
+
def to_xlsx(self, chunk_size=1000):
|
|
271
|
+
file = tempfile.NamedTemporaryFile(suffix='.xlsx', mode='w+b', delete=False)
|
|
272
|
+
workbook = xlsxwriter.Workbook(file)
|
|
273
|
+
worksheet = workbook.add_worksheet('A')
|
|
274
|
+
for row_idx, row_data in enumerate(self.to_rows(chunk_size)):
|
|
275
|
+
for col_idx, col in enumerate(row_data):
|
|
276
|
+
worksheet.write(row_idx, col_idx, col)
|
|
277
|
+
workbook.close()
|
|
278
|
+
file.close()
|
|
279
|
+
return file
|
|
280
|
+
|
|
281
|
+
def to_csv(self, chunk_size=1000):
|
|
282
|
+
file = tempfile.NamedTemporaryFile(suffix='.csv', mode='w', delete=False)
|
|
283
|
+
writer = csv.writer(file)
|
|
284
|
+
writer.writerows(self.to_rows(chunk_size))
|
|
285
|
+
return file
|
|
286
|
+
|
|
287
|
+
def to_file(self):
|
|
288
|
+
total = self.count()
|
|
289
|
+
if total < 10000:
|
|
290
|
+
file = self.to_xlsx()
|
|
291
|
+
file_path = file.name
|
|
292
|
+
content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
293
|
+
elif total < 30000:
|
|
294
|
+
file = self.to_csv()
|
|
295
|
+
file_path = file.name
|
|
296
|
+
content_type = 'text/csv'
|
|
297
|
+
else:
|
|
298
|
+
file = self.to_csv()
|
|
299
|
+
file_path = file.name.replace('.csv', '.zip')
|
|
300
|
+
with zipfile.ZipFile(file_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
|
301
|
+
zipf.write(file.name, arcname='download.csv')
|
|
302
|
+
content_type = 'application/x-zip-compressed:'
|
|
303
|
+
return file_path, content_type
|
|
246
304
|
|
|
247
305
|
def to_dict(self, debug=False):
|
|
248
306
|
title = self.metadata.get('title', str(self.model._meta.verbose_name_plural))
|
|
@@ -268,30 +326,8 @@ class QuerySet(models.QuerySet):
|
|
|
268
326
|
queryset_actions = []
|
|
269
327
|
|
|
270
328
|
if self.request and self.request.GET.get('xlsx'):
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
worksheet = workbook.add_worksheet('A')
|
|
274
|
-
header = []
|
|
275
|
-
rows = []
|
|
276
|
-
serializer = Serializer(None, self.request).fields(*self.metadata['xlsx'])
|
|
277
|
-
for i, obj in enumerate(self):
|
|
278
|
-
row = []
|
|
279
|
-
serializer.obj = obj
|
|
280
|
-
serialized = serializer.serialize(forward_exception=True)
|
|
281
|
-
for item in serialized['data']:
|
|
282
|
-
if i == 0:
|
|
283
|
-
header.append(item['label'])
|
|
284
|
-
if item.get('type') == 'field':
|
|
285
|
-
row.append(item['value'])
|
|
286
|
-
if i == 0:
|
|
287
|
-
rows.append(header)
|
|
288
|
-
rows.append(row)
|
|
289
|
-
for row_idx, row_data in enumerate(rows):
|
|
290
|
-
for col_idx, col in enumerate(row_data):
|
|
291
|
-
worksheet.write(row_idx, col_idx, col)
|
|
292
|
-
workbook.close()
|
|
293
|
-
file.close()
|
|
294
|
-
raise ReadyResponseException(FileResponse(open(file.name, 'rb'), content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'))
|
|
329
|
+
file_path, content_type = self.to_file()
|
|
330
|
+
raise ReadyResponseException(FileResponse(open(file_path, 'rb'), content_type=content_type))
|
|
295
331
|
|
|
296
332
|
if self.request and 'action' in self.request.GET:
|
|
297
333
|
cls = slth.ENDPOINTS[self.request.GET.get('action')]
|
|
@@ -247,6 +247,8 @@ class Serializer:
|
|
|
247
247
|
|
|
248
248
|
def check_role(self, names):
|
|
249
249
|
from slth.models import Role
|
|
250
|
+
if not self.request:
|
|
251
|
+
return True
|
|
250
252
|
return self.request.user.is_superuser or not names or Role.objects.filter(username=self.request.user.username, name__in=names).exists()
|
|
251
253
|
|
|
252
254
|
def to_dict(self, debug=False):
|