forked from dimagi/commcare-hq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
245 lines (207 loc) · 7.72 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
from corehq.apps.domain.models import Domain
from corehq.apps.hqadmin.reports import AdminUserReport, AdminAppReport
from corehq.apps.reports.standard import (monitoring, inspect, export,
deployments, sms, ivr)
import corehq.apps.receiverwrapper.reports as receiverwrapper
import phonelog.reports as phonelog
from corehq.apps.reports.commtrack import standard as commtrack_reports
from corehq.apps.reports.commtrack import maps as commtrack_maps
from corehq.apps.reports.commconnect import system_overview
import hashlib
from dimagi.utils.modules import to_function
import logging
from django.utils.translation import ugettext_noop as _, ugettext_lazy
def REPORTS(project):
from corehq.apps.reports.standard.cases.basic import CaseListReport
from corehq.apps.reports.standard.cases.careplan import make_careplan_reports
from corehq.apps.reports.standard.maps import DemoMapReport, DemoMapReport2, DemoMapCaseList
reports = [
(ugettext_lazy("Monitor Workers"), (
monitoring.WorkerActivityReport,
monitoring.DailyFormStatsReport,
monitoring.SubmissionsByFormReport,
monitoring.FormCompletionTimeReport,
monitoring.CaseActivityReport,
monitoring.FormCompletionVsSubmissionTrendsReport,
monitoring.WorkerActivityTimes,
)),
(ugettext_lazy("Inspect Data"), (
inspect.SubmitHistory, CaseListReport,
)),
(ugettext_lazy("Manage Deployments"), (
deployments.ApplicationStatusReport,
receiverwrapper.SubmissionErrorReport,
phonelog.FormErrorReport,
phonelog.DeviceLogDetailsReport
)),
(ugettext_lazy("Demos for Previewers"), (
DemoMapReport, DemoMapReport2, DemoMapCaseList,
)),
]
if project.commtrack_enabled:
reports.insert(0, (ugettext_lazy("Commtrack"), (
# commtrack_reports.ReportingRatesReport,
commtrack_reports.CurrentStockStatusReport,
commtrack_reports.AggregateStockStatusReport,
# commtrack_reports.RequisitionReport,
# commtrack_maps.StockStatusMapReport,
# commtrack_maps.ReportingStatusMapReport,
)))
if project.has_careplan:
from corehq.apps.app_manager.models import CareplanConfig
config = CareplanConfig.for_domain(project.name)
if config:
cp_reports = tuple(make_careplan_reports(config))
reports.insert(0, (ugettext_lazy("Care Plans"), cp_reports))
messaging_reports = (
sms.MessagesReport,
sms.MessageLogReport,
ivr.CallLogReport,
ivr.ExpectedCallbackReport,
system_overview.SystemOverviewReport,
system_overview.SystemUsersReport
)
messaging_reports += getattr(Domain.get_module_by_name(project.name), 'MESSAGING_REPORTS', ())
messaging = (lambda project, user: (
ugettext_lazy("Logs") if project.commtrack_enabled else ugettext_lazy("Messaging")), messaging_reports)
if project.commconnect_enabled:
reports.insert(0, messaging)
else:
reports.append(messaging)
reports.extend(dynamic_reports(project))
return reports
def dynamic_reports(project):
"""include any reports that can be configured/customized with static parameters for this domain"""
for reportset in project.dynamic_reports:
yield (reportset.section_title, filter(None, (make_dynamic_report(report, [reportset.section_title]) for report in reportset.reports)))
def make_dynamic_report(report_config, keyprefix):
"""create a report class the descends from a generic report class but has specific parameters set"""
# a unique key to distinguish this particular configuration of the generic report
report_key = keyprefix + [report_config.report, report_config.name]
slug = hashlib.sha1(':'.join(report_key)).hexdigest()[:12]
kwargs = dict(report_config.kwargs)
kwargs.update({
'name': report_config.name,
'slug': slug,
})
if report_config.previewers_only:
# note this is a classmethod that will be injected into the dynamic class below
@classmethod
def show_in_navigation(cls, domain=None, project=None, user=None):
return user and user.is_previewer()
kwargs['show_in_navigation'] = show_in_navigation
try:
metaclass = to_function(report_config.report, failhard=True)
except StandardError:
logging.error('dynamic report config for [%s] is invalid' % report_config.report)
return None
# dynamically create a report class
return type('DynamicReport%s' % slug, (metaclass,), kwargs)
from corehq.apps.data_interfaces.interfaces import CaseReassignmentInterface
from corehq.apps.importer.base import ImportCases
DATA_INTERFACES = (
(ugettext_lazy("Export Data"), (
export.ExcelExportReport,
export.CaseExportReport,
export.DeidExportReport,
)),
)
EDIT_DATA_INTERFACES = (
(ugettext_lazy('Edit Data'), (
CaseReassignmentInterface,
ImportCases
)),
)
from corehq.apps.adm.reports.supervisor import SupervisorReportsADMSection
ADM_SECTIONS = (
(_('Supervisor Report'), (
SupervisorReportsADMSection,
)),
)
from corehq.apps.adm.admin import columns, reports
ADM_ADMIN_INTERFACES = (
(_("ADM Default Columns"), (
columns.ReducedADMColumnInterface,
columns.DaysSinceADMColumnInterface,
columns.ConfigurableADMColumnInterface
)),
(_("ADM Default Reports"), (
reports.ADMReportAdminInterface,
))
)
from corehq.apps.indicators.admin import document_indicators, couch_indicators, dynamic_indicators
INDICATOR_ADMIN_INTERFACES = (
(_("Form Based Indicators"), (
document_indicators.FormLabelIndicatorDefinitionAdminInterface,
document_indicators.FormAliasIndicatorDefinitionAdminInterface,
document_indicators.CaseDataInFormAdminInterface,
)),
(_("Case Based Indicators"), (
document_indicators.FormDataInCaseAdminInterface,
)),
(_("Dynamic Indicators"), (
dynamic_indicators.CombinedIndicatorAdminInterface,
)),
(_("Couch Based Indicators"), (
couch_indicators.CouchIndicatorAdminInterface,
couch_indicators.CountUniqueCouchIndicatorAdminInterface,
couch_indicators.MedianCouchIndicatorAdminInterface,
couch_indicators.SumLastEmittedCouchIndicatorAdminInterface,
)),
)
from corehq.apps.announcements.interface import (
ManageGlobalHQAnnouncementsInterface,
ManageReportAnnouncementsInterface,
)
ANNOUNCEMENTS_ADMIN_INTERFACES = (
(_("Manage Announcements"), (
ManageGlobalHQAnnouncementsInterface,
ManageReportAnnouncementsInterface,
)),
)
from corehq.apps.accounting.interface import (
AccountingInterface,
SubscriptionInterface,
SoftwarePlanInterface,
)
ACCOUNTING_ADMIN_INTERFACES = (
(_("Accounting Admin"), (
AccountingInterface,
SubscriptionInterface,
SoftwarePlanInterface,
)),
)
from corehq.apps.appstore.interfaces import CommCareExchangeAdvanced
APPSTORE_INTERFACES = (
(_('App Store'), (
CommCareExchangeAdvanced,
)),
)
from corehq.apps.reports.standard.domains import OrgDomainStatsReport, AdminDomainStatsReport
BASIC_REPORTS = (
(_('Project Stats'), (
OrgDomainStatsReport,
)),
)
ADMIN_REPORTS = (
(_('Domain Stats'), (
AdminDomainStatsReport,
AdminUserReport,
AdminAppReport,
)),
)
from corehq.apps.hqwebapp.models import *
TABS = (
ProjectInfoTab,
ReportsTab,
ProjectDataTab,
CommTrackSetupTab,
ProjectUsersTab,
ApplicationsTab,
CloudcareTab,
MessagingTab,
ExchangeTab,
OrgReportTab,
OrgSettingsTab, # separate menu?
AdminTab,
)