You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

reports.py 845B

123456789101112131415161718192021222324252627282930
  1. class ReportGenerator(object):
  2. u"""
  3. Top-level class that needs to be subclassed to provide a
  4. report generator.
  5. """
  6. filename_template = 'report-%s-to-%s.csv'
  7. mimetype = 'text/csv'
  8. code = ''
  9. description = '<insert report description>'
  10. def __init__(self, **kwargs):
  11. if 'start_date' in kwargs and 'end_date' in kwargs:
  12. self.start_date = kwargs['start_date']
  13. self.end_date = kwargs['end_date']
  14. def generate(self, response):
  15. pass
  16. def filename(self):
  17. u"""
  18. Returns the filename for this report
  19. """
  20. return self.filename_template % (self.start_date, self.end_date)
  21. def is_available_to(self, user):
  22. u"""
  23. Checks whether this report is available to this user
  24. """
  25. return user.is_staff