Hides 'sign up' elements when ACCOUNT_ALLOW_REGISTRATION is disabled

This commit is contained in:
Will Gordon 2019-01-29 18:14:54 -05:00
parent 66b1468fda
commit 3b20e4985b
5 changed files with 33 additions and 12 deletions

View File

@ -175,6 +175,7 @@ Listed in alphabetical order.
Vivian Guillen `@viviangb`_
Will Farley `@goldhand`_ @g01dhand
William Archinal `@archinal`_
Will Gordon `@wgordon17` @wpg4665
Yaroslav Halchenko
Denis Bobrov `@delneg`_
Philipp Matthies `@canonnervio`_
@ -291,6 +292,7 @@ Listed in alphabetical order.
.. _@brentpayne: https://github.com/brentpayne
.. _@afrowave: https://github.com/afrowave
.. _@pchiquet: https://github.com/pchiquet
.. _@wgordon17: https://github.com/wgordon17
.. _@delneg: https://github.com/delneg
.. _@purplediane: https://github.com/purplediane
.. _@umrashrf: https://github.com/umrashrf

View File

@ -195,6 +195,7 @@ TEMPLATES = [
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'{{cookiecutter.project_slug}}.users.context_processors.allauth_settings',
],
},
},

View File

@ -13,9 +13,8 @@
{% get_providers as socialaccount_providers %}
{% if socialaccount_providers %}
<p>{% blocktrans with site.name as site_name %}Please sign in with one
of your existing third party accounts. Or, <a href="{{ signup_url }}">sign up</a>
for a {{ site_name }} account and sign in below:{% endblocktrans %}</p>
<p>{% blocktrans %}Please sign in with one of your existing
third party accounts:{% endblocktrans %}</p>
<div class="socialaccount_ballot">
@ -23,16 +22,25 @@ for a {{ site_name }} account and sign in below:{% endblocktrans %}</p>
{% include "socialaccount/snippets/provider_list.html" with process="login" %}
</ul>
<div class="login-or">{% trans 'or' %}</div>
<div class="login-or">
{% if ACCOUNT_ALLOW_REGISTRATION %}
<p>{% blocktrans with site.name as site_name %}Or <a href="{{ signup_url }}">sign up</a>
for a {{ site_name }} account and sign in below:{% endblocktrans %}</p>
{% else %}
<p>{% blocktrans %}Or sign in below:{% endblocktrans %}</p>
{% endif %}
</div>
</div>
{% include "socialaccount/snippets/login_extra.html" %}
{% else %}
{% if ACCOUNT_ALLOW_REGISTRATION %}
<p>{% blocktrans %}If you have not created an account yet, then please
<a href="{{ signup_url }}">sign up</a> first.{% endblocktrans %}</p>
{% endif %}
{% endif %}
<form class="login" method="POST" action="{% url 'account_login' %}">
{% csrf_token %}

View File

@ -61,10 +61,12 @@
<a class="nav-link" href="{% url 'account_logout' %}">{% trans "Sign Out" %}</a>
</li>
{% else %}
{% if ACCOUNT_ALLOW_REGISTRATION %}
<li class="nav-item">
{# URL provided by django-allauth/account/urls.py #}
<a id="sign-up-link" class="nav-link" href="{% url 'account_signup' %}">{% trans "Sign Up" %}</a>
</li>
{% endif %}
<li class="nav-item">
{# URL provided by django-allauth/account/urls.py #}
<a id="log-in-link" class="nav-link" href="{% url 'account_login' %}">{% trans "Sign In" %}</a>

View File

@ -0,0 +1,8 @@
from django.conf import settings
def allauth_settings(request):
# return any necessary values
return {
'ACCOUNT_ALLOW_REGISTRATION': settings.ACCOUNT_ALLOW_REGISTRATION
}