slthcore 0.5.0__tar.gz → 0.5.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.
Potentially problematic release.
This version of slthcore might be problematic. Click here for more details.
- {slthcore-0.5.0/slthcore.egg-info → slthcore-0.5.2}/PKG-INFO +1 -1
- {slthcore-0.5.0 → slthcore-0.5.2}/setup.py +1 -1
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/db/models.py +3 -12
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/__init__.py +4 -1
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/auth.py +5 -2
- slthcore-0.5.2/slth/middleware/timezone.py +15 -0
- slthcore-0.5.2/slth/migrations/0015_auto_20250412_1126.py +27 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/models.py +2 -3
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/serializer.py +4 -1
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/static/js/slth.min.js +11 -11
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/templates/index.html +1 -1
- slthcore-0.5.2/slth/timezone.py +33 -0
- {slthcore-0.5.0 → slthcore-0.5.2/slthcore.egg-info}/PKG-INFO +1 -1
- {slthcore-0.5.0 → slthcore-0.5.2}/slthcore.egg-info/SOURCES.txt +2 -1
- slthcore-0.5.0/slth/middleware/timezone.py +0 -28
- slthcore-0.5.0/slth/tz.py +0 -13
- {slthcore-0.5.0 → slthcore-0.5.2}/MANIFEST.in +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/setup.cfg +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/application.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/apps.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/configure/__main__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/__main__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/__pycache__/__main__.cpython-312.pyc +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/.DS_Store +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/.gitignore +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/asgi.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/endpoints/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/models.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/settings.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/tests.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/urls.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/wsgi.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/entrypoint.sh +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/manage.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/requirements.txt +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/base.env +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/docker-compose.yml +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/frontend/package.json +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/frontend/src/main.jsx +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/frontend/vite.config.js +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/local.env +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/run.sh +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/selenium/run.sh +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/test.sh +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/components.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/db/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/db/generic.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/deletion.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/dev.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/email.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/job.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/log.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/profile.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/pushsubscription.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/report.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/role.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/settings.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/task.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/timezone.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/user.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/whatsappnotification.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/exceptions.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/factory.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/forms.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/deepseek/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/google/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/google/gemini.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/google/places.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/google/vision.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/justvoip/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/mercadopago/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/openai/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/openai/chatgpt.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/viacep/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/whatsapp/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/management/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/management/commands/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/management/commands/api.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/management/commands/integration_test.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/management/commands/sync.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/management/commands/worker.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/middleware/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0001_initial.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0002_email_role_pushsubscription_error.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0003_rename_photo_profile_alter_profile_options.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0004_alter_profile_photo.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0005_alter_profile_photo.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0006_user.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0007_deletion_log.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0008_alter_deletion_datetime_alter_log_datetime.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0009_remove_email_from_email_email_action_email_attempt_and_more.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0010_email_key_alter_email_action_alter_email_attempt_and_more.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0011_usertimezone.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0012_timezone_remove_usertimezone_key_and_more.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0013_whatsappnotification.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0014_settings.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/notifications.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/oauth.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/pdf/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/pdf/tests.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/permissions.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/printer.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/queryset.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/roles.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/selenium/__init__.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/selenium/browser.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/static/.DS_Store +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/static/css/.DS_Store +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/static/css/slth.css +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/static/images/placeholder.png +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/static/js/index.min.js +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/static/js/react.min.js +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/statistics.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/tasks.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/templates/email.html +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/templates/report.html +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/templates/service-worker.js +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/templates/signature.html +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/tests.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/threadlocal.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/urls.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/utils.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slth/views.py +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slthcore.egg-info/dependency_links.txt +0 -0
- {slthcore-0.5.0 → slthcore-0.5.2}/slthcore.egg-info/top_level.txt +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
from uuid import uuid1
|
|
2
|
-
import pytz
|
|
3
|
-
from datetime import datetime, timedelta
|
|
4
|
-
from django.utils import timezone
|
|
5
2
|
from django.db.models import Model as DjangoModel, fields as DjangoFields
|
|
6
3
|
from django.db.models import *
|
|
7
4
|
from django.utils.translation import gettext_lazy as _
|
|
8
5
|
from . import generic
|
|
9
6
|
from .. import ModelMixin
|
|
10
7
|
from slth import dumps, loads
|
|
8
|
+
from slth import timezone
|
|
11
9
|
|
|
12
10
|
GenericField = generic.GenericField
|
|
13
11
|
|
|
@@ -116,16 +114,10 @@ class TextField(TextField):
|
|
|
116
114
|
class DateTimeField(DateTimeField):
|
|
117
115
|
|
|
118
116
|
def get_db_prep_value(self, value, *args, **kwargs):
|
|
119
|
-
return
|
|
117
|
+
return timezone.get_default_timezone().localize(value).astimezone(timezone.get_current_timezone()).replace(tzinfo=None) if value else None
|
|
120
118
|
|
|
121
119
|
def from_db_value(self, value, *args, **kwargs):
|
|
122
|
-
return
|
|
123
|
-
|
|
124
|
-
def get_current_timezone(self):
|
|
125
|
-
current_timezone_name = timezone.get_current_timezone_name()
|
|
126
|
-
if current_timezone_name and current_timezone_name[0] in ('+', '-'):
|
|
127
|
-
current_timezone_name = "Etc/GMT{}".format(int(current_timezone_name))
|
|
128
|
-
return pytz.timezone(current_timezone_name)
|
|
120
|
+
return timezone.get_current_timezone().localize(value).astimezone(timezone.get_default_timezone()).replace(tzinfo=None) if value else None
|
|
129
121
|
|
|
130
122
|
|
|
131
123
|
class TaskFied(TextField):
|
|
@@ -154,7 +146,6 @@ class FileField(FileField):
|
|
|
154
146
|
|
|
155
147
|
def generate_filename(self, instance, filename):
|
|
156
148
|
filename = '{}.{}'.format(uuid1().hex, filename.split('.')[-1].lower())
|
|
157
|
-
print(filename)
|
|
158
149
|
return super().generate_filename(instance, filename)
|
|
159
150
|
|
|
160
151
|
class ImageField(ImageField):
|
|
@@ -136,7 +136,10 @@ class Endpoint(metaclass=EnpointMetaclass):
|
|
|
136
136
|
doc = HTML(string=html).render()
|
|
137
137
|
pages.extend(doc.pages)
|
|
138
138
|
new_doc = doc.copy(pages=pages)
|
|
139
|
-
|
|
139
|
+
try:
|
|
140
|
+
new_doc.write_pdf(buffer, base_url=base_url, stylesheets=[])
|
|
141
|
+
except Exception:
|
|
142
|
+
new_doc.write_pdf(buffer)
|
|
140
143
|
buffer.seek(0)
|
|
141
144
|
raise ReadyResponseException(HttpResponse(buffer, content_type='application/pdf'))
|
|
142
145
|
return TemplateContent(template, data, autoreload=autoreload)
|
|
@@ -12,12 +12,15 @@ from django.utils import timezone
|
|
|
12
12
|
def login_response(user, redirect='/api/dashboard/'):
|
|
13
13
|
token = Token.objects.create(user=user)
|
|
14
14
|
current_timezone = timezone.get_current_timezone()
|
|
15
|
-
|
|
15
|
+
current_timezone_name = current_timezone.__str__()
|
|
16
|
+
timezone_instance = TimeZone.objects.filter(name=current_timezone_name).first()
|
|
17
|
+
if timezone_instance is None:
|
|
18
|
+
timezone_instance = TimeZone.objects.create(name=current_timezone_name)
|
|
16
19
|
user_timezone = UserTimeZone.objects.filter(user=user).first()
|
|
17
20
|
if user_timezone is None:
|
|
18
21
|
UserTimeZone.objects.create(user=user, timezone=timezone_instance)
|
|
19
22
|
else:
|
|
20
|
-
user_timezone.
|
|
23
|
+
user_timezone.timezone = timezone_instance
|
|
21
24
|
user_timezone.save()
|
|
22
25
|
return Response(
|
|
23
26
|
message="Bem-vindo!",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from slth import timezone
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Middleware:
|
|
5
|
+
def __init__(self, get_response):
|
|
6
|
+
self.get_response = get_response
|
|
7
|
+
|
|
8
|
+
def __call__(self, request):
|
|
9
|
+
tz = request.path[0] == '/' and (request.META.get('HTTP_TZ') or request.META.get('TZ'))
|
|
10
|
+
if tz:
|
|
11
|
+
timezone.activate(tz)
|
|
12
|
+
response = self.get_response(request)
|
|
13
|
+
if tz:
|
|
14
|
+
timezone.deactivate()
|
|
15
|
+
return response
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Generated by Django 5.1.1 on 2025-04-12 11:26
|
|
2
|
+
|
|
3
|
+
from django.db import migrations
|
|
4
|
+
from slth import timezone
|
|
5
|
+
|
|
6
|
+
def migrate(apps, editor):
|
|
7
|
+
TimeZone = apps.get_model('slth', 'TimeZone')
|
|
8
|
+
TimeZone.objects.filter(name='Etc/GMT+4').update(name='Etc/GMT-4')
|
|
9
|
+
TimeZone.objects.filter(name='Etc/GMT+3').update(name='Etc/GMT-3')
|
|
10
|
+
for instance in TimeZone.objects.all():
|
|
11
|
+
name = timezone.get_timezone(instance.name).zone
|
|
12
|
+
print(instance.name, name)
|
|
13
|
+
instance.name = name
|
|
14
|
+
instance.save()
|
|
15
|
+
|
|
16
|
+
def unmigrate(apps, editor):
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
class Migration(migrations.Migration):
|
|
20
|
+
|
|
21
|
+
dependencies = [
|
|
22
|
+
("slth", "0014_settings"),
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
operations = [
|
|
26
|
+
migrations.RunPython(migrate, unmigrate)
|
|
27
|
+
]
|
|
@@ -4,6 +4,7 @@ import pytz
|
|
|
4
4
|
import binascii
|
|
5
5
|
from uuid import uuid1
|
|
6
6
|
import traceback
|
|
7
|
+
from . import timezone
|
|
7
8
|
from .db import models, meta
|
|
8
9
|
from django.conf import settings
|
|
9
10
|
from django.utils.translation import gettext_lazy as _
|
|
@@ -18,7 +19,6 @@ from django.template.loader import render_to_string
|
|
|
18
19
|
from django.core.mail import EmailMultiAlternatives
|
|
19
20
|
from .notifications import send_push_web_notification, send_whatsapp_notification
|
|
20
21
|
from .components import HtmlContent
|
|
21
|
-
from django.utils import timezone
|
|
22
22
|
from slth.application import Application as ApplicationConfig
|
|
23
23
|
from django.contrib.auth.models import BaseUserManager
|
|
24
24
|
|
|
@@ -611,8 +611,7 @@ class TimeZone(models.Model):
|
|
|
611
611
|
return self.name
|
|
612
612
|
|
|
613
613
|
def localtime(self, value):
|
|
614
|
-
|
|
615
|
-
return value_in_default_time_zone.astimezone(pytz.timezone(self.name)).replace(tzinfo=None)
|
|
614
|
+
return timezone.get_timezone(self.name).localize(value).astimezone(timezone.get_default_timezone()).replace(tzinfo=None) if value else None
|
|
616
615
|
|
|
617
616
|
|
|
618
617
|
class UserTimeZone(models.Model):
|
|
@@ -57,7 +57,10 @@ def serialize(obj, primitive=False, request=None, logging=False):
|
|
|
57
57
|
if logging:
|
|
58
58
|
return f'{obj.pk}:{str(obj)}'
|
|
59
59
|
else:
|
|
60
|
-
|
|
60
|
+
try:
|
|
61
|
+
return str(obj) if primitive else dict(pk=obj.pk, str="{}".format(obj))
|
|
62
|
+
except TypeError:
|
|
63
|
+
return str(obj) if primitive else dict(pk=obj.pk, str="?")
|
|
61
64
|
elif isinstance(obj, QuerySet) or isinstance(obj, Manager) or type(obj).__name__ == 'ManyRelatedManager':
|
|
62
65
|
if logging:
|
|
63
66
|
return [f'{obj.pk}:{str(obj)}' for obj in obj.filter()]
|