From 1aeac2f7dd26eafaca44abbd77f3f47ce6e7405a Mon Sep 17 00:00:00 2001
From: jpic <jamespic@gmail.com>
Date: Sun, 29 Nov 2015 22:45:31 +0100
Subject: [PATCH] Removed broken views

---
 legislature/admin.py       |   4 --
 legislature/admin_views.py |  29 ----------
 votes/admin.py             |   4 --
 votes/admin_views.py       | 106 -------------------------------------
 4 files changed, 143 deletions(-)
 delete mode 100644 legislature/admin_views.py
 delete mode 100644 votes/admin_views.py

diff --git a/legislature/admin.py b/legislature/admin.py
index 55c5107b..75de8d5d 100644
--- a/legislature/admin.py
+++ b/legislature/admin.py
@@ -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
diff --git a/legislature/admin_views.py b/legislature/admin_views.py
deleted file mode 100644
index 74802abb..00000000
--- a/legislature/admin_views.py
+++ /dev/null
@@ -1,29 +0,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')
diff --git a/votes/admin.py b/votes/admin.py
index 52af5be0..470bbbb3 100644
--- a/votes/admin.py
+++ b/votes/admin.py
@@ -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)
diff --git a/votes/admin_views.py b/votes/admin_views.py
deleted file mode 100644
index 938cfd65..00000000
--- a/votes/admin_views.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# 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)
-- 
GitLab