diff --git a/src/fellchensammlung/management/commands/populate_db.py b/src/fellchensammlung/management/commands/populate_db.py index 88d47e4..2470b54 100644 --- a/src/fellchensammlung/management/commands/populate_db.py +++ b/src/fellchensammlung/management/commands/populate_db.py @@ -1,5 +1,5 @@ from django.core.management.base import BaseCommand, CommandError -from django.contrib.auth.models import User +from django.core.files import File from fellchensammlung.models import * from fellchensammlung import baker_recipes @@ -20,7 +20,7 @@ class Command(BaseCommand): adoption1 = baker.make(AdoptionNotice, name="Vermittung1", organization=rescue1) - adoption2 = baker.make(AdoptionNotice, name="Vermittung2", organization=rescue2) + adoption2 = baker.make(AdoptionNotice, name="Vermittung2", organization=rescue2) cat = baker.make(Species, name="Katze") rat = baker.make(Species, name="Farbratte") @@ -29,6 +29,17 @@ class Command(BaseCommand): rat2 = baker.make(Animal, name="Rat2", adoption_notice=adoption1, species=rat) cat1 = baker.make(Animal, name="Cat1", adoption_notice=adoption2, species=cat) + animal_photo_combination = [(cat1, "cat1.jpeg"), (rat1, "rat1.jpg"), (rat2, "rat2.jpg")] + for animal, filename in animal_photo_combination: + image_object = Image() + image_object.alt_text = f"Picture of {animal}" + image_object.title = f"Picture of {animal}" + image_object.image.save(f"{filename}", File(open(f"./src/fellchensammlung/tests/assets/{filename}", 'rb'))) + image_object.save() + + animal.photos.add(image_object) + + rule1 = baker.make(Rule, title="Be excellent ot each other", rule_text="This is **markdown**") rule2 = baker.make(Rule, title="Keep al least the minimum number of animals for species", diff --git a/src/fellchensammlung/tests/assets/cat1.jpeg b/src/fellchensammlung/tests/assets/cat1.jpeg new file mode 100644 index 0000000..d4a6fff Binary files /dev/null and b/src/fellchensammlung/tests/assets/cat1.jpeg differ diff --git a/src/fellchensammlung/tests/assets/cat2.jpeg b/src/fellchensammlung/tests/assets/cat2.jpeg new file mode 100644 index 0000000..63ba600 Binary files /dev/null and b/src/fellchensammlung/tests/assets/cat2.jpeg differ diff --git a/src/fellchensammlung/tests/assets/rat1.jpg b/src/fellchensammlung/tests/assets/rat1.jpg new file mode 100644 index 0000000..dee1799 Binary files /dev/null and b/src/fellchensammlung/tests/assets/rat1.jpg differ diff --git a/src/fellchensammlung/tests/assets/rat2.jpg b/src/fellchensammlung/tests/assets/rat2.jpg new file mode 100644 index 0000000..7601c16 Binary files /dev/null and b/src/fellchensammlung/tests/assets/rat2.jpg differ diff --git a/src/fellchensammlung/tests/assets/rat3.jpg b/src/fellchensammlung/tests/assets/rat3.jpg new file mode 100644 index 0000000..ebe9d09 Binary files /dev/null and b/src/fellchensammlung/tests/assets/rat3.jpg differ diff --git a/src/fellchensammlung/tests/assets/rat_cuddle_puddle_1.jpg b/src/fellchensammlung/tests/assets/rat_cuddle_puddle_1.jpg new file mode 100644 index 0000000..85a8f5d Binary files /dev/null and b/src/fellchensammlung/tests/assets/rat_cuddle_puddle_1.jpg differ