Ejemplo n.º 1
0
def package_orphan(package, collection):
    ''' Gives the possibility to orphan or take a package. '''

    packagename = package
    package = None
    try:
        package_acl = pkgdblib.get_acl_package(SESSION, packagename)
        package = pkgdblib.search_package(SESSION, packagename, limit=1)[0]
    except (NoResultFound, IndexError):
        SESSION.rollback()
        flask.flash('No package of this name found.', 'errors')
        return flask.render_template('msg.html')

    for acl in package_acl:
        if acl.collection.branchname == collection:
            try:
                pkgdblib.update_pkg_poc(session=SESSION,
                                        pkg_name=package.name,
                                        pkg_branch=acl.collection.branchname,
                                        pkg_poc='orphan',
                                        user=flask.g.fas_user)
                flask.flash(
                    'You are no longer point of contact on branch: %s' %
                    collection)
            except pkgdblib.PkgdbException, err:
                flask.flash(str(err), 'error')
                SESSION.rollback()
            break
Ejemplo n.º 2
0
def package_orphan(package, collection):
    ''' Gives the possibility to orphan or take a package. '''

    packagename = package
    package = None
    try:
        package_acl = pkgdblib.get_acl_package(SESSION, packagename)
        package = pkgdblib.search_package(SESSION, packagename, limit=1)[0]
    except (NoResultFound, IndexError):
        SESSION.rollback()
        flask.flash('No package of this name found.', 'errors')
        return flask.render_template('msg.html')

    for acl in package_acl:
        if acl.collection.branchname == collection:
            try:
                pkgdblib.update_pkg_poc(
                    session=SESSION,
                    pkg_name=package.name,
                    pkg_branch=acl.collection.branchname,
                    pkg_poc='orphan',
                    user=flask.g.fas_user
                )
                flask.flash(
                    'You are no longer point of contact on branch: %s'
                    % collection)
            except pkgdblib.PkgdbException, err:
                flask.flash(str(err), 'error')
                SESSION.rollback()
            break
Ejemplo n.º 3
0
def package_orphan(namespace, package, full=True):
    ''' Gives the possibility to orphan or take a package. '''

    if not bool(full) or str(full) in ['0', 'False']:
        full = False

    try:
        package_acl = pkgdblib.get_acl_package(
            SESSION, namespace, package)
        package = pkgdblib.search_package(
            SESSION, namespace, package, limit=1)[0]
    except (NoResultFound, IndexError):
        SESSION.rollback()
        flask.flash('No package of this name found.', 'errors')
        return flask.render_template('msg.html')

    collections = [
        acl.collection.branchname
        for acl in package_acl
        if acl.collection.status in ['Active', 'Under Development']
        and acl.status == 'Approved'
        and (
            is_pkgdb_admin(flask.g.fas_user)
            or acl.point_of_contact == flask.g.fas_user.username
            or (
                acl.point_of_contact.startswith('group::') and
                is_pkg_admin(
                    SESSION, flask.g.fas_user, namespace, package.name)
            )
        )
    ]

    form = pkgdb2.forms.BranchForm(collections=collections)

    if form.validate_on_submit():
        for branch in form.branches.data:
            try:
                pkgdblib.update_pkg_poc(
                    session=SESSION,
                    namespace=namespace,
                    pkg_name=package.name,
                    pkg_branch=branch,
                    pkg_poc='orphan',
                    user=flask.g.fas_user
                )

                flask.flash(
                    'You are no longer point of contact on branch: %s'
                    % branch)
            except pkgdblib.PkgdbBugzillaException, err:  # pragma: no cover
                APP.logger.exception(err)
                flask.flash(str(err), 'error')
                SESSION.rollback()
            except pkgdblib.PkgdbException, err:  # pragma: no cover
                flask.flash(str(err), 'error')
                SESSION.rollback()
Ejemplo n.º 4
0
def api_package_orphan():
    '''
Orphan package
--------------
    Orphan one or more packages.

    ::

        /api/package/orphan/

    Accept POST queries only.

    :arg pkgnames: Comma separated list of string of the packages name.
    :arg branches: Comma separated list of string of the branches name in
        which these packages will be orphaned.


    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["User: $USER changed poc of package: $PACKAGE from "
                       "$PREVIOUS_POC to $NEW_POC on branch: $BRANCH"]
        }

        {
          "output": "notok",
          "error": ["You are not allowed to change the point of contact."]
        }

     '''
    httpcode = 200
    output = {}

    pkgnames = flask.request.form.getlist('pkgnames', None)
    branches = flask.request.form.getlist('branches', None)

    if pkgnames and branches:
        try:
            messages = []
            for pkg_name, pkg_branch in itertools.product(
                    pkgnames, branches):
                message = pkgdblib.update_pkg_poc(
                    SESSION,
                    pkg_name=pkg_name,
                    pkg_branch=pkg_branch,
                    pkg_poc='orphan',
                    user=flask.g.fas_user,
                )
                messages.append(message)
            SESSION.commit()
            output['output'] = 'ok'
            output['messages'] = messages
        except pkgdblib.PkgdbException, err:
            SESSION.rollback()
            output['output'] = 'notok'
            output['error'] = str(err)
            httpcode = 500
Ejemplo n.º 5
0
def package_orphan(namespace, package, full=True):
    ''' Gives the possibility to orphan or take a package. '''

    if not bool(full) or str(full) in ['0', 'False']:
        full = False

    try:
        package_acl = pkgdblib.get_acl_package(SESSION, namespace, package)
        package = pkgdblib.search_package(SESSION, namespace, package,
                                          limit=1)[0]
    except (NoResultFound, IndexError):
        SESSION.rollback()
        flask.flash('No package of this name found.', 'errors')
        return flask.render_template('msg.html')

    collections = [
        acl.collection.branchname for acl in package_acl
        if acl.collection.status in ['Active', 'Under Development']
        and acl.status == 'Approved' and (
            is_pkgdb_admin(flask.g.fas_user)
            or acl.point_of_contact == flask.g.fas_user.username or
            (acl.point_of_contact.startswith('group::') and is_pkg_admin(
                SESSION, flask.g.fas_user, namespace, package.name)))
    ]

    form = pkgdb2.forms.BranchForm(collections=collections)

    if form.validate_on_submit():
        for branch in form.branches.data:
            try:
                pkgdblib.update_pkg_poc(session=SESSION,
                                        namespace=namespace,
                                        pkg_name=package.name,
                                        pkg_branch=branch,
                                        pkg_poc='orphan',
                                        user=flask.g.fas_user)

                flask.flash(
                    'You are no longer point of contact on branch: %s' %
                    branch)
            except pkgdblib.PkgdbBugzillaException, err:  # pragma: no cover
                APP.logger.exception(err)
                flask.flash(str(err), 'error')
                SESSION.rollback()
            except pkgdblib.PkgdbException, err:  # pragma: no cover
                flask.flash(str(err), 'error')
                SESSION.rollback()
Ejemplo n.º 6
0
def api_package_orphan():
    '''
Orphan package
--------------
    Orphan one or more packages.

    ::

        /api/package/orphan/

    Accept POST queries only.

    :arg pkgnames: Comma separated list of string of the packages name.
    :arg branches: Comma separated list of string of the branches name in
        which these packages will be orphaned.


    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["User: $USER changed poc of package: $PACKAGE from "
                       "$PREVIOUS_POC to $NEW_POC on branch: $BRANCH"]
        }

        {
          "output": "notok",
          "error": ["You are not allowed to change the point of contact."]
        }

     '''
    httpcode = 200
    output = {}

    pkgnames = flask.request.form.getlist('pkgnames', None)
    branches = flask.request.form.getlist('branches', None)

    if pkgnames and branches:
        try:
            messages = []
            for pkg_name, pkg_branch in itertools.product(pkgnames, branches):
                message = pkgdblib.update_pkg_poc(
                    SESSION,
                    pkg_name=pkg_name,
                    pkg_branch=pkg_branch,
                    pkg_poc='orphan',
                    user=flask.g.fas_user,
                )
                messages.append(message)
            SESSION.commit()
            output['output'] = 'ok'
            output['messages'] = messages
        except pkgdblib.PkgdbException, err:
            SESSION.rollback()
            output['output'] = 'notok'
            output['error'] = str(err)
            httpcode = 500
Ejemplo n.º 7
0
def api_package_orphan():
    '''
Orphan package
--------------
    Orphan one or more packages.

    ::

        /api/package/orphan/

    Accept POST queries only.

    :arg pkgnames: Comma separated list of string of the packages name.
    :arg branches: Comma separated list of string of the branches name in
        which these packages will be orphaned.


    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["User: $USER changed poc of package: $PACKAGE from "
                       "$PREVIOUS_POC to $NEW_POC on branch: $BRANCH"]
        }

        {
          "output": "notok",
          "error": ["You are not allowed to change the point of contact."]
        }

     '''
    httpcode = 200
    output = {}

    pkgnames = flask.request.form.getlist('pkgnames', None)
    branches = flask.request.form.getlist('branches', None)

    if pkgnames and branches:
        messages = []
        errors = set()
        for pkg_name, pkg_branch in itertools.product(
                pkgnames, branches):
            try:
                message = pkgdblib.update_pkg_poc(
                    SESSION,
                    pkg_name=pkg_name,
                    pkg_branch=pkg_branch,
                    pkg_poc='orphan',
                    user=flask.g.fas_user,
                )

                messages.append(message)
                SESSION.commit()
            except pkgdblib.PkgdbException, err:
                SESSION.rollback()
                errors.add(str(err))

        if messages:
            output['messages'] = messages
            output['output'] = 'ok'
        else:
            # If messages is empty that means that we failed all the orphans
            # so output is `notok`, otherwise it means that we succeeded at
            # least once and thus output will be `ok` to keep backward
            # compatibility.
            httpcode = 500
            output['output'] = 'notok'

        if errors:
            errors = list(errors)
            output['error'] = errors
            if len(errors) == 1:
                output['error'] = errors.pop()
Ejemplo n.º 8
0
def api_package_orphan():
    '''
    Orphan package
    --------------
    Orphan one or more packages.

    ::

        /api/package/orphan/

    Accepts POST queries only.

    :arg pkgnames: Comma separated list of string of the packages name.
    :arg branches: Comma separated list of string of the branches name in
        which these packages will be orphaned.
    :kwarg former_poc: Use to restrict orphaning the branches maintained by
        a specific user while providing a broader list of branches.


    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["User: $USER changed poc of package: $PACKAGE from "
                       "$PREVIOUS_POC to $NEW_POC on branch: $BRANCH"]
        }

        {
          "output": "notok",
          "error": ["You are not allowed to change the point of contact."]
        }

     '''
    httpcode = 200
    output = {}

    pkgnames = flask.request.form.getlist('pkgnames', None)
    branches = flask.request.form.getlist('branches', None)
    former_poc = flask.request.form.get('former_poc', None)

    if pkgnames and branches:
        messages = []
        errors = set()
        for pkg_name, pkg_branch in itertools.product(pkgnames, branches):
            try:
                message = pkgdblib.update_pkg_poc(
                    SESSION,
                    pkg_name=pkg_name,
                    pkg_branch=pkg_branch,
                    pkg_poc='orphan',
                    former_poc=former_poc,
                    user=flask.g.fas_user,
                )

                messages.append(message)
                SESSION.commit()
            except pkgdblib.PkgdbException, err:
                SESSION.rollback()
                errors.add(str(err))

        if messages:
            output['messages'] = messages
            output['output'] = 'ok'
        else:
            # If messages is empty that means that we failed all the orphans
            # so output is `notok`, otherwise it means that we succeeded at
            # least once and thus output will be `ok` to keep backward
            # compatibility.
            httpcode = 500
            output['output'] = 'notok'

        if errors:
            errors = list(errors)
            output['error'] = errors
            if len(errors) == 1:
                output['error'] = errors.pop()
Ejemplo n.º 9
0
def package_give(package, full=True):
    ''' Gives the PoC of a package to someone else. '''

    if not bool(full) or str(full) in ['0', 'False']:
        full = False

    packagename = package
    package = None
    try:
        package_acl = pkgdblib.get_acl_package(SESSION, packagename)
        package = pkgdblib.search_package(SESSION, packagename, limit=1)[0]
    except (NoResultFound, IndexError):
        SESSION.rollback()
        flask.flash('No package of this name found.', 'errors')
        return flask.render_template('msg.html')

    # Restrict the branch to the one current user is PoC of (unless admin
    # or group)
    collect_name = []
    for acl in package_acl:
        if acl.point_of_contact != flask.g.fas_user.username and \
                not is_pkgdb_admin(flask.g.fas_user) and \
                not acl.point_of_contact.startswith('group::'):
            pass
        else:
            if acl.point_of_contact.startswith('group::'):
                group = acl.point_of_contact.split('group::')[0]
                if group not in flask.g.fas_user.groups:
                    pass
            elif acl.collection.status != 'EOL':
                collect_name.append(acl.collection.branchname)

    form = pkgdb2.forms.GivePoCForm(collections=collect_name)

    acls = ['commit', 'watchbugzilla', 'watchcommits', 'approveacls']

    if form.validate_on_submit():
        collections = form.branches.data
        pkg_poc = form.poc.data
        if pkg_poc.startswith('group::'):
            acls = ['commit', 'watchbugzilla', 'watchcommits']

        try:
            for pkg_collection in collections:
                message = pkgdblib.update_pkg_poc(
                    SESSION,
                    pkg_name=packagename,
                    pkg_branch=pkg_collection,
                    pkg_poc=pkg_poc,
                    user=flask.g.fas_user,
                )
                flask.flash(message)

                for acl in acls:
                    pkgdblib.set_acl_package(SESSION,
                                             pkg_name=packagename,
                                             pkg_branch=pkg_collection,
                                             pkg_user=pkg_poc,
                                             acl=acl,
                                             status='Approved',
                                             user=flask.g.fas_user)

                SESSION.commit()
        except pkgdblib.PkgdbBugzillaException, err:  # pragma: no cover
            APP.logger.exception(err)
            flask.flash(str(err), 'error')
            SESSION.rollback()
        except pkgdblib.PkgdbException, err:
            SESSION.rollback()
            flask.flash(str(err), 'error')
Ejemplo n.º 10
0
Archivo: acls.py Proyecto: voxik/pkgdb2
def api_acl_reassign():
    '''
    Reassign packages
    -----------------
    Reassign the specified packages from one user to another.

    ::

        /api/package/acl/reassign/

    Accepts POST queries only.

    :arg namespace: The namespace of the packages to reassign (can only
        reassign package from one namespace at a time).
    :arg pkgnames: List of strings of the package name to reassign.
    :arg branches: List of strings of the branchname of the Collection on
        which to reassign the point of contact.
    :arg poc: User name of the new point of contact.
    :kwarg former_poc: Specify the former poc of the packages you want to
        reassign. This allows to specify more branches than the former_poc
        had while still only reassigning the branches the former_poc had.

    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["User: $USER changed poc of package: $PACKAGE from "
                       "$PREVIOUS_POC to $NEW_POC on branch: $BRANCH"]
        }

        {
          "output": "notok",
          "error": ["You are not allowed to change the point of contact."]
        }

    '''
    httpcode = 200
    output = {}

    packages = flask.request.form.getlist('pkgnames', None)
    namespace = flask.request.form.get('namespace', None)
    branches = flask.request.form.getlist('branches', None)
    former_poc = flask.request.form.get('former_poc', None)
    user_target = flask.request.form.get('poc', None)

    if not packages or not branches or not user_target or not namespace:
        output['output'] = 'notok'
        output['error'] = 'Invalid input submitted'
        httpcode = 500

    else:
        messages = []
        errors = set()
        for (package, branch) in itertools.product(packages, branches):
            try:
                message = pkgdblib.update_pkg_poc(
                    session=SESSION,
                    namespace=namespace,
                    pkg_name=package,
                    pkg_branch=branch,
                    pkg_poc=user_target,
                    former_poc=former_poc,
                    user=flask.g.fas_user
                )
                SESSION.commit()
                messages.append(message)
            except PkgdbBugzillaException as err:  # pragma: no cover
                APP.logger.exception(err)
                SESSION.rollback()
                errors.add(str(err))
            except PkgdbException as err:
                SESSION.rollback()
                errors.add(str(err))

        if messages:
            output['messages'] = messages
            output['output'] = 'ok'
        else:
            # If messages is empty that means that we failed all the
            # unorphans so output is `notok`, otherwise it means that we
            # succeeded at least once and thus output will be `ok` to keep
            # backward compatibility.
            httpcode = 500
            output['output'] = 'notok'

        if errors:
            errors = list(errors)
            output['error'] = errors
            if len(errors) == 1:
                output['error'] = errors.pop()

    jsonout = flask.jsonify(output)
    jsonout.status_code = httpcode
    return jsonout
Ejemplo n.º 11
0
def api_acl_reassign():
    '''
Reassign packages
-----------------
    Reassign the specified packages from one user to another.

    ::

        /api/package/acl/reassign/

    Accept POST queries only.

    :arg packages: List of strings of the package name to reassign.
    :arg branches: List of strings of the branchname of the Collection on
        which to reassign the point of contact.
    :arg user_target: User name of the new point of contact.

    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["User: $USER changed poc of package: $PACKAGE from "
                       "$PREVIOUS_POC to $NEW_POC on branch: $BRANCH"]
        }

        {
          "output": "notok",
          "error": ["You are not allowed to change the point of contact."]
        }

    '''
    httpcode = 200
    output = {}

    packages = flask.request.form.get('packages', '').split(',')
    branches = flask.request.form.get('branches', '').split(',')
    user_target = flask.request.form.get('user_target', None)

    if not packages or not branches or not user_target:
        output['output'] = 'notok'
        output['error'] = 'Invalid input submitted'
        httpcode = 500

    else:
        try:
            messages = []
            for (package, branch) in itertools.product(packages, branches):
                messages.append(
                    pkgdblib.update_pkg_poc(
                        session=SESSION,
                        pkg_name=package,
                        pkg_branch=branch,
                        pkg_poc=user_target,
                        user=flask.g.fas_user
                    )
                )
            SESSION.commit()
            output['output'] = 'ok'
            output['messages'] = messages
        except pkgdblib.PkgdbException, err:
            SESSION.rollback()
            output['output'] = 'notok'
            output['error'] = str(err)
            httpcode = 500
Ejemplo n.º 12
0
def package_give(namespace, package, full=True):
    ''' Gives the PoC of a package to someone else. '''

    if not bool(full) or str(full) in ['0', 'False']:
        full = False

    packagename = package
    package = None
    try:
        package_acl = pkgdblib.get_acl_package(
            SESSION, namespace, packagename)
        package = pkgdblib.search_package(
            SESSION, namespace, packagename, limit=1)[0]
    except (NoResultFound, IndexError):
        SESSION.rollback()
        flask.flash('No package of this name found.', 'errors')
        return flask.render_template('msg.html')

    # Restrict the branch to the one current user is PoC of (unless admin
    # or group)
    collect_name = []
    for acl in package_acl:
        if acl.point_of_contact != flask.g.fas_user.username and \
                not is_pkgdb_admin(flask.g.fas_user) and \
                not acl.point_of_contact.startswith('group::'):
            pass
        else:
            if acl.point_of_contact.startswith('group::'):
                group = acl.point_of_contact.split('group::')[0]
                if group not in flask.g.fas_user.groups:
                    pass
            elif acl.collection.status != 'EOL':
                collect_name.append(acl.collection.branchname)

    form = pkgdb2.forms.GivePoCForm(collections=collect_name)

    acls = ['commit', 'watchbugzilla', 'watchcommits', 'approveacls']

    if form.validate_on_submit():
        collections = form.branches.data
        pkg_poc = form.poc.data
        if pkg_poc.startswith('group::'):
            acls = ['commit', 'watchbugzilla', 'watchcommits']

        try:
            for pkg_collection in collections:
                message = pkgdblib.update_pkg_poc(
                    SESSION,
                    namespace=namespace,
                    pkg_name=packagename,
                    pkg_branch=pkg_collection,
                    pkg_poc=pkg_poc,
                    user=flask.g.fas_user,
                )
                flask.flash(message)

                for acl in acls:
                    pkgdblib.set_acl_package(
                        SESSION,
                        namespace=namespace,
                        pkg_name=packagename,
                        pkg_branch=pkg_collection,
                        pkg_user=pkg_poc,
                        acl=acl,
                        status='Approved',
                        user=flask.g.fas_user
                    )

                SESSION.commit()
        except pkgdblib.exceptions.PkgdbBugzillaException as err:  # pragma: no cover
            APP.logger.exception(err)
            flask.flash(str(err), 'error')
            SESSION.rollback()
        except PkgdbException as err:
            SESSION.rollback()
            flask.flash(str(err), 'error')

        return flask.redirect(flask.url_for(
            '.package_info', namespace=namespace, package=packagename)
        )

    return flask.render_template(
        'package_give.html',
        full=full,
        form=form,
        packagename=packagename,
        namespace=namespace,
    )
Ejemplo n.º 13
0
def api_acl_reassign():
    """
Reassign packages
-----------------
    Reassign the specified packages from one user to another.

    ::

        /api/package/acl/reassign/

    Accept POST queries only.

    :arg pkgnames: List of strings of the package name to reassign.
    :arg branches: List of strings of the branchname of the Collection on
        which to reassign the point of contact.
    :arg poc: User name of the new point of contact.

    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["User: $USER changed poc of package: $PACKAGE from "
                       "$PREVIOUS_POC to $NEW_POC on branch: $BRANCH"]
        }

        {
          "output": "notok",
          "error": ["You are not allowed to change the point of contact."]
        }

    """
    httpcode = 200
    output = {}

    packages = flask.request.form.getlist("pkgnames", None)
    branches = flask.request.form.getlist("branches", None)
    user_target = flask.request.form.get("poc", None)

    if not packages or not branches or not user_target:
        output["output"] = "notok"
        output["error"] = "Invalid input submitted"
        httpcode = 500

    else:
        messages = []
        errors = set()
        for (package, branch) in itertools.product(packages, branches):
            try:
                message = pkgdblib.update_pkg_poc(
                    session=SESSION, pkg_name=package, pkg_branch=branch, pkg_poc=user_target, user=flask.g.fas_user
                )
                SESSION.commit()
                messages.append(message)
            except pkgdblib.PkgdbBugzillaException, err:  # pragma: no cover
                APP.logger.exception(err)
                SESSION.rollback()
                errors.add(str(err))
            except pkgdblib.PkgdbException, err:
                SESSION.rollback()
                errors.add(str(err))
Ejemplo n.º 14
0
def api_acl_reassign():
    '''
Reassign packages
-----------------
    Reassign the specified packages from one user to another.

    ::

        /api/package/acl/reassign/

    Accept POST queries only.

    :arg packages: List of strings of the package name to reassign.
    :arg branches: List of strings of the branchname of the Collection on
        which to reassign the point of contact.
    :arg user_target: User name of the new point of contact.

    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["User: $USER changed poc of package: $PACKAGE from "
                       "$PREVIOUS_POC to $NEW_POC on branch: $BRANCH"]
        }

        {
          "output": "notok",
          "error": ["You are not allowed to change the point of contact."]
        }

    '''
    httpcode = 200
    output = {}

    packages = flask.request.form.get('packages', '').split(',')
    branches = flask.request.form.get('branches', '').split(',')
    user_target = flask.request.form.get('user_target', None)

    if not packages or not branches or not user_target:
        output['output'] = 'notok'
        output['error'] = 'Invalid input submitted'
        httpcode = 500

    else:
        try:
            messages = []
            for (package, branch) in itertools.product(packages, branches):
                messages.append(
                    pkgdblib.update_pkg_poc(session=SESSION,
                                            pkg_name=package,
                                            pkg_branch=branch,
                                            pkg_poc=user_target,
                                            user=flask.g.fas_user))
            SESSION.commit()
            output['output'] = 'ok'
            output['messages'] = messages
        except pkgdblib.PkgdbException, err:
            SESSION.rollback()
            output['output'] = 'notok'
            output['error'] = str(err)
            httpcode = 500
Ejemplo n.º 15
0
def api_acl_reassign():
    '''
    Reassign packages
    -----------------
    Reassign the specified packages from one user to another.

    ::

        /api/package/acl/reassign/

    Accepts POST queries only.

    :arg pkgnames: List of strings of the package name to reassign.
    :arg branches: List of strings of the branchname of the Collection on
        which to reassign the point of contact.
    :arg poc: User name of the new point of contact.
    :kwarg former_poc: Specify the former poc of the packages you want to
        reassign. This allows to specify more branches than the former_poc
        had while still only reassigning the branches the former_poc had.

    Sample response:

    ::

        {
          "output": "ok",
          "messages": ["User: $USER changed poc of package: $PACKAGE from "
                       "$PREVIOUS_POC to $NEW_POC on branch: $BRANCH"]
        }

        {
          "output": "notok",
          "error": ["You are not allowed to change the point of contact."]
        }

    '''
    httpcode = 200
    output = {}

    packages = flask.request.form.getlist('pkgnames', None)
    branches = flask.request.form.getlist('branches', None)
    former_poc = flask.request.form.get('former_poc', None)
    user_target = flask.request.form.get('poc', None)

    if not packages or not branches or not user_target:
        output['output'] = 'notok'
        output['error'] = 'Invalid input submitted'
        httpcode = 500

    else:
        messages = []
        errors = set()
        for (package, branch) in itertools.product(packages, branches):
            try:
                message = pkgdblib.update_pkg_poc(session=SESSION,
                                                  pkg_name=package,
                                                  pkg_branch=branch,
                                                  pkg_poc=user_target,
                                                  former_poc=former_poc,
                                                  user=flask.g.fas_user)
                SESSION.commit()
                messages.append(message)
            except pkgdblib.PkgdbBugzillaException, err:  # pragma: no cover
                APP.logger.exception(err)
                SESSION.rollback()
                errors.add(str(err))
            except pkgdblib.PkgdbException, err:
                SESSION.rollback()
                errors.add(str(err))