Пример #1
0
def admin_update_flatpage(request, website, name):
  mainmenu = Widget.get_by_key_name(admin_menu_key_name)
  flatpages = FlatPage.all()
  action = "update"
  pk = FlatPage.key_from(website=website,name=name)
  f = FlatPage.get_by_key_name(pk)
  name = f.name
  title = f.title
  website = f.website
  status = f.status
  content = json.dumps(f.content, ensure_ascii=False)
  

  if request.POST:     
     
     title = request.POST.get('title')
     status = request.POST.get('status')
     content = request.POST.get('content')
     content = content.replace('\r' ,'').replace('\n' ,'')
    
     f.title = title
     f.status = int(status)
     f.content = json.loads(content)
     f.put()
    
  t = loader.get_template('administration/templates/form_flatpage.html')
  c = RequestContext(request, locals())

  return HttpResponse(t.render(c));
Пример #2
0
def admin_add_flatpage(request):
  mainmenu = Widget.get_by_key_name(admin_menu_key_name)

  action = "add"

  if request.POST:   
     name = request.POST.get('name')
     title = request.POST.get('title')
     website = request.POST.get('website')
     status = request.POST.get('status')
     content = request.POST.get('content')	

     key_name = FlatPage.key_from(website=website,name=name)
     flatpage = FlatPage(key_name = key_name)
     flatpage.title = title
     flatpage.name = name
     flatpage.website = website
     flatpage.status = int(status)
     flatpage.content = json.loads(content)
     flatpage.put()
    
  t = loader.get_template('administration/templates/form_flatpage.html')
  c = RequestContext(request, locals())

  return HttpResponse(t.render(c));
Пример #3
0
def flat_handler(request, website, name):
  # for template
  mainmenu = Widget.get_by_key_name('nawadena.com/menu/main')
  sectionmenu = Widget.get_by_key_name('nawadena.com/menu/section')
  menuItems = mainmenu.content.get('items')
  for item in menuItems:    
    if item['path'] == "/p/%(website)s/%(name)s" % {'website':website, 'name':name} :
      item['class'] = 'selected'
   
  pk = FlatPage.key_from(website=website,name=name)
  flatPage = FlatPage.get_by_key_name(pk)

  c = template.RequestContext(request, locals())  
  t = loader.get_template('flat/templates/base-flat.html')
  return http.HttpResponse(t.render(c))
Пример #4
0
def admin_delete_flatpage(request, website, name):
  mainmenu = Widget.get_by_key_name(admin_menu_key_name)
  pk = FlatPage.key_from(website=website,name=name)
  if request.POST:
    try:
      f = FlatPage.get_by_key_name(pk)
      f.delete()
    except exception.NoWidgetToDelete:
      return None

    except AttributeError:
      return HttpResponseRedirect("/_admin/update/flatpage/")
    return HttpResponseRedirect("/_admin/update/flatpage/")

  t = loader.get_template('administration/templates/form_flatpage_delete.html')
  c = RequestContext(request, locals())
  return HttpResponse(t.render(c));