def get(self): global blog global comment user = users.get_current_user() if user : usermail = user.email() thisuser = BloggerDB.query(BloggerDB.email==usermail,BloggerDB.status == 'active').get() if thisuser > 0 : regblogger = 1 if thisuser.privilege == 'admin': blogset = BlogDB.query() elif thisuser.privilege == 'user': blogset = BlogDB.query(BlogDB.blogger == thisuser.username) else: blogset = [] template_values = { 'blogset':blogset, 'regblogger':regblogger, } notification = self.request.get('notification') if notification: template_values['notification'] = notification self.response.set_status(200) template = jinja2_env.get_template('templates/blogs.html') self.response.out.write(template.render(template_values)) else: self.redirect('/') else: self.redirect(users.create_login_url(self.request.uri))
def get(self): blog = [] user = users.get_current_user() if user : usermail = user.email() thisuser = BloggerDB.query(BloggerDB.email==usermail,BloggerDB.status == 'active').get() if thisuser > 0: regblogger = 1 blog = BlogDB.query(BlogDB.blogger == thisuser.username) image = ImageDB.query() video = VideoDB.query() template_values = { 'regblogger':regblogger, 'blog':blog, 'image':image, 'video':video } notification = self.request.get('notification') if notification: template_values['notification'] = notification self.response.set_status(200) template = jinja2_env.get_template('templates/gallery.html') self.response.out.write(template.render(template_values)) else: self.redirect('/') else: self.redirect(users.create_login_url(self.request.uri))
def post(self): if users.get_current_user(): publish = self.request.get('publish') deactivate = self.request.get('deactivate') error = self.request.get('error') blog_ = BlogDB.query() if publish != '': for b in blog_: if b.title == publish: b.status = 'active' b.put() if deactivate != '': for b in blog_: if b.title == deactivate: b.status = 'deactive' b.put() if error != '': for b in blog_: if b.title == error: b.status = 'deactive' b.put() self.redirect('/blogs') else: self.redirect(users.create_login_url(self.request.uri))
def post(self): if users.get_current_user(): usermail = users.get_current_user().email() thisuser = BloggerDB.query(BloggerDB.email==usermail,BloggerDB.status=='active').get() if thisuser: title = self.request.get('title') image = self.request.get('image') content = self.request.get('content') id = self.request.get('id') slug = slugify(title) blog = BlogDB.get_by_id(int(id)) blog.title = title blog.image = image blog.content = content blog.slug = slug blog.put() self.redirect('/edit') else: self.redirect('/') else: self.redirect(users.create_login_url(self.request.uri))
def post(self): if users.get_current_user(): usermail = users.get_current_user().email() thisuser = BloggerDB.query(BloggerDB.email==usermail,BloggerDB.status=='active').get() if thisuser: null = 'null' title = str(self.request.get('title',null)) image = str(self.request.get('image',null)) content = self.request.get('content',null) blogger_ = thisuser.username if title == "": title = str(null) if content == "": content = str(null) slug = slugify(title) newblog = BlogDB( blogger = blogger_, title = title, image = image, content = content, slug = slug ) newblog.put() subscribers = newsletterDB.query() for sub in subscribers: submail = sub.email name = sub.name dom = 'http://muthonithrives.com/blog?title=' link = str(dom+slug) newslettermail(submail,name, title, blogger_,link) self.redirect('/new') self.redirect('/') else: self.redirect(users.create_login_url(self.request.uri))
def get(self): if users.get_current_user(): usermail = users.get_current_user().email() thisuser = BloggerDB.query(BloggerDB.email==usermail,BloggerDB.status=='active').get() if thisuser: global blog global comment blogedit = [] myblogs2edit = [] regblogger = 1 id = self.request.get('id') myblog = BlogDB.query(BlogDB.blogger == thisuser.username) for b in myblog: myblogs2edit.append(b) if id !="": be = BlogDB.get_by_id(int(id)) blogedit.append(be) template_values = { 'regblogger':regblogger, 'blogs2edit':myblogs2edit, 'blogedit':blogedit } notification = self.request.get('notification') if notification: template_values['notification'] = notification self.response.set_status(200) template = jinja2_env.get_template('templates/edit.html') self.response.out.write(template.render(template_values)) else: self.redirect('/') else: self.redirect(users.create_login_url(self.request.uri))
def get(self): global blog global comment global blogsl try: regblogger = 0 blog = BlogDB.query(BlogDB.status == 'active') bl = blog.get() slug = self.request.get('title',bl.slug) comment = [] video = VideoDB.query() image = ImageDB.query() blogsl = BlogDB.query(BlogDB.status == 'active',BlogDB.slug == slug).get() slid = str(blogsl.key.id()) if blogsl: comment = CommentDB.query(CommentDB.blogid == slid) except Exception as e: self.redirect('/') template_values = { 'regblogger':regblogger, 'video':video, 'image':image, 'blog':blog, 'blogsl':blogsl, 'comment':comment } notification = self.request.get('notification') if notification: template_values['notification'] = notification self.response.set_status(200) template = jinja2_env.get_template('templates/myblog.html') self.response.out.write(template.render(template_values))
def get(self): global blog global comment regblogger = 0 blog = BlogDB.query(BlogDB.status == 'active').order(-BlogDB.date) comment = CommentDB.query().order(-CommentDB.date) image = ImageDB.query() template_values = { 'image':image, 'blog':blog, 'comment':comment, 'regblogger':regblogger } notification = self.request.get('notification') if notification: template_values['notification'] = notification self.response.set_status(200) template = jinja2_env.get_template('templates/contact.html') self.response.out.write(template.render(template_values))