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

images in options feature #346

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/deploy_to_ecs_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions plio/migrations/0032_question_option_images.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
1 change: 1 addition & 0 deletions plio/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions plio/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class Meta:
"text",
"type",
"options",
"option_images",
"correct_answer",
"survey",
"image",
Expand All @@ -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
Loading