summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/forms.py10
-rw-r--r--yaksh/urls.py6
-rw-r--r--yaksh/views.py9
3 files changed, 11 insertions, 14 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py
index 5dd56a2..3459be9 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -10,6 +10,7 @@ from taggit.managers import TaggableManager
from taggit.forms import TagField
from django.forms.models import inlineformset_factory
from django.db.models import Q
+from django.utils import timezone
from textwrap import dedent
try:
from string import letters
@@ -18,7 +19,7 @@ except ImportError:
from string import punctuation, digits
import datetime
import pytz
-from .email_verification import generate_activation_key
+from .send_emails import generate_activation_key
languages = (
("select", "Select Language"),
@@ -146,11 +147,8 @@ class UserRegisterForm(forms.Form):
new_profile.is_email_verified = True
else:
new_profile.activation_key = generate_activation_key(new_user.username)
- new_profile.key_expiry_time = datetime.datetime.strftime(
- datetime.datetime.now() + \
- datetime.timedelta(minutes=20),
- "%Y-%m-%d %H:%M:%S"
- )
+ new_profile.key_expiry_time = timezone.now() + \
+ timezone.timedelta(minutes=20)
new_profile.save()
return u_name, pwd, new_user.email, new_profile.activation_key
diff --git a/yaksh/urls.py b/yaksh/urls.py
index b02b797..e4676d3 100644
--- a/yaksh/urls.py
+++ b/yaksh/urls.py
@@ -5,9 +5,9 @@ urlpatterns = [
url(r'^$', views.index),
url(r'^login/$', views.user_login, name='login'),
url(r'^logout/$', views.user_logout),
- url(r'^update_email/$', views.update_email),
- url(r'^activate/(?P<key>.+)$', views.activate_user),
- url(r'^new_activation/$', views.new_activation),
+ url(r'^update_email/$', views.update_email, name="update_email"),
+ url(r'^activate/(?P<key>.+)$', views.activate_user, name="activate"),
+ url(r'^new_activation/$', views.new_activation, name='new_activation'),
url(r'^quizzes/$', views.quizlist_user, name='quizlist_user'),
url(r'^quizzes/(?P<enrolled>\w+)/$', views.quizlist_user, name='quizlist_user'),
url(r'^results/$', views.results_user),
diff --git a/yaksh/views.py b/yaksh/views.py
index 6a4325e..c7af5cc 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -42,7 +42,7 @@ from yaksh.forms import UserRegisterForm, UserLoginForm, QuizForm,\
from .settings import URL_ROOT
from yaksh.models import AssignmentUpload
from .file_utils import extract_files
-from .email_verification import send_user_mail, generate_activation_key
+from .send_emails import send_user_mail, generate_activation_key
from .decorators import email_verified
@@ -1540,10 +1540,8 @@ def new_activation(request, email=None):
if not user.profile.is_email_verified:
user.profile.activation_key = generate_activation_key(user.username)
- user.profile.key_expiry_time = datetime.strftime(
- datetime.now() + \
- timedelta(minutes=20), "%Y-%m-%d %H:%M:%S"
- )
+ user.profile.key_expiry_time = timezone.now() + \
+ timezone.timedelta(minutes=20)
user.profile.save()
success, msg = send_user_mail(user.email, user.profile.activation_key)
if success:
@@ -1599,6 +1597,7 @@ def download_assignment_file(request, quiz_id, question_id=None, user_id=None):
return response
@login_required
+@email_verified
def duplicate_course(request, course_id):
user = request.user
course = get_object_or_404(Course, pk=course_id)