import assigned status to device
This commit is contained in:
18
apps/pos_device/migrations/0057_device_assigned.py
Normal file
18
apps/pos_device/migrations/0057_device_assigned.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0 on 2025-08-16 12:20
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pos_device', '0056_remove_deviceassignment_unique_assign_client_device'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='device',
|
||||
name='assigned',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0 on 2025-08-16 12:22
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('pos_device', '0057_device_assigned'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='device',
|
||||
old_name='assigned',
|
||||
new_name='assigned_state',
|
||||
),
|
||||
]
|
||||
@@ -47,6 +47,7 @@ class Device(BaseModel):
|
||||
related_name='devices',
|
||||
null=True
|
||||
)
|
||||
assigned_state = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return f'Device: {self.serial} - {self.id}'
|
||||
|
||||
@@ -195,6 +195,10 @@ class DeviceAssignmentViewSet(viewsets.ModelViewSet):
|
||||
if serializer.is_valid():
|
||||
assignment = serializer.save()
|
||||
|
||||
# set device status to assigned
|
||||
assignment.device.assigned_state = True
|
||||
assignment.device.save()
|
||||
|
||||
# set organization having pos status
|
||||
if assignment.client.organization:
|
||||
assignment.client.organization.has_pos = True
|
||||
|
||||
Reference in New Issue
Block a user