コード例 #1
0
ファイル: functions.py プロジェクト: cstavr/synnefo
def submit_application(owner=None,
                       name=None,
                       precursor_id=None,
                       homepage=None,
                       description=None,
                       start_date=None,
                       end_date=None,
                       member_join_policy=None,
                       member_leave_policy=None,
                       limit_on_members_number=None,
                       comments=None,
                       resource_policies=None,
                       request_user=None):

    precursor = None
    if precursor_id is not None:
        get_chain_of_application_for_update(precursor_id)
        precursor = ProjectApplication.objects.get(id=precursor_id)

        if (request_user and
            (not precursor.owner == request_user and
             not request_user.is_superuser
             and not request_user.is_project_admin())):
            m = _(astakos_messages.NOT_ALLOWED)
            raise PermissionDenied(m)

    force = request_user.is_project_admin()
    ok, limit = qh_add_pending_app(owner, precursor, force)
    if not ok:
        m = _(astakos_messages.REACHED_PENDING_APPLICATION_LIMIT) % limit
        raise PermissionDenied(m)

    application = ProjectApplication(
        applicant=request_user,
        owner=owner,
        name=name,
        precursor_application_id=precursor_id,
        homepage=homepage,
        description=description,
        start_date=start_date,
        end_date=end_date,
        member_join_policy=member_join_policy,
        member_leave_policy=member_leave_policy,
        limit_on_members_number=limit_on_members_number,
        comments=comments)

    if precursor is None:
        application.chain = new_chain()
    else:
        chain = precursor.chain
        application.chain = chain
        objs = ProjectApplication.objects
        pending = objs.filter(chain=chain, state=ProjectApplication.PENDING)
        for app in pending:
            app.state = ProjectApplication.REPLACED
            app.save()

    application.save()
    if resource_policies is not None:
        application.set_resource_policies(resource_policies)
    logger.info("User %s submitted %s." %
                (request_user.log_display, application.log_display))
    application_submit_notify(application)
    return application
コード例 #2
0
def submit_application(owner=None,
                       name=None,
                       project_id=None,
                       homepage=None,
                       description=None,
                       start_date=None,
                       end_date=None,
                       member_join_policy=None,
                       member_leave_policy=None,
                       limit_on_members_number=None,
                       comments=None,
                       resources=None,
                       request_user=None):

    project = None
    if project_id is not None:
        project = get_project_for_update(project_id)
        project_check_allowed(project, request_user, level=APPLICANT_LEVEL)

    policies = validate_resource_policies(resources)

    force = request_user.is_project_admin()
    ok, limit = qh_add_pending_app(owner, project, force)
    if not ok:
        m = _(astakos_messages.REACHED_PENDING_APPLICATION_LIMIT) % limit
        raise ProjectConflict(m)

    application = ProjectApplication(
        applicant=request_user,
        owner=owner,
        name=name,
        homepage=homepage,
        description=description,
        start_date=start_date,
        end_date=end_date,
        member_join_policy=member_join_policy,
        member_leave_policy=member_leave_policy,
        limit_on_members_number=limit_on_members_number,
        comments=comments)

    if project is None:
        chain = new_chain()
        application.chain_id = chain.chain
        application.save()
        Project.objects.create(id=chain.chain, application=application)
    else:
        application.chain = project
        application.save()
        if project.application.state != ProjectApplication.APPROVED:
            project.application = application
            project.save()

        pending = ProjectApplication.objects.filter(
            chain=project,
            state=ProjectApplication.PENDING).exclude(id=application.id)
        for app in pending:
            app.state = ProjectApplication.REPLACED
            app.save()

    if policies is not None:
        set_resource_policies(application, policies)
    logger.info("User %s submitted %s." %
                (request_user.log_display, application.log_display))
    application_submit_notify(application)
    return application
コード例 #3
0
ファイル: functions.py プロジェクト: antonis-m/synnefo
def submit_application(owner=None,
                       name=None,
                       project_id=None,
                       homepage=None,
                       description=None,
                       start_date=None,
                       end_date=None,
                       member_join_policy=None,
                       member_leave_policy=None,
                       limit_on_members_number=None,
                       comments=None,
                       resources=None,
                       request_user=None):

    project = None
    if project_id is not None:
        project = get_project_for_update(project_id)
        project_check_allowed(project, request_user, level=APPLICANT_LEVEL)

    policies = validate_resource_policies(resources)

    force = request_user.is_project_admin()
    ok, limit = qh_add_pending_app(owner, project, force)
    if not ok:
        m = _(astakos_messages.REACHED_PENDING_APPLICATION_LIMIT) % limit
        raise ProjectConflict(m)

    application = ProjectApplication(
        applicant=request_user,
        owner=owner,
        name=name,
        homepage=homepage,
        description=description,
        start_date=start_date,
        end_date=end_date,
        member_join_policy=member_join_policy,
        member_leave_policy=member_leave_policy,
        limit_on_members_number=limit_on_members_number,
        comments=comments)

    if project is None:
        chain = new_chain()
        application.chain_id = chain.chain
        application.save()
        Project.objects.create(id=chain.chain, application=application)
    else:
        application.chain = project
        application.save()
        if project.application.state != ProjectApplication.APPROVED:
            project.application = application
            project.save()

        pending = ProjectApplication.objects.filter(
            chain=project,
            state=ProjectApplication.PENDING).exclude(id=application.id)
        for app in pending:
            app.state = ProjectApplication.REPLACED
            app.save()

    if policies is not None:
        set_resource_policies(application, policies)
    logger.info("User %s submitted %s." %
                (request_user.log_display, application.log_display))
    application_submit_notify(application)
    return application
コード例 #4
0
def submit_application(owner=None,
                       name=None,
                       precursor_id=None,
                       homepage=None,
                       description=None,
                       start_date=None,
                       end_date=None,
                       member_join_policy=None,
                       member_leave_policy=None,
                       limit_on_members_number=None,
                       comments=None,
                       resource_policies=None,
                       request_user=None):

    precursor = None
    if precursor_id is not None:
        get_chain_of_application_for_update(precursor_id)
        precursor = ProjectApplication.objects.get(id=precursor_id)

        if (request_user and (not precursor.owner == request_user
                              and not request_user.is_superuser
                              and not request_user.is_project_admin())):
            m = _(astakos_messages.NOT_ALLOWED)
            raise PermissionDenied(m)

    force = request_user.is_project_admin()
    ok, limit = qh_add_pending_app(owner, precursor, force)
    if not ok:
        m = _(astakos_messages.REACHED_PENDING_APPLICATION_LIMIT) % limit
        raise PermissionDenied(m)

    application = ProjectApplication(
        applicant=request_user,
        owner=owner,
        name=name,
        precursor_application_id=precursor_id,
        homepage=homepage,
        description=description,
        start_date=start_date,
        end_date=end_date,
        member_join_policy=member_join_policy,
        member_leave_policy=member_leave_policy,
        limit_on_members_number=limit_on_members_number,
        comments=comments)

    if precursor is None:
        application.chain = new_chain()
    else:
        chain = precursor.chain
        application.chain = chain
        objs = ProjectApplication.objects
        pending = objs.filter(chain=chain, state=ProjectApplication.PENDING)
        for app in pending:
            app.state = ProjectApplication.REPLACED
            app.save()

    application.save()
    if resource_policies is not None:
        application.set_resource_policies(resource_policies)
    logger.info("User %s submitted %s." %
                (request_user.log_display, application.log_display))
    application_submit_notify(application)
    return application