Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/ Fixed sorting in albums #910

Merged
merged 8 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added app/gallery/factories/_init_.py
Empty file.
15 changes: 15 additions & 0 deletions app/gallery/factories/album_factory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import factory
from factory.django import DjangoModelFactory

from app.gallery.models.album import Album


class AlbumFactory(DjangoModelFactory):
class Meta:
model = Album

id = factory.Sequence(lambda n: f"picture_{n}")
image = factory.Faker("image")
title = factory.Faker("title")
image_alt = factory.Faker("image_alt")
description = factory.Faker("description")
17 changes: 17 additions & 0 deletions app/gallery/migrations/0003_alter_album_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 4.2.5 on 2024-10-21 17:00

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("gallery", "0002_remove_picture_album_album_id_alter_album_slug"),
]

operations = [
migrations.AlterModelOptions(
name="album",
options={"ordering": ["-created_at"]},
),
]
3 changes: 3 additions & 0 deletions app/gallery/models/album.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class Album(BaseModel, BasePermissionModel, OptionalImage):
slug = models.SlugField(max_length=50, primary_key=False)
write_access = AdminGroup.all()

class Meta:
ordering = ["-created_at"]

def __str__(self):
return self.title

Expand Down
Empty file added app/tests/gallery/_init_.py
Empty file.
Loading