def post(self): logging.debug("POST") self.response.headers['Content-Type'] = 'text/html' action = self.request.get('button') if action == 'follow': username = self.request.get('username') if username is not None or username != '': userinfo_id = username userinfo_key = ndb.Key(UserInfo, userinfo_id) userin = userinfo_key.get() my_user = utilities.userKey() my_user.following.append(username) my_user.put() self.redirect('/') elif action == 'unfollow': my_user = utilities.userKey() user_id = self.request.get('username') user_key = ndb.Key(UserInfo, user_id) if user_id in my_user.following: idx = my_user.following.index(user_id) del my_user.following[idx] my_user.put() self.redirect('/')
def post(self): logging.debug("POST") self.response.headers['Content-Type'] = 'text/html' action = self.request.get('button') if action == 'Update': my_user = utilities.userKey() username = self.request.get('username') content = self.request.get('content') if content is not None or content != '': twitter_id = content twitter_key = ndb.Key(Twitter, twitter_id) tweets = twitter_key.get() my_user = utilities.userKey() new_data = Twitter(id=twitter_id, username=username, content=content, user_id=my_user.key.id()) new_data.put() my_user.tweets.append(twitter_key) my_user.put() self.redirect('/')
def get(self): logging.debug("GET") self.response.headers['Content-Type'] = 'text/html' my_user = utilities.userKey() value = self.request.get('name') query = Twitter.query() data = query.fetch() query1 = UserInfo.query() data1 = query1.fetch() if utilities.userLoggedIn(): if my_user is None or my_user == '': if not utilities.userExist(): utilities.newUser(utilities.currentUser()) renderpage.register(self, utilities.logoutUrl(self), my_user) else: if not utilities.userExist(): utilities.newUser(utilities.currentUser()) renderpage.user(self, utilities.logoutUrl(self), my_user, data, data1, value) else: renderpage.login(self, utilities.loginUrl(self))
def post(self): logging.debug("POST") self.response.headers['Content-Type'] = 'text/html' action = self.request.get('button') if action == 'Register': first_name = self.request.get('fname') last_name = self.request.get('lname') username = self.request.get('username') about = self.request.get('about') dob = self.request.get('dob') if username is not None or username != '': userinfo_id = username userinfo_key = ndb.Key(UserInfo, userinfo_id) userin = userinfo_key.get() my_user = utilities.userKey() new_data = UserInfo(id=userinfo_id, username=username, first_name=first_name, last_name=last_name, about=about, dob=datetime.strptime(dob, '%Y-%m-%d'),user_id=my_user.key.id()) new_data.put() my_user.username = username my_user.put() self.redirect('/')
def get(self): logging.debug("GET") self.response.headers['Content-Type'] = 'text/html' my_user = utilities.userKey() query = Twitter.query() tweets = query.fetch() query1 = UserInfo.query() userinfo = query1.fetch() if utilities.userLoggedIn(): if my_user is None or my_user == '': if not utilities.userExist(): utilities.newUser(utilities.currentUser()) renderpage.register(self, utilities.logoutUrl(self), my_user) else: if not utilities.userExist(): utilities.newUser(utilities.currentUser()) renderpage.profile(self, utilities.logoutUrl(self), my_user, tweets, userinfo) else: renderpage.login(self, utilities.loginUrl(self))
def post(self): logging.debug("POST") self.response.headers['Content-Type'] = 'text/html' action = self.request.get('button') if action == 'Add': my_user = utilities.userKey() username = self.request.get('username') content = self.request.get('content') uploaded_file = self.request.POST.get("file") tweets = Twitter() if content is not None or content != '': twitter_id = content twitter_key = ndb.Key(Twitter, twitter_id) get_tweets = twitter_key.get() tweets.id = content tweets.key = twitter_key tweets.username = username tweets.content = content tweets.user_id = my_user.key.id() if len(self.get_uploads()) > 0: upload = self.get_uploads()[0] blobinfo = blobstore.BlobInfo(upload.key()) filename = blobinfo.filename tweets.image_name = filename tweets.blobstore = upload.key() tweets.image_path = get_serving_url(upload.key()) tweets.put() my_user.tweets.append(twitter_key) my_user.put() self.redirect('/') elif action == 'Delete': my_user = utilities.userKey() twitter_id = self.request.get('twitter_id') twitter_key = ndb.Key(Twitter, twitter_id) if twitter_key in my_user.tweets: my_user.tweets.remove(twitter_key) my_user.put() ndb.Key(Twitter, twitter_id).delete() self.redirect('/')
def get(self): logging.debug("GET") self.response.headers['Content-Type'] = 'text/html' my_user = utilities.userKey() if utilities.userLoggedIn(): if not utilities.userExist(): utilities.newUser(utilities.currentUser()) renderpage.register(self, utilities.logoutUrl(self), my_user) else: renderpage.login(self, utilities.loginUrl(self))
def get(self): logging.debug("GET") self.response.headers['Content-Type'] = 'text/html' my_user = utilities.userKey() query = Twitter.query() data = query.fetch() url1 = blobstore.create_upload_url('/uploadhandler') if utilities.userLoggedIn(): if my_user is None or my_user == '': if not utilities.userExist(): utilities.newUser(utilities.currentUser()) renderpage.register(self, utilities.logoutUrl(self), my_user) else: if not utilities.userExist(): utilities.newUser(utilities.currentUser()) renderpage.add(self, utilities.logoutUrl(self), my_user, data, url1) else: renderpage.login(self, utilities.loginUrl(self))