Initial commit from monorepo

This commit is contained in:
Ruslan Bakiev
2026-01-07 09:12:35 +07:00
commit 5a5186732b
53 changed files with 3347 additions and 0 deletions

0
suppliers/__init__.py Normal file
View File

10
suppliers/admin.py Normal file
View File

@@ -0,0 +1,10 @@
from django.contrib import admin
from .models import SupplierProfile
@admin.register(SupplierProfile)
class SupplierProfileAdmin(admin.ModelAdmin):
list_display = ['name', 'country', 'is_verified', 'is_active', 'created_at']
list_filter = ['is_verified', 'is_active', 'country']
search_fields = ['name', 'description', 'team_uuid']
readonly_fields = ['uuid', 'created_at', 'updated_at']

7
suppliers/apps.py Normal file
View File

@@ -0,0 +1,7 @@
from django.apps import AppConfig
class SuppliersConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'suppliers'
verbose_name = 'Профили поставщиков'

View File

View File

@@ -0,0 +1,34 @@
from django.core.management.base import BaseCommand
from django.db import transaction
from suppliers.models import SupplierProfile
COUNTRY_TO_CODE = {
"Russia": "RU",
"Kazakhstan": "KZ",
"Uzbekistan": "UZ",
"Turkey": "TR",
"UAE": "AE",
"China": "CN",
"India": "IN",
"Germany": "DE",
"Brazil": "BR",
"Kenya": "KE",
}
class Command(BaseCommand):
help = "Fill empty country_code based on country name"
@transaction.atomic
def handle(self, *args, **options):
updated = 0
for profile in SupplierProfile.objects.filter(country_code=""):
if profile.country in COUNTRY_TO_CODE:
profile.country_code = COUNTRY_TO_CODE[profile.country]
profile.save(update_fields=["country_code"])
updated += 1
self.stdout.write(f"Updated {profile.name}: {profile.country} -> {profile.country_code}")
self.stdout.write(self.style.SUCCESS(f"Updated {updated} supplier profiles"))

View File

@@ -0,0 +1,32 @@
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name='Supplier',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('uuid', models.CharField(default=uuid.uuid4, max_length=100, unique=True)),
('team_uuid', models.CharField(max_length=100, unique=True)),
('name', models.CharField(max_length=255)),
('description', models.TextField(blank=True, default='')),
('country', models.CharField(blank=True, default='', max_length=100)),
('logo_url', models.URLField(blank=True, default='')),
('is_verified', models.BooleanField(default=False)),
('is_active', models.BooleanField(default=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
],
options={
'db_table': 'suppliers',
'ordering': ['name'],
},
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.2.9 on 2025-12-10 05:20
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('suppliers', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='supplier',
name='country_code',
field=models.CharField(blank=True, default='', max_length=3),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.2.9 on 2025-12-10 11:56
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('suppliers', '0002_supplier_country_code'),
]
operations = [
migrations.AddField(
model_name='supplier',
name='latitude',
field=models.FloatField(blank=True, null=True),
),
migrations.AddField(
model_name='supplier',
name='longitude',
field=models.FloatField(blank=True, null=True),
),
]

View File

@@ -0,0 +1 @@

41
suppliers/models.py Normal file
View File

@@ -0,0 +1,41 @@
from django.db import models
import uuid
class SupplierProfile(models.Model):
"""Профиль поставщика на бирже - витринные данные для marketplace.
Первоисточник данных о поставщике - Team (team_type=SELLER).
Этот профиль содержит только витринную информацию для отображения на бирже.
"""
uuid = models.CharField(max_length=100, unique=True, default=uuid.uuid4)
team_uuid = models.CharField(max_length=100, unique=True) # Связь с Team
name = models.CharField(max_length=255)
description = models.TextField(blank=True, default='')
country = models.CharField(max_length=100, blank=True, default='')
country_code = models.CharField(max_length=3, blank=True, default='')
logo_url = models.URLField(blank=True, default='')
# Координаты для карты
latitude = models.FloatField(null=True, blank=True)
longitude = models.FloatField(null=True, blank=True)
is_verified = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = 'suppliers' # Сохраняем имя таблицы для совместимости
ordering = ['name']
verbose_name = 'Supplier Profile'
verbose_name_plural = 'Supplier Profiles'
def __str__(self):
return f"{self.name} ({self.country})"
# Alias for backwards compatibility
Supplier = SupplierProfile