Skip to content

Commit c5f0d7a

Browse files
committed
Change sponsors page to read data from db instead of HTML include
1 parent 918203a commit c5f0d7a

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

warehouse/routes.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,9 @@ def includeme(config):
4848
)
4949
# Redirect the old "sponsor PyPI" page to the sponsors page
5050
config.add_redirect("/sponsor/", "/sponsors/", domain=warehouse)
51-
config.add_template_view(
51+
config.add_route(
5252
"sponsors",
5353
"/sponsors/",
54-
# Use the full resource path here to make it able to be overridden by
55-
# pypi-theme.
56-
"warehouse:templates/pages/sponsors.html",
57-
view_kw={"has_translations": True},
5854
)
5955

6056
# Our legal policies

warehouse/sponsors/views.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
13+
from pyramid.view import view_config
14+
15+
from warehouse.sponsors.models import Sponsor
16+
17+
18+
@view_config(
19+
route_name="sponsors",
20+
renderer="pages/sponsors.html",
21+
has_translations=True,
22+
)
23+
def display_sponsors_page(request):
24+
sponsors = request.db.query(Sponsor).all()
25+
return {"sponsors": sponsors}

warehouse/templates/pages/sponsors.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
{% extends "base.html" %}
1515
{% block title %}{% trans %}Sponsors{% endtrans %}{% endblock %}
1616

17-
{% from "warehouse:templates/includes/sponsors.html" import sponsors %}
18-
1917
{% block content %}
2018
<div class="horizontal-section">
2119
<div class="site-container">
@@ -117,7 +115,7 @@ <h2 class="sponsor-grid__sponsor-name">Your company here</h2>
117115
{% if sponsor.psf_sponsor %}
118116
<div class="sponsor-grid__sponsor">
119117
<div class="sponsor-grid__sponsor-img">
120-
<img src="{{ request.static_path('warehouse:static/dist/images/sponsors/color/' + sponsor.image) }}" alt="{{ sponsor.name }}">
118+
<img src="{{ sponsor.color_logo_url }}" alt="{{ sponsor.name }}">
121119
</div>
122120
<h2 class="sponsor-grid__sponsor-name">{{ sponsor.name }}</h2>
123121
<div class="sponsor-grid__sponsor-activity">
@@ -142,7 +140,7 @@ <h2 class="centered-heading__title">Infrastructure sponsors</h2>
142140
{% if sponsor.infra_sponsor %}
143141
<div class="sponsor-grid__sponsor">
144142
<div class="sponsor-grid__sponsor-img">
145-
<img src="{{ request.static_path('warehouse:static/dist/images/sponsors/color/' + sponsor.image) }}" alt="{{ sponsor.name }}">
143+
<img src="{{ sponsor.color_logo_url }}" alt="{{ sponsor.name }}">
146144
</div>
147145
<div class="sponsor-grid__sponsor-description">
148146
<h2>{{ sponsor.name }}</h2>
@@ -180,7 +178,7 @@ <h2 class="sponsor-grid__sponsor-name">Your company here</h2>
180178
{% if sponsor.one_time %}
181179
<div class="sponsor-grid__sponsor">
182180
<div class="sponsor-grid__sponsor-img">
183-
<img src="{{ request.static_path('warehouse:static/dist/images/sponsors/color/' + sponsor.image) }}" alt="{{ sponsor.name }}">
181+
<img src="{{ sponsor.color_logo_url }}" alt="{{ sponsor.name }}">
184182
</div>
185183
<div class="sponsor-grid__sponsor-description">
186184
<h2>{{ sponsor.name }}</h2>

0 commit comments

Comments
 (0)