mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-02-27 00:28:23 +00:00
FEAT: Markdown support on asset comments
This commit is contained in:
@@ -7,6 +7,7 @@ __author__ = 'ghost'
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter(name="markdown")
|
||||
def markdown_filter(text, input_format='html'):
|
||||
# markdown library can't handle text=None
|
||||
|
||||
@@ -1,9 +1,36 @@
|
||||
{% extends 'base_assets.html' %}
|
||||
{% load static %}
|
||||
{% load widget_tweaks %}
|
||||
{% block title %}Asset {{ object.asset_id }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% block css %}
|
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
|
||||
{% endblock %}
|
||||
|
||||
{% block preload_js %}
|
||||
<script src="//cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
|
||||
<script src="{% static 'js/interaction.js' %}"></script>
|
||||
<script>
|
||||
function checkIfCableHidden() {
|
||||
if (document.getElementById("id_is_cable").checked) {
|
||||
document.getElementById("cable-table").hidden = false;
|
||||
} else {
|
||||
document.getElementById("cable-table").hidden = true;
|
||||
}
|
||||
}
|
||||
checkIfCableHidden();
|
||||
|
||||
$(document).ready(function () {
|
||||
setupMDE('#id_comments');
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h1>
|
||||
{% if duplicate %}
|
||||
@@ -45,16 +72,3 @@
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js%}
|
||||
<script>
|
||||
function checkIfCableHidden() {
|
||||
if (document.getElementById("id_is_cable").checked) {
|
||||
document.getElementById("cable-table").hidden = false;
|
||||
} else {
|
||||
document.getElementById("cable-table").hidden = true;
|
||||
}
|
||||
}
|
||||
checkIfCableHidden();
|
||||
</script>
|
||||
{%endblock%}
|
||||
|
||||
@@ -1,9 +1,38 @@
|
||||
{% extends 'base_assets.html' %}
|
||||
{% load static %}
|
||||
{% load widget_tweaks %}
|
||||
{% block title %}Asset {{ object.asset_id }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% block css %}
|
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
|
||||
{% endblock %}
|
||||
|
||||
{% block preload_js %}
|
||||
<script src="//cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block js %}
|
||||
{% if edit %}
|
||||
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
|
||||
<script src="{% static 'js/interaction.js' %}"></script>
|
||||
<script>
|
||||
function checkIfCableHidden() {
|
||||
if (document.getElementById("id_is_cable").checked) {
|
||||
document.getElementById("cable-table").hidden = false;
|
||||
} else {
|
||||
document.getElementById("cable-table").hidden = true;
|
||||
}
|
||||
}
|
||||
checkIfCableHidden();
|
||||
|
||||
$(document).ready(function () {
|
||||
setupMDE('#id_comments');
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h1>
|
||||
{% if edit and object %}
|
||||
@@ -53,18 +82,3 @@
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block js%}
|
||||
{% if edit %}
|
||||
<script>
|
||||
function checkIfCableHidden() {
|
||||
if (document.getElementById("id_is_cable").checked) {
|
||||
document.getElementById("cable-table").hidden = false;
|
||||
} else {
|
||||
document.getElementById("cable-table").hidden = true;
|
||||
}
|
||||
}
|
||||
checkIfCableHidden();
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{% load widget_tweaks %}
|
||||
{% load markdown_tags %}
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Asset Details
|
||||
@@ -35,14 +36,14 @@
|
||||
<!---TODO: Lower default number of lines in comments box-->
|
||||
<div class="form-group">
|
||||
<label for="{{ form.comments.id_for_label }}">Comments</label>
|
||||
{% render_field form.comments|add_class:'form-control' %}
|
||||
{% render_field form.comments|add_class:'form-control md-enabled' %}
|
||||
</div>
|
||||
{% else %}
|
||||
<dt>Asset ID</dt>
|
||||
<dd>{{ object.asset_id }}</dd>
|
||||
|
||||
<dt>Description</dt>
|
||||
<dd style="overflow-wrap: break-word;">{{ object.description }}</dd>
|
||||
<dd class="dont-break-out">{{ object.description }}</dd>
|
||||
|
||||
<dt>Category</dt>
|
||||
<dd>{{ object.category }}</dd>
|
||||
@@ -54,7 +55,7 @@
|
||||
<dd>{{ object.serial_number|default:'-' }}</dd>
|
||||
|
||||
<dt>Comments</dt>
|
||||
<dd style="overflow-wrap: break-word;">{{ object.comments|default:'-'|linebreaksbr }}</dd>
|
||||
<dd class="dont-break-out well">{{ object.comments|default:'-'|markdown }}</dd>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user