view.html 4.6 KB
Newer Older
1
2
3
4
{% extends "base.html" %}
{% load bt %}
{% load i18n %}
{% load babel %}
5
{% load comments %}
6
7
8
{% block styles %}
{% endblock %}
{% block scripts %}
9
10
11
<script type="text/javascript" src="{%media_url%}/js/jquery.1.4.2.min.js"></script>
<script type="text/javascript" charset="utf-8">
function bindPostCommentHandler() {
stef's avatar
stef committed
12
13
14
15
    $('.toggle').click(function(){
      $(this).hide();
      $(this).next().show();
    });
16
17
18
19
20
21
22
23
24
25
    $('#comment_form form input.submit-preview').remove();
    $('#comment_form form').submit(function() {
        var postdata=$('#comment_form form').serialize()+'&csrftoken={{csrf_token}}';
        $.ajax({
            type: "POST",
            data: postdata,
            url: "{% comment_form_target %}",
            cache: false,
            dataType: "html",
            success: function(html, textStatus) {
stef's avatar
stef committed
26
                $('#comment_form form').replaceWith(html+" "+"{% trans 'It will appear here after moderation.' %}");
27
28
29
                bindPostCommentHandler();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
stef's avatar
stef committed
30
                $('#comment_form form').replaceWith("{% trans 'Your comment was unable to be posted at this time. We apologise for the inconvenience.' %}");
31
32
33
34
35
36
37
38
            }
        });
        return false;
    });
}

$(document).ready(function() {
    bindPostCommentHandler();
stef's avatar
stef committed
39
40
  $('.confirm_form').submit(function() {
     var self=this;
41
42
43
44
45
46
47
     var email=$(this).children('input:first').attr('value');
     if( email.length>0) {
        $.ajax({url: '/confirm/'+$(this).attr('id')+'/'+email, success: function(data) { $(self).html(data); }});
     } else {
        console.log($(this).find('[type=submit]'));
        $(this).find('[type=text]').focus();
     }
stef's avatar
stef committed
48
49
     return false;
     });
50
51
});
</script>
52
53
54
{% endblock %}

{%block content%}
stef's avatar
stef committed
55
<div id='global'>
stef's avatar
stef committed
56
  <h2>{{v.operator}} ({{v.country}}) {{v.contract}}</h2>
57
<ul id="report">
58
59
60
61
62
63
64
  {%if v.resource_name%}<li><dl><dt>{% trans "Resource" %}</dt><dd>{{v.resource_name}}</dd></dl></li>{%endif%}
  {%if v.type%}<li><dl><dt>{% trans "Type" %}</dt><dd>{{v.type}}</dd></dl></li>{%endif%}
  {%if v.media%}<li><dl><dt>{% trans "Media" %}</dt><dd>{{v.media}}</dd></dl></li>{%endif%}
  {%if v.temporary%}<li><dl><dt>{% trans "Temporary restriction" %}</dt><dd>{{v.temporary}}</dd></dl></li>{%endif%}
  {%if v.loophole%}<li><dl><dt>{% trans "Loophole offering" %}</dt><dd>{% trans "yes" %}</dd></dl></li>{%endif%}
  {%if v.contractual%}<li><dl><dt>{% trans "Contractual restriction" %}</dt><dd>{% trans "yes" %}</dd></dl></li>{%endif%}
  {%if v.contract_excerpt%}<li><dl><dt>{% trans "Contract excerpt" %}</dt><dd class='text'>{{v.contract_excerpt|safe}}</dd></dl></li>{%endif%}
65
  {%if v.comment_set.all%}
stef's avatar
stef committed
66
  <li id="description" class='round-box'>
67
    <h3>{%trans "Description" %}</h3>
68
    {%for c in v.comment_set.all%}
69
70
    <div class="description-node">
      <div class="description">{{c.comment|safe}}</div>
stef's avatar
stef committed
71
      <span class="submitter">{%if c.submitter_name%}{{c.submitter_name}}{%else%}{{c.submitter_email}}{%endif%}</span> - <span class="comment_date">{{c.timestamp|datetimefmt:"short" }}</span>
72
73
      {%if c.attachment_set.all%}
      <div class="attachs">
stef's avatar
stef committed
74
         {% trans "Attachments" %}
75
76
        <ul>
          {%for a in c.attachment_set.all%}
77
          <li><a href="{%media_url%}/{{a.storage.url}}">{{a.name}}</a></li>
78
79
80
81
          {%endfor%}
        </ul>
      </div>
      {%endif%}
82
    </div>
83
    {%endfor%}
84
85
  </li>
</ul>
86
  <h3>{%trans "Confirm this restriction if you experience it as well" %}</h3>
stef's avatar
stef committed
87
  <div class="info-validate" style="display: inline-block;">
88
    <form method="get" id="{{ v.pk }}" class="confirm_form" >
89
        <label>{% trans "In order to <strong>confirm</strong> this report, please enter your email address" %}</label>
stef's avatar
stef committed
90
        <input type="text" name="email" />
91
        <input type="hidden" value="{{ v.pk }}" />
stef's avatar
stef committed
92
93
94
        <input type="submit" value="{% trans "confirm" %}" />
      </form>
   </div>
95
  {%endif%}
96
  {% if not key %}
97
  <div id="comments">
stef's avatar
stef committed
98
  <h3>{% trans "Comments" %}</h3>
stef's avatar
stef committed
99
100
101
  {% get_comment_list for v as cmt_list %}
  {% for comment in cmt_list %}
  <div class="comment">
102
103
     <p><a href="{{ comment.user_url }}">{{ comment.user_name }}</a> - {{ comment.submit_date }}</p>
     <p>{{ comment.comment }}</p>
stef's avatar
stef committed
104
105
  </div>
  {% endfor %}
stef's avatar
stef committed
106
107
  <div class="toggle button">{% trans "Add comment" %}</div>
  <div id="comment_form" style="display: none;">
108
109
    {% render_comment_form for v %}
  </div>
110
  {% else %}
stef's avatar
stef committed
111
  <br />
Benjamin Sonntag's avatar
Benjamin Sonntag committed
112
113
  <a class="button" href='/moderate/?key={{key}}&action=approve'>{% trans "Approve Submission" %}</a>
  <a class="button" href='/moderate/?key={{key}}&action=delete'>{% trans "Delete Submission" %}</a>
114
  </div>
115
  {% endif %}
stef's avatar
stef committed
116
</div>
117
{%endblock%}