Skip to content

generate a fallback for footer.url if footer_pathname not set#17550

Merged
eviljeff merged 2 commits into
mozilla:masterfrom
eviljeff:17544-generate-shelf-footer
Jul 23, 2021
Merged

generate a fallback for footer.url if footer_pathname not set#17550
eviljeff merged 2 commits into
mozilla:masterfrom
eviljeff:17544-generate-shelf-footer

Conversation

@eviljeff

Copy link
Copy Markdown
Member

@eviljeff
eviljeff requested review from a team and bobsilverberg and removed request for a team July 22, 2021 12:27
@eviljeff
eviljeff force-pushed the 17544-generate-shelf-footer branch from 278f12d to 7364e76 Compare July 22, 2021 12:27

@bobsilverberg bobsilverberg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, nice work!

r+wc

Comment thread src/olympia/shelves/serializers.py Outdated
is_flat_url = request and is_gate_active(request, 'wrap-outgoing-parameter')

url = data.get('url')
if not url and obj.endpoint in (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I'm not sure if it would actually be better because of nesting, but looking at this it feels like you could start with just if not url:, because that is part of both of the following if / elif clauses.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I was just avoid the extra layer of indentation but I guess it's more "correct" to have a two levels.

return url
else:
return {
**data,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would this **data be? If we don't need to worry about it when is_flat_url is True, why do we need to worry about it here? I guess it's just being safe in case there is something there?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data will contain text too (and other fields if they're added to the serializer later) but I see now I forgot to do the same when flat_url is true above!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 332ed63 - and changed the tests to better check that the output is what we expect (before ShelfSerializer was using CTAField so we partly relied on those tests to cover all the edge cases with the more unusual api gates)

@eviljeff
eviljeff merged commit ae40a40 into mozilla:master Jul 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

always return shelf footer url - generate fallback

2 participants