From 11d06b7b973ba7c29d2d6be21d941c73fe20022a Mon Sep 17 00:00:00 2001 From: evgeniy-st Date: Sat, 2 Nov 2019 12:00:09 +0300 Subject: [PATCH] update Carousel model_name --- apps/main/models.py | 101 ++++---------------------------------------- 1 file changed, 9 insertions(+), 92 deletions(-) diff --git a/apps/main/models.py b/apps/main/models.py index a181e464..549dda74 100644 --- a/apps/main/models.py +++ b/apps/main/models.py @@ -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