diff --git a/equipment_tracker/accounts/admin.py b/equipment_tracker/accounts/admin.py index 33db357..c7b0b42 100644 --- a/equipment_tracker/accounts/admin.py +++ b/equipment_tracker/accounts/admin.py @@ -6,7 +6,8 @@ from .models import CustomUser class CustomUserAdmin(UserAdmin): model = CustomUser - list_display = UserAdmin.list_display + ('is_technician', 'is_teacher') + list_display = UserAdmin.list_display + \ + ('is_technician', 'is_teacher', 'id') fieldsets = UserAdmin.fieldsets + ( (None, {'fields': ('is_technician', 'is_teacher')}), ) diff --git a/equipment_tracker/transactions/serializers.py b/equipment_tracker/transactions/serializers.py index 3aca4d3..0416051 100644 --- a/equipment_tracker/transactions/serializers.py +++ b/equipment_tracker/transactions/serializers.py @@ -58,10 +58,10 @@ class TransactionSerializer(serializers.HyperlinkedModelSerializer): def create(self, validated_data): # Any transactions created will be associated with the one sending the POST/CREATE request user = self.context['request'].user - validated_data.data['borrower'] = user + validated_data['borrower'] = user # All created transactions will be labelled as Pending - validated_data['transaction_status'] = 'Pending' + validated_data['transaction_status'] = 'Pending Approval' # If no teacher responsible for the borrow transaction is selected, raise an error if 'teacher' not in validated_data: @@ -101,10 +101,10 @@ class TransactionSerializer(serializers.HyperlinkedModelSerializer): equipments = validated_data['equipments'] for equipment in equipments: existing__pending_transactions = Transaction.objects.filter( - equipments=equipment, transaction_status__in=['Pending', 'Approved', 'Borrowed', 'With Breakages: Pending Resolution']) + equipments=equipment, transaction_status__in=['Pending Approval', 'Approved', 'Borrowed', 'With Breakages: Pending Resolution', 'Returned: Pending Checking']) if existing__pending_transactions.exists(): raise serializers.ValidationError( - f"Cannot add Equipment #{equipment.id}. It is still part of a non-finalized transaction") + f"Cannot add Equipment ID:{equipment.id}. It is still part of a non-finalized transaction") return super().create(validated_data)