Example #1
0
def admin_actions():
    """ Return the actions requested and requiring intervention from an
    admin.
    """
    package = flask.request.args.get('package', None)
    packager = flask.request.args.get('packager', None)
    action = flask.request.args.get('action', None)
    status = flask.request.args.get('status', 'Awaiting Review')
    limit = flask.request.args.get('limit', APP.config['ITEMS_PER_PAGE'])
    page = flask.request.args.get('page', 1)

    try:
        page = abs(int(page))
    except ValueError:
        page = 1

    try:
        limit = abs(int(limit))
    except ValueError:
        limit = APP.config['ITEMS_PER_PAGE']
        flask.flash('Incorrect limit provided, using default', 'errors')

    actions = []
    cnt_actions = 0
    try:
        actions = pkgdblib.search_actions(
            SESSION,
            package=package or None,
            packager=packager or None,
            action=action,
            status=status,
            page=page,
            limit=limit,
            order='desc',
        )
        cnt_actions = pkgdblib.search_actions(
            SESSION,
            package=package or None,
            packager=packager or None,
            action=action,
            status=status,
            count=True
        )
    except pkgdblib.PkgdbException, err:
        flask.flash(err, 'errors')
Example #2
0
def admin_actions():
    """ Return the actions requested and requiring intervention from an
    admin.
    """
    package = flask.request.args.get('package', None)
    packager = flask.request.args.get('packager', None)
    action = flask.request.args.get('action', None)
    status = flask.request.args.get('status', 'Awaiting Review')
    limit = flask.request.args.get('limit', APP.config['ITEMS_PER_PAGE'])
    page = flask.request.args.get('page', 1)

    try:
        page = abs(int(page))
    except ValueError:
        page = 1

    try:
        limit = abs(int(limit))
    except ValueError:
        limit = APP.config['ITEMS_PER_PAGE']
        flask.flash('Incorrect limit provided, using default', 'errors')

    actions = []
    cnt_actions = 0
    try:
        actions = pkgdblib.search_actions(
            SESSION,
            package=package or None,
            packager=packager or None,
            action=action,
            status=status,
            page=page,
            limit=limit,
        )
        cnt_actions = pkgdblib.search_actions(
            SESSION,
            package=package or None,
            packager=packager or None,
            action=action,
            status=status,
            count=True
        )
    except pkgdblib.PkgdbException, err:
        flask.flash(err, 'errors')
Example #3
0
def packager_requests(packager):
    ''' Display the requests made by the specified packager. '''
    action = flask.request.args.get('action') or None
    package = flask.request.args.get('package') or None
    status = flask.request.args.get('status', 'All')
    limit = flask.request.args.get('limit', APP.config['ITEMS_PER_PAGE'])
    page = flask.request.args.get('page', 1)

    try:
        page = abs(int(page))
    except ValueError:
        page = 1

    try:
        limit = abs(int(limit))
    except ValueError:
        limit = APP.config['ITEMS_PER_PAGE']
        flask.flash('Incorrect limit provided, using default', 'errors')

    actions = []
    cnt_actions = 0
    try:
        actions = pkgdblib.search_actions(
            SESSION,
            packager=packager,
            package=package,
            action=action,
            status=status,
            page=page,
            limit=limit,
            order='desc',
        )
        cnt_actions = pkgdblib.search_actions(
            SESSION,
            packager=packager,
            package=package,
            action=action,
            status=status,
            page=page,
            limit=limit,
            count=True,
        )
    except pkgdblib.PkgdbException, err:
        flask.flash(err, 'errors')
Example #4
0
def packager_requests(packager):
    ''' Display the requests made by the specified packager. '''
    action = flask.request.args.get('action') or None
    package = flask.request.args.get('package') or None
    status = flask.request.args.get('status', 'All')
    limit = flask.request.args.get('limit', APP.config['ITEMS_PER_PAGE'])
    page = flask.request.args.get('page', 1)

    try:
        page = abs(int(page))
    except ValueError:
        page = 1

    try:
        limit = abs(int(limit))
    except ValueError:
        limit = APP.config['ITEMS_PER_PAGE']
        flask.flash('Incorrect limit provided, using default', 'errors')

    actions = []
    cnt_actions = 0
    try:
        actions = pkgdblib.search_actions(
            SESSION,
            packager=packager,
            package=package,
            action=action,
            status=status,
            page=page,
            limit=limit,
            order='desc',
        )
        cnt_actions = pkgdblib.search_actions(
            SESSION,
            packager=packager,
            package=package,
            action=action,
            status=status,
            page=page,
            limit=limit,
            count=True,
        )
    except pkgdblib.PkgdbException, err:
        flask.flash(err, 'errors')
Example #5
0
def admin_actions():
    """ Return the actions requested and requiring intervention from an
    admin.
    """
    package = flask.request.args.get("package", None)
    packager = flask.request.args.get("packager", None)
    action = flask.request.args.get("action", None)
    status = flask.request.args.get("status", "Awaiting Review")
    limit = flask.request.args.get("limit", APP.config["ITEMS_PER_PAGE"])
    page = flask.request.args.get("page", 1)

    try:
        page = abs(int(page))
    except ValueError:
        page = 1

    try:
        limit = abs(int(limit))
    except ValueError:
        limit = APP.config["ITEMS_PER_PAGE"]
        flask.flash("Incorrect limit provided, using default", "errors")

    actions = []
    cnt_actions = 0
    try:
        actions = pkgdblib.search_actions(
            SESSION,
            package=package or None,
            packager=packager or None,
            action=action,
            status=status,
            page=page,
            limit=limit,
            order="desc",
        )
        cnt_actions = pkgdblib.search_actions(
            SESSION, package=package or None, packager=packager or None, action=action, status=status, count=True
        )
    except pkgdblib.PkgdbException, err:
        flask.flash(err, "errors")
Example #6
0
def packager_requests(packager):
    ''' Display the requests made by the specified packager. '''
    action = flask.request.args.get('action') or None
    package = flask.request.args.get('package') or None
    status = flask.request.args.get('status', 'All')
    limit = flask.request.args.get('limit', APP.config['ITEMS_PER_PAGE'])
    page = flask.request.args.get('page', 1)

    try:
        page = abs(int(page))
    except ValueError:
        page = 1

    try:
        limit = abs(int(limit))
    except ValueError:
        limit = APP.config['ITEMS_PER_PAGE']
        flask.flash('Incorrect limit provided, using default', 'errors')

    actions = []
    cnt_actions = 0
    try:
        actions = pkgdblib.search_actions(
            SESSION,
            packager=packager,
            package=package,
            action=action,
            status=status,
            page=page,
            limit=limit,
            order='desc',
        )
        cnt_actions = pkgdblib.search_actions(
            SESSION,
            packager=packager,
            package=package,
            action=action,
            status=status,
            page=page,
            limit=limit,
            count=True,
        )
    except PkgdbException as err:
        flask.flash(err, 'errors')

    total_page = int(ceil(cnt_actions / float(limit)))

    action_status = pkgdblib.get_status(
        SESSION, 'admin_status')['admin_status']
    action_status.insert(0, 'All')

    return flask.render_template(
        'list_actions.html',
        select='packagers',
        actions=actions,
        cnt_actions=cnt_actions,
        total_page=total_page,
        page=page,
        package=package or '',
        packager=packager,
        action=action,
        status=status,
        statuses=action_status,
    )
Example #7
0
def api_admin_actions():
    """
List admin actions
------------------
    List actions requiring intervention from an admin.

    ::

        /api/admin/actions/

    Accept GET queries only.

    :kwarg package: restrict the actions to a specific package.
    :kwarg packager: restrict the actions to a specific packager.
    :kwarg action: restrict the actions to a specific action, options are:
        ``request.branch``, ``request.package`` and ``request.unretire``.
    :kwarg status: restrict the actions depending on their status, options
        are: ``Awaiting Review``, ``Approved``, ``Denied``, ``Obsolete``,
        ``Removed``.
    :kwarg limit: An integer to limit the number of results, defaults to
        250, maximum is 500.
    :kwarg page: The page number to return (useful in combination to limit).

    Sample response:

    ::

        /api/admin/actions

        {
          "output": "ok",
          "actions": [
            {
              "action": "request.branch",
              "collection": {
                "branchname": "epel7",
                "dist_tag": ".el7",
                "koji_name": "epel7",
                "name": "Fedora EPEL",
                "status": "Active",
                "version": "7"
              },
              "date_created": 1402470695.0,
              "date_updated": 1402470695.0,
              "from_collection": {
                "branchname": "f19",
                "dist_tag": ".fc19",
                "koji_name": "f19",
                "name": "Fedora",
                "status": "Active",
                "version": "19"
              },
              "id": 8,
              "info": null,
              "package": {
                "acls": [],
                "creation_date": 1400063778.0,
                "description": "Guake is a drop-down terminal for Gnome "
                               "Desktop Environment, so you just need to "
                               "press a key to invoke him, and press again "
                               "to hide.",
                "name": "guake",
                "review_url": null,
                "status": "Approved",
                "summary": "Drop-down terminal for GNOME",
                "upstream_url": "http://guake.org/"
              },
              "status": "Awaiting Review",
              "user": "******"
            }
          ],
          "page": 1,
          "page_total": 1
        }

    .. note:: the ``date_created`` and ``date_updated`` fields are both
            timestamps expressed in
            `Unix TIME <https://en.wikipedia.org/wiki/Unix_time>`_

    """
    package = flask.request.args.get('package', None)
    packager = flask.request.args.get('packager', None)
    action = flask.request.args.get('action', None)
    status = flask.request.args.get('status', None)
    page = flask.request.args.get('page', 1)
    limit = get_limit()

    httpcode = 200
    output = {}

    try:
        page = abs(int(page))
    except ValueError:
        page = 1

    actions = []
    cnt_actions = 0
    try:
        actions = pkgdblib.search_actions(
            SESSION,
            package=package or None,
            packager=packager or None,
            action=action,
            status=status,
            limit=limit,
            page=page
        )

        cnt_actions += pkgdblib.search_actions(
            SESSION,
            package=package or None,
            packager=packager or None,
            action=action,
            status=status,
            count=True,
        )
    except PkgdbException as err:  # pragma: no cover
        SESSION.rollback()
        output['output'] = 'notok'
        output['error'] = str(err)
        httpcode = 500

    if not actions:
        output['output'] = 'notok'
        output['actions'] = []
        output['error'] = 'No actions found for these parameters'
        httpcode = 404
    else:
        output['actions'] = [
            act.to_json()
            for act in actions
        ]
        output['output'] = 'ok'
        output['page'] = int(page)
        output['page_total'] = int(ceil(cnt_actions / float(limit)))

    if 'page_total' not in output:
        output['page'] = 1
        output['page_total'] = 1

    jsonout = flask.jsonify(output)
    jsonout.status_code = httpcode
    return jsonout
Example #8
0
def packager_requests(packager):
    ''' Display the requests made by the specified packager. '''
    action = flask.request.args.get('action') or None
    package = flask.request.args.get('package') or None
    status = flask.request.args.get('status', 'All')
    limit = flask.request.args.get('limit', APP.config['ITEMS_PER_PAGE'])
    page = flask.request.args.get('page', 1)

    try:
        page = abs(int(page))
    except ValueError:
        page = 1

    try:
        limit = abs(int(limit))
    except ValueError:
        limit = APP.config['ITEMS_PER_PAGE']
        flask.flash('Incorrect limit provided, using default', 'errors')

    actions = []
    cnt_actions = 0
    try:
        actions = pkgdblib.search_actions(
            SESSION,
            packager=packager,
            package=package,
            action=action,
            status=status,
            page=page,
            limit=limit,
            order='desc',
        )
        cnt_actions = pkgdblib.search_actions(
            SESSION,
            packager=packager,
            package=package,
            action=action,
            status=status,
            page=page,
            limit=limit,
            count=True,
        )
    except PkgdbException as err:
        flask.flash(err, 'errors')

    total_page = int(ceil(cnt_actions / float(limit)))

    action_status = pkgdblib.get_status(SESSION,
                                        'admin_status')['admin_status']
    action_status.insert(0, 'All')

    return flask.render_template(
        'list_actions.html',
        select='packagers',
        actions=actions,
        cnt_actions=cnt_actions,
        total_page=total_page,
        page=page,
        package=package or '',
        packager=packager,
        action=action,
        status=status,
        statuses=action_status,
    )
Example #9
0
def admin_actions():
    """ Return the actions requested and requiring intervention from an
    admin.
    """
    package = flask.request.args.get('package', None)
    packager = flask.request.args.get('packager', None)
    action = flask.request.args.get('action', None)
    status = flask.request.args.get('status', 'Awaiting Review')
    limit = flask.request.args.get('limit', APP.config['ITEMS_PER_PAGE'])
    page = flask.request.args.get('page', 1)

    try:
        page = abs(int(page))
    except ValueError:
        page = 1

    try:
        limit = abs(int(limit))
    except ValueError:
        limit = APP.config['ITEMS_PER_PAGE']
        flask.flash('Incorrect limit provided, using default', 'errors')

    actions = []
    cnt_actions = 0
    try:
        actions = pkgdblib.search_actions(
            SESSION,
            package=package or None,
            packager=packager or None,
            action=action,
            status=status,
            page=page,
            limit=limit,
            order='desc',
        )
        cnt_actions = pkgdblib.search_actions(
            SESSION,
            package=package or None,
            packager=packager or None,
            action=action,
            status=status,
            count=True
        )
    except PkgdbException as err:
        flask.flash(err, 'errors')

    total_page = int(ceil(cnt_actions / float(limit)))

    action_status = pkgdblib.get_status(
        SESSION, 'admin_status')['admin_status']
    action_status.insert(0, 'All')

    return flask.render_template(
        'list_actions.html',
        actions=actions,
        cnt_actions=cnt_actions,
        total_page=total_page,
        page=page,
        package=package or '',
        packager=packager or '',
        action=action,
        status=status,
        statuses=action_status,
    )
Example #10
0
def api_admin_actions():
    """
List admin actions
------------------
    List actions requiring intervention from an admin.

    ::

        /api/admin/actions/

    Accept GET queries only.

    :kwarg package: restrict the actions to a specific package.
    :kwarg packager: restrict the actions to a specific packager.
    :kwarg action: restrict the actions to a specific action, options are:
        ``request.branch``, ``request.package``.
    :kwarg status: restrict the actions depending on their status, options
        are: ``Awaiting Review``, ``Approved``, ``Denied``, ``Obsolete``,
        ``Removed``.
    :kwarg limit: An integer to limit the number of results, defaults to
        250, maximum is 500.
    :kwarg page: The page number to return (useful in combination to limit).

    Sample response:

    ::

        /api/admin/actions

        {
          "output": "ok",
          "actions": [
            {
              "action": "request.branch",
              "collection": {
                "branchname": "epel7",
                "dist_tag": ".el7",
                "koji_name": "epel7",
                "name": "Fedora EPEL",
                "status": "Active",
                "version": "7"
              },
              "date_created": 1402470695.0,
              "date_updated": 1402470695.0,
              "from_collection": {
                "branchname": "f19",
                "dist_tag": ".fc19",
                "koji_name": "f19",
                "name": "Fedora",
                "status": "Active",
                "version": "19"
              },
              "id": 8,
              "info": null,
              "package": {
                "acls": [],
                "creation_date": 1400063778.0,
                "description": "Guake is a drop-down terminal for Gnome "
                               "Desktop Environment, so you just need to "
                               "press a key to invoke him, and press again "
                               "to hide.",
                "name": "guake",
                "review_url": null,
                "status": "Approved",
                "summary": "Drop-down terminal for GNOME",
                "upstream_url": "http://guake.org/"
              },
              "status": "Awaiting Review",
              "user": "******"
            }
          ],
          "page": 1,
          "page_total": 1
        }

    .. note:: the ``date_created`` and ``date_updated`` fields are both
            timestamps expressed in
            `Unix TIME <https://en.wikipedia.org/wiki/Unix_time>`_

    """
    package = flask.request.args.get('package', None)
    packager = flask.request.args.get('packager', None)
    action = flask.request.args.get('action', None)
    status = flask.request.args.get('status', None)
    page = flask.request.args.get('page', 1)
    limit = get_limit()

    httpcode = 200
    output = {}

    try:
        page = abs(int(page))
    except ValueError:
        page = 1

    actions = []
    cnt_actions = 0
    try:
        actions = pkgdblib.search_actions(SESSION,
                                          package=package or None,
                                          packager=packager or None,
                                          action=action,
                                          status=status,
                                          limit=limit,
                                          page=page)

        cnt_actions += pkgdblib.search_actions(
            SESSION,
            package=package or None,
            packager=packager or None,
            action=action,
            status=status,
            count=True,
        )
    except pkgdblib.PkgdbException, err:  # pragma: no cover
        SESSION.rollback()
        output['output'] = 'notok'
        output['error'] = str(err)
        httpcode = 500