コード例 #1
0
 def obj_update(self, bundle, **kwargs):
     self._ensure_toggle_enabled(bundle.request)
     domain = kwargs['domain']
     pk = kwargs['pk']
     try:
         data_source = get_document_or_404(DataSourceConfiguration, domain,
                                           pk)
     except Http404 as e:
         raise NotFound(str(e))
     allowed_update_fields = [
         'display_name',
         'configured_filter',
         'configured_indicators',
     ]
     for key, value in bundle.data.items():
         if key in allowed_update_fields:
             data_source[key] = value
     try:
         data_source.validate()
         data_source.save()
     except BadSpecError as e:
         raise ImmediateHttpResponse(
             add_cors_headers_to_response(
                 HttpResponse(
                     json.dumps({
                         "error":
                         _("Invalid data source! Details: {details}").
                         format(details=str(e))
                     }),
                     content_type="application/json",
                     status=500,
                 )))
     bundle.obj = data_source
     return bundle
コード例 #2
0
 def obj_get_list(self, bundle, domain, **kwargs):
     config = get_document_or_404(FormExportInstance, domain,
                                  self.config_id)
     return get_form_export_base_query(domain,
                                       config.app_id,
                                       config.xmlns,
                                       include_errors=True)
コード例 #3
0
 def obj_get_list(self, bundle, domain, **kwargs):
     config = get_document_or_404(CaseExportInstance, domain,
                                  self.config_id)
     query = get_case_export_base_query(domain, config.case_type)
     for filter in config.get_filters():
         query = query.filter(filter.to_es_filter())
     return query
コード例 #4
0
ファイル: v0_5.py プロジェクト: kkrampa/commcare-hq
 def obj_get(self, bundle, **kwargs):
     domain = kwargs['domain']
     pk = kwargs['pk']
     try:
         report_configuration = get_document_or_404(ReportConfiguration, domain, pk)
     except Http404 as e:
         raise NotFound(e.message)
     return report_configuration
コード例 #5
0
 def obj_get(self, bundle, **kwargs):
     domain = kwargs['domain']
     pk = kwargs['pk']
     try:
         report_configuration = get_document_or_404(ReportConfiguration, domain, pk)
     except Http404 as e:
         raise NotFound(e.message)
     return report_configuration
コード例 #6
0
ファイル: views.py プロジェクト: tstalka/commcare-hq
 def get(self, request, domain, config_id, **kwargs):
     table_id = int(kwargs.get('table_id', 0))
     config = get_document_or_404(CaseExportInstance, domain, config_id)
     metadata = render_to_string('api/odata_metadata.xml', {
         'fields': get_case_odata_fields_from_config(config, table_id),
         'primary_key': 'caseid' if table_id == 0 else 'number',
     })
     return add_odata_headers(HttpResponse(metadata, content_type='application/xml'))
コード例 #7
0
 def get(self, request, domain, config_id):
     config = get_document_or_404(FormExportInstance, domain, config_id)
     metadata = render_to_string(
         'api/form_odata_metadata.xml', {
             'fields': get_case_odata_fields_from_config(config),
         })
     return add_odata_headers(
         HttpResponse(metadata, content_type='application/xml'))
コード例 #8
0
 def obj_get(self, bundle, **kwargs):
     self._ensure_toggle_enabled(bundle.request)
     domain = kwargs['domain']
     pk = kwargs['pk']
     try:
         data_source = get_document_or_404(DataSourceConfiguration, domain,
                                           pk)
     except Http404 as e:
         raise NotFound(str(e))
     return data_source
コード例 #9
0
 def obj_get_list(self, bundle, domain, **kwargs):
     config = get_document_or_404(FormExportInstance, domain,
                                  self.config_id)
     query = get_form_export_base_query(domain,
                                        config.app_id,
                                        config.xmlns,
                                        include_errors=False)
     for filter in config.get_filters():
         query = query.filter(filter.to_es_filter())
     return query
コード例 #10
0
ファイル: v0_5.py プロジェクト: twymer/commcare-hq
    def obj_get_list(self, bundle, domain, **kwargs):
        config = get_document_or_404(CaseExportInstance, domain,
                                     self.config_id)
        query = get_case_export_base_query(domain, config.case_type)
        for filter in config.get_filters():
            query = query.filter(filter.to_es_filter())

        if not bundle.request.couch_user.has_permission(
                domain, 'access_all_locations'):
            query = query_location_restricted_cases(query, bundle.request)

        return query
コード例 #11
0
ファイル: v0_5.py プロジェクト: twymer/commcare-hq
    def obj_get_list(self, bundle, domain, **kwargs):
        config = get_document_or_404(FormExportInstance, domain,
                                     self.config_id)
        query = get_form_export_base_query(domain,
                                           config.app_id,
                                           config.xmlns,
                                           include_errors=False)
        for filter in config.get_filters():
            query = query.filter(filter.to_es_filter())

        if not bundle.request.couch_user.has_permission(
                domain, 'access_all_locations'):
            query = query_location_restricted_forms(query, bundle.request)

        return query
コード例 #12
0
ファイル: views.py プロジェクト: twymer/commcare-hq
    def get(self, request, domain, config_id, **kwargs):
        table_id = int(kwargs.get('table_id', 0))
        config = get_document_or_404(CaseExportInstance, domain, config_id)
        case_fields = get_case_odata_fields_from_config(config, table_id)

        field_names = [f.name for f in case_fields]
        primary_key = 'caseid' if table_id == 0 else 'number'
        if f'{primary_key} *sensitive*' in field_names:
            primary_key = f'{primary_key} *sensitive*'

        metadata = render_to_string('api/odata_metadata.xml', {
            'fields': case_fields,
            'primary_key': primary_key,
        })
        return add_odata_headers(HttpResponse(metadata, content_type='application/xml'))
コード例 #13
0
ファイル: views.py プロジェクト: tobiasmcnulty/commcare-hq
    def get(self, request, domain, config_id, **kwargs):
        table_id = int(kwargs.get('table_id', 0))
        config = get_document_or_404(FormExportInstance, domain, config_id)
        if raise_odata_permissions_issues(request.couch_user, domain, config):
            raise Http404()
        form_fields = get_form_odata_fields_from_config(config, table_id)

        field_names = [f.name for f in form_fields]
        primary_key = 'formid' if table_id == 0 else 'number'
        if f'{primary_key} *sensitive*' in field_names:
            primary_key = f'{primary_key} *sensitive*'

        metadata = render_to_string('api/odata_metadata.xml', {
            'fields': form_fields,
            'primary_key': primary_key,
        })
        return add_odata_headers(HttpResponse(metadata, content_type='application/xml'))
コード例 #14
0
ファイル: v0_5.py プロジェクト: caktus/commcare-hq
    def obj_get_list(self, bundle, domain, **kwargs):
        config = get_document_or_404(CaseExportInstance, domain,
                                     self.config_id)
        if raise_odata_permissions_issues(bundle.request.couch_user, domain,
                                          config):
            raise ImmediateHttpResponse(
                HttpForbidden(
                    ugettext_noop(
                        "You do not have permission to view this feed.")))
        query = get_case_export_base_query(domain, config.case_type)
        for filter in config.get_filters():
            query = query.filter(filter.to_es_filter())

        if not bundle.request.couch_user.has_permission(
                domain, 'access_all_locations'):
            query = query_location_restricted_cases(query, bundle.request)

        return query
コード例 #15
0
ファイル: views.py プロジェクト: soitun/commcare-hq
 def get(self, request, domain, config_id, **kwargs):
     table_id = int(kwargs.get('table_id', 0))
     config = get_document_or_404(CaseExportInstance, domain, config_id)
     if raise_odata_permissions_issues(request.couch_user, domain, config):
         raise Http404()
     urlname = ODataCaseMetadataView.urlname
     url_args = [domain, config_id]
     if table_id > 0:
         urlname = ODataCaseMetadataView.table_urlname
         url_args.append(table_id)
     service_document_content = {
         '@odata.context': absolute_reverse(urlname, args=url_args),
         'value': [{
             'name': 'feed',
             'kind': 'EntitySet',
             'url': 'feed',
         }]
     }
     return add_odata_headers(JsonResponse(service_document_content))
コード例 #16
0
 def obj_get_list(self, bundle, domain, **kwargs):
     config = get_document_or_404(CaseExportInstance, domain,
                                  self.config_id)
     return get_case_export_base_query(domain, config.case_type)
コード例 #17
0
ファイル: views.py プロジェクト: ekush/commcare-hq
 def location(self):
     parent_id = self.request.GET.get('parent')
     parent = (get_document_or_404(Location, self.domain, parent_id)
               if parent_id else None)
     return Location(domain=self.domain, parent=parent)
コード例 #18
0
ファイル: views.py プロジェクト: xbryanc/commcare-hq
def delete_performance_config(request, domain, config_id):
    config = get_document_or_404(PerformanceConfiguration, domain, config_id)
    config.delete()
    messages.success(request, _(u'Performance Message deleted!'))
    return HttpResponseRedirect(
        reverse(ListPerformanceConfigsView.urlname, args=[domain]))
コード例 #19
0
ファイル: views.py プロジェクト: xbryanc/commcare-hq
 def performance_config(self):
     return get_document_or_404(PerformanceConfiguration, self.domain,
                                self.config_id)
コード例 #20
0
ファイル: views.py プロジェクト: saketkanth/commcare-hq
 def performance_config(self):
     return get_document_or_404(
         PerformanceConfiguration, self.domain, self.config_id
     )
コード例 #21
0
ファイル: views.py プロジェクト: ekush/commcare-hq
 def location(self):
     parent_id = self.request.GET.get('parent')
     parent = (get_document_or_404(Location, self.domain, parent_id)
               if parent_id else None)
     return Location(domain=self.domain, parent=parent)
コード例 #22
0
ファイル: views.py プロジェクト: ansarbek/commcare-hq
def edit_performance_config(request, domain, config_id):
    config = get_document_or_404(PerformanceConfiguration, domain, config_id)
    return _edit_performance_message_shared(request, domain, config)
コード例 #23
0
ファイル: views.py プロジェクト: ansarbek/commcare-hq
def delete_performance_config(request, domain, config_id):
    config = get_document_or_404(PerformanceConfiguration, domain, config_id)
    config.delete()
    messages.success(request, _(u'Performance Message deleted!'))
    return HttpResponseRedirect(reverse('performance_sms.list_performance_configs', args=[domain]))