Exemplo n.º 1
0
    def POST_link_thumb(self, link=None, file=None, img_type="jpg"):
        if link and (not promote.is_promoted(link) or c.user_is_sponsor):
            errors = dict(BAD_CSS_NAME="", IMAGE_ERROR="")

            # thumnails for promoted links can change and therefore expire
            force_thumbnail(link, file, file_type=".%s" % img_type)

            if any(errors.values()):
                return UploadedImage("", "", "upload", errors=errors, form_id="image-upload").render()
            else:
                link._commit()
                return UploadedImage(
                    _("saved"), thumbnail_url(link), "", errors=errors, form_id="image-upload"
                ).render()
Exemplo n.º 2
0
    def POST_link_thumb(self, link=None, file=None, img_type='jpg'):
        if link and (not promote.is_promoted(link) or c.user_is_sponsor):
            errors = dict(BAD_CSS_NAME="", IMAGE_ERROR="")

            # thumnails for promoted links can change and therefore expire
            force_thumbnail(link, file, file_type=".%s" % img_type)

            if any(errors.values()):
                return UploadedImage("", "", "upload", errors=errors,
                                     form_id="image-upload").render()
            else:
                link._commit()
                return UploadedImage(_('saved'), thumbnail_url(link), "",
                                     errors=errors,
                                     form_id="image-upload").render()
Exemplo n.º 3
0
 def POST_link_thumb(self, link=None, file=None, img_type="jpg"):
     if link and (not promote.is_promoted(link) or c.user_is_sponsor or c.user.trusted_sponsor):
         errors = dict(BAD_CSS_NAME="", IMAGE_ERROR="")
         try:
             # thumnails for promoted links can change and therefore expire
             force_thumbnail(link, file, file_type=".%s" % img_type)
         except cssfilter.BadImage:
             # if the image doesn't clean up nicely, abort
             errors["IMAGE_ERROR"] = _("bad image")
         if any(errors.values()):
             return UploadedImage("", "", "upload", errors=errors, form_id="image-upload").render()
         else:
             link._commit()
             return UploadedImage(
                 _("saved"), thumbnail_url(link), "", errors=errors, form_id="image-upload"
             ).render()
Exemplo n.º 4
0
 def POST_link_thumb(self, link=None, file=None, img_type='jpg'):
     if link and (not promote.is_promoted(link) or
                  c.user_is_sponsor or c.user.trusted_sponsor):
         errors = dict(BAD_CSS_NAME="", IMAGE_ERROR="")
         try:
             # thumnails for promoted links can change and therefore expire
             force_thumbnail(link, file, file_type=".%s" % img_type)
         except cssfilter.BadImage:
             # if the image doesn't clean up nicely, abort
             errors["IMAGE_ERROR"] = _("bad image")
         if any(errors.values()):
             return UploadedImage("", "", "upload", errors=errors,
                                  form_id="image-upload").render()
         else:
             link._commit()
             return UploadedImage(_('saved'), thumbnail_url(link), "",
                                  errors=errors,
                                  form_id="image-upload").render()