Пример #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()
Пример #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 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()
Пример #3
0
    def POST_link_thumb(self, link=None, file=None, img_type='jpg'):
        if not link or (promote.is_promoted(link) and not c.user_is_sponsor):
            # only let sponsors edit thumbnails of live promos
            return abort(403, 'forbidden')

        force_thumbnail(link, file, file_type=".%s" % img_type)
        link._commit()
        return UploadedImage(_('saved'), thumbnail_url(link), "", errors=errors,
                             form_id="image-upload").render()
Пример #4
0
    def POST_link_mobile_ad_image(self, link=None, file=None, img_type='jpg'):
        if not (link and c.user_is_sponsor and file):
            # only sponsors can set the mobile img
            return abort(403, 'forbidden')

        force_mobile_ad_image(link, file, file_type=".%s" % img_type)
        link._commit()
        return UploadedImage(_('saved'), link.mobile_ad_url, "", errors=errors,
                             form_id="mobile-ad-image-upload").render()