mirror of
				https://github.com/cookiecutter/cookiecutter-django.git
				synced 2025-11-01 00:17:54 +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.tz", | ||||
|                 "django.contrib.messages.context_processors.messages", | ||||
|                 "{{cookiecutter.project_slug}}.users.context_processors.allauth_settings", | ||||
|             ], | ||||
|         }, | ||||
|     } | ||||
|  |  | |||
|  | @ -13,25 +13,37 @@ | |||
| {% get_providers as socialaccount_providers %} | ||||
| 
 | ||||
| {% if socialaccount_providers %} | ||||
| <p>{% blocktranslate 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:{% endblocktranslate %}</p> | ||||
|   <p> | ||||
|     {% translate "Please sign in with one of your existing third party accounts:" %} | ||||
|     {% 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"> | ||||
| 
 | ||||
|   <ul class="socialaccount_providers"> | ||||
|     {% include "socialaccount/snippets/provider_list.html" with process="login" %} | ||||
|   </ul> | ||||
|     <ul class="socialaccount_providers"> | ||||
|       {% include "socialaccount/snippets/provider_list.html" with process="login" %} | ||||
|     </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 %} | ||||
| <p>{% blocktranslate %}If you have not created an account yet, then please | ||||
| <a href="{{ signup_url }}">sign up</a> first.{% endblocktranslate %}</p> | ||||
|   {% if ACCOUNT_ALLOW_REGISTRATION %} | ||||
|     <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 %} | ||||
| 
 | ||||
| <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> | ||||
|                 </li> | ||||
|               {% else %} | ||||
|                 <li class="nav-item"> | ||||
|                   {# URL provided by django-allauth/account/urls.py #} | ||||
|                   <a id="sign-up-link" class="nav-link" href="{% url 'account_signup' %}">{% translate "Sign Up" %}</a> | ||||
|                 </li> | ||||
|                 {% 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' %}">{% translate "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' %}">{% 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