当前位置: 首页>>代码示例>>Python>>正文


Python models.SurveyKeyword类代码示例

本文整理汇总了Python中corehq.apps.reminders.models.SurveyKeyword的典型用法代码示例。如果您正苦于以下问题:Python SurveyKeyword类的具体用法?Python SurveyKeyword怎么用?Python SurveyKeyword使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SurveyKeyword类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: migrate

    def migrate(self, log_file):
        count = 0
        ids = self.get_couch_ids()
        total_count = len(ids)
        for doc in iter_docs_with_retry(SurveyKeyword.get_db(), ids):
            try:
                couch_obj = SurveyKeyword.wrap(doc)
                couch_obj._migration_do_sync()
            except Exception as e:
                log_file.write('Could not sync SurveyKeyword %s: %s\n' % (doc['_id'], e))

            count += 1
            if (count % 1000) == 0:
                print 'Processed %s / %s documents' % (count, total_count)
开发者ID:,项目名称:,代码行数:14,代码来源:

示例2: keyword

 def keyword(self):
     if self.keyword_id is None:
         raise Http404()
     sk = SurveyKeyword.get(self.keyword_id)
     if sk.domain != self.domain:
         raise Http404()
     return sk
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:7,代码来源:views.py

示例3: get_couch_ids

 def get_couch_ids(self):
     result = SurveyKeyword.view(
         'reminders/survey_keywords',
         include_docs=False,
         reduce=False,
     ).all()
     return [row['id'] for row in result]
开发者ID:,项目名称:,代码行数:7,代码来源:

示例4: total

 def total(self):
     data = (
         SurveyKeyword.get_db()
         .view("reminders/survey_keywords", reduce=True, startkey=[self.domain], endkey=[self.domain, {}])
         .first()
     )
     return data["value"] if data else 0
开发者ID:dimagi,项目名称:commcare-hq,代码行数:7,代码来源:views.py

示例5: total

 def total(self):
     data = SurveyKeyword.get_db().view(
         'reminders/survey_keywords',
         reduce=True,
         startkey=[self.domain],
         endkey=[self.domain, {}],
     ).first()
     return data['value'] if data else 0
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:8,代码来源:views.py

示例6: testCouchSyncToSQL

    def testCouchSyncToSQL(self):
        self.assertEqual(self.getCouchCount(), 0)
        self.assertEqual(self.getSQLCount(), 0)

        # Test Create
        couch_obj = SurveyKeyword()
        self.setRandomCouchObjectValues(couch_obj)
        self.assertEqual(self.getCouchCount(), 1)
        self.assertEqual(self.getSQLCount(), 1)

        sql_obj = Keyword.objects.get(couch_id=couch_obj._id)
        self.compareObjects(couch_obj, sql_obj)
        self.assertTrue(SurveyKeyword.get_db().get_rev(couch_obj._id).startswith('1-'))

        # Test Update
        self.setRandomCouchObjectValues(couch_obj)
        self.assertEqual(self.getCouchCount(), 1)
        self.assertEqual(self.getSQLCount(), 1)
        sql_obj = Keyword.objects.get(couch_id=couch_obj._id)
        self.compareObjects(couch_obj, sql_obj)
        self.assertTrue(SurveyKeyword.get_db().get_rev(couch_obj._id).startswith('2-'))

        # Test Delete
        couch_id = couch_obj._id
        couch_obj.delete()
        with self.assertRaises(ResourceNotFound):
            SurveyKeyword.get(couch_id)
        self.assertEqual(self.getCouchCount(), 0)
        self.assertEqual(self.getSQLCount(), 0)
开发者ID:,项目名称:,代码行数:29,代码来源:

示例7: get_couch_count

 def get_couch_count(self):
     result = SurveyKeyword.view(
         'reminders/survey_keywords',
         include_docs=False,
         reduce=True,
     ).all()
     if result:
         return result[0]['value']
     return 0
开发者ID:,项目名称:,代码行数:9,代码来源:

示例8: get_deleted_item_data

 def get_deleted_item_data(self, item_id):
     try:
         s = SurveyKeyword.get(item_id)
     except ResourceNotFound:
         raise Http404()
     if s.domain != self.domain or s.doc_type != "SurveyKeyword":
         raise Http404()
     s.delete()
     return {"itemData": self._fmt_deleted_keyword_data(s), "template": "keyword-deleted-template"}
开发者ID:dimagi,项目名称:commcare-hq,代码行数:9,代码来源:views.py

示例9: paginated_list

 def paginated_list(self):
     for keyword in SurveyKeyword.get_by_domain(
         self.domain,
         limit=self.limit,
         skip=self.skip,
     ):
         yield {
             'itemData': self._fmt_keyword_data(keyword),
             'template': 'keyword-row-template',
         }
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:10,代码来源:views.py

示例10: getCouchCount

 def getCouchCount(self):
     result = SurveyKeyword.view(
         'reminders/survey_keywords',
         startkey=[self.domain],
         endkey=[self.domain, {}],
         include_docs=False,
         reduce=True,
     ).all()
     if result:
         return result[0]['value']
     return 0
开发者ID:,项目名称:,代码行数:11,代码来源:

示例11: device_data

def device_data(request):
    if "data" not in request.POST:
        return HttpResponseBadRequest("Missing 'data' POST parameter.")

    data = request.POST.get("data")
    data = data.strip()
    data_points = data.split(",")
    device_id = None
    for data_point in data_points:
        key_value = data_point.partition("=")
        key = key_value[0].strip().upper()
        value = key_value[2].strip()
        if key == "SN":
            device_id = value
            break

    if device_id is None:
        return HttpResponseBadRequest("Missing 'SN' in data string.")

    # This view lookup is an implicit assert that either one device exists
    # with the given device_id, or no devices exist with this device_id.
    case = CommConnectCase.view("wisepill/device", key=[device_id], include_docs=True).one()

    event = WisePillDeviceEvent(
        domain=case.domain if case is not None else None,
        data=data,
        received_on=datetime.utcnow(),
        case_id=case._id if case is not None else None,
        processed=False,
    )
    event.save()

    if case is not None:
        survey_keywords = SurveyKeyword.get_all(case.domain)
        for survey_keyword in survey_keywords:
            if survey_keyword.keyword.upper() == "DEVICE_EVENT":
                for survey_keyword_action in survey_keyword.actions:
                    if survey_keyword_action.action == METHOD_STRUCTURED_SMS:
                        handle_structured_sms(
                            survey_keyword,
                            survey_keyword_action,
                            case,
                            None,
                            "DEVICE_EVENT,%s" % data,
                            send_response=False,
                        )
                        event.processed = True
                        event.save()
                        break

    return HttpResponse("")
开发者ID:philipkaare,项目名称:commcare-hq,代码行数:51,代码来源:views.py

示例12: create_survey_keyword

 def create_survey_keyword(self, keyword, form_unique_id, delimiter=None,
     override_open_sessions=True, initiator_filter=None):
     sk = SurveyKeyword(
         domain=self.domain,
         keyword=keyword,
         description=keyword,
         actions=[SurveyKeywordAction(
             recipient=RECIPIENT_SENDER,
             recipient_id=None,
             action=METHOD_SMS_SURVEY,
             message_content=None,
             form_unique_id=form_unique_id,
             use_named_args=False,
             named_args={},
             named_args_separator=None,
         )],
         delimiter=delimiter,
         override_open_sessions=override_open_sessions,
         initiator_doc_type_filter=initiator_filter or [],
     )
     sk.save()
     self.keywords.append(sk)
     return sk
开发者ID:sheelio,项目名称:commcare-hq,代码行数:23,代码来源:util.py

示例13: page_context

 def page_context(self):
     domain_has_reminders_or_keywords = (
         CaseReminderHandler.domain_has_reminders(self.domain) or
         SurveyKeyword.domain_has_keywords(self.domain)
     )
     bulk_sms_verification_enabled = (
         domain_has_reminders_or_keywords and
         domain_has_privilege(self.domain, privileges.INBOUND_SMS)
     )
     return {
         'group': self.group,
         'bulk_sms_verification_enabled': bulk_sms_verification_enabled,
         'num_users': len(self.member_ids),
         'user_form': self.user_selection_form,
         'domain_uses_case_sharing': self.domain_uses_case_sharing,
     }
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:16,代码来源:groups.py

示例14: get_keyword_display

    def get_keyword_display(self, keyword_id, content_cache):
        if keyword_id in content_cache:
            return content_cache[keyword_id]
        try:
            keyword = SurveyKeyword.get(keyword_id)
            if keyword.deleted():
                display = '%s %s' % (keyword.description, _('(Deleted Keyword)'))
            else:
                urlname = (EditStructuredKeywordView.urlname if keyword.is_structured_sms()
                    else EditNormalKeywordView.urlname)
                display = '<a target="_blank" href="%s">%s</a>' % (
                    reverse(urlname, args=[keyword.domain, keyword_id]),
                    keyword.description,
                )
        except ResourceNotFound:
            display = '-'

        content_cache[keyword_id] = display
        return display
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:19,代码来源:sms.py

示例15: get_keyword_display

    def get_keyword_display(self, keyword_id, content_cache):
        if keyword_id in content_cache:
            return content_cache[keyword_id]
        try:
            keyword = SurveyKeyword.get(keyword_id)
            if keyword.doc_type.endswith('-Deleted'):
                # We'll get rid of this once we move to postgres
                raise ResourceNotFound()
        except ResourceNotFound:
            display = _('(Deleted Keyword)')
        else:
            urlname = (EditStructuredKeywordView.urlname if keyword.is_structured_sms()
                else EditNormalKeywordView.urlname)
            display = '<a target="_blank" href="%s">%s</a>' % (
                reverse(urlname, args=[keyword.domain, keyword_id]),
                keyword.description,
            )

        content_cache[keyword_id] = display
        return display
开发者ID:,项目名称:,代码行数:20,代码来源:


注:本文中的corehq.apps.reminders.models.SurveyKeyword类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。