samanthasgroup / django-webapps

Backend for the database, implemented in Django
Other
3 stars 0 forks source link

Create read-only API views for ToolJet dashboard (lists and profiles) #30

Closed lemontree210 closed 1 year ago

lemontree210 commented 1 year ago

The tasks can be done step by step in small PRs. Please mention the PRs in the bullet points as you go.

Preliminaries and Implementation details

General overview

Example output for "all students" view (without personal info) ```json [ { "id": 1, "first_name": "Sergey", "last_name": "Borisov", "utc_code": "UTC+3", "availability_slots": [ { "day_of_week": 0, "time_from": "18", "time_to": "19" }, { "day_of_week": 2, "time_from": "18", "time_to": "19" } ], "communication_mode": "RU/UA", "age_range": "18-20", "speaking_club_status": "NOT_GOING", "status": "GROUP_ASSIGNED", "languages_and_levels": [ { "language": "English", "level": "A1" } ] } ] ```
Example output for "all teachers" view (without personal info) ```json [ { "id": 1, "first_name": "Sergey", "last_name": "Vasilyev", "status": "TEACHING_ACCEPTING_MORE", "communication_mode": "RU/EN", "teacher_info": { "utc_code": "UTC+3", "availability_slots": [ { "day_of_week": 0, "time_from": "18", "time_to": "19" }, { "day_of_week": 2, "time_from": "18", "time_to": "19" } ], "student_age_ranges": [ "18-25", "25-34" ], "languages_and_levels": [ { "language": "German", "level": "A2" }, { "language": "English", "level": "A1" } ], "max_number_of_groups": 2, "max_weekly_sessions": 4, "can_lead_speaking_clubs": true, "additional_skills_comment": "can also teach programming", }, "non_teaching_help":{ "can_help_create_cv": true, "can_conduct_mock_interviews": true, "can_provide_employment_help": true, "can_help_develop_career_strategy": true, "can_create_and_evaluate_linkedin_profile": true, "can_edit_cv": false, "can_consult_on_career_switch": false, "can_consult_on_univeristy_application": false, "can_help_translate_documents": false, "can_help_with_creative_industry_portfolio": true, }, //taken from https://miro.com/app/board/uXjVOnwo92I=/?moveToWidget=3458764546201695041&cot=14 (finalized list) "peer_teacher_help":{ "can_check_syllabus": true, "can_host_monitoring_sessions": false, "can_give_feedback": true, "can_help_with_childrens_groups": true, "can_provide_materials": true, "can_invite_to_class": true, "can_work_in_tandem": true } } ] ```
Example output for "all groups" view ```json [ { "id": 1, "communication_mode": "RU/UA", "schedule": [ { "day_of_week": 0, "time_from": "18", "time_to": "19" }, { "day_of_week": 2, "time_from": "18", "time_to": "19" } ], "language_and_level": { "language": "English", "level": "A1" }, "lesson_duration": 60, "status": "WORKING", "start_date": "23/03/2023", "tg_chat_url": "https://t.me/somechat", "coordinators": [ { "id": 1, "name": "Ivan Ivanov" }, { "id": 2, "name": "Sergey Sergeev" } ], "teachers": [ { "id": 1, "name": "Maria Petrova" }, { "id": 2, "name": "Pavel Nikolaev" } ], "student_count": 5, "is_staff_only": false } ] ```

Personal overview (for this given coordinator only)

General question: how to let Django know what to return from the database.

We have to think about the authentication of the coordinator. We may have to add a column in Coordinator with either a ToolJet username or some sort of token, depending on what variables are available in ToolJet and/or what is safer.

Profiles

Please note that profiles must include LogEvents (maybe not all of them, but at least last 5-10) with this person.

Without personal info: any coordinator can see these profiles

Example output ```json { "id": 1, "first_name": "Jesse", "last_name": "Mccormick", "comment": "some comment", "utc_timedelta": "UTC-03:00", "member_since": "2023-01-14", "availability_slots": { "monday": [ { "from_utc_hour": "14:00:00", "to_utc_hour": "15:00:00" } ], "tuesday": [], "wednesday": [], "thursday": [], "friday": [], "saturday": [], "sunday": [] }, "communication_language_mode": "ru_ua", "age_range": "5-6", "status": "not_attending", "is_member_of_speaking_club": true, "teaching_languages_and_levels": [ { "language": "Polish", "level": "A1" }, { "language": "Czech", "level": "C1" } ], "non_teaching_help_required": { "help_create_cv": true, "conduct_mock_interviews": true, "provide_employment_help": true, "help_develop_career_strategy": true, "create_and_evaluate_linkedin_profile": true, "edit_cv": false, "consult_on_career_switch": false, "consult_on_univeristy_application": false, "help_translate_documents": false, "help_with_creative_industry_portfolio": true } } ```
Example output ```json { "id": 41, "first_name": "Gabrielle", "last_name": "Frank", "status": "finished_stays", "communication_language_mode": "ru_ua", "utc_timedelta": "UTC-03:30", "is_adult": true, "member_since": "2022-06-15", "availability_slots": { "monday": [ { "from_utc_hour": "10:00:00", "to_utc_hour": "11:00:00" } ], "tuesday": [], "wednesday": [], "thursday": [ { "from_utc_hour": "12:00:00", "to_utc_hour": "14:00:00" } ], "friday": [], "saturday": [], "sunday": [] }, "student_age_ranges": [ "66-95" ], "teaching_languages_and_levels": [ { "language": "English", "level": "A1" } ], "simultaneous_groups": 2, "weekly_frequency_per_group": 2, "can_host_speaking_club": true, "non_teaching_help_provided_comment": "", "non_teaching_help_provided": { "cv_write_edit": true, "cv_proofread": true, "mock_interview": true, "job_search": false, "career_strategy": true, "linkedin": true, "career_switch": true, "portfolio": false, "uni_abroad": false, "translate_docs": false }, "peer_support": { "can_check_syllabus": false, "can_host_mentoring_sessions": true, "can_give_feedback": true, "can_help_with_childrens_groups": false, "can_provide_materials": true, "can_invite_to_class": true, "can_work_in_tandem": true } } ```
Example output ```json { "id": 22, "communication_language_mode": "l2_only", "schedule": { "monday": null, "tuesday": null, "wednesday": null, "thursday": "08:58:12", "friday": null, "saturday": null, "sunday": "08:07:09" }, "language_and_level": { "language": "English", "level": "C1" }, "lesson_duration_in_minutes": 30, "status": "pending", "start_date": "2023-04-20", "end_date": "2023-06-07", "telegram_chat_url": "http://ortega-villanueva.biz/", "coordinators": [ { "id": 221, "full_name": "Bradley Lawrence" }, { "id": 222, "full_name": "Lawrence Wilson" } ], "teachers": [ { "id": 227, "full_name": "Diana Webb" }, { "id": 228, "full_name": "Tim Harrison" } ], "students": [ { "id": 12, "full_name": "Josh Smith" }, { "id": 13, "full_name": "Patrick White" } ], "students_count": 4, "is_for_staff_only": true } ```

With personal info: dashboard sends coordinator's login (=email) to backend and gets profiles of their students and teachers with personal info

lemontree210 commented 1 year ago

Example output for "all teachers" view (without personal info)

@ivanBarinsky Please look at the "additional skills" section in your example. In there, you have 3 things mixed together:

  1. Hosting of speaking clubs that is now a separate boolean field
  2. Types of "non-teaching" help that teachers can provide to students
  3. Peer help that teachers can provide to other teachers

We do, however, have an additional_skills_comment where the teacher can describe what other skills they have (in free text).

Please consult the models once again :)

lemontree210 commented 1 year ago

Example output for "all groups" view

@ivanBarinsky we don't need to show availability_slots for the group in the dashboard, but we do need to show its schedule (exact days and times).

dont-text-me commented 1 year ago

Example output for "all groups" view

@ivanBarinsky we don't need to show availability_slots for the group in the dashboard, but we do need to show its schedule (exact days and times).

ah, my bad, i remember having a similar conversation in miro 🤦 the field in the example output was meant to be the schedule, will update the name 👌 (renamed availability_slots to schedule in the all groups view)

dont-text-me commented 1 year ago

Example output for "all teachers" view (without personal info)

@ivanBarinsky Please look at the "additional skills" section in your example. In there, you have 3 things mixed together:

  1. Hosting of speaking clubs that is now a separate boolean field
  2. Types of "non-teaching" help that teachers can provide to students
  3. Peer help that teachers can provide to other teachers

We do, however, have an additional_skills_comment where the teacher can describe what other skills they have (in free text).

Please consult the models once again :)

  1. Thanks for noticing, will move that under teacher_info re. 2 and 3, it sounds like it would make more sense to keep them separated too, in the UI as well. i'll change the schema to break up the additional_skills field into non_teaching_help and peer_teacher_help . Will also update the UI to have 2 different components to edit the different fields.
lemontree210 commented 1 year ago

Moving API views for actions into separate issue