Révision f704453d
Ajouté par Serghei Mihai il y a presque 9 ans
uauth/organization/forms.py | ||
---|---|---|
38 | 38 |
|
39 | 39 |
class StaticForm(forms.Form): |
40 | 40 |
static_file = forms.FileField(_('Static file')) |
41 |
|
|
42 |
|
|
43 |
class FederationForm(forms.Form): |
|
44 |
federation_file = forms.FileField(_('Federation file')) |
uauth/organization/templates/organization/federations.html | ||
---|---|---|
1 |
{% extends "organization/base.html" %} |
|
2 |
{% load i18n %} |
|
3 |
|
|
4 |
{% block page-title %} |
|
5 |
{% trans 'Federations management' %} |
|
6 |
{% endblock %} |
|
7 |
|
|
8 |
{% block appbar %} |
|
9 |
<h2>{% trans "Federations" %}</h2> |
|
10 |
<a href="{% url "federations-add" organization.slug %}" rel="popup">{% trans "Add federation" %}</a> |
|
11 |
{% endblock %} |
|
12 |
|
|
13 |
{% block content %} |
|
14 |
<form action='{% url "federations-delete" organization.slug %}'> |
|
15 |
<table> |
|
16 |
<thead> |
|
17 |
<tr><td>{% trans "Filename" %}</td><td></td></tr> |
|
18 |
</thead> |
|
19 |
<tbody> |
|
20 |
{% for federation in federations %} |
|
21 |
<tr><td>{{ federation }}</td><td> <button name="federation" value="{{ federation }}" class="icon-delete">{% trans "Remove" %}</button></td></tr> |
|
22 |
{% empty %} |
|
23 |
<tr><td colspan=2>{% trans "No federations uploaded yet" %}</td></tr> |
|
24 |
{% endfor %} |
|
25 |
</tbody> |
|
26 |
</table> |
|
27 |
</form> |
|
28 |
{% endblock %} |
uauth/organization/templates/organization/manage.html | ||
---|---|---|
5 | 5 |
<ul class="apps"> |
6 | 6 |
<li class="users"><a href="{% url 'manage-users' organization.slug %}">{% trans 'Users' %}</a></li> |
7 | 7 |
<li class="theme"><a href="{% url 'manage-theme' organization.slug %}">{% trans 'Theme' %}</a></li> |
8 |
<li class="federations"><a href="{% url 'manage-federations' organization.slug %}">{% trans 'Federations' %}</a></li> |
|
8 | 9 |
</ul> |
9 | 10 |
{% endblock %} |
uauth/organization/urls.py | ||
---|---|---|
14 | 14 |
url(r'^theme/template/delete$', template_delete, name='template-delete'), |
15 | 15 |
url(r'^theme/static/upload$', static_upload, name='static-upload'), |
16 | 16 |
url(r'^theme/static/delete$', static_delete, name='static-delete'), |
17 |
url(r'^federations/$', federations, name='manage-federations'), |
|
18 |
url(r'^federations/add$', federations_add, name='federations-add'), |
|
19 |
url(r'^federations/delete$', federations_delete, name='federations-delete') |
|
17 | 20 |
) |
uauth/organization/views.py | ||
---|---|---|
263 | 263 |
return redirect(self.get_success_url()) |
264 | 264 |
|
265 | 265 |
static_delete = StaticDelete.as_view() |
266 |
|
|
267 |
|
|
268 |
class FederationsView(OrganizationMixin, TemplateView): |
|
269 |
template_name = 'organization/federations.html' |
|
270 |
|
|
271 |
def get_success_url(self): |
|
272 |
return reverse_lazy('manage-federations', kwargs={'organization_slug': self.kwargs['organization_slug']}) |
|
273 |
|
|
274 |
def get_context_data(self, **kwargs): |
|
275 |
ctx = super(FederationsView, self).get_context_data(**kwargs) |
|
276 |
org = ctx['organization'] |
|
277 |
federations_dir = os.path.join(settings.ORGANIZATIONS_DIR, |
|
278 |
org.slug, 'federations') |
|
279 |
ctx['federations_dir'] = federations_dir |
|
280 |
if os.path.exists(federations_dir): |
|
281 |
ctx['federations'] = os.listdir(federations_dir) |
|
282 |
else: |
|
283 |
ctx['federations'] = [] |
|
284 |
return ctx |
|
285 |
|
|
286 |
federations = FederationsView.as_view() |
|
287 |
|
|
288 |
|
|
289 |
class FederationsAdd(UploadMixin, FederationsView): |
|
290 |
form_class = FederationForm |
|
291 |
filename_param = 'federation_file' |
|
292 |
upload_dir = 'federations' |
|
293 |
|
|
294 |
federations_add = FederationsAdd.as_view() |
|
295 |
|
|
296 |
|
|
297 |
class FederationsDelete(TemplateView): |
|
298 |
def get(self, request, *args, **kwargs): |
|
299 |
ctx = self.get_context_data(**kwargs) |
|
300 |
s = request.GET.get('federation') |
|
301 |
if os.path.exists(os.path.join(ctx['federations_dir'], f)): |
|
302 |
try: |
|
303 |
os.remove(os.path.join(ctx['federations_dir'], f)) |
|
304 |
messages.info(request, _('Federation file %s successfully removed') % f) |
|
305 |
except IOError: |
|
306 |
messages.error(request, _('An error occured while removing file %s') % f) |
|
307 |
else: |
|
308 |
messages.error(request, _('Unknown federation file %s') % f) |
|
309 |
return redirect(self.get_success_url()) |
|
310 |
|
|
311 |
federations_delete = FederationsDelete.as_view() |
uauth/static/css/style.css | ||
---|---|---|
75 | 75 |
|
76 | 76 |
/* icons */ |
77 | 77 |
li.users a {background-image: url(icons/icon-personnes.png);} |
78 |
li.theme a {background-image: url(icons/icon-ressources.png);} |
|
78 |
li.theme a {background-image: url(icons/icon-ressources.png);} |
|
79 |
li.federations a {background-image: url(icons/icon-grid.png);} |
Formats disponibles : Unified diff
federation files management (#7067)