Skip to content
Extraits de code Groupes Projets
Valider 1aeac2f7 rédigé par Jamesie Pic's avatar Jamesie Pic
Parcourir les fichiers

Removed broken views

parent a06c58ee
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -23,13 +23,9 @@ 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
......
# 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')
......@@ -5,12 +5,8 @@ from autocomplete_light import shortcuts as ac
from django.contrib import admin
from django.core.urlresolvers import reverse
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)
def link_to_edit(obj, field):
try:
related_obj = getattr(obj, field)
......
# 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.conf import settings
from django.shortcuts import render, redirect
from django import forms
import requests
from representatives_votes.tasks import import_a_proposal_from_toutatis
from .forms import RecommendationForm
class SearchForm(forms.Form):
query = forms.CharField(label='Search', max_length=100)
def import_vote_with_recommendation(request):
context = {}
toutatis_server = getattr(settings,
'TOUTATIS_SERVER',
'http://toutatis.mm.staz.be')
if request.method == 'POST' and 'search' in request.POST:
form = SearchForm(request.POST)
if form.is_valid():
query = form.cleaned_data['query']
context['api_url'] = '{}/api/proposals/?search={}&limit=30'.format(
toutatis_server,
query
)
r = requests.get(context['api_url'])
context['results'] = r.json()
elif request.method == 'POST' and 'create_recommendation' in request.POST:
form = RecommendationForm(data=request.POST)
if form.is_valid():
# First import proposal
proposal_fingerprint = request.POST['proposal_fingerprint']
proposal = import_a_proposal_from_toutatis(proposal_fingerprint)
recommendation = form.save(commit=False)
recommendation.proposal = proposal
recommendation.save()
return redirect('/admin/votes/recommendation/')
else:
proposal_fingerprint = request.GET.get('import', None)
if proposal_fingerprint:
api_url = '{}/api/proposals/?fingerprint={}'.format(
toutatis_server,
proposal_fingerprint
)
proposal = requests.get(api_url).json()['results'][0]
context['recommendation_proposal_title'] = proposal['title']
context['recommendation_proposal_dossier_title'] = proposal['dossier_title']
context['recommendation_proposal_fingerprint'] = proposal['fingerprint']
context['recommendation_form'] = RecommendationForm()
form = SearchForm()
context['form'] = form
return render(request, 'votes/admin/import.html', context)
def import_vote(request):
context = {}
toutatis_server = getattr(settings,
'TOUTATIS_SERVER',
'http://toutatis.mm.staz.be')
if request.method == 'POST' and 'search' in request.POST:
print(request.POST)
form = SearchForm(request.POST)
if form.is_valid():
query = form.cleaned_data['query']
context['api_url'] = '{}/api/proposals/?search={}&limit=1000'.format(
toutatis_server,
query
)
r = requests.get(context['api_url'])
context['results'] = r.json()
else:
proposal_fingerprint = request.GET.get('import', None)
if proposal_fingerprint:
import_a_proposal_from_toutatis(proposal_fingerprint)
return redirect('/admin/')
form = SearchForm()
context['form'] = form
return render(request, 'votes/admin/import.html', context)
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter