Commit 90e65108 authored by Daniel W Bond's avatar Daniel W Bond
Browse files

listing close and update pages

parent ad7ba7f1
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Bookshare • {{ listing.title }} &nbull; Close
{% endblock %}
{% block content %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-lg-12 text-center">
<h1><strong>SRCT</strong>&#8203;BOOKSHARE</h1>
<p class="lead text-center"><strong>Close Listing</strong></p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save" class="btn btn-primary" />
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Bookshare &bull; {{ listing.title }} &nbull; Update
{% endblock %}
{% block content %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-lg-12 text-center">
<h1><strong>SRCT</strong>&#8203;BOOKSHARE</h1>
<p class="lead text-center"><strong>Update Listing</strong></p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Update" class="btn btn-primary" />
</form>
</div>
</div>
</div>
</div>
{% endblock %}
from django.conf.urls import patterns, include, url
from trades.views import ListListings, CreateListing, DetailListing
from trades.views import ListListings, CreateListing, DetailListing, UpdateListing, CloseListing
from trades.models import Listing
urlpatterns = patterns('',
......@@ -28,4 +28,15 @@ urlpatterns = patterns('',
template_name='detail_listing.html'),
name='detail_listing'),
url(r'^listing/(?P<slug>[\w-]+)/update/$',
UpdateListing.as_view(
model=Listing,
template_name = 'listing_update.html'),
name='update_listing'),
url(r'^listing/(?P<slug>[\w-]+)/close/$',
CloseListing.as_view(
model=Listing,
template_name = 'listing_close.html'),
name='close_listing'),
)
......@@ -4,6 +4,9 @@ from trades.forms import ListingForm, FinalPriceForm, CloseForm, BidForm
from django.views.generic import DetailView, ListView, CreateView, UpdateView, DeleteView
from braces.views import LoginRequiredMixin
from django.contrib.auth.models import User
from django.http import Http404
import math
import pyisbn
import requests
......@@ -93,3 +96,49 @@ class CreateListing(LoginRequiredMixin, CreateView):
},
)
"""
class UpdateListing(LoginRequiredMixin, UpdateView):
model = Listing
#form_class = UpdateListingForm
fields = ['active', 'title', 'author', 'isbn', 'year', 'edition', 'condition',
'description', 'price', 'photo',]
template_suffix_name = '_update'
login_url = '/'
def get_context_data(self, **kwargs):
context = super(UpdateListing, self).get_context_data(**kwargs)
requesting_student = User.objects.get(username=self.request.user.username)
selling_student = self.get_object().seller.user
print requesting_student
print selling_student
# if selling_student is not requesting_student:
# raise Http404
return context
class CloseListing(LoginRequiredMixin, UpdateView):
model = Listing
fields = ['sold', 'date_sold', 'finalPrice',]
template_suffix_name = '_close'
login_url = '/'
def get_context_data(self, **kwargs):
context = super(CloseListing, self).get_context_data(**kwargs)
requesting_student = User.objects.get(username=self.request.user.username)
selling_student = self.get_object().seller.user
print requesting_student
print selling_student
# if selling_student is not requesting_student:
# raise Http404
return context
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