From 284c955ec6a86ededb0e7374e520d7110bad0462 Mon Sep 17 00:00:00 2001 From: Paarhati Ozkasgarli Date: Sat, 11 Mar 2017 21:04:58 +0300 Subject: [PATCH] Update settings and Fix User Activation Updated some of the values in settings.py and fixed user activation email template. Change-Id: I1eb60b624ad5d6516b7750ddbb90dc0d5087e62a --- authcp/urls.py | 1 + authcp/views.py | 11 ++++++----- dash_stack_dashboard/settings.py | 14 +++++++------- requirement.txt | 3 ++- templates/authcp/success.html | 4 ---- templates/mail/user_register_welcome.html | 2 +- templates/mail/user_register_welcome.txt | 2 +- 7 files changed, 18 insertions(+), 19 deletions(-) diff --git a/authcp/urls.py b/authcp/urls.py index b182ddf..0f5ae20 100644 --- a/authcp/urls.py +++ b/authcp/urls.py @@ -8,5 +8,6 @@ urlpatterns = [ url(r'^login/$', auth_views.login, {'template_name': 'authcp/login.html'}, name='login'), url(r'^logout/$', auth_views.logout, name='logout'), url(r'^register/$', views.register_user, name='register'), + url(r'^register-activate/(?P.+)$', views.activation, name='register-activate'), url(r'^register-success/$', views.register_success, name='register-success'), ] diff --git a/authcp/views.py b/authcp/views.py index c5a8785..55165ad 100644 --- a/authcp/views.py +++ b/authcp/views.py @@ -1,6 +1,7 @@ -import random, hashlib, datetime +import random, hashlib from oslo_i18n import translate as _ +from datetime import timedelta from django.shortcuts import render, get_object_or_404 from django.http import HttpResponseRedirect @@ -45,17 +46,17 @@ def register_user(request): usernamesalt=form.cleaned_data['email'] profile=Profile.objects.get(user_id=u.id) profile.activation_key=hashlib.sha1(salt+usernamesalt).hexdigest() - profile.key_expires=datetime.datetime.strftime(datetime.datetime.now() + datetime.timedelta(days=2), - "%Y-%m-%d %H:%M:%S") + profile.key_expires=timezone.now() + timedelta(days=2) profile.save() - send_email({'u': u, 'profil': profile}, + site_url=settings.SITE_ROOT_URL + send_email({'u': u, 'profile': profile, 'site_url': site_url}, _('Welcome to our cloud'), u.email, settings.DEFAULT_EMAIL_FROM, ) return render(request, 'authcp/success.html', - {'u': u, 'profil': profile}) + {'u': u, 'profile': profile}) else: print(form.errors) else: diff --git a/dash_stack_dashboard/settings.py b/dash_stack_dashboard/settings.py index b02aa42..ff71072 100644 --- a/dash_stack_dashboard/settings.py +++ b/dash_stack_dashboard/settings.py @@ -32,7 +32,7 @@ ALLOWED_HOSTS = [ ] # fullt qualified hostname or domain. Ex -SITE_ROOT_URL = 'http://demo.dash-stack.com/' +SITE_ROOT_URL = 'http://127.0.0.1:8000' # login url LOGIN_URL = '/auth/login/' @@ -116,6 +116,10 @@ DATABASES = { 'PASSWORD': 'password', 'HOST': 'localhost', 'PORT': '', + 'OPTIONS': { + 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", + 'init_command': 'SET innodb_strict_mode=1', + }, } } @@ -140,8 +144,6 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization -# https://docs.djangoproject.com/en/1.10/topics/i18n/ - LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' @@ -154,8 +156,6 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) -# https://docs.djangoproject.com/en/1.10/howto/static-files/ - STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), ] @@ -169,10 +169,10 @@ STATIC_URL = '/static/' EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # Host for sending e-mail. -EMAIL_HOST = 'localhost' +EMAIL_HOST = '35.156.60.241' # Port for sending e-mail. -EMAIL_PORT = 25 +EMAIL_PORT = 587 # Optional SMTP authentication information for EMAIL_HOST. EMAIL_HOST_USER = '' diff --git a/requirement.txt b/requirement.txt index 0641f6e..ff854eb 100644 --- a/requirement.txt +++ b/requirement.txt @@ -3,4 +3,5 @@ Django==1.10.3 mysqlclient==1.3.9 oslo.i18n==3.10.0 requests==2.12.1 -django-settings-export==1.2.1 \ No newline at end of file +django-settings-export==1.2.1 +pytz==2016.10 \ No newline at end of file diff --git a/templates/authcp/success.html b/templates/authcp/success.html index 5af90c1..e7c9998 100644 --- a/templates/authcp/success.html +++ b/templates/authcp/success.html @@ -7,10 +7,6 @@ - - {{ u.get_profile.activation_key }}
- {{ profile }} -