def get(self): self.response.headers['Content-Type'] = 'text/html' url_string = '' url = '' collection = [] Caption = [] length = 0 userfollower = 0 userfollowing = 0 user = users.get_current_user() if user: url = users.create_logout_url(self.request.uri) url_string = 'logout' myuser_details = ndb.Key('MyUser', user.email()) myuser = myuser_details.get() if myuser == None: myuser = MyUser(id=user.email()) myuser.email_address = user.email() myuser.userId = user.nickname() welcome = 'Welcome to the application' myuser.put() collection_key = ndb.Key('post',user.email()) collection_key = collection_key.get() if collection_key != None: i = len(collection_key.photo_url) - 1 while i > -1: collection.append(collection_key.photo_url[i]) Caption.append(collection_key.caption[i]) i = i - 1 length = len(collection) collect = ndb.Key('followerfollowing',user.email()).get() if collect != None: userfollower = len(collect.follower) userfollowing = len(collect.following) else: url = users.create_login_url(self.request.uri) url_string = 'login' template_values = { 'url' : url, 'url_string' : url_string, 'user' : user, 'collection' : collection, 'Caption' : Caption, 'i' : length, 'userfollower': userfollower, 'userfollowing': userfollowing, } template = JINJA_ENVIRONMENT.get_template('login-logout.html') self.response.write(template.render(template_values))
def post(self): self.response.headers['Content-Type'] = 'text/html' url_string = '' url = '' user = users.get_current_user() if user: url = users.create_logout_url(self.request.uri) url_string = 'logout' myuser_details = ndb.Key('MyUser', user.email()) myuser = myuser_details.get() if myuser == None: myuser = MyUser(id=user.email()) myuser.email_address = user.email() myuser.userId = user.nickname() welcome = 'Welcome to the application' myuser.put() upload = self.get_uploads()[0] blobinfo = blobstore.BlobInfo(upload.key()) image_url = get_serving_url(blobinfo) caption = self.request.get('caption') collection_key = ndb.Key('post', user.email()) collection_key = collection_key.get() if collection_key == None: collection_key = post(id=user.email()) collection_key.photo_url.append(image_url) collection_key.email_address = user.email() collection_key.caption.append(caption) else: collection_key.photo_url.append(image_url) collection_key.email_address = user.email() collection_key.caption.append(caption) collection_key.put() self.redirect('/') else: url = users.create_login_url(self.request.uri) url_string = 'login' self.redirect('/') template_values = { 'url': url, 'url_string': url_string, 'user': user, 'collection_key': collection_key, } template = JINJA_ENVIRONMENT.get_template('photocomment.html') self.response.write(template.render(template_values))
def get(self): self.response.headers['Content-Type'] = 'text/html' url_string = '' url = '' user = users.get_current_user() if user: url = users.create_logout_url(self.request.uri) url_string = 'logout' myuser_details = ndb.Key('MyUser', user.email()) myuser = myuser_details.get() if myuser == None: myuser = MyUser(id=user.email()) myuser.email_address = user.email() myuser.userId = user.nickname() welcome = 'Welcome to the application' myuser.put() else: url = users.create_login_url(self.request.uri) url_string = 'login' self.redirect('/') Raw_Data = MyUser.query() Search_KeyWord = self.request.get('search') Result = [] Found = Raw_Data.filter(MyUser.email_address == Search_KeyWord).fetch() if Found == []: Found = Raw_Data.filter(MyUser.userId == Search_KeyWord).fetch() if Found == []: Raw_Data = Raw_Data.fetch() for i in range(0,len(Raw_Data)): if Raw_Data[i].email_address.find(Search_KeyWord) != -1: Result.append(Raw_Data[i].email_address) elif Raw_Data[i].userId.find(Search_KeyWord) != -1: Result.append(Raw_Data[i].email_address) else: Result.append(Found[0].email_address) else: Result.append(Found[0].email_address) template_values = { 'url' : url, 'url_string' : url_string, 'user' : user, 'Result' : Result, } template = JINJA_ENVIRONMENT.get_template('search.html') self.response.write(template.render(template_values))
def get(self): self.response.headers['Content-Type'] = 'text/html' url_string = '' url = '' userfollower = 0 userfollowing = 0 newfollower = "" user = users.get_current_user() if user: email = self.request.get('email_address') if email == "": email = user.email() url = users.create_logout_url(self.request.uri) url_string = 'logout' myuser_details = ndb.Key('MyUser', user.email()) myuser = myuser_details.get() if myuser == None: myuser = MyUser(id=user.email()) myuser.email_address = user.email() myuser.userId = user.nickname() welcome = 'Welcome to the application' myuser.put() collect = ndb.Key('followerfollowing', email).get() if collect != None: if collect.following != None: newfollower = collect.follower else: newfollower = [] else: newfollower = [] else: url = users.create_login_url(self.request.uri) url_string = 'login' self.redirect('/') template_values = { 'url': url, 'url_string': url_string, 'user': user, 'userfollower': userfollower, 'userfollowing': userfollowing, 'newfollower': newfollower, } template = JINJA_ENVIRONMENT.get_template('follower.html') self.response.write(template.render(template_values))
def get(self): self.response.headers['Content-Type'] = 'text/html' url_string = '' url = '' collection_key = [] user = users.get_current_user() upload_url = "" if user: url = users.create_logout_url(self.request.uri) url_string = 'logout' myuser_details = ndb.Key('MyUser', user.email()) myuser = myuser_details.get() upload_url = blobstore.create_upload_url('/photocomment') if myuser == None: myuser = MyUser(id=user.email()) myuser.email_address = user.email() myuser.userId = user.nickname() welcome = 'Welcome to the application' myuser.put() collection_key = ndb.Key('post', user.email()) collection_key = collection_key.get() if collection_key == None: collection_key = post(id=user.email()) collection_key.put() else: url = users.create_login_url(self.request.uri) url_string = 'login' self.redirect('/') template_values = { 'url': url, 'url_string': url_string, 'user': user, 'collection_key': collection_key, 'upload_url': upload_url, } template = JINJA_ENVIRONMENT.get_template('photocomment.html') self.response.write(template.render(template_values))
def get(self): self.response.headers['Content-Type'] = 'text/html' url_string = '' url = '' collection = [] Caption = [] length = 0 userfollower = 0 userfollowing = 0 userfollower1 = 0 userfollowing1 = 0 newEmail = self.request.get('email_address') newUsers = ndb.Key('MyUser',newEmail).get() user = users.get_current_user() followDecission = "False" if user: url = users.create_logout_url(self.request.uri) url_string = 'logout' myuser_details = ndb.Key('MyUser', user.email()) myuser = myuser_details.get() if myuser == None: myuser = MyUser(id=user.email()) myuser.email_address = user.email() myuser.userId = user.nickname() welcome = 'Welcome to the application' myuser.put() collection_key = ndb.Key('post',newUsers.userId) collection_key = collection_key.get() if collection_key != None: i = len(collection_key.photo_url) - 1 while i > -1: collection.append(collection_key.photo_url[i]) Caption.append(collection_key.caption[i]) i = i - 1 length = len(collection) newUserFFList = ndb.Key('followerfollowing',newEmail).get() if newUserFFList != None: userfollower = len(newUserFFList.follower) userfollowing = len(newUserFFList.following) oldUsersEmail = myuser.email_address collect = ndb.Key('followerfollowing',oldUsersEmail).get() if collect != None: for i in collect.following: if i == newEmail: followDecission = 'True' break else: url = users.create_login_url(self.request.uri) url_string = 'login' self.redirect('/') template_values = { 'url' : url, 'url_string' : url_string, 'user' : user, 'collection' : collection, 'Caption' : Caption, 'length' : length, 'newUsers' : newUsers, 'newEmail' : newEmail, 'userfollower': userfollower, 'userfollowing': userfollowing, 'userfollower1': userfollower1, 'userfollowing1': userfollowing1, 'followDecission' : followDecission, } template = JINJA_ENVIRONMENT.get_template('newUsers.html') self.response.write(template.render(template_values))