Reformat html files

This commit is contained in:
cuom1999 2023-01-27 17:11:10 -06:00
parent 9a208ca108
commit 52f1e77fe1
205 changed files with 11096 additions and 11086 deletions

View file

@ -1,5 +1,5 @@
<form id="edit-notes" action="{{ url('ticket_notes', ticket.id) }}" method="post">
{% csrf_token %}
{{ form.notes }}
<button type="submit" class="submit">{{ _('Update') }}</button>
{% csrf_token %}
{{ form.notes }}
<button type="submit" class="submit">{{ _('Update') }}</button>
</form>

View file

@ -1,25 +1,25 @@
<div class="blog-box">
<h3 class="problem-feed-name">
<a href="{{ ticket.linked_item.get_absolute_url() }}">
{{ ticket.linked_item|item_title }}</a>
&#183
<a href="{{ url('ticket', ticket.id) }}">
{{ ticket.title }}
</a>
</h3>
{% with author=ticket.user %}
{% if author %}
<div class="problem-feed-info-entry">
<i class="fa fa-pencil-square-o fa-fw"></i>
<span class="pi-value">{{ link_user(author) }}</span>
</div>
{% endif %}
{% endwith %}
<div class="problem-feed-types">
<i class="fa fa-tag"></i>
{{link_user(ticket.messages.last().user)}} {{_(' replied')}}
</div>
<div class='blog-description content-description'>
{{ ticket.messages.last().body|markdown(lazy_load=True)|reference|str|safe }}
</div>
<div class="blog-box">
<h3 class="problem-feed-name">
<a href="{{ ticket.linked_item.get_absolute_url() }}">
{{ ticket.linked_item|item_title }}</a>
&#183
<a href="{{ url('ticket', ticket.id) }}">
{{ ticket.title }}
</a>
</h3>
{% with author=ticket.user %}
{% if author %}
<div class="problem-feed-info-entry">
<i class="fa fa-pencil-square-o fa-fw"></i>
<span class="pi-value">{{ link_user(author) }}</span>
</div>
{% endif %}
{% endwith %}
<div class="problem-feed-types">
<i class="fa fa-tag"></i>
{{link_user(ticket.messages.last().user)}} {{_(' replied')}}
</div>
<div class='blog-description content-description'>
{{ ticket.messages.last().body|markdown(lazy_load=True)|reference|str|safe }}
</div>
</div>

View file

@ -1,278 +1,278 @@
{% extends "base.html" %}
{% block media %}
<style>
#ticket-list .fa-check-circle-o {
color: #00a900;
}
<style>
#ticket-list .fa-check-circle-o {
color: #00a900;
}
#ticket-list .fa-exclamation-circle {
color: darkred;
}
#ticket-list .fa-exclamation-circle {
color: darkred;
}
@media (min-width: 500px) {
#container {
display: flex;
flex-direction: row-reverse;
}
@media (min-width: 500px) {
#container {
display: flex;
flex-direction: row-reverse;
}
#container > main {
flex: 1;
}
#container > main {
flex: 1;
}
#container > aside {
flex: 1;
max-width: 200px;
margin-left: 1em;
}
#container > aside {
flex: 1;
max-width: 200px;
margin-left: 1em;
}
#container > aside > div {
position: sticky;
top: 60px;
}
}
#container > aside > div {
position: sticky;
top: 60px;
}
}
.select2-selection__arrow {
display: none;
}
.select2-selection__arrow {
display: none;
}
.select2-selection__rendered {
cursor: text;
}
.select2-selection__rendered {
cursor: text;
}
.select2-results__option {
position: relative;
}
.select2-results__option {
position: relative;
}
.select2-results__option--highlighted {
background-color: #DEDEDE !important;
}
.select2-results__option--highlighted {
background-color: #DEDEDE !important;
}
li.select2-results__option--highlighted a.user-redirect {
display: inline-block;
}
li.select2-results__option--highlighted a.user-redirect {
display: inline-block;
}
a.user-redirect {
color: #2980b9;
vertical-align: middle;
font-size: 1.2em;
position: absolute;
right: 0.8em;
display: none;
}
a.user-redirect {
color: #2980b9;
vertical-align: middle;
font-size: 1.2em;
position: absolute;
right: 0.8em;
display: none;
}
a.user-redirect:hover {
text-shadow: 0 0 2px blue;
}
</style>
a.user-redirect:hover {
text-shadow: 0 0 2px blue;
}
</style>
{% endblock %}
{% block js_media %}
<script type="text/javascript">
window.filter_user_ids = {{filter_status.user_id}};
window.filter_own_id = {{filter_status.own_id}};
window.filter_assignee_ids = {{filter_status.assignee_id}};
</script>
<script type="text/javascript" src="{{ static('event.js') }}"></script>
<script type="text/javascript">
$(function () {
$('input#own').click(function () {
($('<form>').attr('action', window.location.pathname + '?' + $('form#filter-form').serialize())
.append($('<input>').attr('type', 'hidden').attr('name', 'csrfmiddlewaretoken')
.attr('value', $.cookie('csrftoken')))
.attr('method', 'POST').appendTo($('body')).submit());
<script type="text/javascript">
window.filter_user_ids = {{filter_status.user_id}};
window.filter_own_id = {{filter_status.own_id}};
window.filter_assignee_ids = {{filter_status.assignee_id}};
</script>
<script type="text/javascript" src="{{ static('event.js') }}"></script>
<script type="text/javascript">
$(function () {
$('input#own').click(function () {
($('<form>').attr('action', window.location.pathname + '?' + $('form#filter-form').serialize())
.append($('<input>').attr('type', 'hidden').attr('name', 'csrfmiddlewaretoken')
.attr('value', $.cookie('csrftoken')))
.attr('method', 'POST').appendTo($('body')).submit());
});
register_notify('ticket', {
$checkbox: $('#desktop-notification'),
change: function (enabled) {
if (!enabled)
for (key in localStorage)
if (key.startsWith('ticket:open:'))
delete localStorage[key];
}
});
function main_list_notify(id) {
key = 'ticket:open:' + id;
return !(key in localStorage) || localStorage[key] == '0';
}
var $tbody = $('#ticket-list').find('tbody');
function new_ticket(ticket) {
console.log('Fetching data for: ' + ticket.id);
$.ajax({
url: '{{ url('ticket_ajax') }}',
data: {id: ticket.id},
success: function (data) {
console.log('Got data for: ' + ticket.id);
console.log(data);
$tbody.prepend($(data.row));
notify('ticket', data.notification.title, {
body: data.notification.body
});
register_notify('ticket', {
$checkbox: $('#desktop-notification'),
change: function (enabled) {
if (!enabled)
for (key in localStorage)
if (key.startsWith('ticket:open:'))
delete localStorage[key];
}
});
function main_list_notify(id) {
key = 'ticket:open:' + id;
return !(key in localStorage) || localStorage[key] == '0';
},
error: function (data) {
if (data.status === 403)
console.log('No right to see: ' + ticket.id);
else {
console.log('Could not load ticket:');
console.log(data.responseText);
}
var $tbody = $('#ticket-list').find('tbody');
function new_ticket(ticket) {
console.log('Fetching data for: ' + ticket.id);
$.ajax({
url: '{{ url('ticket_ajax') }}',
data: {id: ticket.id},
success: function (data) {
console.log('Got data for: ' + ticket.id);
console.log(data);
$tbody.prepend($(data.row));
notify('ticket', data.notification.title, {
body: data.notification.body
});
},
error: function (data) {
if (data.status === 403)
console.log('No right to see: ' + ticket.id);
else {
console.log('Could not load ticket:');
console.log(data.responseText);
}
}
});
}
function ticket_status(ticket) {
if (!main_list_notify(ticket.id)) return;
var $row = $('#ticket-' + ticket.id);
console.log('Ticket status change: ' + ticket.id);
if ($row.length) {
var $status = $row.find('td').first().find('i');
if (ticket.open) {
$status.removeClass('fa-check-circle-o').addClass('fa-exclamation-circle');
notify('ticket', '{{ _('Reopened: ') }}' + ticket.title);
} else {
$status.removeClass('fa-exclamation-circle').addClass('fa-check-circle-o');
notify('ticket', '{{ _('Closed: ') }}' + ticket.title);
}
}
}
window.load_dynamic_update = function (last_msg) {
var $assignees = $(filter_assignee_ids);
return new EventReceiver(
"{{ EVENT_DAEMON_LOCATION }}", "{{ EVENT_DAEMON_POLL_LOCATION }}",
['tickets'], last_msg, function (message) {
console.log(message);
if (filter_own_id != null && message.user != filter_own_id &&
!~message.assignees.indexOf(filter_own_id))
return;
if (filter_user_ids.length && !~filter_user_ids.indexOf(message.user))
return;
if ($assignees.length && !$assignees.filter(message.assignees).length)
return;
switch (message.type) {
case 'new-ticket':
new_ticket(message);
break;
case 'ticket-status':
ticket_status(message);
break;
}
}
);
};
var user_select2 = {
escapeMarkup: function (markup) {
return markup;
},
templateResult: function (data, container) {
return $('<span>')
.append($('<img>', {
'class': 'user-search-image', src: data.gravatar_url,
width: 24, height: 24
}))
.append($('<span>', {'class': data.display_rank + ' user-search-name'}).text(data.text));
},
ajax: {
data: function (params) {
return {
term: params.term || '',
page: params.page || 1
}
},
processResults: function (data) {
return {
results: data.results,
pagination: {
more: data.more
}
};
},
},
};
$('#filter-user').select2($.extend(true, {}, user_select2,
{ajax: {url: '{{ url('ticket_user_select2_ajax') }}'}}));
$('#filter-assignee').select2($.extend(true, {}, user_select2,
{ajax: {url: '{{ url('ticket_assignee_select2_ajax') }}'}}));
}
});
</script>
}
{% if last_msg %}
<script type="text/javascript">
$(function () {
load_dynamic_update({{last_msg}});
});
</script>
{% endif %}
function ticket_status(ticket) {
if (!main_list_notify(ticket.id)) return;
var $row = $('#ticket-' + ticket.id);
console.log('Ticket status change: ' + ticket.id);
if ($row.length) {
var $status = $row.find('td').first().find('i');
if (ticket.open) {
$status.removeClass('fa-check-circle-o').addClass('fa-exclamation-circle');
notify('ticket', '{{ _('Reopened: ') }}' + ticket.title);
} else {
$status.removeClass('fa-exclamation-circle').addClass('fa-check-circle-o');
notify('ticket', '{{ _('Closed: ') }}' + ticket.title);
}
}
}
window.load_dynamic_update = function (last_msg) {
var $assignees = $(filter_assignee_ids);
return new EventReceiver(
"{{ EVENT_DAEMON_LOCATION }}", "{{ EVENT_DAEMON_POLL_LOCATION }}",
['tickets'], last_msg, function (message) {
console.log(message);
if (filter_own_id != null && message.user != filter_own_id &&
!~message.assignees.indexOf(filter_own_id))
return;
if (filter_user_ids.length && !~filter_user_ids.indexOf(message.user))
return;
if ($assignees.length && !$assignees.filter(message.assignees).length)
return;
switch (message.type) {
case 'new-ticket':
new_ticket(message);
break;
case 'ticket-status':
ticket_status(message);
break;
}
}
);
};
var user_select2 = {
escapeMarkup: function (markup) {
return markup;
},
templateResult: function (data, container) {
return $('<span>')
.append($('<img>', {
'class': 'user-search-image', src: data.gravatar_url,
width: 24, height: 24
}))
.append($('<span>', {'class': data.display_rank + ' user-search-name'}).text(data.text));
},
ajax: {
data: function (params) {
return {
term: params.term || '',
page: params.page || 1
}
},
processResults: function (data) {
return {
results: data.results,
pagination: {
more: data.more
}
};
},
},
};
$('#filter-user').select2($.extend(true, {}, user_select2,
{ajax: {url: '{{ url('ticket_user_select2_ajax') }}'}}));
$('#filter-assignee').select2($.extend(true, {}, user_select2,
{ajax: {url: '{{ url('ticket_assignee_select2_ajax') }}'}}));
});
</script>
{% if last_msg %}
<script type="text/javascript">
$(function () {
load_dynamic_update({{last_msg}});
});
</script>
{% endif %}
{% endblock %}
{% block body %}
<div id="container">
<aside>
<div>
<div id="notification-box">
<input id="desktop-notification" type="checkbox">
<label for="desktop-notification">{{ _('Use desktop notification') }}</label>
</div>
<div id="container">
<aside>
<div>
<div id="notification-box">
<input id="desktop-notification" type="checkbox">
<label for="desktop-notification">{{ _('Use desktop notification') }}</label>
</div>
<form id="filter-form" name="form" action="" method="get">
<div id="own-box" class="filter-check">
<input id="own" type="checkbox" name="own"{% if filter_status.own %} checked{% endif %} value="1">
<label for="own">{{ _('Show my tickets only') }}</label>
</div>
<form id="filter-form" name="form" action="" method="get">
<div id="own-box" class="filter-check">
<input id="own" type="checkbox" name="own"{% if filter_status.own %} checked{% endif %} value="1">
<label for="own">{{ _('Show my tickets only') }}</label>
</div>
<div id="user-box" class="filter-select2">
<label for="filter-user">{{ _('Filing user') }}</label>
<select id="filter-user" style="width: 100%" multiple name="user">
{% for username in filter_status.user %}
<option value="{{ username }}" selected>{{ username }}</option>
{% endfor %}
</select>
</div>
<div id="user-box" class="filter-select2">
<label for="filter-user">{{ _('Filing user') }}</label>
<select id="filter-user" style="width: 100%" multiple name="user">
{% for username in filter_status.user %}
<option value="{{ username }}" selected>{{ username }}</option>
{% endfor %}
</select>
</div>
<div id="assignee-box" class="filter-select2">
<label for="filter-user">{{ _('Assignee') }}</label>
<select id="filter-assignee" style="width: 100%" multiple name="assignee">
{% for username in filter_status.assignee %}
<option value="{{ username }}" selected>{{ username }}</option>
{% endfor %}
</select>
</div>
<div id="assignee-box" class="filter-select2">
<label for="filter-user">{{ _('Assignee') }}</label>
<select id="filter-assignee" style="width: 100%" multiple name="assignee">
{% for username in filter_status.assignee %}
<option value="{{ username }}" selected>{{ username }}</option>
{% endfor %}
</select>
</div>
<button type="submit" style="margin-left: auto" class="submit">{{ _('Go') }}</button>
</form>
</div>
</aside>
<button type="submit" style="margin-left: auto" class="submit">{{ _('Go') }}</button>
</form>
</div>
</aside>
<main>
{% if page_obj.num_pages > 1 %}
<div style="margin-bottom:6px; margin-top:3px">{% include "list-pages.html" %}</div>
{% endif %}
<table id="ticket-list" class="table h-scrollable-table">
<thead>
<tr>
<th></th>
<th>{{ _('ID') }}</th>
<th>{{ _('Title') }}</th>
<th>{{ _('User') }}</th>
<th>{{ _('Assignees') }}</th>
</tr>
</thead>
<tbody>
{% for ticket in tickets %}
{% include "ticket/row.html" %}
{% endfor %}
</tbody>
</table>
{% if page_obj.num_pages > 1 %}
<div style="margin-top:10px">{% include "list-pages.html" %}</div>
{% endif %}
</main>
</div>
<main>
{% if page_obj.num_pages > 1 %}
<div style="margin-bottom:6px; margin-top:3px">{% include "list-pages.html" %}</div>
{% endif %}
<table id="ticket-list" class="table h-scrollable-table">
<thead>
<tr>
<th></th>
<th>{{ _('ID') }}</th>
<th>{{ _('Title') }}</th>
<th>{{ _('User') }}</th>
<th>{{ _('Assignees') }}</th>
</tr>
</thead>
<tbody>
{% for ticket in tickets %}
{% include "ticket/row.html" %}
{% endfor %}
</tbody>
</table>
{% if page_obj.num_pages > 1 %}
<div style="margin-top:10px">{% include "list-pages.html" %}</div>
{% endif %}
</main>
</div>
{% endblock %}

View file

@ -1,22 +1,22 @@
<section id="message-{{ message.id }}" class="message">
<div class="detail">
<div class="header">
<div class="info">
<a class="user-container" href="{{ url('user_page', message.user.user.username) }}" class="user">
<img src="{{ gravatar(message.user, 135) }}" class="gravatar">
<span class="username {{ message.user.css_class }}">{{ message.user.user.username }}</span>
</a>
</div>
<div class="spacer"></div>
<div class="send-time">
<div class="relative-time"></div>
<div class="message-date">{{ message.time|date('DATE_FORMAT') }}</div>
<div class="message-time">{{ message.time|time('TIME_FORMAT') }}</div>
</div>
</div>
<div class="content content-description">
{{ message.body|markdown|reference|str|safe }}
</div>
<div class="detail">
<div class="header">
<div class="info">
<a class="user-container" href="{{ url('user_page', message.user.user.username) }}" class="user">
<img src="{{ gravatar(message.user, 135) }}" class="gravatar">
<span class="username {{ message.user.css_class }}">{{ message.user.user.username }}</span>
</a>
</div>
<div class="spacer"></div>
<div class="send-time">
<div class="relative-time"></div>
<div class="message-date">{{ message.time|date('DATE_FORMAT') }}</div>
<div class="message-time">{{ message.time|time('TIME_FORMAT') }}</div>
</div>
</div>
<div class="content content-description">
{{ message.body|markdown|reference|str|safe }}
</div>
</div>
</section>

View file

@ -1,40 +1,40 @@
{% extends "base.html" %}
{% block media %}
{{ form.media.css }}
<style>
form#ticket-form {
display: block;
margin: 0 auto;
width: 100%;
max-width: 750px;
padding-top: 1em;
}
{{ form.media.css }}
<style>
form#ticket-form {
display: block;
margin: 0 auto;
width: 100%;
max-width: 750px;
padding-top: 1em;
}
#id_title {
width: 100%;
}
#id_title {
width: 100%;
}
form#ticket-form .submit {
margin: 10px 0 0 auto;
}
</style>
form#ticket-form .submit {
margin: 10px 0 0 auto;
}
</style>
{% endblock %}
{% block js_media %}{{ form.media.js }}{% endblock %}
{% block body %}
<form id="ticket-form" action="" method="POST" class="form-area">
{% block guideline_message %}{% endblock %}
{% csrf_token %}
<div class="title-block{% if form.title.errors %} error{% endif %}">{{ form.title }}</div>
{% if form.title.errors or form.body.errors %}
<div class="form-errors">
{{ form.title.errors }}
{{ form.body.errors }}
</div>
{% endif %}
<div class="body-block">{{ form.body }}</div>
<button type="submit" class="submit">{{ _('Create') }}</button>
</form>
<form id="ticket-form" action="" method="POST" class="form-area">
{% block guideline_message %}{% endblock %}
{% csrf_token %}
<div class="title-block{% if form.title.errors %} error{% endif %}">{{ form.title }}</div>
{% if form.title.errors or form.body.errors %}
<div class="form-errors">
{{ form.title.errors }}
{{ form.body.errors }}
</div>
{% endif %}
<div class="body-block">{{ form.body }}</div>
<button type="submit" class="submit">{{ _('Create') }}</button>
</form>
{% endblock %}

View file

@ -1,12 +1,12 @@
{% extends "ticket/new.html" %}
{% block guideline_message %}
{% if not request.in_contest %}
<div class="alert alert-warning alert-dismissable">
<a class="close">x</a>
<b>{{ _('Thanks for opening a ticket!') }}</b>
<br><br>
{{ _('Please keep in mind that this form is for reporting issues with a problem statement, and not for asking for help. If you require assistance on solving a problem, ask in the comments instead.') }}
</div>
{% endif %}
{% if not request.in_contest %}
<div class="alert alert-warning alert-dismissable">
<a class="close">x</a>
<b>{{ _('Thanks for opening a ticket!') }}</b>
<br><br>
{{ _('Please keep in mind that this form is for reporting issues with a problem statement, and not for asking for help. If you require assistance on solving a problem, ask in the comments instead.') }}
</div>
{% endif %}
{% endblock %}

View file

@ -1,4 +1,4 @@
{{ preview_data|markdown|reference|str|safe }}
{% if REQUIRE_JAX %}
<div data-config="{{ static('mathjax3_config.js') }}" class="require-mathjax-support"></div>
<div data-config="{{ static('mathjax3_config.js') }}" class="require-mathjax-support"></div>
{% endif %}

View file

@ -1,7 +1,7 @@
<tr id="ticket-{{ ticket.id }}">
<td><i class="fa {% if ticket.is_open %}fa-exclamation-circle{% else %}fa-check-circle-o{% endif %}"></i></td>
<td>{{ ticket.id }}</td>
<td><a href="{{ url('ticket', ticket.id) }}">{{ ticket.title }}</a></td>
<td>{{ link_user(ticket.user) }}</td>
<td>{{ link_users(ticket.assignees.all()) }}</td>
<td><i class="fa {% if ticket.is_open %}fa-exclamation-circle{% else %}fa-check-circle-o{% endif %}"></i></td>
<td>{{ ticket.id }}</td>
<td><a href="{{ url('ticket', ticket.id) }}">{{ ticket.title }}</a></td>
<td>{{ link_user(ticket.user) }}</td>
<td>{{ link_users(ticket.assignees.all()) }}</td>
</tr>

View file

@ -1,234 +1,234 @@
{% extends "base.html" %}
{% block media %}
{{ form.media.css }}
{{ form.media.css }}
{% endblock %}
{% block js_media %}
{{ form.media.js }}
<script src="{{ static('libs/featherlight/featherlight.min.js') }}" type="text/javascript"></script>
<script type="text/javascript" src="{{ static('event.js') }}"></script>
<script type="text/javascript">
$(function () {
var $h2 = $('#content').find('> h2:first-child');
var $status = $h2.find('.status i'), $title = $h2.find('.title');
{{ form.media.js }}
<script src="{{ static('libs/featherlight/featherlight.min.js') }}" type="text/javascript"></script>
<script type="text/javascript" src="{{ static('event.js') }}"></script>
<script type="text/javascript">
$(function () {
var $h2 = $('#content').find('> h2:first-child');
var $status = $h2.find('.status i'), $title = $h2.find('.title');
function update_ticket_state(open) {
if (open)
$status.removeClass('fa-check-circle-o').addClass('fa-exclamation-circle');
else
$status.removeClass('fa-exclamation-circle').addClass('fa-check-circle-o');
$('.close-ticket').toggle(open);
$('.open-ticket').toggle(!open);
}
function update_ticket_state(open) {
if (open)
$status.removeClass('fa-check-circle-o').addClass('fa-exclamation-circle');
else
$status.removeClass('fa-exclamation-circle').addClass('fa-check-circle-o');
$('.close-ticket').toggle(open);
$('.open-ticket').toggle(!open);
}
$('.close-ticket, .open-ticket').click(function () {
var open = $(this).attr('data-open') == '1';
$.ajax({
url: $(this).attr('data-ajax'), type: 'POST',
success: function () {
update_ticket_state(open);
},
error: function (data) {
alert('Could not change ticket: ' + data.responseText);
}
});
});
$('.edit-notes').featherlight({
afterOpen: function () {
var $form = $('#edit-notes');
$form.find('.submit').click(function () {
$.post($form.attr('action'), $form.serialize()).done(function (data) {
$('#ticket-notes').find('.info-empty').toggle(!data).end().find('.info-real').html(data);
$.featherlight.current().close();
});
return false;
});
}
});
var page_ref_key = 'ticket:open:{{ ticket.id }}', page_close_key = page_ref_key + ':close';
var page_ref;
function increase_page_ref() {
if (page_ref_key in localStorage)
localStorage[page_ref_key] = page_ref = +localStorage[page_ref_key] + 1;
else
localStorage[page_ref_key] = page_ref = 1;
}
function decrease_page_ref() {
if (page_ref_key in localStorage) {
localStorage[page_close_key] = page_ref;
delete localStorage[page_close_key];
localStorage[page_ref_key] = +localStorage[page_ref_key] - 1;
}
page_ref = null;
}
function is_highest_ref() {
console.log(localStorage[page_ref_key], page_ref);
if (page_ref_key in localStorage)
return +localStorage[page_ref_key] == page_ref;
return true;
}
$(window).on('storage', function (e) {
e = e.originalEvent;
if (e.key == page_close_key && e.newValue !== null)
if (page_ref != null && page_ref > +e.newValue)
--page_ref;
});
register_notify('ticket', {
change: function (enabled) {
if (enabled)
increase_page_ref();
}
});
$(window).on('beforeunload', function () {
decrease_page_ref();
});
function ticket_status(ticket) {
update_ticket_state(ticket.open);
if (is_highest_ref())
notify('ticket', (ticket.open ? '{{ _('Reopened: ') }}' :
'{{ _('Closed: ') }}') + $title.text());
}
function ticket_message(ticket) {
$.ajax({
url: '{{ url('ticket_message_ajax', ticket.id) }}',
data: {message: ticket.message},
success: function (data) {
$('#messages').append($(data.message));
},
error: function (data) {
if (data.status === 403)
console.log('No right to see: ' + ticket.message);
else {
console.log('Could not load ticket message:');
console.log(data.responseText);
}
}
});
}
window.load_dynamic_update = function (last_msg) {
return new EventReceiver(
"{{ EVENT_DAEMON_LOCATION }}", "{{ EVENT_DAEMON_POLL_LOCATION }}",
['ticket-{{ ticket.id }}'], last_msg, function (message) {
switch (message.type) {
case 'ticket-status':
ticket_status(message);
break;
case 'ticket-message':
ticket_message(message);
break;
}
}
);
}
$('.close-ticket, .open-ticket').click(function () {
var open = $(this).attr('data-open') == '1';
$.ajax({
url: $(this).attr('data-ajax'), type: 'POST',
success: function () {
update_ticket_state(open);
},
error: function (data) {
alert('Could not change ticket: ' + data.responseText);
}
});
</script>
});
{% if last_msg %}
<script type="text/javascript">
$(function () {
load_dynamic_update({{last_msg}});
$('.edit-notes').featherlight({
afterOpen: function () {
var $form = $('#edit-notes');
$form.find('.submit').click(function () {
$.post($form.attr('action'), $form.serialize()).done(function (data) {
$('#ticket-notes').find('.info-empty').toggle(!data).end().find('.info-real').html(data);
$.featherlight.current().close();
});
</script>
{% endif %}
return false;
});
}
});
var page_ref_key = 'ticket:open:{{ ticket.id }}', page_close_key = page_ref_key + ':close';
var page_ref;
function increase_page_ref() {
if (page_ref_key in localStorage)
localStorage[page_ref_key] = page_ref = +localStorage[page_ref_key] + 1;
else
localStorage[page_ref_key] = page_ref = 1;
}
function decrease_page_ref() {
if (page_ref_key in localStorage) {
localStorage[page_close_key] = page_ref;
delete localStorage[page_close_key];
localStorage[page_ref_key] = +localStorage[page_ref_key] - 1;
}
page_ref = null;
}
function is_highest_ref() {
console.log(localStorage[page_ref_key], page_ref);
if (page_ref_key in localStorage)
return +localStorage[page_ref_key] == page_ref;
return true;
}
$(window).on('storage', function (e) {
e = e.originalEvent;
if (e.key == page_close_key && e.newValue !== null)
if (page_ref != null && page_ref > +e.newValue)
--page_ref;
});
register_notify('ticket', {
change: function (enabled) {
if (enabled)
increase_page_ref();
}
});
$(window).on('beforeunload', function () {
decrease_page_ref();
});
function ticket_status(ticket) {
update_ticket_state(ticket.open);
if (is_highest_ref())
notify('ticket', (ticket.open ? '{{ _('Reopened: ') }}' :
'{{ _('Closed: ') }}') + $title.text());
}
function ticket_message(ticket) {
$.ajax({
url: '{{ url('ticket_message_ajax', ticket.id) }}',
data: {message: ticket.message},
success: function (data) {
$('#messages').append($(data.message));
},
error: function (data) {
if (data.status === 403)
console.log('No right to see: ' + ticket.message);
else {
console.log('Could not load ticket message:');
console.log(data.responseText);
}
}
});
}
window.load_dynamic_update = function (last_msg) {
return new EventReceiver(
"{{ EVENT_DAEMON_LOCATION }}", "{{ EVENT_DAEMON_POLL_LOCATION }}",
['ticket-{{ ticket.id }}'], last_msg, function (message) {
switch (message.type) {
case 'ticket-status':
ticket_status(message);
break;
case 'ticket-message':
ticket_message(message);
break;
}
}
);
}
});
</script>
{% if last_msg %}
<script type="text/javascript">
$(function () {
load_dynamic_update({{last_msg}});
});
</script>
{% endif %}
{% endblock %}
{% block content_title %}
<span class="status">
<i class="fa {% if ticket.is_open %}fa-exclamation-circle{% else %}fa-check-circle-o{% endif %}"></i>
</span>
<span class="title">{{ ticket.title }}</span><small>#{{ ticket.id }}</small>
<span class="status">
<i class="fa {% if ticket.is_open %}fa-exclamation-circle{% else %}fa-check-circle-o{% endif %}"></i>
</span>
<span class="title">{{ ticket.title }}</span><small>#{{ ticket.id }}</small>
{% endblock %}
{% block body %}
<div class="ticket-container">
<div class="ticket-messages">
<main id="messages" class="messages">
{% for message in ticket_messages %}
{% include "ticket/message.html" %}
{% endfor %}
</main>
<hr>
<section class="message new-message">
<div class="info">
<a href="{{ url('user_page', request.user.username) }}" class="user">
<img src="{{ gravatar(request.user, 135) }}" class="gravatar">
<div class="username {{ request.profile.css_class }}">{{ request.user.username }}</div>
</a>
</div>
<div class="detail">
<form action="" method="post">
{% csrf_token %}
{% if form.non_field_errors() or form.body.errors %}
<div class="form-errors">
{{ form.non_field_errors() }}
{{ form.body.errors }}
</div>
{% endif %}
<div class="body-block">{{ form.body }}</div>
<button type="submit" class="submit">{{ _('Post') }}</button>
</form>
</div>
</section>
<div class="ticket-container">
<div class="ticket-messages">
<main id="messages" class="messages">
{% for message in ticket_messages %}
{% include "ticket/message.html" %}
{% endfor %}
</main>
<hr>
<section class="message new-message">
<div class="info">
<a href="{{ url('user_page', request.user.username) }}" class="user">
<img src="{{ gravatar(request.user, 135) }}" class="gravatar">
<div class="username {{ request.profile.css_class }}">{{ request.user.username }}</div>
</a>
</div>
<aside class="ticket-sidebar">
<div class="ticket-info">
<div class="info-box">
<div class="info-title">{{ _('Associated object') }}</div>
<div class="info-data">
<a href="{{ ticket.linked_item.get_absolute_url() }}">{{ ticket.linked_item }}</a>
</div>
</div>
<div class="info-box">
<div class="info-title">{{ _('Assignees') }}</div>
<div class="info-data">
{% if assignees %}
{{ link_users(assignees) }}
{% else %}
<div class="info-empty">{{ _('No one is assigned.') }}</div>
{% endif %}
</div>
</div>
<button data-ajax="{{ url('ticket_close', ticket.id) }}" data-open="0" class="close-ticket"
{% if not ticket.is_open %}style="display: none"{% endif %}>{{ _('Close ticket') }}</button>
<button data-ajax="{{ url('ticket_open', ticket.id) }}" data-open="1" class="open-ticket"
{% if ticket.is_open %}style="display: none"{% endif %}>{{ _('Reopen ticket') }}</button>
{% if perms.judge.change_ticket or request.profile in assignees %}
<div class="info-box">
<div class="info-title">{{ _('Assignee notes') }}
<a href="#" data-featherlight="{{ url('ticket_notes', ticket.id) }}" class="edit-notes">
<i class="fa fa-pencil"></i>
</a>
</div>
<div id="ticket-notes" class="info-data">
<div{% if ticket.notes %} style="display: none"{% endif %} class="info-empty">
{{ _('Nothing here.') }}
</div>
<div class="info-real">{{ ticket.notes|linebreaks }}</div>
</div>
</div>
{% endif %}
</div>
</aside>
<div class="detail">
<form action="" method="post">
{% csrf_token %}
{% if form.non_field_errors() or form.body.errors %}
<div class="form-errors">
{{ form.non_field_errors() }}
{{ form.body.errors }}
</div>
{% endif %}
<div class="body-block">{{ form.body }}</div>
<button type="submit" class="submit">{{ _('Post') }}</button>
</form>
</div>
</section>
</div>
<aside class="ticket-sidebar">
<div class="ticket-info">
<div class="info-box">
<div class="info-title">{{ _('Associated object') }}</div>
<div class="info-data">
<a href="{{ ticket.linked_item.get_absolute_url() }}">{{ ticket.linked_item }}</a>
</div>
</div>
<div class="info-box">
<div class="info-title">{{ _('Assignees') }}</div>
<div class="info-data">
{% if assignees %}
{{ link_users(assignees) }}
{% else %}
<div class="info-empty">{{ _('No one is assigned.') }}</div>
{% endif %}
</div>
</div>
<button data-ajax="{{ url('ticket_close', ticket.id) }}" data-open="0" class="close-ticket"
{% if not ticket.is_open %}style="display: none"{% endif %}>{{ _('Close ticket') }}</button>
<button data-ajax="{{ url('ticket_open', ticket.id) }}" data-open="1" class="open-ticket"
{% if ticket.is_open %}style="display: none"{% endif %}>{{ _('Reopen ticket') }}</button>
{% if perms.judge.change_ticket or request.profile in assignees %}
<div class="info-box">
<div class="info-title">{{ _('Assignee notes') }}
<a href="#" data-featherlight="{{ url('ticket_notes', ticket.id) }}" class="edit-notes">
<i class="fa fa-pencil"></i>
</a>
</div>
<div id="ticket-notes" class="info-data">
<div{% if ticket.notes %} style="display: none"{% endif %} class="info-empty">
{{ _('Nothing here.') }}
</div>
<div class="info-real">{{ ticket.notes|linebreaks }}</div>
</div>
</div>
{% endif %}
</div>
</aside>
</div>
{% endblock %}
{% block bodyend %}
{{ super() }}
{% if REQUIRE_JAX %}
{% include "mathjax-load.html" %}
{% endif %}
{% include "comments/math.html" %}
{{ super() }}
{% if REQUIRE_JAX %}
{% include "mathjax-load.html" %}
{% endif %}
{% include "comments/math.html" %}
{% endblock %}