make it pretty

This commit is contained in:
Uwe Kamper 2013-10-25 04:24:26 +02:00
parent 96ff186913
commit 847eb691fe
8 changed files with 68 additions and 11 deletions

View file

@ -42,6 +42,7 @@ class PasswordForm(forms.Form):
class RFIDForm(forms.Form): class RFIDForm(forms.Form):
rfid = forms.CharField(max_length=255, help_text=_('Your RFID')) rfid = forms.CharField(max_length=255, help_text=_('Your RFID'))
class SIPPinForm(forms.Form): class SIPPinForm(forms.Form):
sippin = forms.CharField(max_length=255, help_text=_('Your SIP PIN')) sippin = forms.CharField(max_length=255, help_text=_('Your SIP PIN'))
@ -49,3 +50,7 @@ class SIPPinForm(forms.Form):
class NRF24Form(forms.Form): class NRF24Form(forms.Form):
nrf24 = forms.CharField(max_length=255, nrf24 = forms.CharField(max_length=255,
help_text=_('Your NRF24 identification')) help_text=_('Your NRF24 identification'))
class CLabPinForm(forms.Form):
c_lab_pin = GastroPinField(help_text=_('Your c-lab PIN'))

View file

@ -0,0 +1,23 @@
{% extends "form_base.html" %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block form_title %}{% trans "c-lab PIN"%}{% endblock %}
{% block form_description %}
<p>{% blocktrans %}Change your c-lab PIN to access the c-lab in the basement.{% endblocktrans %}</p>
{% endblock %}
{% block form_fields %}
{{ form.non_field_errors }}
<form action="{% url account.views.clabpin %}" 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 %}

View file

@ -5,7 +5,12 @@
{% block form_title %}{% trans "Gastro PIN"%}{% endblock %} {% block form_title %}{% trans "Gastro PIN"%}{% endblock %}
{% block form_description %} {% block form_description %}
<p>{% blocktrans %}Change your Gastro PIN to access the vending machines.{% endblocktrans %}</p>
<p>{% blocktrans %}Change your Gastro PIN to access the vending machines.
To use unlock member prices, press the <code>A</code> button then enter
your numeric user ID{% endblocktrans %}
<code>{{ member.uidNumber }}</code>
{% blocktrans %}and your Gastro PIN.{% endblocktrans %}</p>
{% endblock %} {% endblock %}
{% block form_fields %} {% block form_fields %}

View file

@ -9,7 +9,8 @@
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="well"> <div class="span11 well">
<h3>Login</h3>
<form class="form form-horizontal" action="/account/login/?next={{ redirect_to }}" method="post"> <form class="form form-horizontal" action="/account/login/?next={{ redirect_to }}" method="post">
{% csrf_token %} {% csrf_token %}
{{ form|crispy }} {{ form|crispy }}
@ -21,5 +22,9 @@
</form> </form>
</div> </div>
</div> </div>
<hr />
<div class="row pull-right">
<small class="muted">Copyright &copy; 2013 by c-base e.V.</small>
</div>
</div> </div>
{% endblock body %} {% endblock body %}

View file

@ -24,6 +24,10 @@
<li class="{% if request.path == rfid_url %}active{% endif %}"> <li class="{% if request.path == rfid_url %}active{% endif %}">
<a href="{{ rfid_url }}">{% trans "RFID" %}</a> <a href="{{ rfid_url }}">{% trans "RFID" %}</a>
</li> </li>
{% url account.views.clabpin as clab_url %}
<li class="{% if request.path == clab_url %}active{% endif %}">
<a href="{{ clab_url }}">{% trans "c-lab-PIN" %}</a>
</li>
{% url account.views.nrf24 as nrf24_url %} {% url account.views.nrf24 as nrf24_url %}
<li class="{% if request.path == nrf24_url %}active{% endif %}"> <li class="{% if request.path == nrf24_url %}active{% endif %}">
<a href="{{ nrf24_url }}">{% trans "NRF24" %}</a> <a href="{{ nrf24_url }}">{% trans "NRF24" %}</a>

View file

@ -11,6 +11,7 @@ urlpatterns = patterns(
url(r'^nrf24/$', 'account.views.nrf24', name='nrf24'), url(r'^nrf24/$', 'account.views.nrf24', name='nrf24'),
url(r'^password/$', 'account.views.password', name='password'), url(r'^password/$', 'account.views.password', name='password'),
url(r'^sippin/$', 'account.views.sippin', name='sippin'), url(r'^sippin/$', 'account.views.sippin', name='sippin'),
url(r'^clabpin/$', 'account.views.clabpin', name='clabpin'),
url(r'^$', 'account.views.home', name="home"), url(r'^$', 'account.views.home', name="home"),
url(r'^groups/(?P<group_name>[^/]+)/', 'account.views.groups_list'), url(r'^groups/(?P<group_name>[^/]+)/', 'account.views.groups_list'),
) )

View file

@ -13,7 +13,7 @@ from django.shortcuts import render
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from forms import GastroPinForm, WlanPresenceForm, LoginForm, PasswordForm, \ from forms import GastroPinForm, WlanPresenceForm, LoginForm, PasswordForm, \
RFIDForm, NRF24Form, SIPPinForm RFIDForm, NRF24Form, SIPPinForm, CLabPinForm
from cbase_members import MemberValues, retrieve_member from cbase_members import MemberValues, retrieve_member
@ -113,15 +113,17 @@ def set_ldap_field(request, form_type, field_names, template_name):
member.save() member.save()
new_form = form_type(initial=initial) new_form = form_type(initial=initial)
return render(request, template_name, return render(request, template_name,
{'message': _('Your changes have been saved. Thank you!'), {'message': _('Your changes have been saved. Thank you!'),
'form': new_form}) 'form': new_form, 'member': member.to_dict()})
else: else:
return render(request, template_name, {'form:': form}) return render(request, template_name,
{'form:': form, 'member': member.to_dict()})
else: else:
for form_field, ldap_field in field_names: for form_field, ldap_field in field_names:
initial[form_field] = member.get(ldap_field) initial[form_field] = member.get(ldap_field)
form = form_type(initial=initial) form = form_type(initial=initial)
return render(request, template_name, {'form': form}) return render(request, template_name,
{'form': form, 'member': member.to_dict()})
@login_required @login_required
def wlan_presence(request): def wlan_presence(request):
@ -138,5 +140,11 @@ def nrf24(request):
@login_required @login_required
def password(request): def password(request):
return set_ldap_field(request, PasswordForm, [('password1', 'password')], 'password.html') return set_ldap_field(request, PasswordForm, [('password1', 'password')],
'password.html')
@login_required
def clabpin(request):
return set_ldap_field(request, CLabPinForm, [('c_lab_pin', 'c-labPIN')],
'clabpin.html')

View file

@ -38,10 +38,12 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</a> </a>
<!-- a class="brand" href="/">crew.c-base.org</a --> <span class="brand"><a href="/">{% trans "c-base Member Interface" %}</a></span>
<div class="nav-collapse collapse"> <div class="nav-collapse collapse">
<p class="navbar-text pull-left"> <p class="navbar-text pull-left">
c-base member-interface {% if request.user.is_authenticated %}-&gt; {{ request.user.username }}{% endif %}
{% if request.user.is_authenticated %}
<i class="icon-user icon-white"></i> {{ request.user.username }}{% endif %}
</p> </p>
<div class="pull-right"> <div class="pull-right">
@ -94,7 +96,7 @@
{{ form|crispy }} {{ form|crispy }}
<div class="control-group"> <div class="control-group">
<div class="controls"> <div class="controls">
<button type="submit" class="btn btn-primary">{% trans "Save" %}</button> <button type="submit" class="btn btn-primary">{% trans "Sign in" %}</button>
</div> </div>
</div> </div>
</form> </form>
@ -102,6 +104,10 @@
</div> </div>
</div> </div>
{% endblock container %} {% endblock container %}
<hr />
<div class="row pull-right">
<small class="muted">Copyright &copy; 2013 by c-base e.V.</small>
</div>
</div><!-- /.container --> </div><!-- /.container -->
{% endblock body %} {% endblock body %}
<script src="/static/js/bootstrap.js"></script> <script src="/static/js/bootstrap.js"></script>