From c9bbea1ba10d758f75eacdd5540bd9cea7d7f1a5 Mon Sep 17 00:00:00 2001
From: Nicolas ROCHE <nroche@entrouvert.com>
Date: Mon, 24 Feb 2020 18:48:10 +0100
Subject: [PATCH] manager: remove unused manager views code (#40153)

---
 .../environment/tenant_confirm_delete.html    | 17 ------
 hobo/manager_urls.py                          |  8 ---
 hobo/templates/hobo/manager_home.html         | 50 -----------------
 hobo/views.py                                 | 54 -------------------
 4 files changed, 129 deletions(-)
 delete mode 100644 hobo/environment/templates/environment/tenant_confirm_delete.html
 delete mode 100644 hobo/manager_urls.py
 delete mode 100644 hobo/templates/hobo/manager_home.html

diff --git a/hobo/environment/templates/environment/tenant_confirm_delete.html b/hobo/environment/templates/environment/tenant_confirm_delete.html
deleted file mode 100644
index 597a293..0000000
--- a/hobo/environment/templates/environment/tenant_confirm_delete.html
+++ /dev/null
@@ -1,17 +0,0 @@
-{% extends "hobo/base.html" %}
-{% load i18n  %}
-
-{% block content %}
-<form action="{% url 'delete-tenant' object.id %}" method="post">
-  {% csrf_token %}
-  <p>
-    {% blocktrans with name=object.schema_name %}
-    Are you sure you want to delete "{{ name }}"?
-    {% endblocktrans %}
-  </p>
-  <div class="right">
-    <button type="button" class="cancel">{% trans 'Cancel' %}</button>
-    <input type="submit" value="{% trans 'Delete' %}" />
-  </div>
-</form>
-{% endblock %}
diff --git a/hobo/manager_urls.py b/hobo/manager_urls.py
deleted file mode 100644
index 5d2b1d0..0000000
--- a/hobo/manager_urls.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from django.conf.urls import patterns, include, url
-
-urlpatterns = patterns('',
-    url(r'^$', 'hobo.views.manager_home', name='manager-home'),
-    url(r'^update/(?P<pk>\d+)$', 'hobo.views.update_tenant', name='update-tenant'),
-    url(r'^delete/(?P<pk>\d+)$', 'hobo.views.delete_tenant', name='delete-tenant'),
-    url(r'^hobos.json$', 'hobo.views.hobos', name='hobos'),
-)
diff --git a/hobo/templates/hobo/manager_home.html b/hobo/templates/hobo/manager_home.html
deleted file mode 100644
index 0a3abed..0000000
--- a/hobo/templates/hobo/manager_home.html
+++ /dev/null
@@ -1,50 +0,0 @@
-{% extends "hobo/base.html" %}
-{% load i18n %}
-
-{% block appbar %}
-  <h2>{% trans 'Add instance' %}</h2>
-{% endblock %}
-
-{% block content %}
-  <form class="small" method="post" >
-    {% csrf_token %}
-    {{ form.as_p }}
-    <button>{% trans 'Add' %}</button>
-  </form>
-
-  <h2>{% trans 'Tenants' %}</h2>
-    {% for tenant in tenants_list %}
-    <div>
-     <a href="{% url 'delete-tenant' tenant.object.id %}" class="delete-tenant" title="{% trans 'Delete tenant' %}"></a>
-     <h3>{{ tenant.object }}</h3>
-     <form class="small" method="post" action="{% url 'update-tenant' tenant.object.pk %}" >
-       {% csrf_token %}
-       {{ tenant.form.as_p }}
-       <button class="enable-on-change" disabled="disabled">{% trans 'Save' %}</button>
-     </form>
-    </div>
-    {% endfor %}
-{% endblock %}
-
-{% block page-end %}
-<script>
-$(function() {
-    $('a.delete-tenant').click(function() {
-        var url = $(this).attr('href');
-        $.get($(this).attr('href'), function(data) {
-            var form = $(data).find('form');
-            $(form).dialog({modal: true, title: '{% trans "Tenant deletion" %}', width: 'auto'});
-            $('.cancel', form).click(function() {$(form).dialog('close')});
-        });
-        event.preventDefault();
-    });
-
-    $('button.enable-on-change').each(function(index, element) {
-        var button = $(element);
-        $(element).parent('form').find('input').on('change keydown',
-                                                   function() {$(button).prop('disabled', null);});
-    });
-
-})
-</script>
-{% endblock %}
diff --git a/hobo/views.py b/hobo/views.py
index 8f59ac6..884e70d 100644
--- a/hobo/views.py
+++ b/hobo/views.py
@@ -33,70 +33,16 @@ class Home(TemplateView):
     def get_context_data(self, **kwargs):
         context = super(Home, self).get_context_data(**kwargs)
         context['services'] = [x for x in get_installed_services() if not x.secondary]
         context['has_authentic'] = bool(Authentic.objects.filter(secondary=False))
         return context
 
 home = admin_required(Home.as_view())
 
-class ManagerHome(edit.CreateView):
-    template_name = 'hobo/manager_home.html'
-    form_class = HoboForm
-
-    def get_success_url(self):
-        return reverse('manager-home')
-
-    def get_context_data(self, **kwargs):
-        from tenant_schemas.utils import get_public_schema_name
-        context = super(ManagerHome, self).get_context_data(**kwargs)
-        tenants_list = ()
-        for obj in get_tenant_model().objects.exclude(schema_name=get_public_schema_name()):
-            f = HoboUpdateForm(instance=obj, auto_id='%s_%%s' % obj.pk)
-            tenants_list += ({'object': obj, 'form': f},)
-        context['tenants_list'] = tenants_list
-        return context
-
-    def form_valid(self, form):
-        response = super(ManagerHome, self).form_valid(form)
-        self.object.create_schema(True)
-        return response
-
-manager_home = admin_required(ManagerHome.as_view())
-
-class ManagerUpdateTenant(edit.UpdateView):
-    model = get_tenant_model()
-    template_name = 'hobo/manager_home.html'
-    form_class = HoboUpdateForm
-
-    def get_success_url(self):
-        return reverse('manager-home')
-
-    def form_valid(self, form):
-        response = super(ManagerUpdateTenant, self).form_valid(form)
-        self.object.create_schema(True)
-        return response
-
-update_tenant = admin_required(ManagerUpdateTenant.as_view())
-
-class ManagerDeleteTenant(edit.DeleteView):
-    template_name = 'environment/tenant_confirm_delete.html'
-    model = get_tenant_model()
-
-    def get_success_url(self):
-        return reverse('manager-home', self.object.id)
-
-delete_tenant = admin_required(ManagerDeleteTenant.as_view())
-
-def hobos(request, *args, **kwargs):
-    response = HttpResponse(content_type='application/json')
-    tenants = [{'name': tenant.schema_name, 'url': tenant.domain_url} \
-               for tenant in get_tenant_model().objects.all()]
-    json.dump(tenants, response)
-    return response
 
 def hobo(request, **kwargs):
     # The hobos URL is supposed to return a list of hobo websites, this
     # dummy implementation makes it possible to point deployment agents to
     # a single instance, that will announce itself as the only hobo around.
     response = HttpResponse(content_type='application/json')
     json.dump([request.build_absolute_uri('/')], response)
     return response
-- 
2.25.0

