from django.db import models


class AdvertisementSpace(models.Model):
    """ 广告位容器模型 """
    SPACE_TYPE_CHOICES = (('carousel', '轮播广告位'), ('banner', '横幅广告位'),
                          ('side', '侧边栏广告位'), ('popup', '弹窗广告位'))

    name = models.CharField('广告位名称', max_length=50)
    identifier = models.SlugField('前端标识', unique=True, help_text="模板中调用的唯一标识符")
    space_type = models.CharField('广告类型',
                                  max_length=20,
                                  choices=SPACE_TYPE_CHOICES)
    width = models.PositiveIntegerField('宽度(px)')
    height = models.PositiveIntegerField('高度(px)')
    position = models.CharField('页面位置', max_length=20, default='header')

    class Meta:
        verbose_name = '广告位'
        verbose_name_plural = verbose_name

    def __str__(self):
        return f"{self.name} ({self.get_space_type_display()})"
