diff --git a/main/forms.py b/main/forms.py index 39faef0..c08d43b 100644 --- a/main/forms.py +++ b/main/forms.py @@ -1,17 +1,17 @@ from django import forms +from django.forms.widgets import RadioSelect -#from radius.models import * -# -#class TempUserForm(forms.ModelForm): -# # TODO : Move this to radius? -# class Meta: -# model = TempUser class TempUserForm(forms.Form): - who = forms.CharField(label='Hvem') + who = forms.CharField(label='Hvem', required=True) RANGE_CHOICES = ( - ('1 day', '1 dag'), - ('2 days', '2 dager'), - ('7 days', '1 uke (7 dager)'), + ('1', '1 dag'), + ('2', '2 dager'), + ('7', '1 uke (7 dager)'), ) - duration = forms.ChoiceField(label='Varighet', choices=RANGE_CHOICES) - why = forms.CharField(label='Hvorfor') + duration = forms.TypedChoiceField( + label='Varighet', + coerce=int, + choices=RANGE_CHOICES, + widget=RadioSelect, + required=True) + why = forms.CharField(label='Hvorfor', required=True) diff --git a/main/models.py b/main/models.py index 71a8362..013b6ac 100644 --- a/main/models.py +++ b/main/models.py @@ -1,3 +1,10 @@ from django.db import models +from django.contrib.auth.models import User -# Create your models here. +class TempUserLog(models.Model): + who = models.CharField(max_length=255) + why = models.CharField(max_length=255) + expires = models.DateTimeField() + issued_by = models.ForeignKey(User) + created = models.DateTimeField(auto_now_add=True) + # TODO username and pass diff --git a/main/pdf.py b/main/pdf.py index ca00580..1d900ad 100644 --- a/main/pdf.py +++ b/main/pdf.py @@ -4,7 +4,6 @@ # - http://stackoverflow.com/questions/1377446/html-to-pdf-for-a-django-site # - http://stackoverflow.com/questions/2179958/django-pisa-adding-images-to-pdf-output ? -import uuid import cStringIO as StringIO import ho.pisa as pisa from django.template.loader import get_template @@ -18,10 +17,7 @@ def render_to_pdf(template_src, context_dict): html = template.render(context) result = StringIO.StringIO() - pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("ISO-8859-1")), result) + pdf = pisa.pisaDocument(StringIO.StringIO(html.encode("UTF-8")), result) if not pdf.err: return HttpResponse(result.getvalue(), mimetype='application/pdf') return HttpResponse('We had some errors
%s
' % escape(html)) - -def unique_filename(): - return uuid.uuid4() diff --git a/main/templates/pdf/new_temp_user.html b/main/templates/pdf/new_temp_user.html index f3ef131..4c32080 100644 --- a/main/templates/pdf/new_temp_user.html +++ b/main/templates/pdf/new_temp_user.html @@ -1,7 +1,7 @@ - My Title + Midlertidig Bruker For Trådløst Nettverk på Chateau Neuf - {{log.id}}