|
|
|
@ -9,15 +9,11 @@ from django.contrib.auth.models import User
|
|
|
|
|
from django.contrib.gis.db import models
|
|
|
|
|
from django.core.validators import MinValueValidator
|
|
|
|
|
from django.db.models import Sum
|
|
|
|
|
from django.utils.timezone import now
|
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
|
|
|
|
from compensation.settings import COMPENSATION_IDENTIFIER_LENGTH, COMPENSATION_IDENTIFIER_TEMPLATE, \
|
|
|
|
|
ECO_ACCOUNT_IDENTIFIER_LENGTH, ECO_ACCOUNT_IDENTIFIER_TEMPLATE
|
|
|
|
|
from intervention.models import Intervention, ResponsibilityData
|
|
|
|
|
from konova.models import BaseObject, BaseResource, Geometry, UuidModel
|
|
|
|
|
from konova.settings import DEFAULT_SRID_RLP, LANIS_LINK_TEMPLATE
|
|
|
|
|
from konova.utils.generators import generate_random_string
|
|
|
|
|
from user.models import UserActionLogEntry
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -146,22 +142,6 @@ class Compensation(AbstractCompensation):
|
|
|
|
|
def __str__(self):
|
|
|
|
|
return "{}".format(self.identifier)
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def _generate_new_identifier() -> str:
|
|
|
|
|
""" Generates a new identifier for the intervention object
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
str
|
|
|
|
|
"""
|
|
|
|
|
curr_month = str(now().month)
|
|
|
|
|
curr_year = str(now().year)
|
|
|
|
|
rand_str = generate_random_string(
|
|
|
|
|
length=COMPENSATION_IDENTIFIER_LENGTH,
|
|
|
|
|
only_numbers=True,
|
|
|
|
|
)
|
|
|
|
|
_str = "{}{}{}".format(curr_month, curr_year, rand_str)
|
|
|
|
|
return COMPENSATION_IDENTIFIER_TEMPLATE.format(_str)
|
|
|
|
|
|
|
|
|
|
def save(self, *args, **kwargs):
|
|
|
|
|
if self.identifier is None or len(self.identifier) == 0:
|
|
|
|
|
# Create new identifier
|
|
|
|
@ -284,22 +264,6 @@ class EcoAccount(AbstractCompensation):
|
|
|
|
|
# ToDo
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def _generate_new_identifier() -> str:
|
|
|
|
|
""" Generates a new identifier for the intervention object
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
str
|
|
|
|
|
"""
|
|
|
|
|
curr_month = str(now().month)
|
|
|
|
|
curr_year = str(now().year)
|
|
|
|
|
rand_str = generate_random_string(
|
|
|
|
|
length=ECO_ACCOUNT_IDENTIFIER_LENGTH,
|
|
|
|
|
only_numbers=True,
|
|
|
|
|
)
|
|
|
|
|
_str = "{}{}{}".format(curr_month, curr_year, rand_str)
|
|
|
|
|
return ECO_ACCOUNT_IDENTIFIER_TEMPLATE.format(_str)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class EcoAccountWithdraw(BaseResource):
|
|
|
|
|
"""
|
|
|
|
|