Ejemplo n.º 1
0
Archivo: main.py Proyecto: zoyoe/ectool
def items(request,shop,category):
  stories = getCategoriesInfo()
  lvl1 = "Category"
  lvl2 = "Gallery"
  if (shop in stories):
    for c in stories[shop]:
      if (category in stories[shop][c]['children']):
        lvl1 = stories[shop][c]['name']
        lvl2 = stories[shop][c]['children'][category]['name']
  else:
    return error.ZoyoeError("category does not exist")
  dict = {'SHOP':shop,'ITEM_WIDTH':'200','STORIES':stories,'PATH':lvl1,'CATEGORY':lvl2}
  query = getCategoryItems(category).filter("disable ==",False)
  myPagedQuery = PagedQuery(query, 12)
  items = []
  dict['queryurlprev'] = "#" 
  dict['queryurlnext'] = "#" 
  total = myPagedQuery.page_count()
  dict['pages'] = range(1,total+1)
  idx = 0
  if ('page' in request.GET):
    idx = int(request.GET['page'])
    items = myPagedQuery.fetch_page(int(request.GET['page']))
  else:
    items = myPagedQuery.fetch_page()
  if (idx != 0):
    dict['queryurlprev'] = "/items/"+shop+"/"+category +"/?page="+str(idx-1)
  if (idx < dict['pages']):
    dict['queryurlnext'] = "/items/"+shop+"/"+category +"/?page="+str(idx+1)
  dict['sellitems'] = items
  dict['queryurl'] = "/items/"+shop+"/"+category
  context = Context(dict)
  temp_path = getSiteInfo().gettemplate("products.html");
  return (render_to_response(temp_path,context,context_instance=RequestContext(request)))
Ejemplo n.º 2
0
def preference(request):
    context = {}
    context['CATEGORIES'] = ShopInfo.all().filter("type =",
                                                  "category").order("name")
    context['SITEINFO'] = retailtype.getSiteInfo()
    return (render_to_response("config/preferences.html",
                               context,
                               context_instance=RequestContext(request)))
Ejemplo n.º 3
0
def configsite(attr, content):
    siteinfo = retailtype.getSiteInfo()
    keys = siteinfo.__dict__
    properties = siteinfo.properties()
    if (attr in properties):
        model = properties.get(attr)
        if isinstance(model, db.StringProperty):
            setattr(siteinfo, attr, content)
        elif isinstance(model, db.BooleanProperty):
            setattr(siteinfo, attr, (False, True)[content == "True"])
        elif isinstance(model, db.TextProperty):
            setattr(siteinfo, attr, content)
        else:
            pass
    siteinfo.put()
Ejemplo n.º 4
0
def configsite(attr,content):
  siteinfo = retailtype.getSiteInfo()
  keys = siteinfo.__dict__
  properties = siteinfo.properties()
  if (attr in properties):
     model = properties.get(attr)
     if isinstance(model, db.StringProperty):
       setattr(siteinfo,attr,content)
     elif isinstance(model,db.BooleanProperty):
       setattr(siteinfo,attr,(False,True)[content == "True"])
     elif isinstance(model,db.TextProperty):
       setattr(siteinfo,attr,content)
     else: 
       pass
  siteinfo.put()
Ejemplo n.º 5
0
def items(request, shop, category):
    stories = getCategoriesInfo()
    lvl1 = "Category"
    lvl2 = "Gallery"
    if (shop in stories):
        for c in stories[shop]:
            if (category in stories[shop][c]['children']):
                lvl1 = stories[shop][c]['name']
                lvl2 = stories[shop][c]['children'][category]['name']
    else:
        return error.ZoyoeError("category does not exist")
    dict = {
        'SHOP': shop,
        'ITEM_WIDTH': '200',
        'STORIES': stories,
        'PATH': lvl1,
        'CATEGORY': lvl2
    }
    query = getCategoryItems(category).filter("disable ==", False)
    myPagedQuery = PagedQuery(query, 12)
    items = []
    dict['queryurlprev'] = "#"
    dict['queryurlnext'] = "#"
    total = myPagedQuery.page_count()
    dict['pages'] = range(1, total + 1)
    idx = 0
    if ('page' in request.GET):
        idx = int(request.GET['page'])
        items = myPagedQuery.fetch_page(int(request.GET['page']))
    else:
        items = myPagedQuery.fetch_page()
    if (idx != 0):
        dict[
            'queryurlprev'] = "/items/" + shop + "/" + category + "/?page=" + str(
                idx - 1)
    if (idx < dict['pages']):
        dict[
            'queryurlnext'] = "/items/" + shop + "/" + category + "/?page=" + str(
                idx + 1)
    dict['sellitems'] = items
    dict['queryurl'] = "/items/" + shop + "/" + category
    context = Context(dict)
    temp_path = getSiteInfo().gettemplate("products.html")
    return (render_to_response(temp_path,
                               context,
                               context_instance=RequestContext(request)))
Ejemplo n.º 6
0
Archivo: main.py Proyecto: zoyoe/ectool
def main(request):
  if (request.META['HTTP_HOST']=="www.zoyoe.com"):
    # This is the main website
    stories = getCategoriesInfo()
    fliers = ShopInfo.all().filter("type =","category").order("name")
    context = Context({'STORIES':stories,'FLIERS':fliers})
    return (render_to_response("zoyoe/index.html",context,context_instance=RequestContext(request)))
  else:
    # This is customer's website
    site = getSiteInfo()
    if site:
      if site.published:
        return retail(request)
      else:
        return HttpResponseRedirect('/admin/')
    else:
      return HttpResponseRedirect('/admin/config/preference/')
Ejemplo n.º 7
0
def main(request):
    if (request.META['HTTP_HOST'] == "www.zoyoe.com"):
        # This is the main website
        stories = getCategoriesInfo()
        fliers = ShopInfo.all().filter("type =", "category").order("name")
        context = Context({'STORIES': stories, 'FLIERS': fliers})
        return (render_to_response("zoyoe/index.html",
                                   context,
                                   context_instance=RequestContext(request)))
    else:
        # This is customer's website
        site = getSiteInfo()
        if site:
            if site.published:
                return retail(request)
            else:
                return HttpResponseRedirect('/admin/')
        else:
            return HttpResponseRedirect('/admin/config/preference/')
Ejemplo n.º 8
0
def preference(request):
  context = {}
  context['CATEGORIES'] = ShopInfo.all().filter("type =","category").order("name")
  context['SITEINFO'] = retailtype.getSiteInfo()
  return (render_to_response("config/preferences.html",context,context_instance=RequestContext(request)))