year added to index view

This commit is contained in:
fjrodriguez
2023-01-05 16:09:22 -06:00
parent 64555bc92a
commit f437232861
8 changed files with 106 additions and 57 deletions

View File

@@ -34,7 +34,7 @@ INSTALLED_APPS = [
'allauth.account',
'allauth.socialaccount',
'widget_tweaks',
'Clientes',
]
REST_FRAMEWORK = {
@@ -102,7 +102,7 @@ ACCOUNT_LOGOUT_ON_PASSWORD_CHANGE = True
EMAIL_TIMEOUT = 10
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_SUBJECT_PREFIX = 'AS Timbres'
if DEBUG:
if DEBUG :
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
@@ -121,6 +121,8 @@ else:
# Database
# https://docs.djangoproject.com/en/4.1/ref/settings/#databases
if DEBUG:
DATABASES = {
'default': {

View File

@@ -9,21 +9,36 @@ from django.http import HttpResponse
from django.test import SimpleTestCase, override_settings
from rest_framework.authtoken.views import obtain_auth_token
def response_error_handler(request, exception=None):
context={}
return render(request, '403.html',context,status=403)
def response_error_handler_404(request,exception=None):
return render(request,'404.html',status=404)
def permission_denied_view(request):
raise PermissionDenied
urlpatterns = [
path('admin/', admin.site.urls),
path('accounts/', include('allauth.urls')),
path('DRF_Token/', obtain_auth_token, name='DRF_Token'),
path('', include('Clientes.urls')),
path('403/', permission_denied_view),
]
handler403 = response_error_handler
handler404 = response_error_handler_404
if settings.DEBUG: #DEV only
urlpatterns += static(settings.STATIC_URL, document_root= settings.STATIC_ROOT)
@@ -32,8 +47,9 @@ if settings.DEBUG: #DEV only
# ROOT_URLCONF must specify the module that contains handler403 = ...
@override_settings(ROOT_URLCONF=__name__)
class CustomErrorHandlerTests(SimpleTestCase):
def test_handler_renders_template_response(self):
response = self.client.get('/403/')
# Make assertions on the response here. For example:
self.assertContains(response, 'Error handler content', status_code=403)
self.assertContains(response, 'Error handler content', status_code=403)