Esempio n. 1
0
def delete():
    title = config.normalize_title(request.values['title'])
    section = "section_{0}".format(request.values['section'])
    quality = request.values['quality']
    filters_list = config.get_filters(section, quality)
    if title in filters_list:
        filters_list.remove(title)
        config.set_filters(section, quality, filters_list)
        response = {
            'msg': "Filter deleted successfully: {0}".format(title),
            'status': 0
        }
    else:
        response = {
            'msg': "Failed to delete filter: {0}".format(title),
            'status': 1
        }
    return dumps(response)
Esempio n. 2
0
def add():
    title = config.normalize_title(request.values['title'])
    section = "section_{0}".format(request.values['section'])
    quality = request.values['quality']
    filters_list = config.get_filters(section, quality)
    if not title in filters_list:
        filters_list.append(title)
        config.set_filters(section, quality, filters_list)
        response = {
            'msg': "Filter added successfully: {0}".format(title),
            'status': 0
        }
    else:
        response = {
            'msg': "Failed to add filter: {0}".format(title),
            'status': 1
        }
    resp = dumps(response)
    return resp
Esempio n. 3
0
def add():
    """ Add a new filter for a title to a given section

    :return: Add status message
    :rtype: dict
    """
    title = config.normalize_title(request.values['title'])
    section = "section_{0}".format(request.values['section'])
    quality = request.values['quality']
    filters_list = config.get_filters(section, quality)
    if not title in filters_list:
        filters_list.append(title)
        config.set_filters(section, quality, filters_list)
        response = {
            'msg': "Filter added successfully: {0}".format(title),
            'status': api.STATUS_OK
        }
    else:
        response = {
            'msg': "Failed to add filter: {0}".format(title),
            'status': api.STATUS_FAIL
        }
    return response
Esempio n. 4
0
def delete():
    """ Delete a filter from a section over XHR

    :return: Delete status message
    :rtype: dict
    """
    title = config.normalize_title(request.values['title'])
    section = "section_{0}".format(request.values['section'])
    quality = request.values['quality']
    filters_list = config.get_filters(section, quality)
    if title in filters_list:
        filters_list.remove(title)
        config.set_filters(section, quality, filters_list)
        response = {
            'msg': "Filter deleted successfully: {0}".format(title),
            'status': api.STATUS_OK
        }
    else:
        response = {
            'msg': "Failed to delete filter: {0}".format(title),
            'status': api.STATUS_FAIL
        }
    return response
Esempio n. 5
0
def add():
    """ Add a new filter for a title to a given section

    :return: Add status message
    :rtype: dict
    """
    title = config.normalize_title(request.values['title'])
    section = "section_{0}".format(request.values['section'])
    quality = request.values['quality']
    filters_list = config.get_filters(section, quality)
    if not title in filters_list:
        filters_list.append(title)
        config.set_filters(section, quality, filters_list)
        response = {
            'msg': "Filter added successfully: {0}".format(title),
            'status': api.STATUS_OK
        }
    else:
        response = {
            'msg': "Failed to add filter: {0}".format(title),
            'status': api.STATUS_FAIL
        }
    return response
Esempio n. 6
0
def delete():
    """ Delete a filter from a section over XHR

    :return: Delete status message
    :rtype: dict
    """
    title = config.normalize_title(request.values['title'])
    section = "section_{0}".format(request.values['section'])
    quality = request.values['quality']
    filters_list = config.get_filters(section, quality)
    if title in filters_list:
        filters_list.remove(title)
        config.set_filters(section, quality, filters_list)
        response = {
            'msg': "Filter deleted successfully: {0}".format(title),
            'status': api.STATUS_OK
        }
    else:
        response = {
            'msg': "Failed to delete filter: {0}".format(title),
            'status': api.STATUS_FAIL
        }
    return response