# Path: libre/apps/lock_manager/literals.py
# DEFAULT_LOCK_TIMEOUT_VALUE = 30


import logging
from django.db import (models, transaction, DatabaseError)
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
from .managers import LockManager
from .literals import DEFAULT_LOCK_TIMEOUT_VALUE
from __future__ import absolute_import




logger = logging.getLogger(__name__)


class Lock(models.Model):
    creation_datetime = models.DateTimeField(verbose_name=_(u'creation datetime'))
    timeout = models.IntegerField(default=DEFAULT_LOCK_TIMEOUT_VALUE, verbose_name=_(u'timeout'))
    name = models.CharField(max_length=48, verbose_name=_(u'name'), unique=True)

    objects = LockManager()

    def __unicode__(self):
        return self.name

    def save(self, *args, **kwargs):
        self.creation_datetime = now()
        if not self.timeout and not kwargs.get('timeout'):

# Path: libre/apps/lock_manager/literals.py
# DEFAULT_LOCK_TIMEOUT_VALUE = 30


# Path: libre/apps/lock_manager/models.py
import logging
from django.db import (models, transaction, DatabaseError)
from django.utils.timezone import now
from django.utils.translation import ugettext_lazy as _
from .managers import LockManager
from .literals import DEFAULT_LOCK_TIMEOUT_VALUE

from __future__ import absolute_import




logger = logging.getLogger(__name__)


class Lock(models.Model):
    creation_datetime = models.DateTimeField(verbose_name=_(u'creation datetime'))
    timeout = models.IntegerField(default=DEFAULT_LOCK_TIMEOUT_VALUE, verbose_name=_(u'timeout'))
    name = models.CharField(max_length=48, verbose_name=_(u'name'), unique=True)

    objects = LockManager()

    def __unicode__(self):
        return self.name

    def save(self, *args, **kwargs):
        self.creation_datetime = now()
        if not self.timeout and not kwargs.get('timeout'):

            self.timeout = DEFAULT_LOCK_TIMEOUT_VALUE