@@ -0,0 +1,18 @@ +# Generated by Django 5.0.11 on 2026-04-03 14:47 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('authentication', '0025_remove_customusermodel_idx_users_email_upper_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='businessuserhost', + name='initial_token_limit', + field=models.DecimalField(blank=True, decimal_places=2, max_digits=50, null=True, verbose_name='Initial token limit'), + ), + ] @@ -63,6 +63,14 @@ class BusinessUserHost(BaseModel): ) token_cap_enabled = models.BooleanField(default=False, verbose_name=_('Token low balance cap enabled')) + initial_token_limit = models.DecimalField( + max_digits=50, + decimal_places=2, + null=True, + blank=True, + verbose_name=_('Initial token limit'), + ) + # Judicial information ITN = models.BigIntegerField(null=True, blank=True, verbose_name=_('ITN')) PSRN = models.BigIntegerField(null=True, blank=True, verbose_name=_('PSRN')) @@ -40,11 +40,14 @@ class BusinessAccountService: host: BusinessUserHost, account_privileges: str, ): - account, _ = BusinessAccount.objects.update_or_create( + account, created = BusinessAccount.objects.update_or_create( user=user, parent_company=host, defaults={'account_privileges': account_privileges}, ) + if created and (initial_token_limit := host.initial_token_limit) is not None: + account.token_limit = initial_token_limit + account.save(update_fields=['token_limit']) return cls(account) @classmethod @@ -151,6 +151,8 @@ class BusinessHostService: and (token_cap := serializer.validated_data.get('token_cap', None)) is not None ): company.token_cap = token_cap + if 'initial_token_limit' in serializer.validated_data: + company.initial_token_limit = serializer.validated_data['initial_token_limit'] company.save() if serialize: return BusinessHostSerializer(company, context={'token_cap_enabled': company.token_cap_enabled}) @@ -184,6 +184,9 @@ class BusinessHostUpdateSerializer(serializers.Serializer): token_cap_emails = serializers.ListField(child=serializers.EmailField(), required=False) token_cap_enabled = serializers.BooleanField(required=False) token_cap = serializers.DecimalField(max_digits=15, decimal_places=2, required=False) + initial_token_limit = serializers.DecimalField( + max_digits=50, decimal_places=2, required=False, allow_null=True + ) class NeuronModelStatisticsSerialiser(serializers.Serializer): @@ -216,6 +219,9 @@ class NewBusinessHostSerializer(serializers.Serializer): corporate_email = serializers.EmailField(required=False) corporate_phone = serializers.CharField(required=False) job_title = serializers.CharField(required=False) + initial_token_limit = serializers.DecimalField( + max_digits=50, decimal_places=2, required=False, allow_null=True + ) class BusinessHostSerializer(serializers.Serializer): @@ -234,6 +240,9 @@ class BusinessHostSerializer(serializers.Serializer): token_cap = serializers.DecimalField(max_digits=15, decimal_places=2) token_cap_emails = serializers.ListField(child=serializers.EmailField()) token_cap_enabled = serializers.BooleanField() + initial_token_limit = serializers.DecimalField( + max_digits=50, decimal_places=2, allow_null=True, required=False + ) def get_worker_amount(self, obj): return self.context.get('worker_amount') @@ -2,13 +2,13 @@ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. -# +# #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2026-04-03 16:06+0300\n" +"POT-Creation-Date: 2026-04-03 17:52+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -246,52 +246,56 @@ msgstr "Email'ы для рассылки по низкому балансу" msgid "Token low balance cap enabled" msgstr "Рассылка по низкому балансу включена" -#: authentication/models/business_host.py:67 +#: authentication/models/business_host.py:71 +msgid "Initial token limit" +msgstr "Базовый лимит токенов" + +#: authentication/models/business_host.py:75 msgid "ITN" msgstr "ИНН" -#: authentication/models/business_host.py:68 +#: authentication/models/business_host.py:76 msgid "PSRN" msgstr "ОГРН" -#: authentication/models/business_host.py:69 ml_model/models.py:180 +#: authentication/models/business_host.py:77 ml_model/models.py:180 #: tools/public_api/models.py:31 tools/public_api/services/api_key.py:24 msgid "Name" msgstr "Наименование" -#: authentication/models/business_host.py:72 +#: authentication/models/business_host.py:80 msgid "Preffered name" msgstr "" -#: authentication/models/business_host.py:73 +#: authentication/models/business_host.py:81 msgid "Corporate email" msgstr "Корпоративная почта" -#: authentication/models/business_host.py:75 +#: authentication/models/business_host.py:83 msgid "Corporate phone" msgstr "Корпоративный телефон" -#: authentication/models/business_host.py:77 +#: authentication/models/business_host.py:85 msgid "Job title" msgstr "Наименование работ" -#: authentication/models/business_host.py:83 +#: authentication/models/business_host.py:91 msgid "Allowed models" msgstr "Разрешенные модели" -#: authentication/models/business_host.py:87 +#: authentication/models/business_host.py:95 msgid "Private models" msgstr "Приватные модели" -#: authentication/models/business_host.py:90 +#: authentication/models/business_host.py:98 msgid "Log history enabled" msgstr "История логов включена" -#: authentication/models/business_host.py:113 +#: authentication/models/business_host.py:121 msgid "Business Account" msgstr "Бизнес Аккаунт" -#: authentication/models/business_host.py:114 +#: authentication/models/business_host.py:122 msgid "Business Accounts" msgstr "Бизнес Аккаунты" @@ -541,11 +545,11 @@ msgstr "Пользователь бизнес-аккаунта не зареги msgid "No user with this uid found" msgstr "Не найден пользователь с данным ID" -#: authentication/services/business_account_service.py:54 +#: authentication/services/business_account_service.py:57 msgid "BusinessAccount for this user doesn't exist" msgstr "Бизнес-аккаунт для данного юзера не найден" -#: authentication/services/business_account_service.py:68 +#: authentication/services/business_account_service.py:71 msgid "Invited account can either accept or reject an invitation" msgstr "Приглашенный аккаунт может принять или отклонить приглашение"