Example #1
0
def load_template_source(template_name, template_dirs=None):

    display_name = "db:%s:%s:%s" % ("webatat", template_name, settings.DOMAIN)

    try:
        key_name = Template.key_from(website=settings.DOMAIN, name=template_name)
        template = Template.get_by_key_name(key_name)

        return (template.content, display_name)
        # return (key_name, template_name)
    except:
        pass
    raise TemplateDoesNotExist(template_name)
Example #2
0
def admin_delete_template(request, website, name):
  mainmenu = Widget.get_by_key_name(admin_menu_key_name)
  pk = Template.key_from(website=website,name=name)
  if request.POST:	
    try:
      t = Template.get_by_key_name(pk)
      t.delete()
    except exception.NoWidgetToDelete:
      return None

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

  t = loader.get_template('administration/templates/form_template_delete.html')
  c = RequestContext(request, locals())
  return HttpResponse(t.render(c));
Example #3
0
def admin_update_templates(request):
  mainmenu = Widget.get_by_key_name(admin_menu_key_name)
  templates = Template.all()
  action = "update"
    
  t = loader.get_template('administration/templates/form_template.html')
  c = RequestContext(request, locals())

  return HttpResponse(t.render(c));
Example #4
0
def admin_update_template(request, website, name):
  mainmenu = Widget.get_by_key_name(admin_menu_key_name)
  templates = Template.all()
  action = "update"
  pk = Template.key_from(website=website,name=name)
  t = Template.get_by_key_name(pk)
  name = t.name
  website = t.website
  content = t.content
  

  if request.POST:     
     
     content = request.POST.get('content')
     #content = content.replace('\r' ,'').replace('\n' ,'')
    
     t.content = content
     t.put()
    
  t = loader.get_template('administration/templates/form_template.html')
  c = RequestContext(request, locals())

  return HttpResponse(t.render(c));
Example #5
0
def admin_add_template(request):
  mainmenu = Widget.get_by_key_name(admin_menu_key_name)

  action = "add"

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

     key_name = Template.key_from(website=website,name=name)
     template = Template(key_name = key_name)
     template.name = name
     template.website = website
     template.content = content
     template.put()
    
  t = loader.get_template('administration/templates/form_template.html')
  c = RequestContext(request, locals())

  return HttpResponse(t.render(c));