Exemple #1
0
    def render(self, name, value, attrs=None):
        from ella_newman import options
        if attrs is None:
            attrs = {}
        related_url = '../../../%s/%s/' % (
            self.rel.to._meta.app_label, self.rel.to._meta.object_name.lower())
        url = ''
        if not attrs.has_key('class'):
            attrs[
                'class'] = 'vForeignKeyRawIdAdminField'  # The JavaScript looks for this hook.

        output = []
        if value and issubclass(self.rel.to, Photo):
            obj = self._get_obj(value)
            output.append(options.thumb_html(obj))
            # output.append('<span class="widget-thumb"><img src="%s" alt="Thumbnail %s" /></span>' % (obj.get_formated_photo(options.get_thumb_format())['url'], name))
        output.append(
            super(ForeignKeyRawIdWidget, self).render(name, value, attrs))
        output.append(' <a href="%s%s?pop" class="rawid-related-lookup" id="lookup_id_%s">' % \
            (related_url, url, name))
        output.append(
            '<img src="%sico/16/search.png" width="16" height="16" /></a>' %
            newman_settings.MEDIA_PREFIX)
        if value:
            output.append(self.label_for_value(value))
        return mark_safe(u''.join(output))
Exemple #2
0
    def render(self, name, value, attrs=None):
        from ella_newman import options
        if attrs is None:
            attrs = {}
        related_url = '../../../%s/%s/' % (self.rel.to._meta.app_label, self.rel.to._meta.object_name.lower())
        url = ''
        if not attrs.has_key('class'):
            attrs['class'] = 'vForeignKeyRawIdAdminField' # The JavaScript looks for this hook.

        output = []
        if value and issubclass(self.rel.to, Photo):
            obj = self._get_obj(value)
            output.append(options.thumb_html(obj))
            # output.append('<span class="widget-thumb"><img src="%s" alt="Thumbnail %s" /></span>' % (obj.get_formated_photo(options.get_thumb_format())['url'], name))
        output.append(super(ForeignKeyRawIdWidget, self).render(name, value, attrs))
        output.append(' <a href="%s%s?pop" class="rawid-related-lookup" id="lookup_id_%s">' % \
            (related_url, url, name))
        output.append('<img src="%sico/16/search.png" width="16" height="16" /></a>' % newman_settings.MEDIA_PREFIX)
        if value:
            output.append(self.label_for_value(value))
        return mark_safe(u''.join(output))
Exemple #3
0
 def photo_thumbnail(self, object):
     if object.photo:
         return mark_safe(options.thumb_html(object.photo))
     else:
         return mark_safe('<span class="form-error-msg">%s</span>' %
                          ugettext('No main photo!'))
Exemple #4
0
 def photo_thumbnail(self, object):
     if object.photo:
         return mark_safe(options.thumb_html(object.photo))
     else:
         return mark_safe('<span class="form-error-msg">%s</span>' % ugettext('No main photo!'))