28 lines
1.1 KiB
Python
Raw Normal View History

from django.db import models
2013-09-29 13:53:35 +02:00
from django.contrib.auth.models import User, AbstractUser
from django.forms import ModelForm
2013-09-29 13:53:35 +02:00
from django.conf import settings
2013-09-29 14:07:24 +02:00
from django.contrib.auth.hashers import make_password
2013-09-28 18:02:13 +02:00
class Host(models.Model):
"""TODO: hash update_secret"""
2013-09-29 13:13:04 +02:00
fqdn = models.CharField(max_length=256, unique=True, verbose_name="Fully qualified domain name")
2013-09-28 18:02:13 +02:00
update_secret = models.CharField(max_length=256)
2013-09-29 01:21:44 +02:00
comment = models.CharField(max_length=256, default='', blank=True, null=True)
2013-09-28 18:02:13 +02:00
last_update = models.DateTimeField(auto_now=True)
created = models.DateTimeField(auto_now_add=True)
2013-09-29 13:53:35 +02:00
created_by = models.ForeignKey(settings.AUTH_USER_MODEL, related_name='hosts')
2013-09-28 18:02:13 +02:00
def __unicode__(self):
2013-09-29 01:18:28 +02:00
return u"%s - %s" % (self.fqdn, self.comment)
2013-09-29 13:53:35 +02:00
class ProxyUser(AbstractUser):
ipv4 = models.GenericIPAddressField(protocol='IPv4', blank=True, null=True)
ipv6 = models.GenericIPAddressField(protocol='IPv6', blank=True, null=True)
2013-09-29 14:07:24 +02:00
secret = models.CharField(max_length=256, default='', blank=True, null=True)
def create_secret(self):
self.secret = self.make_random_password()+self.username