def build_relations(self, props, override_tags):
     """Create all relations on the artifact object as described in props."""
     self._set_full_tags(props, override_tags)
     if props.get("team_id") is not None:
         self._connect_relation(self.neo.team, Team.find(props["team_id"]))
     if props.get("user_id") is not None:
         self._connect_relation(self.neo.user, User.find(props["user_id"]))
Example #2
0
 def build_team(cls, name="test", members=[], traits=[]):
     team = Team(name=name).save()
     if "with_members" in traits:
         cls._add_members_to_team(team, 2)
     for member in members:
         team.members.connect(member)
     return team
 def post(self, **params):
     """Logic for creating a team"""
     team = Team(**params).save()
     user = User.find_by(id_=get_jwt_identity())
     team.members.connect(user)  # pylint:disable=no-member
     _notify_of_team_creation(team)
     return team
 def get(self, **params):
     """get a single team"""
     try:
         team = Team.find_by(id_=params["id"])
         return team
     except Team.DoesNotExist:  # pylint:disable=no-member
         return abort(404, "team not found")
 def put(self, **params):
     """Logic for updating a team"""
     try:
         team = Team.find_by(id_=params.pop("id"))
         team.update(**params)
         return team
     except Team.DoesNotExist:  # pylint:disable=no-member
         return abort(404, "team not found")
Example #6
0
def _find_multiple_by(params):
    team = Team.find_by(id_=params.get("team_id"), force=False)
    if team is None:
        artifacts = Artifact.nodes
    else:
        artifacts = team.artifacts
    _from = params.get("offset", 0)
    _to = params.get("limit", 10) + _from
    return artifacts.order_by("created_at")[_from:_to]
 def suggested_tags(self, **params):
     """Takes an array of tags and suggests tags based on that"""
     current_tags = params["tags"]
     team = Team.find(params["team_id"])
     current_tags = [tag for tag in current_tags if tag != ""]
     return {
         "tags": tag_suggestions.find_tags(team, params["limit"],
                                           current_tags)
     }
Example #8
0
    def post(self, **params):
        """Logic for adding a single team member"""
        user = User.find_by(id_=get_jwt_identity())
        team = Team.find_by(join_key=params["join_key"], force=False)

        if not team:
            return abort(404, "this invite link is not valid")
        if user in team.members:
            return abort(409, "user already in team")

        team.members.connect(user)
        return team