Better logging

This commit is contained in:
AndyGrant committed 2018-06-10 14:11:41 -04:00
1 parent f8e344fe00
commit 7d63b6b917
11 files changed
+14 -39

No files matched your search

+2 -1
View File
@@ -7,10 +7,11 @@ from django.contrib.auth.models import User
class LogEvent(Model):
data = CharField(max_length=256)
author = CharField(max_length=64)
creation = DateTimeField(auto_now=True)
def __str__(self):
return "{0} : {1}".format(self.creation, self.data)
return "{0} {1} : {2}".format(self.creation, self.author, self.data)
class Engine(Model):
+4
View File
@@ -32,6 +32,10 @@ table {
font-size: 20px;
}
th, td {
border: 1px solid black;
}
th {
text-align: center;
padding: 4px 16px;
+5 -8
View File
@@ -43,7 +43,8 @@ def register(request):
# Log the registration
event = LogEvent()
event.data = 'Created user {0}'.format(request.POST['username'])
event.data = 'Created an account'
event.author = request.POST['username']
event.save()
# Kick back to index
@@ -128,11 +129,7 @@ def machines(request):
def eventLog(request):
# Build context dictionary for template
data = {'events': []}
for event in LogEvent.objects.all():
data['events'].append({
'data' : event.data,
'creation' : event.creation})
data = {'events': LogEvent.objects.all()}
return render(request, 'eventLog.html', data)
@login_required
@@ -148,8 +145,8 @@ def newTest(request):
# Log the test creation
event = LogEvent()
event.data = '{0} : Created {1} (id={2})'.format(
request.user.username, str(test), test.id)
event.data = 'Created Test {0} ({1})'.format(str(test), test.id)
event.author = request.user.username
event.save()
return HttpResponseRedirect('/index/')
+1 -5
View File
@@ -5,11 +5,7 @@
<head>
<link rel="stylesheet" href="{% static 'style.css' %}">
<title>
{% block title %}
OpenBench
{% endblock %}
</title>
<title>OpenBench</title>
</head>
<body>
{% if error %}
+2 -5
View File
@@ -1,9 +1,5 @@
{% extends "OpenBench/base.html" %}
{% block title %}
Event Log
{% endblock %}
{% block style %}
{% load static %}
{% endblock %}
@@ -12,7 +8,8 @@ Event Log
<table>
{% for event in events %}
<tr>
<td>{{event.creation}}</td>
<td style='text-align:left'>{{event.creation}}</td>
<td style='text-align:left'>{{event.author}}</td>
<td style='text-align:left'>{{event.data}}</td>
</tr>
{% endfor %}
-4
View File
@@ -2,10 +2,6 @@
{% load mytags %}
{% block title %}
Index
{% endblock %}
{% block content %}
<h2>Pending</h2>
<table>
-4
View File
@@ -1,9 +1,5 @@
{% extends "OpenBench/base.html" %}
{% block title %}
Login
{% endblock %}
{% block style %}
{% load static %}
{% endblock %}
-4
View File
@@ -1,9 +1,5 @@
{% extends "OpenBench/base.html" %}
{% block title %}
New Testhttp://127.0.0.1:12345/index
{% endblock %}
{% block content %}
<form method="POST" action="/newTest/">
{% csrf_token %}
-4
View File
@@ -1,9 +1,5 @@
{% extends "OpenBench/base.html" %}
{% block title %}
Register
{% endblock %}
{% block style %}
{% load static %}
{% endblock %}
-4
View File
@@ -1,9 +1,5 @@
{% extends "OpenBench/base.html" %}
{% block title %}
Event Log
{% endblock %}
{% block style %}
{% load static %}
{% endblock %}
BIN
View File
Binary file not shown.