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


Python models.Form类代码示例

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


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

示例1: dehydrate_module

    def dehydrate_module(self, app, module, langs):
        """
        Convert a Module object to a JValue representation
        with just the good parts.

        NOTE: This is not a tastypie "magic"-name method to
        dehydrate the "module" field; there is no such field.
        """
        dehydrated = {}

        dehydrated['case_type'] = module.case_type

        dehydrated['case_properties'] = app_manager_util.get_case_properties(app, [module.case_type], defaults=['name'])[module.case_type]

        dehydrated['forms'] = []
        for form in module.forms:
            form = Form.get_form(form.unique_id)
            form_jvalue = {
                'xmlns': form.xmlns,
                'name': form.name,
                'questions': form.get_questions(langs),
            }
            dehydrated['forms'].append(form_jvalue)

        return dehydrated
开发者ID:NoahCarnahan,项目名称:commcare-hq,代码行数:25,代码来源:v0_4.py

示例2: create_data_source_from_app

def create_data_source_from_app(request, domain):
    if request.method == 'POST':
        form = ConfigurableDataSourceFromAppForm(domain, request.POST)
        if form.is_valid():
            # save config
            app_source = form.app_source_helper.get_app_source(form.cleaned_data)
            app = Application.get(app_source.application)
            if app_source.source_type == 'case':
                data_source = get_case_data_source(app, app_source.source)
                data_source.save()
                messages.success(request, _(u"Data source created for '{}'".format(app_source.source)))
            else:
                assert app_source.source_type == 'form'
                xform = Form.get_form(app_source.source)
                data_source = get_form_data_source(app, xform)
                data_source.save()
                messages.success(request, _(u"Data source created for '{}'".format(xform.default_name())))

            return HttpResponseRedirect(reverse('edit_configurable_data_source', args=[domain, data_source._id]))
    else:
        form = ConfigurableDataSourceFromAppForm(domain)
    context = _shared_context(domain)
    context['sources_map'] = form.app_source_helper.all_sources
    context['form'] = form
    return render(request, 'userreports/data_source_from_app.html', context)
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:25,代码来源:views.py

示例3: keyword_uses_form_that_requires_case

def keyword_uses_form_that_requires_case(survey_keyword):
    for action in survey_keyword.keywordaction_set.all():
        if action.action in [KeywordAction.ACTION_SMS_SURVEY, KeywordAction.ACTION_STRUCTURED_SMS]:
            form = Form.get_form(action.form_unique_id)
            if form.requires_case():
                return True
    return False
开发者ID:dimagi,项目名称:commcare-hq,代码行数:7,代码来源:keyword.py

示例4: get_form_name

def get_form_name(form_unique_id):
    try:
        form = Form.get_form(form_unique_id)
    except ResourceNotFound:
        return _("[unknown]")

    return form.full_path_name
开发者ID:nnestle,项目名称:commcare-hq,代码行数:7,代码来源:util.py

示例5: dehydrate_module

    def dehydrate_module(self, app, module, langs):
        """
        Convert a Module object to a JValue representation
        with just the good parts.

        NOTE: This is not a tastypie "magic"-name method to
        dehydrate the "module" field; there is no such field.
        """
        try:
            dehydrated = {}

            dehydrated["case_type"] = module.case_type

            dehydrated["case_properties"] = app_manager_util.get_case_properties(
                app, [module.case_type], defaults=["name"]
            )[module.case_type]

            dehydrated["unique_id"] = module.unique_id

            dehydrated["forms"] = []
            for form in module.forms:
                form_unique_id = form.unique_id
                form = Form.get_form(form_unique_id)
                form_jvalue = {
                    "xmlns": form.xmlns,
                    "name": form.name,
                    "questions": form.get_questions(langs, include_translations=True),
                    "unique_id": form_unique_id,
                }
                dehydrated["forms"].append(form_jvalue)
            return dehydrated
        except Exception as e:
            return {"error": unicode(e)}
开发者ID:puttarajubr,项目名称:commcare-hq,代码行数:33,代码来源:v0_4.py

示例6: keyword_uses_form_that_requires_case

def keyword_uses_form_that_requires_case(survey_keyword):
    for action in survey_keyword.actions:
        if action.action in [METHOD_SMS_SURVEY, METHOD_STRUCTURED_SMS]:
            form = Form.get_form(action.form_unique_id)
            if form.requires_case():
                return True
    return False
开发者ID:johan--,项目名称:commcare-hq,代码行数:7,代码来源:keyword.py

示例7: get_form

def get_form(form_unique_id, include_app_module=False):
    form = Form.get_form(form_unique_id)
    if include_app_module:
        app = form.get_app()
        module = form.get_module()
        return (app, module, form)
    else:
        return form
开发者ID:jmaina,项目名称:commcare-hq,代码行数:8,代码来源:keyword.py

示例8: _resolve_from_template

 def _resolve_from_template(self, template, query_context):
     # todo: support other types and options
     assert template.type == 'form'
     startdate, enddate = get_daterange_start_end_dates(template.time_range)
     xmlns = Form.get_form(template.source_id).xmlns
     return FormData.objects.filter(
         user_id=query_context.user._id,
         xmlns=xmlns,
         received_on__gte=startdate,
         received_on__lt=enddate,
     ).count()
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:11,代码来源:query_engine.py

示例9: clean_form_unique_id

 def clean_form_unique_id(self):
     value = self.cleaned_data.get("form_unique_id")
     if value is None:
         raise ValidationError(_("Please create a form first, and then add a keyword for it."))
     try:
         form = CCHQForm.get_form(value)
         app = form.get_app()
         assert app.domain == self._cchq_domain
     except Exception:
         raise ValidationError(_("Invalid form chosen."))
     return value
开发者ID:comm-scriptek,项目名称:commcare-hq,代码行数:11,代码来源:forms.py

示例10: search_form_by_id_response

 def search_form_by_id_response(self):
     """
     Returns a dict of {"id": [form unique id], "text": [full form path]}
     """
     form_unique_id = self.search_term
     try:
         form = Form.get_form(form_unique_id)
         assert form.get_app().domain == self.domain
         return {"text": form.full_path_name, "id": form_unique_id}
     except:
         return {}
开发者ID:dimagi,项目名称:commcare-hq,代码行数:11,代码来源:views.py

示例11: clean

 def clean(self):
     cleaned_data = super(ConfigurableFormDataSourceFromAppForm, self).clean()
     app = Application.get(cleaned_data['app_id'])
     form = Form.get_form(cleaned_data['form_id'])
     if form.get_app()._id != app._id:
         raise ValidationError(_('Form name {} not found in application {}').format(
             form.default_name(),
             app.name
         ))
     self.app = app
     self.form = form
     return cleaned_data
开发者ID:jmaina,项目名称:commcare-hq,代码行数:12,代码来源:forms.py

示例12: get_memoized_app_module_form

    def get_memoized_app_module_form(self, domain):
        try:
            form = Form.get_form(self.form_unique_id)
            app = form.get_app()
            module = form.get_module()
        except (ResourceNotFound, XFormIdNotUnique):
            return None, None, None, None

        if app.domain != domain:
            return None, None, None, None

        return app, module, form, form_requires_input(form)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:12,代码来源:content.py

示例13: get_app_module_form

def get_app_module_form(form_unique_id, logged_subevent=None):
    """
    Returns (app, module, form, error, error_code)
    """
    try:
        form = Form.get_form(form_unique_id)
        app = form.get_app()
        module = form.get_module()
        return (app, module, form, False, None)
    except:
        log_error(MessagingEvent.ERROR_CANNOT_FIND_FORM, logged_subevent)
        return (None, None, None, True, MSG_FORM_NOT_FOUND)
开发者ID:johan--,项目名称:commcare-hq,代码行数:12,代码来源:keyword.py

示例14: validate_form_unique_id

def validate_form_unique_id(form_unique_id, domain):
    error_msg = _('Invalid form chosen.')
    try:
        form = CCHQForm.get_form(form_unique_id)
        app = form.get_app()
    except Exception:
        raise ValidationError(error_msg)

    if app.domain != domain:
        raise ValidationError(error_msg)

    return form_unique_id
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:12,代码来源:forms.py

示例15: get_app_module_form

def get_app_module_form(call_log_entry, logged_subevent):
    """
    Returns (app, module, form, error)
    """
    try:
        form = Form.get_form(call_log_entry.form_unique_id)
        app = form.get_app()
        module = form.get_module()
        return (app, module, form, False)
    except:
        log_error(MessagingEvent.ERROR_CANNOT_FIND_FORM, call_log_entry, logged_subevent)
        return (None, None, None, True)
开发者ID:nnestle,项目名称:commcare-hq,代码行数:12,代码来源:api.py


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