def post(self,type): if type != '': user = AccountIO() user.getFromSession() if user.account: postwrite = PostWrite(user.account) if type == 'text': postwrite.postText(self.request.get('title'), self.request.get('textpost')) elif type == 'quote': postwrite.postQuote(self.request.get('quote'), self.request.get('source')) elif type == 'link': postwrite.postLink(self.request.get('title'), self.request.get('url'), self.request.get('description')) elif type == 'image': if self.request.get('imageurl') != '': postwrite.postImage(self.request.get('imageurl'), self.request.get('caption')) # Todo: add image upload code. elif type == 'embed': postwrite.postEmbed(self.request.get('embedcode'), self.request.get('description')) if self.request.headers['referer'].startswith('http://pinstme.appspot.com/share'): path = os.path.join(os.path.dirname(__file__), '../views/bookmarklet-exit.html') self.response.out.write(template.render(path,{'message':'Message Posted!'})) else: self.redirect('/')
def get(self, nickname): if nickname == '': self.redirect('/') else: profile = AccountIO() profile.getFromNickname( nickname ) # Called user doesn't exist if not profile.account: self.redirect('/') else: user = AccountIO() user.getFromSession() posts = PostRead() '''if isOwner: token = Token() token.account = account.key() avatar_token = string.join( random.sample( string.letters + string.digits, 30 ), '' ) token.code = avatar_token expires = datetime.now() + timedelta( hours = 1 ) token.expires = expires token.put() else: avatar_token = '' ''' # Template values template_values = { 'user': user.account, 'profile': profile.account, 'profileFollowing': user.isFollowing( profile ), 'profileFolled': user.isFollowing( profile ), 'profileMessages': posts.getSentMessages( profile.account ), 'profileFollowed': profile.getFollowed(), 'profileFollowers': profile.getFollowers() } # We get the template path then show it path = os.path.join(os.path.dirname(__file__), '../views/profile.html') self.response.out.write(template.render(path, template_values))
def get(self): user = AccountIO() user.getFromSession() # Template values, yay! if user.account: template_values = { 'nickname': user.account.nickname } else: self.redirect('/') # We get the template path then show it path = os.path.join(os.path.dirname(__file__), '../views/post.html') self.response.out.write(template.render(path, template_values))
def get(self): user = AccountIO() postread = PostRead() user.getFromSession() # Template values, yay! if user.account: template_values = { 'messages': postread.getMessages(user.account), 'nickname': user.account.nickname } else: template_values = { 'messages': postread.getAllMessages(), 'nickname': '' } # We get the template path then show it path = os.path.join(os.path.dirname(__file__), '../views/index.html') self.response.out.write(template.render(path, template_values))
def post(self, follow_nick): # Toggle following a user or not # Query: User's account & friend's nickname user_account = AccountIO() user_account.getFromSession() # Does that user exist? follow_account = AccountIO() follow_account.getFromSession() if follow_account.account and user_account.account: if user_account.isFollowing( follow_account.account ): user_account.account.following.remove(follow_account.account.key()) else: user_account.account.following.append(follow_account.account.key()) user_account.account.put() self.redirect('/user/'+follow_nick)