How to use the ramp-database.ramp_database.tools._query.select_team_by_name function in ramp-database

To help you get started, we’ve selected a few ramp-database examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github paris-saclay-cds / ramp-board / ramp-database / ramp_database / tools / user.py View on Github external
github_url=github_url, website_url=website_url, bio=bio,
                is_want_news=is_want_news)

    # Creating default team with the same name as the user
    # user is admin of his/her own team
    team = Team(name=name, admin=user)
    session.add(team)
    session.add(user)
    try:
        session.commit()
    except IntegrityError as e:
        session.rollback()
        message = ''
        if select_user_by_name(session, name) is not None:
            message += 'username is already in use'
        elif select_team_by_name(session, name) is not None:
            # We only check for team names if username is not in db
            message += 'username is already in use as a team name'
        if select_user_by_email(session, lower_case_email) is not None:
            if message:
                message += ' and '
            message += 'email is already in use'
        if message:
            raise NameClashError(message)
        else:
            raise e
    logger.info('Creating {}'.format(user))
    logger.info('Creating {}'.format(team))
    return user
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / tools / team.py View on Github external
event_name : str
        The RAMP event name.
    team_name : str
        The name of the team.

    Returns
    -------
    event : :class:`ramp_database.model.Event`
        The queried Event.
    team : :class:`ramp_database.model.Team`
        The queried team.
    event_team : :class:`ramp_database.model.EventTeam`
        The relationship event-team table.
    """
    event = select_event_by_name(session, event_name)
    team = select_team_by_name(session, team_name)
    event_team = select_event_team_by_name(session, event_name, team_name)
    if event_team is None:
        event_team = EventTeam(event=event, team=team)
        session.add(event_team)
        session.commit()
    return event, team, event_team
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / tools / user.py View on Github external
"""Get a team by its name.

    Parameters
    ----------
    session : :class:`sqlalchemy.orm.Session`
        The session to directly perform the operation on the database.
    name : str or None
        The name of the team. If None, all teams will be queried.

    Returns
    -------
    team : :class:`ramp_database.model.Team` or list of \
:class:`ramp_database.model.Team`
        The queried team.
    """
    return select_team_by_name(session, name)
github paris-saclay-cds / ramp-board / ramp-database / ramp_database / tools / submission.py View on Github external
team_name : str
        The team associated to the submission.
    submission_name : str
        The name to give to the current submission.
    submission_path : str
        The path of the files associated to the current submission. It will
        corresponds to the key `ramp_kit_subissions_dir` of the dictionary
        created with :func:`ramp_utils.generate_ramp_config`.

    Returns
    -------
    submission : :class:`ramp_database.model.Submission`
        The newly created submission.
    """
    event = select_event_by_name(session, event_name)
    team = select_team_by_name(session, team_name)
    event_team = select_event_team_by_name(session, event_name, team_name)
    submission = (session.query(Submission)
                         .filter(Submission.name == submission_name)
                         .filter(Submission.event_team == event_team)
                         .one_or_none())

    # create a new submission
    if submission is None:
        all_submissions = (session.query(Submission)
                                  .filter(Submission.event_team == event_team)
                                  .order_by(Submission.submission_timestamp)
                                  .all())
        last_submission = None if not all_submissions else all_submissions[-1]
        # check for non-admin user if they wait enough to make a new submission
        if (team.admin.access_level != 'admin' and last_submission is not None
                and last_submission.is_not_sandbox):