Commit 6172c9c6 authored by Daniel W Bond's avatar Daniel W Bond

search page login protected; listing charts not

parent a5917739
...@@ -5,6 +5,9 @@ from django.conf.urls.static import static ...@@ -5,6 +5,9 @@ from django.conf.urls.static import static
from django.conf import settings from django.conf import settings
from django.contrib import admin from django.contrib import admin
from django.views.decorators.cache import cache_page from django.views.decorators.cache import cache_page
from django.contrib.auth.decorators import login_required
# third party imports
from haystack.views import SearchView
# imports from your apps # imports from your apps
from .views import HomepageView, ChartsView from .views import HomepageView, ChartsView
...@@ -23,13 +26,13 @@ urlpatterns = patterns('', ...@@ -23,13 +26,13 @@ urlpatterns = patterns('',
url(r'^mod/', include('mod.urls')), url(r'^mod/', include('mod.urls')),
# search # search
url(r'^search/', include('haystack.urls'), name='search'), url(r'^search/', login_required(SearchView(), login_url='login'), name='search'),
# site-wide pages # site-wide pages
# homepage is weird for cacheing... no special url, but different content # homepage is weird for cacheing... no special url, but different content
# for each user # for each user
url(r'^$', HomepageView.as_view(), name='homepage'), url(r'^$', HomepageView.as_view(), name='homepage'),
url(r'^charts/?$', cache_page(60 * 10)(ChartsView.as_view()), name='charts'), url(r'^charts/?$', ChartsView.as_view(), name='charts'),
# static pages # static pages
url(r'^about/?$', url(r'^about/?$',
......
...@@ -21,7 +21,7 @@ class HomepageView(TemplateView): ...@@ -21,7 +21,7 @@ class HomepageView(TemplateView):
return context return context
class ChartsView(LoginRequiredMixin, TemplateView): class ChartsView(TemplateView):
template_name = 'charts.html' template_name = 'charts.html'
login_url = 'login' login_url = 'login'
......
...@@ -10,6 +10,10 @@ SRCT Bookshare • Charts ...@@ -10,6 +10,10 @@ SRCT Bookshare • Charts
{% load trades_extras %} {% load trades_extras %}
{% load cache %}
{% cache 600 ChartsNotToolbar %}
<div class="page-header" id="banner"> <div class="page-header" id="banner">
<div class="row"> <div class="row">
<div class="col-lg-12 text-center"> <div class="col-lg-12 text-center">
...@@ -82,4 +86,6 @@ SRCT Bookshare &bull; Charts ...@@ -82,4 +86,6 @@ SRCT Bookshare &bull; Charts
</div> </div>
</div> </div>
{% endcache %}
{% endblock content %} {% endblock content %}
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
{% if user.is_authenticated %} {% if user.is_authenticated %}
<li><a href="{% url 'create_listing' %}">Create Listing</a></li> <li><a href="{% url 'create_listing' %}">Create Listing</a></li>
<li><a href="{% url 'list_listings' %}">Latest Listings</a></li> <li><a href="{% url 'list_listings' %}">Latest Listings</a></li>
<li><a href="{% url 'charts' %}">Listing Charts</a></li>
{% else %} {% else %}
<li><a href="{% url 'about' %}">About</a></li> <li><a href="{% url 'about' %}">About</a></li>
{% endif %} {% endif %}
<li><a href="{% url 'charts' %}">Listing Charts</a></li>
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
{% if user.is_authenticated %} {% if user.is_authenticated %}
......
...@@ -52,6 +52,11 @@ class ListingForm(forms.ModelForm): ...@@ -52,6 +52,11 @@ class ListingForm(forms.ModelForm):
self.fields['description'].label = "Other Notes" self.fields['description'].label = "Other Notes"
self.fields['photo'].required = False self.fields['photo'].required = False
def clean(self):
cleaned_data = super(ListingForm, self).clean()
print cleaned_data
return super(ListingForm, self).clean()
class Meta: class Meta:
model = Listing model = Listing
......
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