Commit 002ab738 authored by Nicolas Joyard's avatar Nicolas Joyard

Cleanup unused views

parent 9a36e6ea
......@@ -4,16 +4,13 @@ from django.contrib import admin
from views.home import HomeView
from views.dossier_ac import DossierAutocomplete, ProposalAutocomplete
from views.dossier_ac import ProposalAutocomplete
from views.dossier_detail_base import DossierDetailBase
from views.dossier_detail_recommendations import DossierDetailRecommendations
from views.dossier_detail_proposals import DossierDetailProposals
from views.dossier_detail_documents import DossierDetailDocuments
from views.dossier_list import DossierList
from views.group_ac import GroupAutocomplete
from views.group_list import GroupList
from views.representative_detail_base import RepresentativeDetailBase
from views.representative_detail_votes import RepresentativeDetailVotes
from views.representative_detail_mandates import RepresentativeDetailMandates
......@@ -82,32 +79,11 @@ urlpatterns = [
RepresentativeDetailPositions.as_view(),
name='representative-positions'
),
url(
r'^legislature/group/$',
GroupList.as_view(),
name='group-list'
),
url(
r'^legislature/groups/$',
RedirectGroupList.as_view(),
name='group-list-redirect'
),
url(
r'^legislature/group/(?P<kind>\w+)/$',
GroupList.as_view(),
name='group-list'
),
url(
r'^legislature/groups/(?P<kind>\w+)/$',
RedirectGroupList.as_view(),
name='group-list-redirect'
),
url(
r'^legislature/autocomplete/group/$',
GroupAutocomplete.as_view(),
name='group-autocomplete',
),
url(
r'^votes/dossier/$',
DossierList.as_view(),
......@@ -138,11 +114,6 @@ urlpatterns = [
DossierDetailDocuments.as_view(),
name='dossier-documents'
),
url(
r'^votes/autocomplete/dossier/$',
DossierAutocomplete.as_view(),
name='dossier-autocomplete',
),
url(
r'^votes/autocomplete/proposal/$',
ProposalAutocomplete.as_view(),
......
......@@ -7,19 +7,6 @@ from django.db.models import Q
from representatives_votes.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()
......
# coding: utf-8
from core.views import ActiveLegislatureMixin
from dal.autocomplete import Select2QuerySetView
import datetime
from django.db.models import Q
from representatives.models import Group
class GroupAutocomplete(Select2QuerySetView, ActiveLegislatureMixin):
def get_queryset(self):
qs = Group.objects.distinct().exclude(kind__in=['chamber', 'country'])
if self.get_active_only():
qs = qs.filter(
Q(mandates__end_date__gte=datetime.date.today()) |
Q(mandates__end_date__isnull=True)
)
if self.q:
qs = qs.filter(
Q(name__icontains=self.q) |
Q(abbreviation__icontains=self.q)
)
return qs
# coding: utf-8
import datetime
from core.views import PaginationMixin, ActiveLegislatureMixin
from django.db import models
from django.views import generic
from representatives.models import Group
class GroupList(PaginationMixin, ActiveLegislatureMixin, generic.ListView):
def override_active_only(self):
kind = self.kwargs.get('kind')
if kind == 'chamber' or kind == 'country':
return False
else:
return None
def get_queryset(self):
qs = Group.objects.all()
if self.get_active_only():
qs = qs.filter(
models.Q(mandates__end_date__gte=datetime.date.today()) |
models.Q(mandates__end_date__isnull=True)
)
kind = self.kwargs.get('kind', None)
if kind:
qs = qs.filter(kind=kind).distinct()
return qs.select_related('chamber').order_by('chamber__name', 'name')
{% extends 'base.html' %}
{% load memopol_tags %}
{% block content %}
{% include 'core/blocks/pagination.html' %}
{% block list %}
<table>
{% for group in object_list %}
<tr>
{% if group.kind != 'country' and group.kind != 'chamber' %}
<td>
<a href="{% chamber_url group.chamber %}">
{{ group.chamber|chamber_icon }}
</a>
</td>
{% endif %}
<td>
<a href="{% group_url group %}">
{{ group.abbreviation }}
</a>
</td>
<td>
<a href="{% group_url group %}">
{% if group.kind == 'chamber' %}
{{ group|chamber_icon }}
{% elif group.kind == 'country' %}
{{ group|country_flag }}
{% elif group.kind == 'group' %}
{{ group|group_long_icon }}
{% else %}
{{ group.name }}
{% endif %}
</a>
</td>
</tr>
{% endfor %}
</table>
{% endblock %}
{% endblock %}
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