コード例 #1
0
def send_post_video(request, access_token):
    param = extract_parameter_from_request(request, url_param_type['POST'])

    if param:
        target_id, target_type = interpreter.get_target_content_info(param)
        user_id = gate_keeper.extract_user_id_from_access_token(access_token)

        if (target_id and user_id and target_type
                and clerk.check_right_upload(target_id, user_id, target_type)
                and formatchecker.is_correct_data_format(
                    request.FILES, formatchecker.data_type['POST_FILE'])):

            result = clerk.upload_file(target_id, request.FILES,
                                       clerk.upload_type['post'],
                                       attach_ft['VIDEO'],
                                       attach_ft['SMALL_THUMBNAIL'],
                                       attach_ft['BIG_THUMBNAIL'])

            if result == server_status_code['OK']:
                return interpreter.pack_up_amazon_s3_video_url(
                    clerk.complete_upload_post(target_id))

            else:
                return json_response(result)

    return json_response(server_status_code['BADREQUEST'])
コード例 #2
0
def complete_external_upload(request, access_token):
    param = extract_parameter_from_request(request, url_param_type['POST'])

    if param:
        target_id, target_type = interpreter.get_target_content_info(param)

        if target_id and target_type:
            return json_response(clerk.complete_upload_post(target_id))

    return json_response(server_status_code['BADREQUEST'])
コード例 #3
0
def click_content_on_search(request):
    param = extract_parameter_from_request(request, url_param_type['NICKNAME'],
                                           url_param_type['TAG'])

    if param:
        target_id, target_type = interpreter.get_target_content_info(param)

        if target_id and target_type:
            return json_response(clerk.click_content(target_id, target_type))

    return json_response(server_status_code['BADREQUEST'])
コード例 #4
0
def get_content(request):
    param = extract_parameter_from_request(request, url_param_type['POST'],
                                           url_param_type['COMMENT'],
                                           url_param_type['USER'])

    if param:
        target_id, target_type = interpreter.get_target_content_info(param)

        if target_id and target_type:
            return json_response(clerk.get_content(target_id, target_type))

    return json_response(server_status_code['BADREQUEST'])
コード例 #5
0
def remove_video_url_broken(request):
    param = extract_parameter_from_request(request, url_param_type['POST'],
                                           url_param_type['URL'])

    if param:
        target_id, target_type = interpreter.get_target_content_info(param)
        broken_url = param[url_param_type['URL']]

        if target_id and target_type and broken_url:
            return json_response(
                clerk.remove_video_url(broken_url, target_id, target_type))

    return json_response(server_status_code['BADREQUEST'])
コード例 #6
0
def cancel_collect_contents(request, access_token):
    param = extract_parameter_from_request(request, url_param_type['COMMENT'],
                                           url_param_type['POST'],
                                           url_param_type['USER'],
                                           url_param_type['TAG'])

    if param:
        user_id = gate_keeper.extract_user_id_from_access_token(access_token)
        target_id, target_type = interpreter.get_target_content_info(param)

        if user_id and target_id and target_type:
            return json_response(
                clerk.cancel_collect_content(target_id, user_id, target_type))

    return json_response(server_status_code['BADREQUEST'])
コード例 #7
0
def send_gfycat_url(request, access_token):
    param = extract_parameter_from_request(request, url_param_type['POST'])
    url_info = interpreter.load_json_from_request(request)

    if param and formatchecker.is_correct_data_format(
            url_info, formatchecker.data_type['F_MSG']):
        target_id, target_type = interpreter.get_target_content_info(param)
        user_id = gate_keeper.extract_user_id_from_access_token(access_token)
        gfycat_mp4_url = url_info['gmu']

        if target_id and target_type and user_id and gfycat_mp4_url:
            return json_response(
                clerk.save_gfycat_url_at_post(target_id, target_type, user_id,
                                              gfycat_mp4_url))

    return json_response(server_status_code['BADREQUEST'])
コード例 #8
0
def send_user_profile_picture(request, access_token):
    param = extract_parameter_from_request(request, url_param_type['USER'])

    if param:
        target_id, target_type = interpreter.get_target_content_info(param)
        user_id = gate_keeper.extract_user_id_from_access_token(access_token)

        if (target_id and user_id
                and clerk.check_right_upload(target_id, user_id, target_type)
                and formatchecker.is_correct_data_format(
                    request.FILES, formatchecker.data_type['PROFILE_FILE'])):

            return json_response(
                clerk.upload_file(target_id, request.FILES,
                                  clerk.upload_type['user'],
                                  attach_ft['SMALL_PROFILE'],
                                  attach_ft['BIG_PROFILE']))

    return json_response(server_status_code['BADREQUEST'])
コード例 #9
0
def report_contents(request, access_token):
    param = extract_parameter_from_request(request, url_param_type['COMMENT'],
                                           url_param_type['POST'],
                                           url_param_type['USER'],
                                           url_param_type['REPORTTYPE'])

    if param:
        target_id, target_type = interpreter.get_target_content_info(param)
        report_text = interpreter.load_json_from_request(request)
        reporter_id = gate_keeper.extract_user_id_from_access_token(
            access_token)
        report_type = param[url_param_type['REPORTTYPE']]

        if target_id and reporter_id and report_type and target_type and 0 <= report_type <= 6:
            return json_response(
                clerk.report_content(target_id, target_type, reporter_id,
                                     report_type, report_text))

    return json_response(result=server_status_code['BADREQUEST'])
コード例 #10
0
def auto_complete_contents(request):
    param = extract_parameter_from_request(request, url_param_type['NICKNAME'],
                                           url_param_type['TAG'],
                                           url_param_type['COUNT'])

    if param:
        target_id, target_type = interpreter.get_target_content_info(param)

        if target_id and target_type:
            if param[url_param_type['NICKNAME']]:
                list_type = response_list_type['USERLIST']

            else:
                list_type = response_list_type['TAGLIST']

            return interpreter.pack_up_list(
                clerk.auto_complete_contents(target_id,
                                             param[url_param_type['COUNT']],
                                             target_type), list_type)

    return json_response(server_status_code['BADREQUEST'])