Example #1
0
def create_promotedflavor():
    #Only the users with the appropiate roles could manage the promoted flavors.
    authorization()
    #if the user has the correct roles, they can manage the promoted flavors
    body = util.remove_non_usable_characters(
                        util.remove_xml_header(request.data.decode("utf-8")))
    content_type = request.content_type
    
    validator_factory = factory_selector.get_factory(content_type)
    validator = validator_factory.create_flavor_request_validator()
    validator.validate(body)
    
    flavor = Flavor.deserialize(content_type, body)
    flavor.promoted =  True
    flavor.public = True
    
    manager = FlavorSynchronizer()
    created_flavor = manager.create_promoted_flavor(flavor)
    print ("request.accept_mimetypes")
    print (request.accept_mimetypes)
    
    response_body = created_flavor.serialize(request.accept_mimetypes)
    
    return Response(response_body, status=201, mimetype=request.accept_mimetypes[0][0])