Models¶
User¶
-
class
app.model.
User
(slack_id)¶ Represent a user with related fields and methods.
- Parameters
slack_id (
str
) –
-
__init__
(slack_id)¶ Initialize the user with a given Slack ID.
- Parameters
slack_id (
str
) –
-
classmethod
from_dict
(d)¶ Convert dict response object to user model.
- Parameters
d (
typing.Dict
[str
,typing.Any
]) – the dictionary representing a usercls (
typing.Type
[~T]) –
- Return type
~T
- Returns
the converted user model.
-
get_attachment
()¶ Return slack-formatted attachment (dictionary) for user.
- Return type
typing.Dict
[str
,typing.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
cls (
typing.Type
[~T]) –
- Return type
bool
- Returns
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
cls (
typing.Type
[~T]) –
- Return type
typing.Dict
[str
,typing.Any
]- Returns
the dictionary representing the user
Team¶
-
class
app.model.
Team
(github_team_id, github_team_name, displayname)¶ Represent a team with related fields and methods.
- Parameters
github_team_id (
str
) –github_team_name (
str
) –displayname (
str
) –
-
__init__
(github_team_id, github_team_name, displayname)¶ Initialize the team.
Parameters are a valid Github team ID, team name and display name.
- Parameters
github_team_id (
str
) –github_team_name (
str
) –displayname (
str
) –
-
add_member
(github_user_id)¶ Add a new member’s Github ID to the team’s set of members’ IDs.
- Parameters
github_user_id (
str
) –
-
add_team_lead
(github_user_id)¶ Add a user’s Github ID to the team’s set of team lead IDs.
- Parameters
github_user_id (
str
) –
-
discard_member
(github_user_id)¶ Discard the member of the team with Github ID in the argument.
- Parameters
github_user_id (
str
) –
-
discard_team_lead
(github_user_id)¶ Remove a user’s Github ID to the team’s set of team lead IDs.
- Parameters
github_user_id (
str
) –
-
classmethod
from_dict
(d)¶ Convert dict response object to team model.
- Parameters
d (
typing.Dict
[str
,typing.Any
]) – the dictionary representing a teamcls (
typing.Type
[~T]) –
- Return type
~T
- Returns
the 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.
- Parameters
github_user_id (
str
) –- Return type
bool
-
has_team_lead
(github_user_id)¶ Identify if user with given ID is a team lead.
- Parameters
github_user_id (
str
) –- Return type
bool
-
is_team_lead
(github_user_id)¶ Identify if user with given ID is a team lead.
- Parameters
github_user_id (
str
) –- 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
cls (
typing.Type
[~T]) –
- Return type
bool
- 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
cls (
typing.Type
[~T]) –
- Return type
typing.Dict
[str
,typing.Any
]- Returns
the dictionary representing the team