-
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
218 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.db.models import Q | ||
from django.http import HttpRequest | ||
from django.shortcuts import render | ||
|
||
from backend.models import InvoiceProduct | ||
|
||
|
||
def fetch_products(request: HttpRequest): | ||
results = [] | ||
search_text = request.GET.get("search_existing_service") | ||
if search_text: | ||
results = ( | ||
InvoiceProduct.objects.filter(user=request.user) | ||
.filter( | ||
Q(name__icontains=search_text) | Q(description__icontains=search_text) | ||
) | ||
.order_by("name") | ||
) | ||
else: | ||
results = InvoiceProduct.objects.filter(user=request.user).order_by("name") | ||
|
||
return render(request, "pages/products/fetched_items.html", {"products": results}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.urls import path | ||
|
||
from . import fetch | ||
|
||
urlpatterns = [ | ||
path("fetch/", fetch.fetch_products, name="fetch"), | ||
] | ||
|
||
app_name = "products" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Generated by Django 4.1.7 on 2023-12-18 13:24 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("backend", "0004_invoice_client_is_representative"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="InvoiceProduct", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("name", models.CharField(max_length=50)), | ||
("description", models.CharField(max_length=100)), | ||
("quantity", models.IntegerField()), | ||
( | ||
"rate", | ||
models.DecimalField( | ||
blank=True, decimal_places=2, max_digits=15, null=True | ||
), | ||
), | ||
( | ||
"user", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{# This is for the INVOICE CREATION dropdown #} | ||
{% for product in products %} | ||
<li> | ||
<button hx-post="{% url 'api:invoices:services add' %}" hx-include="#services_table_body" | ||
hx-swap="innerHTML" | ||
hx-target="#services_table_body" | ||
hx-vals='{"existing_service": "{{ product.id }}"}'> | ||
{{ product.name }} <br> {{ product.description }} | ||
<div class="btn btn-primary btn-sm btn-circle absolute right-2"> | ||
<i class="fa-solid fa-plus"></i> | ||
</div> | ||
</button> | ||
</li> | ||
{% endfor %} |