70 lines
3.0 KiB
Python
70 lines
3.0 KiB
Python
from django.db import models
|
|
from BaseModels.base_models import *
|
|
from django.utils.translation import gettext_lazy as _
|
|
from GeneralApp.models import Block_Abstract
|
|
from django.contrib.contenttypes.models import ContentType
|
|
from django.contrib.contenttypes.fields import GenericForeignKey
|
|
from django.contrib.contenttypes.fields import GenericRelation
|
|
from django.core.validators import validate_image_file_extension
|
|
|
|
class BlockPluginPresentation(Block_Abstract):
|
|
from BaseModels.base_models import Manager_Enabled
|
|
objects = models.Manager()
|
|
enabled_objs = Manager_Enabled()
|
|
|
|
content_type = models.ForeignKey(ContentType, on_delete=models.SET_NULL, null=True)
|
|
object_id = models.PositiveIntegerField()
|
|
content_object = GenericForeignKey('content_type', 'object_id')
|
|
|
|
pre_title = models.CharField(max_length=250, verbose_name=_('Текст перед заголовком'), null=True, blank=True)
|
|
|
|
but1_title = models.CharField(max_length=100, verbose_name=_('Текст на кнопке 1'), null=True, blank=True)
|
|
but2_title = models.CharField(max_length=100, verbose_name=_('Текст на кнопке 2'), null=True, blank=True)
|
|
|
|
but1_url = models.TextField(verbose_name=_('URL привязанной страницы к кнопке 1'), null=True, blank=True)
|
|
but2_url = models.TextField(verbose_name=_('URL привязанной страницы к кнопке 2'), null=True, blank=True)
|
|
|
|
but1_icon = models.FileField(
|
|
upload_to='uploads/', verbose_name=_('Пиктограмма для кнопки 1'), null=True, blank=True,
|
|
validators=[validate_file_extension]
|
|
)
|
|
but2_icon = models.FileField(
|
|
upload_to='uploads/', verbose_name=_('Пиктограмма для кнопки 2'), null=True, blank=True,
|
|
validators=[validate_file_extension]
|
|
)
|
|
|
|
class Meta:
|
|
verbose_name = _('Блок презентации плагина')
|
|
verbose_name_plural = _('Блоки презентации плагина')
|
|
|
|
|
|
class Section(BaseModelViewPage):
|
|
|
|
plugin_presentation = GenericRelation('ServicesApp.BlockPluginPresentation',
|
|
related_query_name='grel_%(class)s_for_block_plugin_presentation')
|
|
|
|
class Meta:
|
|
verbose_name = _('Раздел сайта')
|
|
verbose_name_plural = _('Разделы сайта')
|
|
|
|
|
|
class Service(BaseModelViewPage):
|
|
|
|
url = models.TextField(verbose_name=_('URL привязанной страницы'), null=True, blank=True)
|
|
|
|
section = models.ForeignKey(
|
|
Section, verbose_name=_('Раздел'),
|
|
on_delete=models.SET_NULL, related_name='rel_services_for_section',
|
|
null=True, blank=True
|
|
)
|
|
parent_service = models.ForeignKey(
|
|
'Service', verbose_name=_('Родитель'),
|
|
on_delete=models.SET_NULL, related_name='rel_children_for_service',
|
|
null=True, blank=True
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
verbose_name = _('Услуга')
|
|
verbose_name_plural = _('Услуги') |