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.

Files changed (129) hide show
  1. {slthcore-0.5.0/slthcore.egg-info → slthcore-0.5.2}/PKG-INFO +1 -1
  2. {slthcore-0.5.0 → slthcore-0.5.2}/setup.py +1 -1
  3. {slthcore-0.5.0 → slthcore-0.5.2}/slth/db/models.py +3 -12
  4. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/__init__.py +4 -1
  5. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/auth.py +5 -2
  6. slthcore-0.5.2/slth/middleware/timezone.py +15 -0
  7. slthcore-0.5.2/slth/migrations/0015_auto_20250412_1126.py +27 -0
  8. {slthcore-0.5.0 → slthcore-0.5.2}/slth/models.py +2 -3
  9. {slthcore-0.5.0 → slthcore-0.5.2}/slth/serializer.py +4 -1
  10. {slthcore-0.5.0 → slthcore-0.5.2}/slth/static/js/slth.min.js +11 -11
  11. {slthcore-0.5.0 → slthcore-0.5.2}/slth/templates/index.html +1 -1
  12. slthcore-0.5.2/slth/timezone.py +33 -0
  13. {slthcore-0.5.0 → slthcore-0.5.2/slthcore.egg-info}/PKG-INFO +1 -1
  14. {slthcore-0.5.0 → slthcore-0.5.2}/slthcore.egg-info/SOURCES.txt +2 -1
  15. slthcore-0.5.0/slth/middleware/timezone.py +0 -28
  16. slthcore-0.5.0/slth/tz.py +0 -13
  17. {slthcore-0.5.0 → slthcore-0.5.2}/MANIFEST.in +0 -0
  18. {slthcore-0.5.0 → slthcore-0.5.2}/setup.cfg +0 -0
  19. {slthcore-0.5.0 → slthcore-0.5.2}/slth/__init__.py +0 -0
  20. {slthcore-0.5.0 → slthcore-0.5.2}/slth/application.py +0 -0
  21. {slthcore-0.5.0 → slthcore-0.5.2}/slth/apps.py +0 -0
  22. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/configure/__main__.py +0 -0
  23. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/__main__.py +0 -0
  24. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/__pycache__/__main__.cpython-312.pyc +0 -0
  25. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/.DS_Store +0 -0
  26. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/.gitignore +0 -0
  27. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/__init__.py +0 -0
  28. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/asgi.py +0 -0
  29. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/endpoints/__init__.py +0 -0
  30. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/models.py +0 -0
  31. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/settings.py +0 -0
  32. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/tests.py +0 -0
  33. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/urls.py +0 -0
  34. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/api/wsgi.py +0 -0
  35. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/entrypoint.sh +0 -0
  36. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/manage.py +0 -0
  37. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/backend/requirements.txt +0 -0
  38. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/base.env +0 -0
  39. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/docker-compose.yml +0 -0
  40. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/frontend/package.json +0 -0
  41. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/frontend/src/main.jsx +0 -0
  42. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/frontend/vite.config.js +0 -0
  43. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/local.env +0 -0
  44. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/run.sh +0 -0
  45. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/selenium/run.sh +0 -0
  46. {slthcore-0.5.0 → slthcore-0.5.2}/slth/cmd/init/boilerplate/test.sh +0 -0
  47. {slthcore-0.5.0 → slthcore-0.5.2}/slth/components.py +0 -0
  48. {slthcore-0.5.0 → slthcore-0.5.2}/slth/db/__init__.py +0 -0
  49. {slthcore-0.5.0 → slthcore-0.5.2}/slth/db/generic.py +0 -0
  50. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/deletion.py +0 -0
  51. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/dev.py +0 -0
  52. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/email.py +0 -0
  53. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/job.py +0 -0
  54. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/log.py +0 -0
  55. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/profile.py +0 -0
  56. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/pushsubscription.py +0 -0
  57. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/report.py +0 -0
  58. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/role.py +0 -0
  59. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/settings.py +0 -0
  60. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/task.py +0 -0
  61. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/timezone.py +0 -0
  62. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/user.py +0 -0
  63. {slthcore-0.5.0 → slthcore-0.5.2}/slth/endpoints/whatsappnotification.py +0 -0
  64. {slthcore-0.5.0 → slthcore-0.5.2}/slth/exceptions.py +0 -0
  65. {slthcore-0.5.0 → slthcore-0.5.2}/slth/factory.py +0 -0
  66. {slthcore-0.5.0 → slthcore-0.5.2}/slth/forms.py +0 -0
  67. {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/__init__.py +0 -0
  68. {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/deepseek/__init__.py +0 -0
  69. {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/google/__init__.py +0 -0
  70. {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/google/gemini.py +0 -0
  71. {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/google/places.py +0 -0
  72. {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/google/vision.py +0 -0
  73. {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/justvoip/__init__.py +0 -0
  74. {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/mercadopago/__init__.py +0 -0
  75. {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/openai/__init__.py +0 -0
  76. {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/openai/chatgpt.py +0 -0
  77. {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/viacep/__init__.py +0 -0
  78. {slthcore-0.5.0 → slthcore-0.5.2}/slth/integrations/whatsapp/__init__.py +0 -0
  79. {slthcore-0.5.0 → slthcore-0.5.2}/slth/management/__init__.py +0 -0
  80. {slthcore-0.5.0 → slthcore-0.5.2}/slth/management/commands/__init__.py +0 -0
  81. {slthcore-0.5.0 → slthcore-0.5.2}/slth/management/commands/api.py +0 -0
  82. {slthcore-0.5.0 → slthcore-0.5.2}/slth/management/commands/integration_test.py +0 -0
  83. {slthcore-0.5.0 → slthcore-0.5.2}/slth/management/commands/sync.py +0 -0
  84. {slthcore-0.5.0 → slthcore-0.5.2}/slth/management/commands/worker.py +0 -0
  85. {slthcore-0.5.0 → slthcore-0.5.2}/slth/middleware/__init__.py +0 -0
  86. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0001_initial.py +0 -0
  87. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0002_email_role_pushsubscription_error.py +0 -0
  88. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0003_rename_photo_profile_alter_profile_options.py +0 -0
  89. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0004_alter_profile_photo.py +0 -0
  90. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0005_alter_profile_photo.py +0 -0
  91. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0006_user.py +0 -0
  92. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0007_deletion_log.py +0 -0
  93. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0008_alter_deletion_datetime_alter_log_datetime.py +0 -0
  94. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0009_remove_email_from_email_email_action_email_attempt_and_more.py +0 -0
  95. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0010_email_key_alter_email_action_alter_email_attempt_and_more.py +0 -0
  96. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0011_usertimezone.py +0 -0
  97. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0012_timezone_remove_usertimezone_key_and_more.py +0 -0
  98. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0013_whatsappnotification.py +0 -0
  99. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/0014_settings.py +0 -0
  100. {slthcore-0.5.0 → slthcore-0.5.2}/slth/migrations/__init__.py +0 -0
  101. {slthcore-0.5.0 → slthcore-0.5.2}/slth/notifications.py +0 -0
  102. {slthcore-0.5.0 → slthcore-0.5.2}/slth/oauth.py +0 -0
  103. {slthcore-0.5.0 → slthcore-0.5.2}/slth/pdf/__init__.py +0 -0
  104. {slthcore-0.5.0 → slthcore-0.5.2}/slth/pdf/tests.py +0 -0
  105. {slthcore-0.5.0 → slthcore-0.5.2}/slth/permissions.py +0 -0
  106. {slthcore-0.5.0 → slthcore-0.5.2}/slth/printer.py +0 -0
  107. {slthcore-0.5.0 → slthcore-0.5.2}/slth/queryset.py +0 -0
  108. {slthcore-0.5.0 → slthcore-0.5.2}/slth/roles.py +0 -0
  109. {slthcore-0.5.0 → slthcore-0.5.2}/slth/selenium/__init__.py +0 -0
  110. {slthcore-0.5.0 → slthcore-0.5.2}/slth/selenium/browser.py +0 -0
  111. {slthcore-0.5.0 → slthcore-0.5.2}/slth/static/.DS_Store +0 -0
  112. {slthcore-0.5.0 → slthcore-0.5.2}/slth/static/css/.DS_Store +0 -0
  113. {slthcore-0.5.0 → slthcore-0.5.2}/slth/static/css/slth.css +0 -0
  114. {slthcore-0.5.0 → slthcore-0.5.2}/slth/static/images/placeholder.png +0 -0
  115. {slthcore-0.5.0 → slthcore-0.5.2}/slth/static/js/index.min.js +0 -0
  116. {slthcore-0.5.0 → slthcore-0.5.2}/slth/static/js/react.min.js +0 -0
  117. {slthcore-0.5.0 → slthcore-0.5.2}/slth/statistics.py +0 -0
  118. {slthcore-0.5.0 → slthcore-0.5.2}/slth/tasks.py +0 -0
  119. {slthcore-0.5.0 → slthcore-0.5.2}/slth/templates/email.html +0 -0
  120. {slthcore-0.5.0 → slthcore-0.5.2}/slth/templates/report.html +0 -0
  121. {slthcore-0.5.0 → slthcore-0.5.2}/slth/templates/service-worker.js +0 -0
  122. {slthcore-0.5.0 → slthcore-0.5.2}/slth/templates/signature.html +0 -0
  123. {slthcore-0.5.0 → slthcore-0.5.2}/slth/tests.py +0 -0
  124. {slthcore-0.5.0 → slthcore-0.5.2}/slth/threadlocal.py +0 -0
  125. {slthcore-0.5.0 → slthcore-0.5.2}/slth/urls.py +0 -0
  126. {slthcore-0.5.0 → slthcore-0.5.2}/slth/utils.py +0 -0
  127. {slthcore-0.5.0 → slthcore-0.5.2}/slth/views.py +0 -0
  128. {slthcore-0.5.0 → slthcore-0.5.2}/slthcore.egg-info/dependency_links.txt +0 -0
  129. {slthcore-0.5.0 → slthcore-0.5.2}/slthcore.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: slthcore
3
- Version: 0.5.0
3
+ Version: 0.5.2
4
4
  Summary: API generator based on yml file
5
5
  Home-page: https://github.com/brenokcc
6
6
  Author: Breno Silva
@@ -4,7 +4,7 @@ install_requires = []
4
4
 
5
5
  setup(
6
6
  name='slthcore',
7
- version='0.5.0',
7
+ version='0.5.2',
8
8
  packages=find_packages(),
9
9
  install_requires=install_requires,
10
10
  include_package_data=True,
@@ -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 self.get_current_timezone().localize(value).astimezone(timezone.get_default_timezone()).replace(tzinfo=None) if value else None
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 pytz.timezone(timezone.get_default_timezone_name()).localize(value).astimezone(self.get_current_timezone()).replace(tzinfo=None) if value else None
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
- new_doc.write_pdf(buffer, base_url=base_url, stylesheets=[])
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
- timezone_instance = TimeZone.objects.get_or_create(name=current_timezone.__str__())[0]
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.key = current_timezone.__str__()
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
- value_in_default_time_zone = pytz.timezone(timezone.get_current_timezone_name()).localize(value).astimezone(timezone.get_default_timezone()).replace(tzinfo=None)
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
- return str(obj) if primitive else dict(pk=obj.pk, str=str(obj))
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()]