Ejemplo n.º 1
0
def view(request, urlid):
    data = []
    logging.debug('View ChannelUrl %s' % (urlid))
    try:
        urlid = int(urlid)
    except:
        pass
    channelurl = ChannelUrl.get_by_id(urlid)
    if channelurl:
        channel = channelurl.channel.get()
        url = channelurl.url.get()

        if channel.private == False:
            extras = Extra.query(Extra.channelurl == channelurl.key)
            rates = Rate.query(Rate.channelurl == channelurl.key)
            rating = channelurl.rating()
            #data.append({'channel':channel,'post':post,'url':url,'extras': extras})
            data = {
                'channel': channel,
                'post': post,
                'url': url,
                'extras': extras,
                'rates': rates,
                'rating': rating
            }

    template_values = {
        'data': data,
    }
    return render_to_response('url.html', template_values)
Ejemplo n.º 2
0
  try:
    id=int(id)
    if id<1000:
      id=DEFAULT_COUNTER_NAME+str(id)
      #logging.debug('%s' % id)
  except:
    pattern1 = r'^[A-Z]{1}$'
    pattern2 = r'^[A-Z]{2}$'
    if re.match(pattern1,id):
      id=DEFAULT_COUNTER_NAME[0]+str(id)
      #logging.debug('%s' % id)
      id=id+str(counter.get_count(id))
      #logging.debug('%s' % id)
    elif re.match(pattern2,id):
      id=id+str(counter.get_count(id))
  channelurl=ChannelUrl.get_by_id(id)
  if channelurl:
    url=channelurl.url.get().url
    url_title=channelurl.url.get().title
    rate=channelurl.rating()
    extra=channelurl.extras(plain='True')
    posts=channelurl.posts()
    channel=channelurl.channel.get().name
  
    retval=simplejson.dumps({'id':channelurl.key.id(),'url':url,'title': url_title,'rate':rate,'extra':extra,'posts':posts})
  else:
    retval=simplejson.dumps({'id':0})
  return HttpResponse(retval, mimetype="application/json")
  

def find(request):