initial commit
This commit is contained in:
commit
ce809235e5
34 changed files with 736 additions and 0 deletions
64
settings/models.py
Normal file
64
settings/models.py
Normal file
|
@ -0,0 +1,64 @@
|
|||
from django.db import models
|
||||
from django.core.validators import RegexValidator
|
||||
|
||||
|
||||
class SIPAccount(models.Model):
|
||||
ip = models.GenericIPAddressField()
|
||||
username = models.CharField(max_length=255)
|
||||
password = models.CharField(max_length=255)
|
||||
display_name = models.CharField(max_length=255)
|
||||
|
||||
tone_scheme = models.CharField(max_length=10)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.username}@{self.ip}'
|
||||
|
||||
class Meta:
|
||||
verbose_name = "SIP Account"
|
||||
verbose_name_plural = "SIP Accounts"
|
||||
ordering = ['display_name']
|
||||
|
||||
|
||||
class SnomPhoneType(models.Model):
|
||||
model = models.CharField(max_length=255)
|
||||
phonebook_function_key = models.IntegerField(default=-1, help_text='if set to anything >+0, phonebook will be provisioned on this key')
|
||||
|
||||
def __str__(self):
|
||||
return self.model
|
||||
|
||||
|
||||
class SnomFunctionKey(models.Model):
|
||||
phone_type = models.ForeignKey(SnomPhoneType, on_delete=models.CASCADE)
|
||||
key_id = models.IntegerField()
|
||||
|
||||
label = models.CharField(max_length=255)
|
||||
value = models.CharField(max_length=255)
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.phone_type.model}:{self.key_id}'
|
||||
|
||||
class Meta:
|
||||
ordering = ['phone_type', 'key_id']
|
||||
|
||||
constraints = [
|
||||
models.UniqueConstraint(fields=['phone_type', 'key_id'], name='phone_type_key_id_unique')
|
||||
]
|
||||
|
||||
|
||||
class SnomPhone(models.Model):
|
||||
mac_address = models.CharField(max_length=12, validators=[RegexValidator('^[0-9A-F]{12}$')], primary_key=True)
|
||||
phone_name = models.CharField(max_length=255)
|
||||
admin_password = models.CharField(max_length=255)
|
||||
timezone = models.CharField(max_length=10, help_text="https://service.snom.com/display/wiki/timezone", default="GBR-0")
|
||||
|
||||
sip_account = models.ForeignKey(SIPAccount, on_delete=models.PROTECT)
|
||||
phone_type = models.ForeignKey(SnomPhoneType, on_delete=models.PROTECT)
|
||||
|
||||
def __str__(self):
|
||||
return self.phone_name
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Snom Phone"
|
||||
verbose_name_plural = "Snom Phones"
|
||||
ordering = ['phone_name']
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue