[Permissions] Only superusers can assign a framework agreement to a job
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- django, python
- Domain
- authorization, backend
Research direction
Start with chaotica_utils/enums.py and inspect UnitRoles.PERMISSIONS for the Sales and Manager roles; then read jobtracker/views/job.py around assign_job_framework and the permission helper's global-permission setting. Confirm the role permission works for a unit member, and check the job widget's pencil visibility. Done when authorized unit roles can assign a framework and users without permission no longer see the pencil.
Written by the indexing model from the issue text.
Description
Summary
assign_job_framework (jobtracker/views/job.py) is protected by:
@job_permission_required_or_403("jobtracker.can_manage_framework_job", (Job, "slug", "slug"))
job_permission_required_or_403 defaults to accept_global_perms=False, so the check passes only on an object permission on the job, or on the permission held through the job's organisational unit. In practice nobody but a superuser has either:
-
The Sales Manager and Sales Member site roles include
jobtracker.can_manage_framework_job(chaotica_utils/enums.py), but as a global permission, which this view ignores. -
No unit role grants it. The Sales and Manager unit roles have the line commented out, and it uses a codename that doesn't exist:
# "jobtracker.can_manage_frameworkagreement_job", -
The pencil on the job's "Associated Framework" card is shown to everyone who can view the job, so everyone else clicks it and gets a 403.
Verified by reproducing it: a unit member with the Sales unit role fails user_has_unit_perms(user, "jobtracker.can_manage_framework_job", unit).
Impact
Sales and delivery staff can't link jobs to framework agreements, so framework days used, scheduled and remaining stay at zero, and the closed-framework and over-allocation checks never apply. Only superusers can do it, which defeats the role model.
Suggested fix
- In
UnitRoles.PERMISSIONS, replace the commented-out lines in the Sales and Manager unit roles with"jobtracker.can_manage_framework_job". - Optionally, pass
accept_global_perms=Trueonassign_job_framework, so the site roles that already list the permission work as intended. - Hide the pencil unless
user_has_unit_perms(...)passes, as other job widgets do.
Workaround
Create a custom unit role with only this permission. Custom role names are left alone by the daily task_sync_role_permissions_to_default. Then give that role to the relevant members of each unit:
from django.contrib.auth.models import Permission
from jobtracker.models import OrganisationalUnitRole
role, _ = OrganisationalUnitRole.objects.get_or_create(name="Framework Manager")
role.permissions.add(Permission.objects.get(codename="can_manage_framework_job"))
Granting the permission directly to a user on the unit doesn't last: OrganisationalUnit.sync_permissions() removes any per-user unit permission that the user's roles don't grant. Adding it to the built-in Sales role doesn't last either, because the daily sync resets known roles to their defaults.
- Dominant language
- HTML
- Stars
- 6
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from brainthee/CHAOTICA
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 86/100
-
[Minor UI Bug] Client page shows account manager photos as squares overlapping the round borderOpen
Difficulty 1/5 Under an hour Newbie friendliness 94/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
All issues in brainthee/CHAOTICA
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
LightningEg/Lightning#588 ·
Maintainers usually reply within 1 day
-
ssh
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
contour-terminal/contour#2306 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
bug frontend
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
blocklist addition
Difficulty 1/5 Under an hour Newbie friendliness 73/100
MetaMask/eth-phishing-detect#311666 ·
Maintainers usually reply within 1 day