Esempio n. 1
0
    def render(self, context, instance, placeholder):
        view = self.get_detail_view(context['request'], instance.node, opts=instance)
        context.update(view.get_context_data())
        if instance.link_type:
            context[view.context_object_name].link = PluginLink.create_from(instance)

        return context
Esempio n. 2
0
    def render(self, context, instance, placeholder):
        view = self.get_detail_view(context['request'], instance.node, opts=instance)
        context.update(view.get_context_data())
        if instance.link_type:
            context[view.context_object_name].link = PluginLink.create_from(instance)

        return context
Esempio n. 3
0
    def render(self, context, instance, placeholder):
        instance.node.link = PluginLink.create_from(instance)
        context.update({
            'image_node': instance.node,
        })
        if instance.width or instance.height:
            w = instance.width or widthratio(instance.height, instance.node.height, instance.node.width)
            h = instance.height or widthratio(instance.width, instance.node.width, instance.node.height)
            context.update({'thumbnail_size': (w, h)})

        return context
Esempio n. 4
0
 def clean_link_url(self):
     if self.cleaned_data.has_key(
             'link_type') and self.cleaned_data['link_type'] in (
                 PluginLink.LINK_URL, PluginLink.LINK_URL_REVERSE):
         if not self.cleaned_data['link_url']:
             raise forms.ValidationError(
                 self.fields['link_url'].error_messages['required'])
         else:
             if not PluginLink(self.cleaned_data['link_type'],
                               url=self.cleaned_data['link_url']).href():
                 raise forms.ValidationError(
                     self.fields['link_url'].error_messages['invalid'])
     return self.cleaned_data['link_url']
Esempio n. 5
0
    def render(self, context, instance, placeholder):
        instance.node.link = PluginLink.create_from(instance)
        context.update({
            'image_node': instance.node,
        })
        if instance.width or instance.height:
            w = instance.width or widthratio(
                instance.height, instance.node.height, instance.node.width)
            h = instance.height or widthratio(
                instance.width, instance.node.width, instance.node.height)
            context.update({'thumbnail_size': (w, h)})

        return context
Esempio n. 6
0
    def get_context_data(self, *args, **kwargs):
        context_data = super(ImagePluginDetailView,
                             self).get_context_data(*args, **kwargs)

        if self.return_url:
            page = get_page_from_path(self.return_url.strip('/'))
            if page:
                context_data.update({
                    'link':
                    PluginLink(url=page.get_absolute_url(),
                               text=_('Back to %s') % page.get_title())
                })

        return context_data
Esempio n. 7
0
 def clean_link_type(self):
     if 'node' in self.cleaned_data:
         # TODO: Links for folders, for instance link to full-size image for all slideshow items.
         # Could be achieved using FileNode.get_list() processors
         if self.cleaned_data['link_type'] and self.cleaned_data[
                 'node'].node_type == FileNode.FOLDER:
             raise forms.ValidationError(
                 _('You can only link individual files, not folders.'))
         if self.cleaned_data['link_type'] == PluginLink.LINK_IMAGE_DETAIL:
             if not PluginLink(self.cleaned_data['link_type'],
                               obj=self.cleaned_data['node']).href():
                 raise forms.ValidationError(
                     _('You need to attach the Media Tree application to a page in order to link to full size images.'
                       ))
     return self.cleaned_data['link_type']