summaryrefslogtreecommitdiffstats
path: root/hyperkitty/templates/message.html
blob: 5ae2fb1acc753b911370b25a823aa00ed3e516a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{% extends "base.html" %}
{% load gravatar %}
{% load hk_generic %}
{% load storm %}

{% block content %}

<div class="message-header">
    <a class="thread-back"
       href="{% url thread threadid=message.thread_id, mlist_fqdn=list_address %}">
    </a>
    <h1>{{ message.subject }}</h1>
</div>

<section id="thread_content">
	{% include 'messages/first_email.html' with first_mail=message %}
</section>

{% endblock %}

{% block additionaljs %}
<script type="text/javascript">
	$(document).ready(function() {
		$(".voteup").click(function() {
			// @TODO: Extract the message id from the HTML DOM element instead of hard coding it in Javascript.
			message_id = this.parentElement.getAttribute('messageid');
			{% if user.is_authenticated %}
			$.ajax({
				type : "POST",
				url : "{% url message_vote mlist_fqdn=list_address %}",
				data : {
					vote : 1,
					messageid : message_id,
					list : "{{list_address}}",
					csrfmiddlewaretoken : '{{ csrf_token }}'
				},
				success : function(response) {
					console.log(response);
					location.reload();
				}
			});
			return false;
			{% else %}
				alert('You need to login in order to vote');
			{% endif %}
		});

		$(".votedown").click(function() {
			message_id = this.parentElement.getAttribute('messageid');
			{% if user.is_authenticated %}
			$.ajax({
				type : "POST",
				url : '{% url message_vote mlist_fqdn=list_address %}',
				data : {
					vote : -1,
					messageid : message_id,
					list : "{{list_address}}",
					csrfmiddlewaretoken : '{{ csrf_token }}'
				},
				success : function(response) {
					console.log(response);
					// @TODO : Remove this reload and update count using AJAX
					location.reload();
				}
			});
			return false;
			{% else %}
				alert('You need to login in order to vote');
			{% endif %}

		});

	});
</script>

{% endblock %}