Remove section field from transactions. This should be in the user model instead

This commit is contained in:
Keannu Bernasol 2024-01-14 21:05:08 +08:00
parent 4b51ccebc2
commit 7b511e0d8c
4 changed files with 1 additions and 21 deletions

View file

@ -1,18 +0,0 @@
# Generated by Django 5.0.1 on 2024-01-11 03:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('transactions', '0002_alter_transaction_transaction_status'),
]
operations = [
migrations.AddField(
model_name='transaction',
name='section',
field=models.CharField(max_length=255, null=True),
),
]

View file

@ -38,7 +38,6 @@ class Transaction(models.Model):
max_length=40, choices=TRANSACTION_STATUS_CHOICES, default='Pending', db_index=True)
subject = models.TextField(max_length=128)
timestamp = models.DateTimeField(default=now, editable=False)
section = models.CharField(max_length=255, null=True)
def __str__(self):
return f"Transaction #{self.id} under {self.teacher} by {self.borrower}"

View file

@ -41,7 +41,6 @@ class TransactionSerializer(serializers.HyperlinkedModelSerializer):
required=False, allow_null=True, allow_blank=True)
timestamp = serializers.DateTimeField(
format="%m-%d-%Y %I:%M %p", read_only=True)
section = serializers.CharField(required=True, allow_null=False)
transaction_status = serializers.ChoiceField(
choices=Transaction.TRANSACTION_STATUS_CHOICES)
@ -49,7 +48,7 @@ class TransactionSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Transaction
fields = ['id', 'borrower', 'teacher', 'subject',
'equipments', 'remarks', 'transaction_status', 'additional_members', 'consumables', 'timestamp', 'section']
'equipments', 'remarks', 'transaction_status', 'additional_members', 'consumables', 'timestamp']
read_only_fields = ['id', 'timestamp']
def to_representation(self, instance):