Skip to content

Commit

Permalink
use get_current_site() for getting site domain for manage lexicons
Browse files Browse the repository at this point in the history
  • Loading branch information
henrinie committed Sep 1, 2024
1 parent 5d26c9f commit 37aef83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions signbank/dictionary/templates/dictionary/manage_lexicons.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ <h3>{% blocktrans %}Description{% endblocktrans %}</h3>
<h3>{% blocktrans %}Copyright{% endblocktrans %}</h3>
<p>{{obj.copyright}}</p>
<h3>{% blocktrans %}ECV (externally controlled vocabulary){% endblocktrans %} <small>{% blocktrans %}A vocabulary for ELAN{% endblocktrans %}</small></h3>
{% if obj.is_public %}<p>{% blocktrans %}Public ECV{% endblocktrans %}: <a href="http://{{ request.get_host }}{% url 'dictionary:public_gloss_list_xml' obj.id %}">
http://{{ request.get_host }}{% url 'dictionary:public_gloss_list_xml' obj.id %}</a></p>
{% if obj.is_public %}<p>{% blocktrans %}Public ECV{% endblocktrans %}: <a href="https://{{ current_site_domain }}{% url 'dictionary:public_gloss_list_xml' obj.id %}">
https://{{ current_site_domain }}{% url 'dictionary:public_gloss_list_xml' obj.id %}</a></p>
{% endif %}
<p>{% blocktrans %}Advanced ECV{% endblocktrans %}: <a href="http://{{ request.get_host }}{% url 'dictionary:gloss_list_xml' obj.id %}">
http://{{ request.get_host }}{% url 'dictionary:gloss_list_xml' obj.id %}</a></p>
<p>{% blocktrans %}Advanced ECV{% endblocktrans %}: <a href="https://{{ current_site_domain }}{% url 'dictionary:gloss_list_xml' obj.id %}">
https://{{ current_site_domain }}{% url 'dictionary:gloss_list_xml' obj.id %}</a></p>
{% if user.is_superuser %}
<h3>{% blocktrans %}Users with permissions{% endblocktrans %}</h3>
<ul>{% for user in obj.users_with_perms.all %}
Expand Down Expand Up @@ -64,8 +64,8 @@ <h3>{% blocktrans %}Copyright{% endblocktrans %}</h3>
<p>{{obj.copyright}}</p>
{% if obj.is_public %}
<h3>{% blocktrans %}ECV (externally controlled vocabulary){% endblocktrans %} <small>{% blocktrans %}A vocabulary for ELAN{% endblocktrans %}</small></h3>
<p>{% blocktrans %}Public ECV{% endblocktrans %}: <a href="http://{{ request.get_host }}{% url 'dictionary:public_gloss_list_xml' obj.id %}">
http://{{ request.get_host }}{% url 'dictionary:public_gloss_list_xml' obj.id %}</a></p>
<p>{% blocktrans %}Public ECV{% endblocktrans %}: <a href="https://{{ current_site_domain }}{% url 'dictionary:public_gloss_list_xml' obj.id %}">
https://{{ current_site_domain }}{% url 'dictionary:public_gloss_list_xml' obj.id %}</a></p>
{% endif %}
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions signbank/dictionary/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django.contrib import messages
from django.contrib.auth.decorators import permission_required
from django.contrib.admin.views.decorators import user_passes_test
from django.contrib.sites.shortcuts import get_current_site
from django.core.exceptions import PermissionDenied
from django.urls import reverse, reverse_lazy
from django.utils.translation import ugettext as _
Expand Down Expand Up @@ -91,6 +92,8 @@ def get_context_data(self, **kwargs):
qs = self.get_queryset()
context['has_permissions'] = qs.filter(has_view_perm=True)
context['no_permissions'] = qs.filter(has_view_perm=False)
current_site = get_current_site(self.request)
context['current_site_domain'] = getattr(current_site, 'domain', self.request.get_host())
# Show users with permissions to lexicons to SuperUsers
if self.request.user.is_superuser:
for lexicon in context['has_permissions']:
Expand Down

0 comments on commit 37aef83

Please sign in to comment.