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 django.contrib.auth.decorators import login_required
|
||||||
|
|
||||||
from regluit.core.models import Campaign
|
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(
|
urlpatterns = patterns(
|
||||||
"regluit.frontend.views",
|
"regluit.frontend.views",
|
||||||
|
@ -23,9 +23,7 @@ urlpatterns = patterns(
|
||||||
name="faq"),
|
name="faq"),
|
||||||
url(r"^wishlist/$", "wishlist", name="wishlist"),
|
url(r"^wishlist/$", "wishlist", name="wishlist"),
|
||||||
url(r"^campaigns/(?P<pk>\d+)/$",CampaignFormView.as_view(), name="campaign_by_id"),
|
url(r"^campaigns/(?P<pk>\d+)/$",CampaignFormView.as_view(), name="campaign_by_id"),
|
||||||
url(r"^campaigns/(?P<facet>\w*)$",
|
url(r"^campaigns/(?P<facet>\w*)$", CampaignListView.as_view(), name='campaign_list'),
|
||||||
ListView.as_view( model=Campaign,template_name="campaign_list.html", context_object_name="campaign_list"),
|
|
||||||
name='campaign_list'),
|
|
||||||
url(r"^lists/(?P<facet>\w*)$",
|
url(r"^lists/(?P<facet>\w*)$",
|
||||||
ListView.as_view( model=Campaign,template_name="campaign_list.html", context_object_name="campaign_list"),
|
ListView.as_view( model=Campaign,template_name="campaign_list.html", context_object_name="campaign_list"),
|
||||||
name='work_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.csrf import csrf_exempt
|
||||||
from django.views.decorators.http import require_POST
|
from django.views.decorators.http import require_POST
|
||||||
from django.views.generic.edit import FormView
|
from django.views.generic.edit import FormView
|
||||||
|
from django.views.generic.list import ListView
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.shortcuts import render, render_to_response, get_object_or_404
|
from django.shortcuts import render, render_to_response, get_object_or_404
|
||||||
|
@ -135,6 +136,21 @@ def subjects(request):
|
||||||
|
|
||||||
return render(request, 'subjects.html', {'subjects': subjects})
|
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):
|
class PledgeView(FormView):
|
||||||
template_name="pledge.html"
|
template_name="pledge.html"
|
||||||
|
|
Loading…
Reference in New Issue