From c99f816e71d28dfaf3bd44d27d211f2b44778f48 Mon Sep 17 00:00:00 2001 From: Joseph Date: Tue, 17 Apr 2018 23:12:35 +0100 Subject: Add wiki audit logs (#52) * Add wiki audit logs * Flake8 issues * Forgot to remove debug prints * Removed print but forgot to remove `.text` * Futile attempt to increase coverage * Reading up on API docs asks us to send User-Agent with our info in it * Add tests for wiki * Well played, Travis * Nothing in my local env is working on travis lol * Why does it appear it can't decide between 200 & 302 :thinking: * Flake8 * Post route * Same issue with local env working differently from Travis env * Add page to show page is being edited * Lock page when it is being edited * Add JS to keep refreshing lock on article * Add compare route to render diff * Add revision table to database * Add revision storage * Add revision list route * JS for Revision list radio buttons * Add revision comparison template * Add revision list template * flak8 my ass * [Unit Tests] New unit tests for history routes :sparkles: * Does this fix things? * Address gdude's reviews * Noticed a bug in the diff generation route which meant that empty posts could potentially error * Flake 8 * Audit logs were logging after change, meaning it was comparing after & after, which didn't work * Change table name * Remove whitespace from line to fix flake8 issue * Address reviews * Git hook made me do something wrong, apologies * Switch from werkzeug redirect to flask one * Address Apertures reviews --- templates/wiki/compare_revision.html | 13 +++++++++++++ templates/wiki/page_edit.html | 20 +++++++++++++++++++- templates/wiki/page_in_use.html | 13 +++++++++++++ templates/wiki/revision_list.html | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 templates/wiki/compare_revision.html create mode 100644 templates/wiki/page_in_use.html create mode 100644 templates/wiki/revision_list.html (limited to 'templates/wiki') diff --git a/templates/wiki/compare_revision.html b/templates/wiki/compare_revision.html new file mode 100644 index 00000000..34ab61bc --- /dev/null +++ b/templates/wiki/compare_revision.html @@ -0,0 +1,13 @@ +{% extends "wiki/base.html" %} +{% block title %}Wiki | Comparing {{ title }}{% endblock %} +{% block og_title %}Wiki | Comparing {{ title }}{% endblock %} +{% block og_description %}{% endblock %} +{% block content %} +
+

+ Revision comparison for {{ title }} +

+ + {{ diff | safe }} +
+{% endblock %} diff --git a/templates/wiki/page_edit.html b/templates/wiki/page_edit.html index b59a8912..a2d709e2 100644 --- a/templates/wiki/page_edit.html +++ b/templates/wiki/page_edit.html @@ -99,5 +99,23 @@ document.getElementById("title").oninput = function() { document.getElementById("preview-title").textContent = document.getElementById("title").value; } + + function refreshLock(){ + console.log("Refreshing lock") + let xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function() { + if (this.readyState === 4 && this.status === 204) { + console.log("Lock refreshed") + } else if(this.readyState === 4 && this.status !== 204) { + console.log("Could not refresh lock") + } + }; + + xhttp.open("PATCH", document.location.pathname, true); + xhttp.send(); + } + + // Lock refreshing + setInterval(refreshLock, (60 * 4) * 1000) -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/templates/wiki/page_in_use.html b/templates/wiki/page_in_use.html new file mode 100644 index 00000000..4110ee17 --- /dev/null +++ b/templates/wiki/page_in_use.html @@ -0,0 +1,13 @@ +{% extends "wiki/base.html" %} +{% block title %}Wiki Error{% endblock %} +{% block og_title %}Wiki Error{% endblock %} +{% block og_description %}{% endblock %} +{% block content %} +
+
+ +

The page you requested is currently being edited

+

Please try again in a little bit when the lock has expired.

+
+
+{% endblock %} diff --git a/templates/wiki/revision_list.html b/templates/wiki/revision_list.html new file mode 100644 index 00000000..6eb5b6a8 --- /dev/null +++ b/templates/wiki/revision_list.html @@ -0,0 +1,36 @@ +{% extends "wiki/base.html" %} +{% block title %}Wiki | Revisions to {{ page }}{% endblock %} +{% block og_title %}Wiki | Revisions to {{ page }}{% endblock %} +{% block og_description %}{% endblock %} +{% block content %} +
+

Wiki page revisions

+ + + + + + + + + + + + {% for revision in revisions %} + + + + + + + + {% endfor %} + +
Page titleDateUser IDCompare beforeCompare after
{{ revision["post"]["title"] }}{{ revision["pretty_time"] }}{{ revision['user'] }}
+ Compare selections +
+ + +{% endblock %} -- cgit v1.2.3