Dispatcharr/apps/accounts/models.py
Patti 63fed9131a Add user stream profile settings and configurable service ports
- Add stream profile selection to user settings, allowing per-user default streaming profiles
- Add configurable environment variables for UWSGI_PORT, REDIS_PORT, and DAPHNE_PORT
- Add PostgreSQL database existence check in initialization scripts
- Update nginx, uwsgi configs, and entrypoint to use configurable ports
2026-01-20 21:43:17 +01:00

47 lines
1.4 KiB
Python

# apps/accounts/models.py
from django.db import models
from django.contrib.auth.models import AbstractUser, Permission
from core.models import StreamProfile
class User(AbstractUser):
"""
Custom user model for Dispatcharr.
Inherits from Django's AbstractUser to add additional fields if needed.
"""
class UserLevel(models.IntegerChoices):
STREAMER = 0, "Streamer"
STANDARD = 1, "Standard User"
ADMIN = 10, "Admin"
avatar_config = models.JSONField(default=dict, blank=True, null=True)
channel_profiles = models.ManyToManyField(
"dispatcharr_channels.ChannelProfile",
blank=True,
related_name="users",
)
user_level = models.IntegerField(default=UserLevel.STREAMER)
custom_properties = models.JSONField(default=dict, blank=True, null=True)
stream_profile = models.ForeignKey(
StreamProfile,
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name="users",
)
def __str__(self):
return self.username
def get_groups(self):
"""
Returns the groups (roles) the user belongs to.
"""
return self.groups.all()
def get_permissions(self):
"""
Returns the permissions assigned to the user and their groups.
"""
return self.user_permissions.all() | Permission.objects.filter(group__user=self)