Skip to content

Instantly share code, notes, and snippets.

@mtreacy002
Last active February 19, 2021 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtreacy002/3927fddffc02f1862caa7b8544f04030 to your computer and use it in GitHub Desktop.
Save mtreacy002/3927fddffc02f1862caa7b8544f04030 to your computer and use it in GitHub Desktop.
BIT Mentorship relation flow - user send request to work as mentor/mentee
# for mentorship_relations dummy data
# 2nd scenario.
# user send request to work as program mentor/mentee
# prepare empty tasks_list for mentorship_relation1
tasks_list_1 = TasksListModel()
db.session.add(tasks_list_1)
db.session.commit()
# user1 send request to work on a program as mentor
# here, as a temporary value, organization rep id is used as mentee id
# on MentorshipRelationModel
action_user_id = user1
mentor_user = user1
mentee_user = organization.rep_id
creation_date=1589630400, # Saturday, 16 May 2020 12:00:00 PM UTC+0
end_date=program2.end_date, # Friday, 31 July 2020 9:00:00 AM UTC+0 == program2 end_date
state=MentorshipRelationState.PENDING,
notes="Please take me as a mentor...",
tasks_list=tasks_list_1,
)
mentorship_relation1.start_date = (
program2.start_date
) # Thursday, 21 May 2020 12:00:00 PM UTC+0
db.session.add(mentorship_relation1)
db.session.commit()
# initiate mentorship_relations_extension
mentorship_relations_extension1 = MentorshipRelationExtensionModel(
program_id=program2.id, mentorship_relation_id=mentorship_relation1.id
)
mentorship_relations_extension1.mentor_request_date = (
mentorship_relation1.creation_date
)
db.session.add(mentorship_relations_extension1)
db.session.commit()
# later, organization accepted program request
mentorship_relation1.action_id = organization.rep_id
mentorship_relation1.notes = "ok, will do."
mentorship_relations_extension1.mentor_agreed_date = (
1589803200 # Monday, 18 May 2020 12:00:00 PM UTC+0
)
# update related tables
db.session.add(mentorship_relation1)
db.session.add(mentorship_relations_extension1)
db.session.commit()
# then user2 send request to work on a program as mentee
# in the instance we already have user1 as mentor
# user2 can see this on the program profile page
# here we just need to replace organization rep with user2 as mentee
# but request email will be directed to the organization email
mentorship_relation1.action_id = user2.id
mentorship_relation1.mentee_id = user2.id
mentorship_relation1.notes = "Please take me as a mentee."
mentorship_relations_extension1.mentee_request_date = (
1589803200 # Monday, 18 May 2020 12:00:00 PM UTC+0
)
# update related tables
db.session.add(mentorship_relation1)
db.session.add(mentorship_relations_extension1)
db.session.commit()
# program accepted mentee request
mentorship_relation1.action_id = organization.rep_id
mentorship_relation1.notes = "sure, why not."
mentorship_relations_extension1.mentee_agreed_date = (
1589976000 # Wednesday, 20 May 2020 12:00:00 PM UTC+0
)
# update mentorship_relation state
mentorship_relation1.state = MentorshipRelationState.ACCEPTED
mentorship_relation1.accept_date = (
mentorship_relations_extension1.mentee_agreed_date
)
# now we have user1 and user2 as mentor and mentee of the program
# update program status
program2.status = ProgramStatus.IN_PROGRESS
# update related tables
db.session.add(mentorship_relation1)
db.session.add(mentorship_relations_extension1)
db.session.add(program2)
db.session.commit()
# create list of tasks assigned at the beginning of the program
tasks_list_1_task_a = "this is task a for tasks list 1"
tasks_list_1_task_b = "this is task b for tasks list 1"
tasks_list_1.add_task(
description=tasks_list_1_task_a, created_at=1590062400
) # Thursday, 21 May 2020 12:00:00 PM UTC+0
tasks_list_1.add_task(
description=tasks_list_1_task_b, created_at=1590062400
) # Thursday, 21 May 2020 12:00:00 PM UTC+0
db.session.add(tasks_list_1)
db.session.commit()
# mentor comment on task a
tasks_list_1_task_comment_a = TaskCommentModel(
user_id=user1.id,
task_id=1,
relation_id=1,
comment="Do you need help with the task?",
)
tasks_list_1_task_comment_a.creation_date = (
1590062400 # Thursday, 21 May 2020 12:00:00 PM UTC+0 == tasks a creation date
)
db.session.add(tasks_list_1_task_comment_a)
db.session.commit()
# mentee responded to mentor comment
tasks_list_1_task_comment_a.user_id = user2.id
tasks_list_1_task_comment_a.comment = "Nope. All good"
tasks_list_1_task_comment_a.modification_date = (
1590148800 # Friday, 22 May 2020 12:00:00 PM UTC+0
)
db.session.add(tasks_list_1_task_comment_a)
db.session.commit()
# when the task is completed
tasks_list_1.update_task(
task_id=1,
is_done=True,
completed_at=1590235200, # Saturday, 23 May 2020 12:00:00 PM UTC+0
)
# mentor add comment on task a completion
tasks_list_1_task_comment_a.user_id = user1.id
tasks_list_1_task_comment_a.comment = "Well done!"
tasks_list_1_task_comment_a.modification_date = (
1590235200 # Saturday, 23 May 2020 12:00:00 PM UTC+0
)
db.session.add(tasks_list_1)
db.session.add(tasks_list_1_task_comment_a)
db.session.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment