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
4f48fcec
Commit
4f48fcec
authored
Oct 28, 2016
by
Daniel W Bond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
404 handling for object dne on accounts views
parent
92e6bc6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
11 deletions
+27
-11
roomlist/accounts/views.py
roomlist/accounts/views.py
+27
-11
No files found.
roomlist/accounts/views.py
View file @
4f48fcec
...
...
@@ -113,7 +113,10 @@ class DetailStudent(LoginRequiredMixin, DetailView):
current_url
=
self
.
request
.
get_full_path
()
url_uname
=
current_url
.
split
(
'/'
)[
3
]
detailed_student
=
Student
.
objects
.
get
(
user__username
=
url_uname
)
try
:
detailed_student
=
Student
.
objects
.
get
(
user__username
=
url_uname
)
except
ObjectDoesNotExist
:
raise
Http404
if
(
detailed_student
in
self
.
request
.
user
.
student
.
blocked_kids
.
all
()):
raise
Http404
...
...
@@ -185,6 +188,10 @@ class UpdateStudent(LoginRequiredMixin, FormValidMessageMixin, FormView):
current_url
=
self
.
request
.
get_full_path
()
url_uname
=
current_url
.
split
(
'/'
)[
3
]
try
:
student
=
Student
.
objects
.
get
(
user__username
=
url_uname
)
except
ObjectDoesNotExist
:
raise
Http404
if
not
(
url_uname
==
self
.
request
.
user
.
username
):
return
HttpResponseRedirect
(
reverse
(
'update_student'
,
...
...
@@ -341,6 +348,10 @@ class DeleteStudent(FormView):
current_url
=
self
.
request
.
get_full_path
()
url_uname
=
current_url
.
split
(
'/'
)[
3
]
try
:
student
=
Student
.
objects
.
get
(
user__username
=
url_uname
)
except
ObjectDoesNotExist
:
raise
Http404
if
not
(
url_uname
==
self
.
request
.
user
.
username
):
return
HttpResponseRedirect
(
reverse
(
'delete_student'
,
...
...
@@ -473,12 +484,13 @@ class CreateConfirmation(LoginRequiredMixin, CreateView):
# [u'', u'accounts', u'student', u'gmason', u'flag', u'confirmer']
confirmer_uname
=
current_url
.
split
(
'/'
)[
3
]
student_uname
=
current_url
.
split
(
'/'
)[
5
]
confirmer
=
Student
.
objects
.
get
(
user__username
=
confirmer_uname
)
student
=
Student
.
objects
.
get
(
user__username
=
student_uname
)
flags
=
Confirmation
.
objects
.
filter
(
confirmer
=
confirmer
,
student
=
student
).
count
()
try
:
confirmer
=
Student
.
objects
.
get
(
user__username
=
confirmer_uname
)
student
=
Student
.
objects
.
get
(
user__username
=
student_uname
)
flags
=
Confirmation
.
objects
.
filter
(
confirmer
=
confirmer
,
student
=
student
).
count
()
except
ObjectDoesNotExist
:
raise
Http404
# you can't flag yourself
if
confirmer
==
student
:
...
...
@@ -547,7 +559,8 @@ class DeleteConfirmation(LoginRequiredMixin, DeleteView):
current_url
=
self
.
request
.
get_full_path
()
confirmer_uname
=
current_url
.
split
(
'/'
)[
3
]
confirmer
=
Student
.
objects
.
get
(
user__username
=
confirmer_uname
)
# not catching exceptions here; that's handled in get_object
# only the person who created the confirmation may delete it
if
not
(
requester
==
confirmer
):
...
...
@@ -567,9 +580,12 @@ class DeleteConfirmation(LoginRequiredMixin, DeleteView):
confirmer_uname
=
current_url
.
split
(
'/'
)[
3
]
student_uname
=
current_url
.
split
(
'/'
)[
5
]
confirmer
=
Student
.
objects
.
get
(
user__username
=
confirmer_uname
)
student
=
Student
.
objects
.
get
(
user__username
=
student_uname
)
confirmation
=
Confirmation
.
objects
.
get
(
confirmer
=
confirmer
,
student
=
student
)
try
:
confirmer
=
Student
.
objects
.
get
(
user__username
=
confirmer_uname
)
student
=
Student
.
objects
.
get
(
user__username
=
student_uname
)
confirmation
=
Confirmation
.
objects
.
get
(
confirmer
=
confirmer
,
student
=
student
)
except
ObjectDoesNotExist
:
raise
Http404
return
confirmation
def
get_success_url
(
self
):
...
...
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