Initial work on reports API

This commit is contained in:
Jeremy Stretch
2017-09-21 16:32:05 -04:00
parent 16d1f9aca8
commit b5ab498e75
9 changed files with 199 additions and 44 deletions

View File

@@ -6,6 +6,7 @@ import graphviz
from django.contrib.auth.models import User
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.contrib.postgres.fields import JSONField
from django.core.validators import ValidationError
from django.db import models
from django.db.models import Q
@@ -388,6 +389,26 @@ class ImageAttachment(models.Model):
return None
#
# Report results
#
class ReportResult(models.Model):
"""
This model stores the results from running a user-defined report.
"""
report = models.CharField(max_length=255, unique=True)
created = models.DateTimeField(auto_created=True)
user = models.ForeignKey(User, on_delete=models.SET_NULL, related_name='+', blank=True, null=True)
data = JSONField()
class Meta:
ordering = ['report']
permissions = (
('run_report', 'Run a report and save the results'),
)
#
# User actions
#