예제 #1
0
파일: urls.py 프로젝트: gawel/memopol2
from django.conf.urls.defaults import patterns, url, include
from django.views.generic import ListView, DetailView
from django.shortcuts import redirect
from django.core.urlresolvers import reverse

from memopol2 import utils

from mps.models import MP, Group, Department
from mps.views import MPList, MPsFromModel, MPView
from reps.models import Opinion


urlpatterns = patterns('mps.views',
    # the /names view is *very* expansive. we cache it in RAM for a week
    url(r'^$', utils.cached(3600*24*7)(MPList.as_view()), name='index'),

    url(r'^depute/(?P<pk>[a-zA-Z]+)/$', MPView.as_view(), name='mp'),
    url(r'^depute/(?P<pk>[a-zA-Z]+)/contact$', DetailView.as_view(model=MP, context_object_name='mp', template_name='mps/mp_contact.html'), name='mp_contact'),
    url(r'^group/$', ListView.as_view(queryset=Group.with_mps_count()), name='index_groups'),
    url(r'^group/(?P<pk>.+)/$', MPsFromModel.as_view(model=Group, template_name='mps/container_detail.html'), name='index_by_group'),
    url(r'^department/$', ListView.as_view(queryset=Department.with_mps_count().order_by('number')), name='index_departments'),
    url(r'^department/(?P<pk>.+)/$', MPsFromModel.as_view(model=Department, template_name='mps/container_detail.html'), name='index_by_department'),
    url(r'^opinion/$', ListView.as_view(queryset=Opinion.with_mps_count().order_by('-_date').select_related('_author')), name='index_opinions'),
    url(r'^opinion/(?P<pk>[0-9]+)/$', DetailView.as_view(model=Opinion, template_name="mps/opinion_detail.html"), name='index_by_opinions'),

    url(r'^vote/', include("mps_votes.urls", namespace="votes", app_name="mps_urls")),

    url(r'^votes/$', lambda request: redirect(reverse("mps:votes:index_votes"))),

    url(r'^nosdeputes/(?P<pk>.+)/$', 'get_nosdeputes_widget')
)
예제 #2
0
파일: urls.py 프로젝트: byroot/memopol2
from django.conf.urls.defaults import patterns, url
from django.views.generic import ListView
from memopol2 import utils

from meps.models import Country, Group, Committee, Delegation, Organization, Building, MEP
from reps.models import Party, Opinion
from votes.models import Proposal

from views import BuildingDetailView, MEPView, MEPsFromView, MEPList, PartyView

urlpatterns = patterns('meps.views',
    # those view are *very* expansive. we cache them in RAM for a week
    url(r'^names/$', utils.cached(3600*24*7)(MEPList.as_view()), name='index_names'),
    url(r'^inactive/$', utils.cached(3600*24*7)(MEPList.as_view(active=False)), name='index_inactive'),
    url(r'^score/$', MEPList.as_view(queryset=MEP.objects.filter(active=True).exclude(total_score__isnull=True).order_by('position'), score_listing=True), name='scores'),

    url(r'^opinion/$', ListView.as_view(model=Opinion), name='index_opinions'),
    url(r'^opinion/(?P<pk>[0-9]+)/$', MEPsFromView.as_view(model=Opinion, named_header="reps/opinion_header.html"), name='index_by_opinions'),
    url(r'^organization/$', ListView.as_view(model=Organization), name='index_organizations'),
    url(r'^organization/(?P<pk>[0-9]+)/$', MEPsFromView.as_view(model=Organization, organization_role=True), name='index_by_organization'),
    url(r'^country/$', ListView.as_view(model=Country), name='index_countries'),
    url(r'^country/(?P<slug>[a-zA-Z][a-zA-Z])/$', MEPsFromView.as_view(model=Country, slug_field='code', hidden_fields=['country'], named_header="meps/country_header.html"), name='index_by_country'),
    url(r'^group/$', ListView.as_view(model=Group), name='index_groups'),
    url(r'^group/(?P<slug>[a-zA-Z/-]+)/$', MEPsFromView.as_view(model=Group, hidden_fields=['group'], slug_field="abbreviation", named_header="meps/group_header.html", group_role=True),  name='index_by_group'),
    url(r'^committee/$', ListView.as_view(queryset=Committee.ordered_by_meps_count()), name='index_committees'),
    url(r'^committee/(?P<slug>[A-Z]+)/$', MEPsFromView.as_view(model=Committee, slug_field="abbreviation", committee_role=True), name='index_by_committee'),
    url(r'^delegation/$', ListView.as_view(model=Delegation), name='index_delegations'),
    url(r'^delegation/(?P<pk>[0-9]+)/$', MEPsFromView.as_view(model=Delegation, delegation_role=True), name='index_by_delegation'),
    url(r'^party/$', ListView.as_view(model=Party), name='index_parties'),
    url(r'^party/(?P<pk>[0-9]+)-(?P<slugified_name>[0-9a-z\-]*)/$', PartyView.as_view(),  name='index_by_party'),
    url(r'^floor/$', ListView.as_view(queryset=Building.objects.order_by('postcode')), name='index_floor'),
예제 #3
0
파일: urls.py 프로젝트: olethanh/memopol2
from django.conf.urls.defaults import patterns, url
from django.views.generic import list_detail
from memopol2 import utils

from mps.models import MP, Group, Department

urlpatterns = patterns('',
    # the /names view is *very* expansive. we cache it in RAM for a week
    url(r'^$', utils.cached(3600*24*7)(list_detail.object_list), {'queryset': MP.objects.filter(active=True)}, name='index'),

    url(r'^depute/(?P<object_id>[a-zA-Z]+)/$', list_detail.object_detail, {'queryset': MP.objects.all(), 'template_object_name': 'mp'}, name='mp'),
    url(r'^depute/(?P<object_id>[a-zA-Z]+)/contact$', list_detail.object_detail, {'queryset': MP.objects.all(), 'template_object_name': 'mp', 'template_name': 'mps/mp_contact.html'}, name='mp_contact'),
    url(r'^group/$', list_detail.object_list, {'queryset': Group.objects.all()}, name='index_groups'),
    url(r'^group/(?P<object_id>.+)/$', list_detail.object_detail, {'queryset': Group.objects.all(), 'template_name': 'mps/container_detail.html'}, name='index_by_group'),
    url(r'^department/$', list_detail.object_list, {'queryset': Department.objects.all().order_by('number')}, name='index_departments'),
    url(r'^department/(?P<object_id>.+)/$', list_detail.object_detail, {'queryset': Department.objects.all(), 'template_name': 'mps/container_detail.html'}, name='index_by_department'),
)
예제 #4
0
파일: urls.py 프로젝트: Bouska/memopol2
# TODO: refactor this function, should probably be moved to class based generic views if possible
def proposal_rep(request, proposal_id, mp_id):
    representative = get_object_or_404(MP, id=mp_id)
    proposal = get_object_or_404(Proposal, id=proposal_id)
    # dirty query because we don't store absent vote
    votes = [Vote.objects.get(representative=representative, recommendation=r)
             if Vote.objects.filter(representative=representative, recommendation=r)
             else {'choice': 'absent', 'recommendation': r, 'representative': representative}
             for r in proposal.recommendation_set.all()]
    context = {'representative': representative, 'proposal': proposal, 'votes': votes}
    return render(request, 'meps/per_mep.html', context)


urlpatterns = patterns('mps.views',
    # the /names view is *very* expansive. we cache it in RAM for a week
    url(r'^$', utils.cached(3600*24*7)(ListView.as_view(queryset=MP.objects.filter(active=True))), name='index'),

    url(r'^depute/(?P<pk>[a-zA-Z]+)/$', DetailView.as_view(model=MP, context_object_name='mp'), name='mp'),
    url(r'^depute/(?P<pk>[a-zA-Z]+)/contact$', DetailView.as_view(model=MP, context_object_name='mp', template_name='mps/mp_contact.html'), name='mp_contact'),
    url(r'^group/$', ListView.as_view(model=Group), name='index_groups'),
    url(r'^group/(?P<pk>.+)/$', DetailView.as_view(model=Group, template_name='mps/container_detail.html'), name='index_by_group'),
    url(r'^department/$', ListView.as_view(queryset=Department.objects.order_by('number')), name='index_departments'),
    url(r'^department/(?P<pk>.+)/$', DetailView.as_view(model=Department, template_name='mps/container_detail.html'), name='index_by_department'),
    url(r'^opinion/$', ListView.as_view(queryset=Opinion.objects.filter(institution="FR")), name='index_opinions'),
    url(r'^opinion/(?P<pk>[0-9]+)/$', DetailView.as_view(model=Opinion, template_name="mps/opinion_detail.html"), name='index_by_opinions'),

    url(r'^vote/$', ListView.as_view(queryset=Proposal.objects.filter(institution="FR")), name='index_votes'),
    url(r'^vote/(?P<proposal_id>[a-zA-Z/-_]+)/(?P<pk>\d+)/(?P<recommendation>[\w.]+)/$', VoteRecommendationChoice.as_view(model=Recommendation), name='recommendation_choice'),
    url(r'^vote/(?P<proposal_id>[a-zA-Z/-_]+)/(?P<pk>\d+)/$', VoteRecommendation.as_view(model=Recommendation, template_name="mps/recommendation_detail.html"), name='recommendation'),
    url(r'^vote/(?P<pk>[a-zA-Z/-_]+)/dataporn/$', DetailView.as_view(model=Proposal, context_object_name='vote', template_name="mps/proposal_dataporn.html"), name='vote_dataporn'),
    url(r'^vote/(?P<proposal_id>[a-zA-Z/-_]+)/(?P<mep_id>.+)/$', proposal_rep, name='votes_mp'),
예제 #5
0
파일: urls.py 프로젝트: olethanh/memopol2
  'queryset': Organization.objects.all(),
  'template_name': 'meps/container_detail.html',
  'extra_context': {
    'hidden_fields': [],
    'header_template': 'meps/named_header.html',
  },
}
mep_dict = {'queryset': MEP.objects.all(), 'slug_field': 'id', 'template_object_name': 'mep'}
mep_dict_dataporn = {'queryset': MEP.objects.all(), 'slug_field': 'id', 'template_object_name': 'mep', 'template_name': 'meps/dataporn.html'}
mep_contact_dict = {'queryset': MEP.objects.all(), 'slug_field': 'id',
                    'template_name': 'meps/mep_contact.html',
                    'template_object_name': 'mep'}

urlpatterns = patterns('meps.views',
    # those view are *very* expansive. we cache them in RAM for a week
    url(r'^names/$', utils.cached(3600*24*7)(list_detail.object_list), {'queryset': MEP.objects.filter(active=True)}, name='index_names'),
    url(r'^inactive/$', utils.cached(3600*24*7)(list_detail.object_list), {'queryset': MEP.objects.filter(active=False)}, name='index_inactive'),

    url(r'^organization/$', list_detail.object_list, {'queryset': Organization.objects.all()}, name='index_organizations'),
    url(r'^organization/(?P<object_id>[0-9]+)/$', list_detail.object_detail, organization_dict, name='index_by_organization'),
    url(r'^country/$', list_detail.object_list, {'queryset': Country.objects.with_counts()}, name='index_countries'),
    url(r'^country/(?P<slug>[a-zA-Z][a-zA-Z])/$', list_detail.object_detail, country_dict, name='index_by_country'),
    url(r'^group/$', list_detail.object_list, {'queryset': Group.objects.with_counts()}, name='index_groups'),
    url(r'^group/(?P<slug>[a-zA-Z/-]+)/$', list_detail.object_detail, group_dict,  name='index_by_group'),
    url(r'^committee/$', list_detail.object_list, {'queryset': Committee.objects.with_counts()}, name='index_committees'),
    url(r'^committee/(?P<slug>[A-Z]+)/$', list_detail.object_detail, committe_dict, name='index_by_committee'),
    url(r'^delegation/$', list_detail.object_list, {'queryset': Delegation.objects.with_counts()}, name='index_delegations'),
    url(r'^delegation/(?P<object_id>[0-9]+)/$', list_detail.object_detail, delegation_dict, name='index_by_delegation'),
    url(r'^party/$', list_detail.object_list, {'queryset': Party.objects.with_counts()}, name='index_parties'),
    url(r'^party/(?P<object_id>[0-9]+)/$', list_detail.object_detail, party_dict,  name='index_by_party'),
    url(r'^score/$', 'score_sort', name='scores'),