Exemplo n.º 1
0
    def get_image_list(self, request, object_id):
        """ Get a list of available images for this page for TinyMCE to
            refer to. If the setting exists, scale the image to the default
            size specified in `related_image_size`.
        """

        assert self.related_image_field, \
            'No image field defined. Please define a property with the name \
             of the image field in the Admin class.'

        if not self.related_image_size:
            logger.info('No image size defined, not rendering thumbnails for \
                         TinyMCE image list.')

        obj = self._getobj(request, object_id)

        related_images = self.get_related_images(request, obj)

        image_list = []
        for obj in related_images:
            image = getattr(obj, self.related_image_field)
            if self.related_image_size:
                image = get_thumbnail(image, self.related_image_size)

            image_list.append((unicode(obj), image.url))

        return render_to_image_list(image_list)
def images(request, app_label, module_name, object_id=None):
    object = get_object(app_label, module_name, object_id)
    if object is None:
        images = []
    else:
        images = AttachmentImage.objects.filter(
            content_type=ContentType.objects.get_for_model(
                    object.__class__),
            object_id=object.id)
    link_list = [(os.path.basename(obj.image.url), obj.display.url) for obj in images]
    return render_to_image_list(link_list)
Exemplo n.º 3
0
    def get_image_list(self, request, object_id):
        """ Get a list of available images for this page for TinyMCE to
            refer to. If the setting exists, scale the image to the default
            size specified in `PAGEIMAGE_SIZE`.
        """
        object = self._getobj(request, object_id)

        page_images = object.pageimage_set.all()

        image_list = []
        for obj in page_images:
            image = obj.image
            if PAGEIMAGE_SIZE:
                image = get_thumbnail(image, PAGEIMAGE_SIZE)

            image_list.append((unicode(obj), image.url))

        return render_to_image_list(image_list)
Exemplo n.º 4
0
 def get_image_list(self, request, object_id):
     """ Get a list of available images for this page for TinyMCE to
         refer to. If the setting exists, scale the image to the default
         size specified in `PAGEIMAGE_SIZE`.
     """
     object = self._getobj(request, object_id)
     
     images = object.eventimage_set.all()
 
     image_list = []
     for obj in images:
         image = obj.image
         if settings.PAGEIMAGE_SIZE:
             image = get_thumbnail(image, settings.PAGEIMAGE_SIZE)
     
         image_list.append((unicode(obj), image.url))
     
     return render_to_image_list(image_list)
Exemplo n.º 5
0
def images(request, app_label, module_name, object_id=None):
    object = get_object(app_label, module_name, object_id)
    if object is None:
        images = []
    else:
        images = AttachmentImage.objects.filter(
            content_type=ContentType.objects.get_for_model(object.__class__),
            object_id=object.id)

    link_list = []
    for obj in images:
        link_list.append([os.path.basename(obj.image.url), obj.display.url])
        for spec in settings.ATTACHMENT_SPECS_FOR_TINYMCE:
            try:
                img = getattr(obj, spec)
            except AttributeError:
                pass
            else:
                link_list.append([os.path.basename(img.url), img.url])

    return render_to_image_list(link_list)
Exemplo n.º 6
0
 def test_render_to_image_list(self):
     response = render_to_image_list([('test', 'test.jpg')])
     result_ok = b'var tinyMCEImageList = [["test", "test.jpg"]];'
     self.assertEqual(200, response.status_code)
     self.assertEqual('application/x-javascript', response['Content-Type'])
     self.assertEqual(result_ok, response.content)
Exemplo n.º 7
0
 def test_render_to_image_list(self):
     response = render_to_image_list([('test', 'test.jpg')])
     result_ok = b'var tinyMCEImageList = [["test", "test.jpg"]];'
     self.assertEqual(200, response.status_code)
     self.assertEqual('application/x-javascript', response['Content-Type'])
     self.assertEqual(result_ok, response.content)
Exemplo n.º 8
0
def mce_list(request):
    referer = request.META.get('HTTP_REFERER', '')
    print referer
    objects = Image.objects.all()
    link_list = [(unicode(obj), obj.entry_image.url) for obj in objects]
    return render_to_image_list(link_list)
Exemplo n.º 9
0
def adminfiles_image_list(request):
    from adminfiles.models import FileUpload
    from tinymce.views import render_to_image_list

    image_list = [(image.title, image.upload.url) for image in FileUpload.objects.all() if image.is_image]
    return render_to_image_list(image_list)