diff --git a/cotisations/forms.py b/cotisations/forms.py index 0f135963..926db818 100644 --- a/cotisations/forms.py +++ b/cotisations/forms.py @@ -45,7 +45,7 @@ from django.utils.translation import ugettext_lazy as _ from django.shortcuts import get_object_or_404 from re2o.field_permissions import FieldPermissionFormMixin -from re2o.mixins import FormRevMixin +from re2o.mixins import FormRevMixin, AutocompleteModelMixin, AutocompleteMultipleModelMixin from .models import ( Article, Paiement, @@ -79,6 +79,14 @@ class FactureForm(FieldPermissionFormMixin, FormRevMixin, ModelForm): class Meta: model = Facture fields = "__all__" + widgets = { + "user": AutocompleteModelMixin( + url="/users/user-autocomplete", + ), + "banque": AutocompleteModelMixin( + url="/cotisations/banque-autocomplete", + ), + } def clean(self): cleaned_data = super(FactureForm, self).clean() diff --git a/cotisations/templates/cotisations/edit_facture.html b/cotisations/templates/cotisations/edit_facture.html index ca55cb66..b2f58df9 100644 --- a/cotisations/templates/cotisations/edit_facture.html +++ b/cotisations/templates/cotisations/edit_facture.html @@ -25,13 +25,13 @@ with this program; if not, write to the Free Software Foundation, Inc., {% load bootstrap3 %} {% load staticfiles%} -{% load massive_bootstrap_form %} {% load i18n %} {% block title %}{% trans "Creation and editing of invoices" %}{% endblock %} {% block content %} {% bootstrap_form_errors factureform %} +{{ factureform.media }}
{% csrf_token %} @@ -40,7 +40,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {% else %}

{% trans "Edit invoice" %}

{% endif %} - {% massive_bootstrap_form factureform 'user' %} + {% bootstrap_form factureform %} {{ venteform.management_form }}

{% trans "Articles" %}

diff --git a/cotisations/urls.py b/cotisations/urls.py index 6baf74c7..c78effa6 100644 --- a/cotisations/urls.py +++ b/cotisations/urls.py @@ -27,7 +27,7 @@ from __future__ import unicode_literals from django.conf.urls import url -from . import views +from . import views, views_autocomplete from . import payment_methods urlpatterns = [ @@ -104,4 +104,6 @@ urlpatterns = [ url(r"^index_paiement/$", views.index_paiement, name="index-paiement"), url(r"^control/$", views.control, name="control"), url(r"^$", views.index, name="index"), + ### Autocomplete Views + url(r'^banque-autocomplete/$', views_autocomplete.BanqueAutocomplete.as_view(), name='banque-autocomplete',), ] + payment_methods.urls.urlpatterns diff --git a/cotisations/views_autocomplete.py b/cotisations/views_autocomplete.py new file mode 100644 index 00000000..70afe855 --- /dev/null +++ b/cotisations/views_autocomplete.py @@ -0,0 +1,50 @@ +# -*- mode: python; coding: utf-8 -*- +# Re2o est un logiciel d'administration développé initiallement au Rézo Metz. Il +# se veut agnostique au réseau considéré, de manière à être installable en +# quelques clics. +# +# Copyright © 2017-2020 Gabriel Détraz +# Copyright © 2017-2020 Jean-Romain Garnier +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# App de gestion des users pour re2o +# Lara Kermarec, Gabriel Détraz, Lemesle Augustin +# Gplv2 +""" +Django views autocomplete view + +Here are defined the autocomplete class based view. + +""" +from __future__ import unicode_literals + +from django.db.models import Q, Value, CharField + +from .models import ( + Banque +) + +from re2o.mixins import AutocompleteViewMixin + +from re2o.acl import ( + can_view_all, +) + + +class BanqueAutocomplete(AutocompleteViewMixin): + obj_type = Banque + +