Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix practice_add_new_report] Add a condition to check if the practice supervisor is selected. #111

Merged

Conversation

true-real-michael
Copy link
Contributor

@true-real-michael true-real-michael commented Mar 2, 2024

Description

If a new report is added while the practice supervisor is not selected, the application crashes with 500: Internal Server Error.

This PR fixes this error and suggests the user to select the supervisor via a flash error message.

Steps to reproduce the bug

  1. Go to https://se.math.spbu.ru/practice or a locally hosted alternative
  2. Add a new practice via the button "Новая работа".
  3. Do NOT select a supervisor (note that the service allows to create a new practice without a name and without supervisor selected).
  4. In the created practice go to "Отчётность".
  5. Add a new report

Context

This line tries to find a supervisor but fails because current_thesis.supervisor_id is None

Staff.query.filter_by(id=current_thesis.supervisor_id).first().user_id

Screenshot 2024-03-02 at 13 49 21

Suggested solution

A condition is added to check if the supervisor is selected. In case if the supervisor is not selected flash an error message which suggests to select the supervisor.

Alternative solution

Prohibit to create a new practice unless a supervisor is selected.

A new condition is added to check if the thesis supervisor is selected.
iakov
iakov previously approved these changes Mar 6, 2024
@iakov
Copy link
Contributor

iakov commented Mar 6, 2024

Nice PR, thanks. I've fixed formatting, and it is fine to be merged.

@iakov iakov enabled auto-merge March 6, 2024 10:19
@iakov iakov requested a review from foreverjun March 6, 2024 10:21
@iakov iakov added this pull request to the merge queue Mar 6, 2024
Merged via the queue into spbu-se:current with commit 70a9074 Mar 6, 2024
4 checks passed
@true-real-michael true-real-michael deleted the fix-practice-add-new-report branch March 6, 2024 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants