Commit 072020e5 authored by njoyard's avatar njoyard

Merge pull request #26 from political-memory/remove-views

Remove features that don't belong here
parents 7cc4b1b7 d4456173
from dal import autocomplete
from django.db.models import Q
from models import Dossier, Proposal
class DossierAutocomplete(autocomplete.Select2QuerySetView):
def get_queryset(self):
qs = Dossier.objects.all()
if self.q:
qs = qs.filter(
Q(title__icontains=self.q) |
Q(reference__icontains=self.q)
)
return qs
class ProposalAutocomplete(autocomplete.Select2QuerySetView):
def get_queryset(self):
qs = Proposal.objects.all()
if self.q:
qs = qs.filter(
Q(dossier__title__icontains=self.q) |
Q(title__icontains=self.q) |
Q(reference__icontains=self.q)
)
return qs
# coding: utf-8
from django.core.urlresolvers import reverse
from django.db import models
from representatives.models import (HashableModel, Representative,
......@@ -18,9 +17,6 @@ class Dossier(HashableModel, TimeStampedModel):
def __unicode__(self):
return unicode(self.title)
def get_absolute_url(self):
return reverse('representatives_votes:dossier-detail', args=(self.pk,))
class Proposal(HashableModel, TimeStampedModel):
dossier = models.ForeignKey(Dossier, related_name='proposals')
......
from django.conf import settings
from django.conf.urls import url
import views
urlpatterns = [
url(
r'^dossier/(?P<pk>\d+)/$',
views.DossierDetail.as_view(),
name='dossier-detail'
),
url(
r'^dossier/$',
views.DossierList.as_view(),
name='dossier-list'
),
]
if 'dal_select2' in settings.INSTALLED_APPS:
from autocompletes import ( # noqa
DossierAutocomplete,
ProposalAutocomplete,
)
urlpatterns += [
url(
'^autocomplete/dossier/$',
DossierAutocomplete.as_view(),
name='dossier-autocomplete',
),
url(
'^autocomplete/proposal/$',
ProposalAutocomplete.as_view(),
name='proposal-autocomplete',
),
]
from django.views import generic
from .models import Dossier
class DossierList(generic.ListView):
model = Dossier
class DossierDetail(generic.DetailView):
model = Dossier
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