Commit 0838d262 authored by Arnaud Fabre's avatar Arnaud Fabre
Browse files

Adds a command from votes to legislature

parent 1bf92403
# coding: utf-8
# This file is part of memopol.
#
# memopol is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or any later version.
#
# memopol is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Affero Public
# License along with django-representatives.
# If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2015 Arnaud Fabre <af@laquadrature.net>
from __future__ import absolute_import
from django.contrib import admin
from representatives.models import Email, WebSite, Address, Phone, Country
from .admin_views import representatives_update_all
from .models import MemopolRepresentative
admin.site.register_view('representatives_update_all', view=representatives_update_all)
class EmailInline(admin.TabularInline):
model = Email
extra = 0
......@@ -43,7 +67,6 @@ class MemopolRepresentativeAdmin(admin.ModelAdmin):
]
# class MandateAdmin(admin.ModelAdmin):
# list_display = ('representative', 'group', 'role', 'constituency', 'begin_date', 'end_date', 'active')
# search_fields = ('representative', 'group', 'constituency')
......
# coding: utf-8
# This file is part of mempol.
#
# mempol is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or any later version.
#
# mempol is distributed in the hope that it will
# be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU General Affero Public
# License along with django-representatives.
# If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2015 Arnaud Fabre <af@laquadrature.net>
from __future__ import absolute_import
from django.shortcuts import redirect
from .tasks import representatives_update_all as rpr_update_task
def representatives_update_all(request):
rpr_update_task.delay()
return redirect('/admin')
......@@ -17,17 +17,16 @@
# If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2015 Arnaud Fabre <af@laquadrature.net>
from __future__ import absolute_import
from celery import shared_task
from legislature.models import MemopolRepresentative
from .models import MemopolRepresentative
@shared_task
def update_representatives_score():
def representatives_update_all():
'''
Update score for all representatives
Call MemopolRepresentative.update_all methods
'''
for representative in MemopolRepresentative.objects.all():
representative.update_score()
representative.update_all()
......@@ -22,13 +22,11 @@ from __future__ import absolute_import
from django.contrib import admin
from django.core.urlresolvers import reverse
from .admin_views import import_vote_with_recommendation, import_vote, update_representatives_score
from .admin_views import import_vote_with_recommendation, import_vote
from .models import Recommendation, MemopolDossier
admin.site.register_view('import_vote', view=import_vote)
admin.site.register_view('import_vote_with_recommendation', view=import_vote_with_recommendation)
admin.site.register_view('update_representatives_score', view=update_representatives_score)
def link_to_edit(obj, field):
try:
......
......@@ -27,17 +27,12 @@ import requests
from representatives_votes.tasks import import_a_proposal_from_toutatis
from .forms import RecommendationForm
from .tasks import update_representatives_score as task_urs
class SearchForm(forms.Form):
query = forms.CharField(label='Search', max_length=100)
def update_representatives_score(request):
task_urs.delay()
return redirect('/admin')
def import_vote_with_recommendation(request):
context = {}
toutatis_server = getattr(settings,
......
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