mirror of
				https://github.com/cookiecutter/cookiecutter-django.git
				synced 2025-11-04 01:47:28 +03:00 
			
		
		
		
	Hides 'sign up' elements when ACCOUNT_ALLOW_REGISTRATION is disabled (#1914)
Co-authored-by: Bruno Alla <alla.brunoo@gmail.com>
This commit is contained in:
		
							parent
							
								
									c007f46dbe
								
							
						
					
					
						commit
						785df85c4d
					
				| 
						 | 
					@ -197,6 +197,7 @@ TEMPLATES = [
 | 
				
			||||||
                "django.template.context_processors.static",
 | 
					                "django.template.context_processors.static",
 | 
				
			||||||
                "django.template.context_processors.tz",
 | 
					                "django.template.context_processors.tz",
 | 
				
			||||||
                "django.contrib.messages.context_processors.messages",
 | 
					                "django.contrib.messages.context_processors.messages",
 | 
				
			||||||
 | 
					                "{{cookiecutter.project_slug}}.users.context_processors.allauth_settings",
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,9 +13,15 @@
 | 
				
			||||||
{% get_providers as socialaccount_providers %}
 | 
					{% get_providers as socialaccount_providers %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% if socialaccount_providers %}
 | 
					{% if socialaccount_providers %}
 | 
				
			||||||
<p>{% blocktranslate with site.name as site_name %}Please sign in with one
 | 
					  <p>
 | 
				
			||||||
of your existing third party accounts. Or, <a href="{{ signup_url }}">sign up</a>
 | 
					    {% translate "Please sign in with one of your existing third party accounts:" %}
 | 
				
			||||||
for a {{ site_name }} account and sign in below:{% endblocktranslate %}</p>
 | 
					    {% if ACCOUNT_ALLOW_REGISTRATION %}
 | 
				
			||||||
 | 
					      {% blocktranslate trimmed %}
 | 
				
			||||||
 | 
					        Or, <a href="{{ signup_url }}">sign up</a>
 | 
				
			||||||
 | 
					        for a {{ site_name }} account and sign in below:
 | 
				
			||||||
 | 
					      {% endblocktranslate %}
 | 
				
			||||||
 | 
					    {% endif %}
 | 
				
			||||||
 | 
					  </p>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <div class="socialaccount_ballot">
 | 
					  <div class="socialaccount_ballot">
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,15 +29,21 @@ for a {{ site_name }} account and sign in below:{% endblocktranslate %}</p>
 | 
				
			||||||
      {% include "socialaccount/snippets/provider_list.html" with process="login" %}
 | 
					      {% include "socialaccount/snippets/provider_list.html" with process="login" %}
 | 
				
			||||||
    </ul>
 | 
					    </ul>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <div class="login-or">{% translate 'or' %}</div>
 | 
					    <div class="login-or">{% translate "or" %}</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  {% include "socialaccount/snippets/login_extra.html" %}
 | 
					  {% include "socialaccount/snippets/login_extra.html" %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% else %}
 | 
					{% else %}
 | 
				
			||||||
<p>{% blocktranslate %}If you have not created an account yet, then please
 | 
					  {% if ACCOUNT_ALLOW_REGISTRATION %}
 | 
				
			||||||
<a href="{{ signup_url }}">sign up</a> first.{% endblocktranslate %}</p>
 | 
					    <p>
 | 
				
			||||||
 | 
					      {% blocktranslate trimmed %}
 | 
				
			||||||
 | 
					        If you have not created an account yet, then please
 | 
				
			||||||
 | 
					        <a href="{{ signup_url }}">sign up</a> first.
 | 
				
			||||||
 | 
					      {% endblocktranslate %}
 | 
				
			||||||
 | 
					    </p>
 | 
				
			||||||
 | 
					  {% endif %}
 | 
				
			||||||
{% endif %}
 | 
					{% endif %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<form class="login" method="POST" action="{% url 'account_login' %}">
 | 
					<form class="login" method="POST" action="{% url 'account_login' %}">
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -79,10 +79,12 @@
 | 
				
			||||||
                  <a class="nav-link" href="{% url 'account_logout' %}">{% translate "Sign Out" %}</a>
 | 
					                  <a class="nav-link" href="{% url 'account_logout' %}">{% translate "Sign Out" %}</a>
 | 
				
			||||||
                </li>
 | 
					                </li>
 | 
				
			||||||
              {% else %}
 | 
					              {% else %}
 | 
				
			||||||
 | 
					                {% if ACCOUNT_ALLOW_REGISTRATION %}
 | 
				
			||||||
              <li class="nav-item">
 | 
					              <li class="nav-item">
 | 
				
			||||||
                {# URL provided by django-allauth/account/urls.py #}
 | 
					                {# URL provided by django-allauth/account/urls.py #}
 | 
				
			||||||
                <a id="sign-up-link" class="nav-link" href="{% url 'account_signup' %}">{% translate "Sign Up" %}</a>
 | 
					                <a id="sign-up-link" class="nav-link" href="{% url 'account_signup' %}">{% translate "Sign Up" %}</a>
 | 
				
			||||||
              </li>
 | 
					              </li>
 | 
				
			||||||
 | 
					              {% endif %}
 | 
				
			||||||
                <li class="nav-item">
 | 
					                <li class="nav-item">
 | 
				
			||||||
                  {# URL provided by django-allauth/account/urls.py #}
 | 
					                  {# URL provided by django-allauth/account/urls.py #}
 | 
				
			||||||
                  <a id="log-in-link" class="nav-link" href="{% url 'account_login' %}">{% translate "Sign In" %}</a>
 | 
					                  <a id="log-in-link" class="nav-link" href="{% url 'account_login' %}">{% translate "Sign In" %}</a>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,8 @@
 | 
				
			||||||
 | 
					from django.conf import settings
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def allauth_settings(request):
 | 
				
			||||||
 | 
					    """Expose some settings from django-allauth in templates."""
 | 
				
			||||||
 | 
					    return {
 | 
				
			||||||
 | 
					        "ACCOUNT_ALLOW_REGISTRATION": settings.ACCOUNT_ALLOW_REGISTRATION,
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user