Don't show signup link if disable_signup.

master
Nick Sergeant 2016-11-02 16:50:50 -04:00
parent c438c1e2e0
commit 860f1afca5
2 changed files with 14 additions and 6 deletions

View File

@ -1,4 +1,5 @@
import hashlib
import os
from django import template
from snipts.models import Favorite, Snipt
@ -42,6 +43,12 @@ def snipts_count_for_user(context):
return snipts
@tag(register, [Constant('as'), Variable()])
def signup_enabled(context, asvar):
context[asvar] = os.environ.get("DISABLE_SIGNUP") != "true"
return ''
@tag(register, [Constant('as'), Variable()])
def get_lexers(context, asvar):
context[asvar] = get_lexers_list()

View File

@ -1,5 +1,7 @@
{% load snipt_tags static %}
{% signup_enabled as 'signup_is_enabled' %}
<!DOCTYPE html>
<html lang="en" class="{% block html-class %}{% endblock %}" ng-app="Snipt">
<head>
@ -92,6 +94,11 @@
<li>
<a href="/login/?next={{ request.path }}" {% if '/login/' in request.path %} class="active"{% endif %}>Log in</a>
</li>
{% if signup_is_enabled %}
<li>
<a href="/signup/" {% if '/signup/' in request.path %} class="active"{% endif %}>Sign up</a>
</li>
{% endif %}
{% else %}
<li>
<a href="/{{ request.user.username }}/" {% if request.user.username in request.path %} class="active"{% endif %}>My snipts</a>
@ -165,12 +172,6 @@
Account
</a>
</li>
<li>
<a href="/for-teams/">
<i class="icon-star-empty icon-white"></i>
For Teams
</a>
</li>
{% if request.user.is_superuser %}
<li>
<a href="/admin/">