-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use Sponsor Logos #19803
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
base: main
Are you sure you want to change the base?
Use Sponsor Logos #19803
Changes from all commits
fef4aa3
5c88fec
764dac9
d0f1d1d
75b3226
1b21773
1df95c4
d2641c2
43e6195
9b34573
094f0fb
3811f09
942958c
97d75c7
ff59483
165d72e
9e80da1
8f8ce97
9d78c6b
99aea70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,12 +8,32 @@ | |
|
|
||
|
|
||
| def _sponsors(request): | ||
| return request.db.query(Sponsor).filter(Sponsor.is_active == true()).all() | ||
| return ( | ||
| request.db.query(Sponsor) | ||
| .filter(Sponsor.is_active == true()) | ||
| .order_by(Sponsor.infra_sponsor, Sponsor.level_order, Sponsor.name) | ||
| .all() | ||
| ) | ||
|
|
||
|
|
||
| def _footer_sponsors(request): | ||
| """Return footer sponsors: PSF by level then name, infra by name.""" | ||
| all_sponsors = request.sponsors | ||
| psf = sorted( | ||
| (s for s in all_sponsors if s.footer and not s.infra_sponsor), | ||
| key=lambda s: (s.level_order or 0, s.name), | ||
| ) | ||
| infra = sorted( | ||
| (s for s in all_sponsors if s.infra_sponsor), | ||
| key=lambda s: s.name, | ||
| ) | ||
| return psf + infra | ||
|
|
||
|
|
||
| def includeme(config): | ||
| # Add a request method which will allow to list sponsors | ||
| config.add_request_method(_sponsors, name="sponsors", reify=True) | ||
| config.add_request_method(_footer_sponsors, name="footer_sponsors", reify=True) | ||
|
Comment on lines
34
to
+36
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if instead of a new request method, Maybe a shape like: sponsors = {
"infrastructure": [...],
"all": [...],
}Then we remain with a single request method request.sponsors that returns the presorted, filtered objects for the templates to iterate? |
||
|
|
||
| # Add a periodic task to update sponsors table | ||
| if config.registry.settings.get("pythondotorg.api_token"): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,8 +50,10 @@ def update_pypi_sponsors(request): | |
| sponsor.service = sponsor_info["description"] | ||
| sponsor.link_url = sponsor_info["sponsor_url"] | ||
| sponsor.color_logo_url = sponsor_info["logo"] | ||
| sponsor.white_logo_url = sponsor_info.get("white_logo") | ||
| sponsor.level_name = sponsor_info["level_name"] | ||
| sponsor.level_order = sponsor_info["level_order"] | ||
| sponsor.is_active = True | ||
| sponsor.psf_sponsor = True | ||
| sponsor.footer = sponsor_info["level_name"] in {"Visionary", "Sustainability"} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This condition is no longer used in the template |
||
| sponsor.origin = "remote" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice refactor