Skip to content
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

Fix domain being None in opensearch results #543

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def test_sort(client, package):
def test_packages(client, package):
response = client.get('/opensearch/packages/')
assert response.status_code == 200
assert 'template="example.com/opensearch/packages/"' in response.content.decode()


def test_packages_suggest(client, package):
Expand Down
5 changes: 3 additions & 2 deletions packages/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.contrib import messages
from django.contrib.auth.decorators import permission_required
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.core.cache import cache
from django.db.models import Q
from django.http import HttpResponse, HttpResponseBadRequest
Expand All @@ -21,10 +22,10 @@
@require_safe
@cache_control(public=True, max_age=86400)
def opensearch(request):
domain = "%s://%s" % (request.scheme, request.META.get('HTTP_HOST'))
current_site = Site.objects.get_current()

return render(request, 'packages/opensearch.xml',
{'domain': domain},
{'domain': current_site.domain},
content_type='application/opensearchdescription+xml')


Expand Down
5 changes: 3 additions & 2 deletions public/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from operator import attrgetter

from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.db.models import Count, Q
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render
Expand All @@ -25,12 +26,12 @@ def updates():
else:
def updates():
return get_recent_updates()
domain = "%s://%s" % (request.scheme, request.META.get('HTTP_HOST'))
current_site = Site.objects.get_current()
context = {
'news_updates': News.objects.order_by('-postdate', '-id')[:15],
'pkg_updates': updates,
'staff_groups': StaffGroup.objects.all(),
'domain': domain,
'domain': current_site.domain,
}
return render(request, 'public/index.html', context)

Expand Down
Loading