Example #1
0
def review(request):
	if request.method=='POST':
		link=Link.get_by_id(int(request.POST['id']))
		link.status=request.POST['action']
		link.put()

	approved_links=Link.all().filter('status =', 'approved')
	submitted_links=Link.all().filter('status =', 'submitted')
	return(render_to_response('links/review.html', locals(), context_instance=RequestContext(request)))
Example #2
0
def review(request):
    if request.method == 'POST':
        link = Link.get_by_id(int(request.POST['id']))
        link.status = request.POST['action']
        link.put()

    approved_links = Link.all().filter('status =', 'approved')
    submitted_links = Link.all().filter('status =', 'submitted')
    return (render_to_response('links/review.html',
                               locals(),
                               context_instance=RequestContext(request)))
Example #3
0
def shorten(url, title, size):
    q = Link.all()
    q.filter("url =", url)
    urls = q.fetch(1)
    if (len(urls) > 0):
        return urls[0].short_url()
    newLink = Link(url = url, title = title, size = size)
    newLink.save()
    return newLink.short_url()
Example #4
0
 def get(self):
     if users.get_current_user():
         links = Link.all().filter("author =", users.get_current_user()).order("-date").fetch(100)
         self.response.out.write("<ul>")
         for link in links:
             if link and link.content:
                 self.response.out.write("<li><a href=\"" + urllib2.unquote(link.content) + "\">" + urllib2.unquote(link.content)+ "</li>")
         self.response.out.write("</ul>")
     else:
         self.redirect(users.create_login_url("/links/all"))
Example #5
0
    def get(self, hash):
        l = memcache.get(hash)
        if l:
            l.hits += 1
            l.put()
        else:
            l = Link.all().filter("hash =", hash).get()

        memcache.set(str(l.hash), l)
        self.redirect("%s" % str(l.url))
Example #6
0
 def get(self, **kwargs):
   preset        = {'prop_operation_id':str(Property._OPER_SELL)}
   direct_links  = Link.all().filter('type = ', 'home').fetch(25)
   return self.render_response('frontend/home.html'
               , config_array    = config_array
               , preset          = preset
               , presetJSON      = json.dumps(preset)
               , _OPER_SELL      = Property._OPER_SELL
               , _OPER_RENT      = Property._OPER_RENT
               , direct_links    = direct_links)
 def get(self):
     if users.get_current_user():
         links = Link.all().filter("author =", users.get_current_user()).order("-date").fetch(100)
         self.response.out.write("<ul>")
         for link in links:
             if link and link.content:
                 self.response.out.write("<li><a href=\"" + urllib2.unquote(link.content) + "\">" + urllib2.unquote(link.content)+ "</li>")
         self.response.out.write("</ul>")
     else:
         self.redirect(users.create_login_url("/links/all"))
 def get(self):
     # if users.get_current_user():
     #    link = Link.all().filter("author =", users.get_current_user()).order("-date").get()
     #    if link and link.content:
     #        self.response.out.write("<link>" + urllib2.unquote(link.content) + "</link>")
     #    else:
     #        self.response.out.write("\"\"")
     # elif oauth.get_current_user():
     if oauth.get_current_user():
         link = Link.all().filter("author =", oauth.get_current_user()).order("-date").get()
         if link and link.content:
             self.response.out.write("<link>" + urllib2.unquote(link.content) + "</link>")
         else:
             self.response.out.write('""')
     else:
         self.redirect(users.create_login_url("/links/get"))
Example #9
0
def index(year=None,month=None,day=None):

  tz = g.tz
  tz_utc = pytz.utc

  if not year or not month or not day:
  	day = datetime.now(tz_utc).astimezone(tz)
  else:
  	day = datetime(year, month, day, 0, 0, 0, tzinfo=tz)

  links = Link.all()

  day_from = datetime(day.year, day.month, day.day, 0, 0, 0, tzinfo=tz) 
  day_end = day_from + timedelta(days=1)

  links.filter("updated_at >=", day_from)
  links.filter("updated_at <", day_end)
  links.order("-updated_at")
  return render_template('index.html', links=links, view_today=day)
Example #10
0
    def get(self):
        g = self.request.get
        q = Bookmark.all()
        if g('key'):
            b = Bookmark.get(g('key'))
            if b:
                if self.has_permission_for(b):
                    self.json_output([b,])
                    return
                else:
                    self.do_error('forbidden')
            else:
                self.do_error('not-found')
        if g('tag'):
            q = q.filter('tags=', g('tag'))
        if g('tags'): #union comma sep
            q = q.filter('tags IN', g('tags').split(','))
        if g('all_tags'):
            for t in g('all_tags').split(','):
                q = q.filter('tags=', t)
        if g('link'):
            l = Link.all().filter('url=', g('link')).get()
            if l:
                q = q.filter('link=', l)
        if g('title'):
            q = q.filter('title=', g('title'))
        if g('access'):
            q = q.filter('access=', g('access'))
        if g('user'):
            q = q.filter('user='******'-created')

        try:
            limit = int(g('limit'))
        except:
            limit = 10

        results = [r for r in q.fetch(limit) if self.can_view(r)]
        self.json_output(results)
Example #11
0
    def get(self):
        #if users.get_current_user():
        #    link = Link.all().filter("author =", users.get_current_user()).order("-date").get()
        #    if link and link.content:
        #        self.response.out.write("<link>" + urllib2.unquote(link.content) + "</link>")
        #    else:
        #        self.response.out.write("\"\"")
        #elif oauth.get_current_user():
        if oauth.get_current_user():
            user = oauth.get_current_user()
            source = "memcache"
            link = memcache.get(user.user_id())
            if link is None:
                link = Link.all().filter("author =", oauth.get_current_user()).order("-date").get()
                source = "database"
            if link and link.content:
		timedelta = datetime.now() - link.date
                self.response.out.write("<link>" + urllib2.unquote(link.content) + "</link><source>" + source +"</source><age>" + str(timedelta.days) + "</age>")
            else:
                self.response.out.write("\"\"")
        else:
            self.redirect(users.create_login_url("/links/get"))
Example #12
0
    def get(self):
        if users.get_current_user():
            link = Link.all().filter("author =", users.get_current_user()).order("-date").get()
            if link and link.content:
                self.response.out.write("<link>" + urllib2.unquote(link.content) + "</link>")
            else:
                self.response.out.write("\"\"")
        #elif oauth.get_current_user():
        #if oauth.get_current_user():
        #    user = oauth.get_current_user()
        #    source = "memcache"
        #    link = memcache.get(user.user_id())
        #    if link is None:
        #       link = Link.all().filter("author =", oauth.get_current_user()).order("-date").get()
        #        source = "database"
        #    if link and link.content:
		#timedelta = datetime.now() - link.date
        #        self.response.out.write("<link>" + urllib2.unquote(link.content) + "</link><source>" + source +"</source><age>" + str(timedelta.days) + "</age>")
        #    else:
        #        self.response.out.write("\"\"")
        else:
            #self.redirect(users.create_login_url("/links/get"))
            self.response.out.write("Not logged in...")
Example #13
0
 def get_link(self, url):
     l = Link.all().filter('url =', url).get()
     if l is None:
         l = Link(url=url)
         l.put()
     return l
Example #14
0
	def get(self):
		pending_links=Link.all().filter('status =', 'submitted')
		context=dict(pending_links=pending_links)
		return self.render_response('link/review.html', **context)
Example #15
0
    def get(self):
        from models import Link

        for link in Link.all():
            link.delete()
        self.redirect('/links/')