-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
29 changed files
with
20,287 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
https://docs.djangoproject.com/en/2.2/ref/settings/ | ||
""" | ||
|
||
import datetime | ||
import os | ||
|
||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||
|
@@ -38,17 +39,24 @@ | |
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
'rest_framework', | ||
'rest_framework_simplejwt.token_blacklist', | ||
'djoser', | ||
'django_filters', | ||
'corsheaders', | ||
] | ||
|
||
PROJECT_APPS = [ | ||
'base', | ||
'base.utils', | ||
'business', | ||
'business.company', | ||
'base.users', | ||
] | ||
|
||
INSTALLED_APPS = DJANGO_APPS + PROJECT_APPS | ||
|
||
MIDDLEWARE = [ | ||
'corsheaders.middleware.CorsMiddleware', | ||
'django.middleware.security.SecurityMiddleware', | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
'django.middleware.common.CommonMiddleware', | ||
|
@@ -86,6 +94,7 @@ | |
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | ||
'ATOMIC_REQUESTS': True, # Create transactions on each view request | ||
} | ||
} | ||
|
||
|
@@ -132,11 +141,12 @@ | |
# Use Django's standard `django.contrib.auth` permissions, | ||
# or allow read-only access for unauthenticated users. | ||
'DEFAULT_PERMISSION_CLASSES': [ | ||
#'rest_framework.permissions.IsAuthenticated', | ||
'rest_framework.permissions.IsAuthenticated', | ||
], | ||
'DEFAULT_AUTHENTICATION_CLASSES': ( | ||
'rest_framework.authentication.SessionAuthentication', | ||
'rest_framework_simplejwt.authentication.JWTAuthentication', | ||
'rest_framework.authentication.BasicAuthentication', | ||
'rest_framework.authentication.SessionAuthentication', | ||
), | ||
'DEFAULT_PARSER_CLASSES': ( | ||
'rest_framework.parsers.JSONParser', | ||
|
@@ -146,4 +156,53 @@ | |
'PAGE_SIZE': 20, | ||
'UNICODE_JSON': True, | ||
'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend',), | ||
} | ||
} | ||
|
||
SIMPLE_JWT = { | ||
'ACCESS_TOKEN_LIFETIME': datetime.timedelta(hours=12), | ||
'AUTH_HEADER_TYPES': ('JWT',), | ||
'SLIDING_TOKEN_LIFETIME': datetime.timedelta(hours=12), | ||
'REFRESH_TOKEN_LIFETIME': datetime.timedelta(days=1), | ||
'ROTATE_REFRESH_TOKENS': False, | ||
'BLACKLIST_AFTER_ROTATION': True, | ||
} | ||
|
||
|
||
DOMAIN = os.environ.get('SITE_DOMAIN', None) #'localhost:8080' | ||
# se puede cambiar por el dominio del frontend | ||
SITE_NAME = 'localhost' | ||
|
||
|
||
DJOSER = { | ||
'PASSWORD_RESET_CONFIRM_URL': '/auth/password/reset/confirm/{uid}/{token}', # Coloque la ruta del frontend y tome el uid y el token para enviarlos como parametros | ||
'ACTIVATION_URL': '/auth/activate/{uid}/{token}', | ||
'PASSWORD_RESET_SHOW_EMAIL_NOT_FOUND': True, | ||
'SEND_ACTIVATION_EMAIL': False, | ||
'SERIALIZERS': {'user_create': 'base.users.serializers.CreateUserSerializer', | ||
'user': 'djoser.serializers.UserSerializer' | ||
}, | ||
} | ||
|
||
DATETIME_FORMAT = { | ||
'DATETIME_USER': '%B, %d de %Y, %I:%M:%S %P ', | ||
} | ||
|
||
EMAIL_USE_TLS = True | ||
|
||
EMAIL_HOST = 'smtp.gmail.com' | ||
EMAIL_PORT = 587 | ||
EMAIL_HOST_USER = '[email protected]' | ||
EMAIL_HOST_PASSWORD = 'passaccount' | ||
EMAIL_FROM = EMAIL_HOST_USER | ||
|
||
# During production only | ||
#EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | ||
# During development only | ||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' | ||
|
||
|
||
CORS_ORIGIN_ALLOW_ALL=True | ||
|
||
CORS_ORIGIN_WHITELIST = ( | ||
'http:https://localhost:8080', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class UserConfig(AppConfig): | ||
name = 'users' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ADMINS = "Administrator" | ||
USER = "User" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
""" | ||
WatchInSGE System | ||
""" | ||
|
||
## @package base.users.email | ||
# | ||
# Driver for handling email | ||
# @author Team WatchIn | ||
# @version 1.0.0 | ||
|
||
from templated_mail.mail import BaseEmailMessage | ||
|
||
|
||
class AccountCreateEmail(BaseEmailMessage): | ||
"""! | ||
Class that handles the context of the email that is generated when creating an account from the administrator | ||
@author Leonel P. Hernandez M. (leonelphm at gmail.com) | ||
@date 03-10-2018 | ||
@version 1.0.0 | ||
""" | ||
template_name = 'email/account_create.html' | ||
|
||
def get_context_data(self): | ||
""" | ||
Method that obtains context values to create the message | ||
""" | ||
context = super(AccountCreateEmail, self).get_context_data() | ||
|
||
user = context.get('user') | ||
password = context.get('password') | ||
return context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
""" | ||
WatchInSGE System | ||
""" | ||
|
||
## @package base.users.models | ||
# | ||
# Model that builds users data models | ||
# @author Team WatchIn | ||
# @date 23-05-2019 | ||
# @version 1.0 | ||
|
||
from django.contrib.auth.models import User | ||
from django.db import models | ||
|
||
from business.company.models import Job | ||
from base.utils.models import ( | ||
Sorter, AbstractBaseModels | ||
) | ||
from base.utils.constants import COUNTRY | ||
|
||
|
||
class UserProfile(AbstractBaseModels): | ||
"""! | ||
Class that contains the profiles of the users | ||
@author Ing. Leonel P. Hernandez M. (leonelphm at gmail.com) | ||
@date 17-04-2018 | ||
@version 1.0.0 | ||
""" | ||
fk_user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='user') | ||
fk_job = models.ForeignKey(Job, on_delete=models.CASCADE, | ||
null=True, blank=True) | ||
fk_country = models.ForeignKey(Sorter, on_delete=models.CASCADE, | ||
limit_choices_to={'group_sorter': COUNTRY}, | ||
null=True, blank=True) | ||
address = models.TextField(null=True, blank=True) | ||
state = models.CharField(max_length=50, null=True, blank=True) | ||
telephone = models.CharField(max_length=20, null=True, blank=True) | ||
|
||
class Meta: | ||
""" | ||
Class that builds model metadata | ||
""" | ||
ordering = ('pk',) | ||
db_table = 'base_userProfile' | ||
|
||
def __str__(self): | ||
return self.fk_user.username | ||
|
Oops, something went wrong.