Skip to content

Commit

Permalink
Merge pull request #889 from DemocracyClub/fix-hero-alt-text
Browse files Browse the repository at this point in the history
Fix hero alt text
  • Loading branch information
symroe authored Nov 5, 2024
2 parents e7d1cec + faadb5a commit c2dd708
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@ jobs:
- aws-cli/setup
- run:
name: "Migrate database"
# Invoke Lambda using the AWS CLI. Grep for errors in the response because
# the command will exit 0 even if the invocation failed. The JSON key `FunctionError` will contain something
# if there's an error.
command: |
aws lambda invoke --function-name DCWebsiteManagementFunction --payload '{ "command": "migrate", "args": ["--no-input"] }' --cli-binary-format raw-in-base64-out -
aws lambda invoke --function-name DCWebsiteManagementFunction --payload '{ "command": "migrate", "args": ["--no-input"] }' --cli-binary-format raw-in-base64-out - | grep 'FunctionError": ""'
- run:
name: "Invalidate CloudFront cache"
command: |
Expand Down
9 changes: 6 additions & 3 deletions democracy_club/apps/hermes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ class PostListView(ListView):
template_name = "hermes/post_list.html"

def get_queryset(self):
qs = self.model.objects.published().prefetch_related("author")
qs = (
self.model.objects.published()
.prefetch_related("author")
.defer("body", "hero_alt_text")
)
tag = self.request.GET.get("tag", None)
if tag:
qs = qs.for_tag(tag)
return qs

def get_context_data(self, **kwargs):
context = super(PostListView, self).get_context_data(**kwargs)
posts = Post.objects.all().published()
tags = []
for post in posts:
for post in context["object_list"]:
for tag in post.tags:
if tag not in tags:
tags.append(tag)
Expand Down
2 changes: 1 addition & 1 deletion sam-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Resources:
Timeout: 60
Role: !Sub "arn:aws:iam::${AWS::AccountId}:role/DCWebsiteLambdaExecutionRole"
CodeUri: .
Handler: democracy_club.lambda_awsgi.management_handler
Handler: democracy_club.lambda_wsgi.management_handler
Layers:
- !Ref DependenciesLayer
Runtime: python3.12
Expand Down

0 comments on commit c2dd708

Please sign in to comment.