Models¶

User¶

Data model to represent an individual user.

class app.model.user.User(slack_id)¶

Represent a user with related fields and methods.

__init__(slack_id)¶

Initialize the user with a given Slack ID.

classmethod from_dict(d)¶

Convert dict response object to user model.

Parameters:d (Dict[str, Any]) – the dictionary representing a user
Return type:~T
Returns:returns converted user model.
get_attachment()¶

Return slack-formatted attachment (dictionary) for user.

Return type:Dict[str, Any]
classmethod is_valid(user)¶

Return true if this user has no missing required fields.

Required fields for database to accept:
  • slack_id
  • permissions_level
Parameters:user (~T) – user to check
Return type:bool
Returns:return true if this user has no missing required fields
classmethod to_dict(user)¶

Convert user object to dict object.

The difference with the in-built self.__dict__ is that this is more compatible with storing into NoSQL databases like DynamoDB.

Parameters:user (~T) – the user object
Return type:Dict[str, Any]
Returns:the dictionary representing the user

Team¶

Represent a data model for a team.

class app.model.team.Team(github_team_id, github_team_name, display_name)¶

Represent a team with related fields and methods.

__init__(github_team_id, github_team_name, display_name)¶

Initialize the team.

Parameters are a valid Github team ID, team name and display name.

add_member(github_user_id)¶

Add a new member’s Github ID to the team’s set of members’ IDs.

add_team_lead(github_user_id)¶

Add a user’s Github ID to the team’s set of team lead IDs.

discard_member(github_user_id)¶

Discard the member of the team with Github ID in the argument.

discard_team_lead(github_user_id)¶

Remove a user’s Github ID to the team’s set of team lead IDs.

classmethod from_dict(d)¶

Convert dict response object to team model.

Parameters:d (Dict[str, Any]) – the dictionary representing a team
Return type:~T
Returns:returns converted team model.
get_attachment()¶

Return slack-formatted attachment (dictionary) for team.

get_basic_attachment()¶

Return basic slack-formatted attachment (dictionary) for team.

has_member(github_user_id)¶

Identify if any member has the ID specified in the argument.

Return type:bool
has_team_lead(github_user_id)¶

Identify if user with given ID is a team lead.

Return type:bool
is_team_lead(github_user_id)¶

Identify if user with given ID is a team lead.

Return type:bool
classmethod is_valid(team)¶

Return true if this team has no missing required fields.

Required fields for database to accept:
  • github_team_name
  • github_team_id
Parameters:team (~T) – team to check
Return type:bool
Returns:returns true if this team has no missing required fields
classmethod to_dict(team)¶

Convert team object to dict object.

The difference with the in-built self.__dict__ is that this is more compatible with storing into NoSQL databases like DynamoDB.

Parameters:team (~T) – the team object
Return type:Dict[str, Any]
Returns:the dictionary representing the team

Project¶

Represent a team project.

class app.model.project.Project(github_team_id, github_urls)¶

Represent a team project with team ID and related fields and methods.

__init__(github_team_id, github_urls)¶

Initialize the team project.

Project ID is a UUID generated by uuid.uuid4().

Parameters:
  • github_team_id (str) – the Github team ID associated with the project
  • github_urls (List[str]) – a set/list of URLs pointing to repositories
classmethod from_dict(d)¶

Return a project from a dict object.

Parameters:d (Dict[str, Any]) – the dictionary (usually from DynamoDB)
Return type:~T
Returns:a Project object
get_attachment()¶

Return slack-formatted attachment (dictionary) for project.

Return type:Dict[str, Any]
classmethod is_valid(p)¶

Return true if this project has no missing fields.

Required fields for database to accept:
  • __project_id
  • __github_urls
Parameters:project – project to check
Return type:bool
Returns:true if this project has no missing fields
classmethod to_dict(p)¶

Return a dict object representing a project.

The difference with the in-built self.__dict__ is that this is more compatible with storing into NoSQL databases like DynamoDB.

Parameters:p (~T) – the Project object
Return type:Dict[str, Any]
Returns:a dictionary representing a project

Permissions¶

Data model to represent permissions.

class app.model.permissions.Permissions¶

Enum to represent possible permissions levels.