Skip to content

Refactor Project Api#1531

Merged
jochenklar merged 11 commits into3.0.0/releasefrom
3.0.0/projects/query-roles
Mar 1, 2026
Merged

Refactor Project Api#1531
jochenklar merged 11 commits into3.0.0/releasefrom
3.0.0/projects/query-roles

Conversation

@jochenklar
Copy link
Copy Markdown
Member

This PR adds a subquery for highest role in the hierarchy and refactors ProjectSerializer to include the label of current_role and highest_role and adds project information for the latter, e.g.:

"current_role": {
    "role": "guest",
    "role_display": "Gast"
},
"highest_role": {
    "role": "owner",
    "role_display": "Besitzer",
    "project_id": 2,
    "project_title": "Parent"
},

@jochenklar jochenklar added this to the RDMO 3.0.0 milestone Feb 13, 2026
@jochenklar jochenklar requested a review from CalamityC February 13, 2026 17:41
@jochenklar jochenklar self-assigned this Feb 13, 2026
@jochenklar jochenklar changed the title Refactor roles in project api Refactor Project Api Feb 27, 2026
@jochenklar
Copy link
Copy Markdown
Member Author

Hi @CalamityC, I added a few more changes after our meeting:

  • Filtering with ?role=owner should work now and returns the project when the current_role OR the highest_role is e.g. owner
  • Ordering current_role or highest_role should work now. role does the same as highest_role, since the current project is included in highest_role
  • There was a but in the subquery magic which should be fixed now.
  • I removed owner, manager, etc. and snapshots from the Project API, since you fetch the Memberships and Snapshots seperately anyway, hope thats ok.
  • I added ancestors to the general ProjectSerializer so that it should also be returned when posting.
  • I added more caching so that the Project Request now much fewer database hits.

@jochenklar jochenklar requested a review from CalamityC February 27, 2026 13:11
Comment thread rdmo/projects/serializers/v1/__init__.py
Comment thread rdmo/projects/serializers/v1/__init__.py
@jochenklar
Copy link
Copy Markdown
Member Author

parent_title is back in the API!

parent = ParentField(required=False, allow_null=True)
parent_title = serializers.CharField(source='parent.title', read_only=True)

owners = ProjectUserSerializer(many=True, read_only=True)
Copy link
Copy Markdown
Collaborator

@CalamityC CalamityC Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need that too, or how do we get the owner of a project in projects list (it's supposed to be displayed in the table)?

ATM we use it here:

{row.owners.map(owner => owner.full_name).join('; ')}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I forgot about this. I added them again. But now with more database magic ✨

@jochenklar jochenklar merged commit dfc959c into 3.0.0/release Mar 1, 2026
1 check was pending
@jochenklar jochenklar deleted the 3.0.0/projects/query-roles branch March 1, 2026 18:21
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.

2 participants