Commit 461e8195 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

removed 'please finish your walkthrough' messages-- users are now...

removed 'please finish your walkthrough' messages-- users are now automatically redirected to the relevant walkthrough page
parent 97d61d25
...@@ -3,7 +3,7 @@ from __future__ import absolute_import, print_function ...@@ -3,7 +3,7 @@ from __future__ import absolute_import, print_function
import random import random
# core django imports # core django imports
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.http import HttpResponseForbidden from django.http import HttpResponseForbidden, HttpResponseRedirect
from django.views.generic import (CreateView, ListView, DetailView, UpdateView, from django.views.generic import (CreateView, ListView, DetailView, UpdateView,
FormView, DeleteView) FormView, DeleteView)
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
...@@ -21,22 +21,8 @@ from .forms import (StudentUpdateForm, WelcomeNameForm, WelcomePrivacyForm, ...@@ -21,22 +21,8 @@ from .forms import (StudentUpdateForm, WelcomeNameForm, WelcomePrivacyForm,
WelcomeSocialForm) WelcomeSocialForm)
not_started = """Welcome to SRCT Roomlist! <a href="%s">Click here</a> to walk through settings_redirect = """You've already finished the welcome walkthrough.
your profile setup.""" Your user settings can now be changed here on this page."""
# 1 or 2
started = """Welcome back to SRCT Roomlist! It looks like you're not quite finished with
setting up your profile. <a href="%s">Click here</a> to return to your
welcome walkthrough."""
# 3
almost = """Welcome back to SRCT Roomlist! It looks like you're almost finished
with setting up your profile. <a href="%s">Click here</a> to return
to the last page of your welcome walkthrough."""
# walkthrough finished but Room is None
no_room = """It looks like you haven't set your room yet. Head to <a href="%s"> your
settings page</a> to get that taken care of."""
######### #########
...@@ -82,30 +68,20 @@ def custom_cas_login(request, *args, **kwargs): ...@@ -82,30 +68,20 @@ def custom_cas_login(request, *args, **kwargs):
if request.user.is_authenticated(): if request.user.is_authenticated():
if request.user.student.completedName is False: if not request.user.student.totally_done():
rendered_url = reverse('welcomeName', args=[request.user.username])
add_url = not_started % rendered_url if not request.user.student.completedName:
messages.add_message(request, messages.INFO, mark_safe(add_url)) return HttpResponseRedirect(reverse('welcomeName',
kwargs={'slug':request.user.username}))
elif request.user.student.completedPrivacy is False: elif not request.user.student.completedPrivacy:
rendered_url = reverse('welcomePrivacy', args=[request.user.username]) return HttpResponseRedirect(reverse('welcomePrivacy',
add_url = started % rendered_url kwargs={'slug':request.user.username}))
messages.add_message(request, messages.INFO, mark_safe(add_url)) elif not request.user.student.completedMajor:
return HttpResponseRedirect(reverse('welcomeMajor',
elif request.user.student.completedMajor is False: kwargs={'slug':request.user.username}))
rendered_url = reverse('welcomeMajor', args=[request.user.username]) elif not request.user.completedSocial:
add_url = started % rendered_url return HttpResponseRedirect(reverse('welcomeSocial',
messages.add_message(request, messages.INFO, mark_safe(add_url)) kwargs={'slug':request.user.username}))
elif request.user.student.completedName is False:
rendered_url = reverse('welcomeSocial', args=[request.user.username])
add_url = started % rendered_url
messages.add_message(request, messages.INFO, mark_safe(add_url))
elif request.user.student.room is None:
rendered_url = reverse('updateStudent', args=[request.user.username])
add_url = started % rendered_url
messages.add_message(request, messages.INFO, mark_safe(add_url))
else: else:
welcome_back = random.choice(return_messages) welcome_back = random.choice(return_messages)
messages.add_message(request, messages.INFO, mark_safe(welcome_back)) messages.add_message(request, messages.INFO, mark_safe(welcome_back))
...@@ -336,9 +312,15 @@ class WelcomeName(LoginRequiredMixin, FormView): ...@@ -336,9 +312,15 @@ class WelcomeName(LoginRequiredMixin, FormView):
if not(url_uname == self.request.user.username): if not(url_uname == self.request.user.username):
return HttpResponseForbidden() return HttpResponseForbidden()
elif self.request.user.student.totally_done():
messages.add_message(request, messages.INFO, settings_redirect)
return reverse('updateStudent',
kwargs={'slug':self.request.user.username})
else: else:
return super(WelcomeName, self).get(request, *args, **kwargs) return super(WelcomeName, self).get(request, *args, **kwargs)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(WelcomeName, self).get_context_data(**kwargs) context = super(WelcomeName, self).get_context_data(**kwargs)
...@@ -392,6 +374,10 @@ class WelcomePrivacy(LoginRequiredMixin, UpdateView): ...@@ -392,6 +374,10 @@ class WelcomePrivacy(LoginRequiredMixin, UpdateView):
if not(url_uname == self.request.user.username): if not(url_uname == self.request.user.username):
return HttpResponseForbidden() return HttpResponseForbidden()
elif self.request.user.student.totally_done():
messages.add_message(request, messages.INFO, settings_redirect)
return reverse('updateStudent',
kwargs={'slug':self.request.user.username})
else: else:
return super(WelcomePrivacy, self).get(request, *args, **kwargs) return super(WelcomePrivacy, self).get(request, *args, **kwargs)
...@@ -451,6 +437,10 @@ class WelcomeMajor(LoginRequiredMixin, UpdateView): ...@@ -451,6 +437,10 @@ class WelcomeMajor(LoginRequiredMixin, UpdateView):
if not(url_uname == self.request.user.username): if not(url_uname == self.request.user.username):
return HttpResponseForbidden() return HttpResponseForbidden()
elif self.request.user.student.totally_done():
messages.add_message(request, messages.INFO, settings_redirect)
return reverse('updateStudent',
kwargs={'slug':self.request.user.username})
else: else:
return super(WelcomeMajor, self).get(request, *args, **kwargs) return super(WelcomeMajor, self).get(request, *args, **kwargs)
...@@ -484,6 +474,10 @@ class WelcomeSocial(LoginRequiredMixin, UpdateView): ...@@ -484,6 +474,10 @@ class WelcomeSocial(LoginRequiredMixin, UpdateView):
if not(url_uname == self.request.user.username): if not(url_uname == self.request.user.username):
return HttpResponseForbidden() return HttpResponseForbidden()
elif self.request.user.student.totally_done():
messages.add_message(request, messages.INFO, settings_redirect)
return reverse('updateStudent',
kwargs={'slug':self.request.user.username})
else: else:
return super(WelcomeSocial, self).get(request, *args, **kwargs) return super(WelcomeSocial, self).get(request, *args, **kwargs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment