コード例 #1
0
ファイル: models.py プロジェクト: compoundpartners/js-people
class RelatedPeoplePlugin(CMSPlugin):

    # NOTE: This one does NOT subclass NewsBlogCMSPlugin. This is because this
    # plugin can really only be placed on the article detail view in an apphook.
    cmsplugin_ptr = models.OneToOneField(
        CMSPlugin, on_delete=models.CASCADE, related_name='+', parent_link=True)

    title = models.CharField(max_length=255, blank=True, verbose_name=_('Title'))
    icon = Icon(blank=False, default='')
    image = FilerImageField(on_delete=models.SET_NULL, null=True, blank=True, related_name="main_image")
    number_of_people = models.PositiveSmallIntegerField(verbose_name=_('Number of people'))
    layout = models.CharField(max_length=30, verbose_name=_('layout'))
    related_people = SortedManyToManyField(Person, verbose_name=_('key people'), blank=True, symmetrical=False)
    related_groups = SortedManyToManyField(Group, verbose_name=_('related groups'), blank=True, symmetrical=False)
    related_locations = SortedManyToManyField('js_locations.Location', verbose_name=_('related locations'), blank=True, symmetrical=False)
    related_categories = SortedManyToManyField('aldryn_categories.Category', verbose_name=_('related categories'), blank=True, symmetrical=False)
    related_services = SortedManyToManyField('js_services.Service', verbose_name=_('related services'), blank=True, symmetrical=False)
    more_button_is_shown = models.BooleanField(blank=True, default=False, verbose_name=_('Show “See More Button”'))
    more_button_text = models.CharField(max_length=255, blank=True, verbose_name=_('See More Button Text'))
    more_button_link = models.CharField(max_length=255, blank=True, verbose_name=_('See More Button Link'))

    def copy_relations(self, oldinstance):
        self.related_people.set(oldinstance.related_people.all())
        self.related_groups.set(oldinstance.related_groups.all())
        self.related_locations.set(oldinstance.related_locations.all())
        self.related_services.set(oldinstance.related_services.all())
        self.related_categories.set(oldinstance.related_categories.all())
        if IS_THERE_COMPANIES:
            self.related_companies.set(oldinstance.related_companies.all())

    def __str__(self):
        return text_type(self.pk)
コード例 #2
0
ファイル: models.py プロジェクト: avryhof/mysub
class PortfolioItemPluginConfig(PluginAbstractLink):
    image = FilerImageField(blank=True, null=True, related_name="pfi_image", on_delete=DO_NOTHING)
    sub_heading = CharField(max_length=100, blank=True, null=True)
    icon = Icon()

    def get_short_description(self):
        return "%s" % self.title
コード例 #3
0
ファイル: models.py プロジェクト: evgeny-dmi3ev/js-articles
class NewsBlogJSRelatedPlugin(PluginEditModeMixin, AdjustableCacheModelMixin,
                              CMSPlugin):
    # NOTE: This one does NOT subclass NewsBlogCMSPlugin. This is because this
    # plugin can really only be placed on the article detail view in an apphook.
    cmsplugin_ptr = models.OneToOneField(CMSPlugin,
                                         related_name='+',
                                         parent_link=True)

    title = models.CharField(max_length=255,
                             blank=True,
                             verbose_name=_('Title'))
    icon = Icon(blank=False, default='fa-')
    image = FilerImageField(null=True, blank=True, related_name="title_image")
    number_of_articles = models.PositiveSmallIntegerField(
        verbose_name=_('Number of articles'),
        validators=[django.core.validators.MaxValueValidator(120)])
    layout = models.CharField(max_length=30, verbose_name=_('layout'))
    featured = models.BooleanField(blank=True, default=False)
    exclude_current_article = models.BooleanField(blank=True, default=False)
    related_types = SortedManyToManyField(NewsBlogConfig,
                                          verbose_name=_('related sections'),
                                          blank=True,
                                          symmetrical=False)
    related_categories = SortedManyToManyField(
        Category,
        verbose_name=_('related categories'),
        blank=True,
        symmetrical=False)
    related_services = SortedManyToManyField(
        'js_services.Service',
        verbose_name=_('related services'),
        blank=True,
        symmetrical=False)
    related_authors = SortedManyToManyField(Person,
                                            verbose_name=_('related authors'),
                                            blank=True,
                                            symmetrical=False)

    def copy_relations(self, oldinstance):
        self.related_types = oldinstance.related_types.all()
        self.related_categories = oldinstance.related_categories.all()
        self.related_services = oldinstance.related_services.all()
        self.related_authors = oldinstance.related_authors.all()

    # def get_articles(self, article, request):
    #     """
    #     Returns a queryset of articles that are related to the given article.
    #     """
    #     languages = get_valid_languages_from_request(
    #         article.app_config.namespace, request)
    #     if self.language not in languages:
    #         return Article.objects.none()
    #     qs = article.related.translated(*languages)
    #     if not self.get_edit_mode(request):
    #         qs = qs.published()
    #     return qs

    def __str__(self):
        return ugettext('Related articles')
コード例 #4
0
ファイル: models.py プロジェクト: evgeny-dmi3ev/js-counters
class CounterModel(CMSPlugin):
    counter_text = models.CharField(max_length=255, blank=True, null=True)
    counter_value = models.CharField(max_length=255, blank=True, null=True)
    icon = Icon(blank=False, default='fa-')
    image = FilerImageField(null=True, blank=True, related_name="conter_image")

    def __unicode__(self):
        return self.counter_text or 'counter'
コード例 #5
0
ファイル: models.py プロジェクト: compoundpartners/js-events
class EventRelatedPlugin(PluginEditModeMixin, AdjustableCacheModelMixin,
                         CMSPlugin):
    # NOTE: This one does NOT subclass NewsBlogCMSPlugin. This is because this
    # plugin can really only be placed on the article detail view in an apphook.
    cmsplugin_ptr = models.OneToOneField(CMSPlugin,
                                         on_delete=models.CASCADE,
                                         related_name='+',
                                         parent_link=True)

    title = models.CharField(max_length=255,
                             blank=True,
                             verbose_name=_('Title'))
    icon = Icon(blank=False, default='')
    image = FilerImageField(on_delete=models.SET_NULL,
                            null=True,
                            blank=True,
                            related_name="related_events_title_image")
    number_of_items = models.PositiveSmallIntegerField(
        verbose_name=_('Number of events'))
    layout = models.CharField(max_length=30,
                              verbose_name=_('layout'),
                              blank=True,
                              default='',
                              choices=[])
    time_period = models.CharField(max_length=30,
                                   verbose_name=_('Time Period'))
    featured = models.BooleanField(blank=True, default=False)
    exclude_current_item = models.BooleanField(
        blank=True, default=False, verbose_name=_('Exclude current event'))
    related_types = SortedManyToManyField(EventsConfig,
                                          verbose_name=_('related sections'),
                                          blank=True,
                                          symmetrical=False)
    related_categories = SortedManyToManyField(
        Category,
        verbose_name=_('related categories'),
        blank=True,
        symmetrical=False)
    related_service_sections = SortedManyToManyField(
        'js_services.ServicesConfig',
        verbose_name=_('related service section'),
        blank=True,
        symmetrical=False)
    related_services = SortedManyToManyField(
        'js_services.Service',
        verbose_name=_('related services'),
        blank=True,
        symmetrical=False)
    related_hosts = SortedManyToManyField(Person,
                                          verbose_name=_('related hosts'),
                                          blank=True,
                                          symmetrical=False)
    related_locations = SortedManyToManyField(
        'js_locations.location',
        verbose_name=_('related locations'),
        blank=True)

    more_button_is_shown = models.BooleanField(
        blank=True, default=False, verbose_name=_('Show “See More Button”'))
    more_button_text = models.CharField(max_length=255,
                                        blank=True,
                                        verbose_name=_('See More Button Text'))
    more_button_link = models.CharField(max_length=255,
                                        blank=True,
                                        verbose_name=_('See More Button Link'))

    def copy_relations(self, oldinstance):
        self.related_types.set(oldinstance.related_types.all())
        self.related_categories.set(oldinstance.related_categories.all())
        self.related_service_sections.set(
            oldinstance.related_service_sections.all())
        self.related_services.set(oldinstance.related_services.all())
        self.related_hosts.set(oldinstance.related_hosts.all())
        self.related_locations.set(oldinstance.related_locations.all())

    def __str__(self):
        return ugettext('Related events')
コード例 #6
0
class Bootstrap4Link(AbstractLink):
    """
    Components > "Button" Plugin
    https://getbootstrap.com/docs/4.0/components/buttons/
    """
    url_validators = [
        LocalORIntranetURLValidator(),
    ]

    external_link = models.CharField(
        verbose_name=_('External link'),
        blank=True,
        max_length=2040,
        validators=url_validators,
        help_text=_('Provide a link to an external source.'),
    )
    link_type = models.CharField(
        verbose_name=_('Type'),
        choices=LINK_CHOICES,
        default=LINK_CHOICES[0][0],
        max_length=255,
        help_text=_('Adds either the .btn-* or .text-* classes.'),
    )
    link_color = RGBColorField(verbose_name=_('Color'), blank=True, null=True)
    link_context = models.CharField(
        verbose_name=_('Context'),
        choices=COLOR_STYLE_CHOICES,
        blank=True,
        max_length=255,
    )
    link_size = models.CharField(
        verbose_name=_('Size'),
        choices=LINK_SIZE_CHOICES,
        blank=True,
        max_length=255,
    )
    link_alignment = models.CharField(
        verbose_name=_('Alignment'),
        choices=LINK_ALIGNMENTS,
        blank=True,
        max_length=255,
    )
    link_outline = models.BooleanField(
        verbose_name=_('Outline'),
        default=False,
        help_text=_('Applies the .btn-outline class to the elements.'),
    )
    link_block = models.BooleanField(
        verbose_name=_('Block'),
        default=False,
        help_text=_('Extends the button to the width of its container.'),
    )
    modal_id = models.CharField(
        blank=True,
        default='',
        max_length=60,
        verbose_name=_('Modal Id'),
        help_text=_('Do not include a preceding "#" symbol.'),
    )
    icon_left = Icon(verbose_name=_('Icon left'), )
    icon_right = Icon(verbose_name=_('Icon right'), )
    no_link = models.BooleanField(
        verbose_name=_('No Link'),
        default=False,
    )

    def __str__(self):
        return str(self.pk)

    def get_link(self):
        if self.no_link:
            return ''
        return super(Bootstrap4Link, self).get_link()

    def clean(self):
        if not self.no_link:
            super(Bootstrap4Link, self).clean()