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
B
bookshare
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
30
Issues
30
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
SRCT
bookshare
Commits
7f307ea1
Commit
7f307ea1
authored
May 02, 2015
by
Daniel W Bond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed method of forbidden returns
parent
4a347c18
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
179 additions
and
143 deletions
+179
-143
bookshare/lookouts/views.py
bookshare/lookouts/views.py
+6
-11
bookshare/trades/views.py
bookshare/trades/views.py
+173
-132
No files found.
bookshare/lookouts/views.py
View file @
7f307ea1
# core django imports
from
core.models
import
Student
from
django.http
import
HttpResponseForbidden
from
django.contrib
import
messages
from
django.http
import
HttpResponse
,
HttpResponseRedirect
from
django.http
import
HttpResponse
,
HttpResponse
Forbidden
,
HttpResponse
Redirect
from
django.db
import
IntegrityError
from
django.core.urlresolvers
import
reverse
from
django.utils.safestring
import
mark_safe
...
...
@@ -13,6 +11,7 @@ from ratelimit.decorators import ratelimit
# imports from your apps
from
.forms
import
LookoutForm
from
.models
import
Lookout
from
core.models
import
Student
class
CreateLookout
(
LoginRequiredMixin
,
CreateView
):
...
...
@@ -55,16 +54,14 @@ class DetailLookout(LoginRequiredMixin, DetailView):
template_name
=
'detail_lookout.html'
login_url
=
'login'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
DetailLookout
,
self
).
get_context_data
(
**
kwargs
)
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
me
=
Student
.
objects
.
get
(
user
=
self
.
request
.
user
)
lookout_student
=
self
.
get_object
().
owner
if
not
(
lookout_student
==
me
):
return
HttpResponseForbidden
()
return
context
return
super
(
DetailLookout
,
self
).
get
(
request
,
*
args
,
**
kwargs
)
# updating is not neccessary since it's just literally an isbn and a course
...
...
@@ -76,13 +73,11 @@ class DeleteLookout(LoginRequiredMixin, DeleteView):
success_url
=
'/'
login_url
=
'login'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
DeleteLookout
,
self
).
get_context_data
(
**
kwargs
)
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
me
=
Student
.
objects
.
get
(
user
=
self
.
request
.
user
)
lookout_student
=
self
.
get_object
().
owner
if
not
(
lookout_student
==
me
):
return
HttpResponseForbidden
()
return
context
return
super
(
DeleteLookout
,
self
).
get
(
request
,
*
args
,
**
kwargs
)
bookshare/trades/views.py
View file @
7f307ea1
This diff is collapsed.
Click to expand it.
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