Conversation
|
Problem z lintem był taki, że zapomniałem usunąć komentarza jak naprawiałem błąd w signals.py i drugi podczas importu do zarejestrowania sygnału w apps.py. Użyłem komentarza, który informuje linter o tym, żeby ignorował tą linijkę. |
Antoni-Czaplicki
left a comment
There was a problem hiding this comment.
fajna PR, drobne komentarze tylko
| old_name='type', | ||
| new_name='folder_type', |
There was a problem hiding this comment.
hej, czemu nie po prostu type? jak już mamy obiekt folder to wiemy że to filder
There was a problem hiding this comment.
Ponieważ type to funkcja w pythonie i stwierdziłem, że możę lepiej będzie to trochę uszczegółowić.
quizzes/models.py
Outdated
| class Type(models.TextChoices): | ||
| ARCHIVE = "ARCHIVE", "Archive" | ||
| REGULAR = "REGULAR", "Regular" | ||
|
|
There was a problem hiding this comment.
można by to nazwać FolderType i dać na góre pliku
quizzes/signals.py
Outdated
| Creates archive folder for each new user | ||
| """ | ||
| if created: | ||
| Folder.objects.create(name="Archive", owner=instance, folder_type=Folder.Type.ARCHIVE) |
There was a problem hiding this comment.
nazwałbym to jednak po polsku bo będzie wyświetlane w UI
quizzes/models.py
Outdated
| ARCHIVE = "ARCHIVE", "Archive" | ||
| REGULAR = "REGULAR", "Regular" |
There was a problem hiding this comment.
fajnie jakby sam typ był zapisywany z małej żeby pasowało do innych rzeczy w bazie
| ARCHIVE = "ARCHIVE", "Archive" | |
| REGULAR = "REGULAR", "Regular" | |
| ARCHIVE = "archive", "Archive" | |
| REGULAR = "regular", "Regular" |
README.md
Outdated
| pip install -r requirements.txt | ||
| ``` | ||
|
|
||
There was a problem hiding this comment.
to raczej przez przypadek
There was a problem hiding this comment.
Pull request overview
This PR adds first-class support for per-user quiz archive folders, enforced at the model, serializer, view, and signal layers, together with dedicated tests.
Changes:
- Introduces a
folder_typefield onFolder(withARCHIVEandREGULARtypes) and migrations to support it. - Adds automatic creation of an
Archivefolder for each new user via a Django signal, and enforces archive-specific rules (no subfolders, cannot move/rename/delete archive folders) in serializers and views. - Adds a
move-to-archivequiz endpoint plus a comprehensive test suite (test_folder_archive.py) validating archive creation, constraints, and quiz-moving behavior.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
quizzes/views.py |
Adds move_to_archive action on QuizViewSet and enforces archive folder immutability in FolderViewSet (perform_destroy, move), including appropriate HTTP statuses. |
quizzes/tests/test_folder_archive.py |
Introduces tests covering quiz archive behavior, signal-driven archive creation, archive folder protections, cross-user isolation, and allowed operations on regular folders. |
quizzes/signals.py |
Adds a post_save signal handler to automatically create an Archive folder for each newly created User. |
quizzes/serializers.py |
Extends FolderSerializer with folder_type (read-only) and validation preventing archive subfolders/rename, and updates MoveFolderSerializer to forbid moving folders into archive folders. |
quizzes/models.py |
Adds Folder.Type choices and a folder_type field on Folder, defaulting to REGULAR, to model archive vs regular folders. |
quizzes/migrations/0013_folder_type.py |
Schema migration adding a type field to Folder to store folder type choices with default REGULAR. |
quizzes/migrations/0014_rename_type_folder_folder_type.py |
Follows up by renaming the Folder.type field to folder_type to align with the updated model. |
quizzes/apps.py |
Wires the quizzes app ready() hook to import signals, ensuring archive-folder creation is active. |
README.md |
Minor whitespace tweak in the setup instructions section (no functional impact). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| updated_at = models.DateTimeField(auto_now=True) | ||
| folder_type = models.CharField(max_length=10, choices=Type.choices, default=Type.REGULAR) | ||
|
|
||
| class Meta: |
There was a problem hiding this comment.
można by dodać jeszcze walidacje że nie da się utworzyć więcej niż jednego archiwum
możesz użyć https://docs.djangoproject.com/en/6.0/ref/models/constraints/
|
Zastosowałem się do poprawek, miałem problem z migracjami bo mój branch był trochę w plecy względem mastera ale jakoś się udało to naprawić. |
|
dobra to ja ogarne zaraz |
|
Putting on hold until library design is finalized |
Użyłem sygnałów do tworzenia archiwum dla każdego nowego użytkownika. Każdy folder ma status - "regular" lub "archive" i na podstawie tego użytkownik może przeprowadzać jakieś operacje, dopisałem dla wygody frontendu endpoint move-to-archive. Napisałem do tego proste testy, mam nadzieję, że nie zapomniałem o żadnym casie. Wyszedłem z założenia, że do archiwum nie możemy dodawać podfolderów. Wrzucamy tam wyłącznie quizy.
Important
Introduces automatic archive folder creation for new users and adds functionality to move quizzes to an archive folder with necessary validations and tests.
post_savesignal insignals.py.move-to-archiveendpoint inviews.pyto move quizzes to the archive folder.Typeclass inmodels.pyfor folder types (ARCHIVE,REGULAR).folder_typefield toFoldermodel with a unique constraint for one archive per user.FolderSerializerto includefolder_typeand add validation for archive folder restrictions.validate_parent_idinMoveFolderSerializerto prevent moving folders into archive.test_folder_archive.pyto test archive folder creation, restrictions, and quiz archiving.folder_typefield and rename it tofolder_typeinFoldermodel.This description was created by
for 6ad1b03. You can customize this summary. It will automatically update as commits are pushed.