Skip to content

Services

ESalomons edited this page Jul 8, 2021 · 1 revision

User service

Manages user entity.

Properties:

  • user_collection: Collection
  • mail_service: MailService
  • psw_salt
get_user_info_by_id
Parameters _id: string, not null
Returns User
Description Retrieves user object of specified user-id
get_user_by_id
Parameters _id: string, not null
Returns dict
Description Retrieves user dictionary based on the id (includes password hash)
get_user_by_email
Parameters email: string, not null
Returns dict
Description Retrieves user dictionary based on the email (includes password hash)
get_trainers_of_club
Parameters club_id: string, not null
Returns User []
Description Retrieves all trainers of the club.
get_admins_of_club
Parameters club_id: string, not null
Returns User []
Description Retrieves all club administrators of the club.
add_club_to_user
Parameters user_id: string, not nullclub_id: string, not null
Returns -
Description Adds club_id to the user entry in the database.
add_team_to_user
Parameters user_id: string, not nullteam_id: string, not null
Returns -
Description Adds team_id to the user's team list
remove_team_from_user
Parameters user_id: string, not nullteam_id: string, not null
Returns -
Description Removes team id from user's team list.
create_user
Parameters user: User, not null
Returns string
Description Creates a new user in the database and sends an email to the user with its password
edit_user
Parameters user: Userpassword: string
Returns -
Description Updates user information based on the provided user object and/or updates password if it is provided.
delete_user
Parameters user_id: string, not null
Returns -
Description Deletes user from the system based on the provided id
delete_common_users_with_club_id
Parameters club_id: string, not null
Returns -
Description Deletes all users that have provided club_id in their club_ids list but do not have a system administrator role.
remove_club_from_users
Parameters club_id: string, not null
Returns -
Description Removes club_id from all users
remove_team_from_users
Parameters team_id: string, not null
Returns -
Description Removes team_id from all users
reset_user_password
Parameters user_id: string, not null
Returns -
Description Resets password of the user with the provided id and sends an email to it with the new generated password

Club service

Manages club entity.

Properties

  • club_collection: Collection
  • base_database_url: string
  • user_service: UserService
  • connection_service: ConnectionService
add
Parameters club: Club, not null
Returns New id of the club (String)
Description Creates a new club in the system, creates a new database connection, and updates a system administrator user with the new id of the club.
delete
Parameters club_id: string, not null
Returns -
Description Deletes club from the system deletes all users that were associated with the club, removes club id entry from the administrator user, updates connection map.
edit
Parameters club: Club, not null
Returns -
Description Updates a user with new provided values.
get_one
Parameters club_id: string, not null
Returns Club
Description Finds single club based on the provided id
get_all
Parameters -
Returns Club []
Description Returns all clubs of the system.

Team service

Responsible for managing team entities.

Parameters:

  • connection_service: ConnectionService
  • user_service: UserService
add
Parameters team: Team, not null
Returns New id of the team (String)
Description Creates a new team in the club database and adds the team to the current user's team_ids list.
delete
Parameters team_id: string, not null
Returns -
Description Deletes club from club database. Requires that the team has no players left associated. Also deleted reference of the team from all other users.
edit
Parameters team: Team, not null
Returns -
Description Updates a team with new provided values.
get_all
Parameters -
Returns Team []
Description Returns all teams of the system.
get_team_by_id
Parameters team_id: string, not null
Returns Team
Description Returns team if it is found in the club's database based on the provided team_id
connect_trainer
Parameters trainer_id: string, not nullteam_id: string, not null
Returns -
Description Connects a specified trainer to the specified team in the club's database.
disconnect_trainer
Parameters trainer_id: string, not nullteam_id: string, not null
Returns -
Description Disconnects a specified trainer from the specified team in the club's database.
delete_trainer
Parameters trainer_id: string, not null
Returns -
Description Deletes trainer from the club.
add_player
Parameters team_id: string, not nullplayer_id: string, not null
Returns -
Description Adds a player to the specified team in the club's database.

Player service

Responsible for managing player entities.

Parameters:

  • connection_service: ConnectionService
  • team_service: TeamService
add
Parameters player: Player, not null
Returns New id of the player(String)
Description Creates new player in the club's database
delete
Parameters player_id: string, not null
Returns -
Description Deletes player from the club's database
edit
Parameters player: Player, not null
Returns -
Description Updates a player with new provided values.
get_all
Parameters -
Returns Player[]
Description Returns all players of the club.
get_by_id
Parameters player_id: string, not null
Returns Player
Description Returns player of specified id if found.
get_team_all
Parameters team_id: string, not null
Returns Player []
Description Returns all players of the team
change_team
Parameters old_team_id: string, not nullnew_team_id: string, not nullplayer_id: string, not null
Returns -
Description Changes the player's team. Removes a player from his old team and adds it to the new one

Connection service

Responsible for managing database connections of the different clubs.

Parameters:

  • club_collection: Collection
  • app
get_connection_by_club_id
Parameters club_id: ObjectId, not null
Returns PyMongo
Description Return connection to the database based on the provided club id
update_connection_map
Parameters -
Returns -
Description Stores all available club connections and stores them on the map for easier access.
drop_db
Parameters club_id: ObjectId, not null
Returns -
Description Drops all data from the club database

Mail service

send_mail
Parameters receiver: string, not nullcontent: string, not null
Returns -
Description Send email to the provided email address (receiver)

File upload service

upload_image
Parameters file: File
Returns Optional[str]
Description Uploads an image into the system. Needs to be one of these file extensions: .png, .jpg, .jpeg

Menu service

get_menu_by_role
Parameters role: int, not null
Returns dict []
Description Provides menu items based on the provided role
Clone this wiki locally