Initial commit from ZIP
This commit is contained in:
commit
378d4692a9
454 files changed
+40367
No files matched your search
@@ -0,0 +1,26 @@
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import F
|
||||
|
||||
from rules.contrib.models import RulesModel
|
||||
from outbo.apps.core.models import TimestampableDeletableMixin, SoftDeletableManager
|
||||
|
||||
|
||||
class ProjectNumberManager(SoftDeletableManager):
|
||||
def get_next_number(self, prefix):
|
||||
current = self.get_or_create(prefix=prefix)[0]
|
||||
value = current.value
|
||||
|
||||
current.value = F("value") + 1
|
||||
current.save()
|
||||
|
||||
return value
|
||||
|
||||
|
||||
class ProjectNumber(TimestampableDeletableMixin, RulesModel):
|
||||
objects = ProjectNumberManager()
|
||||
all_objects = ProjectNumberManager(alive_only=False)
|
||||
|
||||
prefix = models.CharField(max_length=4)
|
||||
value = models.PositiveIntegerField(default=1)
|
||||
Reference in new issue
Block a user