Esempio n. 1
0
 def setUp(self):
     self.datespan_decorator = datespan_in_request(
         from_param="startdate",
         to_param="enddate",
         default_days=7,
         format_string='%Y-%m-%dT%H:%M:%S'
     )
Esempio n. 2
0
 def setUp(self):
     self.datespan_decorator = datespan_in_request(
         from_param="startdate",
         to_param="enddate",
         default_days=7,
         format_string='%Y-%m-%dT%H:%M:%S'
     )
Esempio n. 3
0
    def test_from_request(self):
        start_date = datetime(2013, 7, 21, 0, 0, 0)
        end_date = datetime(2013, 7, 15, 0, 0, 0)
        request = HttpRequest()
        query_string = urlencode({
            'startdate': start_date.isoformat(),
            'enddate': end_date.isoformat()}
        )
        request.GET = QueryDict(query_string)
        datespan_in_request()

        @self.datespan_decorator
        def dummy(req):
            return getattr(req, 'datespan', None)

        datespan = dummy(request)
        self.assertIsNotNone(datespan)
        self.assertIsInstance(datespan, DateSpan)
        self.assertEqual(datespan.enddate, end_date)
        self.assertEqual(datespan.startdate, start_date)
Esempio n. 4
0
    def test_from_request(self):
        start_date = datetime(2013, 7, 21, 0, 0, 0)
        end_date = datetime(2013, 7, 15, 0, 0, 0)
        request = HttpRequest()
        query_string = urlencode({
            'startdate': start_date.isoformat(),
            'enddate': end_date.isoformat()}
        )
        request.GET = QueryDict(query_string)
        datespan_in_request()

        @self.datespan_decorator
        def dummy(req):
            return getattr(req, 'datespan', None)

        datespan = dummy(request)
        self.assertIsNotNone(datespan)
        self.assertIsInstance(datespan, DateSpan)
        self.assertEqual(datespan.enddate, end_date)
        self.assertEqual(datespan.startdate, start_date)
Esempio n. 5
0
)
from corehq.apps.reports.standard import inspect, export, ProjectReport
from corehq.apps.reports.export import (ApplicationBulkExportHelper,
    CustomBulkExportHelper, save_metadata_export_to_tempfile)
from corehq.apps.users.decorators import require_permission
from corehq.apps.users.export import export_users
from corehq.apps.users.models import CommCareUser
from corehq.apps.users.models import Permissions
from corehq.apps.domain.decorators import login_and_domain_required


DATE_FORMAT = "%Y-%m-%d"

datespan_default = datespan_in_request(
    from_param="startdate",
    to_param="enddate",
    default_days=7,
)

require_form_export_permission = require_permission(Permissions.view_report, 'corehq.apps.reports.standard.export.ExcelExportReport', login_decorator=None)
require_case_export_permission = require_permission(Permissions.view_report, 'corehq.apps.reports.standard.export.CaseExportReport', login_decorator=None)

require_form_view_permission = require_permission(Permissions.view_report, 'corehq.apps.reports.standard.inspect.SubmitHistory', login_decorator=None)
require_case_view_permission = require_permission(Permissions.view_report, 'corehq.apps.reports.standard.cases.basic.CaseListReport', login_decorator=None)

require_can_view_all_reports = require_permission(Permissions.view_reports)

@login_and_domain_required
def default(request, domain):
    return HttpResponseRedirect(reverse(saved_reports, args=[domain]))
Esempio n. 6
0
)
from corehq.apps.reports.standard import inspect, export, ProjectReport
from corehq.apps.reports.export import (ApplicationBulkExportHelper,
                                        CustomBulkExportHelper,
                                        save_metadata_export_to_tempfile)
from corehq.apps.users.decorators import require_permission
from corehq.apps.users.export import export_users
from corehq.apps.users.models import CommCareUser
from corehq.apps.users.models import Permissions
from corehq.apps.domain.decorators import login_and_domain_required

DATE_FORMAT = "%Y-%m-%d"

datespan_default = datespan_in_request(
    from_param="startdate",
    to_param="enddate",
    default_days=7,
)

require_form_export_permission = require_permission(
    Permissions.view_report,
    'corehq.apps.reports.standard.export.ExcelExportReport',
    login_decorator=None)
require_case_export_permission = require_permission(
    Permissions.view_report,
    'corehq.apps.reports.standard.export.CaseExportReport',
    login_decorator=None)

require_form_view_permission = require_permission(
    Permissions.view_report,
    'corehq.apps.reports.standard.inspect.SubmitHistory',