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
bookshare
Commits
c3846699
Commit
c3846699
authored
Apr 10, 2015
by
Daniel W Bond
Browse files
put view information as attributes in views rather than as attributes in urls
parent
ebf08333
Changes
7
Hide whitespace changes
Inline
Side-by-side
bookshare/core/urls.py
View file @
c3846699
...
...
@@ -4,9 +4,5 @@ from core.models import Student
urlpatterns
=
patterns
(
''
,
url
(
r
'^(?P<slug>[\w-]+)/$'
,
DetailStudent
.
as_view
(
model
=
Student
,
context_object_name
=
'student'
,
template_name
=
'profile.html'
),
name
=
'profile'
),
DetailStudent
.
as_view
(),
name
=
'profile'
),
)
bookshare/core/views.py
View file @
c3846699
...
...
@@ -28,6 +28,8 @@ def privacy_opt_out(request):
# User profile page
class
DetailStudent
(
LoginRequiredMixin
,
DetailView
):
model
=
Student
template_name
=
'profile.html'
context_object_name
=
'student'
def
get_context_data
(
self
,
**
kwargs
):
...
...
bookshare/lookouts/urls.py
View file @
c3846699
...
...
@@ -6,23 +6,12 @@ from lookouts.models import Lookout
urlpatterns
=
patterns
(
''
,
url
(
r
'^new/$'
,
CreateLookout
.
as_view
(
model
=
Lookout
,
template_name
=
'create_lookout.html'
),
name
=
'create_lookout'
),
CreateLookout
.
as_view
(),
name
=
'create_lookout'
),
url
(
r
'^(?P<slug>[\w-]+)/$'
,
DetailLookout
.
as_view
(
model
=
Lookout
,
context_object_name
=
'lookout'
,
template_name
=
'detail_lookout.html'
),
name
=
'detail_lookout'
),
DetailLookout
.
as_view
(),
name
=
'detail_lookout'
),
url
(
r
'^(?P<slug>[\w-]+)/delete/$'
,
DeleteLookout
.
as_view
(
model
=
Lookout
,
context_object_name
=
'lookout'
,
template_name
=
'delete_lookout.html'
),
name
=
'delete_lookout'
),
DeleteLookout
.
as_view
(),
name
=
'delete_lookout'
),
)
bookshare/lookouts/views.py
View file @
c3846699
...
...
@@ -14,6 +14,8 @@ class CreateLookout(LoginRequiredMixin, CreateView):
# can only be viewed by the user who created the lookout!...
model
=
Lookout
form_class
=
LookoutForm
context_object_name
=
'lookout'
template_name
=
'create_lookout.html'
login_url
=
'/'
def
get_context_data
(
self
,
**
kwargs
):
...
...
@@ -32,6 +34,7 @@ class CreateLookout(LoginRequiredMixin, CreateView):
class
DetailLookout
(
LoginRequiredMixin
,
DetailView
):
model
=
Lookout
context_object_name
=
'lookout'
template_name
=
'detail_lookout.html'
login_url
=
'/'
...
...
@@ -49,7 +52,9 @@ class DetailLookout(LoginRequiredMixin, DetailView):
# updating is not neccessary since it's just literally an isbn and a course
class
DeleteLookout
(
LoginRequiredMixin
,
DeleteView
):
model
=
Lookout
model
=
Lookout
context_object_name
=
'lookout'
template_name
=
'delete_lookout.html'
success_url
=
'/'
def
get_context_data
(
self
,
**
kwargs
):
...
...
bookshare/settings/urls.py
View file @
c3846699
...
...
@@ -21,9 +21,11 @@ urlpatterns = patterns('',
# search
url
(
r
'^search/'
,
include
(
'haystack.urls'
),
name
=
'search'
),
#
## static
pages
###
#
site-wide
pages
url
(
r
'^$'
,
HomepageView
.
as_view
(),
name
=
'homepage'
),
url
(
r
'^charts/?$'
,
ChartsView
.
as_view
(),
name
=
'charts'
),
### static pages ###
url
(
r
'^about/?$'
,
TemplateView
.
as_view
(
template_name
=
'about.html'
),
name
=
'about'
),
url
(
r
'^privacy/?$'
,
TemplateView
.
as_view
(
template_name
=
'privacy.html'
),
name
=
'privacy'
),
url
(
r
'^privacy/opt-out/?$'
,
'core.views.privacy_opt_out'
,
name
=
'privacy_opt_out'
),
...
...
bookshare/trades/urls.py
View file @
c3846699
...
...
@@ -6,59 +6,32 @@ from trades.models import Listing, Bid
urlpatterns
=
patterns
(
''
,
url
(
r
'^all/$'
,
ListListings
.
as_view
(
model
=
Listing
,
paginate_by
=
15
,
queryset
=
Listing
.
objects
.
exclude
(
cancelled
=
True
).
order_by
(
'-created'
),
context_object_name
=
'listings'
,
template_name
=
'list_listings.html'
),
name
=
'list_listings'
),
ListListings
.
as_view
(),
name
=
'list_listings'
),
url
(
r
'^new/$'
,
CreateListing
.
as_view
(
model
=
Listing
,
template_name
=
'create_listing.html'
),
name
=
'create_listing'
),
CreateListing
.
as_view
(),
name
=
'create_listing'
),
url
(
r
'^listing/(?P<slug>[\w-]+)/$'
,
ListingPage
.
as_view
(),
name
=
'detail_listing'
),
ListingPage
.
as_view
(),
name
=
'detail_listing'
),
url
(
r
'^listing/(?P<slug>[\w-]+)/flag/$'
,
CreateFlag
.
as_view
(),
name
=
'create_flag'
),
CreateFlag
.
as_view
(),
name
=
'create_flag'
),
url
(
r
'^listing/(?P<listing_slug>[\w-]+)/flag/(?P<slug>[\w-]+)/remove/$'
,
DeleteFlag
.
as_view
(),
name
=
'delete_flag'
),
DeleteFlag
.
as_view
(),
name
=
'delete_flag'
),
url
(
r
'^listing/(?P<slug>[\w-]+)/edit/$'
,
EditListing
.
as_view
(
model
=
Listing
,
template_name
=
'listing_edit.html'
),
name
=
'edit_listing'
),
EditListing
.
as_view
(),
name
=
'edit_listing'
),
url
(
r
'^listing/(?P<slug>[\w-]+)/sell/$'
,
SellListing
.
as_view
(
model
=
Listing
,
template_name
=
'listing_sell.html'
),
name
=
'sell_listing'
),
SellListing
.
as_view
(),
name
=
'sell_listing'
),
url
(
r
'^listing/(?P<slug>[\w-]+)/unsell/$'
,
UnSellListing
.
as_view
(
model
=
Listing
,
template_name
=
'listing_unsell.html'
),
name
=
'unsell_listing'
),
UnSellListing
.
as_view
(),
name
=
'unsell_listing'
),
url
(
r
'^listing/(?P<slug>[\w-]+)/cancel/$'
,
CancelListing
.
as_view
(
model
=
Listing
,
template_name
=
'listing_cancel.html'
),
name
=
'cancel_listing'
),
CancelListing
.
as_view
(),
name
=
'cancel_listing'
),
url
(
r
'^listing/(?P<slug>[\w-]+)/reopen/$'
,
ReopenListing
.
as_view
(
model
=
Listing
,
template_name
=
'listing_reopen.html'
),
name
=
'reopen_listing'
),
ReopenListing
.
as_view
(),
name
=
'reopen_listing'
),
)
bookshare/trades/views.py
View file @
c3846699
...
...
@@ -54,8 +54,30 @@ class ListListings(LoginRequiredMixin, ListView):
model
=
Listing
context_object_name
=
'listings'
paginate_by
=
15
queryset
=
Listing
.
objects
.
exclude
(
cancelled
=
True
).
order_by
(
'-created'
)
template_name
=
'list_listings.html'
login_url
=
'/'
class
CreateListing
(
LoginRequiredMixin
,
CreateView
):
model
=
Listing
form_class
=
ListingForm
template_name
=
'create_listing.html'
context_object_name
=
'listing'
# ISBN query!
login_url
=
'/'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
CreateListing
,
self
).
get_context_data
(
**
kwargs
)
me
=
Student
.
objects
.
get
(
user
=
self
.
request
.
user
)
form
=
ListingForm
(
initial
=
{
'seller'
:
me
})
form
.
fields
[
'seller'
].
widget
=
HiddenInput
()
context
[
'my_form'
]
=
form
return
context
# These next two views are tied together...
class
DetailListing
(
DetailView
):
model
=
Listing
...
...
@@ -88,6 +110,7 @@ class DetailListing(DetailView):
class
CreateBid
(
CreateView
):
model
=
Bid
form_class
=
BidForm
context_object_name
=
'bid'
template_name
=
'detail_listing.html'
login_url
=
'/'
...
...
@@ -113,6 +136,7 @@ class ListingPage(LoginRequiredMixin, View):
class
CreateFlag
(
LoginRequiredMixin
,
CreateView
):
model
=
Flag
template_name
=
'create_flag.html'
context_object_name
=
'flag'
login_url
=
'/'
...
...
@@ -151,6 +175,7 @@ class CreateFlag(LoginRequiredMixin, CreateView):
class
DeleteFlag
(
LoginRequiredMixin
,
DeleteView
):
model
=
Flag
context_object_name
=
'flag'
template_name
=
'delete_flag.html'
def
get_success_url
(
self
):
...
...
@@ -180,26 +205,10 @@ class EditBid(LoginRequiredMixin, UpdateView):
# can only be edited by the bidder
class
CreateListing
(
LoginRequiredMixin
,
CreateView
):
model
=
Listing
form_class
=
ListingForm
# ISBN query!
login_url
=
'/'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
CreateListing
,
self
).
get_context_data
(
**
kwargs
)
me
=
Student
.
objects
.
get
(
user
=
self
.
request
.
user
)
form
=
ListingForm
(
initial
=
{
'seller'
:
me
})
form
.
fields
[
'seller'
].
widget
=
HiddenInput
()
context
[
'my_form'
]
=
form
return
context
class
EditListing
(
LoginRequiredMixin
,
UpdateView
):
model
=
Listing
template_name
=
'listing_edit.html'
context_object_name
=
'listing'
#form_class = EditListingForm
fields
=
[
'title'
,
'author'
,
'isbn'
,
'year'
,
'edition'
,
'condition'
,
'access_code'
,
...
...
@@ -223,6 +232,8 @@ class SellListing(LoginRequiredMixin, UpdateView):
model
=
Listing
fields
=
[
'sold'
,
'email_message'
,
'winning_bid'
,
'date_closed'
]
template_suffix_name
=
'_sell'
context_object_name
=
'listing'
template_name
=
'listing_sell.html'
form_class
=
SellListingForm
login_url
=
'/'
...
...
@@ -258,6 +269,8 @@ class UnSellListing(LoginRequiredMixin, UpdateView):
model
=
Listing
fields
=
[
'sold'
,
'winning_bid'
,
'date_closed'
]
template_suffix_name
=
'_unsell'
context_object_name
=
'listing'
template_name
=
'listing_unsell.html'
form_class
=
UnSellListingForm
login_url
=
'/'
...
...
@@ -286,6 +299,8 @@ class CancelListing(LoginRequiredMixin, UpdateView):
model
=
Listing
fields
=
[
'cancelled'
,
'date_closed'
,]
template_suffix_name
=
'_cancel'
context_object_name
=
'listing'
template_name
=
'listing_cancel.html'
form_class
=
CancelListingForm
login_url
=
'/'
...
...
@@ -313,6 +328,8 @@ class ReopenListing(LoginRequiredMixin, UpdateView):
model
=
Listing
fields
=
[
'cancelled'
]
template_suffix_name
=
'_reopen'
context_object_name
=
'listing'
template_name
=
'listing_reopen.html'
form_class
=
ReopenListingForm
login_url
=
'/'
...
...
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