Django-reporter v.0.1

Advertisement
Advertisement

Django-reporterA Django application to create automated email reports in .csv format. It includes a management command that is intended to be invoked periocically from cron.InstallationTo install:pip install django-reporterThen add reporter to your INSTALLED_APPS:INSTALLED_APPS = ( ... 'reporter',)Also, make sure the email settings for your project are correct.Creating ReportsSimilar to Django's admin app, reports are created within reports.py files inside your installed applications. Inside each reports.py should be at least one report that subclasses the reporter.BaseReport class. After the subclass is defined, use the reporter.register() function to register the report. Your subclass should define at least two attributes and implement a few methods, detailed below. Review the sample_reports.py file for an example of a simple report.Required AttributesA basic report should have a docstring (which is shown with the --list-all option on the management command), and needs at least two attributes, name, and frequencies.For example, the sample report starts out with:class AdminLogReport(reporter.BaseReport): """ Send full admin log info for the day, broken down by user """ name = 'admin_log' frequencies = ['daily']nameThe name of the report, used when invoking the report management command.frequenciesThe frequencies that this report is available for.Built-in AttributesThe base class automatically sets a number of attributes that are available in the subclass.frequencyThe requested frequency of the report. This can be used to determine the correct date range to filter for in your report.dateThe requested date for the report. Defaults to today if no date is provided.tomorrowThe requested date plus 1 day.one_weekThe requested date minus 7 days.one_monthThe requested date minus 32 days.argsA list of additional arguments passed on to the report from the management command.MethodsThese methods are required to be implemented in your subclass in order to generate reports.get_default_recipientsThis method is called by the base class's send_results method. It provides the default recipients for the email, which is used if the recipients are not overridden by the --recipients option on the management command. This should return a list of strings containing the email address of each recipient.get_email_subjectThis method is also called by the base class's send_results method. It provides the subject line for the email that is sent. It should return a string.get_dataThis is the method that the base class calls to retrieve the data that should be converted to csv and sent through email. This should return a list of rows, each row consisting of a list of fields.For example, in the sample admin_log report, a header row is defined at the top of the get_data method:data = [['Username', 'Time', 'Action', 'Content Type', 'ID', 'Name']]Then, for each row of data, a list of data within those fields is appended:data.append([log.user, time, actions[log.action_flag], log.content_type.name, log.object_id, obj_name])RegistrationOnce the report is defined in the reports.py file, it's ready to be registered. The sample report registers its class at the bottom of the file:reporter.register(AdminLogReport)Running ReportsTo run reports, use the report management command.Usage:report [options] FREQUENCY REPORT_NAME [REPORT ARGS]Valid frequencies are "daily", "weekly", and "monthly". By default, the reports are emailed to the report's default recipients. This can be overridden through the --recipients option. Additional arguments after the report name will be passed to the report.Options-V, --viewSend the data to stdout instead of emailing or saving to a file.-f FILE, --filename=FILEInstead of emailing the results, save them to the provided filename.-r RECIPIENTS, --recipients=RECIPIENTSOverride the default recipients for the report. Seperate each email address with a comma. Do not use spaces.-l, --list-allList all available reports, and then exit.-d YYYY-MM-DD, --date=YYYY-MM-DDProvide a date to run the report for.#md5=ad2503b144a87a8befe1062acd3358f7

Django-reporterA Django application to create ... Custom email-based reports for any Django project ...

 
  • Django-reporter
  • 0.1
  • Brandon Konkle
  • Linux
  • Freeware
  • 10 Kb
  • 454
  • Free
 
 

Review Django-reporter

  • captcha
 

Other software of Brandon Konkle
    
    New HTML Editors software
    • HTMLPad 2020  v.16.0Quick, intelligent and powerful HTML, CSS, JavaScript editor. Packed with sophisticated features and tools, HTMLPad enables you to create, edit, validate, reuse, navigate and deploy your HTML, CSS and JavaScript code faster and easier than ever.
    • OrgChart JS  v.5.3.3A JavaScript library for building interactive Org-Charts, specifically tailored for displaying a company's organizational structure ...
    • Rapid PHP 2018  v.15.5Quick, lightweight and very powerful PHP editor that combines features of a fully-packed PHP IDE with unmatched speed. Rapid PHP is the most complete all-in-one software for coding PHP, HTML, CSS, JavaScript with integrated debugger and other tools.
    • HTMLPad 2018  v.15.5Quick, intelligent and powerful HTML, CSS, JavaScript editor. Packed with sophisticated features and tools, HTMLPad enables you to create, edit, validate, reuse, navigate and deploy your HTML, CSS and JavaScript code faster and easier than ever.
    • Django-layar  v.0.2.0Helper for publishing data to Layar augmented reality browser from Django ...
    • Joomla Permissions Quiz  v.1.0Build multiple choice quiz for Joomla ...