diff --git a/apps/audits/api.py b/apps/audits/api.py index 7a86156f0..4801c2e5e 100644 --- a/apps/audits/api.py +++ b/apps/audits/api.py @@ -6,7 +6,7 @@ from rest_framework import generics import serializers -from .models import ProxyLog +from .models import ProxyLog, CommandLog from .hands import IsSuperUserOrTerminalUser, Terminal @@ -45,5 +45,7 @@ class ProxyLogDetailApi(generics.RetrieveUpdateDestroyAPIView): permission_classes = (IsSuperUserOrTerminalUser,) -class CommandLogCreateApi(generics.CreateAPIView): +class CommandLogCreateApi(generics.ListCreateAPIView): + queryset = CommandLog.objects.all() serializer_class = serializers.CommandLogSerializer + permission_classes = (IsSuperUserOrTerminalUser,) diff --git a/apps/audits/models.py b/apps/audits/models.py index 76d086810..29cd7b981 100644 --- a/apps/audits/models.py +++ b/apps/audits/models.py @@ -60,14 +60,14 @@ class ProxyLog(models.Model): class CommandLog(models.Model): proxy_log = models.ForeignKey(ProxyLog, on_delete=models.CASCADE, related_name='command_log') + command_no = models.IntegerField() command = models.CharField(max_length=1000, blank=True) output = models.TextField(blank=True) - date_start = models.DateTimeField(null=True) - date_finished = models.DateTimeField(null=True) + datetime = models.DateTimeField(null=True) def __unicode__(self): return '%s: %s' % (self.id, self.command) class Meta: db_table = 'command_log' - ordering = ['-date_start', 'command'] + ordering = ['command_no', 'command'] diff --git a/apps/audits/serializers.py b/apps/audits/serializers.py index 74adc8ee0..97be972ae 100644 --- a/apps/audits/serializers.py +++ b/apps/audits/serializers.py @@ -16,5 +16,4 @@ class CommandLogSerializer(serializers.ModelSerializer): model = models.CommandLog -if __name__ == '__main__': - pass +