Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
roomlist
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
roomlist
Commits
69104ff9
Commit
69104ff9
authored
Oct 11, 2015
by
Daniel W Bond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrapped cas view to add messages, added custom messages per welcome completion
parent
8d48594b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
2 deletions
+58
-2
roomlist/accounts/views.py
roomlist/accounts/views.py
+56
-1
roomlist/settings/urls.py
roomlist/settings/urls.py
+2
-1
No files found.
roomlist/accounts/views.py
View file @
69104ff9
...
...
@@ -3,13 +3,69 @@ from django.shortcuts import get_object_or_404
from
django.http
import
HttpResponseForbidden
from
django.views.generic
import
ListView
,
DetailView
,
UpdateView
,
FormView
from
django.core.urlresolvers
import
reverse
from
django.contrib
import
messages
from
django.utils.safestring
import
mark_safe
# third party imports
from
braces.views
import
LoginRequiredMixin
from
cas.views
import
login
as
cas_login
# imports from your apps
from
.models
import
Student
,
Major
,
Room
from
.forms
import
StudentUpdateForm
,
WelcomeNameForm
not_started
=
"""Welcome to SRCT Roomlist! <a href="%s">Click here</a> to walk through
your profile setup."""
# 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."""
def
custom_cas_login
(
request
,
*
args
,
**
kwargs
):
response
=
cas_login
(
request
,
*
args
,
**
kwargs
)
# returns HttpResponseRedirect
if
request
.
user
.
is_authenticated
():
if
request
.
user
.
student
.
completedName
is
False
:
rendered_url
=
reverse
(
'welcomeName'
,
args
=
[
request
.
user
.
username
])
add_url
=
not_started
%
rendered_url
messages
.
add_message
(
request
,
messages
.
INFO
,
mark_safe
(
add_url
))
elif
request
.
user
.
student
.
completedPrivacy
is
False
:
rendered_url
=
reverse
(
'welcomePrivacy'
,
args
=
[
request
.
user
.
username
])
add_url
=
started
%
rendered_url
messages
.
add_message
(
request
,
messages
.
INFO
,
mark_safe
(
add_url
))
elif
request
.
user
.
student
.
completedMajor
is
False
:
rendered_url
=
reverse
(
'welcomeMajor'
,
args
=
[
request
.
user
.
username
])
add_url
=
started
%
rendered_url
messages
.
add_message
(
request
,
messages
.
INFO
,
mark_safe
(
add_url
))
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
))
# eventually add a reminder if the privacy is set to students
# one in ten change will display a reminder and link to change
return
response
# details about the student
class
DetailStudent
(
LoginRequiredMixin
,
DetailView
):
model
=
Student
...
...
@@ -252,7 +308,6 @@ class WelcomeMajor(LoginRequiredMixin, UpdateView):
return
super
(
WelcomeMajor
,
self
).
get
(
request
,
*
args
,
**
kwargs
)
def
form_valid
(
self
,
form
):
self
.
obj
=
self
.
get_object
()
self
.
obj
.
completedMajor
=
True
...
...
roomlist/settings/urls.py
View file @
69104ff9
...
...
@@ -5,6 +5,7 @@ from django.views.generic import TemplateView
from
django.contrib
import
admin
from
django.views.decorators.cache
import
cache_page
admin
.
autodiscover
()
admin
.
site
.
login
=
login_required
(
admin
.
site
.
login
)
...
...
@@ -32,7 +33,7 @@ urlpatterns = patterns('',
url
(
r
'^search/'
,
include
(
'haystack.urls'
),
name
=
'search'
),
# login and logout
url
(
r
'^login/'
,
'
cas.views.
login'
,
name
=
'login'
),
url
(
r
'^login/'
,
'
accounts.views.custom_cas_
login'
,
name
=
'login'
),
url
(
r
'^logout/'
,
'cas.views.logout'
,
name
=
'logout'
),
# url(r'^login/$', 'django.contrib.auth.views.login', name='login'),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment