From 42e7cc59a3d379342dc106220bf2b1fa6d2c2f0a Mon Sep 17 00:00:00 2001 From: stef Date: Sat, 30 Apr 2011 18:55:20 +0200 Subject: [PATCH] [enh] added view report, and some other improvements --- bt/forms.py | 1 + bt/models.py | 6 ++++-- bt/views.py | 10 ++++++++-- media/css/style.css | 12 ++++++++++-- templates/base.html | 2 ++ templates/list.html | 1 + templates/view.html | 41 +++++++++++++++++++++++++++++++++++++++++ urls.py | 1 + 8 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 templates/view.html diff --git a/bt/forms.py b/bt/forms.py index f571beb..d8941f0 100644 --- a/bt/forms.py +++ b/bt/forms.py @@ -22,6 +22,7 @@ class AddViolation(forms.Form): contract = forms.CharField(required=True, max_length=256, help_text=_('The specific contract at the ISP provider. (please be as specific as possible)')) comment = forms.CharField(required=True, widget=AdvancedEditor(), help_text=_('Please describe the symptoms you are experiencing. What service or site, or person is unavailable or seems artificially slowed down.')) email = forms.EmailField(required=True, help_text=_("We need your email to validate your report. We're not storing the email later on.")) + nick = forms.CharField(required=False, help_text=_("We need your some name to identify you later on.")) attachments = MultiFileField(required=False, help_text=_("Attach screenshot, document or any other relevant information.")) resource = forms.ChoiceField(required=False, choices=(('',''),)+tuple(sorted(RESOURCES,key=itemgetter(1))), help_text=_('The what is the affected resource.')) resource_name = forms.CharField(required=False, max_length=4096, help_text=_('Please specify the name of the affected resource.')) diff --git a/bt/models.py b/bt/models.py index 3bbf50a..eff7cfc 100644 --- a/bt/models.py +++ b/bt/models.py @@ -53,6 +53,7 @@ class Violation(models.Model): operator = models.CharField(max_length=256) contract = models.CharField(max_length=256) resource = models.CharField(max_length=20, choices=RESOURCES) + resource_name = models.CharField(max_length=4096) type = models.CharField(max_length=20, choices=TYPES) media = models.CharField( max_length=20, choices=MEDIA) temporary = models.BooleanField( ) @@ -61,9 +62,10 @@ class Violation(models.Model): loophole = models.BooleanField() class Comment(models.Model): - submitter = models.EmailField() + submitter_email = models.EmailField() + submitter_name = models.CharField(max_length=20) comment = models.TextField() - timestamp = models.DateField() + timestamp = models.DateTimeField() violation = models.ForeignKey(Violation) class Attachment(models.Model): diff --git a/bt/views.py b/bt/views.py index 62f656e..6056615 100644 --- a/bt/views.py +++ b/bt/views.py @@ -1,10 +1,11 @@ from forms import AddViolation from django.http import HttpResponse, HttpResponseRedirect, Http404 -from django.shortcuts import render_to_response +from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext from django.core.files import File from django.conf import settings from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger +from django.core.exceptions import ObjectDoesNotExist from models import Violation, Attachment, Comment from tempfile import mkstemp from datetime import datetime @@ -29,7 +30,8 @@ def add(request): v.save() c = Comment( comment=form.cleaned_data['comment'], - submitter=form.cleaned_data['email'], + submitter_email=form.cleaned_data['email'], + submitter_name=form.cleaned_data['nick'], timestamp=datetime.now(), violation=v, ) @@ -68,3 +70,7 @@ def index(request): violations = paginator.page(paginator.num_pages) return render_to_response('list.html', {"violations": violations}) + +def view(request,id): + v = get_object_or_404(Violation, pk=id) + return render_to_response('view.html', { 'v': v, }) diff --git a/media/css/style.css b/media/css/style.css index a30b29d..2261fb0 100644 --- a/media/css/style.css +++ b/media/css/style.css @@ -2,15 +2,23 @@ body { border: 0; padding: 0; font-family: Verdana,Arial,Helvetica,sans-serif; } img { border: 0; } h1, h2, h3, h4, div, ul { padding: 0; margin: 0; } h2 { margin: auto; width: 50%; padding 4em; } +li { list-style: none; } + .fieldWrapper { margin: 1em; width: 100%; } .fieldWrapper label { width: 200px; display: inline-block; } .help_text { font-size: 0.7em; left: 30px; width: 20%; position: absolute; } .attachments { float: right; margin-top: 0.4em; display: block; clear: both; } -table.listing, .pagination { width: 90%; margin: auto; } -table.listing thead td { font-weight: bold; border-bottom: 1px solid black; } +.comment-node { margin: 1em; padding-bottom: 0.4em; border-bottom: 1px solid black; width: 500px;} +.comment { margin: 1em; } +.atttachsg { margin: 1em; } #addForm { margin: auto; width: 50%; padding 4em; } #add_attach { cursor: pointer; } #show_optionals { text-decoration: underline; color: blue; cursor: pointer; clear: both; } #optional { clear: both; } + +table.listing, .pagination { width: 90%; margin: auto; } +table.listing thead td { font-weight: bold; border-bottom: 1px solid black; } +dt { display: inline-block; width: 14em; } +dd { display: inline; } diff --git a/templates/base.html b/templates/base.html index cf56dfe..310faad 100644 --- a/templates/base.html +++ b/templates/base.html @@ -18,6 +18,8 @@