本文整理汇总了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'])
示例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'))
示例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')
示例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})