Commit 365c2828 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

login redirects now work -- issue #47

parent 64ff8ce5
......@@ -10,6 +10,7 @@ class DetailStudent(LoginRequiredMixin, DetailView):
model = Student
template_name = 'profile.html'
context_object_name = 'student'
login_url = 'login'
def get_context_data(self, **kwargs):
......@@ -45,5 +46,3 @@ class DetailStudent(LoginRequiredMixin, DetailView):
context['bids'] = Bid.objects.filter(bidder=self.get_object())
return context
login_url = '/'
......@@ -13,7 +13,7 @@ class CreateLookout(LoginRequiredMixin, CreateView):
fields = ['isbn', ]
context_object_name = 'lookout'
template_name = 'create_lookout.html'
login_url = '/'
login_url = 'login'
def form_valid(self, form):
me = Student.objects.get(user=self.request.user)
......@@ -34,7 +34,7 @@ class DetailLookout(LoginRequiredMixin, DetailView):
model = Lookout
context_object_name = 'lookout'
template_name = 'detail_lookout.html'
login_url = '/'
login_url = 'login'
def get_context_data(self, **kwargs):
context = super(DetailLookout, self).get_context_data(**kwargs)
......@@ -55,6 +55,7 @@ class DeleteLookout(LoginRequiredMixin, DeleteView):
context_object_name = 'lookout'
template_name = 'delete_lookout.html'
success_url = '/'
success_url = 'login'
def get_context_data(self, **kwargs):
context = super(DeleteLookout, self).get_context_data(**kwargs)
......
......@@ -23,6 +23,7 @@ class HomepageView(TemplateView):
class ChartsView(LoginRequiredMixin, TemplateView):
template_name = 'charts.html'
login_url = 'login'
def get_context_data(self, **kwargs):
context = super(ChartsView, self).get_context_data(**kwargs)
......
......@@ -59,7 +59,7 @@ class ListListings(LoginRequiredMixin, ListView):
paginate_by = 15
queryset = Listing.objects.exclude(cancelled=True).order_by('-created')
template_name = 'list_listings.html'
login_url = '/'
login_url = 'login'
class CreateListing(LoginRequiredMixin, CreateView):
......@@ -69,7 +69,7 @@ class CreateListing(LoginRequiredMixin, CreateView):
template_name = 'create_listing.html'
context_object_name = 'listing'
# ISBN query!
login_url = '/'
login_url = 'login'
def form_valid(self, form):
me = Student.objects.get(user=self.request.user)
......@@ -90,7 +90,6 @@ class DetailListing(DetailView):
model = Listing
context_object_name = 'listing'
template_name = 'detail_listing.html'
login_url = '/'
def get_context_data(self, **kwargs):
context = super(DetailListing, self).get_context_data(**kwargs)
......@@ -118,7 +117,6 @@ class CreateBid(CreateView):
fields = ['listing', 'price', 'text', ]
context_object_name = 'bid'
template_name = 'detail_listing.html'
login_url = '/'
def form_valid(self, form):
me = Student.objects.get(user=self.request.user)
......@@ -133,6 +131,7 @@ class CreateBid(CreateView):
# ...to make this single view
class ListingPage(LoginRequiredMixin, View):
login_url = 'login'
# see this page for an explanation
# https://docs.djangoproject.com/en/1.7/topics/class-based-views/mixins/#an-alternative-better-solution
......@@ -152,8 +151,7 @@ class CreateFlag(LoginRequiredMixin, CreateView):
fields = ['reason', ]
template_name = 'create_flag.html'
context_object_name = 'flag'
login_url = '/'
login_url = 'login'
def form_valid(self, form):
me = Student.objects.get(user=self.request.user)
......@@ -203,6 +201,7 @@ class DeleteFlag(LoginRequiredMixin, DeleteView):
model = Flag
context_object_name = 'flag'
template_name = 'delete_flag.html'
login_url = 'login'
def get_success_url(self):
return reverse('detail_listing',
......@@ -240,13 +239,12 @@ class EditListing(LoginRequiredMixin, UpdateView):
template_name = 'listing_edit.html'
context_object_name = 'listing'
#form_class = EditListingForm
login_url = 'login'
fields = ['title', 'author', 'isbn', 'year', 'edition', 'condition',
'access_code', 'description', 'price', 'photo', ]
template_suffix_name = '_edit'
login_url = '/'
def get_context_data(self, **kwargs):
context = super(EditListing, self).get_context_data(**kwargs)
......@@ -265,8 +263,7 @@ class SellListing(LoginRequiredMixin, UpdateView):
template_suffix_name = '_sell'
context_object_name = 'listing'
template_name = 'listing_sell.html'
login_url = '/'
login_url = 'login'
def form_valid(self, form):
# filling out fields
......@@ -333,8 +330,7 @@ class UnSellListing(LoginRequiredMixin, UpdateView):
template_suffix_name = '_unsell'
context_object_name = 'listing'
template_name = 'listing_unsell.html'
login_url = '/'
login_url = 'login'
def form_valid(self, form):
form.instance.sold = False
......@@ -360,8 +356,7 @@ class CancelListing(LoginRequiredMixin, UpdateView):
template_suffix_name = '_cancel'
context_object_name = 'listing'
template_name = 'listing_cancel.html'
login_url = '/'
login_url = 'login'
def form_valid(self, form):
today = date.today()
......@@ -388,8 +383,7 @@ class ReopenListing(LoginRequiredMixin, UpdateView):
template_suffix_name = '_reopen'
context_object_name = 'listing'
template_name = 'listing_reopen.html'
login_url = '/'
login_url = 'login'
def form_valid(self, form):
form.instance.cancelled = False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment