Skip to content

Feat/72 automatic archive folder#129

Draft
DominikDab341 wants to merge 9 commits intomasterfrom
feat/72-automatic-archive-folder
Draft

Feat/72 automatic archive folder#129
DominikDab341 wants to merge 9 commits intomasterfrom
feat/72-automatic-archive-folder

Conversation

@DominikDab341
Copy link
Contributor

@DominikDab341 DominikDab341 commented Jan 23, 2026

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.

  • Behavior:
    • Automatically creates an archive folder for each new user using post_save signal in signals.py.
    • Adds move-to-archive endpoint in views.py to move quizzes to the archive folder.
    • Archive folders cannot have subfolders or be renamed, moved, or deleted.
  • Models:
    • Adds Type class in models.py for folder types (ARCHIVE, REGULAR).
    • Adds folder_type field to Folder model with a unique constraint for one archive per user.
  • Serializers:
    • Updates FolderSerializer to include folder_type and add validation for archive folder restrictions.
    • Adds validate_parent_id in MoveFolderSerializer to prevent moving folders into archive.
  • Tests:
    • Adds test_folder_archive.py to test archive folder creation, restrictions, and quiz archiving.
  • Migrations:
    • Adds migrations to introduce folder_type field and rename it to folder_type in Folder model.

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

@DominikDab341
Copy link
Contributor Author

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ę.

Copy link
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.

fajna PR, drobne komentarze tylko

Comment on lines +15 to +16
old_name='type',
new_name='folder_type',
Copy link
Member

Choose a reason for hiding this comment

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

hej, czemu nie po prostu type? jak już mamy obiekt folder to wiemy że to filder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ponieważ type to funkcja w pythonie i stwierdziłem, że możę lepiej będzie to trochę uszczegółowić.

Comment on lines +18 to +21
class Type(models.TextChoices):
ARCHIVE = "ARCHIVE", "Archive"
REGULAR = "REGULAR", "Regular"

Copy link
Member

Choose a reason for hiding this comment

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

można by to nazwać FolderType i dać na góre pliku

Creates archive folder for each new user
"""
if created:
Folder.objects.create(name="Archive", owner=instance, folder_type=Folder.Type.ARCHIVE)
Copy link
Member

Choose a reason for hiding this comment

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

nazwałbym to jednak po polsku bo będzie wyświetlane w UI

Comment on lines +19 to +20
ARCHIVE = "ARCHIVE", "Archive"
REGULAR = "REGULAR", "Regular"
Copy link
Member

Choose a reason for hiding this comment

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

fajnie jakby sam typ był zapisywany z małej żeby pasowało do innych rzeczy w bazie

Suggested change
ARCHIVE = "ARCHIVE", "Archive"
REGULAR = "REGULAR", "Regular"
ARCHIVE = "archive", "Archive"
REGULAR = "regular", "Regular"

README.md Outdated
pip install -r requirements.txt
```

Copy link
Member

Choose a reason for hiding this comment

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

to raczej przez przypadek

Copy link
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

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_type field on Folder (with ARCHIVE and REGULAR types) and migrations to support it.
  • Adds automatic creation of an Archive folder 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-archive quiz 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:
Copy link
Member

Choose a reason for hiding this comment

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

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/

@DominikDab341
Copy link
Contributor Author

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ć.

@Antoni-Czaplicki
Copy link
Member

dobra to ja ogarne zaraz

@Antoni-Czaplicki Antoni-Czaplicki marked this pull request as draft February 8, 2026 20:09
@Antoni-Czaplicki
Copy link
Member

Putting on hold until library design is finalized

@DominikDab341 DominikDab341 linked an issue Feb 19, 2026 that may be closed by this pull request
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.

Folder usuniętych

3 participants