Skip to content

Commit

Permalink
Unconditionally use tenant_url template tag
Browse files Browse the repository at this point in the history
because we've already decided that this distribution will be
MT/Postgres only and everything is enabled unconditionally it
doesn't make sense for the existing wrappers anymore.
  • Loading branch information
atodorov committed Mar 15, 2020
1 parent 4624593 commit 4b9aeff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
29 changes: 3 additions & 26 deletions tcms_enterprise/templatetags/enterprise_tags.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Copyright (c) 2019 Alexander Todorov <atodorov@MrSenko.com>
# Copyright (c) 2019-2020 Alexander Todorov <atodorov@MrSenko.com>

# Licensed under the GPL 3.0: https://www.gnu.org/licenses/gpl-3.0.txt

import os
from django import template
from django.db import connection
from django.urls import reverse
Expand All @@ -21,30 +20,8 @@ def next_url(request):
"""
next = request.GET.get('next', '/')

if (os.environ.get('KIWI_DB_ENGINE', '').find('postgresql') > -1) and (connection.schema_name != 'public'):
try:
from tcms_tenants import urls
if connection.schema_name != 'public':
next = reverse('tcms_tenants:redirect-to', args=[connection.schema_name, next])

next = reverse('tcms_tenants:redirect-to', args=[connection.schema_name, next])
except ImportError:
pass
# handle double slashes in case we want to redirect to tenant's root
return next.replace('//', '/')


@register.simple_tag
def next_domain(request, schema_name = None):
"""
Return the domain through we are going to redirect if
tenants are configured and installed. Otherwise we go
directly to the current domain.
"""
if (os.environ.get('KIWI_DB_ENGINE', '').find('postgresql') > -1):
try:
from tcms_tenants.templatetags.tcms_tenants import tenant_url

return tenant_url(request, schema_name)
except ImportError:
pass

return ''
3 changes: 2 additions & 1 deletion templates.d/registration/custom_login.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends "registration/login.html" %}
{% load static %}
{% load tcms_tenants %}
{% load enterprise_tags %}

{% block custom_login %}
Expand All @@ -9,7 +10,7 @@
</p>

{% for backend in backends.backends %}
<a href='{% next_domain request "public" %}{% url "social:begin" backend|lower %}?next={% next_url request %}'>
<a href='{% tenant_url request "public" %}{% url "social:begin" backend|lower %}?next={% next_url request %}'>
{% with "images/social_auth/backends/"|add:backend|lower|add:".png" as image_path %}
<img src='{% static image_path %}' alt="{{ backend|title }} login" title="{{ backend|title }} login">
{% endwith %}
Expand Down

0 comments on commit 4b9aeff

Please sign in to comment.