fix for packages with . in name

This commit is contained in:
crflynn
2018-09-19 20:50:01 -04:00
parent edda426efa
commit a4bf548068
2 changed files with 5 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ def api():
@blueprint.route("/packages/<package>/recent") @blueprint.route("/packages/<package>/recent")
def api_downloads_recent(package): def api_downloads_recent(package):
"""Get the recent downloads of a package.""" """Get the recent downloads of a package."""
package = package.replace(".", "-")
category = request.args.get('period') category = request.args.get('period')
if category is None: if category is None:
downloads = RecentDownloadCount.query.\ downloads = RecentDownloadCount.query.\
@@ -53,6 +54,7 @@ def api_downloads_recent(package):
@blueprint.route("/packages/<package>/overall") @blueprint.route("/packages/<package>/overall")
def api_downloads_overall(package): def api_downloads_overall(package):
"""Get the overall download time series of a package.""" """Get the overall download time series of a package."""
package = package.replace(".", "-")
mirrors = request.args.get('mirrors') mirrors = request.args.get('mirrors')
if mirrors == 'true': if mirrors == 'true':
downloads = OverallDownloadCount.query.\ downloads = OverallDownloadCount.query.\
@@ -104,6 +106,7 @@ def api_downloads_system(package):
def generic_downloads(model, package, arg, name): def generic_downloads(model, package, arg, name):
"""Generate a generic response.""" """Generate a generic response."""
package = package.replace(".", "-")
category = request.args.get(arg) category = request.args.get(arg)
if category is not None: if category is not None:
downloads = model.query.\ downloads = model.query.\

View File

@@ -61,6 +61,7 @@ def index():
@blueprint.route("/search/<package>", methods=("GET", "POST")) @blueprint.route("/search/<package>", methods=("GET", "POST"))
def search(package): def search(package):
"""Render the home page.""" """Render the home page."""
package = package.replace(".", "-")
form = MyForm() form = MyForm()
if form.validate_on_submit(): if form.validate_on_submit():
package = form.name.data package = form.name.data
@@ -91,6 +92,7 @@ def faqs():
@blueprint.route("/packages/<package>") @blueprint.route("/packages/<package>")
def package(package): def package(package):
"""Render the package page.""" """Render the package page."""
package = package.replace(".", "-")
# Recent download stats # Recent download stats
recent_downloads = RecentDownloadCount.query.\ recent_downloads = RecentDownloadCount.query.\
filter_by(package=package).all() filter_by(package=package).all()