Allow to assign more than one role in a project.
See original GitHub issueWhen I given a user two role(project_admin and annotator), I got a error with:
backend_1 | File "/app/api/serializers.py", line 98, in get_current_users_role
backend_1 | queryset, project=instance.id, user=self.context.get("request").user.id
backend_1 | File "/usr/local/lib/python3.6/site-packages/django/shortcuts.py", line 93, in get_object_or_404
backend_1 | return queryset.get(*args, **kwargs)
backend_1 | File "/usr/local/lib/python3.6/site-packages/django/db/models/query.py", line 403, in get
backend_1 | (self.model._meta.object_name, num)
backend_1 | api.models.RoleMapping.MultipleObjectsReturned: get() returned more than one RoleMapping -- it returned 2!
There may more than one role of users_role
, so it should replace get_object_or_404
with filter
:
https://github.com/doccano/doccano/blob/v1.0.2/app/api/serializers.py#L98
queryset = RoleMapping.objects.values("role_id__name")
if queryset:
users_role = get_object_or_404(
queryset, project=instance.id, user=self.context.get("request").user.id
)
for key, val in role_abstractor.items():
role_abstractor[key] = users_role["role_id__name"] == val
return role_abstractor
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Assign people to work on tasks - Microsoft Support
Assign people to work on tasks · In the Gantt Chart, go to the Resource Names column. · Click the arrow and pick...
Read more >Assigning more than one role to a task - PPM User Discussions
Hello; We want to assign more than one role to a task. That is, Assigned role in work plan for a task should...
Read more >Assigning Multiple Roles To A Resource In Primavera P6
The answer to our students question is, yes, in Primavera P6 multiple roles can be assigned to a single resource. A resource therefore...
Read more >Assign a Project Team Member to multiple roles
I am trying to figure out a way to assign a Project Team Member to multiple roles for different set of tasks that...
Read more >Multiple projects and roles - Auth0 Community
You can use role-based access control, which will allow you to assign roles to your users and grant them permissions based on those...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there an update on this? It seemed like consensus was reached to mark this as a bug instead of a feature, correct? It should not be allowed to add a user to more than one role.
It seems like any user who is currently assigned to a role for a given project already should not show up in the dropdown (or be validated against if selected) for new project member roles.
@mymusise Yes, that’s correct. Each user/project/role pair should be unique. If this is not currently being enforced, I suspect it’s a bug with the v1 UI.
@kuraga That sounds like a bug in the validation logic in RoleMapping. The error for that situation should be a 400.