示例#1
0
 def post(self, post_id=None, **kwargs):
     """Handle submitted form data"""
     # validate form
     if self.form.validate():
         title = self.form.title.data
         lead = self.form.lead.data
         content = self.form.content.data
         live = self.form.live.data
         tags = self.form.tags.data
         language = self.form.language.data
         if tags is not None:
             tags = [tag.strip() for tag in tags.split(',') if tag != '']
         # saving edited
         if post_id:
             post = BlogPost.get_by_id(post_id)
             post.title = title
             post.lead = lead
             post.content = content
             post.live = live
             post.tags = tags
             post.language = language
         # creating new
         else:
             post = BlogPost(title=title,
                             lead=lead,
                             content=content,
                             live=live,
                             tags=tags,
                             language=language)
         if post.put():
             return redirect('admin/blog')
     return self.get(**kwargs)
示例#2
0
 def post(self, post_id=None, **kwargs):
     """Handle submitted form data"""
     # validate form
     if self.form.validate():
         title = self.form.title.data
         lead = self.form.lead.data
         content = self.form.content.data
         live = self.form.live.data
         tags = self.form.tags.data
         language = self.form.language.data
         if tags is not None:
             tags = [tag.strip() for tag in tags.split(',') if tag != '']
         # saving edited
         if post_id:
             post = BlogPost.get_by_id(post_id)
             post.title = title
             post.lead = lead
             post.content = content
             post.live = live
             post.tags = tags
             post.language = language
         # creating new
         else:
             post = BlogPost(title=title, lead=lead, content=content, live=live, tags=tags, language=language)
         if post.put():
             return redirect('admin/blog')
     return self.get(**kwargs)
示例#3
0
 def get(self, tag=None, **kwargs):
     language = self.get_locale()
     if tag is None:
         posts = BlogPost.get_latest_posts(10, language=language)
     else:
         posts = BlogPost.get_posts_by_tag(tag, language=language)
     context = {'posts': posts, 'tag': tag}
     return render_response('feed/blog.xml', **context)
示例#4
0
 def get(self, tag=None, **kwargs):
     language = self.get_locale()
     if tag is None:
         posts = BlogPost.get_latest_posts(10, language=language)
     else:
         posts = BlogPost.get_posts_by_tag(tag, language=language)
     context = {
         'posts': posts,
         'tag': tag
     }
     return render_response('feed/blog.xml', **context)
示例#5
0
 def get(self, **kwargs):
     posts = BlogPost.all().order('-modified')
     result = posts.fetch(10)
     context = {
         'posts': result,
     }
     return self.render_response('admin/blog/index.html', **context)
示例#6
0
 def get(self, **kwargs):
     posts = BlogPost.all().order('-modified')
     result = posts.fetch(10)
     context = {
         'posts': result,
     }
     return self.render_response('admin/blog/index.html', **context)
示例#7
0
 def get(self, **kwargs):
     language = self.get_locale()
     products = Product.get_latest_products(3, language=language)
     posts = BlogPost.get_latest_posts(5, language=language)
     context = {
         'products': products,
         'posts': posts,
         'language': language,
     }
     return self.render_response('pages/welcome.html', **context)
示例#8
0
 def get(self, **kwargs):
     language = self.get_locale()
     products = Product.get_latest_products(3, language=language)
     posts = BlogPost.get_latest_posts(5, language=language)
     context = {
         'products': products,
         'posts': posts,
         'language': language,
     }
     return self.render_response('pages/welcome.html', **context)
示例#9
0
 def get(self, **kwargs):
     language = self.get_locale()
     product = Product.get_promoted_product(language=language)
     posts = BlogPost.get_latest_posts(5, language=language)
     offer = Offer.get_latest_offer(language=language)
     context = {
         'product': product,
         'posts': posts,
         'offer': offer,
         'format_currency': i18n.format_currency,
         'language': language,
     }
     return self.render_response('pages/welcome.html', **context)
示例#10
0
 def get(self, post_id=None, **kwargs):
     """Return a post to edit or an empty form to create"""
     template = 'admin/blog/new.html'
     context = {
         'form': self.form,
     }
     # render edit
     if post_id is not None:
         post = BlogPost.get_by_id(post_id)
         if post:
             self.form = BlogPostForm(obj=post)
             self.form.tags.data = ', '.join(post.tags)
             context.update({ 'form': self.form })
             template = 'admin/blog/edit.html'
         else:
             return redirect('admin/blog/')
     # render new
     return self.render_response(template, **context)
示例#11
0
 def get(self, post_id=None, **kwargs):
     """Return a post to edit or an empty form to create"""
     template = 'admin/blog/new.html'
     context = {
         'form': self.form,
     }
     # render edit
     if post_id is not None:
         post = BlogPost.get_by_id(post_id)
         if post:
             self.form = BlogPostForm(obj=post)
             self.form.tags.data = ', '.join(post.tags)
             context.update({'form': self.form})
             template = 'admin/blog/edit.html'
         else:
             return redirect('admin/blog/')
     # render new
     return self.render_response(template, **context)