Beispiel #1
0
 def get(self):
     action = self.param('action')
     if(action == ''):
         value ={'action':'?action=add'}
     elif(action=='edit'):
         key = self.param('key')
         blog = Blog.get(key)
         value={'action':'?key='+ key +'&action=edit',
                'title':blog.title,
                'content':blog.content} 
     self.generateBasePage('manage/addblog.html',value)
     return
Beispiel #2
0
 def get(self):
     action = self.param('action')
     if (action == ''):
         value = {'action': '?action=add'}
     elif (action == 'edit'):
         key = self.param('key')
         blog = Blog.get(key)
         value = {
             'action': '?key=' + key + '&action=edit',
             'title': blog.title,
             'content': blog.content
         }
     self.generateBasePage('manage/addblog.html', value)
     return
Beispiel #3
0
 def post(self):
     key = self.param('key')
     action = self.param('action')
     title1,content1 = (self.request.get(item) for item in ('title', 'content'))
     if(not title1)or(not content1):
         self.error(501,'Please input title and content .')
         return
     if(action=='add'):            
         blogEntity = Blog(title = title1, content = content1, createTimeStamp = datetime.now())
         blogEntity.publish()
         self.redirect('/')
         share2miniblog(blogEntity)
     elif(action=='edit'):
         blogEntity = Blog.get(key)
         blogEntity.title = title1
         blogEntity.content = content1
         blogEntity.put()
         self.redirect('/?p=%d'%blogEntity.blog_id)
Beispiel #4
0
 def post(self):
     key = self.param('key')
     action = self.param('action')
     title1, content1 = (self.request.get(item)
                         for item in ('title', 'content'))
     if (not title1) or (not content1):
         self.error(501, 'Please input title and content .')
         return
     if (action == 'add'):
         blogEntity = Blog(title=title1,
                           content=content1,
                           createTimeStamp=datetime.now())
         blogEntity.publish()
         self.redirect('/')
         share2miniblog(blogEntity)
     elif (action == 'edit'):
         blogEntity = Blog.get(key)
         blogEntity.title = title1
         blogEntity.content = content1
         blogEntity.put()
         self.redirect('/?p=%d' % blogEntity.blog_id)
Beispiel #5
0
    def post(self):
        if (self.isAdmin):
            name = self.blog.author
            email = self.login_user.email()
            url = self.blog.systemURL
        else:
            name = self.param('author')
            email = self.param('email')
            url = self.param('url')
        key = self.param('key')
        content = self.param('comment')
        if (name and content):
            ##should be removed when deploy to real site
            content = content.decode('utf8')
            name = name.decode('utf8')
            ##should be removed when deploy to real site
            comment = Comment(author=name,
                              content=content,
                              authorEmail=email,
                              authorURL=url,
                              ownerBlog=Blog.get(key))
            comment.save()
            date = comment.commentTime.strftime("%Y-%m-%d")
            time = comment.commentTime.strftime("%H:%M")
            commentData = {
                'author': comment.author,
                'id': comment.key().id(),
                'url': comment.authorURL,
                'date': date,
                'time': time
            }
            self.response.headers['Content-Type'] = 'text/plain; charset=utf-8'

            self.response.out.write(simplejson.dumps(commentData))
        # self.redirect(Blog.get(key).selfLink)
        else:
            self.error(501, 'Please input name and comment .')