from django.db import models
from shared_models.common.base import BaseModel

class CustomerCryptoWallet(BaseModel):
    id = models.AutoField(primary_key=True, editable=False)
    customer_id = models.IntegerField(db_index=True)
    address = models.CharField(max_length=255)
    network = models.CharField(max_length=255)
    token = models.CharField(max_length=255)
    is_primary = models.BooleanField(default=False)
    is_active = models.BooleanField(default=True)
    comment = models.TextField(blank=True, null=True, help_text='Additional notes about this crypto wallet')

    class Meta:
        app_label = 'shared_customer_crypto_wallet'
        db_table = 'shared_customer_crypto_wallets'
        verbose_name = 'Customer Crypto Wallet'
        verbose_name_plural = 'Customer Crypto Wallets'
        ordering = ['-created_at']
        indexes = [
            models.Index(fields=['customer_id']),
            models.Index(fields=['address', 'network']),
            models.Index(fields=['token']),
        ]
        permissions = [
            # Base CRUD permissions (auto-generated by Django)
            # view_customercryptowallet, add_customercryptowallet, change_customercryptowallet, delete_customercryptowallet
            
            # Crypto wallet-specific action permissions
            ('verify_customercryptowallet', 'Can verify customer crypto wallet'),
            ('approve_customercryptowallet', 'Can approve customer crypto wallet'),
            ('set_primary_customercryptowallet', 'Can set primary crypto wallet'),
        ]

    def __str__(self):
        return f"Customer Crypto Wallet {self.address} ({self.network}/{self.token})"
