clean templates, add userdetail and proper landing page
This commit is contained in:
parent
413728b24f
commit
96ff186913
13 changed files with 253 additions and 80 deletions
|
|
@ -32,7 +32,13 @@ class MemberValues(object):
|
|||
self._new = copy.deepcopy(self._old)
|
||||
|
||||
def get(self, key, default=None):
|
||||
value = self._new.get(key, default)[0]
|
||||
value_list = self._new.get(key, default)
|
||||
if value_list:
|
||||
value = value_list[0]
|
||||
else:
|
||||
value = default
|
||||
|
||||
# Decode
|
||||
if value == 'TRUE':
|
||||
return True
|
||||
elif value == 'FALSE':
|
||||
|
|
@ -78,6 +84,12 @@ class MemberValues(object):
|
|||
result = l.modify_s(dn, mod_attrs)
|
||||
print "result is: ", result
|
||||
|
||||
def to_dict(self):
|
||||
result = {}
|
||||
for key, value in self._new.items():
|
||||
result[key] = self.get(key)
|
||||
return result
|
||||
|
||||
def _get_bind_dn(self):
|
||||
"""
|
||||
Adds the uid=userid, to the base dn and returns that.
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class WlanPresenceForm(forms.Form):
|
|||
help_text=_('Enable WiFi presence?'))
|
||||
|
||||
|
||||
class PaswordForm(forms.Form):
|
||||
class PasswordForm(forms.Form):
|
||||
password1 = forms.CharField(max_length=255, widget=forms.PasswordInput,
|
||||
help_text=_('New password'))
|
||||
password2 = forms.CharField(max_length=255, widget=forms.PasswordInput,
|
||||
|
|
@ -42,6 +42,9 @@ class PaswordForm(forms.Form):
|
|||
class RFIDForm(forms.Form):
|
||||
rfid = forms.CharField(max_length=255, help_text=_('Your RFID'))
|
||||
|
||||
class SIPPinForm(forms.Form):
|
||||
sippin = forms.CharField(max_length=255, help_text=_('Your SIP PIN'))
|
||||
|
||||
|
||||
class NRF24Form(forms.Form):
|
||||
nrf24 = forms.CharField(max_length=255,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "base.html" %}
|
||||
{% extends "member_base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block container %}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,23 @@
|
|||
{% extends "base.html" %}
|
||||
{% extends "form_base.html" %}
|
||||
{% load i18n %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<h2>Gastro-Pin</h2>
|
||||
{% if message %}
|
||||
<div class="alert alert-success">{{ message }}</div>
|
||||
{% endif %}
|
||||
<form action="/gastropin/" method="post">
|
||||
{{ form.non_field_errors }}
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% block form_title %}{% trans "Gastro PIN"%}{% endblock %}
|
||||
|
||||
{% block form_description %}
|
||||
<p>{% blocktrans %}Change your Gastro PIN to access the vending machines.{% endblocktrans %}</p>
|
||||
{% endblock %}
|
||||
|
||||
{% block form_fields %}
|
||||
{{ form.non_field_errors }}
|
||||
<form action="{% url account.views.gastropin %}" method="post" class="form-horizontal well">
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<button type="submit" class="btn btn-primary">{% trans "Save"%}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock form_fields %}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
|
|
@ -7,11 +9,15 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="span">
|
||||
<form class="form" action="/account/login/?next={{ redirect_to }}" method="post">
|
||||
<div class="well">
|
||||
<form class="form form-horizontal" action="/account/login/?next={{ redirect_to }}" method="post">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<input class="btn" type="submit" value="login"/>
|
||||
{{ form|crispy }}
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<button type="submit" class="btn btn-primary">{% trans "Login" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
43
account/templates/member_base.html
Normal file
43
account/templates/member_base.html
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
<ul class="nav nav-tabs">
|
||||
{% url account.views.home as home_url %}
|
||||
<li class="{% if request.path == home_url %}active{% endif %}">
|
||||
<a href="{{ home_url }}">{% trans "Home" %}</a>
|
||||
</li>
|
||||
{% url account.views.password as password_url %}
|
||||
<li class="{% if request.path == password_url %}active{% endif %}">
|
||||
<a href="{{ password_url }}">{% trans "Password" %}</a>
|
||||
</li>
|
||||
{% url account.views.gastropin as gastro_url %}
|
||||
<li class="{% if request.path == gastro_url %}active{% endif %}">
|
||||
<a href="{{ gastro_url }}">{% trans "Gastro-PIN" %}</a>
|
||||
</li>
|
||||
{% url account.views.wlan_presence as wlan_presence_url %}
|
||||
<li class="{% if request.path == wlan_presence_url %}active{% endif %}">
|
||||
<a href="{{ wlan_presence_url }}">{% trans "WiFi presence" %}</a>
|
||||
</li>
|
||||
{% url account.views.rfid as rfid_url %}
|
||||
<li class="{% if request.path == rfid_url %}active{% endif %}">
|
||||
<a href="{{ rfid_url }}">{% trans "RFID" %}</a>
|
||||
</li>
|
||||
{% url account.views.nrf24 as nrf24_url %}
|
||||
<li class="{% if request.path == nrf24_url %}active{% endif %}">
|
||||
<a href="{{ nrf24_url }}">{% trans "NRF24" %}</a>
|
||||
</li>
|
||||
{% url account.views.sippin as sippin_url %}
|
||||
<li class="{% if request.path == sippin_url %}active{% endif %}">
|
||||
<a href="{{ sippin_url }}">{% trans "SIP-PIN" %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% block container %}{% endblock container %}
|
||||
|
||||
<hr />
|
||||
<div class="row pull-right">
|
||||
<small class="muted">Copyright © 2013 by c-base e.V.</small>
|
||||
</div>
|
||||
</div><!-- /.container -->
|
||||
{% endblock body %}
|
||||
23
account/templates/password.html
Normal file
23
account/templates/password.html
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{% extends "form_base.html" %}
|
||||
{% load i18n %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
{% block form_title %}{% trans "Password"%}{% endblock %}
|
||||
|
||||
{% block form_description %}
|
||||
<p>{% blocktrans %}You can change your password here.{% endblocktrans %}</p>
|
||||
{% endblock %}
|
||||
|
||||
{% block form_fields %}
|
||||
{{ form.non_field_errors }}
|
||||
<form action="{% url account.views.password %}" method="post" class="form-horizontal well">
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<button type="submit" class="btn btn-primary">{% trans "Save"%}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock form_fields %}
|
||||
23
account/templates/sippin.html
Normal file
23
account/templates/sippin.html
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{% extends "form_base.html" %}
|
||||
{% load i18n %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
{% block form_title %}{% trans "SIP PIN"%}{% endblock %}
|
||||
|
||||
{% block form_description %}
|
||||
<p>{% blocktrans %}The SIP PIN is your access to the c-base SIP server for voice telephony.{% endblocktrans %}</p>
|
||||
{% endblock %}
|
||||
|
||||
{% block form_fields %}
|
||||
{{ form.non_field_errors }}
|
||||
<form action="{% url account.views.sippin %}" method="post" class="form-horizontal well">
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<button type="submit" class="btn btn-primary">{% trans "Save"%}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock form_fields %}
|
||||
51
account/templates/start.html
Normal file
51
account/templates/start.html
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
{% extends "member_base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block container %}
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<h2>{% trans "Welcome to the c-base member interface" %}</h2>
|
||||
<p class="lead">{% blocktrans %}Here you can change
|
||||
some parameters of your c-base member account.{% endblocktrans %}</p>
|
||||
|
||||
<h3>{% trans "Basic information about your account" %}</h3>
|
||||
|
||||
<ul>
|
||||
|
||||
<li>{% trans "Your user ID:" %}
|
||||
<code>{{ member.uid }}</code></li>
|
||||
<li>{% trans "Numeric user ID:" %}
|
||||
<code>{{ member.uidNumber }}</code><br />
|
||||
<span class="muted">{% blocktrans %}The numeric user ID can be used to login with
|
||||
the vending machines and network connected combination
|
||||
locks.{% endblocktrans %}</span></li>
|
||||
<li>
|
||||
{% trans "Your c-base e-mail address:" %}
|
||||
<code>{{ member.mail }}</code>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>{% trans "Management information" %}</h3>
|
||||
|
||||
<ul>
|
||||
<li>{% trans "Name:" %}
|
||||
{{ member.displayName }}
|
||||
</li>
|
||||
<li>
|
||||
{% trans "External e-mail address:" %}
|
||||
{{ member.externalEmail }}<br>
|
||||
<span class="muted">{% blocktrans %}The external e-mail address is used by the
|
||||
board of c-base to reach you in cases where your c-base
|
||||
address (see above) is not working. To change your
|
||||
externe e-mail address please contact the c-base board
|
||||
(<a href="mailto:vorstand@c-base.org">vorstand@c-base.org</a>).{% endblocktrans %}</span>
|
||||
</li>
|
||||
<li>
|
||||
{% trans "Your c-base member account balance:" %}
|
||||
<a class="btn btn-small" href="https://vorstand.c-base.org/member/">{% trans "Check balance" %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
{% endblock container %}
|
||||
|
|
@ -3,11 +3,14 @@ from django.conf.urls import patterns, url
|
|||
|
||||
urlpatterns = patterns(
|
||||
'',
|
||||
url(r'^login/$', 'account.views.auth_login', name="auth_login"),
|
||||
url(r'^login/$', 'account.views.auth_login', name="cbase_auth_login"),
|
||||
url(r'^logout/$', 'account.views.auth_logout', name="auth_logout"),
|
||||
url(r'^gastropin/$', 'account.views.gastropin', name='gastropin'),
|
||||
url(r'^wlan_presence/$', 'account.views.wlan_presence', name='wlan_presence'),
|
||||
url(r'^rfid/$', 'account.views.rfid', name='rfid'),
|
||||
url(r'^nrf24/$', 'account.views.nrf24', name='rfid'),
|
||||
url(r'^nrf24/$', 'account.views.nrf24', name='nrf24'),
|
||||
url(r'^password/$', 'account.views.password', name='password'),
|
||||
url(r'^sippin/$', 'account.views.sippin', name='sippin'),
|
||||
url(r'^$', 'account.views.home', name="home"),
|
||||
url(r'^groups/(?P<group_name>[^/]+)/', 'account.views.groups_list'),
|
||||
)
|
||||
|
|
@ -12,10 +12,34 @@ from django.contrib.auth.models import Group
|
|||
from django.shortcuts import render
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from forms import GastroPinForm, WlanPresenceForm, LoginForm, PaswordForm, \
|
||||
RFIDForm, NRF24Form
|
||||
from forms import GastroPinForm, WlanPresenceForm, LoginForm, PasswordForm, \
|
||||
RFIDForm, NRF24Form, SIPPinForm
|
||||
from cbase_members import MemberValues, retrieve_member
|
||||
|
||||
|
||||
def landingpage(request):
|
||||
if request.user.is_authenticated():
|
||||
return HttpResponseRedirect('/account')
|
||||
form = LoginForm()
|
||||
is_ceymaster = is_admin = False
|
||||
if 'ceymaster' in [g.name for g in request.user.groups.all()]:
|
||||
is_ceymaster = True
|
||||
if 'ldap_admins' in [g.name for g in request.user.groups.all()]:
|
||||
is_admin = True
|
||||
groups = Group.objects.all()
|
||||
admins = Group.objects.get(name="ldap_admins").user_set.all()
|
||||
|
||||
# values = get_user_values(request.user.username, request.session['ldap_password'])
|
||||
#return render_to_response("dashboard.html", locals())
|
||||
return render(request, 'base.html', {'form': form, 'admins': admins})
|
||||
|
||||
@login_required
|
||||
def home(request):
|
||||
member = retrieve_member(request)
|
||||
context = {'member': member.to_dict()}
|
||||
print context
|
||||
return render(request, 'start.html', context)
|
||||
|
||||
def auth_login(request):
|
||||
redirect_to = request.GET.get('next', '') or '/'
|
||||
if request.method == 'POST':
|
||||
|
|
@ -44,6 +68,7 @@ def auth_login(request):
|
|||
return render_to_response('login.html',
|
||||
RequestContext(request, locals()))
|
||||
|
||||
@login_required
|
||||
def auth_logout(request):
|
||||
redirect_to = request.GET.get('next', '') or '/'
|
||||
logout(request)
|
||||
|
|
@ -51,19 +76,6 @@ def auth_logout(request):
|
|||
response.delete_cookie('sessionkey')
|
||||
return response
|
||||
|
||||
def landingpage(request):
|
||||
is_ceymaster = is_admin = False
|
||||
if 'ceymaster' in [g.name for g in request.user.groups.all()]:
|
||||
is_ceymaster = True
|
||||
if 'ldap_admins' in [g.name for g in request.user.groups.all()]:
|
||||
is_admin = True
|
||||
groups = Group.objects.all()
|
||||
admins = Group.objects.get(name="ldap_admins").user_set.all()
|
||||
if request.user.is_authenticated():
|
||||
# values = get_user_values(request.user.username, request.session['ldap_password'])
|
||||
return render_to_response("dashboard.html", locals())
|
||||
return render_to_response("base.html", locals())
|
||||
|
||||
@login_required(redirect_field_name="/" ,login_url="/account/login/")
|
||||
def groups_list(request, group_name):
|
||||
group = get_object_or_404(Group, name=group_name)
|
||||
|
|
@ -76,24 +88,13 @@ def groups_list(request, group_name):
|
|||
|
||||
@login_required
|
||||
def gastropin(request):
|
||||
if request.method == 'POST':
|
||||
form = GastroPinForm(request.POST)
|
||||
if form.is_valid():
|
||||
user = request.user
|
||||
user_profile = user.get_profile()
|
||||
user_profile.gastropin = form.cleaned_data['gastropin']
|
||||
user_profile.save()
|
||||
return render(request, 'gastropin.html',
|
||||
{'message': _('Your Gastro-PIN was changed. Thank you!'),
|
||||
'form:': form})
|
||||
else:
|
||||
return render(request, 'gastropin.html', {'form:': form})
|
||||
|
||||
else:
|
||||
form = GastroPinForm()
|
||||
|
||||
return render(request, 'gastropin.html', {'form': form})
|
||||
return set_ldap_field(request, GastroPinForm,
|
||||
[('gastropin', 'gastropin')], 'gastropin.html')
|
||||
|
||||
@login_required
|
||||
def sippin(request):
|
||||
return set_ldap_field(request, SIPPinForm, [('sippin', 'sippin')],
|
||||
'sippin.html')
|
||||
|
||||
def set_ldap_field(request, form_type, field_names, template_name):
|
||||
"""
|
||||
|
|
@ -135,4 +136,7 @@ def rfid(request):
|
|||
def nrf24(request):
|
||||
return set_ldap_field(request, NRF24Form, [('nrf24', 'nrf24')], 'nrf24.html')
|
||||
|
||||
@login_required
|
||||
def password(request):
|
||||
return set_ldap_field(request, PasswordForm, [('password1', 'password')], 'password.html')
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
{% load i18n %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
|
|
@ -64,33 +66,18 @@
|
|||
<br/>
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
<ul class="nav nav-tabs">
|
||||
{% url cbmi.views.landingpage as landing_page_url %}
|
||||
<li class="{% if request.path == landing_page_url %}active{% endif %}">
|
||||
<a href="{{ landing_page_url }}">{% trans "Home" %}</a>
|
||||
</li>
|
||||
{% url account.views.wlan_presence as wlan_presence_url %}
|
||||
<li class="{% if request.path == wlan_presence_url %}active{% endif %}">
|
||||
<a href="{{ wlan_presence_url }}">{% trans "WLAN Presence" %}</a>
|
||||
</li>
|
||||
{% url account.views.rfid as rfid_url %}
|
||||
<li class="{% if request.path == rfid_url %}active{% endif %}">
|
||||
<a href="{{ rfid_url }}">{% trans "RFID" %}</a>
|
||||
</li>
|
||||
{% url account.views.nrf24 as nrf24_url %}
|
||||
<li class="{% if request.path == nrf24_url %}active{% endif %}">
|
||||
<a href="{{ nrf24_url }}">{% trans "NRF24" %}</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% block container %}
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<div class="span8">
|
||||
<div class="well">
|
||||
<h2>c-base member-interface</h2>
|
||||
Auf dieser Seite kann jedes Member seine LDAP-Daten editieren und u.A. sein Passwort neu setzen.
|
||||
{% blocktrans %}On this website any member can view and
|
||||
edit their data stored in the LDAP directory of
|
||||
c-base.{% endblocktrans %}
|
||||
</div>
|
||||
<div class="alert alert-info alert-block">
|
||||
neumember können sich ihr initiales passwort mit einem der folgenden member setzen:
|
||||
{% blocktrans %}If you are a new member and don't have a
|
||||
password yet, please contact one of the following people:{% endblocktrans %}
|
||||
<ul>
|
||||
{% for admin in admins %}
|
||||
<li>{{ admin}}</li>
|
||||
|
|
@ -98,6 +85,21 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<div class="well">
|
||||
<h4>Login</h4>
|
||||
<form class="form" action="/account/login/?next={% url account.views.home %}"
|
||||
method="post">
|
||||
{% csrf_token %}
|
||||
{{ form|crispy }}
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<button type="submit" class="btn btn-primary">{% trans "Save" %}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div><!-- /.well -->
|
||||
</div>
|
||||
</div>
|
||||
{% endblock container %}
|
||||
</div><!-- /.container -->
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@ urlpatterns = patterns('',
|
|||
|
||||
url(r'account/', include('account.urls')),
|
||||
|
||||
url(r'^$', 'account.views.landingpage'),
|
||||
url(r'^$', 'account.views.landingpage', name="landingpage"),
|
||||
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue