diff --git a/logs/migrations/0002_auto_20150316_1420.py b/logs/migrations/0002_auto_20150316_1420.py new file mode 100644 index 0000000..eb8cc13 --- /dev/null +++ b/logs/migrations/0002_auto_20150316_1420.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import datetime +from django.conf import settings +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('logs', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='logs', + name='user', + field=models.ForeignKey(to=settings.AUTH_USER_MODEL), + preserve_default=False, + ), + migrations.AlterField( + model_name='logs', + name='date', + field=models.DateTimeField(auto_now=True), + preserve_default=True, + ), + ] diff --git a/logs/models.py b/logs/models.py index a8ed08b..3a51e6c 100644 --- a/logs/models.py +++ b/logs/models.py @@ -1,11 +1,12 @@ from django.db import models from instances.models import Instance - +from django.contrib.auth.models import User class Logs(models.Model): + user = models.ForeignKey(User) instance = models.ForeignKey(Instance) message = models.CharField(max_length=255) - date = models.DateTimeField() + date = models.DateTimeField(auto_now=True) def __unicode__(self): return self.instance \ No newline at end of file diff --git a/logs/views.py b/logs/views.py index ff8493f..f8bf0ed 100644 --- a/logs/views.py +++ b/logs/views.py @@ -16,6 +16,6 @@ def showlogs(request): if not request.user.is_superuser: return HttpResponseRedirect(reverse('index')) - + logs = Logs.objects.all() return render(request, 'showlogs.html', locals()) \ No newline at end of file diff --git a/templates/showlogs.html b/templates/showlogs.html index 6a0b951..c6309fc 100644 --- a/templates/showlogs.html +++ b/templates/showlogs.html @@ -13,5 +13,40 @@ {% include 'errors_block.html' %}
+
+ {% if not logs %} +
+
+ + {% trans "Warning:" %} {% trans "You don't have any Logs" %} +
+
+ {% else %} +
+ + + + + + + + + + + + {% for log in logs %} + + + + + + + + {% endfor %} + +
#{% trans "User" %}{% trans "Instance" %}{% trans "Message" %}{% trans "Date" %}
{{ forloop.counter }}{{ log.user }}{{ log.instance }}{{ log.message }}{{ log.date }}
+
+ {% endif %} +
{% endblock %} \ No newline at end of file