Example #1
0
    def post(self):
        artwork_json = json.loads(self.request.get('json'))

        publish_date = (datetime.datetime.utcfromtimestamp(
            artwork_json['publishDate'] / 1000).date())
        if FeaturedArtwork.all().filter('publish_date=',
                                        publish_date).get() != None:
            webapp2.abort(409, message='Artwork already exists for this date.')

        crop_tuple = tuple(
            float(x) for x in json.loads(self.request.get('crop')))

        new_image_url, new_thumb_url = backroomarthelper.maybe_process_image(
            artwork_json['imageUri'], crop_tuple,
            publish_date.strftime('%Y%m%d') + ' ' + artwork_json['title'] +
            ' ' + artwork_json['byline'])

        if not new_thumb_url and 'thumbUri' in artwork_json:
            new_thumb_url = artwork_json['thumbUri']
        new_artwork = FeaturedArtwork(
            title=artwork_json['title'],
            byline=artwork_json['byline'],
            attribution=artwork_json['attribution']
            if 'attribution' in artwork_json else None,
            image_url=new_image_url,
            thumb_url=new_thumb_url,
            details_url=artwork_json['detailsUri'],
            publish_date=publish_date)
        new_artwork.save()
        self.response.set_status(200)
Example #2
0
    def post(self):
        id = long(self.request.get('id'))
        artwork_json = json.loads(self.request.get('json'))
        crop_tuple = tuple(
            float(x) for x in json.loads(self.request.get('crop')))
        target_artwork = FeaturedArtwork.get_by_id(id)
        if not target_artwork:
            webapp2.abort(404)

        target_artwork.title = artwork_json['title']
        target_artwork.byline = artwork_json['byline']
        target_artwork.attribution = artwork_json[
            'attribution'] if 'attribution' in artwork_json else None

        new_image_url, new_thumb_url = backroomarthelper.maybe_process_image(
            artwork_json['imageUri'], crop_tuple,
            target_artwork.publish_date.strftime('%Y%m%d') + ' ' +
            artwork_json['title'] + ' ' + artwork_json['byline'])
        if not new_thumb_url and 'thumbUri' in artwork_json:
            new_thumb_url = artwork_json['thumbUri']

        target_artwork.image_url = new_image_url
        target_artwork.thumb_url = new_thumb_url
        target_artwork.details_url = artwork_json['detailsUri']
        target_artwork.save()

        self.response.set_status(200)
        self.response.out.write(json.dumps(artwork_dict(target_artwork)))
Example #3
0
    def post(self):
        artwork_json = json.loads(self.request.get("json"))

        publish_date = datetime.datetime.utcfromtimestamp(artwork_json["publishDate"] / 1000).date()
        if FeaturedArtwork.all().filter("publish_date=", publish_date).get() != None:
            webapp2.abort(409, message="Artwork already exists for this date.")

        crop_tuple = tuple(float(x) for x in json.loads(self.request.get("crop")))

        new_image_url, new_thumb_url = backroomarthelper.maybe_process_image(
            artwork_json["imageUri"],
            crop_tuple,
            publish_date.strftime("%Y%m%d") + " " + artwork_json["title"] + " " + artwork_json["byline"],
        )

        if not new_thumb_url and "thumbUri" in artwork_json:
            new_thumb_url = artwork_json["thumbUri"]
        new_artwork = FeaturedArtwork(
            title=artwork_json["title"],
            byline=artwork_json["byline"],
            attribution=artwork_json["attribution"] if "attribution" in artwork_json else None,
            image_url=new_image_url,
            thumb_url=new_thumb_url,
            details_url=artwork_json["detailsUri"],
            publish_date=publish_date,
        )
        new_artwork.save()
        self.response.set_status(200)
Example #4
0
    def post(self):
        id = long(self.request.get("id"))
        artwork_json = json.loads(self.request.get("json"))
        crop_tuple = tuple(float(x) for x in json.loads(self.request.get("crop")))
        target_artwork = FeaturedArtwork.get_by_id(id)
        if not target_artwork:
            webapp2.abort(404)

        target_artwork.title = artwork_json["title"]
        target_artwork.byline = artwork_json["byline"]
        target_artwork.attribution = artwork_json["attribution"] if "attribution" in artwork_json else None

        new_image_url, new_thumb_url = backroomarthelper.maybe_process_image(
            artwork_json["imageUri"],
            crop_tuple,
            target_artwork.publish_date.strftime("%Y%m%d") + " " + artwork_json["title"] + " " + artwork_json["byline"],
        )
        if not new_thumb_url and "thumbUri" in artwork_json:
            new_thumb_url = artwork_json["thumbUri"]

        target_artwork.image_url = new_image_url
        target_artwork.thumb_url = new_thumb_url
        target_artwork.details_url = artwork_json["detailsUri"]
        target_artwork.save()

        self.response.set_status(200)
        self.response.out.write(json.dumps(artwork_dict(target_artwork)))
Example #5
0
  def post(self):
    artwork_json = json.loads(self.request.get('json'))

    publish_date = (datetime.datetime
        .utcfromtimestamp(artwork_json['publishDate'] / 1000)
        .date())
    if FeaturedArtwork.all().filter('publish_date=', publish_date).get() != None:
      webapp2.abort(409, message='Artwork already exists for this date.')

    crop_tuple = tuple(float(x) for x in json.loads(self.request.get('crop')))

    new_image_url, new_thumb_url = backroomarthelper.maybe_process_image(
        artwork_json['imageUri'],
        crop_tuple,
        publish_date.strftime('%Y%m%d') + ' '
            + artwork_json['title'] + ' '
            + artwork_json['byline'])

    if not new_thumb_url and 'thumbUri' in artwork_json:
      new_thumb_url = artwork_json['thumbUri']
    new_artwork = FeaturedArtwork(
        title=artwork_json['title'],
        byline=artwork_json['byline'],
        attribution=artwork_json['attribution'] if 'attribution' in artwork_json else None,
        image_url=new_image_url,
        thumb_url=new_thumb_url,
        details_url=artwork_json['detailsUri'],
        publish_date=publish_date)
    new_artwork.save()
    self.response.set_status(200)
Example #6
0
  def post(self):
    id = long(self.request.get('id'))
    artwork_json = json.loads(self.request.get('json'))
    crop_tuple = tuple(float(x) for x in json.loads(self.request.get('crop')))
    target_artwork = FeaturedArtwork.get_by_id(id)
    if not target_artwork:
      webapp2.abort(404)

    target_artwork.title = artwork_json['title']
    target_artwork.byline = artwork_json['byline']
    target_artwork.attribution = artwork_json['attribution'] if 'attribution' in artwork_json else None

    new_image_url, new_thumb_url = backroomarthelper.maybe_process_image(
        artwork_json['imageUri'],
        crop_tuple,
        target_artwork.publish_date.strftime('%Y%m%d') + ' '
            + artwork_json['title'] + ' '
            + artwork_json['byline'])
    if not new_thumb_url and 'thumbUri' in artwork_json:
      new_thumb_url = artwork_json['thumbUri']

    target_artwork.image_url = new_image_url
    target_artwork.thumb_url = new_thumb_url
    target_artwork.details_url = artwork_json['detailsUri']
    target_artwork.save()

    self.response.set_status(200)
    self.response.out.write(json.dumps(artwork_dict(target_artwork)))