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
1628a080
Commit
1628a080
authored
Mar 03, 2020
by
Daniel W Bond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added several additional comments, and FormValidMixin where necessary
parent
dc9fdbc9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
bookshare/trades/views.py
bookshare/trades/views.py
+8
-5
No files found.
bookshare/trades/views.py
View file @
1628a080
...
...
@@ -50,6 +50,8 @@ class CreateListing(LoginRequiredMixin, FormValidMessageMixin, CreateView):
def
form_valid
(
self
,
form
):
me
=
self
.
request
.
user
.
student
# you will see this throughout-- this field is not exposed to the user
# and is instead handled here
form
.
instance
.
poster
=
me
# take uploaded image and scale it down before storing
...
...
@@ -84,7 +86,7 @@ class CreateListing(LoginRequiredMixin, FormValidMessageMixin, CreateView):
return
super
(
CreateListing
,
self
).
post
(
request
,
*
args
,
**
kwargs
)
class
DeleteListing
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
DeleteView
):
class
DeleteListing
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
FormValidMessageMixin
,
DeleteView
):
model
=
Listing
context_object_name
=
'listing'
template_name
=
'delete_listing.html'
...
...
@@ -99,7 +101,6 @@ class DetailListing(LoginRequiredMixin, DetailView):
model
=
Listing
context_object_name
=
'listing'
template_name
=
'detail_listing.html'
login_url
=
'login'
def
get_context_data
(
self
,
**
kwargs
):
...
...
@@ -257,7 +258,7 @@ class CreateFlag(LoginRequiredMixin, CreateView):
kwargs
=
{
'slug'
:
self
.
object
.
listing
.
slug
})
class
DeleteFlag
(
LoginRequiredMixin
,
DeleteView
):
class
DeleteFlag
(
LoginRequiredMixin
,
FormValidMessageMixin
,
DeleteView
):
model
=
Flag
context_object_name
=
'flag'
template_name
=
'delete_flag.html'
...
...
@@ -334,7 +335,7 @@ class CreateBidFlag(LoginRequiredMixin, CreateView):
kwargs
=
{
'slug'
:
self
.
object
.
bid
.
listing
.
slug
})
class
DeleteBidFlag
(
LoginRequiredMixin
,
DeleteView
):
class
DeleteBidFlag
(
LoginRequiredMixin
,
FormValidMessageMixin
,
DeleteView
):
model
=
BidFlag
context_object_name
=
'bidflag'
template_name
=
'delete_bid_flag.html'
...
...
@@ -441,9 +442,11 @@ class ExchangeListing(LoginRequiredMixin, FormValidMessageMixin, UpdateView):
# because the page shouldn't exist in this scenario
raise
Http404
# can't exchange a cancelled listing
if
(
self
.
obj
.
cancelled
is
True
):
raise
Http404
# only you can confirm the exchange of your own listing
if
not
(
posting_student
==
me
):
return
HttpResponseForbidden
()
else
:
...
...
@@ -714,7 +717,7 @@ class EditRating(LoginRequiredMixin, UpdateView):
kwargs
=
{
'slug'
:
self
.
object
.
listing
.
poster
.
slug
})
class
DeleteRating
(
LoginRequiredMixin
,
DeleteView
):
class
DeleteRating
(
LoginRequiredMixin
,
FormValidMessageMixin
,
DeleteView
):
model
=
Rating
context_object_name
=
'rating'
template_name
=
'delete_rating.html'
...
...
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