slthcore 0.3.7__tar.gz → 0.3.8__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 (108) hide show
  1. {slthcore-0.3.7/slthcore.egg-info → slthcore-0.3.8}/PKG-INFO +1 -1
  2. {slthcore-0.3.7 → slthcore-0.3.8}/setup.py +1 -1
  3. {slthcore-0.3.7 → slthcore-0.3.8}/slth/endpoints/auth.py +10 -1
  4. slthcore-0.3.8/slth/endpoints/timezone.py +11 -0
  5. {slthcore-0.3.7 → slthcore-0.3.8}/slth/middleware/timezone.py +12 -9
  6. slthcore-0.3.8/slth/migrations/0011_usertimezone.py +31 -0
  7. slthcore-0.3.8/slth/migrations/0012_timezone_remove_usertimezone_key_and_more.py +37 -0
  8. {slthcore-0.3.7 → slthcore-0.3.8}/slth/models.py +32 -4
  9. slthcore-0.3.8/slth/tz.py +13 -0
  10. {slthcore-0.3.7 → slthcore-0.3.8/slthcore.egg-info}/PKG-INFO +1 -1
  11. {slthcore-0.3.7 → slthcore-0.3.8}/slthcore.egg-info/SOURCES.txt +4 -0
  12. {slthcore-0.3.7 → slthcore-0.3.8}/MANIFEST.in +0 -0
  13. {slthcore-0.3.7 → slthcore-0.3.8}/setup.cfg +0 -0
  14. {slthcore-0.3.7 → slthcore-0.3.8}/slth/__init__.py +0 -0
  15. {slthcore-0.3.7 → slthcore-0.3.8}/slth/apps.py +0 -0
  16. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/configure/__main__.py +0 -0
  17. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/__main__.py +0 -0
  18. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/__pycache__/__main__.cpython-312.pyc +0 -0
  19. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/.DS_Store +0 -0
  20. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/.gitignore +0 -0
  21. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/backend/api/__init__.py +0 -0
  22. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/backend/api/asgi.py +0 -0
  23. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/backend/api/endpoints/__init__.py +0 -0
  24. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/backend/api/models.py +0 -0
  25. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/backend/api/settings.py +0 -0
  26. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/backend/api/tests.py +0 -0
  27. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/backend/api/urls.py +0 -0
  28. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/backend/api/wsgi.py +0 -0
  29. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/backend/application.yml +0 -0
  30. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/backend/entrypoint.sh +0 -0
  31. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/backend/manage.py +0 -0
  32. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/backend/requirements.txt +0 -0
  33. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/base.env +0 -0
  34. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/docker-compose.yml +0 -0
  35. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/frontend/package.json +0 -0
  36. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/frontend/src/main.jsx +0 -0
  37. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/frontend/vite.config.js +0 -0
  38. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/local.env +0 -0
  39. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/run.sh +0 -0
  40. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/selenium/run.sh +0 -0
  41. {slthcore-0.3.7 → slthcore-0.3.8}/slth/cmd/init/boilerplate/test.sh +0 -0
  42. {slthcore-0.3.7 → slthcore-0.3.8}/slth/components.py +0 -0
  43. {slthcore-0.3.7 → slthcore-0.3.8}/slth/db/__init__.py +0 -0
  44. {slthcore-0.3.7 → slthcore-0.3.8}/slth/db/generic.py +0 -0
  45. {slthcore-0.3.7 → slthcore-0.3.8}/slth/db/models.py +0 -0
  46. {slthcore-0.3.7 → slthcore-0.3.8}/slth/endpoints/__init__.py +0 -0
  47. {slthcore-0.3.7 → slthcore-0.3.8}/slth/endpoints/deletion.py +0 -0
  48. {slthcore-0.3.7 → slthcore-0.3.8}/slth/endpoints/dev.py +0 -0
  49. {slthcore-0.3.7 → slthcore-0.3.8}/slth/endpoints/email.py +0 -0
  50. {slthcore-0.3.7 → slthcore-0.3.8}/slth/endpoints/job.py +0 -0
  51. {slthcore-0.3.7 → slthcore-0.3.8}/slth/endpoints/log.py +0 -0
  52. {slthcore-0.3.7 → slthcore-0.3.8}/slth/endpoints/profile.py +0 -0
  53. {slthcore-0.3.7 → slthcore-0.3.8}/slth/endpoints/pushsubscription.py +0 -0
  54. {slthcore-0.3.7 → slthcore-0.3.8}/slth/endpoints/report.py +0 -0
  55. {slthcore-0.3.7 → slthcore-0.3.8}/slth/endpoints/role.py +0 -0
  56. {slthcore-0.3.7 → slthcore-0.3.8}/slth/endpoints/task.py +0 -0
  57. {slthcore-0.3.7 → slthcore-0.3.8}/slth/endpoints/user.py +0 -0
  58. {slthcore-0.3.7 → slthcore-0.3.8}/slth/exceptions.py +0 -0
  59. {slthcore-0.3.7 → slthcore-0.3.8}/slth/factory.py +0 -0
  60. {slthcore-0.3.7 → slthcore-0.3.8}/slth/forms.py +0 -0
  61. {slthcore-0.3.7 → slthcore-0.3.8}/slth/management/__init__.py +0 -0
  62. {slthcore-0.3.7 → slthcore-0.3.8}/slth/management/commands/__init__.py +0 -0
  63. {slthcore-0.3.7 → slthcore-0.3.8}/slth/management/commands/integration_test.py +0 -0
  64. {slthcore-0.3.7 → slthcore-0.3.8}/slth/management/commands/sync.py +0 -0
  65. {slthcore-0.3.7 → slthcore-0.3.8}/slth/management/commands/worker.py +0 -0
  66. {slthcore-0.3.7 → slthcore-0.3.8}/slth/middleware/__init__.py +0 -0
  67. {slthcore-0.3.7 → slthcore-0.3.8}/slth/migrations/0001_initial.py +0 -0
  68. {slthcore-0.3.7 → slthcore-0.3.8}/slth/migrations/0002_email_role_pushsubscription_error.py +0 -0
  69. {slthcore-0.3.7 → slthcore-0.3.8}/slth/migrations/0003_rename_photo_profile_alter_profile_options.py +0 -0
  70. {slthcore-0.3.7 → slthcore-0.3.8}/slth/migrations/0004_alter_profile_photo.py +0 -0
  71. {slthcore-0.3.7 → slthcore-0.3.8}/slth/migrations/0005_alter_profile_photo.py +0 -0
  72. {slthcore-0.3.7 → slthcore-0.3.8}/slth/migrations/0006_user.py +0 -0
  73. {slthcore-0.3.7 → slthcore-0.3.8}/slth/migrations/0007_deletion_log.py +0 -0
  74. {slthcore-0.3.7 → slthcore-0.3.8}/slth/migrations/0008_alter_deletion_datetime_alter_log_datetime.py +0 -0
  75. {slthcore-0.3.7 → slthcore-0.3.8}/slth/migrations/0009_remove_email_from_email_email_action_email_attempt_and_more.py +0 -0
  76. {slthcore-0.3.7 → slthcore-0.3.8}/slth/migrations/0010_email_key_alter_email_action_alter_email_attempt_and_more.py +0 -0
  77. {slthcore-0.3.7 → slthcore-0.3.8}/slth/migrations/__init__.py +0 -0
  78. {slthcore-0.3.7 → slthcore-0.3.8}/slth/notifications.py +0 -0
  79. {slthcore-0.3.7 → slthcore-0.3.8}/slth/oauth.py +0 -0
  80. {slthcore-0.3.7 → slthcore-0.3.8}/slth/pdf/__init__.py +0 -0
  81. {slthcore-0.3.7 → slthcore-0.3.8}/slth/pdf/tests.py +0 -0
  82. {slthcore-0.3.7 → slthcore-0.3.8}/slth/permissions.py +0 -0
  83. {slthcore-0.3.7 → slthcore-0.3.8}/slth/printer.py +0 -0
  84. {slthcore-0.3.7 → slthcore-0.3.8}/slth/queryset.py +0 -0
  85. {slthcore-0.3.7 → slthcore-0.3.8}/slth/roles.py +0 -0
  86. {slthcore-0.3.7 → slthcore-0.3.8}/slth/selenium/__init__.py +0 -0
  87. {slthcore-0.3.7 → slthcore-0.3.8}/slth/selenium/browser.py +0 -0
  88. {slthcore-0.3.7 → slthcore-0.3.8}/slth/serializer.py +0 -0
  89. {slthcore-0.3.7 → slthcore-0.3.8}/slth/static/.DS_Store +0 -0
  90. {slthcore-0.3.7 → slthcore-0.3.8}/slth/static/css/.DS_Store +0 -0
  91. {slthcore-0.3.7 → slthcore-0.3.8}/slth/static/css/slth.css +0 -0
  92. {slthcore-0.3.7 → slthcore-0.3.8}/slth/static/js/index.min.js +0 -0
  93. {slthcore-0.3.7 → slthcore-0.3.8}/slth/static/js/react.min.js +0 -0
  94. {slthcore-0.3.7 → slthcore-0.3.8}/slth/static/js/slth.min.js +0 -0
  95. {slthcore-0.3.7 → slthcore-0.3.8}/slth/statistics.py +0 -0
  96. {slthcore-0.3.7 → slthcore-0.3.8}/slth/tasks.py +0 -0
  97. {slthcore-0.3.7 → slthcore-0.3.8}/slth/templates/email.html +0 -0
  98. {slthcore-0.3.7 → slthcore-0.3.8}/slth/templates/index.html +0 -0
  99. {slthcore-0.3.7 → slthcore-0.3.8}/slth/templates/report.html +0 -0
  100. {slthcore-0.3.7 → slthcore-0.3.8}/slth/templates/service-worker.js +0 -0
  101. {slthcore-0.3.7 → slthcore-0.3.8}/slth/templates/signature.html +0 -0
  102. {slthcore-0.3.7 → slthcore-0.3.8}/slth/tests.py +0 -0
  103. {slthcore-0.3.7 → slthcore-0.3.8}/slth/threadlocal.py +0 -0
  104. {slthcore-0.3.7 → slthcore-0.3.8}/slth/urls.py +0 -0
  105. {slthcore-0.3.7 → slthcore-0.3.8}/slth/utils.py +0 -0
  106. {slthcore-0.3.7 → slthcore-0.3.8}/slth/views.py +0 -0
  107. {slthcore-0.3.7 → slthcore-0.3.8}/slthcore.egg-info/dependency_links.txt +0 -0
  108. {slthcore-0.3.7 → slthcore-0.3.8}/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.3.7
3
+ Version: 0.3.8
4
4
  Summary: API generator based on yml file
5
5
  Home-page: https://github.com/brenokcc
6
6
  Author: Breno Silva
@@ -5,7 +5,7 @@ install_requires = []
5
5
 
6
6
  setup(
7
7
  name='slthcore',
8
- version='0.3.7',
8
+ version='0.3.8',
9
9
  packages=find_packages(),
10
10
  install_requires=install_requires,
11
11
  include_package_data=True,
@@ -3,10 +3,11 @@ from django.conf import settings
3
3
  from django.core.exceptions import ValidationError
4
4
  from slth import forms
5
5
  from django.contrib.auth import authenticate
6
- from ..models import Token
6
+ from ..models import Token, UserTimeZone, TimeZone
7
7
  from ..components import Response
8
8
  from .. import oauth
9
9
  from . import PublicEndpoint, Endpoint
10
+ from django.utils import timezone
10
11
 
11
12
 
12
13
  class Login(PublicEndpoint):
@@ -39,6 +40,14 @@ class Login(PublicEndpoint):
39
40
  )
40
41
  if user:
41
42
  token = Token.objects.create(user=user)
43
+ current_timezone = timezone.get_current_timezone()
44
+ timezone_instance = TimeZone.objects.get_or_create(name=current_timezone.__str__())[0]
45
+ user_timezone = UserTimeZone.objects.filter(user=user).first()
46
+ if user_timezone is None:
47
+ UserTimeZone.objects.create(user=user, timezone=timezone_instance)
48
+ else:
49
+ user_timezone.key = current_timezone.__str__()
50
+ user_timezone.save()
42
51
  return Response(
43
52
  message="Bem-vindo!",
44
53
  redirect=self.request.GET.get("next", "/api/dashboard/"),
@@ -0,0 +1,11 @@
1
+ from slth import endpoints
2
+ from ..models import TimeZone
3
+
4
+
5
+ class Timezones(endpoints.ListEndpoint[TimeZone]):
6
+ def check_permission(self):
7
+ return self.check_role()
8
+
9
+
10
+ class Add(endpoints.AddEndpoint[TimeZone]):
11
+ pass
@@ -2,6 +2,18 @@ import pytz
2
2
  from datetime import datetime
3
3
  from django.utils import timezone
4
4
 
5
+ def now():
6
+ return datetime.now().astimezone(timezone.get_current_timezone()).replace(tzinfo=None)
7
+
8
+ def today():
9
+ return now().date()
10
+
11
+ def local(dt, tz):
12
+ from_timezone = timezone.get_default_timezone()
13
+ to_timezone = pytz.timezone(tz)
14
+ from_timezone.localize(dt).astimezone(to_timezone).replace(tzinfo=None)
15
+
16
+
5
17
  class Middleware:
6
18
  def __init__(self, get_response):
7
19
  self.get_response = get_response
@@ -14,12 +26,3 @@ class Middleware:
14
26
  if tz:
15
27
  timezone.deactivate()
16
28
  return response
17
-
18
- def now():
19
- return datetime.now().astimezone(timezone.get_current_timezone()).replace(tzinfo=None)
20
-
21
- def today():
22
- return now().date()
23
-
24
- def local_datetime(dt, tz):
25
- pass
@@ -0,0 +1,31 @@
1
+ # Generated by Django 5.1.3 on 2024-12-03 15:42
2
+
3
+ import django.db.models.deletion
4
+ import slth
5
+ import slth.db.models
6
+ from django.conf import settings
7
+ from django.db import migrations, models
8
+
9
+
10
+ class Migration(migrations.Migration):
11
+
12
+ dependencies = [
13
+ ('slth', '0010_email_key_alter_email_action_alter_email_attempt_and_more'),
14
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
15
+ ]
16
+
17
+ operations = [
18
+ migrations.CreateModel(
19
+ name='UserTimeZone',
20
+ fields=[
21
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
22
+ ('key', slth.db.models.CharField(max_length=255, verbose_name='Fuso Horário')),
23
+ ('user', slth.db.models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Usuário')),
24
+ ],
25
+ options={
26
+ 'verbose_name': 'Fuso Horário do Usuário',
27
+ 'verbose_name_plural': 'Fusos Horários do Usuário',
28
+ },
29
+ bases=(models.Model, slth.ModelMixin),
30
+ ),
31
+ ]
@@ -0,0 +1,37 @@
1
+ # Generated by Django 5.1.3 on 2024-12-05 14:14
2
+
3
+ import django.db.models.deletion
4
+ import slth
5
+ import slth.db.models
6
+ from django.db import migrations, models
7
+
8
+
9
+ class Migration(migrations.Migration):
10
+
11
+ dependencies = [
12
+ ('slth', '0011_usertimezone'),
13
+ ]
14
+
15
+ operations = [
16
+ migrations.CreateModel(
17
+ name='TimeZone',
18
+ fields=[
19
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
20
+ ('name', slth.db.models.CharField(max_length=255, verbose_name='Nome')),
21
+ ],
22
+ options={
23
+ 'verbose_name': 'Fuso Horário',
24
+ 'verbose_name_plural': 'Fusos Horários',
25
+ },
26
+ bases=(models.Model, slth.ModelMixin),
27
+ ),
28
+ migrations.RemoveField(
29
+ model_name='usertimezone',
30
+ name='key',
31
+ ),
32
+ migrations.AddField(
33
+ model_name='usertimezone',
34
+ name='timezone',
35
+ field=slth.db.models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='slth.timezone', verbose_name='Fuso Horário'),
36
+ ),
37
+ ]
@@ -1,6 +1,6 @@
1
1
  import os
2
2
  import json
3
- import time
3
+ import pytz
4
4
  import binascii
5
5
  from uuid import uuid1
6
6
  import traceback
@@ -9,7 +9,6 @@ from django.conf import settings
9
9
  from django.utils.translation import gettext_lazy as _
10
10
  from django.contrib.auth.models import User
11
11
  from django.db import transaction
12
- from django.db.models.base import ModelBase
13
12
  from django.apps import apps
14
13
  from datetime import datetime
15
14
  from django.core.cache import cache
@@ -19,7 +18,6 @@ from django.template.loader import render_to_string
19
18
  from django.core.mail import EmailMultiAlternatives
20
19
  from .notifications import send_push_web_notification
21
20
  from .components import HtmlContent
22
-
23
21
  from slth import APPLICATON
24
22
  from django.contrib.auth.models import BaseUserManager
25
23
 
@@ -64,7 +62,7 @@ class User(User):
64
62
  return (
65
63
  super().serializer()
66
64
  .fieldset('Dados Gerais', (('first_name', 'last_name'), 'email'))
67
- .fieldset('Dados de Acesso', ('username', ('is_superuser', 'is_active'),))
65
+ .fieldset('Dados de Acesso', (('username', 'get_timezone'), ('is_superuser', 'is_active'),))
68
66
  .queryset('Notificação', 'get_push_subscriptions')
69
67
  .queryset('Papéis', 'get_roles')
70
68
  )
@@ -79,6 +77,11 @@ class User(User):
79
77
  @meta('Papéis')
80
78
  def get_roles(self):
81
79
  return Role.objects.filter(username=self.username).fields('get_description')
80
+
81
+ @meta('Fuso Horário')
82
+ def get_timezone(self):
83
+ user_timezone = self.usertimezone_set.first()
84
+ return user_timezone.key if user_timezone else None
82
85
 
83
86
 
84
87
 
@@ -507,6 +510,31 @@ class Deletion(models.Model):
507
510
  self.save()
508
511
 
509
512
 
513
+ class TimeZone(models.Model):
514
+ name = models.CharField(verbose_name='Nome')
515
+
516
+ class Meta:
517
+ verbose_name = 'Fuso Horário'
518
+ verbose_name_plural = 'Fusos Horários'
519
+
520
+ def __str__(self):
521
+ return self.name
522
+
523
+ def localtime(self, datetime=None):
524
+ return datetime.astimezone(pytz.timezone(self.name)).replace(tzinfo=None)
525
+
526
+
527
+ class UserTimeZone(models.Model):
528
+ user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name='Usuário', on_delete=models.CASCADE)
529
+ timezone = models.ForeignKey(TimeZone, verbose_name='Fuso Horário', on_delete=models.CASCADE, null=True)
530
+
531
+ class Meta:
532
+ verbose_name = 'Fuso Horário do Usuário'
533
+ verbose_name_plural = 'Fusos Horários do Usuário'
534
+
535
+ def __str__(self):
536
+ return '{} - {}'.format(self.user.username, self.key)
537
+
510
538
 
511
539
  # class Task(models.Model):
512
540
  # total = models.IntegerField(verbose_name='Total', default=0)
@@ -0,0 +1,13 @@
1
+ import pytz
2
+ from datetime import datetime
3
+ from django.utils import timezone
4
+
5
+
6
+ def now():
7
+ return datetime.now().astimezone(timezone.get_current_timezone()).replace(tzinfo=None)
8
+
9
+ def today():
10
+ return now().date()
11
+
12
+ def localtime(tz, _datetime=None):
13
+ return (_datetime or datetime.now()).replace(tzinfo=timezone.get_default_timezone()).astimezone(pytz.timezone(tz)).replace(tzinfo=None)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: slthcore
3
- Version: 0.3.7
3
+ Version: 0.3.8
4
4
  Summary: API generator based on yml file
5
5
  Home-page: https://github.com/brenokcc
6
6
  Author: Breno Silva
@@ -18,6 +18,7 @@ slth/statistics.py
18
18
  slth/tasks.py
19
19
  slth/tests.py
20
20
  slth/threadlocal.py
21
+ slth/tz.py
21
22
  slth/urls.py
22
23
  slth/utils.py
23
24
  slth/views.py
@@ -62,6 +63,7 @@ slth/endpoints/pushsubscription.py
62
63
  slth/endpoints/report.py
63
64
  slth/endpoints/role.py
64
65
  slth/endpoints/task.py
66
+ slth/endpoints/timezone.py
65
67
  slth/endpoints/user.py
66
68
  slth/management/__init__.py
67
69
  slth/management/commands/__init__.py
@@ -80,6 +82,8 @@ slth/migrations/0007_deletion_log.py
80
82
  slth/migrations/0008_alter_deletion_datetime_alter_log_datetime.py
81
83
  slth/migrations/0009_remove_email_from_email_email_action_email_attempt_and_more.py
82
84
  slth/migrations/0010_email_key_alter_email_action_alter_email_attempt_and_more.py
85
+ slth/migrations/0011_usertimezone.py
86
+ slth/migrations/0012_timezone_remove_usertimezone_key_and_more.py
83
87
  slth/migrations/__init__.py
84
88
  slth/pdf/__init__.py
85
89
  slth/pdf/tests.py
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