summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei Mihai <smihai@entrouvert.com>2015-05-25 14:53:13 (GMT)
committerSerghei Mihai <smihai@entrouvert.com>2015-05-26 07:39:33 (GMT)
commitf704453da87847c49b8c1ddef2170cb9cf391aa9 (patch)
tree0f94ff1c5172d79431c613fe238db1dc5abaf4b7
parentf4843b93ea02835d0305ef01e0f94a39798d0e3a (diff)
downloadu-auth-f704453da87847c49b8c1ddef2170cb9cf391aa9.zip
u-auth-f704453da87847c49b8c1ddef2170cb9cf391aa9.tar.gz
u-auth-f704453da87847c49b8c1ddef2170cb9cf391aa9.tar.bz2
federation files management (#7067)
-rw-r--r--uauth/organization/forms.py4
-rw-r--r--uauth/organization/templates/organization/federations.html28
-rw-r--r--uauth/organization/templates/organization/manage.html1
-rw-r--r--uauth/organization/urls.py3
-rw-r--r--uauth/organization/views.py46
-rw-r--r--uauth/static/css/icons/icon-grid-hover.pngbin0 -> 429 bytes
-rw-r--r--uauth/static/css/icons/icon-grid.pngbin0 -> 246 bytes
-rw-r--r--uauth/static/css/style.css3
8 files changed, 84 insertions, 1 deletions
diff --git a/uauth/organization/forms.py b/uauth/organization/forms.py
index 2c77f71..0090343 100644
--- a/uauth/organization/forms.py
+++ b/uauth/organization/forms.py
@@ -38,3 +38,7 @@ class TemplateForm(forms.Form):
class StaticForm(forms.Form):
static_file = forms.FileField(_('Static file'))
+
+
+class FederationForm(forms.Form):
+ federation_file = forms.FileField(_('Federation file'))
diff --git a/uauth/organization/templates/organization/federations.html b/uauth/organization/templates/organization/federations.html
new file mode 100644
index 0000000..b3ae989
--- /dev/null
+++ b/uauth/organization/templates/organization/federations.html
@@ -0,0 +1,28 @@
+{% extends "organization/base.html" %}
+{% load i18n %}
+
+{% block page-title %}
+{% trans 'Federations management' %}
+{% endblock %}
+
+{% block appbar %}
+<h2>{% trans "Federations" %}</h2>
+<a href="{% url "federations-add" organization.slug %}" rel="popup">{% trans "Add federation" %}</a>
+{% endblock %}
+
+{% block content %}
+<form action='{% url "federations-delete" organization.slug %}'>
+<table>
+ <thead>
+ <tr><td>{% trans "Filename" %}</td><td></td></tr>
+ </thead>
+ <tbody>
+ {% for federation in federations %}
+ <tr><td>{{ federation }}</td><td> <button name="federation" value="{{ federation }}" class="icon-delete">{% trans "Remove" %}</button></td></tr>
+ {% empty %}
+ <tr><td colspan=2>{% trans "No federations uploaded yet" %}</td></tr>
+ {% endfor %}
+ </tbody>
+</table>
+</form>
+{% endblock %}
diff --git a/uauth/organization/templates/organization/manage.html b/uauth/organization/templates/organization/manage.html
index 6435f23..f6e9392 100644
--- a/uauth/organization/templates/organization/manage.html
+++ b/uauth/organization/templates/organization/manage.html
@@ -5,5 +5,6 @@
<ul class="apps">
<li class="users"><a href="{% url 'manage-users' organization.slug %}">{% trans 'Users' %}</a></li>
<li class="theme"><a href="{% url 'manage-theme' organization.slug %}">{% trans 'Theme' %}</a></li>
+ <li class="federations"><a href="{% url 'manage-federations' organization.slug %}">{% trans 'Federations' %}</a></li>
</ul>
{% endblock %}
diff --git a/uauth/organization/urls.py b/uauth/organization/urls.py
index 7dd2f02..68ffa27 100644
--- a/uauth/organization/urls.py
+++ b/uauth/organization/urls.py
@@ -14,4 +14,7 @@ urlpatterns = patterns('',
url(r'^theme/template/delete$', template_delete, name='template-delete'),
url(r'^theme/static/upload$', static_upload, name='static-upload'),
url(r'^theme/static/delete$', static_delete, name='static-delete'),
+ url(r'^federations/$', federations, name='manage-federations'),
+ url(r'^federations/add$', federations_add, name='federations-add'),
+ url(r'^federations/delete$', federations_delete, name='federations-delete')
)
diff --git a/uauth/organization/views.py b/uauth/organization/views.py
index 911a7d8..93dcda0 100644
--- a/uauth/organization/views.py
+++ b/uauth/organization/views.py
@@ -263,3 +263,49 @@ class StaticDelete(ThemeView):
return redirect(self.get_success_url())
static_delete = StaticDelete.as_view()
+
+
+class FederationsView(OrganizationMixin, TemplateView):
+ template_name = 'organization/federations.html'
+
+ def get_success_url(self):
+ return reverse_lazy('manage-federations', kwargs={'organization_slug': self.kwargs['organization_slug']})
+
+ def get_context_data(self, **kwargs):
+ ctx = super(FederationsView, self).get_context_data(**kwargs)
+ org = ctx['organization']
+ federations_dir = os.path.join(settings.ORGANIZATIONS_DIR,
+ org.slug, 'federations')
+ ctx['federations_dir'] = federations_dir
+ if os.path.exists(federations_dir):
+ ctx['federations'] = os.listdir(federations_dir)
+ else:
+ ctx['federations'] = []
+ return ctx
+
+federations = FederationsView.as_view()
+
+
+class FederationsAdd(UploadMixin, FederationsView):
+ form_class = FederationForm
+ filename_param = 'federation_file'
+ upload_dir = 'federations'
+
+federations_add = FederationsAdd.as_view()
+
+
+class FederationsDelete(TemplateView):
+ def get(self, request, *args, **kwargs):
+ ctx = self.get_context_data(**kwargs)
+ s = request.GET.get('federation')
+ if os.path.exists(os.path.join(ctx['federations_dir'], f)):
+ try:
+ os.remove(os.path.join(ctx['federations_dir'], f))
+ messages.info(request, _('Federation file %s successfully removed') % f)
+ except IOError:
+ messages.error(request, _('An error occured while removing file %s') % f)
+ else:
+ messages.error(request, _('Unknown federation file %s') % f)
+ return redirect(self.get_success_url())
+
+federations_delete = FederationsDelete.as_view()
diff --git a/uauth/static/css/icons/icon-grid-hover.png b/uauth/static/css/icons/icon-grid-hover.png
new file mode 100644
index 0000000..c574806
--- /dev/null
+++ b/uauth/static/css/icons/icon-grid-hover.png
Binary files differ
diff --git a/uauth/static/css/icons/icon-grid.png b/uauth/static/css/icons/icon-grid.png
new file mode 100644
index 0000000..61c91bf
--- /dev/null
+++ b/uauth/static/css/icons/icon-grid.png
Binary files differ
diff --git a/uauth/static/css/style.css b/uauth/static/css/style.css
index 24d40ce..f58db0a 100644
--- a/uauth/static/css/style.css
+++ b/uauth/static/css/style.css
@@ -75,4 +75,5 @@ div.example {
/* icons */
li.users a {background-image: url(icons/icon-personnes.png);}
-li.theme a {background-image: url(icons/icon-ressources.png);} \ No newline at end of file
+li.theme a {background-image: url(icons/icon-ressources.png);}
+li.federations a {background-image: url(icons/icon-grid.png);} \ No newline at end of file