Skip to content

feat: Author-level access to evaluation metrics (Freshdesk #308)#113

Merged
mpasternak merged 2 commits into
devfrom
fix/freshdesk-308
Apr 20, 2026
Merged

feat: Author-level access to evaluation metrics (Freshdesk #308)#113
mpasternak merged 2 commits into
devfrom
fix/freshdesk-308

Conversation

@mpasternak
Copy link
Copy Markdown
Member

Summary

  • Added two-tier permission system for evaluation metrics: full access (admins/staff) and author-level read-only access (own metrics only)
  • Added BppUser.autor OneToOneField linking user accounts to Autor records, with automatic matching by email
  • Added user profile page ("Mój profil") with navigation link in top bar
  • Restricted admin-only operations (pin/unpin, generation, export, statistics) to full-access users
  • Fixed DJ001 warnings: replaced null=True with default="" on BppUser CharField fields

Changes

  • Model: BppUser.autor OneToOneField + sprobuj_dopasowac_autora() auto-matching
  • Migration: 0411_bppuser_autor_onetoone (adds field + converts NULLs to empty strings)
  • Permissions: ma_pelne_uprawnienia_ewaluacji() / ma_uprawnienia_ewaluacji() in views/mixins.py
  • Views: Access control in list, detail, pin/unpin, generation, export, statistics
  • Templates: UI elements hidden for author-only users (generation box, crop mode, export/stats buttons, pin/unpin controls)
  • New files: profile view, profile template, bulk matching management command, towncrier fragment

Test plan

  • Run uv run python src/manage.py migrate to apply migration 0411
  • Run uv run python src/manage.py dopasuj_autorow_do_uzytkownikow to bulk-match users to authors
  • Log in as admin — verify full access to all evaluation metrics features
  • Log in as a user linked to an author — verify read-only access to own metrics only
  • Verify author-only user cannot access other authors' metrics via URL manipulation
  • Verify pin/unpin, generation, export, statistics return 403 for author-only users
  • Run uv run pytest src/ewaluacja_metryki/ to verify existing tests pass

🤖 Generated with Claude Code

Add two-tier permission system allowing authors linked to user accounts
to view their own evaluation metrics. Full access for admins/staff,
read-only own-data access for linked authors. Includes BppUser.autor
OneToOneField, auto-matching by email, profile page, and UI adjustments.

Also fix DJ001 warnings: replace null=True with default="" on
BppUser CharField fields (multiseek_format, multiseek_order_1, pbn_token).
@mpasternak
Copy link
Copy Markdown
Member Author

@claude rebase

@claude
Copy link
Copy Markdown

claude Bot commented Apr 19, 2026

Claude finished @mpasternak's task in 22s —— View job


I'm unable to perform a git rebase operation due to technical limitations — rebasing requires a force push, which is outside the scope of what I can safely execute as an automated agent.

To rebase this branch onto dev, run:

git fetch origin
git checkout fix/freshdesk-308
git rebase origin/dev
# resolve any conflicts if needed
git push --force-with-lease origin fix/freshdesk-308

You can find more information and potential workarounds in the FAQ.

Resolutions:
- src/bpp/models/profile.py: keep branch's `default=""` (branch has
  backing migration to convert NULL→'' and AlterField, unlike dev's
  noqa-only approach)
- migrations: rename 0411_bppuser_autor_onetoone → 0413 to avoid
  collision with dev's 0411_uczelnia_orcid_fields and
  0412_uczelnia_orcid_staff_only; update dependencies accordingly
@mpasternak mpasternak merged commit 4358510 into dev Apr 20, 2026
11 of 12 checks passed
@mpasternak mpasternak deleted the fix/freshdesk-308 branch April 28, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant