Skip to content

Bugfix add auto assigning manager if he create project#390

Merged
kbeker merged 1 commit intomasterfrom
bugfix-assign-manager-to-project-which-he-create
Jul 8, 2019
Merged

Bugfix add auto assigning manager if he create project#390
kbeker merged 1 commit intomasterfrom
bugfix-assign-manager-to-project-which-he-create

Conversation

@kbeker
Copy link
Contributor

@kbeker kbeker commented Jul 5, 2019

Resolves #118

@kbeker kbeker added the bug Something isn't working label Jul 5, 2019
@kbeker kbeker added this to the next_release milestone Jul 5, 2019
@kbeker kbeker self-assigned this Jul 5, 2019
@MartynaAnnaGottschling MartynaAnnaGottschling self-requested a review July 5, 2019 10:57
@kbeker kbeker changed the title Add auto assigning manager if he create project Bugfix add auto assigning manager if he create project Jul 5, 2019
Copy link
Collaborator

@maciejSamerdak maciejSamerdak left a comment

Choose a reason for hiding this comment

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

It does it's job alright.
But if not for now, I believe the change in form should ultimately see the daylight. If the user becomes a manager whether he selects himself on list or not, then there's absolutely no reason for him to be on the list at all.


def form_valid(self, form: ProjectAdminForm) -> HttpRequest:
if self.request.user not in form.cleaned_data["managers"]:
assert not self.request.user.is_employee
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems overly cautious to me, since AFAIK we already successfully restrict access for unauthorised personel.
But, you know, personally I don't mind it much, really. 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I gave assert here only for safety-check purposes. It already gave me feed back when I set there assert self.request.user.is_manager and I completely forgot about ADMIN role. So it might be helpful :)

class ManagerSelectMultiple(SelectMultiple):
def optgroups(self, name: str, value: List, attrs: Optional[Dict] = None) -> List:
self.choices.queryset = CustomUser.objects.exclude(user_type=CustomUser.UserType.EMPLOYEE.name)
return super().optgroups(name, value, attrs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since the user is assigned either way, the user should be excluded from the field and the field should be marked as optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@kbeker kbeker force-pushed the bugfix-assign-manager-to-project-which-he-create branch from 76f4c9c to 91ec78b Compare July 5, 2019 11:56
@kbeker kbeker force-pushed the bugfix-assign-manager-to-project-which-he-create branch from cb6e2fc to 3de7b06 Compare July 8, 2019 07:01
@kbeker kbeker merged commit 3de7b06 into master Jul 8, 2019
@kbeker kbeker deleted the bugfix-assign-manager-to-project-which-he-create branch July 8, 2019 07:03
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.

As a manager, when I create a project and don't assign myself to it, I can't edit it.

4 participants