Skip to content

Feat/155 change of folder architecture#157

Open
DominikDab341 wants to merge 33 commits intodevfrom
feat/155-change-of-folder-architecture
Open

Feat/155 change of folder architecture#157
DominikDab341 wants to merge 33 commits intodevfrom
feat/155-change-of-folder-architecture

Conversation

@DominikDab341
Copy link
Copy Markdown
Contributor

@DominikDab341 DominikDab341 commented Feb 21, 2026

Zmieniłem architekturę folderów, dodałem parę testów i migrację, która powinna stworzyć root foldery dla istniejących już użytkowników. Zmergowałem również kod Wiktora, który implementuje endpointy library i model SharedFolder. Zrefactorowałem go tak, żeby była jedna klasa APIView zajmująca się tą logiką (dopiero po fakcie zobaczyłem, że sposób, którym zrobił był opisany przez Sarę więc jeżeli należy to zmienić to zmienię ).


Important

Refactor folder architecture by introducing Folder and SharedFolder models, renaming maintainer to creator, and updating views, serializers, and tests accordingly.

  • Folder Architecture:
    • Introduced Folder model in models.py with fields for name, owner, parent, created_at, and updated_at.
    • Added SharedFolder model for sharing folders with users or study groups.
    • Created migrations 0004_folder_quiz_folder.py, 0017_sharedfolder.py, and 0021_create_root_folders.py to set up folder structure and root folders for users.
  • Model Changes:
    • Renamed maintainer to creator in Quiz model and updated related fields and permissions.
    • Updated Quiz model to include a folder field, linking quizzes to folders.
  • View and Serializer Updates:
    • Updated QuizViewSet and FolderViewSet to handle folder-related operations and permissions.
    • Added LibraryView to handle library endpoints for accessing folders and quizzes.
    • Updated serializers to include folder information and handle new permissions.
  • Permissions:
    • Updated permissions to reflect folder ownership and sharing capabilities.
    • Added checks for folder and quiz edit permissions based on ownership and sharing.
  • Tests:
    • Added and updated tests in tests/ to cover new folder architecture, permissions, and library endpoints.
    • Ensured tests reflect changes in folder structure and quiz ownership logic.

This description was created by Ellipsis for ac52c07. You can customize this summary. It will automatically update as commits are pushed.

@DominikDab341 DominikDab341 linked an issue Feb 21, 2026 that may be closed by this pull request
@Antoni-Czaplicki Antoni-Czaplicki marked this pull request as draft February 23, 2026 18:10
@Antoni-Czaplicki
Copy link
Copy Markdown
Member

awaiting architecture discussion

@DominikDab341 DominikDab341 marked this pull request as ready for review March 3, 2026 15:18
Copy link
Copy Markdown
Collaborator

@MoonPrincess06 MoonPrincess06 left a comment

Choose a reason for hiding this comment

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

Poza tym jednym komentarzu, co zostawiłam, nie rzuca mi się nic takiego w oczy

MoonPrincess06
MoonPrincess06 previously approved these changes Mar 5, 2026
Copy link
Copy Markdown
Collaborator

@MoonPrincess06 MoonPrincess06 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors the quizzes “folder” domain by introducing per-user root folders, adding folder sharing, and updating quiz ownership semantics from maintainer to creator, with corresponding API + test updates.

Changes:

  • Added User.root_folder and mechanisms to create root folders (signal + data migration).
  • Introduced/expanded folder & sharing support (Folder, SharedFolder) and added a /library/ browsing endpoint.
  • Renamed Quiz.maintainerQuiz.creator and updated views/serializers/admin/tests accordingly.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
users/models.py Adds root_folder OneToOne relation to quizzes.Folder.
users/migrations/0006_user_root_folder.py Migration adding root_folder to User.
quizzes/apps.py Registers quizzes app signals on startup.
quizzes/signals.py Adds post-save hook to auto-create a root folder for new users.
quizzes/models.py Adds folder root detection/protection, SharedFolder, and updates Quiz to use creator + non-null folder.
quizzes/permissions.py Updates permission classes to reflect creator/folder ownership model.
quizzes/serializers.py Renames maintainer fields to creator; adds LibraryItemSerializer; adds root-folder move validation.
quizzes/views.py Updates queries to use creator; enforces folder-owner delete; adds LibraryView.
quizzes/urls.py Adds /library/ routes.
quizzes/admin.py Renames admin fields/search/autocomplete from maintainer to creator.
quizzes/migrations/0004_folder_quiz_folder.py Adjusts initial folder migration definition (incl. timestamps/parent/owner).
quizzes/migrations/0005_rename_user_folder_owner_folder_created_at_and_more.py Deleted migration as part of migration history rewrite.
quizzes/migrations/0006_folder_parent.py Deleted migration as part of migration history rewrite.
quizzes/migrations/0007_question_answer.py Repoints dependency to 0004_* after removing 0005/0006.
quizzes/migrations/0017_sharedfolder.py Adds SharedFolder table.
quizzes/migrations/0019_merge_0017_sharedfolder_0018_delete_quizprogress.py Merge migration for branching migration history.
quizzes/migrations/0020_rename_maintainer_to_creator.py Schema rename of Quiz.maintainerQuiz.creator.
quizzes/migrations/0021_create_root_folders.py Data migration to create root folders and attach orphan quizzes; makes Quiz.folder required.
quizzes/migrations/0022_merge_0019_questionissue_0021_create_root_folders.py Merge migration.
uploads/tests.py Updates quiz creation in upload tests to use creator + folder.
quizzes/tests/test_library_endpoint.py Adds test coverage for /library/ root/folder browsing and sharing.
quizzes/tests/test_folder_root.py Adds tests for root folder creation, move/delete protection, and cascade behavior.
quizzes/tests/test_folder_crud.py Adds CRUD + permission tests for folders/quizzes under the new model.
quizzes/tests/test_copy_quiz.py Updates copy tests to use creator + folder, and asserts copied quiz lands in copier’s root folder.
quizzes/tests/test_quiz_crud.py Updates CRUD tests for creator and adds root-folder assignment assertions.
quizzes/tests/test_question_crud.py Updates question CRUD tests for creator + folder.
quizzes/tests/test_metadata_action.py Updates metadata tests for creator + folder.
quizzes/tests/test_quiz_progress.py Updates progress tests for creator + folder.
quizzes/tests/test_quiz_serializer_extras.py Updates serializer tests for creator + folder.
quizzes/tests/test_record_answer_updates_session.py Updates session tests for creator + folder.
quizzes/tests/test_has_external_images.py Updates external-images test for creator + folder.
quizzes/tests/last_used_quizzes_test.py Updates last-used tests for creator + folder and response field rename.

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
@Antoni-Czaplicki
Copy link
Copy Markdown
Member

hej, pamiętaj że by oznaczać komentarze jako rozwiązane

Copy link
Copy Markdown
Collaborator

@MoonPrincess06 MoonPrincess06 left a comment

Choose a reason for hiding this comment

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

Znalazłam kilka rzeczy jeszcze, ale poza tym jest git:)

Copy link
Copy Markdown
Collaborator

@MoonPrincess06 MoonPrincess06 left a comment

Choose a reason for hiding this comment

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

Przejrzyj proszę całą bazę i pozmieniaj to maintainer na creator pls. W IDE możesz po prostu wyszukać słowo maintainer w repo i przeklikać każde wystąpienie nazwy i usalić, czy chcesz to zmienić czy nie. Fajny też byłby refactor nazw klas i funkcji, bo nowa osoba może nie wiedzieć kim jest maintainer w nazwie funkcji

Copy link
Copy Markdown
Member

@Antoni-Czaplicki Antoni-Czaplicki left a comment

Choose a reason for hiding this comment

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

kilka uwag plus jakbyś miał chwile ogarnać konflikty to by było super

Copy link
Copy Markdown
Member

@Antoni-Czaplicki Antoni-Czaplicki left a comment

Choose a reason for hiding this comment

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

a little bit more

owner = models.ForeignKey(User, on_delete=models.CASCADE, related_name="folders")
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)

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.

lets also add field for when associated root folder user has been deleted

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I dont get the idea of this change. Whe we are deleting user (owner of specify root_folder) we are deleting this folder also.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 32 out of 32 changed files in this pull request and generated 10 comments.

DominikDab341 and others added 2 commits April 2, 2026 00:14
…mplicit (fall through) returns'

Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
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] Zmiana architektury folderów

5 participants