bb-plane-fork/apps/api/plane/db/models/device.py
sriram veeraghanta 02d0ee3e0f
chore: add copyright (#8584)
* feat: adding new copyright info on all files

* chore: adding CI
2026-01-27 13:54:22 +05:30

42 lines
1.6 KiB
Python

# Copyright (c) 2023-present Plane Software, Inc. and contributors
# SPDX-License-Identifier: AGPL-3.0-only
# See the LICENSE file for details.
# models.py
from django.db import models
from django.conf import settings
from .base import BaseModel
class Device(BaseModel):
class DeviceType(models.TextChoices):
ANDROID = "ANDROID", "Android"
IOS = "IOS", "iOS"
WEB = "WEB", "Web"
DESKTOP = "DESKTOP", "Desktop"
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="devices")
device_id = models.CharField(max_length=255, blank=True, null=True)
device_type = models.CharField(max_length=255, choices=DeviceType.choices)
push_token = models.CharField(max_length=255, blank=True, null=True)
is_active = models.BooleanField(default=True)
class Meta:
db_table = "devices"
verbose_name = "Device"
verbose_name_plural = "Devices"
class DeviceSession(BaseModel):
device = models.ForeignKey(Device, on_delete=models.CASCADE, related_name="sessions")
session = models.ForeignKey("db.Session", on_delete=models.CASCADE, related_name="device_sessions")
is_active = models.BooleanField(default=True)
user_agent = models.CharField(max_length=255, null=True, blank=True)
ip_address = models.GenericIPAddressField(null=True, blank=True)
start_time = models.DateTimeField(auto_now_add=True)
end_time = models.DateTimeField(null=True, blank=True)
class Meta:
db_table = "device_sessions"
verbose_name = "Device Session"
verbose_name_plural = "Device Sessions"