8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-23 07:23:46 +00:00

Add autocomplete on cotisations

This commit is contained in:
chirac 2020-12-28 18:57:08 +01:00
parent 709c9a839e
commit f4dbec01c8
4 changed files with 64 additions and 4 deletions

View file

@ -45,7 +45,7 @@ from django.utils.translation import ugettext_lazy as _
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from re2o.field_permissions import FieldPermissionFormMixin from re2o.field_permissions import FieldPermissionFormMixin
from re2o.mixins import FormRevMixin from re2o.mixins import FormRevMixin, AutocompleteModelMixin, AutocompleteMultipleModelMixin
from .models import ( from .models import (
Article, Article,
Paiement, Paiement,
@ -79,6 +79,14 @@ class FactureForm(FieldPermissionFormMixin, FormRevMixin, ModelForm):
class Meta: class Meta:
model = Facture model = Facture
fields = "__all__" fields = "__all__"
widgets = {
"user": AutocompleteModelMixin(
url="/users/user-autocomplete",
),
"banque": AutocompleteModelMixin(
url="/cotisations/banque-autocomplete",
),
}
def clean(self): def clean(self):
cleaned_data = super(FactureForm, self).clean() cleaned_data = super(FactureForm, self).clean()

View file

@ -25,13 +25,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load bootstrap3 %} {% load bootstrap3 %}
{% load staticfiles%} {% load staticfiles%}
{% load massive_bootstrap_form %}
{% load i18n %} {% load i18n %}
{% block title %}{% trans "Creation and editing of invoices" %}{% endblock %} {% block title %}{% trans "Creation and editing of invoices" %}{% endblock %}
{% block content %} {% block content %}
{% bootstrap_form_errors factureform %} {% bootstrap_form_errors factureform %}
{{ factureform.media }}
<form class="form" method="post"> <form class="form" method="post">
{% csrf_token %} {% csrf_token %}
@ -40,7 +40,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% else %} {% else %}
<h3>{% trans "Edit invoice" %}</h3> <h3>{% trans "Edit invoice" %}</h3>
{% endif %} {% endif %}
{% massive_bootstrap_form factureform 'user' %} {% bootstrap_form factureform %}
{{ venteform.management_form }} {{ venteform.management_form }}
<h3>{% trans "Articles" %}</h3> <h3>{% trans "Articles" %}</h3>
<table class="table table-striped"> <table class="table table-striped">

View file

@ -27,7 +27,7 @@ from __future__ import unicode_literals
from django.conf.urls import url from django.conf.urls import url
from . import views from . import views, views_autocomplete
from . import payment_methods from . import payment_methods
urlpatterns = [ urlpatterns = [
@ -104,4 +104,6 @@ urlpatterns = [
url(r"^index_paiement/$", views.index_paiement, name="index-paiement"), url(r"^index_paiement/$", views.index_paiement, name="index-paiement"),
url(r"^control/$", views.control, name="control"), url(r"^control/$", views.control, name="control"),
url(r"^$", views.index, name="index"), url(r"^$", views.index, name="index"),
### Autocomplete Views
url(r'^banque-autocomplete/$', views_autocomplete.BanqueAutocomplete.as_view(), name='banque-autocomplete',),
] + payment_methods.urls.urlpatterns ] + payment_methods.urls.urlpatterns

View file

@ -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