implemented a generic view class for campaigns.
Ending and newest views are reverse sorted. campaign status is dealt with except for successful campaignspull/1/head
parent
0bd6475906
commit
68b0d4b73a
|
@ -5,7 +5,7 @@ from django.views.generic import ListView, DetailView
|
|||
from django.contrib.auth.decorators import login_required
|
||||
|
||||
from regluit.core.models import Campaign
|
||||
from regluit.frontend.views import CampaignFormView, GoodreadsDisplayView, LibraryThingView, PledgeView
|
||||
from regluit.frontend.views import CampaignFormView, GoodreadsDisplayView, LibraryThingView, PledgeView, CampaignListView
|
||||
|
||||
urlpatterns = patterns(
|
||||
"regluit.frontend.views",
|
||||
|
@ -23,9 +23,7 @@ urlpatterns = patterns(
|
|||
name="faq"),
|
||||
url(r"^wishlist/$", "wishlist", name="wishlist"),
|
||||
url(r"^campaigns/(?P<pk>\d+)/$",CampaignFormView.as_view(), name="campaign_by_id"),
|
||||
url(r"^campaigns/(?P<facet>\w*)$",
|
||||
ListView.as_view( model=Campaign,template_name="campaign_list.html", context_object_name="campaign_list"),
|
||||
name='campaign_list'),
|
||||
url(r"^campaigns/(?P<facet>\w*)$", CampaignListView.as_view(), name='campaign_list'),
|
||||
url(r"^lists/(?P<facet>\w*)$",
|
||||
ListView.as_view( model=Campaign,template_name="campaign_list.html", context_object_name="campaign_list"),
|
||||
name='work_list'),
|
||||
|
|
|
@ -15,6 +15,7 @@ from django.http import HttpResponse
|
|||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.decorators.http import require_POST
|
||||
from django.views.generic.edit import FormView
|
||||
from django.views.generic.list import ListView
|
||||
from django.views.generic.base import TemplateView
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import render, render_to_response, get_object_or_404
|
||||
|
@ -135,7 +136,22 @@ def subjects(request):
|
|||
|
||||
return render(request, 'subjects.html', {'subjects': subjects})
|
||||
|
||||
class CampaignListView(ListView):
|
||||
template_name = "campaign_list.html"
|
||||
context_object_name = "campaign_list"
|
||||
model = models.Campaign
|
||||
|
||||
def get_queryset(self):
|
||||
facet = self.kwargs['facet']
|
||||
if (facet == 'newest'):
|
||||
return models.Campaign.objects.filter(activated__isnull = False, suspended__isnull = True, withdrawn__isnull = True).order_by('activated').reverse()
|
||||
elif (facet == 'almost'):
|
||||
return models.Campaign.objects.all()
|
||||
elif (facet == 'ending'):
|
||||
return models.Campaign.objects.filter(activated__isnull = False, suspended__isnull = True, withdrawn__isnull = True).order_by('activated')
|
||||
else:
|
||||
return models.Campaign.objects.all()
|
||||
|
||||
class PledgeView(FormView):
|
||||
template_name="pledge.html"
|
||||
form_class = CampaignPledgeForm
|
||||
|
|
Loading…
Reference in New Issue