Example #1
0
def odlc_to_review_proto(odlc):
    """Converts an ODLC into a review proto."""
    review_proto = interop_admin_api_pb2.OdlcReview()
    review_proto.odlc.CopyFrom(odlc_to_proto(odlc))
    review_proto.last_modified_timestamp = odlc.last_modified_time.isoformat()
    if odlc.thumbnail_approved is not None:
        review_proto.thumbnail_approved = odlc.thumbnail_approved
    if odlc.description_approved is not None:
        review_proto.description_approved = odlc.description_approved
    return review_proto
Example #2
0
    def put(self, request, pk):
        """Updates the review status of a odlc."""
        review_proto = interop_admin_api_pb2.OdlcReview()
        try:
            json_format.Parse(request.body, review_proto)
        except Exception:
            return HttpResponseBadRequest('Failed to parse review proto.')

        try:
            odlc = find_odlc(request, int(pk))
        except Odlc.DoesNotExist:
            return HttpResponseNotFound('Odlc %s not found' % pk)
        except ValueError as e:
            return HttpResponseForbidden(str(e))

        update_odlc_from_review_proto(odlc, review_proto)
        odlc.save()

        return HttpResponse(json_format.MessageToJson(
            odlc_to_review_proto(odlc)),
                            content_type="application/json")