From 7cecdad32c7b2254dbda3f0a38ada1b131fff409 Mon Sep 17 00:00:00 2001 From: Gregory Trullemans Date: Tue, 11 Jun 2024 10:05:50 +0200 Subject: [PATCH] Update project --- README.md | 2 +- billing/admin.py | 19 +++++++++----- billing/forms.py | 17 +++++++----- .../templates}/clients/create.html | 2 +- .../templates}/clients/details.html | 0 .../templates}/clients/listing.html | 0 .../billing => billing/templates}/compta.html | 0 .../templates}/contracts/create.html | 0 .../templates}/contracts/details.html | 0 .../templates}/contracts/listing.html | 0 .../templates}/prestations/create.html | 0 .../templates}/prestations/listing.html | 0 billing/views.py | 14 +++++----- comptaClub/settings.py | 2 ++ .../templates}/export_table.html | 0 .../templates}/transactions/create.html | 0 .../templates}/transactions/details.html | 0 .../templates}/transactions/listing.html | 0 .../templates}/year_listing.html | 0 .../year_transaction_export_ooo.html | 0 .../year_transaction_export_spf.html | 0 .../year_transaction_export_sxs.html | 0 .../templates}/year_transaction_listing.html | 0 comptabilite/views.py | 8 +++--- core/apps.py | 7 +++++ {templates => core/templates}/base.html | 0 {templates => core/templates}/login.html | 26 +------------------ .../templates}/create.html | 0 .../templates}/details.html | 0 .../templates}/listing.html | 0 30 files changed, 47 insertions(+), 50 deletions(-) rename {templates/billing => billing/templates}/clients/create.html (97%) rename {templates/billing => billing/templates}/clients/details.html (100%) rename {templates/billing => billing/templates}/clients/listing.html (100%) rename {templates/billing => billing/templates}/compta.html (100%) rename {templates/billing => billing/templates}/contracts/create.html (100%) rename {templates/billing => billing/templates}/contracts/details.html (100%) rename {templates/billing => billing/templates}/contracts/listing.html (100%) rename {templates/billing => billing/templates}/prestations/create.html (100%) rename {templates/billing => billing/templates}/prestations/listing.html (100%) rename {templates/comptability => comptabilite/templates}/export_table.html (100%) rename {templates/comptability => comptabilite/templates}/transactions/create.html (100%) rename {templates/comptability => comptabilite/templates}/transactions/details.html (100%) rename {templates/comptability => comptabilite/templates}/transactions/listing.html (100%) rename {templates/comptability => comptabilite/templates}/year_listing.html (100%) rename {templates/comptability => comptabilite/templates}/year_transaction_export_ooo.html (100%) rename {templates/comptability => comptabilite/templates}/year_transaction_export_spf.html (100%) rename {templates/comptability => comptabilite/templates}/year_transaction_export_sxs.html (100%) rename {templates/comptability => comptabilite/templates}/year_transaction_listing.html (100%) create mode 100644 core/apps.py rename {templates => core/templates}/base.html (100%) rename {templates => core/templates}/login.html (75%) rename {templates/event => eventCompta/templates}/create.html (100%) rename {templates/event => eventCompta/templates}/details.html (100%) rename {templates/event => eventCompta/templates}/listing.html (100%) diff --git a/README.md b/README.md index 127cc0e..077d04c 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Commande à taper : python manage.py importcsv -b nom_de_la_banque -f path_du_fichier_csv -Le fichier importer DOIT être un `.csv`. +Le fichier importer DOIT être un `.csv` et dois être push sur Heroku. Egalement possible de le faire sur heroku via la commandes suivantes : heroku login diff --git a/billing/admin.py b/billing/admin.py index c7d0f1e..39b2703 100644 --- a/billing/admin.py +++ b/billing/admin.py @@ -1,5 +1,11 @@ from django.contrib import admin +from django_admin_listfilter_dropdown.filters import ( + DropdownFilter, + ChoiceDropdownFilter, + RelatedDropdownFilter, +) + from .models import ( Client, Contract, @@ -7,6 +13,7 @@ from .models import ( ) +@admin.register(Client) class ClientAdmin(admin.ModelAdmin): model = Client @@ -14,6 +21,7 @@ class ClientAdmin(admin.ModelAdmin): search_fields = ("name", "adress", "city") +@admin.register(Contract) class ContractAdmin(admin.ModelAdmin): model = Contract @@ -22,13 +30,12 @@ class ContractAdmin(admin.ModelAdmin): list_filter = ("is_finished",) # 'date__year', +@admin.register(Prestation) class PrestationAdmin(admin.ModelAdmin): model = Prestation list_display = ("date", "label", "total_amount", "contract") - search_fields = ("label",) - - -admin.site.register(Client, ClientAdmin) -admin.site.register(Contract, ContractAdmin) -admin.site.register(Prestation, PrestationAdmin) + search_fields = ("label", "contract__title") + list_filter = ( + ("contract", RelatedDropdownFilter), + ) diff --git a/billing/forms.py b/billing/forms.py index 774b675..efbdd04 100644 --- a/billing/forms.py +++ b/billing/forms.py @@ -39,20 +39,25 @@ class ContractForm(forms.ModelForm): class Meta: model = Contract fields = ("title", "client", "advance", "reference", "is_finished", "is_paid", "description") + client = forms.ModelChoiceField(queryset=Contract.objects.all()) widgets = { "title": forms.TextInput( - attrs={"class": "form-control", "placeholder": "Titre de la facture"} + attrs={"class": "form-control", "placeholder": "Titre du contrat"} ), - "client": ModelSelect2Widget( - search_fields=["title__icontains", "contact__icontains", "city__icontains"], - max_results=10, - attrs={"data-minimum-input-length": 0, "class": "form-control"}, + "client": forms.Select( + attrs={ + "class": "form-control" + }, ), "advance": forms.TextInput( attrs={"class": "form-control", } ), "reference": forms.TextInput( - attrs={"class": "form-control", } + attrs={ + "class": "form-control", + "placeholder": date.today().strftime("%Y-%m") + "-00x", + "value": date.today().strftime("%Y-%m") + "-00x", + } ), "is_finished": forms.CheckboxInput( attrs={"class": "form-control", } diff --git a/templates/billing/clients/create.html b/billing/templates/clients/create.html similarity index 97% rename from templates/billing/clients/create.html rename to billing/templates/clients/create.html index 7f5d525..3b3a5ac 100644 --- a/templates/billing/clients/create.html +++ b/billing/templates/clients/create.html @@ -16,7 +16,7 @@
{% csrf_token %}
- +
{{ form.name }} {% if form.name.errors %}{% for error in form.name.errors %}{{error}}{% endfor %}{% endif %} diff --git a/templates/billing/clients/details.html b/billing/templates/clients/details.html similarity index 100% rename from templates/billing/clients/details.html rename to billing/templates/clients/details.html diff --git a/templates/billing/clients/listing.html b/billing/templates/clients/listing.html similarity index 100% rename from templates/billing/clients/listing.html rename to billing/templates/clients/listing.html diff --git a/templates/billing/compta.html b/billing/templates/compta.html similarity index 100% rename from templates/billing/compta.html rename to billing/templates/compta.html diff --git a/templates/billing/contracts/create.html b/billing/templates/contracts/create.html similarity index 100% rename from templates/billing/contracts/create.html rename to billing/templates/contracts/create.html diff --git a/templates/billing/contracts/details.html b/billing/templates/contracts/details.html similarity index 100% rename from templates/billing/contracts/details.html rename to billing/templates/contracts/details.html diff --git a/templates/billing/contracts/listing.html b/billing/templates/contracts/listing.html similarity index 100% rename from templates/billing/contracts/listing.html rename to billing/templates/contracts/listing.html diff --git a/templates/billing/prestations/create.html b/billing/templates/prestations/create.html similarity index 100% rename from templates/billing/prestations/create.html rename to billing/templates/prestations/create.html diff --git a/templates/billing/prestations/listing.html b/billing/templates/prestations/listing.html similarity index 100% rename from templates/billing/prestations/listing.html rename to billing/templates/prestations/listing.html diff --git a/billing/views.py b/billing/views.py index f45f949..ffde0a1 100644 --- a/billing/views.py +++ b/billing/views.py @@ -49,7 +49,7 @@ def client_listing(request): """ Récupère la liste de tous les clients. """ client_list = Client.objects.all() context = {"client_list": client_list} - return render(request, "billing/clients/listing.html", context) + return render(request, "clients/listing.html", context) @login_required @@ -62,7 +62,7 @@ def client_details(request, client_id=None): """ client = get_object_or_404(Client, pk=client_id) context = {"client": client} - return render(request, "billing/clients/details.html", context) + return render(request, "clients/details.html", context) @login_required @@ -90,7 +90,7 @@ def client_create_or_update(request, client_id=None): form = ClientForm(instance=client) context = {"form": form, "client_id": client_id} - return render(request, "billing/clients/create.html", context) + return render(request, "clients/create.html", context) @login_required @@ -99,7 +99,7 @@ def contract_listing(request): """ Récupère la liste de tous les contrats. """ contract_list = Contract.objects.all() context = {"contract_list": contract_list} - return render(request, "billing/contracts/listing.html", context) + return render(request, "contracts/listing.html", context) @login_required @@ -125,7 +125,7 @@ def contract_detail(request, contract_id): "prestation_count": prestation_count, "total": total, } - return render(request, "billing/contracts/details.html", context) + return render(request, "contracts/details.html", context) @login_required @@ -153,7 +153,7 @@ def contract_create_or_update(request, contract_id=None): form = ContractForm(instance=contract) context = {"form": form, "contract_id": contract_id} - return render(request, "billing/contracts/create.html", context) + return render(request, "contracts/create.html", context) @login_required @@ -206,7 +206,7 @@ def prestation_create_or_update(request, prestation_id=None): form = PrestationForm(instance=prestation) context = {"form": form, "prestation_id": prestation_id} - return render(request, "billing/prestations/create.html", context) + return render(request, "prestations/create.html", context) @login_required diff --git a/comptaClub/settings.py b/comptaClub/settings.py index ee831c4..ace86f2 100644 --- a/comptaClub/settings.py +++ b/comptaClub/settings.py @@ -47,10 +47,12 @@ INSTALLED_APPS = [ "django.contrib.messages", "django.contrib.staticfiles", "comptabilite.apps.ComptabiliteConfig", + "core.apps.CoreConfig", "eventCompta.apps.ManagementConfig", "billing.apps.BillingConfig", "django.contrib.humanize", "django_select2", + "django_admin_listfilter_dropdown", ] MIDDLEWARE = [ diff --git a/templates/comptability/export_table.html b/comptabilite/templates/export_table.html similarity index 100% rename from templates/comptability/export_table.html rename to comptabilite/templates/export_table.html diff --git a/templates/comptability/transactions/create.html b/comptabilite/templates/transactions/create.html similarity index 100% rename from templates/comptability/transactions/create.html rename to comptabilite/templates/transactions/create.html diff --git a/templates/comptability/transactions/details.html b/comptabilite/templates/transactions/details.html similarity index 100% rename from templates/comptability/transactions/details.html rename to comptabilite/templates/transactions/details.html diff --git a/templates/comptability/transactions/listing.html b/comptabilite/templates/transactions/listing.html similarity index 100% rename from templates/comptability/transactions/listing.html rename to comptabilite/templates/transactions/listing.html diff --git a/templates/comptability/year_listing.html b/comptabilite/templates/year_listing.html similarity index 100% rename from templates/comptability/year_listing.html rename to comptabilite/templates/year_listing.html diff --git a/templates/comptability/year_transaction_export_ooo.html b/comptabilite/templates/year_transaction_export_ooo.html similarity index 100% rename from templates/comptability/year_transaction_export_ooo.html rename to comptabilite/templates/year_transaction_export_ooo.html diff --git a/templates/comptability/year_transaction_export_spf.html b/comptabilite/templates/year_transaction_export_spf.html similarity index 100% rename from templates/comptability/year_transaction_export_spf.html rename to comptabilite/templates/year_transaction_export_spf.html diff --git a/templates/comptability/year_transaction_export_sxs.html b/comptabilite/templates/year_transaction_export_sxs.html similarity index 100% rename from templates/comptability/year_transaction_export_sxs.html rename to comptabilite/templates/year_transaction_export_sxs.html diff --git a/templates/comptability/year_transaction_listing.html b/comptabilite/templates/year_transaction_listing.html similarity index 100% rename from templates/comptability/year_transaction_listing.html rename to comptabilite/templates/year_transaction_listing.html diff --git a/comptabilite/views.py b/comptabilite/views.py index e0fa399..bc3864a 100644 --- a/comptabilite/views.py +++ b/comptabilite/views.py @@ -343,7 +343,7 @@ def year_listing(request): year_list.append((year.year, Transaction.objects.by_year(year.year).count(),)) context = {"year_list": year_list} - return render(request, "comptability/year_listing.html", context) + return render(request, "year_listing.html", context) @login_required @@ -390,7 +390,7 @@ def transaction_listing_for_year_and_type( "total_simulated": total_simulated, "total": total, } - return render(request, "comptability/transactions/listing.html", context) + return render(request, "transactions/listing.html", context) @login_required @@ -402,7 +402,7 @@ def transaction_details(request, transaction_id): transaction = Transaction.objects.get(pk=transaction_id) context = {"event": transaction.event, "transaction": transaction} # changed template - return render(request, "comptability/transactions/details.html", context) + return render(request, "transactions/details.html", context) @login_required @@ -430,4 +430,4 @@ def transaction_create_or_update(request, transaction_id=None): form = TransactionForm(instance=transaction) context = {"form": form, "transaction_id": transaction_id} - return render(request, "comptability/transactions/create.html", context) + return render(request, "transactions/create.html", context) diff --git a/core/apps.py b/core/apps.py new file mode 100644 index 0000000..aa7e4d9 --- /dev/null +++ b/core/apps.py @@ -0,0 +1,7 @@ +from django.apps import AppConfig + + +class CoreConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = "core" + verbose_name = "Core" diff --git a/templates/base.html b/core/templates/base.html similarity index 100% rename from templates/base.html rename to core/templates/base.html diff --git a/templates/login.html b/core/templates/login.html similarity index 75% rename from templates/login.html rename to core/templates/login.html index 74401a9..a48751e 100644 --- a/templates/login.html +++ b/core/templates/login.html @@ -47,7 +47,7 @@
{% if message %} -

{{message}}

+

{{ message }}

{% endif %}
@@ -68,34 +68,10 @@ - - {% block extra_script %}{% endblock %} -
{% block content %}{% endblock %}
diff --git a/templates/event/create.html b/eventCompta/templates/create.html similarity index 100% rename from templates/event/create.html rename to eventCompta/templates/create.html diff --git a/templates/event/details.html b/eventCompta/templates/details.html similarity index 100% rename from templates/event/details.html rename to eventCompta/templates/details.html diff --git a/templates/event/listing.html b/eventCompta/templates/listing.html similarity index 100% rename from templates/event/listing.html rename to eventCompta/templates/listing.html