Commit 42e7cc59 authored by stef's avatar stef

[enh] added view report, and some other improvements

parent de3703af
...@@ -22,6 +22,7 @@ class AddViolation(forms.Form): ...@@ -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)')) 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.')) 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.")) 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.")) 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 = 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.')) resource_name = forms.CharField(required=False, max_length=4096, help_text=_('Please specify the name of the affected resource.'))
......
...@@ -53,6 +53,7 @@ class Violation(models.Model): ...@@ -53,6 +53,7 @@ class Violation(models.Model):
operator = models.CharField(max_length=256) operator = models.CharField(max_length=256)
contract = models.CharField(max_length=256) contract = models.CharField(max_length=256)
resource = models.CharField(max_length=20, choices=RESOURCES) resource = models.CharField(max_length=20, choices=RESOURCES)
resource_name = models.CharField(max_length=4096)
type = models.CharField(max_length=20, choices=TYPES) type = models.CharField(max_length=20, choices=TYPES)
media = models.CharField( max_length=20, choices=MEDIA) media = models.CharField( max_length=20, choices=MEDIA)
temporary = models.BooleanField( ) temporary = models.BooleanField( )
...@@ -61,9 +62,10 @@ class Violation(models.Model): ...@@ -61,9 +62,10 @@ class Violation(models.Model):
loophole = models.BooleanField() loophole = models.BooleanField()
class Comment(models.Model): class Comment(models.Model):
submitter = models.EmailField() submitter_email = models.EmailField()
submitter_name = models.CharField(max_length=20)
comment = models.TextField() comment = models.TextField()
timestamp = models.DateField() timestamp = models.DateTimeField()
violation = models.ForeignKey(Violation) violation = models.ForeignKey(Violation)
class Attachment(models.Model): class Attachment(models.Model):
......
from forms import AddViolation from forms import AddViolation
from django.http import HttpResponse, HttpResponseRedirect, Http404 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.template import RequestContext
from django.core.files import File from django.core.files import File
from django.conf import settings from django.conf import settings
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.core.exceptions import ObjectDoesNotExist
from models import Violation, Attachment, Comment from models import Violation, Attachment, Comment
from tempfile import mkstemp from tempfile import mkstemp
from datetime import datetime from datetime import datetime
...@@ -29,7 +30,8 @@ def add(request): ...@@ -29,7 +30,8 @@ def add(request):
v.save() v.save()
c = Comment( c = Comment(
comment=form.cleaned_data['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(), timestamp=datetime.now(),
violation=v, violation=v,
) )
...@@ -68,3 +70,7 @@ def index(request): ...@@ -68,3 +70,7 @@ def index(request):
violations = paginator.page(paginator.num_pages) violations = paginator.page(paginator.num_pages)
return render_to_response('list.html', {"violations": violations}) 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, })
...@@ -2,15 +2,23 @@ body { border: 0; padding: 0; font-family: Verdana,Arial,Helvetica,sans-serif; } ...@@ -2,15 +2,23 @@ body { border: 0; padding: 0; font-family: Verdana,Arial,Helvetica,sans-serif; }
img { border: 0; } img { border: 0; }
h1, h2, h3, h4, div, ul { padding: 0; margin: 0; } h1, h2, h3, h4, div, ul { padding: 0; margin: 0; }
h2 { margin: auto; width: 50%; padding 4em; } h2 { margin: auto; width: 50%; padding 4em; }
li { list-style: none; }
.fieldWrapper { margin: 1em; width: 100%; } .fieldWrapper { margin: 1em; width: 100%; }
.fieldWrapper label { width: 200px; display: inline-block; } .fieldWrapper label { width: 200px; display: inline-block; }
.help_text { font-size: 0.7em; left: 30px; width: 20%; position: absolute; } .help_text { font-size: 0.7em; left: 30px; width: 20%; position: absolute; }
.attachments { float: right; margin-top: 0.4em; display: block; clear: both; } .attachments { float: right; margin-top: 0.4em; display: block; clear: both; }
table.listing, .pagination { width: 90%; margin: auto; } .comment-node { margin: 1em; padding-bottom: 0.4em; border-bottom: 1px solid black; width: 500px;}
table.listing thead td { font-weight: bold; border-bottom: 1px solid black; } .comment { margin: 1em; }
.atttachsg { margin: 1em; }
#addForm { margin: auto; width: 50%; padding 4em; } #addForm { margin: auto; width: 50%; padding 4em; }
#add_attach { cursor: pointer; } #add_attach { cursor: pointer; }
#show_optionals { text-decoration: underline; color: blue; cursor: pointer; clear: both; } #show_optionals { text-decoration: underline; color: blue; cursor: pointer; clear: both; }
#optional { 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; }
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
</head> </head>
<body> <body>
<div id="auth" class="menu"> <div id="auth" class="menu">
<a href="{%root_url%}/add/">Report restriction</a>
<a href="{%root_url%}/">List reports</a>
{% if user.is_authenticated %} {% if user.is_authenticated %}
<a href="{%root_url%}/accounts/settings">{{ user.username }}</a> <a href="{%root_url%}/accounts/settings">{{ user.username }}</a>
<a href="{%root_url%}/accounts/logout">Logout</a> <a href="{%root_url%}/accounts/logout">Logout</a>
......
...@@ -30,6 +30,7 @@ $(document).ready(function(){ ...@@ -30,6 +30,7 @@ $(document).ready(function(){
<tbody> <tbody>
{% for violation in violations.object_list %} {% for violation in violations.object_list %}
<tr> <tr>
<td><a href="/view/{{violation.pk}}">#{{ violation.pk }}</a></td>
<td>{{ violation.country }}</td> <td>{{ violation.country }}</td>
<td>{{ violation.operator }}</td> <td>{{ violation.operator }}</td>
<td>{{ violation.contract }}</td> <td>{{ violation.contract }}</td>
......
{% extends "base.html" %}
{% load bt %}
{% load i18n %}
{% load babel %}
{% block styles %}
{% endblock %}
{% block scripts %}
{% endblock %}
{%block content%}
<ul>
<li><dl><dt>Operator</dt><dd>{{v.operator}} ({{v.country}})</dd></dl></li>
<li><dl><dt>Contract</dt><dd>{{v.contract}}</dd></dl></li>
{%if v.resource%}<li><dl><dt>Resource</dt><dd>{{v.resource}}</dd></dl></li>{%endif%}
{%if v.type%}<li><dl><dt>Type</dt><dd>{{v.type}}</dd></dl></li>{%endif%}
{%if v.media%}<li><dl><dt>Media</dt><dd>{{v.media}}</dd></dl></li>{%endif%}
{%if v.temporary%}<li><dl><dt>Temporary restriction</dt><dd>{{v.temporary}}</dd></dl></li>{%endif%}
{%if v.contractual%}<li><dl><dt>Contractual restriction</dt><dd>{{v.Contractual}}</dd></dl></li>{%endif%}
{%if v.contract_excerpt%}<li><dl><dt>Contract excerpt</dt><dd>{{v.contract_excerpt}}</dd></dl></li>{%endif%}
{%if v.loophole%}<li><dl><dt>Loophole offering</dt><dd>{{v.loophole}}</dd></dl></li>{%endif%}
{%if v.comment_set.all%}
<div id="comments">
Comments
{%for c in v.comment_set.all%}
<div class="comment-node">
<span class="commenter">{%if c.submitter_nick%}{{c.submitter_nick}}{%else%}{{c.submitter_email}}{%endif%}</span> - <span class="comment_date">{{c.timestamp|datetimefmt:"short" }}</span>
<div class="comment">{{c.comment}}</div>
{%if c.attachment_set.all%}
<div class="attachs">
Attachments
<ul>
{%for a in c.attachment_set.all%}
<li><a href="{{a.storage.url}}">{{a.storage.name}}</a></li>
{%endfor%}
</ul>
</div>
{%endif%}
{%endfor%}
</div>
{%endif%}
{%endblock%}
...@@ -13,6 +13,7 @@ urlpatterns = patterns('', ...@@ -13,6 +13,7 @@ urlpatterns = patterns('',
url(r'^captcha/', include('captcha.urls')), url(r'^captcha/', include('captcha.urls')),
(r'^ajax/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$', bt.ajax), (r'^ajax/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$', bt.ajax),
(r'^add/$', bt.add), (r'^add/$', bt.add),
(r'^view/(?P<id>[0-9]*)$', bt.view),
) )
if settings.DEV_SERVER: if settings.DEV_SERVER:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment