-
Notifications
You must be signed in to change notification settings - Fork 5
Support for draft projects & private draft permissions #917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…/RolnickLab/antenna into feat/restrict-ml-processing-jobs
…/RolnickLab/antenna into feat/restrict-ml-processing-jobs
… generic permission check instead
…onship with the project model
Hey @mohamedelabbas1996, I have tested this and it worked great! Nice work.
I tested this by trying to access projects (regular and drafts) from different user types (admin, members, non members). For related entities, I only tested deployments, but I tried both list and detail endpoints. Some questions:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements draft project functionality by adding a draft
boolean field to the Project model and introducing visibility restrictions. Draft projects are only accessible to authorized users (owners, members, or superusers) across the platform.
- Added
draft
field to Project model with visibility controls - Refactored queryset architecture with new
BaseQuerySet
class for consistent filtering - Updated API endpoints and admin interface to respect draft project visibility
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
ami/base/models.py | Added BaseQuerySet with visible_for_user filtering and project accessor logic |
ami/main/models.py | Added draft field to Project model and updated managers to use BaseQuerySet |
ami/main/migrations/0070_project_draft.py | Database migration to add draft field |
ami/main/api/views.py | Updated API views to apply draft visibility filtering |
ami/main/api/serializers.py | Added draft field to Project serializer |
ami/main/admin.py | Added draft field to admin interface |
ami/main/signals.py | Updated permission constants |
ami/users/roles.py | Updated permission constants |
ami/main/tests.py | Added comprehensive tests for draft project permissions |
ami/ml/models/pipeline.py | Updated to use BaseQuerySet |
ami/ml/models/algorithm.py | Updated to use BaseQuerySet |
ami/ml/models/processing_service.py | Updated to use BaseQuerySet |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
…ct-draft-projects-permissions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mohamedelabbas1996 this seems to be working great. I added one test and addressed my own suggestions! will you review my changes? then I am ready to merge.
@mihow I have tested and reviewed this and I think it's good to go! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging!
Summary
This PR implements view permission restrictions for draft projects, ensuring that only authorized users (owners, members, or superusers) can view them across the platform.
List of Changes
Added
draft
boolean field to the Project model.Updated the Django admin interface to allow editing the draft field.
Created
BaseQuerySet
class to standardize queryset behavior and made relevant models inherit from it.Added
visible_for_user(user)
toBaseQuerySet
to filter draft projects and related objects visible to the user.Added project_accessor string to models only when they have an indirect one-to-many relationship to the Project model. For models with a direct one-to-many or many-to-many relationship, the accessor is inferred dynamically in the visible_for_user method of BaseQuerySet. .
Related Issues
Closes #913
Closes #899
Detailed Description
To support the concept of draft or scratch projects, we introduce a new
draft
boolean field on the Project model. Draft projects are meant to be private by default and not accessible to users outside the project team.This PR implements logic to restrict visibility of these projects using the existing permission system, with the addition of:
A reusable
visible_for_user(user, project_accessor)
filter method onBaseQuerySet
which limits queryset results to objects belonging to draft projects the user is allowed to view.Integration of this filtering logic into the API
DefaultViewSet
by overridingget_queryset()
, ensuring endpoints automatically respect draft visibility.How to Test the Changes
Create a draft project and assign different users as owner, member, or outsider.
Use the API or admin panel to verify:
Owners and members can access draft project details.
Outsiders (non-members) are denied access.
Superusers have access regardless of membership.
Ensure related models also respect draft project visibility.
Screenshots
Deployment Notes
N/A
Checklist