Repository navigation
Add the Profile model and SkillProfile models - #828
AdrianDAlessandro wants to merge 6 commits into
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🟡 Changes recommended
Admin deletion and migration rollback can lose assessment ownership, and existing shared links no longer render correctly.
3 open issues
What changed in this PR
This PR decouples skill assessments from authentication accounts by introducing Profile and replacing UserSkill with SkillProfile, supporting standalone career profiles alongside user profiles.
Changes:
- Add profile models, automatic creation for new users, and migrations for existing assessments.
- Update forms, views, admin pages, charts, and exports to use skill profiles.
- Adapt tests, sample data, and developer documentation.
| File | Description |
|---|---|
| tests/main/test_user_models.py | Test profile creation, ownership, uniqueness, and deletion. |
| tests/main/test_registration_views.py | Verify registration creates a profile. |
| tests/main/test_main_views.py | Update view assertions and chart payloads. |
| tests/main/test_admin_views.py | Replace proxy-admin tests with profile-admin tests. |
| tests/main/test_account_data_views.py | Update download tests and JSON keys. |
| tests/main/conftest.py | Replace the assessment fixture with SkillProfile. |
| tests/data/example_role.json | Rename the sample chart-data key. |
| main/views/account_views.py | Use profile-backed assessments and forms. |
| main/views/account_data_views.py | Export assessments through profiles. |
| main/urls.py | Reference renamed download views. |
| main/templates/main/snippets/skill-wheel.html | Read the renamed chart-data key. |
| main/templates/main/snippets/share_skill_profile_dropdown.html | Update the sharing-template include. |
| main/templates/main/snippets/export_skill_profile.html | Update export payload access and usage comment. |
| main/templates/main/snippets/create_skill_profile_link.html | Correct the template usage comment. |
| main/static/assets/sample_data/sample_profile_59.json | Update the sample profile payload key. |
| main/static/assets/sample_data/sample_profile_41.json | Update the sample profile payload key. |
| main/static/assets/sample_data/sample_profile_1.json | Update the sample profile payload key. |
| main/signals.py | Create profiles when users are created. |
| main/models/user_models.py | Introduce profiles and profile-owned assessments. |
| main/migrations/0035_rename_userskill_skillprofile.py | Rename the assessment model. |
| main/migrations/0034_delete_userproxy_remove_userskill_unique_user_skill_and_more.py | Finalize profile ownership and constraints. |
| main/migrations/0033_populate_userskill_profiles.py | Create existing users’ profiles and transfer assessments. |
| main/migrations/0032_alter_userskill_user_profile_userskill_profile.py | Introduce the transitional profile schema. |
| main/forms.py | Accept profiles when editing assessments. |
| main/apps.py | Register profile-creation signals. |
| main/admin.py | Replace the user proxy with profile administration. |
| docs/dev-guide/development.md | Document cleanup of generated documentation. |
| docs/dev-guide/architecture.md | Describe profile ownership and automatic creation. |
Review effort: Balanced
eacd203 to
c03f015
Compare
TinyMarsh
left a comment
There was a problem hiding this comment.
I only have one potential issue. The rest of the PR looks good though!
| if obj is None: | ||
| return True |
There was a problem hiding this comment.
I think there might be an issue with this. But I might be completely wrong 😅
So this is here so that the bulk deletion checkboxes appear, that's fine. But, the problem is that Django’s built-in Delete selected profiles action then deletes the selected profiles and I'm not sure it repeats this custom permission check separately for each profile. So a user with the relevant delete permissions can select a user-linked profile and delete it in bulk, even though deleting that same profile from its individual profile page is blocked.
There was a problem hiding this comment.
I'm not 100% sure of the exact order of things, but this is what I landed on when trying multiple options. It does appear that this function is called multiple times, at multiple stages, both with and without obj defined. When trying to delete a user-linked profile with the bulk-delete facility, you get a page saying you don't have permission:
But it remains possible to delete profiles with no associated user.
c03f015 to
fc24fa3
Compare
fc24fa3 to
389e17e
Compare
TinyMarsh
left a comment
There was a problem hiding this comment.
After addressing the delete permission query, this now looks good.


Description
Apologies for the long PR! These new models are in a part of the DB that touches a lot of the code, but this is part of the motivation for this change. Hopefully, this will make future changes related to skill profiles simpler.
This adds a
Profilemodel that is to be used for two things:UserSkills, as was done before)All users must have a
Profile, this is ensured by a post-save signal that is fired whenever a new user is created. There is also a migration that creates a profile for every existing user.It also replaces the previous
UserSkillmodel with aSkillProfilemodel. This is implemented in a way that ensures all existing users' skill profiles remain intact. There is a series of migrations for this.All the views, forms and templates that interact with the skill profiles have been changed as minimally as possible, focussing on:
user_skillbecomesskill_profile, etc)user.profileobject when it is all that is needed (i.e.SkillProfileFormmethods no longer takeuseras an input)Fixes #824
Type of change
Key checklist
python -m pytest)mkdocs serve)pre-commit run --all-files)Further checks