Commit e95998d9 authored by David Seaward's avatar David Seaward

add download link for ovpn file (see #28 )

* parameterised variable for file location
* link to instructions PDF
* SITE_DOMAIN is part of user identity
parent 45940925
......@@ -4,6 +4,7 @@
[settings]
SITE_TITLE = Title
SITE_BYLINE = Example byline
SITE_DOMAIN = example.com
DEBUG = True
ALLOWED_HOSTS = localhost
STATIC_ROOT = /var/opt/purist/account/static
......@@ -17,7 +18,7 @@ AUTH_LDAP_START_TLS = True
AUTH_LDAP_BIND_DN = cn=admin,dc=example,dc=com
AUTH_LDAP_USER_SEARCH_BASE_DN = ou=people,dc=example,dc=com
SQLITE_DB_PATH = /var/opt/purist/account/db.sqlite3
STATICFILES_DIRS = /var/opt/purist/brand
STATICFILES_DIRS = /var/opt/purist/brand,/var/opt/purist/downloads
WOO_URL = https://example.com
WOO_WP_API = True
WOO_VERSION = wc/v1
......@@ -27,3 +28,4 @@ WOO1_EMAIL_SUFFIX = @example.com
OVPN_HOSTNAME = ssh.example.com
OVPN_PORT = 22
OVPN_USERNAME = username
OVPN_FILEPATH = "/path/to/{IDENTITY}/{IDENTITY}.ovpn"
......@@ -47,16 +47,16 @@ SPDX-License-Identifier: CC-BY-SA-4.0
<div id="main">
<article>
<h2>Services</h2>
<h2>{% trans "Services" %}</h2>
<table style="border-collapse: collapse;">
<thead>
<tr>
<th>Service</th>
<th>Active</th>
<th>Expires</th>
<th>Credit</th>
<th>{% trans "Service" %}</th>
<th>{% trans "Active" %}</th>
<th>{% trans "Expires" %}</th>
<th>{% trans "Credit" %}</th>
</tr>
</thead>
......@@ -75,12 +75,20 @@ SPDX-License-Identifier: CC-BY-SA-4.0
</table>
<h2>Profile management</h2>
<h2>{% trans "Profile management" %}</h2>
<ul>
<li><a href="{% url 'auth_password_change' %}">{% trans "Change password" %}</a></li>
</ul>
<h2>{% trans "Downloads" %}</h2>
<ul>
<li><a href="{% url 'ovpn_userfile' %}">{% trans "Tunnel certificate" %}</a></li>
<li><a href="{% static 'tunnel_instructions.pdf' %}">{% trans "How to use Tunnel certificate (PDF)" %}</a>
</li>
</ul>
</article>
</div>
......
from django.conf import settings
from django.contrib.auth.decorators import login_required
from django.http import FileResponse
from django.shortcuts import render
from .models import Limit
@login_required
def userlimit(request):
username = request.user.get_username()
limits = Limit.objects.filter(user__username=username)
......@@ -16,3 +19,12 @@ def userlimit(request):
}
return render(request, 'limitmonitor/userlimit.html', render_data)
@login_required
def ovpn_userfile(request):
username = request.user.get_username()
identity = username + "@" + settings.SITE_DOMAIN
filepath = settings.OVPN_FILEPATH.replace("{IDENTITY}", identity)
return FileResponse(open(filepath, 'rb'))
......@@ -109,6 +109,7 @@ STATIC_ROOT = config("STATIC_ROOT")
STATICFILES_DIRS = config("STATICFILES_DIRS", cast=Csv())
SITE_TITLE = config("SITE_TITLE")
SITE_BYLINE = config("SITE_BYLINE")
SITE_DOMAIN = config("SITE_DOMAIN")
#
# WOOCOMMERCE
......@@ -137,3 +138,4 @@ WOO1_FIELD_LIST = config("WOO1_FIELD_LIST", cast=Csv())
OVPN_HOSTNAME = config("OVPN_HOSTNAME")
OVPN_PORT = config("OVPN_PORT", cast=int)
OVPN_USERNAME = config("OVPN_USERNAME")
OVPN_FILEPATH = config("OVPN_FILEPATH")
......@@ -38,6 +38,7 @@ urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^accounts/$', RedirectView.as_view(url='/')),
url(r'^accounts/profile/$', limitmonitor.views.userlimit, name='profile'),
url(r'^accounts/profile/purist.ovpn', limitmonitor.views.ovpn_userfile, name='ovpn_userfile'),
url(r'^accounts/register/$', RegistrationView.as_view(form_class=RegistrationForm), name='registration_register'),
url(r'^accounts/', include('registration.backends.simple.urls')),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment