def post(self): # Variables form = self.request.get('submitType') title = None content = None exp = self.request.cookies.get('expire') logging.info(exp) if (exp != None): valid = CookieManager.checkCookie(exp) else: valid = 0 if form == 'submitPost': title = self.request.get('title') content = self.request.get('content') # Instantiate Blog class postObject = Post.Post() # Insert the attributes to data store postObject.insertToDatastore(title, content) # Loads the page template_values = { 'valid': valid, } template = JINJA_ENVIRONMENT.get_template('/admin/dashboard.html') self.response.write(template.render(template_values))
def get(self): # Check cookie exp = self.request.cookies.get('expire') logging.info(exp) if (exp != None): valid = CookieManager.checkCookie(exp) else: valid = 0 saranObject = Saran.Saran() # Get Delete ID deleteID = self.request.get('deleteid') # Delete Saran with Proper ID if (deleteID != ''): saranObject.deleteSaran(deleteID) source = 'saran' # When the page first loads, null template template_values = { 'valid': valid, 'source': source, } template = JINJA_ENVIRONMENT.get_template('/redirect.html') self.response.write(template.render(template_values))
def get(self): # Cookie check exp = self.request.cookies.get('expire') logging.info(exp) if (exp != None): valid = CookieManager.checkCookie(exp) else: valid = 0 # Define variables saranObject = Saran.Saran() listSaran2 = saranObject.listSaran() count = len(listSaran2) # List saranIDList = [] nameList = [] emailList = [] contentList = [] datetimeList = [] # Timezone convertion # Set timezone jkt = timezone('Asia/Jakarta') utc = timezone('UTC') # For post in posts ... for saran in listSaran2: # Convert timezone utc_dt = utc.localize(saran.date) jkt_dt = utc_dt.astimezone(jkt) content = saran.isi if (len(content) > 50): content = content[:50] + "..." # Insert to list nameList.append(saran.nama) emailList.append(saran.email) contentList.append(content) datetimeList.append(jkt_dt.strftime("%d-%m-%Y %H:%M:%S")) saranIDList.append(saran.key.id()) # Loads the page template_values = { 'valid': valid, 'count': count, 'nameList': nameList, 'emailList': emailList, 'contentList': contentList, 'datetimeList': datetimeList, 'saranIDList': saranIDList, } template = JINJA_ENVIRONMENT.get_template('/admin/kotak-saran.html') self.response.write(template.render(template_values))
def get(self): # Cookie check exp = self.request.cookies.get('expire') logging.info(exp) if (exp != None): valid = CookieManager.checkCookie(exp) else: valid = 0 # Define variables postObject = Post.Post() posts = postObject.listPosts() count = len(posts) # List postIDList = [] titleList = [] contentList = [] datetimeList = [] # Timezone convertion # Set timezone jkt = timezone('Asia/Jakarta') utc = timezone('UTC') # For post in posts ... for post in posts: # Convert timezone utc_dt = utc.localize(post.date) jkt_dt = utc_dt.astimezone(jkt) content = post.content if (len(content) > 50): content = content[:50] + "..." # Insert to list titleList.append(post.title) contentList.append(content) datetimeList.append(jkt_dt.strftime("%d-%m-%Y %H:%M:%S")) postIDList.append(post.key.id()) # Loads the page template_values = { 'valid': valid, 'count': count, 'titleList': titleList, 'contentList': contentList, 'datetimeList': datetimeList, 'postIDList': postIDList, } template = JINJA_ENVIRONMENT.get_template('/admin/post-menu.html') self.response.write(template.render(template_values))
def get(self): exp = self.request.cookies.get('expire') logging.info(exp) if (exp != None): valid = CookieManager.checkCookie(exp) else: valid = 0 # Loads the page template_values = { 'valid': valid, } template = JINJA_ENVIRONMENT.get_template('/admin/dashboard.html') self.response.write(template.render(template_values))
def get(self): # Check cookie exp = self.request.cookies.get('expire') logging.info(exp) if (exp != None): valid = CookieManager.checkCookie(exp) else: valid = 0 postObject = Post.Post() # Get Delete ID deleteID = self.request.get('deleteid') # Get Edit ID editID = self.request.get('editid') # Delete Post with Proper ID if (deleteID != ''): postObject.deletePost(deleteID) source = 'post' # When the page first loads, null template template_values = { 'valid': valid, 'source': source, } template = JINJA_ENVIRONMENT.get_template('/redirect.html') self.response.write(template.render(template_values)) elif (editID != ''): post = postObject.getPost(editID) # Loads edit page template_values = { 'valid': valid, 'editID': editID, 'post': post, } template = JINJA_ENVIRONMENT.get_template('/admin/edit-menu.html') self.response.write(template.render(template_values))