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


Python Survey.get方法代码示例

本文整理汇总了Python中survey.models.Survey.get方法的典型用法代码示例。如果您正苦于以下问题:Python Survey.get方法的具体用法?Python Survey.get怎么用?Python Survey.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在survey.models.Survey的用法示例。


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

示例1: __init__

# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import get [as 别名]
 def __init__(self, *args, **kwargs):
     super(IndicatorForm, self).__init__(*args, **kwargs)
     if kwargs.get('instance'):
         qset = kwargs['instance'].question_set
         survey = kwargs['instance'].survey
         self.fields['survey'].initial = survey
         self.fields['survey'].widget.attrs['readonly'] = 'readonly'
         self.fields['question_set'].queryset = survey.qsets
         self.fields['question_set'].initial = qset
         self.fields['question_set'].widget.attrs['readonly'] = 'readonly'
         self.fields['variables'].initial = kwargs['instance'].variables.all()
     self.fields['variables'].queryset = self.available_variables()
     self.fields['variables'].icons = {
             'add': {
                 'data-toggle': "modal",
                 'data-target': "#add_variable",
                 'id': 'add_new_variable',
                 'title': 'Add Variable'},
             'edit': {
                 'data-toggle': "modal",
                 'title': 'Edit Variable',
                 'id': 'edit_variable'},
             'delete': {
                 'data-toggle': "modal",
                 'data-target': "#remove-selected-variable",
                 'id': 'delete_variable',
                 'title': 'Delete Variable'}}
     self.fields['formulae'].icons = {'check': {'id': 'validate', 'title': 'Validate'}, }
     if self.data.get('survey'):
         self.fields['question_set'].queryset = Survey.get(
             pk=self.data['survey']).qsets
     self.fields['name'].label = 'Indicator'
     self.order_fields(['survey', 'question_set', 'name',
                        'description', 'variables', 'formulae'])
开发者ID:unicefuganda,项目名称:uSurvey,代码行数:36,代码来源:indicator.py

示例2: wipe_survey_data

# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import get [as 别名]
def wipe_survey_data(request, survey_id):
    from survey.models import Interview
    from survey.utils import views_helper
    if views_helper.has_super_powers(request):
        survey = Survey.get(pk=survey_id)
        Interview.objects.filter(survey=survey).delete()
        messages.info(request, 'Data has been cleared for %s' % survey.name)
    return HttpResponseRedirect(reverse('survey_list_page'))
开发者ID:unicefuganda,项目名称:uSurvey,代码行数:10,代码来源:surveys.py

示例3: list_qsets

# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import get [as 别名]
def list_qsets(request):
    if request.GET.get('survey_id'):
        values = Survey.get(
            id=request.GET.get('survey_id')).qsets.values(
            'id', 'name')
    else:
        values = QuestionSet.objects.values('id', 'name')
    return HttpResponse(
        json.dumps(
            list(values)),
        content_type='application/json')
开发者ID:unicefuganda,项目名称:uSurvey,代码行数:13,代码来源:question_set.py

示例4: index

# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import get [as 别名]
def index(request, survey_id=None):
    if survey_id:
        survey = Survey.get(pk=survey_id)
    request.breadcrumbs(Batch.index_breadcrumbs(survey=survey))
    if survey_id is None:
        batches = Batch.objects.all()
    else:
        batches = Batch.objects.filter(survey__id=survey_id)
    qset_view = QuestionSetView(model_class=Batch)
    qset_view.questionSetForm = BatchForm
    return qset_view.index(
        request, batches, extra_context={
            'survey': survey}, initial={
            'survey': survey.pk})
开发者ID:unicefuganda,项目名称:uSurvey,代码行数:16,代码来源:batch.py


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