From 94e740fb04f1e42d983eadcc8334fb88f55f76c6 Mon Sep 17 00:00:00 2001 From: Skia Date: Sun, 18 Dec 2016 17:59:08 +0100 Subject: [PATCH] Small improvement in file prop view --- core/templates/core/user_pictures.jinja | 3 +-- core/views/files.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/core/templates/core/user_pictures.jinja b/core/templates/core/user_pictures.jinja index 3a79454e..c435e26d 100644 --- a/core/templates/core/user_pictures.jinja +++ b/core/templates/core/user_pictures.jinja @@ -1,5 +1,4 @@ {% extends "core/base.jinja" %} -{% from "core/macros.jinja" import user_link_with_pict, delete_godfather %} {% block title %} {% trans user_name=profile.get_display_name() %}{{ user_name }}'s pictures{% endtrans %} @@ -23,7 +22,7 @@ {%- endif %}
- {{ r.picture.get_display_name() }} + {{ r.picture.get_display_name() }}
{%- endfor %} diff --git a/core/views/files.py b/core/views/files.py index 31596d74..bd1a3c58 100644 --- a/core/views/files.py +++ b/core/views/files.py @@ -16,6 +16,8 @@ from django import forms import os +from ajax_select import make_ajax_form, make_ajax_field + from core.models import SithFile, RealGroup, Notification from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, CanCreateMixin, can_view, not_found from counter.models import Counter @@ -111,12 +113,21 @@ class FileEditView(CanEditMixin, UpdateView): kwargs['popup'] = 'popup' return kwargs +class FileEditPropForm(forms.ModelForm): + class Meta: + model = SithFile + fields = ['parent', 'owner', 'edit_groups', 'view_groups'] + parent = make_ajax_field(SithFile, 'parent', 'files', help_text="") + edit_groups = make_ajax_field(SithFile, 'edit_groups', 'groups', help_text="") + view_groups = make_ajax_field(SithFile, 'view_groups', 'groups', help_text="") + + class FileEditPropView(CanEditPropMixin, UpdateView): model = SithFile pk_url_kwarg = "file_id" template_name = 'core/file_edit.jinja' context_object_name = "file" - fields = ['parent', 'owner', 'edit_groups', 'view_groups'] + form_class = FileEditPropForm def get_form(self, form_class=None): form = super(FileEditPropView, self).get_form(form_class)