update Carousel model_name

This commit is contained in:
evgeniy-st 2019-11-02 12:00:09 +03:00
parent 1747f6e95c
commit 11d06b7b97

View File

@ -14,96 +14,8 @@ from configuration.models import TranslationSettings
from location.models import Country
from main import methods
from review.models import Review
from utils.models import (ProjectBaseMixin, TJSONField,
TranslatedFieldsMixin, ImageMixin,
PlatformMixin, URLImageMixin)
from utils.querysets import ContentTypeQuerySetMixin
#
#
# class Tag(models.Model):
# """Tag model."""
# name = models.CharField(max_length=250)
#
#
# class MediaAsset(models.Model):
# """Assets model."""
# PHOTO = 0
# VIDEO = 1
# VIDEO_URL = 2
# PDF = 3
# DOCUMENT = 4
#
# ASSET_TYPE_CHOICES = (
# (PHOTO, _('photo')),
# (VIDEO, _('video')),
# (VIDEO_URL, _('video url')),
# (PDF, _('pdf')),
# (DOCUMENT, _('document'))
# )
#
# AMAZON_S3 = 0
#
# STORAGE_TYPE_CHOICES = (
# (AMAZON_S3, _('amazon s3')),
# )
#
# PUBLIC = 0
# PRIVATE = 1
# ROLE = 2
#
# ACCESS_TYPE_CHOICES = (
# (PUBLIC, _('public')),
# (PRIVATE, _('private')),
# (ROLE, _('role')),
# )
#
# asset_type = models.PositiveSmallIntegerField(
# _('asset type'), choices=ASSET_TYPE_CHOICES, default=PHOTO
# )
# storage_type = models.PositiveSmallIntegerField(
# _('storage type'), choices=STORAGE_TYPE_CHOICES, default=AMAZON_S3
# )
# storage_unit = models.CharField(_('storage unit'), blank=True, default='')
# path = models.CharField(_('path'))
# access_type = models.PositiveSmallIntegerField(
# _('access type'), choices=ACCESS_TYPE_CHOICES, default=PUBLIC)
# asset_text = JSONField(_('asset_text'))
# size = models.IntegerField(_('size'))
# version = models.CharField(_('version'), max_length=250)
# text = JSONField(_('text'))
#
#
# class Contacts(models.Model):
# """Contacts model."""
# address = models.ForeignKey(
# 'location.Address', verbose_name=_('address'), on_delete=models.CASCADE
# )
#
#
# class Social(models.Model):
# """Social model."""
# WEBSITE = 0
# SOCIAL = 1
#
# SOCIAL_TYPE_CHOICES = (
# (WEBSITE, _('website')),
# (SOCIAL, _('social')),
# )
#
# social_type = models.PositiveSmallIntegerField(
# _('social type'), choices=SOCIAL_TYPE_CHOICES
# )
#
#
# class Note(models.Model):
# """Note model."""
#
#
# class Ad(models.Model):
# """Ad model."""
#
from utils.models import (ProjectBaseMixin, TJSONField, URLImageMixin,
TranslatedFieldsMixin, PlatformMixin)
class Currency(TranslatedFieldsMixin, models.Model):
@ -369,5 +281,10 @@ class Carousel(models.Model):
@property
def model_name(self):
if hasattr(self.content_object, 'establishment_type'):
return self.content_object.establishment_type.name_translated
from establishment.models import Establishment
from news.models import News
if isinstance(self.content_object, Establishment):
return self.content_object.establishment_type.index_name
elif isinstance(self.content_object, News):
return self.content_object.model
return None