def get(self, content_id): databaseOperations.connectToDatabase('astrodb') if self.current_user: sessionUserID = databaseOperations.getIDFromUser(self.get_secure_cookie("user"))[0] else: sessionUserID = -1 code=databaseOperations.fetchCode(content_id) if code: path = '../code/' + str(code[0]) codeFile = open(path, 'r+') codeContent = codeFile.read() codeFile.close() else: codeContent = None self.render("../showcode.html", userName=self.get_secure_cookie("user"), code=code, codeContent = codeContent, sessionUserID = sessionUserID, isAdmin=databaseOperations.isAdmin(self.get_secure_cookie("user")), commentNum=databaseOperations.fetchCommentNum(content_id), comments=databaseOperations.fetchComments(content_id), contentID=content_id) databaseOperations.closeConnectionToDatabase()
def get(self, content_id): databaseOperations.connectToDatabase('astrodb') if self.current_user: sessionUserID = databaseOperations.getIDFromUser(self.get_secure_cookie("user"))[0] else: sessionUserID = -1 news = databaseOperations.fetchNews(content_id) if news: path = '../news/' + str(news[0]) newsFile = open(path, 'r+') newsContent = newsFile.read() newsFile.close() else: newsContent = None self.render("../shownews.html", userName=self.get_secure_cookie("user"), news=news, newsContent = newsContent, sessionUserID = sessionUserID, isAdmin=databaseOperations.isAdmin(self.get_secure_cookie("user")), commentNum=databaseOperations.fetchCommentNum(content_id), comments=databaseOperations.fetchComments(content_id), contentID=content_id ) databaseOperations.closeConnectionToDatabase()
def get(self, content_id): databaseOperations.connectToDatabase('astrodb') if self.current_user: sessionUserID = databaseOperations.getIDFromUser(self.get_secure_cookie("user"))[0] else: sessionUserID = -1 self.render("../showart.html", userName=self.get_secure_cookie("user"), art=databaseOperations.fetchArt(content_id), sessionUserID = sessionUserID, isAdmin=databaseOperations.isAdmin(self.get_secure_cookie("user")), commentNum=databaseOperations.fetchCommentNum(content_id), comments=databaseOperations.fetchComments(content_id), contentID=content_id) databaseOperations.closeConnectionToDatabase()
def post(self, content_id): username = self.get_secure_cookie("user") databaseOperations.connectToDatabase('astrodb') if not self.current_user or databaseOperations.isBanned(username) or not databaseOperations.isVerified(username): self.redirect("/login") return (comment, user) = (self.get_argument("comment", None), self.current_user) date = time.strftime("%d %b %G %H:%M", time.localtime(time.time())) user_id = databaseOperations.getIDFromUser(user)[0] content_type = databaseOperations.getContentTypeFromID(content_id)[0] print content_type if not comment: self.redirect( "/show%s/%s" %(content_type, str(content_id)) ) return databaseOperations.insertComment(content_id, user_id, comment, date) databaseOperations.closeConnectionToDatabase() self.redirect( "/show%s/%s" %(content_type, str(content_id)) )