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


Python Survey.put方法代码示例

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


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

示例1: deleteItem

# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import put [as 别名]
def deleteItem():
	form = cgi.FieldStorage();
	vote = form['voteon'].value;	
        item = vote.replace("__"," ");
	survey = form['survey'].value;	
	owner = users.get_current_user();
	oldSurvey = db.GqlQuery("SELECT * FROM Survey WHERE name = :1 and owner = :2",survey,owner);
	oldValues = [];
	oldExpiration="";
	for sur in oldSurvey:
		oldValues = sur.values;
		oldExpiration = sur.expiration;
	oldValues.remove(item);
	newSurvey = Survey(name=survey,owner=owner,values=oldValues,expiration=oldExpiration);
	db.delete(oldSurvey);
	newSurvey.put();
	oldItem = db.GqlQuery("SELECT * FROM Item WHERE name = :1 and owner = :2 and survey = :3",item,owner,survey);
	db.delete(oldItem);
	oldSearch = db.GqlQuery("SELECT * FROM Search WHERE name = :1 and owner = :2 and survey = :3 and entityType = :4",item,owner,survey,"item");
	db.delete(oldSearch);
	oldComment = db.GqlQuery("SELECT * FROM Comments WHERE itemName = :1 AND itemOwner = :2 AND survey = :3",item,owner,surveyName);
	db.delete(oldComment);
	oldCommentValidator = db.GqlQuery("SELECT * FROM CommentValidator WHERE itemName = :1 AND itemOwner = :2 AND survey = :3",item,owner,surveyName);
	db.delete(oldCommentValidator);
	oldVote = db.GqlQuery("SELECT * FROM Vote WHERE name = :1 AND owner = :2 AND survey = :3",item,owner,surveyName);
	db.delete(oldVote);
	return render_template('survey_confirmation.html',survey=survey,option=oldValues);
开发者ID:prasadkapde,项目名称:OstfinalProject,代码行数:29,代码来源:views.py

示例2: addItems

# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import put [as 别名]
def addItems():
	form = cgi.FieldStorage();
	user = users.get_current_user();
	sName = form['addon'].value;
	sName1 = sName.split(" by ");
	sName2 = sName1[0]; 
	surveyName = sName2.replace("__"," ");
	rawOptions = form['additems'].value;
	rawOptions += ',';
	optionList = rawOptions.split(',');
	counter = 0;
	for option in optionList:
			itemPresent = db.GqlQuery("SELECT * FROM Item WHERE name = :1 AND survey = :2 and owner = :3",option,surveyName,user);
			counter1 = itemPresent.count();
			if (counter1 > 0):
				counter = counter + 1;
	if (counter > 0):
		return render_template('failure.html',message="One or more items that you tried to add are already present in this category.None of the items were added.");
	else:
		surveys = db.GqlQuery("SELECT * FROM Survey WHERE name = :1 and owner = :2",surveyName,user);
		oldItemList = [];
		oldExpiration ="";
		for sur in surveys:
			if (sur.name == surveyName):
				oldItemList = sur.values;
				oldExpiration = sur.expiration;
		for newItems in optionList:
			oldItemList.append(newItems);
		newItemList = oldItemList;
		db.delete(surveys);
		newSurvey = Survey(name=surveyName,owner=user,values=newItemList,expiration=oldExpiration);
		newSurvey.put();
		for option in optionList:
                    if option:
                                item = Item(name=option);
                                item.survey = surveyName;
                                item.owner = user;
                                search1 = Search(name=option,entityType="item",survey=surveyName,owner=user);
                                item.put();
                                search1.put();
		return render_template('survey_confirmation.html',survey=surveyName,option=optionList);
开发者ID:prasadkapde,项目名称:OstfinalProject,代码行数:43,代码来源:views.py

示例3: renameCategory

# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import put [as 别名]
def renameCategory():
	form = cgi.FieldStorage();
	user = users.get_current_user();
	newSurveyName = form['renameText'].value.strip();
	oldSurveyName = form['renamesurvey'].value;
	newNameCheck = db.GqlQuery("SELECT * FROM Survey WHERE owner = :1 AND name = :2",user,newSurveyName);
	counter = newNameCheck.count();
	if (counter > 0):
			return render_template('failure.html',message="You already have a survey with given name. Please try with some other name");
	else:
		oldSurvey = db.GqlQuery("SELECT * FROM Survey WHERE owner = :1 AND name = :2",user,oldSurveyName);
		for old in oldSurvey:
			newSurvey = Survey(name=newSurveyName,values=old.values,owner=old.owner,expiration=old.expiration);
			newSurvey.put();
		oldItems = db.GqlQuery("SELECT * FROM Item WHERE survey = :1 and owner = :2",oldSurveyName,user);
		for old in oldItems:
			newItem = Item(name=old.name,image=old.image,survey=newSurveyName,owner=old.owner);
			newItem.put();
		oldVotes = db.GqlQuery("SELECT * FROM Vote WHERE survey = :1 and owner = :2",oldSurveyName,user);
		for old in oldVotes:
			newVote = Vote(name=old.name,owner=old.owner,win=old.win,survey=newSurveyName);
			newVote.put();
		oldComments = db.GqlQuery("SELECT * FROM Comments WHERE itemOwner = :1 AND survey = :2",user,oldSurveyName);
		for old in oldComments:
			newComment = Comments(itemName=old.itemName,itemOwner=old.itemOwner,comment=old.comment,survey=newSurveyName);
			newComment.put();
		oldCommentValidator = db.GqlQuery("SELECT * FROM CommentValidator where itemOwner = :1 and survey = :2",user,oldSurveyName);
		for old in oldCommentValidator:
			newCommentValidator = CommentValidator(itemName=old.itemName,itemOwner=old.itemOwner,commenter=old.commenter,survey=newSurveyName);
			newCommentValidator.put();
		oldSearch = db.GqlQuery("SELECT * FROM  Search WHERE survey = :1 AND owner = :2",oldSurveyName,user);
		for old in oldSearch:
			if(old.entityType == "survey"):
				newSearch = Search(name=newSurveyName,entityType=old.entityType,survey=newSurveyName,owner=old.owner);
				newSearch.put();
			else:
				newSearch = Search(name=old.name,entityType=old.entityType,survey=newSurveyName,owner=old.owner);
				newSearch.put();
		deleteGeneric(surveyName=oldSurveyName);
		return render_template('failure.html',message="Update Successful!");
开发者ID:prasadkapde,项目名称:OstfinalProject,代码行数:42,代码来源:views.py

示例4: addSurvey

# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import put [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

示例5: updateExpiration

# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import put [as 别名]
def updateExpiration():
	form = cgi.FieldStorage();
	user = users.get_current_user();
	oldSurveyName = form['update'].value;
	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);
	oldSurvey = db.GqlQuery("SELECT * FROM Survey WHERE name = :1 AND owner = :2",oldSurveyName,user);
	newSurvey="";
	for old in oldSurvey:
		newSurvey= Survey(name=old.name,values=old.values,owner=old.owner,expiration=surveyExpireDate);
	db.delete(oldSurvey);
	newSurvey.put();
	return render_template('failure.html',message="Update Successful.");
开发者ID:prasadkapde,项目名称:OstfinalProject,代码行数:26,代码来源:views.py

示例6: uploadFile

# 需要导入模块: from survey.models import Survey [as 别名]
# 或者: from survey.models.Survey import put [as 别名]
def uploadFile():
	try:
		form = cgi.FieldStorage();
		item = form["filename"];
		data = "";
		if item.file:
			data = item.file;
		doc = xml.dom.minidom.parse(data)
		items = doc.getElementsByTagName("NAME");
		owner = users.get_current_user();
		optionList = [];
		for node in items:
			optionList.append(node.firstChild.nodeValue);
		surveyName = optionList[0].strip();
		optionList.remove(surveyName);		
		surveyCheck = db.GqlQuery("SELECT * FROM Survey WHERE name = :1 and owner = :2",surveyName,owner);
		surveyCount = surveyCheck.count();
		if (surveyCount > 0):
			##Get the old item list from Survey.
			oldList = [];
			oldExpiration = "";
			for sur in surveyCheck:
				oldList = oldList+sur.values;
				oldExpiration = sur.expiration;
			addList = []; ## Items that are present in both list;
			removeList = [] ## Items to be deleted.
			listCounter = 0;
			tempList = optionList;
			for old in oldList:
				if(old in optionList):
					addList.append(old);
					optionList.remove(old);
					listCounter = listCounter + 1;
				else:
					removeList.append(old);
			if (len(addList) == len(tempList)) and (listCounter == len(tempList))and (len(removeList) == 0):
				removeList = tempList;
			for remove in removeList:
				oldItem = db.GqlQuery("SELECT * FROM Item WHERE name = :1 and owner = :2 and survey = :3",remove,owner,surveyName);
				db.delete(oldItem);
				oldSearch = db.GqlQuery("SELECT * FROM Search WHERE name = :1 and owner = :2 and survey = :3 and entityType = :4",remove,owner,surveyName,"item");
				db.delete(oldSearch);
				oldComment = db.GqlQuery("SELECT * FROM Comments WHERE itemName = :1 AND itemOwner = :2 AND survey = :3",remove,owner,surveyName);
				db.delete(oldComment);
				oldCommentValidator = db.GqlQuery("SELECT * FROM CommentValidator WHERE itemName = :1 AND itemOwner = :2 AND survey = :3",remove,owner,surveyName);
				db.delete(oldCommentValidator);
				oldVote = db.GqlQuery("SELECT * FROM Vote WHERE name = :1 AND owner = :2 AND survey = :3",remove,owner,surveyName);
				db.delete(oldVote);
			for item in optionList:
				newItem = Item(name=item,survey=surveyName,owner=owner);
				search1 = Search(name=item,owner=owner,entityType="item",survey=surveyName);
				newItem.put();
				search1.put();
			for add in addList:
				optionList.append(add);
			db.delete(surveyCheck);
			newSurvey = Survey(name=surveyName,owner=owner,values=optionList,expiration=oldExpiration);
			newSurvey.put();
		else:
			surveyExpireDate = datetime.datetime(2012,12,30,00,00,00);
			newSurvey = Survey(name=surveyName,owner=owner,values=optionList,expiration=surveyExpireDate);
			newSurvey.put();
			search = Search(name=surveyName,owner=owner,entityType="Survey",survey=surveyName);
			search.put();
			for item in optionList:
				newItem = Item(name=item,survey=surveyName,owner=owner);
				search1 = Search(name=item,owner=owner,entityType="item",survey=surveyName);
				newItem.put();
				search1.put();
		return render_template('survey_confirmation.html',survey=surveyName,option=optionList);
	except:
		return render_template('failure.html',message="The file you uploaded was incorrect!");
开发者ID:prasadkapde,项目名称:OstfinalProject,代码行数:74,代码来源:views.py


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