Commit 79bfa861 authored by Cynddl's avatar Cynddl

Changes from origin branch

parent 19f30733
......@@ -13,6 +13,7 @@ COUNTRIES = (
('EL', _('Greece')),
('ES', _('Spain')),
('FR', _('France')),
('IS', _('Iceland')),
('IT', _('Italy')),
('CY', _('Cyprus')),
('LV', _('Latvia')),
......@@ -30,8 +31,7 @@ COUNTRIES = (
('SK', _('Slovakia')),
('FI', _('Finland')),
('SE', _('Sweden')),
('UK', _('United Kingdom ')),
('NO', _('Norway')),
('UK', _('United Kingdom')),
)
RESOURCES = (
......@@ -91,6 +91,7 @@ class Comment(models.Model):
class Attachment(models.Model):
storage = models.FileField(upload_to='static')
name= models.CharField(max_length=512)
type= models.CharField(max_length=512)
comment = models.ForeignKey(Comment)
class Admin:
......
......@@ -3,6 +3,7 @@ from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.core.files import File
from django.core.servers.basehttp import FileWrapper
from django.conf import settings
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.core.exceptions import ObjectDoesNotExist
......@@ -163,7 +164,7 @@ def add(request):
)
c.save()
for f in request.FILES.getlist('attachments[]'):
a=Attachment(comment=c, name=f.name)
a=Attachment(comment=c, name=f.name, type=f.content_type)
m = hashlib.sha256()
for chunk in f.chunks():
m.update(chunk)
......@@ -213,13 +214,16 @@ def list_violations(request):
countries=sorted([(i['total'],i['country'])
for i in Violation.objects.values('country').filter(activationid='').annotate(total=Count('country'))],
reverse=True)
countries=json.dumps(dict([(c.lower(),"#ff%x00" % (3*int(64*(float(w)/countries[0][0]))+63)) for w,c in countries]))
legend=sorted(set([(w, "rgba(255,%d, 00, 0.4)" % (w*768/(countries[0][0]+1)%256)) for w,c in countries]),reverse=True)
countrycolors=json.dumps(dict([(c.lower(),"#ff%02x00" % (w*768/(countries[0][0]+1)%256)) for w,c in countries]))
#confirms=sorted([(i['total'],i['country'])
# for i in Violation.objects.values('country').filter(activationid='').annotate(total=Count('confirmation'))],
# reverse=True)
return render_to_response('list.html',
{"violations": violations,
"countries": countries,},
"countries": dict([(y,x) for x,y in countries]),
"countrycolors": countrycolors,
"legend": legend,},
#"confirms": confirms,},
context_instance=RequestContext(request))
......@@ -229,6 +233,14 @@ def view(request,id):
raise Http404
return render_to_response('view.html', { 'v': v, },context_instance=RequestContext(request))
def get_attach(request,id):
f = get_object_or_404(Attachment, pk=id)
wrapper = FileWrapper(f.storage)
response=HttpResponse(wrapper, mimetype=f.type)
response['Content-Disposition'] = 'attachment; filename="%s"' % f.name
response['Content-Length'] = f.storage.size
return response
def lookup(request):
if request.method == 'GET':
form = SearchViolation(request.GET)
......
......@@ -661,4 +661,7 @@ ul.messages {
#similar_cases li { list-style: disc inside; margin-left: 0.3em; color: black; }
.mceToolbar { display:none; }
\ No newline at end of file
.mceToolbar { display:none; }
#legend { text-align: center; margin-bottom: .5em; font-size: .7em; }
#legend li { padding: .1em; display: inline; }
#map { float: right; }
This diff is collapsed.
......@@ -79,7 +79,6 @@ $(document).ready(function() {
{%block content%}
<div id='global'>
<h2>{{v.operator}} ({{v.country}}) {{v.contract}}</h2>
<div id="report">
<div id="icons">
<span id="verified_tooltip" class="tooltip">{% trans "This case was verified by the management team" %}</span>
......@@ -89,11 +88,11 @@ $(document).ready(function() {
<span id="invalidations">{%if v.invalidations %} {{v.invalidations}} {%else%} 0 {%endif%}</span>
</div>
<dl>{%if v.resource_name%}<dt>{% trans "Resource" %}</dt><dd>{{v.resource_name}}</dd>{%endif%}
<dl>{%if v.resource_name%}<dt>{% trans "Affected resource" %}</dt><dd>{{v.resource_name}}</dd>{%endif%}
{%if v.type%}<dt>{% trans "Type" %}</dt><dd>{{v.type}}</dd>{%endif%}
{%if v.media%}<dt>{% trans "Media" %}</dt><dd>{{v.media}}</dd>{%endif%}
{%if v.temporary%}<dt>{% trans "Temporary restriction" %}</dt><dd>{{v.temporary}}</dd>{%endif%}
{%if v.loophole%}<dt>{% trans "Loophole offering" %}</dt><dd>{% trans "yes" %}</dd>{%endif%}
{%if v.loophole%}<dt>{% trans "Another offer provided by the same operator removes this restriction" %}</dt><dd>{% trans "yes" %}</dd>{%endif%}
{%if v.contractual%}<dt>{% trans "Contractual restriction" %}</dt><dd>{% trans "yes" %}</dd>{%endif%}
{%if v.contract_excerpt%}<dt>{% trans "Contract excerpt" %}</dt><dd class='text'>{{v.contract_excerpt|safe}}</dd>{%endif%}
{%if v.comment_set.all%}</dl>
......@@ -108,7 +107,7 @@ $(document).ready(function() {
<h4>{% trans "Attachments" %}</h4>
<ul>
{%for a in c.attachment_set.all%}
<li><a href="{%media_url%}/{{a.storage.url}}">{{a.name}}</a></li>
<li><a href="/attach/{{a.id}}">{{a.name}}</a></li>
{%endfor%}
</ul>
</div>
......@@ -136,8 +135,8 @@ $(document).ready(function() {
{% get_comment_list for v as cmt_list %}
{% for comment in cmt_list %}
<div class="comment">
<p><a href="{{ comment.user_url }}">{{ comment.user_name }}</a> - {{ comment.submit_date }}</p>
<p>{{ comment.comment }}</p>
<p>{{ comment.user_name }} - {{ comment.submit_date }}</p>
<p>{{ comment.comment|striptags|urlize|linebreaks }}</p>
</div>
{% endfor %}
<div class="toggle button">{% trans "Add comment" %}</div>
......
......@@ -15,6 +15,7 @@ urlpatterns = patterns('',
(r'^ajax/(?P<country>[^/]*)(/(?P<operator>[^/]*))?$', bt.ajax),
(r'^add/$', bt.add),
(r'^view/(?P<id>[0-9]*)$', bt.view),
(r'^attach/(?P<id>[0-9]*)$', bt.get_attach),
(r'^(?P<id>[0-9]*)$', bt.view),
(r'^rss/$', RssSiteNewsFeed()),
(r'^atom/$', AtomSiteNewsFeed()),
......
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