{ "info": { "author": "Brandon Konkle", "author_email": "brandon.konkle@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP" ], "description": "===============\r\nDjango-reporter\r\n===============\r\n\r\nA Django application to create automated email reports in .csv format. It\r\nincludes a management command that is intended to be invoked periocically from\r\ncron.\r\n\r\nInstallation\r\n************\r\n\r\nTo install::\r\n\r\n pip install django-reporter\r\n\r\nThen add ``reporter`` to your INSTALLED_APPS::\r\n\r\n INSTALLED_APPS = (\r\n ...\r\n 'reporter',\r\n )\r\n\r\nAlso, make sure the email settings for your project are correct.\r\n\r\nCreating Reports\r\n****************\r\n\r\nSimilar to Django's admin app, reports are created within *reports.py* files\r\ninside your installed applications. Inside each *reports.py* should be at\r\nleast one report that subclasses the ``reporter.BaseReport`` class. After the\r\nsubclass is defined, use the ``reporter.register()`` function to register the\r\nreport. Your subclass should define at least two attributes and implement\r\na few methods, detailed below. Review the *sample_reports.py* file for an\r\nexample of a simple report.\r\n\r\nRequired Attributes\r\n-------------------\r\n\r\nA basic report should have a docstring (which is shown with the ``--list-all``\r\noption on the management command), and needs at least two attributes,\r\n``name``, and ``frequencies``.\r\n\r\nFor example, the sample report starts out with::\r\n\r\n class AdminLogReport(reporter.BaseReport):\r\n \"\"\"\r\n Send full admin log info for the day, broken down by user\r\n \"\"\"\r\n name = 'admin_log'\r\n frequencies = ['daily']\r\n\r\n``name``\r\n~~~~~~~~\r\n\r\n.. attribute:: BaseReport.name\r\n\r\nThe name of the report, used when invoking the ``report`` management command.\r\n\r\n``frequencies``\r\n~~~~~~~~~~~~~~~\r\n\r\n.. attribute:: BaseReport.frequencies\r\n\r\nThe frequencies that this report is available for.\r\n\r\nBuilt-in Attributes\r\n-------------------\r\n\r\nThe base class automatically sets a number of attributes that are available\r\nin the subclass.\r\n\r\n``frequency``\r\n~~~~~~~~~~~~~\r\n\r\n.. attribute:: BaseReport.frequency\r\n\r\nThe requested frequency of the report. This can be used to determine the\r\ncorrect date range to filter for in your report.\r\n\r\n``date``\r\n~~~~~~~~\r\n\r\n.. attribute:: BaseReport.date\r\n\r\nThe requested date for the report. Defaults to today if no date is provided.\r\n\r\n``tomorrow``\r\n~~~~~~~~~~~~\r\n\r\n.. attribute:: BaseReport.tomorrow\r\n\r\nThe requested date plus 1 day.\r\n\r\n``one_week``\r\n~~~~~~~~~~~~\r\n\r\n.. attribute:: BaseReport.one_week\r\n\r\nThe requested date minus 7 days.\r\n\r\n``one_month``\r\n~~~~~~~~~~~~~\r\n\r\n.. attribute:: BaseReport.one_month\r\n\r\nThe requested date minus 32 days.\r\n\r\n``args``\r\n~~~~~~~~\r\n\r\n.. attribute:: BaseReport.args\r\n\r\nA list of additional arguments passed on to the report from the management\r\ncommand.\r\n\r\nMethods\r\n-------\r\n\r\nThese methods are required to be implemented in your subclass in order to\r\ngenerate reports.\r\n\r\n``get_default_recipients``\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\n.. method:: BaseReport.get_default_recipients(self):\r\n\r\nThis method is called by the base class's ``send_results`` method. It\r\nprovides the default recipients for the email, which is used if the recipients\r\nare not overridden by the ``--recipients`` option on the management command.\r\nThis should return a list of strings containing the email address of each\r\nrecipient.\r\n\r\n``get_email_subject``\r\n~~~~~~~~~~~~~~~~~~~~~\r\n\r\n.. method:: BaseReport.get_email_subject(self):\r\n\r\nThis method is also called by the base class's ``send_results`` method. It\r\nprovides the subject line for the email that is sent. It should return a\r\nstring.\r\n\r\n``get_data``\r\n~~~~~~~~~~~~\r\n\r\nThis is the method that the base class calls to retrieve the data that should\r\nbe converted to csv and sent through email. This should return a list of\r\nrows, each row consisting of a list of fields.\r\n\r\nFor example, in the sample ``admin_log`` report, a header row is defined at\r\nthe top of the ``get_data`` method::\r\n\r\n data = [['Username', 'Time', 'Action', 'Content Type', 'ID', 'Name']]\r\n\r\nThen, for each row of data, a list of data within those fields is appended::\r\n\r\n data.append([log.user, time, actions[log.action_flag],\r\n log.content_type.name, log.object_id, obj_name])\r\n\r\nRegistration\r\n------------\r\n\r\nOnce the report is defined in the *reports.py* file, it's ready to be\r\nregistered. The sample report registers its class at the bottom of the file::\r\n\r\n reporter.register(AdminLogReport)\r\n\r\nRunning Reports\r\n***************\r\n\r\nTo run reports, use the ``report`` management command.\r\n\r\nUsage::\r\n\r\n report [options] FREQUENCY REPORT_NAME [REPORT ARGS]\r\n\r\nValid frequencies are \"daily\", \"weekly\", and \"monthly\". By default, the\r\nreports are emailed to the report's default recipients. This can be\r\noverridden through the ``--recipients`` option. Additional arguments after\r\nthe report name will be passed to the report.\r\n\r\nOptions\r\n-------\r\n\r\n``-V, --view``\r\n~~~~~~~~~~~~~~\r\n\r\nSend the data to stdout instead of emailing or saving to a file.\r\n\r\n``-f FILE, --filename=FILE``\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\nInstead of emailing the results, save them to the provided filename.\r\n\r\n``-r RECIPIENTS, --recipients=RECIPIENTS``\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\nOverride the default recipients for the report. Seperate each email address\r\nwith a comma. Do not use spaces.\r\n\r\n``-l, --list-all``\r\n~~~~~~~~~~~~~~~~~~\r\n\r\nList all available reports, and then exit.\r\n\r\n``-d YYYY-MM-DD, --date=YYYY-MM-DD``\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\nProvide a date to run the report for.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/pegasus/django-reporter", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "django-reporter", "package_url": "https://pypi.org/project/django-reporter/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-reporter/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/pegasus/django-reporter" }, "release_url": "https://pypi.org/project/django-reporter/0.1/", "requires_dist": null, "requires_python": null, "summary": "Custom email-based reports for any Django project.", "version": "0.1" }, "last_serial": 790465, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "ad2503b144a87a8befe1062acd3358f7", "sha256": "663b532915b6ecf8078e1ab71e4fb97d1af782ccf0696cb49612f220a18c86fe" }, "downloads": -1, "filename": "django-reporter-0.1.tar.gz", "has_sig": false, "md5_digest": "ad2503b144a87a8befe1062acd3358f7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8350, "upload_time": "2010-04-02T13:08:20", "url": "https://files.pythonhosted.org/packages/02/04/b0811a2bea3070abc2423179749c0b1c256af96910d5c7a54fd7f0dddd88/django-reporter-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ad2503b144a87a8befe1062acd3358f7", "sha256": "663b532915b6ecf8078e1ab71e4fb97d1af782ccf0696cb49612f220a18c86fe" }, "downloads": -1, "filename": "django-reporter-0.1.tar.gz", "has_sig": false, "md5_digest": "ad2503b144a87a8befe1062acd3358f7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8350, "upload_time": "2010-04-02T13:08:20", "url": "https://files.pythonhosted.org/packages/02/04/b0811a2bea3070abc2423179749c0b1c256af96910d5c7a54fd7f0dddd88/django-reporter-0.1.tar.gz" } ] }