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


Python Survey.save_sample_size方法代码示例

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


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

示例1: edit

# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import save_sample_size [as 别名]
def edit(request, survey_id):
    try:
        survey = Survey.objects.get(id=survey_id)
        survey_form = SurveyForm(instance=survey)
        if request.method == 'POST':
            survey_form = SurveyForm(instance=survey, data=request.POST)
            if survey_form.is_valid():
                Survey.save_sample_size(survey_form)
                messages.success(request, 'Survey successfully edited.')
                return HttpResponseRedirect(reverse('survey_list_page'))
            elif survey_form.errors.get('__all__'):
                messages.error(request, survey_form.errors['__all__'])
        context = {'survey_form': survey_form,
                   'title': "Edit Survey",
                   'button_label': 'Save',
                   'id': 'edit-survey-form',
                   'cancel_url': request.META.get('HTTP_REFERER') or reverse('survey_list_page'),
                   'action': reverse('edit_survey_page', args=(survey_id, ))
                   }
        request.breadcrumbs([
            ('Surveys', reverse('survey_list_page')),
        ])
        return render(request, 'surveys/new.html', context)
    except Survey.DoesNotExist:
        messages.error(request, 'survey does not exists')
        return HttpResponseRedirect(reverse('survey_list_page'))
开发者ID:unicefuganda,项目名称:uSurvey,代码行数:28,代码来源:surveys.py

示例2: new

# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import save_sample_size [as 别名]
def new(request):
    response = None
    survey_form = SurveyForm()

    if request.method == 'POST':
        survey_form = SurveyForm(request.POST)
        if survey_form.is_valid():
            Survey.save_sample_size(survey_form)
            messages.success(request, 'Survey successfully added.')
            response = HttpResponseRedirect(reverse('survey_list_page') )
        elif survey_form.errors.get('__all__'):
            messages.error(request, survey_form.errors['__all__'])

    context = {'survey_form': survey_form,
               'title': "New Survey",
               'button_label': 'Create',
               'id': 'add-survey-form',
               'action': ".",
               'cancel_url': request.META.get('HTTP_REFERER') or reverse('survey_list_page'),
               }
    request.breadcrumbs([
        ('Surveys', reverse('survey_list_page')),
    ])
    return response or render(request, 'surveys/new.html', context)
开发者ID:unicefuganda,项目名称:uSurvey,代码行数:26,代码来源:surveys.py


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