diff --git a/osinaweb/billing/__pycache__/models.cpython-310.pyc b/osinaweb/billing/__pycache__/models.cpython-310.pyc
index a6926e1e..095a8b64 100644
Binary files a/osinaweb/billing/__pycache__/models.cpython-310.pyc and b/osinaweb/billing/__pycache__/models.cpython-310.pyc differ
diff --git a/osinaweb/billing/__pycache__/urls.cpython-310.pyc b/osinaweb/billing/__pycache__/urls.cpython-310.pyc
index ea549ec9..b7ce50d9 100644
Binary files a/osinaweb/billing/__pycache__/urls.cpython-310.pyc and b/osinaweb/billing/__pycache__/urls.cpython-310.pyc differ
diff --git a/osinaweb/billing/add/__pycache__/views.cpython-310.pyc b/osinaweb/billing/add/__pycache__/views.cpython-310.pyc
index 31911899..fae73479 100644
Binary files a/osinaweb/billing/add/__pycache__/views.cpython-310.pyc and b/osinaweb/billing/add/__pycache__/views.cpython-310.pyc differ
diff --git a/osinaweb/billing/add/views.py b/osinaweb/billing/add/views.py
index ce70902e..ca27fd2b 100644
--- a/osinaweb/billing/add/views.py
+++ b/osinaweb/billing/add/views.py
@@ -6,6 +6,7 @@ from django.template.loader import get_template
from django.conf import settings
import os
from weasyprint import HTML, CSS
+from django.core.files.base import ContentFile
@@ -110,7 +111,6 @@ def add_order (request, *args, **kwargs):
-
def add_invoice_pdf(request, order_id):
order = get_object_or_404(Order, id=order_id)
@@ -160,15 +160,10 @@ def add_invoice_pdf(request, order_id):
)
- # Save PDF to a file
- pdf_file_path = os.path.join(settings.MEDIA_ROOT, f'invoice_{invoice.id}.pdf')
- with open(pdf_file_path, 'wb') as pdf_file:
- pdf_file.write(pdf)
-
# Associate PDF file path with the Invoice object
- invoice.pdf = pdf_file_path
- invoice.save()
-
+ pdf_content = ContentFile(pdf)
+ filename = f'invoice_{invoice.invoice_number}.pdf'
+ invoice.pdf.save(filename, pdf_content, save=True)
# Return PDF
response = HttpResponse(pdf, content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="my_pdf.pdf"'
diff --git a/osinaweb/billing/migrations/0043_alter_invoice_pdf.py b/osinaweb/billing/migrations/0043_alter_invoice_pdf.py
new file mode 100644
index 00000000..1b0e646f
--- /dev/null
+++ b/osinaweb/billing/migrations/0043_alter_invoice_pdf.py
@@ -0,0 +1,18 @@
+# Generated by Django 4.2.5 on 2024-04-24 18:05
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('billing', '0042_order_due_date'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='invoice',
+ name='pdf',
+ field=models.FileField(blank=True, null=True, upload_to='generated_invoices'),
+ ),
+ ]
diff --git a/osinaweb/billing/migrations/0044_alter_orderitem_active.py b/osinaweb/billing/migrations/0044_alter_orderitem_active.py
new file mode 100644
index 00000000..ab6a4264
--- /dev/null
+++ b/osinaweb/billing/migrations/0044_alter_orderitem_active.py
@@ -0,0 +1,18 @@
+# Generated by Django 4.2.5 on 2024-04-24 18:46
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('billing', '0043_alter_invoice_pdf'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='orderitem',
+ name='active',
+ field=models.BooleanField(blank=True, null=True),
+ ),
+ ]
diff --git a/osinaweb/billing/migrations/__pycache__/0043_alter_invoice_pdf.cpython-310.pyc b/osinaweb/billing/migrations/__pycache__/0043_alter_invoice_pdf.cpython-310.pyc
new file mode 100644
index 00000000..f001cdff
Binary files /dev/null and b/osinaweb/billing/migrations/__pycache__/0043_alter_invoice_pdf.cpython-310.pyc differ
diff --git a/osinaweb/billing/migrations/__pycache__/0044_alter_orderitem_active.cpython-310.pyc b/osinaweb/billing/migrations/__pycache__/0044_alter_orderitem_active.cpython-310.pyc
new file mode 100644
index 00000000..b319ee0f
Binary files /dev/null and b/osinaweb/billing/migrations/__pycache__/0044_alter_orderitem_active.cpython-310.pyc differ
diff --git a/osinaweb/billing/models.py b/osinaweb/billing/models.py
index 6522c06d..1ebc4883 100644
--- a/osinaweb/billing/models.py
+++ b/osinaweb/billing/models.py
@@ -58,7 +58,7 @@ class Order(models.Model):
class OrderItem(models.Model):
order = models.ForeignKey(Order, on_delete=models.CASCADE)
item = models.ForeignKey(Item, on_delete=models.CASCADE)
- active = models.BooleanField(default=False, null=True)
+ active = models.BooleanField(null=True, blank=True)
purchased_at = models.DateField(null=True, blank=True)
end_at = models.DateField(blank=True, null=True)
terminated_at = models.DateField(blank=True, null=True)
@@ -98,7 +98,7 @@ class Invoice(models.Model):
invoice_number = models.CharField(max_length=100, null=True, blank=True)
order = models.OneToOneField(Order, on_delete=models.SET_NULL, null=True)
date_created = models.DateField()
- pdf = models.FileField(upload_to='uploaded_images', null=True, blank=True)
+ pdf = models.FileField(upload_to='generated_invoices', null=True, blank=True)
def __str__(self):
return self.invoice_number
def save(self, *args, **kwargs):
diff --git a/osinaweb/billing/templates/details_templates/invoice-details.html b/osinaweb/billing/templates/details_templates/invoice-details.html
index eddea3bb..b1ab4500 100644
--- a/osinaweb/billing/templates/details_templates/invoice-details.html
+++ b/osinaweb/billing/templates/details_templates/invoice-details.html
@@ -135,7 +135,7 @@
-

+
diff --git a/osinaweb/billing/templates/listing_pages/invoices.html b/osinaweb/billing/templates/listing_pages/invoices.html
index 01a14386..4b999768 100644
--- a/osinaweb/billing/templates/listing_pages/invoices.html
+++ b/osinaweb/billing/templates/listing_pages/invoices.html
@@ -77,14 +77,18 @@
{{invoice.date_created}}
+
-
+
+
+
|
+
{% endfor %}
diff --git a/osinaweb/billing/templates/listing_pages/orders.html b/osinaweb/billing/templates/listing_pages/orders.html
index 1f27d697..0a993721 100644
--- a/osinaweb/billing/templates/listing_pages/orders.html
+++ b/osinaweb/billing/templates/listing_pages/orders.html
@@ -95,10 +95,12 @@
{% endif %}
{% if order.invoice %}
-
+
+
+
{% endif %}
diff --git a/osinaweb/customercore/__pycache__/models.cpython-310.pyc b/osinaweb/customercore/__pycache__/models.cpython-310.pyc
index 850794c8..e2a38eae 100644
Binary files a/osinaweb/customercore/__pycache__/models.cpython-310.pyc and b/osinaweb/customercore/__pycache__/models.cpython-310.pyc differ
diff --git a/osinaweb/customercore/__pycache__/views.cpython-310.pyc b/osinaweb/customercore/__pycache__/views.cpython-310.pyc
index 6ba494b8..0ff5b63a 100644
Binary files a/osinaweb/customercore/__pycache__/views.cpython-310.pyc and b/osinaweb/customercore/__pycache__/views.cpython-310.pyc differ
diff --git a/osinaweb/customercore/migrations/0001_initial.py b/osinaweb/customercore/migrations/0001_initial.py
new file mode 100644
index 00000000..45f72185
--- /dev/null
+++ b/osinaweb/customercore/migrations/0001_initial.py
@@ -0,0 +1,59 @@
+# Generated by Django 4.2.5 on 2024-04-24 19:30
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ('osinacore', '0075_remove_ticketattachment_ticket_and_more'),
+ ('billing', '0044_alter_orderitem_active'),
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Ticket',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('title', models.CharField(max_length=400)),
+ ('description', models.TextField(blank=True, null=True)),
+ ('regarding', models.CharField(choices=[('General/Account/Billing', 'General/Account/Billing'), ('Project/Product', 'Project/Product')], max_length=50, null=True)),
+ ('opened_date', models.DateTimeField()),
+ ('department', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='osinacore.department')),
+ ('opened_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
+ ('product', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='billing.item')),
+ ('project', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='osinacore.project')),
+ ],
+ ),
+ migrations.CreateModel(
+ name='TicketUpdate',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('description', models.TextField(blank=True, null=True)),
+ ('date_added', models.DateTimeField()),
+ ('added_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
+ ('ticket', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='customercore.ticket')),
+ ],
+ ),
+ migrations.CreateModel(
+ name='TicketReaction',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('ticket_update', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='customercore.ticketupdate')),
+ ],
+ ),
+ migrations.CreateModel(
+ name='TicketAttachment',
+ fields=[
+ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('file', models.FileField(upload_to='')),
+ ('ticket', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='customercore.ticket')),
+ ('ticket_update', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='customercore.ticketupdate')),
+ ],
+ ),
+ ]
diff --git a/osinaweb/customercore/migrations/__pycache__/0001_initial.cpython-310.pyc b/osinaweb/customercore/migrations/__pycache__/0001_initial.cpython-310.pyc
new file mode 100644
index 00000000..a9fcf9b5
Binary files /dev/null and b/osinaweb/customercore/migrations/__pycache__/0001_initial.cpython-310.pyc differ
diff --git a/osinaweb/customercore/models.py b/osinaweb/customercore/models.py
index 71a83623..c4a7c957 100644
--- a/osinaweb/customercore/models.py
+++ b/osinaweb/customercore/models.py
@@ -1,3 +1,39 @@
from django.db import models
-
+from billing.models import *
# Create your models here.
+
+class Ticket(models.Model):
+ REGARDING_CHOICES = (
+ ('General/Account/Billing', 'General/Account/Billing'),
+ ('Project/Product', 'Project/Product'),
+ )
+ title = models.CharField(max_length=400)
+ description = models.TextField(null=True, blank=True)
+ regarding = models.CharField(max_length=50, choices=REGARDING_CHOICES, null=True)
+ project = models.ForeignKey(Project, on_delete=models.SET_NULL, blank=True, null=True)
+ product = models.ForeignKey(Item, on_delete=models.SET_NULL, blank=True, null=True)
+ department = models.ForeignKey(Department, on_delete=models.SET_NULL,null=True)
+ opened_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
+ opened_date = models.DateTimeField()
+
+
+class TicketUpdate(models.Model):
+ ticket = models.ForeignKey(Ticket, on_delete=models.CASCADE)
+ description = models.TextField(null=True, blank=True)
+ added_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
+ date_added = models.DateTimeField()
+
+
+class TicketAttachment(models.Model):
+ ticket = models.ForeignKey(Ticket, on_delete=models.CASCADE)
+ ticket_update = models.ForeignKey(TicketUpdate, on_delete=models.CASCADE)
+ file = models.FileField()
+
+
+class TicketReaction(models.Model):
+ REGARDING_CHOICES = (
+ ('Happy', 'Happy'),
+ ('Indifferent', 'Indifferent'),
+ ('Sad', 'Sad'),
+ )
+ ticket_update = models.ForeignKey(TicketUpdate, on_delete=models.CASCADE)
\ No newline at end of file
diff --git a/osinaweb/customercore/templates/add_templates/customer-add-ticket.html b/osinaweb/customercore/templates/add_templates/customer-add-ticket.html
index 04029264..9fcea554 100644
--- a/osinaweb/customercore/templates/add_templates/customer-add-ticket.html
+++ b/osinaweb/customercore/templates/add_templates/customer-add-ticket.html
@@ -6,14 +6,14 @@
- Open Ticket
+ Create Ticket