question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow to assign more than one role in a project.

See original GitHub issue

When 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:open
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ljadescommented, Dec 4, 2020

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.

1reaction
c-wcommented, Feb 4, 2020

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found