mirror of
https://github.com/ae-utbm/sith.git
synced 2026-04-22 11:13:14 +00:00
actually fix bug where you can't select /SAS as a parent album
This commit is contained in:
@@ -110,7 +110,9 @@ class Command(BaseCommand):
|
||||
p.save(force_lock=True)
|
||||
|
||||
club_root = SithFile.objects.create(name="clubs", owner=root)
|
||||
sas = SithFile.objects.create(name="SAS", owner=root, is_in_sas=True)
|
||||
sas = SithFile.objects.create(
|
||||
name="SAS", owner=root, id=settings.SITH_SAS_ROOT_DIR_ID
|
||||
)
|
||||
main_club = Club.objects.create(
|
||||
id=1, name="AE", address="6 Boulevard Anatole France, 90000 Belfort"
|
||||
)
|
||||
|
||||
+4
-2
@@ -886,8 +886,10 @@ class SithFile(models.Model):
|
||||
return self.get_parent_path() + "/" + self.name
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
sas = SithFile.objects.filter(id=settings.SITH_SAS_ROOT_DIR_ID).first()
|
||||
self.is_in_sas = sas in self.get_parent_list() or self == sas
|
||||
sas_id = settings.SITH_SAS_ROOT_DIR_ID
|
||||
self.is_in_sas = self.id == sas_id or any(
|
||||
p.id == sas_id for p in self.get_parent_list()
|
||||
)
|
||||
adding = self._state.adding
|
||||
super().save(*args, **kwargs)
|
||||
if adding:
|
||||
|
||||
@@ -344,3 +344,14 @@ def test_quick_upload_image(
|
||||
assert (
|
||||
parsed["name"] == Path(file.name).stem[: QuickUploadImage.IMAGE_NAME_SIZE - 1]
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_populated_sas_is_in_sas():
|
||||
"""Test that, in the data generated by the populate command,
|
||||
the SAS has value is_in_sas=True.
|
||||
|
||||
If it's not the case, it has no incidence in prod, but it's annoying
|
||||
in dev and may cause misunderstandings.
|
||||
"""
|
||||
assert SithFile.objects.get(id=settings.SITH_SAS_ROOT_DIR_ID).is_in_sas
|
||||
|
||||
Reference in New Issue
Block a user