2016-12-20 16:43:52 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
|
2017-12-11 09:08:43 +00:00
|
|
|
from django.core.exceptions import ValidationError
|
|
|
|
from common.utils import validate_ssh_private_key
|
|
|
|
|
2016-12-20 16:43:52 +00:00
|
|
|
|
2017-04-04 03:14:59 +00:00
|
|
|
__all__ = ['init_model', 'generate_fake']
|
2016-12-20 16:43:52 +00:00
|
|
|
|
|
|
|
|
2017-04-04 03:14:59 +00:00
|
|
|
def init_model():
|
2018-03-21 10:13:16 +00:00
|
|
|
from . import SystemUser, AdminUser, Asset
|
|
|
|
for cls in [SystemUser, AdminUser, Asset]:
|
2016-12-20 16:43:52 +00:00
|
|
|
if hasattr(cls, 'initial'):
|
|
|
|
cls.initial()
|
|
|
|
|
|
|
|
|
|
|
|
def generate_fake():
|
2018-03-21 10:13:16 +00:00
|
|
|
from . import SystemUser, AdminUser, Asset
|
|
|
|
for cls in [SystemUser, AdminUser, Asset]:
|
2017-01-07 14:34:12 +00:00
|
|
|
if hasattr(cls, 'generate_fake'):
|
|
|
|
cls.generate_fake()
|
2016-12-20 16:43:52 +00:00
|
|
|
|
|
|
|
|
2017-12-11 09:08:43 +00:00
|
|
|
def private_key_validator(value):
|
|
|
|
if not validate_ssh_private_key(value):
|
|
|
|
raise ValidationError(
|
|
|
|
_('%(value)s is not an even number'),
|
|
|
|
params={'value': value},
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2016-12-20 16:43:52 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
pass
|