From 004896cb26d4b81959416212b6263df0c218ca2b Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Fri, 5 Jan 2024 19:33:25 +0800 Subject: [PATCH] Add consumables and additional members field to transaction --- equipment_tracker/accounts/migrations/0001_initial.py | 2 +- equipment_tracker/accounts/tests.py | 3 --- equipment_tracker/breakages/migrations/0001_initial.py | 2 +- equipment_tracker/breakages/tests.py | 3 --- equipment_tracker/equipments/migrations/0001_initial.py | 2 +- equipment_tracker/equipments/tests.py | 3 --- equipment_tracker/transactions/migrations/0001_initial.py | 6 ++++-- equipment_tracker/transactions/models.py | 2 ++ equipment_tracker/transactions/serializers.py | 4 +++- equipment_tracker/transactions/tests.py | 3 --- 10 files changed, 12 insertions(+), 18 deletions(-) delete mode 100644 equipment_tracker/accounts/tests.py delete mode 100644 equipment_tracker/breakages/tests.py delete mode 100644 equipment_tracker/equipments/tests.py delete mode 100644 equipment_tracker/transactions/tests.py diff --git a/equipment_tracker/accounts/migrations/0001_initial.py b/equipment_tracker/accounts/migrations/0001_initial.py index 718073b..d5bd51e 100644 --- a/equipment_tracker/accounts/migrations/0001_initial.py +++ b/equipment_tracker/accounts/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.7 on 2023-12-29 10:21 +# Generated by Django 4.2.7 on 2024-01-05 10:26 import accounts.models import django.contrib.auth.models diff --git a/equipment_tracker/accounts/tests.py b/equipment_tracker/accounts/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/equipment_tracker/accounts/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/equipment_tracker/breakages/migrations/0001_initial.py b/equipment_tracker/breakages/migrations/0001_initial.py index 6e10fa7..fc19703 100644 --- a/equipment_tracker/breakages/migrations/0001_initial.py +++ b/equipment_tracker/breakages/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.7 on 2023-12-29 10:09 +# Generated by Django 4.2.7 on 2024-01-05 10:26 from django.db import migrations, models import django.db.models.deletion diff --git a/equipment_tracker/breakages/tests.py b/equipment_tracker/breakages/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/equipment_tracker/breakages/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/equipment_tracker/equipments/migrations/0001_initial.py b/equipment_tracker/equipments/migrations/0001_initial.py index 982e758..0ded7d2 100644 --- a/equipment_tracker/equipments/migrations/0001_initial.py +++ b/equipment_tracker/equipments/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.7 on 2023-12-29 10:09 +# Generated by Django 4.2.7 on 2024-01-05 10:26 from django.conf import settings from django.db import migrations, models diff --git a/equipment_tracker/equipments/tests.py b/equipment_tracker/equipments/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/equipment_tracker/equipments/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/equipment_tracker/transactions/migrations/0001_initial.py b/equipment_tracker/transactions/migrations/0001_initial.py index d7f1b8c..7a6c028 100644 --- a/equipment_tracker/transactions/migrations/0001_initial.py +++ b/equipment_tracker/transactions/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.7 on 2023-12-29 10:09 +# Generated by Django 4.2.7 on 2024-01-05 10:26 from django.conf import settings from django.db import migrations, models @@ -11,8 +11,8 @@ class Migration(migrations.Migration): initial = True dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('equipments', '0001_initial'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ @@ -21,6 +21,8 @@ class Migration(migrations.Migration): fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('remarks', models.TextField(max_length=512, null=True)), + ('additional_members', models.TextField(max_length=512, null=True)), + ('consumables', models.TextField(max_length=512, null=True)), ('transaction_status', models.CharField(choices=[('Pending Approval', 'Pending Approval'), ('Approved', 'Approved'), ('Rejected', 'Rejected'), ('Cancelled', 'Cancelled'), ('Borrowed', 'Borrowed'), ('Returned: Pending Checking', 'Returned: Pending Checking'), ('With Breakages: Pending Resolution', 'With Breakages: Pending Resolution'), ('Finalized', 'Finalized')], default='Pending', max_length=40)), ('subject', models.TextField(max_length=128)), ('timestamp', models.DateTimeField(default=django.utils.timezone.now, editable=False)), diff --git a/equipment_tracker/transactions/models.py b/equipment_tracker/transactions/models.py index 588963e..1a8d12c 100644 --- a/equipment_tracker/transactions/models.py +++ b/equipment_tracker/transactions/models.py @@ -28,6 +28,8 @@ class Transaction(models.Model): borrower = models.ForeignKey( CustomUser, on_delete=models.SET_NULL, null=True, related_name='borrowed_transactions') remarks = models.TextField(max_length=512, null=True) + additional_members = models.TextField(max_length=512, null=True) + consumables = models.TextField(max_length=512, null=True) teacher = models.ForeignKey( CustomUser, on_delete=models.SET_NULL, null=True, related_name='teacher_transactions') equipments = models.ManyToManyField(EquipmentInstance) diff --git a/equipment_tracker/transactions/serializers.py b/equipment_tracker/transactions/serializers.py index cb2633a..91be453 100644 --- a/equipment_tracker/transactions/serializers.py +++ b/equipment_tracker/transactions/serializers.py @@ -32,6 +32,8 @@ class TransactionSerializer(serializers.HyperlinkedModelSerializer): equipments = serializers.SlugRelatedField( many=True, slug_field='id', queryset=EquipmentInstance.objects.all(), required=True) subject = serializers.CharField(required=True, allow_null=False) + additional_members = serializers.CharField(required=False, allow_null=True) + consumables = serializers.CharField(required=False, allow_null=True) timestamp = serializers.DateTimeField( format="%m-%d-%Y %I:%M %p", read_only=True) @@ -41,7 +43,7 @@ class TransactionSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Transaction fields = ['id', 'borrower', 'teacher', 'subject', - 'equipments', 'remarks', 'transaction_status', 'timestamp'] + 'equipments', 'remarks', 'transaction_status', 'additional_members', 'consumables', 'timestamp'] read_only_fields = ['id', 'timestamp'] def to_representation(self, instance): diff --git a/equipment_tracker/transactions/tests.py b/equipment_tracker/transactions/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/equipment_tracker/transactions/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here.