refactoring and updating models for python 3.7 -- UUIDModel

This commit is contained in:
Adolfo Gómez García 2019-08-13 10:59:39 +02:00
parent c13da05baa
commit 77c6857973
22 changed files with 22 additions and 26 deletions

View File

@ -39,7 +39,7 @@ from django.http import HttpResponse
from PIL import Image as PILImage
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
from uds.models.util import getSqlDatetime
from uds.core.util import encoders

View File

@ -36,7 +36,7 @@ import typing
from django.db import models
from uds.core.environment import Environment
from uds.core import Module
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
logger = logging.getLogger(__name__)

View File

@ -39,7 +39,7 @@ from django.utils.translation import ugettext_noop as _
from uds.core.util import log
from uds.core.util import states
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
from uds.models.Tag import TaggingMixin
from uds.models.util import getSqlDatetime
from uds.core.util.calendar import CalendarChecker

View File

@ -38,7 +38,7 @@ from django.db.models import signals
from uds.models.Transport import Transport
from uds.core.util import net
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
from uds.models.Tag import TaggingMixin

View File

@ -36,7 +36,7 @@ from django.utils.translation import ugettext as _
from django.db import models
from django.db.models import Q
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
from uds.models.user import User
from uds.models.group import Group
from uds.models.util import getSqlDatetime

View File

@ -36,7 +36,7 @@ import requests
from django.db import models
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
from uds.models.Tag import TaggingMixin

View File

@ -42,7 +42,7 @@ from uds.core.environment import Environment
from uds.core.util import log
from uds.core.util import states
from uds.core.services.Exceptions import InvalidServiceException
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
from uds.models.Tag import TaggingMixin
from uds.models.OSManager import OSManager

View File

@ -35,7 +35,7 @@ import logging
from django.db import models
from django.utils.translation import ugettext as _
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
from uds.models.Image import Image
from uds.core.ui.images import DEFAULT_THUMB_BASE64

View File

@ -42,7 +42,7 @@ from uds.core.util import log
from uds.models.ServicesPool import DeployedService
from uds.models.util import getSqlDatetime
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
logger = logging.getLogger(__name__)

View File

@ -34,7 +34,7 @@ import logging
from django.db import models
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
logger = logging.getLogger(__name__)

View File

@ -34,7 +34,7 @@ import logging
from django.db import models
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
from uds.models.util import getSqlDatetime
from uds.core.managers import cryptoManager

View File

@ -33,7 +33,7 @@ import typing
from django.db import models
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
from uds.models.Tag import TaggingMixin
from uds.models.util import getSqlDatetime
from uds.models.util import NEVER

View File

@ -34,7 +34,7 @@ from django.db import models
from uds.core.util.tools import secondsToTimeString
from .UUIDModel import UUIDModel
from .uuid_model import UUIDModel
from .account import Account
from .user_service import UserService
from .util import NEVER

View File

@ -32,7 +32,7 @@
import logging
from django.db import models
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
from uds.models.Tag import TaggingMixin

View File

@ -37,7 +37,7 @@ from django.db import models
from uds.core.util import states
from .UUIDModel import UUIDModel
from .uuid_model import UUIDModel
from .calendar import Calendar
from .ServicesPool import ServicePool
from .MetaPool import MetaPool

View File

@ -43,7 +43,7 @@ from django.db import models
from uds.core.util import (calendar, log)
from .calendar import Calendar
from .UUIDModel import UUIDModel
from .uuid_model import UUIDModel
from .util import getSqlDatetime
from .ServicesPool import ServicePool
from .Transport import Transport

View File

@ -39,7 +39,7 @@ from django.db import models
from django.utils.translation import ugettext_lazy as _
from dateutil import rrule as rules
from .UUIDModel import UUIDModel
from .uuid_model import UUIDModel
from .calendar import Calendar
from .util import getSqlDatetime

View File

@ -35,7 +35,7 @@ import logging
import typing
from django.db import models
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
from uds.core.util import encoders

View File

@ -39,7 +39,7 @@ from django.db.models import signals
from uds.core.util.State import State
from uds.core.util import log
from .UUIDModel import UUIDModel
from .uuid_model import UUIDModel
from .authenticator import Authenticator
from .user import User
from .util import UnsavedForeignKey, getSqlDatetime

View File

@ -41,7 +41,7 @@ from uds.models.util import UnsavedForeignKey
from uds.models.util import NEVER
from uds.models.util import getSqlDatetime
from uds.core.util import log
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
# Not imported in runtime, just for type checking
if typing.TYPE_CHECKING:

View File

@ -40,7 +40,7 @@ from uds.core.environment import Environment
from uds.core.util import log
from uds.core.util import unique
from uds.core.util.State import State
from uds.models.UUIDModel import UUIDModel
from uds.models.uuid_model import UUIDModel
from uds.models.ServicesPool import DeployedService
from uds.models.ServicesPoolPublication import DeployedServicePublication

View File

@ -33,26 +33,22 @@
import logging
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from uds.core.util.model import generateUuid
logger = logging.getLogger(__name__)
@python_2_unicode_compatible
class UUIDModel(models.Model):
"""
Base abstract model for models that require an uuid
"""
# pylint: disable=model-missing-unicode
uuid = models.CharField(max_length=50, default=None, null=True, unique=True)
class Meta:
abstract = True
def genUuid(self):
def genUuid(self) -> str:
return generateUuid()
# Override default save to add uuid