Skip to content
This repository has been archived by the owner on Jun 12, 2020. It is now read-only.

Commit

Permalink
Merge pull request #45 from industrydive/TECH-8231-reenable-login-for…
Browse files Browse the repository at this point in the history
…-test-envs

TECH-8231 reenable login for test envs
  • Loading branch information
greglinch authored May 15, 2020
2 parents e384401 + 5c67d21 commit 0515dbc
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
4 changes: 0 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
This is an open-source tool for creating a database of sources.

(hat tip to Digital Ocean [Django](https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-16-04) and [Postgres](https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04))

https://docs.bitnami.com/google/infrastructure/django/get-started/start-django-project/

# Developer Setup

The following instructions are intended for a developer to set this up locally
Expand Down
1 change: 1 addition & 0 deletions sourcedive/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
'django.contrib.messages.context_processors.messages',
'social_django.context_processors.backends',
'social_django.context_processors.login_redirect',
'sources.context_processors.sources_context_processor'
],
},
},
Expand Down
8 changes: 8 additions & 0 deletions sources/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.conf import settings


def sources_context_processor(request):
context = {}
context['test_env'] = settings.TEST_ENV

return context
3 changes: 3 additions & 0 deletions templates/admin/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<a href="{{ docsroot }}">{% trans 'Documentation' %}</a> /
{% endif %}
{% endif %}
{% if user.has_usable_password and test_env %}
<a href="{% url 'admin:password_change' %}">Change password</a> /
{% endif %}
<a href="{% url 'admin:logout' %}">{% trans 'Log out' %}</a>
{% endblock %}
</div>
Expand Down
27 changes: 27 additions & 0 deletions templates/admin/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,33 @@
<div style="text-align: center;">
<a class="button" href="{% url 'social:begin' 'google-oauth2' %}">Log in with Gmail</a>
</div>
{% if test_env %}
<br>
<hr>
<br>
<div id="login-toggle" style="text-align: center;">
<a class="button" href="#">Enter credentials</a>
</div>
<form action="{{ app_path }}" method="post" id="login-form">{% csrf_token %}
<div class="form-row">
{{ form.username.errors }}
{{ form.username.label_tag }} {{ form.username }}
</div>
<div class="form-row">
{{ form.password.errors }}
{{ form.password.label_tag }} {{ form.password }}
<input type="hidden" name="next" value="{{ next }}" />
</div>
{% url 'admin_password_reset' as password_reset_url %}
{% if password_reset_url %}
<div class="password-reset-link">
<a href="{{ password_reset_url }}">{% trans 'Forgotten your password or username?' %}</a>
</div>
{% endif %}
<div class="submit-row">
<label>&nbsp;</label><input type="submit" value="{% trans 'Log in' %}" />
</div>
{% endif %}
</form>
</div>
{% endblock %}

0 comments on commit 0515dbc

Please sign in to comment.