Skip to content

Feat/115 feature shared drive - #239

Open
DominikDab341 wants to merge 28 commits into
devfrom
feat/115-feature-shared-drive
Open

Feat/115 feature shared drive#239
DominikDab341 wants to merge 28 commits into
devfrom
feat/115-feature-shared-drive

Conversation

@DominikDab341

Copy link
Copy Markdown
Contributor

Dodano logikę dysków współdzielonych, zmiany pokrywają się z opisem na discordzie. Również zaimplementowano zestaw ~50 testów, które powinny ładnie pokryć cały napisany kod.

Myślałem również nad usunięciem klasy SharedFolder, ponieważ wydawała mi się zbędna ale to najwyżej w poprawkach do pr'ki jeżeli będzie taka potrzeba

@DominikDab341 DominikDab341 self-assigned this May 19, 2026
@DominikDab341 DominikDab341 linked an issue May 19, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

PR wprowadza “shared drives” (współdzielone dyski) oparte o istniejący model Folder, dodając role członków dysku i egzekwując uprawnienia przy tworzeniu/usuwaniu quizów oraz nawigacji po bibliotece.

Changes:

  • Dodanie modelu członkostwa w dysku (SharedDriveMember) + ról (SharedDriveRole) oraz denormalizowanego wskaźnika Folder.shared_drive dla folderów wewnątrz dysku.
  • Nowy SharedDriveViewSet (CRUD dysków, członkowie, leave, tworzenie folderów) i rejestracja routera.
  • Rozszerzenie uprawnień i logiki dostępu (quizzes/folders/library) + nowy pakiet testów API dla shared drives.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
quizzes/views.py Dodaje SharedDriveViewSet oraz dopina shared-drive uprawnienia do tworzenia/usuwania quizów, przenoszenia folderów i dostępu w Library.
quizzes/urls.py Rejestruje endpointy shared-drives w routerze DRF.
quizzes/serializers.py Dodaje serializery dla shared drives/members oraz rozszerza walidację move/folder; zmienia reprezentację quizu.
quizzes/permissions.py Rozszerza dostępność quizów o shared drives i dodaje require_drive_role().
quizzes/models.py Dodaje Folder.shared_drive, SharedDriveRole, SharedDriveMember oraz metody uprawnień dla shared drives.
quizzes/migrations/0029_alter_folder_folder_type_alter_folder_owner_and_more.py Migracja zmieniająca Folder i dodająca SharedDriveMember (w obecnej formie koliduje numeracją).
quizzes/migrations/0031_folder_shared_drive_fk.py Dodaje FK Folder.shared_drive (wymaga korekty zależności po poprawie numeracji migracji).
quizzes/tests/test_shared_drives.py Nowe testy integracyjne API dla shared drives (CRUD, role, foldery, quizy, library, propagation).

Comment thread quizzes/migrations/0031_alter_folder_folder_type_alter_folder_owner_and_more.py Outdated
Comment thread quizzes/migrations/0031_folder_shared_drive_fk.py Outdated
Comment thread quizzes/serializers.py Outdated
Comment thread quizzes/views.py Outdated
Comment thread quizzes/views.py

@Antoni-Czaplicki Antoni-Czaplicki left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note

AI-generated review. Please verify before acting.

Findings:

  1. Contributors can move a shared-drive quiz out of the drive. The source permission check lets a drive CONTRIBUTOR pass, MoveQuizSerializer accepts folder_id=null or any folder owned by the user, and quizzes/views.py:531-535 assigns that destination directly. I reproduced a 200 response moving a private drive quiz into the contributor's root folder. Keep drive-owned quizzes inside the same drive unless an explicit export/copy flow with stronger permission is intended.

  2. Folder moves have a similar boundary escape. MoveFolderSerializer allows a user-owned subtree to move into a drive, while FolderViewSet.move updates shared_drive but keeps ownership. Because the personal folder endpoint still exposes owner-owned folders, the owner can later move the subtree back out and take drive content with it. Define ownership/transfer rules and add regression tests for moving personal folders into/out of drives.

  3. The PR is merge-conflicting and branches migrations from an old quizzes graph. Conflict resolution must preserve current dev behavior such as TRASH, deleted_at, restore/delete behavior, OAuth scope enforcement, and newer service-based quiz flows.

Needed to merge: rebase/resolve conflicts against current dev, regenerate migrations after the current trash migrations, fix quiz and folder move boundaries, add regression tests for both escape paths, then rerun shared-drive, trash, permissions, and migration checks.

@Batirro Batirro left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Znalazłem kilka race conditions przy działaniach z last admin, a reszta wygląda solidnie.

Comment thread quizzes/views.py
Comment thread quizzes/views.py
Comment thread quizzes/views.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Suppressed comments (1)

quizzes/views.py:481

  • perform_create() allows passing any folder_id owned by the user, including protected folders like TRASH/ARCHIVE. Creating a quiz directly in TRASH makes it immediately inaccessible via IsQuizReadable (treated as deleted), and creating directly in ARCHIVE skips setting archived_at. This should be rejected (or handled explicitly) to avoid inconsistent quiz state.
            try:
                folder = Folder.objects.get(pk=folder_id)
            except (Folder.DoesNotExist, ValueError, DjangoValidationError):
                raise ValidationError({"folder_id": "Folder does not exist."})
            if folder.get_shared_drive_root() is not None:
                if not folder.has_shared_drive_permission(self.request.user, SharedDriveRole.CONTRIBUTOR):
                    raise PermissionDenied("Adding a quiz to a shared drive requires contributor role or higher.")
            elif folder.owner != self.request.user:
                raise PermissionDenied("You do not have permission to add a quiz to this folder.")
            serializer.save(creator=self.request.user, folder=folder)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Dyski współdzielone

4 participants