Skip to content

Commit

Permalink
[#65][ADD] Event modification history in event view
Browse files Browse the repository at this point in the history
  • Loading branch information
whikernel committed May 8, 2022
1 parent e50a951 commit 7ebacf6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
24 changes: 20 additions & 4 deletions source/app/blueprints/case/templates/modal_add_case_event.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<div class="modal-header">
<h4 class="modal-title mt-1 mr-4">{% if event.event_id %} Event ID #{{ event.event_id }} {% else %} Add event {% endif %}
<i class="fas fa-info-circle ml-3 mt-2" data-toggle="popover"
title="Task info"
data-content="Last edited {{ event.event_added }} by {{ user_name }}"></i>
{% if event.modification_history %}
<i class="fas fa-info-circle ml-3 mt-2" data-toggle="popover" data-html="true" id="pop_history"
title="Modifications history"
data-content="{% for mod in event.modification_history %}
<code id='mh-{{loop.index}}'></code> - {{ event.modification_history[mod].action }} by {{ event.modification_history[mod].user }}<br/>{% endfor %}">
</i>
{% endif %}
</h4>
{% include 'modals/modal_attributes_nav.html' %}
{% if event.event_id %}
Expand Down Expand Up @@ -267,4 +271,16 @@ <h4 class="modal-title mt-1 mr-4">{% if event.event_id %} Event ID #{{ event.ev
]);
$('#event_iocs').trigger('change');
</script>
{% endif %}
{% endif %}

{% if event.modification_history %}
<script>
$('#pop_history').on('shown.bs.popover', function () {
{% for mod in event.modification_history %}
di = new Date({{mod}} * 1000).toLocaleString();
$('#mh-{{loop.index}}').text(di);
console.log(di);
{% endfor %}
})
</script>
{% endif %}
2 changes: 1 addition & 1 deletion source/app/blueprints/context/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def iris_version():
@app.context_processor
def has_updates():

if not current_user.is_authenticated and current_user.is_admin():
if not current_user.is_authenticated or current_user.is_admin():
return dict(has_updates=False)

server_settings = ServerSettings.query.with_entities(ServerSettings.has_updates_available).first()
Expand Down
3 changes: 3 additions & 0 deletions source/app/static/assets/css/atlantis.css
Original file line number Diff line number Diff line change
Expand Up @@ -8074,6 +8074,9 @@ body[data-background-color="dark"] .badge-danger {

.popover .popover-body {
margin-bottom: 5px;
max-height: 60rem;
overflow-y: auto;
white-space:pre-wrap;
}

.popover .popover-body p {
Expand Down
3 changes: 3 additions & 0 deletions source/app/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from flask import json, url_for, request, render_template
from flask_login import current_user
from sqlalchemy.ext.declarative import DeclarativeMeta
from sqlalchemy.orm.attributes import flag_modified
from werkzeug.utils import redirect

from functools import wraps
Expand Down Expand Up @@ -384,8 +385,10 @@ def add_obj_history_entry(obj, action):
'action': action
}
}
flag_modified(obj, "modification_history")
return obj


# Set basic 404
@app.errorhandler(404)
def page_not_found(e):
Expand Down

0 comments on commit 7ebacf6

Please sign in to comment.