Skip to content

Instantly share code, notes, and snippets.

@davebshow
Last active August 29, 2015 14:05
Show Gist options
  • Save davebshow/ac32992cd9abd30baac9 to your computer and use it in GitHub Desktop.
Save davebshow/ac32992cd9abd30baac9 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from django.db import models
from jsonfield import JSONField
from base.fields import AutoSlugField
from graphs.models import Graph
from operators.models import Query
class ReportTemplate(models.Model):
name = models.CharField(max_length=150)
slug = AutoSlugField(populate_from=['name'], max_length=250,
editable=False, unique=True)
start_date = models.DateTimeField()
frequency = models.DateTimeField() # maybe here just use an integer in minutes...
last_run = models.DateTimeField()
table = JSONField()
graph = models.ForeignKey(Graph, related_name='report_templates')
queries = models.ManyToManyField(Query, related_name='report_templates')
# Various methods here
class Report(models.Model):
date_run = models.DateTimeField()
slug = AutoSlugField(populate_from=['date_run'], max_length=250,
editable=False, unique=True) # maybe populate from date_run...
table = JSONField()
template = models.ForeignKey(ReportTemplate, related_name='reports')
# Various methods here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment