Example #1
0
 def POST(self, name, action='view'):
     self.init_data(name, action)
     form = self.form_class()
     if form.validates():
         active = True if form.get('active').value else False
         if not self.content:
             static_data = Static(position=int(form.get('position').value),
                                  name=form.get('name').value.lstrip('/'),
                                  label=form.get('label').value,
                                  title=form.get('title').value,
                                  content=form.get('content').value,
                                  active=active,)
         else:
             self.content.position=int(form.get('position').value)
             self.content.name=form.get('name').value.lstrip('/')
             self.content.label=form.get('label').value
             self.content.title=form.get('title').value
             self.content.content=form.get('content').value
             self.content.active=active
             static_data = self.content
         static_data.put()
         return web.seeother('/'+static_data.name, absolute=True)
     context['form'] = form
     return render_template('static_content.html', **context)
Example #2
0
 def init_data(self, name, action):
     self.content = Static.all().filter('name =', name).get()
     self.form_class = static_form
     form = self.form_class()
     if not self.content or action == 'edit':
         if not context['google_accounts'].get_current_user():
             raise web.notfound()
         context['form'] = form()
         context['add_or_edit'] = True
     else:
         context['add_or_edit'] = False
         context['content'] = self.content
     context['page_path'] = '/'+name
     if action == 'edit':
         form = form()
         form.get('position').value = self.content.position
         form.get('name').value = self.content.name
         form.get('label').value = self.content.label
         form.get('title').value = self.content.title
         form.get('content').value = self.content.content
         form.get('active').value=self.content.active
         context['form'] = form
Example #3
0
def default_loadhook():
    web.google_accounts = users
    context['google_accounts'] = users
    
    context['static_pages'] = Static.all().filter('position <', 15)\
        .filter('active =', True).order('position')