aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--accounts/templates/accounts/index.html58
-rw-r--r--accounts/views.py15
-rw-r--r--client/views.py2
-rw-r--r--manager/settings.py2
-rw-r--r--templates/registration/login.html26
-rw-r--r--version.txt2
6 files changed, 62 insertions, 43 deletions
diff --git a/accounts/templates/accounts/index.html b/accounts/templates/accounts/index.html
index ea9c160..2a21cbe 100644
--- a/accounts/templates/accounts/index.html
+++ b/accounts/templates/accounts/index.html
@@ -317,43 +317,45 @@
<div id="settings" class="row">
<div class="col l8 offset-l2 s12">
<div class="card-panel">
+ {% if midata_enabled %}
<div class="row">
<div class="col s12">
<h5>Collegamento con MiData</h5>
</div>
</div>
- {% if midata_user %}
- <div class="row">
- <div class="col s12">
- Il tuo utente è già connesso a MiData
- </div>
- <div class="col m6 s12">
- <a href={% url 'oauth_disconnect' %} style="width: 100%" class="btn waves-effect waves-light {{color}}">
- Scollega da MiData
- </a>
+ {% if midata_user %}
+ <div class="row">
+ <div class="col s12">
+ Il tuo utente è già connesso a MiData
+ </div>
+ <div class="col m6 s12">
+ <a href={% url 'oauth_disconnect' %} style="width: 100%" class="btn waves-effect waves-light {{color}}">
+ Scollega da MiData
+ </a>
+ </div>
</div>
- </div>
- {% else %}
- <div class="row">
- <div class="col s12">
- Collega il tuo account con MiData per avere un login unico. Attenzione una volta collegato il
- tuo account i dati presenti su MiData dovranno essere modificati sulla piattaforma stessa.
+ {% else %}
+ <div class="row">
+ <div class="col s12">
+ Collega il tuo account con MiData per avere un login unico. Attenzione una volta collegato il
+ tuo account i dati presenti su MiData dovranno essere modificati sulla piattaforma stessa.
+ </div>
</div>
- </div>
- <div class="row">
- <div class="col m6 s12">
- <a href={% url 'oauth_connect' %} style="width: 100%; background-color: #99BF62" class="btn waves-effect waves-light">
- <div class="row">
- <div class="col s2">
- <img style="height: 30px; padding-top: 3px" src="{% static 'pbs_logo.svg' %}" alt="PBS Logo">
- </div>
- <div class="col s10">
- Collega a MiData
+ <div class="row">
+ <div class="col m6 s12">
+ <a href={% url 'oauth_connect' %} style="width: 100%; background-color: #99BF62" class="btn waves-effect waves-light">
+ <div class="row">
+ <div class="col s2">
+ <img style="height: 30px; padding-top: 3px" src="{% static 'pbs_logo.svg' %}" alt="PBS Logo">
+ </div>
+ <div class="col s10">
+ Collega a MiData
+ </div>
</div>
- </div>
- </a>
+ </a>
+ </div>
</div>
- </div>
+ {% endif %}
{% endif %}
<div class="row">
<div class="col s12">
diff --git a/accounts/views.py b/accounts/views.py
index 2455d73..cd17552 100644
--- a/accounts/views.py
+++ b/accounts/views.py
@@ -30,6 +30,7 @@ from pdf2image.exceptions import (
oauth = OAuth()
hitobito = oauth.register(name="hitobito")
api_url = settings.AUTHLIB_OAUTH_CLIENTS["hitobito"]["api_url"]
+MIDATA_ENABLED = settings.OAUTH_ENABLED
# override to remove help text
class RegisterForm(UserCreationForm):
@@ -96,9 +97,13 @@ def copy_from_midata(request, usercode):
class CustomLoginView(LoginView):
form_class = AuthForm
+ extra_context = {'midata_enabled': MIDATA_ENABLED}
# send to hitobito request to get token
def oauth_login(request):
+ if not MIDATA_ENABLED:
+ return None
+
redirect_uri = request.build_absolute_uri(reverse('auth'))
# forward next page requested by user
@@ -111,6 +116,9 @@ def oauth_login(request):
# callback after acquiring token
def auth(request):
+ if not MIDATA_ENABLED:
+ return None
+
token = hitobito.authorize_access_token(request)
# request data from user account
@@ -152,6 +160,9 @@ def auth(request):
# send to hitobito request to get token
@login_required
def oauth_connect(request):
+ if not MIDATA_ENABLED:
+ return None
+
redirect_uri = request.build_absolute_uri(reverse('auth_connect'))
return hitobito.authorize_redirect(request, redirect_uri)
@@ -171,6 +182,9 @@ def oauth_disconnect(request):
# callback after acquiring token
@login_required
def auth_connect(request):
+ if not MIDATA_ENABLED:
+ return None
+
token = hitobito.authorize_access_token(request)
# request data from user account
@@ -603,6 +617,7 @@ def personal_wrapper(request, errors):
'usable_password': usable_password,
'settings_active': settings_active,
'personal_active': personal_active,
+ 'midata_enabled': MIDATA_ENABLED,
}
return render(request, 'accounts/index.html', context)
diff --git a/client/views.py b/client/views.py
index 992f7dd..0f1bfaa 100644
--- a/client/views.py
+++ b/client/views.py
@@ -331,7 +331,5 @@ def about(request):
if version.startswith("0"):
version = "Beta " + version
- # get commitid using git command, a bit hacky but works
-
context = {"version": version, "commitid": settings.COMMIT_ID}
return render(request, 'client/about.html', context)
diff --git a/manager/settings.py b/manager/settings.py
index 7649631..3432ae0 100644
--- a/manager/settings.py
+++ b/manager/settings.py
@@ -52,6 +52,8 @@ with open("version.txt", 'r') as f:
BRANCH = check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"]).decode()
COMMIT_ID = check_output(["git", "rev-parse", "HEAD"]).decode()
+OAUTH_ENABLED = True
+
# Application definition
INSTALLED_APPS = [
diff --git a/templates/registration/login.html b/templates/registration/login.html
index 9ed5ac4..c9b5362 100644
--- a/templates/registration/login.html
+++ b/templates/registration/login.html
@@ -39,20 +39,22 @@
<br>
<button class="btn waves-effect waves-light {{color}}" type="submit">Login</button>
<br><br><hr><br>
- <div class="row">
- <div class="col s12">
- <a href="{% url 'oauth_login' %}?next={{ request.GET.next }}" style="width: 100%; background-color: #99BF62" class="btn waves-effect waves-light">
- <div class="row">
- <div class="col s2">
- <img style="height: 30px; padding-top: 3px" src="{% static 'pbs_logo.svg' %}" alt="PBS Logo">
- </div>
- <div class="col s10">
- Login con MiData
+ {% if midata_enabled %}
+ <div class="row">
+ <div class="col s12">
+ <a href="{% url 'oauth_login' %}?next={{ request.GET.next }}" style="width: 100%; background-color: #99BF62" class="btn waves-effect waves-light">
+ <div class="row">
+ <div class="col s2">
+ <img style="height: 30px; padding-top: 3px" src="{% static 'pbs_logo.svg' %}" alt="PBS Logo">
+ </div>
+ <div class="col s10">
+ Login con MiData
+ </div>
</div>
- </div>
- </a>
+ </a>
+ </div>
</div>
- </div>
+ {% endif %}
<div class="row">
<div class="col s12">
<a href={% url 'signup' %} style="width: 100%" class="btn waves-effect waves-light {{color}}">
diff --git a/version.txt b/version.txt
index 8c31964..56eed72 100644
--- a/version.txt
+++ b/version.txt
@@ -1,2 +1,2 @@
version=0.4
-rev=21
+rev=22