Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
roomlist
Commits
268815a1
Commit
268815a1
authored
May 01, 2015
by
Daniel W Bond
Browse files
fixed this error, though want to change the flow eventually
parent
8ac74f4c
Changes
2
Show whitespace changes
Inline
Side-by-side
roomlist/accounts/urls.py
View file @
268815a1
...
...
@@ -20,7 +20,7 @@ urlpatterns = patterns('',
template_name
=
'detailStudent.html'
),
name
=
'detailCurrentStudent'
),
url
(
r
'^(?P<slug>[\w-]+)/welcome/$'
,
url
(
r
'^
student/
(?P<slug>[\w-]+)/welcome/$'
,
UpdateStudent
.
as_view
(
model
=
Student
,
template_name
=
"updateStudent.html"
),
...
...
roomlist/accounts/views.py
View file @
268815a1
from
django.shortcuts
import
render
,
get_object_or_404
from
django.http
import
HttpResponseForbidden
from
django.views.generic
import
DetailView
,
ListView
,
UpdateView
,
UpdateView
,
DeleteView
...
...
@@ -11,11 +12,20 @@ class UpdateStudent(LoginRequiredMixin, UpdateView):
model
=
Student
fields
=
[
'room'
,
'privacy'
,]
login_url
=
'
/
'
login_url
=
'
login
'
# copied from below
def
get_object
(
self
):
return
get_object_or_404
(
Student
,
pk
=
self
.
request
.
session
[
'_auth_user_id'
])
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
current_url
=
self
.
request
.
get_full_path
()
url_uname
=
current_url
.
split
(
'/'
)[
3
]
print
url_uname
,
self
.
request
.
user
.
username
if
not
(
url_uname
==
self
.
request
.
user
.
username
):
print
"I'm sorry, what now?"
return
HttpResponseForbidden
()
else
:
return
super
(
UpdateStudent
,
self
).
get
(
request
,
*
args
,
**
kwargs
)
class
UpdateStudentMajor
(
LoginRequiredMixin
,
UpdateView
):
models
=
Student
...
...
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