Пример #1
0
def join_project(project_id, request_user):
    get_chain_for_update(project_id)
    project = get_project_by_id(project_id)
    join_project_checks(project)

    membership, created = ProjectMembership.objects.get_or_create(
        project=project,
        person=request_user)

    if not created:
        msg = _(astakos_messages.MEMBERSHIP_REQUEST_EXISTS)
        raise PermissionDenied(msg)

    auto_accepted = False
    join_policy = project.application.member_join_policy
    if (join_policy == AUTO_ACCEPT_POLICY and (
            not project.violates_members_limit(adding=1))):
        membership.accept()
        qh_sync_user(request_user)
        logger.info("User %s joined %s." %
                    (request_user.log_display, project))
        auto_accepted = True
    else:
        membership_request_notify(project, membership.person)
        logger.info("User %s requested to join %s." %
                    (request_user.log_display, project))
    return auto_accepted
Пример #2
0
def join_project(project_id, request_user, reason=None):
    project = get_project_for_update(project_id)
    join_project_checks(project)

    try:
        membership = get_membership(project.id, request_user.id)
        if not membership.check_action("join"):
            msg = _(astakos_messages.MEMBERSHIP_ASSOCIATED)
            raise ProjectConflict(msg)
        membership.perform_action("join", actor=request_user, reason=reason)
    except ProjectNotFound:
        membership = new_membership(project, request_user, actor=request_user,
                                    reason=reason)

    join_policy = project.application.member_join_policy
    if (join_policy == AUTO_ACCEPT_POLICY and (
            not project.violates_members_limit(adding=1))):
        membership.perform_action("accept", actor=request_user, reason=reason)
        qh_sync_user(request_user)
        logger.info("User %s joined %s." %
                    (request_user.log_display, project))
    else:
        membership_request_notify(project, membership.person)
        logger.info("User %s requested to join %s." %
                    (request_user.log_display, project))
    return membership
Пример #3
0
def join_project(project_id, request_user, reason=None):
    project = get_project_for_update(project_id)
    join_project_checks(project)

    try:
        membership = get_membership(project.id, request_user.id)
        if not membership.check_action("join"):
            msg = _(astakos_messages.MEMBERSHIP_ASSOCIATED)
            raise ProjectConflict(msg)
        membership.perform_action("join", actor=request_user, reason=reason)
    except ProjectNotFound:
        membership = new_membership(project,
                                    request_user,
                                    actor=request_user,
                                    reason=reason)

    join_policy = project.application.member_join_policy
    if (join_policy == AUTO_ACCEPT_POLICY
            and (not project.violates_members_limit(adding=1))):
        membership.perform_action("accept", actor=request_user, reason=reason)
        qh_sync_user(request_user)
        logger.info("User %s joined %s." % (request_user.log_display, project))
    else:
        membership_request_notify(project, membership.person)
        logger.info("User %s requested to join %s." %
                    (request_user.log_display, project))
    return membership
Пример #4
0
def join_project(project_id, request_user):
    get_chain_for_update(project_id)
    project = get_project_by_id(project_id)
    join_project_checks(project)

    membership, created = ProjectMembership.objects.get_or_create(
        project=project, person=request_user)

    if not created:
        msg = _(astakos_messages.MEMBERSHIP_REQUEST_EXISTS)
        raise PermissionDenied(msg)

    auto_accepted = False
    join_policy = project.application.member_join_policy
    if (join_policy == AUTO_ACCEPT_POLICY
            and (not project.violates_members_limit(adding=1))):
        membership.accept()
        qh_sync_user(request_user)
        logger.info("User %s joined %s." % (request_user.log_display, project))
        auto_accepted = True
    else:
        membership_request_notify(project, membership.person)
        logger.info("User %s requested to join %s." %
                    (request_user.log_display, project))
    return auto_accepted
Пример #5
0
def leave_project(memb_id, request_user, reason=None):
    project = get_project_of_membership_for_update(memb_id)
    membership = get_membership_by_id(memb_id)
    leave_project_checks(membership, request_user)

    auto_accepted = False
    leave_policy = project.member_leave_policy
    if leave_policy == AUTO_ACCEPT_POLICY:
        membership.perform_action("remove", actor=request_user, reason=reason)
        quotas.qh_sync_membership(membership)
        logger.info("User %s has left %s." %
                    (request_user.log_display, project))
        auto_accepted = True
    else:
        membership.perform_action("leave_request", actor=request_user,
                                  reason=reason)
        logger.info("User %s requested to leave %s." %
                    (request_user.log_display, project))
        project_notif.membership_request_notify(
            project, membership.person, "leave")
    return auto_accepted