def writeComment(targId, currentUser, commentText): userDict = stdStuff.objFileToList(stdStuff.directory, stdStuff.userFile, byName=True) counter = stdStuff.getCounter() for post in userDict[currentUser].posts: if post.id == targId: post.addComment(counter, currentUser, commentText) stdStuff.objListToFile(userDict, stdStuff.directory, stdStuff.userFile, isDict=True) stdStuff.setCounter(counter) return for friend in userDict[currentUser].friends: for post in userDict[friend].posts: if post.id == targId: post.addComment(counter, currentUser, commentText) stdStuff.objListToFile(userDict, stdStuff.directory, stdStuff.userFile, isDict=True) stdStuff.setCounter(counter) return
def writeComment(targId, cookie, commentText): targName = cookie["username"].value allUsers = stdStuff.objFileToList(stdStuff.directory, stdStuff.userFile) counter = stdStuff.getCounter() for index, value in enumerate(allUsers): if value.name == targName: for index2, value2 in enumerate(value.posts): if int(value2.id) == int(targId): value.posts[index2].addComment(counter, targName, commentText) stdStuff.objListToFile(allUsers, stdStuff.directory, stdStuff.userFile) stdStuff.setCounter(counter)
def writeComment(targId, cookie, commentText): targName = currentGroup currentUser = c['username'].value groupList = stdStuff.objFileToList(stdStuff.directory, stdStuff.groupFile) counter = stdStuff.getCounter() for index, value in enumerate(groupList): if value.name == targName: for index2, value2 in enumerate(value.posts): if int(value2.id) == int(targId): value.posts[index2].addComment(counter, currentUser, commentText) stdStuff.objListToFile(groupList, stdStuff.directory, stdStuff.groupFile) stdStuff.setCounter(counter)
def writePost(cookie, formThing): counter = stdStuff.getCounter() userList = stdStuff.objFileToList(stdStuff.directory, stdStuff.userFile) for x in userList: if x.name == cookie["username"].value: x.addPost( stdStuff.Post(counter, cookie["username"].value, formThing.getvalue("postTitle"), formThing.getvalue('textBody'))) break stdStuff.setCounter(counter) stdStuff.objListToFile(userList, stdStuff.directory, stdStuff.userFile)
def writePost(cookie, formThing): counter = stdStuff.getCounter() userList = stdStuff.objFileToList(stdStuff.directory, stdStuff.userFile) for x in userList: if x.name == cookie["username"].value: x.addPost(stdStuff.Post( counter, cookie["username"].value, stdStuff.deleteBrackets(formThing.getvalue("postTitle")), stdStuff.deleteBrackets(formThing.getvalue('textBody')))) break stdStuff.setCounter(counter) stdStuff.objListToFile(userList, stdStuff.directory, stdStuff.userFile)
def writePost(cookie, formThing): counter = stdStuff.getCounter() groupList = stdStuff.objFileToList(stdStuff.directory, stdStuff.groupFile) for x in groupList: if x.name == currentGroup: x.addPost( stdStuff.Post( counter, cookie["username"].value, stdStuff.deleteBrackets(formThing.getvalue("postTitle")), stdStuff.deleteBrackets(formThing.getvalue('textBody')))) break stdStuff.setCounter(counter) stdStuff.objListToFile(groupList, stdStuff.directory, stdStuff.groupFile)
def writePost(cookie, formThing): counter = stdStuff.getCounter() groupList = stdStuff.objFileToList(stdStuff.directory, stdStuff.groupFile) for x in groupList: if x.name == currentGroup: x.addPost( stdStuff.Post( counter, cookie["username"].value, formThing.getvalue("postTitle"), formThing.getvalue('textBody'))) break stdStuff.setCounter(counter) stdStuff.objListToFile(groupList, stdStuff.directory, stdStuff.groupFile)
form.getvalue("messageTitle"), form.getvalue("messageBody")) except KeyError: body += "<h1>" + recipient + " is not a registered user</h1>" if "markRead" in form: targetMessage = form.getvalue("markRead") if targetMessage == "all": for message in userDict[currentUser].inbox.messages: message.viewed = True else: for message in userDict[currentUser].inbox.messages: if message.id == int(targetMessage): message.viewed = True break stdStuff.objListToFile(userDict, stdStuff.directory, stdStuff.userFile, isDict=True) elif "markUnread" in form: targetMessage = form.getvalue("markUnread") if targetMessage == "all": for message in userDict[currentUser].inbox.messages: message.viewed = False else: for message in userDict[currentUser].inbox.messages: if message.id == int(targetMessage): message.viewed = False break stdStuff.objListToFile(userDict, stdStuff.directory, stdStuff.userFile, isDict=True) if "read" in form:
for index2, value2 in \ enumerate(value.comments): if int(value2.id) == int(commentId): value.comments[ index2].decreaseScore() break elif "upVote" in form: for index, value in enumerate(x.posts): if value.id == targId: for index2, value2 in \ enumerate(value.comments): if value2.id == commentId: value.comments[ index2].increaseScore() break stdStuff.objListToFile(userList, stdStuff.directory, stdStuff.userFile) if "done" in form: writeComment(targId, c, form.getvalue("comment")) body += displayPost(targId, c, "", "", "", "") body += poster() body += """<a href="profile.py">Go back to profile</a>""" else: body += "Failed to Authenticate cookie<br>\n" body += 'Go Login <a href="login.py">here</a><br>' else: body += "Your information expired<br>\n" body += 'Go Login <a href="login.py">here</a><br>' else:
"upVote": comment\ .votedUsers[targName] = "noVote" comment.decreaseScore() elif comment.votedUsers[targName] == \ "downVote": comment\ .votedUsers[targName] = "noVote" comment.increaseScore() break stdStuff.objListToFile(groupDict, stdStuff.directory, stdStuff.groupFile, isDict=True) if "done" in form: writeComment(targId, c, form.getvalue("comment")) body += displayPost(targId, c, "", "", "", "") body += poster() body += """<a href="groupsPage.py">Go back to group page</a>""" else: body += "Failed to Authenticate cookie<br>\n" body += 'Go Login <a href="login.py">here</a><br>' else: body += "Your information expired<br>\n" body += 'Go Login <a href="login.py">here</a><br>'
f = open(directory + stdStuff.currentGroupFile, 'w') f.write(form.getvalue('displayGroups')) f.close() groupStatus = '' f = open(directory + stdStuff.currentGroupFile, 'r') currentGroup = f.read() f.close() if 'done' in form: if form.getvalue('done') == "Add Member": for group in groupList: if group.name == currentGroup: group.addMember(form.getvalue('addMember')) stdStuff.objListToFile(groupList, stdStuff.directory, stdStuff.groupFile,) if form.getvalue('done') == "Kick Member": for group in groupList: if group.name == currentGroup: group.kickMember(form.getvalue('kickMember')) stdStuff.objListToFile(groupList, stdStuff.directory, stdStuff.groupFile,) if form.getvalue('done') == "Change Visibility": for group in groupList: if group.name == currentGroup: group.changeVisibility(form.getvalue('visibility')) stdStuff.objListToFile(groupList, stdStuff.directory, stdStuff.groupFile,) if form.getvalue('done') == "Change Name": groupName = stdStuff.deleteBrackets(form.getvalue('groupName')) for group in groupList:
for index, value in enumerate(x.posts): if value.id == targId: for index2, value2 in \ enumerate(value.comments): if int(value2.id) == int(commentId): value.comments[index2].decreaseScore() break elif "upVote" in form: for index, value in enumerate(x.posts): if value.id == targId: for index2, value2 in \ enumerate(value.comments): if value2.id == commentId: value.comments[index2].increaseScore() break stdStuff.objListToFile(userList, stdStuff.directory, stdStuff.userFile) if "done" in form: writeComment(targId, username, form.getvalue("comment")) body += displayPost(targId, c["username"].value, "", "", "", "") body += poster() body += """<a href="profile.py">Go back to profile</a>""" else: body+="Failed to Authenticate cookie<br>\n" body+= 'Go Login <a href="login.py">here</a><br>' else: body+= "Your information expired<br>\n"
"upVote": comment\ .votedUsers[targName] = "noVote" comment.decreaseScore() elif comment.votedUsers[targName] == \ "downVote": comment\ .votedUsers[targName] = "noVote" comment.increaseScore() break stdStuff.objListToFile(userDict, stdStuff.directory, stdStuff.userFile, isDict=True) if "done" in form: writeComment(targId, username, stdStuff.deleteBrackets(form.getvalue("comment"))) body += displayPost(targId, c["username"].value, "", "", "", "") body += poster() else: body += "Failed to Authenticate cookie<br>\n" body += 'Go Login <a href="login.py">here</a><br>' else: body += "Your information expired<br>\n" body += 'Go Login <a href="login.py">here</a><br>'
allPosts = [] if "downVote" in form or "upVote" in form: targId = int(form.getvalue("postId")) allPosts = stdStuff.objFileToList(stdStuff.directory, stdStuff.postFile) if "downVote" in form: for index, value in enumerate(allPosts): if value.id == targId: allPosts[index].decreaseScore() elif "upVote" in form: for index, value in enumerate(allPosts): if value.id == targId: allPosts[index].increaseScore() break stdStuff.objListToFile(allPosts, stdStuff.directory, stdStuff.postFile) allPosts = stdStuff.objFileToList(stdStuff.directory, stdStuff.postFile) body += makePage() else: body += "Failed to Authenticate cookie<br>\n" body += 'Go Login <a href="login.py">here</a><br>' else: body += "Your information expired<br>\n" body += 'Go Login <a href="login.py">here</a><br>' else: body += 'You seem new<br>\n' body += 'Go Login <a href="login.py">here</a><br>'
allPosts = [] if "downVote" in form or "upVote" in form: targId = int(form.getvalue("postId")) allPosts = stdStuff.objFileToList(stdStuff.directory, stdStuff.postFile) if "downVote" in form: for index, value in enumerate(allPosts): if value.id == targId: allPosts[index].decreaseScore() elif "upVote" in form: for index, value in enumerate(allPosts): if value.id == targId: allPosts[index].increaseScore() break stdStuff.objListToFile(allPosts, stdStuff.directory, stdStuff.postFile) allPosts = stdStuff.objFileToList(stdStuff.directory, stdStuff.postFile) body+=makePage() else: body+="Failed to Authenticate cookie<br>\n" body+= 'Go Login <a href="login.py">here</a><br>' else: body+= "Your information expired<br>\n" body+= 'Go Login <a href="login.py">here</a><br>' else: body+= 'You seem new<br>\n' body+='Go Login <a href="login.py">here</a><br>'