diff --git a/.github/workflows/deploy_to_ecs_staging.yml b/.github/workflows/deploy_to_ecs_staging.yml index f912604..d9955a3 100644 --- a/.github/workflows/deploy_to_ecs_staging.yml +++ b/.github/workflows/deploy_to_ecs_staging.yml @@ -25,8 +25,8 @@ jobs: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_NEW }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_NEW }} aws-region: ${{ secrets.AWS_REGION }} # log into ECR using the AWS credentials diff --git a/plio/migrations/0032_question_option_images.py b/plio/migrations/0032_question_option_images.py new file mode 100644 index 0000000..1a31d88 --- /dev/null +++ b/plio/migrations/0032_question_option_images.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.1 on 2024-07-23 06:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('plio', '0031_question_survey'), + ] + + operations = [ + migrations.AddField( + model_name='question', + name='option_images', + field=models.JSONField(blank=True, null=True), + ), + ] diff --git a/plio/models.py b/plio/models.py index d38b0d3..f27acc7 100644 --- a/plio/models.py +++ b/plio/models.py @@ -134,6 +134,7 @@ class Question(SafeDeleteModel): ) text = models.TextField(blank=True, default="") options = models.JSONField(null=True) + option_images = models.JSONField(null=True, blank=True) # This is an object where keys are indices in the options array and values are image IDs correct_answer = models.JSONField(null=True) survey = models.BooleanField(default=False) created_at = models.DateTimeField(auto_now_add=True) diff --git a/plio/serializers.py b/plio/serializers.py index 0a33061..293f97d 100644 --- a/plio/serializers.py +++ b/plio/serializers.py @@ -102,6 +102,7 @@ class Meta: "text", "type", "options", + "option_images", "correct_answer", "survey", "image", @@ -115,4 +116,11 @@ def to_representation(self, instance): response = super().to_representation(instance) if instance.image: response["image"] = ImageSerializer(instance.image).data + + if instance.option_images: + response["option_images"] = { + index: ImageSerializer(Image.objects.get(id=image_id)).data + for index, image_id in instance.option_images.items() + } + return response