Skip to content

Bugfix no project selected on join crash#168

Merged
kbeker merged 3 commits intomasterfrom
bugfix-no-project-selected-on-join-crash
May 7, 2019
Merged

Bugfix no project selected on join crash#168
kbeker merged 3 commits intomasterfrom
bugfix-no-project-selected-on-join-crash

Conversation

@maciejSamerdak
Copy link
Collaborator

Resolves #141

Done:

  • If there are no projects available for joining, the form with project selection visible in popup is replaced with appropriate message, preventing user from submitting an empty form resulting in app crash

@maciejSamerdak maciejSamerdak added the bug Something isn't working label Apr 30, 2019
@maciejSamerdak maciejSamerdak added this to the tag 0.2.0 milestone Apr 30, 2019
@maciejSamerdak maciejSamerdak self-assigned this Apr 30, 2019

def _create_project_join_form(self) -> ProjectJoinForm:
project_form_queryset = Project.objects.exclude(members__id=self.request.user.id).order_by("name")
if not project_form_queryset:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not project_form_queryset.exists()

@rwrzesien
Copy link
Contributor

This solution seems OK, what I would just do is separate the message display logic from form creation - form still could be created with empty queryset (instead of returning None), but not displayed depending on different variable passed to template. This way we avoid tightly coupling those two elements.

I would also add some validation to the form itself, in case if someone tries to still manually call POST on this view, that checks if queryset is empty and then raise ValidationError. This way we will secure it in both frontend (message) and backend (validation).

@kbeker kbeker force-pushed the bugfix-no-project-selected-on-join-crash branch from 40b0ed4 to 2c77800 Compare May 6, 2019 16:59
@maciejSamerdak
Copy link
Collaborator Author

I introduced fixes that change the current implementation to one that's closer to what @rwrzesien suggested.

When there are no projects the user can join to, the form in join popup
is replaced with appropriate message.
@kbeker kbeker force-pushed the bugfix-no-project-selected-on-join-crash branch from 25aed35 to 4f4298b Compare May 7, 2019 14:26
@kbeker kbeker merged commit 4f4298b into master May 7, 2019
@kbeker kbeker deleted the bugfix-no-project-selected-on-join-crash branch May 7, 2019 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

If no project is selected on project join popup during report creation, the application crashes.

3 participants