2013-10-24 21:27:15 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
2013-10-19 00:47:24 +02:00
|
|
|
from django import forms
|
2013-10-24 21:27:15 +02:00
|
|
|
from django.utils.translation import ugettext as _
|
|
|
|
|
|
2013-10-19 00:47:24 +02:00
|
|
|
|
|
|
|
|
class LoginForm(forms.Form):
|
|
|
|
|
username = forms.CharField(max_length=255)
|
|
|
|
|
password = forms.CharField(max_length=255, widget=forms.PasswordInput)
|
2013-10-23 00:27:31 +02:00
|
|
|
|
|
|
|
|
|
2013-10-24 21:27:15 +02:00
|
|
|
class GastroPinField(forms.CharField):
|
|
|
|
|
def validate(self, value):
|
|
|
|
|
"""
|
|
|
|
|
Check if the value is all numeric and 4 - 6 chars long.
|
|
|
|
|
"""
|
|
|
|
|
match = re.match(r'^\d{4,6}$', value)
|
|
|
|
|
if not match:
|
|
|
|
|
raise forms.ValidationError(_('PIN must be 4 to 6 digits.'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GastroPinForm(forms.Form):
|
|
|
|
|
gastropin = GastroPinField()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class WlanPresenceForm(forms.Form):
|
|
|
|
|
# Boolean fields must never be required.
|
|
|
|
|
presence = forms.BooleanField(required=False,
|
|
|
|
|
help_text=_('Enable WiFi presence?'))
|
|
|
|
|
|
|
|
|
|
|
2013-10-25 01:03:16 +02:00
|
|
|
class PasswordForm(forms.Form):
|
2013-10-24 21:27:15 +02:00
|
|
|
password1 = forms.CharField(max_length=255, widget=forms.PasswordInput,
|
|
|
|
|
help_text=_('New password'))
|
|
|
|
|
password2 = forms.CharField(max_length=255, widget=forms.PasswordInput,
|
|
|
|
|
help_text=_('Repeat password'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RFIDForm(forms.Form):
|
|
|
|
|
rfid = forms.CharField(max_length=255, help_text=_('Your RFID'))
|
|
|
|
|
|
2013-10-25 04:24:26 +02:00
|
|
|
|
2013-10-25 01:03:16 +02:00
|
|
|
class SIPPinForm(forms.Form):
|
|
|
|
|
sippin = forms.CharField(max_length=255, help_text=_('Your SIP PIN'))
|
|
|
|
|
|
2013-10-24 21:27:15 +02:00
|
|
|
|
2013-10-24 21:44:53 +02:00
|
|
|
class NRF24Form(forms.Form):
|
|
|
|
|
nrf24 = forms.CharField(max_length=255,
|
|
|
|
|
help_text=_('Your NRF24 identification'))
|
2013-10-25 04:24:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class CLabPinForm(forms.Form):
|
|
|
|
|
c_lab_pin = GastroPinField(help_text=_('Your c-lab PIN'))
|