UI
This commit is contained in:
1 parent
b600e413a1
commit
6a4620b4d1
10 files changed
+66
-17
No files matched your search
@@ -0,0 +1,3 @@
|
||||
Requirements:
|
||||
=============
|
||||
sudo pip install reportlab pisa html5lib pypdf pil
|
||||
+16
-7
@@ -1,8 +1,17 @@
|
||||
from django.forms import ModelForm
|
||||
from django import forms
|
||||
|
||||
from main.models import *
|
||||
|
||||
class TempUserForm(ModelForm):
|
||||
# TODO : Move this to radius?
|
||||
class Meta:
|
||||
model = TempUser
|
||||
#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')
|
||||
RANGE_CHOICES = (
|
||||
('1 day', '1 dag'),
|
||||
('2 days', '2 dager'),
|
||||
('7 days', '1 uke (7 dager)'),
|
||||
)
|
||||
duration = forms.ChoiceField(label='Varighet', choices=RANGE_CHOICES)
|
||||
why = forms.CharField(label='Hvorfor')
|
||||
@@ -4,6 +4,7 @@
|
||||
# - 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
|
||||
@@ -22,3 +23,5 @@ def render_to_pdf(template_src, context_dict):
|
||||
return HttpResponse(result.getvalue(), mimetype='application/pdf')
|
||||
return HttpResponse('We had some errors<pre>%s</pre>' % escape(html))
|
||||
|
||||
def unique_filename():
|
||||
return uuid.uuid4()
|
||||
@@ -0,0 +1,12 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Liste over midlertidige brukere</h2>
|
||||
<p>
|
||||
Tabell her:<br />
|
||||
{{ table }}
|
||||
<a href="deleted">Vis utgåtte ...</a>
|
||||
</p>
|
||||
<a href="{% url main.views.system %}" class="btn">« Tilbake</a>
|
||||
|
||||
{% endblock %}
|
||||
@@ -5,7 +5,11 @@
|
||||
<p>
|
||||
OK, du skal få lage en, men først...
|
||||
</p>
|
||||
{{ form }}
|
||||
<a href="{% url main.views.system %}" class="btn">Avbryt</a>
|
||||
<form method="post" class="form-stacked">
|
||||
{% csrf_token %}
|
||||
{{ form.as_p }}
|
||||
<button type="submit" class="btn primary">Lag bruker og hent PDF</button>
|
||||
<a href="{% url main.views.system %}" class="btn">Avbryt</a>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
@@ -2,7 +2,8 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<a href="{% url main.views.new %}" class="btn large primary">Lag ny midlertidig bruker</a>
|
||||
<a href="{% url django.contrib.auth.views.logout %}" class="btn large">Logg ut</a>
|
||||
<a href="{% url main.views.new %}" class="btn primary">Lag ny midlertidig bruker</a>
|
||||
<a href="{% url main.views.list_users %}" class="btn">Vis midlertidige</a>
|
||||
<a href="{% url django.contrib.auth.views.logout %}" class="btn">Logg ut</a>
|
||||
|
||||
{% endblock %}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
{% block content %}
|
||||
<strong>MBFTNS</strong> kan lage Midlertidige Brukere For Trådløst Nettverk på <a href="http://studentersamfundet.no">Chateau Neuf</a>.
|
||||
|
||||
{% include "registration/login_form.html" %}
|
||||
<p>
|
||||
{% include "registration/login_form.html" %}
|
||||
</p>
|
||||
{% endblock %}
|
||||
@@ -1,4 +1,4 @@
|
||||
<form method="post" action="{% url django.contrib.auth.views.login %}">
|
||||
<form method="post" action="{% url django.contrib.auth.views.login %}" class="form-stacked">
|
||||
{% if form.non_field_errors %}
|
||||
{{ form.non_field_errors }}<br />
|
||||
{% endif %}
|
||||
@@ -9,6 +9,6 @@
|
||||
<label for="id_password">Passord: </label><br />
|
||||
{{ form.password }} {{ form.password.errors }}<br />
|
||||
<br />
|
||||
<input type="submit" value="Logg inn" />
|
||||
<button type="submit" class="btn primary">Logg inn</button>
|
||||
|
||||
</form>
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
from django.conf.urls.defaults import patterns, include, url
|
||||
|
||||
urlpatterns = patterns('main.views',
|
||||
url(r'^new/', 'new'),
|
||||
url(r'^system/', 'system'),
|
||||
url(r'^new/', 'new'),
|
||||
url(r'^list/', 'list_users'),
|
||||
)
|
||||
+16
-1
@@ -12,8 +12,9 @@ from django.template import RequestContext
|
||||
from django.views.decorators.csrf import csrf_protect
|
||||
|
||||
from models import *
|
||||
from forms import *
|
||||
|
||||
from pdf import render_to_pdf
|
||||
from pdf import render_to_pdf, unique_filename
|
||||
|
||||
def index(request):
|
||||
if request.method == "POST":
|
||||
@@ -31,8 +32,22 @@ def index(request):
|
||||
|
||||
@login_required
|
||||
def new(request):
|
||||
if request.method == "POST":
|
||||
form = TempUserForm(data=request.POST)
|
||||
if form.is_valid():
|
||||
# generate and save the filename for the new pdf
|
||||
fn = unique_filename()
|
||||
download_pdf()
|
||||
|
||||
form = TempUserForm()
|
||||
|
||||
return render_to_response('private/new.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
def list_users(request):
|
||||
# generic view?
|
||||
return render_to_response('private/list.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
def system(request):
|
||||
return render_to_response('private/system.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
Reference in new issue
Block a user