add new fields to rancher

This commit is contained in:
2025-08-19 09:03:41 +03:30
parent b64c28b6d1
commit 14cd349a7d
15 changed files with 459 additions and 82 deletions

View File

View File

@@ -0,0 +1,34 @@
import typing
from apps.pos_device import models as pos_models
class POSDeviceMixin:
""" get require objects with values in request header """
def get_pos_device(self):
""" get device object by device serial in request header """
device = pos_models.Device.objects.get(
serial=self.request.headers.get('device-serial') # noqa
)
return device
def get_device_organization(self):
""" get device owner (organization) information """
organization = pos_models.DeviceAssignment.objects.filter(
device__serial=self.request.headers.get('device-serial') # noqa
).first().organization
return organization
def get_provider_organization(self):
""" get pos provider organization """
provider = pos_models.Organization.objects.get(
en_name=self.request.headers.get('device-provider') # noqa
)
return provider