Keep track of the test as a key, not text
This commit is contained in:
1 parent
c792b9fd3b
commit
5eca62e644
3 files changed
+33
-30
No files matched your search
+10
-10
@@ -3,16 +3,6 @@ from django.db.models import ForeignKey, DateTimeField, OneToOneField
|
|||||||
from django.db.models import CASCADE, PROTECT, Model
|
from django.db.models import CASCADE, PROTECT, Model
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
|
||||||
class LogEvent(Model):
|
|
||||||
|
|
||||||
data = CharField(max_length=256)
|
|
||||||
author = CharField(max_length=64)
|
|
||||||
creation = DateTimeField(auto_now_add=True)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return "{0} {1} : {2}".format(self.creation, self.author, self.data)
|
|
||||||
|
|
||||||
class Engine(Model):
|
class Engine(Model):
|
||||||
|
|
||||||
name = CharField(max_length=128)
|
name = CharField(max_length=128)
|
||||||
@@ -106,3 +96,13 @@ class Test(Model):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '{0} vs {1} @ {2}'.format(self.dev.name, self.base.name, self.timecontrol)
|
return '{0} vs {1} @ {2}'.format(self.dev.name, self.base.name, self.timecontrol)
|
||||||
|
|
||||||
|
class LogEvent(Model):
|
||||||
|
|
||||||
|
data = CharField(max_length=256)
|
||||||
|
author = CharField(max_length=64)
|
||||||
|
test = ForeignKey('Test', PROTECT, related_name='test1')
|
||||||
|
creation = DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "{0} {1} {2}".format(self.author, str(self.test), self.data)
|
||||||
+21
-20
@@ -46,11 +46,6 @@ def register(request):
|
|||||||
# Log the User in now
|
# Log the User in now
|
||||||
loginUser(request, User.objects.get(username=request.POST['username']))
|
loginUser(request, User.objects.get(username=request.POST['username']))
|
||||||
|
|
||||||
# Log the registration
|
|
||||||
LogEvent.objects.create(
|
|
||||||
data='Created an account',
|
|
||||||
author=request.POST['username'])
|
|
||||||
|
|
||||||
# Kick back to index
|
# Kick back to index
|
||||||
return HttpResponseRedirect('/index/')
|
return HttpResponseRedirect('/index/')
|
||||||
|
|
||||||
@@ -188,8 +183,9 @@ def newTest(request):
|
|||||||
|
|
||||||
# Log the test creation
|
# Log the test creation
|
||||||
LogEvent.objects.create(
|
LogEvent.objects.create(
|
||||||
data='Created test {0} ({1})'.format(str(test), test.id),
|
data='Created Test',
|
||||||
author=request.user.username)
|
author=request.user.username,
|
||||||
|
test=test)
|
||||||
|
|
||||||
return HttpResponseRedirect('/index/')
|
return HttpResponseRedirect('/index/')
|
||||||
|
|
||||||
@@ -228,8 +224,9 @@ def editTest(request, id):
|
|||||||
|
|
||||||
# Log changes to the test settings
|
# Log changes to the test settings
|
||||||
LogEvent.objects.create(
|
LogEvent.objects.create(
|
||||||
data='Edited test {0} ({1}) P={2} TP={3}'.format(str(test), test.id, test.priority, test.throughput),
|
data='Edited Test P={0} TP={1}'.format(test.priority, test.throughput),
|
||||||
author=request.user.username)
|
author=request.user.username,
|
||||||
|
test=test)
|
||||||
|
|
||||||
return HttpResponseRedirect('/index/')
|
return HttpResponseRedirect('/index/')
|
||||||
|
|
||||||
@@ -253,8 +250,9 @@ def approveTest(request, id):
|
|||||||
|
|
||||||
# Log the test approval
|
# Log the test approval
|
||||||
LogEvent.objects.create(
|
LogEvent.objects.create(
|
||||||
data='Approved test {0} ({1})'.format(str(test), test.id),
|
data='Approved Test',
|
||||||
author=request.user.username)
|
author=request.user.username,
|
||||||
|
test=test)
|
||||||
|
|
||||||
return HttpResponseRedirect('/index/')
|
return HttpResponseRedirect('/index/')
|
||||||
|
|
||||||
@@ -281,8 +279,9 @@ def restartTest(request, id):
|
|||||||
|
|
||||||
# Log the test stopping
|
# Log the test stopping
|
||||||
LogEvent.objects.create(
|
LogEvent.objects.create(
|
||||||
data='Restarted test {0} ({1})'.format(str(test), test.id),
|
data='Restarted Test',
|
||||||
author=request.user.username)
|
author=request.user.username,
|
||||||
|
test=test)
|
||||||
|
|
||||||
return HttpResponseRedirect('/index/')
|
return HttpResponseRedirect('/index/')
|
||||||
|
|
||||||
@@ -307,8 +306,9 @@ def stopTest(request, id):
|
|||||||
|
|
||||||
# Log the test stopping
|
# Log the test stopping
|
||||||
LogEvent.objects.create(
|
LogEvent.objects.create(
|
||||||
data='Stopped test {0} ({1})'.format(str(test), test.id),
|
data='Stopped Test',
|
||||||
author=request.user.username)
|
author=request.user.username,
|
||||||
|
test=test)
|
||||||
|
|
||||||
return HttpResponseRedirect('/index/')
|
return HttpResponseRedirect('/index/')
|
||||||
|
|
||||||
@@ -333,8 +333,9 @@ def deleteTest(request, id):
|
|||||||
|
|
||||||
# Log the test deltion
|
# Log the test deltion
|
||||||
LogEvent.objects.create(
|
LogEvent.objects.create(
|
||||||
data='Deleted test {0} ({1})'.format(str(test), test.id),
|
data='Deleted Test',
|
||||||
author=request.user.username)
|
author=request.user.username,
|
||||||
|
test=test)
|
||||||
|
|
||||||
return HttpResponseRedirect('/index/')
|
return HttpResponseRedirect('/index/')
|
||||||
|
|
||||||
@@ -399,9 +400,9 @@ def wrongBench(request):
|
|||||||
|
|
||||||
# Log the bad bench so we know why the test was stopped
|
# Log the bad bench so we know why the test was stopped
|
||||||
LogEvent.objects.create(
|
LogEvent.objects.create(
|
||||||
data='Invalid bench for {0} with {1}'.format(str(test), str(engine)),
|
data='Invalid Bench',
|
||||||
author=request.POST['username']
|
author=request.POST['username'],
|
||||||
)
|
test=test)
|
||||||
except: pass
|
except: pass
|
||||||
|
|
||||||
return HttpResponse('None')
|
return HttpResponse('None')
|
||||||
|
|||||||
@@ -9,12 +9,14 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
<th>User</th>
|
<th>User</th>
|
||||||
|
<th>Test</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for event in events %}
|
{% for event in events %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{event.creation|date:'Y-m-d H:i:s'}}</td>
|
<td>{{event.creation|date:'Y-m-d H:i:s'}}</td>
|
||||||
<td>{{event.author}}</td>
|
<td>{{event.author}}</td>
|
||||||
|
<td><a href="/viewTest/{{event.test.id}}">{{event.test.dev.name}}</a></td>
|
||||||
<td>{{event.data}}</td>
|
<td>{{event.data}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
Reference in new issue
Block a user