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


Python Survey.owner方法代码示例

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


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

示例1: addSurvey

# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import owner [as 别名]
def addSurvey():
	form = cgi.FieldStorage();
	user = users.get_current_user();
	surveyName = form['sname'].value.strip();	
	rawOptions = form['options'].value;
	rawOptions += ',';
	optionList = rawOptions.split(',');
	surveyExpireDate = "";
	if (form.has_key("dateValue")):
		expireDate = form['dateValue'].value;
		expireHour = int(form['hours'].value);
		expireMinutes = int(form['minutes'].value);
		expireSeconds = int(form['seconds'].value);
		rawDate = expireDate.split("/");
		month = int(rawDate[0]);
		day = int(rawDate[1]);
		year = int(rawDate[2]);
		surveyExpireDate = datetime.datetime(year,month,day,expireHour,expireMinutes,expireSeconds);
	else:
		surveyExpireDate = datetime.datetime(2012,12,30,0,0,0);
	surveys = db.GqlQuery("SELECT * FROM Survey WHERE name = :1 and owner = :2",surveyName,user);
	counter = surveys.count();
	if (counter == 0):
		survey = Survey(name=surveyName,expiration=surveyExpireDate);
		survey.values = optionList;
		survey.owner = user;
		survey.put();
		search = Search(name=surveyName,entityType="survey",survey=surveyName,owner=user);
		search.put();
		for option in optionList:
			if option:
				item = Item(name=option);
				item.survey = surveyName;
				item.owner = user;
				item.put();
				search1 = Search(name=option,entityType="item",survey=surveyName,owner=user);
				search1.put();
		return render_template('survey_confirmation.html',survey=surveyName,option=optionList);
	else:
		return render_template('failure.html',message="You already have created this survey! Please create a different survey.");
开发者ID:prasadkapde,项目名称:OstfinalProject,代码行数:42,代码来源:views.py


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