예제 #1
0
 def available_domains(self):
     if not self.couch_user:
         return []
     indicator_domains = set(get_indicator_domains())
     indicator_domains = indicator_domains.difference([self.domain])
     return [
         d for d in indicator_domains
         if self.couch_user.has_permission(d, Permissions.edit_data)
     ]
예제 #2
0
def default_admin(request, domain, template="reports/base_template.html", **kwargs):
    if request.domain not in get_indicator_domains():
        raise Http404
    from corehq.apps.indicators.admin import BaseIndicatorAdminInterface
    context = dict(
        domain=domain,
        project=domain,
        report=dict(
            title="Select an Indicator Definition Type",
            show=True,
            slug=None,
            is_async=True,
            section_name=BaseIndicatorAdminInterface.section_name,
        )
    )
    return render(request, template, context)
예제 #3
0
    def handle(self, *args, **options):
        xform_db = XFormInstance.get_db()

        for domain in get_indicator_domains():
            namespaces = get_namespaces(domain)
            indicators = []
            for namespace in namespaces:
                indicators.extend(FormIndicatorDefinition.get_all(namespace, domain))

            form_ids = get_form_ids_by_type(domain, 'XFormInstance',
                                            start=datetime.date(2013, 8, 1),
                                            end=datetime.date(2013, 10, 15))

            for doc in iter_docs(xform_db, form_ids):
                xfrom_doc = XFormInstance.wrap(doc)
                xfrom_doc.update_indicators_in_bulk(indicators, logger=logging)
예제 #4
0
def default_admin(request,
                  domain,
                  template="reports/base_template.html",
                  **kwargs):
    if request.domain not in get_indicator_domains():
        raise Http404
    from corehq.apps.indicators.admin import BaseIndicatorAdminInterface
    context = dict(domain=domain,
                   project=domain,
                   report=dict(
                       title="Select an Indicator Definition Type",
                       show=True,
                       slug=None,
                       is_async=True,
                       section_name=BaseIndicatorAdminInterface.section_name,
                   ))
    return render(request, template, context)
예제 #5
0
    def handle(self, *args, **options):
        xform_db = XFormInstance.get_db()

        for domain in get_indicator_domains():
            namespaces = get_namespaces(domain)
            indicators = []
            for namespace in namespaces:
                indicators.extend(
                    FormIndicatorDefinition.get_all(namespace, domain))

            key = [domain, "by_type", "XFormInstance"]
            data = xform_db.view('couchforms/all_submissions_by_domain',
                                 startkey=key + ["2013-08-01"],
                                 endkey=key + ["2013-10-15"],
                                 reduce=False,
                                 include_docs=False).all()
            form_ids = [d['id'] for d in data]

            for doc in iter_docs(xform_db, form_ids):
                xfrom_doc = XFormInstance.wrap(doc)
                xfrom_doc.update_indicators_in_bulk(indicators, logger=logging)
    def handle(self, *args, **options):
        xform_db = XFormInstance.get_db()

        for domain in get_indicator_domains():
            namespaces = get_namespaces(domain)
            indicators = []
            for namespace in namespaces:
                indicators.extend(FormIndicatorDefinition.get_all(namespace, domain))

            key = [domain, "by_type", "XFormInstance"]
            data = xform_db.view(
                'couchforms/all_submissions_by_domain',
                startkey=key+["2013-08-01"],
                endkey=key+["2013-10-15"],
                reduce=False,
                include_docs=False
            ).all()
            form_ids = [d['id'] for d in data]

            for doc in iter_docs(xform_db, form_ids):
                xfrom_doc = XFormInstance.wrap(doc)
                xfrom_doc.update_indicators_in_bulk(indicators, logger=logging)
예제 #7
0
 def extra_args(self):
     return {
         'domains': ' '.join(get_indicator_domains()),
         'doc_type': self.document_class._doc_type,
     }
예제 #8
0
 def is_viewable(self):
     indicator_enabled_projects = get_indicator_domains()
     return self.couch_user.can_edit_data() and self.domain in indicator_enabled_projects
예제 #9
0
 def is_viewable(self):
     indicator_enabled_projects = get_indicator_domains()
     return self.couch_user.can_edit_data(
     ) and self.domain in indicator_enabled_projects
예제 #10
0
 def available_domains(self):
     if not self.couch_user:
         return []
     indicator_domains = set(get_indicator_domains())
     indicator_domains = indicator_domains.difference([self.domain])
     return [d for d in indicator_domains if self.couch_user.has_permission(d, Permissions.edit_data)]
예제 #11
0
 def extra_args(self):
     return {
         'domains': ' '.join(get_indicator_domains()),
         'doc_type': self.document_class._doc_type,
     }
예제 #12
0
 def domains(self):
     return get_indicator_domains()
예제 #13
0
 def domains(self):
     return get_indicator_domains()
예제 #14
0
 def extra_args(self):
     return {
         'domains': ' '.join(get_indicator_domains()),
         'doc_types': ' '.join([self._main_doc_type] + self._deleted_doc_types),
     }
예제 #15
0
 def extra_args(self):
     return {
         'domains': ' '.join(get_indicator_domains()),
         'doc_types':
         ' '.join([self._main_doc_type] + self._deleted_doc_types),
     }