Пример #1
0
		def login():
			if request.method == "GET":
				return render_template('index.html',user = self.user, posts = Post.all())
			if request.method == "POST":
				mail = request.form['mail']
				password = request.form['password']
				self.user = User.load(mail, password)
			return render_template('index.html',user = self.user, posts = Post.all())
Пример #2
0
 def get(self):
     posts = Post.all().order('-created')
 	
     if self.user:
        self.render('front.html', posts = posts,username = self.user.name)
     else:
         self.render('front.html', posts = posts)
Пример #3
0
 def get(self):
     if self.read_secure_cookie('user_id'):
         posts = Post.all().order('-created')
         user = User.by_id(self.read_secure_cookie('user_id'))
         self.render('home.html',posts = posts, user = user)
     else:
         self.redirect('/')
Пример #4
0
    def get(self):
        posts = Post.all().order('-created')

        if self.user:
            self.render('front.html', posts=posts, username=self.user.name)
        else:
            self.render('front.html', posts=posts)
Пример #5
0
 def get(self):
     """
         This renders home page with all posts, sorted by date.
     """
     deleted_post_id = self.request.get('deleted_post_id')
     posts = greetings = Post.all().order('-created')
     self.render('front.html', posts=posts, deleted_post_id=deleted_post_id)
    def get(self):
        """
            This renders home page with all posts, sorted by date.
        """

        deleted_post_id = self.request.get('deleted_post_id')
        posts = greetings = Post.all().order('-created')
        self.render('welcome.html', posts=posts,
                    deleted_post_id=deleted_post_id)
Пример #7
0
  def get(self):
    posts = Post.all()
    if not config.DEBUG and not self.request.host_url.endswith('appspot.com'):
      posts.filter('confirmed_at !=', None)
    posts.order('-confirmed_at')

    values = {
      'posts': posts
    }
    self.response.out.write(helper.render('main', values))
Пример #8
0
def list_posts():
    if session.get('logged_in'):
        return redirect('/posts_logged_in')
    posts = Post.all()
    images = {}
    if posts:
        for post in posts:
            directory = os.listdir(post.file_path)
            file_path = post.file_path
            images.update({file_path: directory[0]})
    return render_template('posts.html', posts=posts, images=images)
Пример #9
0
 def get(self, post_id=None, action=None):
     if action is None:
         posts = Post.all()
         self.response.out.write(helper.render('admin/posts', { 'posts': posts }))
     elif action == "delete":
         Post.get_by_id(int(post_id)).delete()
         return self.redirect('/admin/posts')
     elif action == "confirm":
         post = Post.get_by_id(int(post_id))
         post.confirmed_at = datetime.datetime.today()
         post.put()
         return self.redirect('/admin/posts')
Пример #10
0
def posts_logged_in():
    posts = Post.all()
    images = {}
    if posts:
        for post in posts:
            directory = os.listdir(post.file_path)
            file_path = post.file_path
            images.update({file_path: directory[0]})
    return render_template('posts_logged_in.html',
                           posts=posts,
                           username=User.find_by_id(session['USERNAME']),
                           images=images)
Пример #11
0
 def post(self):
     self.response.headers.add_header("Access-Control-Allow-Origin", "http://www.jonathonduerig.com");
     postid = self.request.get("postid")
     userid = self.request.get("userid")
     posts = []
     followed = []
     if postid:
         query = Post.all()
         query.filter("postid = ", postid)
         posts = query.fetch(1000)
     elif userid:
         query = Stream.all()
         query.filter("userid = ", userid)
         query.order("-created")
         posts = query.fetch(30)
         query = Relation.all()
         query.filter("follower = ", userid)
         followed = query.fetch(1000)
     resultList = []
     for p in posts:
         resultTags = []
         postkey = ""
         outPostid = ""
         if postid:
             postkey = p.key()
             outPostid = postid
         else:
             postkey = p.postkey.key()
             outPostid = p.postkey.postid
         query = Tag.all()
         query.filter("postkey = ", postkey)
         tags = query.fetch(1000)
         for t in tags:
           found = False
           for f in followed:
             if t.userid == f.user:
               found = True
               break
             pass
           if found or postid:
             tag = {'user': t.userid,
                    'key': t.tag_key,
                    'value': t.tag_value}
             resultTags.append(tag)
           pass
         resultList.append({'postid': outPostid, 'post': p.post,
                            'tags': resultTags})
     resultStr = json.dumps(resultList, sort_keys=True,
                            indent=2)
     self.response.out.write(resultStr)
Пример #12
0
    def get(self):
        posts_query = Post.all().order('-date')
        paginator = GAEPaginator(posts_query, 100)

        page = self.request.GET.get('page', 1)
        try:
            posts = paginator.page(page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            posts = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            posts = paginator.page(paginator.num_pages)

        visible_posts = posts.object_list
        columns = [[], [], []]

        # TODO: calculate contributor ranking fer reals
        contributors = {}
        for i in range(len(visible_posts)):
            columns[i % len(columns)].append(visible_posts[i])
            if not visible_posts[i].author:
                continue
            if visible_posts[i].author in contributors:
                contributors[visible_posts[i].author] += 1
            else:
                contributors[visible_posts[i].author] = 1

        sorted_contributors = sorted(contributors.iteritems(),
                                     key=operator.itemgetter(1))
        sorted_contributors.reverse()
        top_contributors = sorted_contributors[0:min(3, len(contributors))]

        if users.get_current_user():
            url = users.create_logout_url(self.request.uri)
            url_linktext = 'Logout'
        else:
            url = users.create_login_url(self.request.uri)
            url_linktext = 'Login'

        template_values = {
            'top_contributors': top_contributors,
            'columns': columns,
            'url': url,
            'url_linktext': url_linktext,
            'posts': posts,
        }

        path = os.path.join(os.path.dirname(__file__), 'index.html')
        self.response.out.write(template.render(path, template_values))
Пример #13
0
    def get(self):
        posts_query = Post.all().order('-date')
        paginator = GAEPaginator(posts_query, 100)
        
        page = self.request.GET.get('page', 1)
        try:
            posts = paginator.page(page)
        except PageNotAnInteger:
            # If page is not an integer, deliver first page.
            posts = paginator.page(1)
        except EmptyPage:
            # If page is out of range (e.g. 9999), deliver last page of results.
            posts = paginator.page(paginator.num_pages)
        
        visible_posts = posts.object_list
        columns = [[], [], []]
        
        # TODO: calculate contributor ranking fer reals
        contributors = {}
        for i in range(len(visible_posts)):
            columns[i % len(columns)].append(visible_posts[i])
            if not visible_posts[i].author:
                continue
            if visible_posts[i].author in contributors:
                contributors[visible_posts[i].author] += 1
            else:
                contributors[visible_posts[i].author] = 1
        
        sorted_contributors = sorted(contributors.iteritems(), key=operator.itemgetter(1))
        sorted_contributors.reverse()
        top_contributors = sorted_contributors[0:min(3, len(contributors))]
        
        if users.get_current_user():
            url = users.create_logout_url(self.request.uri)
            url_linktext = 'Logout'
        else:
            url = users.create_login_url(self.request.uri)
            url_linktext = 'Login'

        template_values = {
            'top_contributors': top_contributors,
            'columns': columns,
            'url': url,
            'url_linktext': url_linktext,
            'posts': posts,
        }

        path = os.path.join(os.path.dirname(__file__), 'index.html')
        self.response.out.write(template.render(path, template_values))
Пример #14
0
def get_post(url=""):
    #mc_key = 'WIKI'
    post = mc_get(url)
    ##logging.info('UTILS: from MemCahce: ' + str(post_val))
    ##logging.info('UTILS: MemCache Values: ' + str(post[0]) + ', ' + m_url)
    #if post != None:
    #logging.info('UTILS: Found in MemeCache')
    #logging.info("UTILS: MemCache Value: " + str(post))
    #else:
    #logging.info('UTILS: Not Found in MemCache')

    if post is None:
        #logging.info('UTILS: fetching post from DB')
        results = Post.all().filter('url =', url).order('-created').fetch(1)
        #logging.info('UTILS: DB Results: ' + str(results))
        if len(results) == 0:
            mc_set(url, None)
            #logging.info('UTILS: Post Value: None')
        else:
            mc_set(url, results[0])
            #logging.info('UTILS: Post Value: ' + results[0].content)
            post = results[0]
    return post
Пример #15
0
 def post(self):
     self.response.headers.add_header("Access-Control-Allow-Origin", "http://www.jonathonduerig.com");
     postid = self.request.get("postid")
     post = self.request.get("post")
     user = self.request.get("user")
     key = self.request.get("key")
     value = self.request.get("value")
     query = Post.all()
     query.filter("postid = ", postid)
     postResult = query.fetch(1000)
     post = Post(postid=postid, post=post)
     if len(postResult) > 0:
         post = postResult[0]
     else:
         post.put()
     tag = Tag(userid=user, postkey=post.key(), tag_key=key, tag_value=value)
     tag.put()
     query = Relation.all()
     query.filter("user = "******"Tagged post " + postid + " with " + user + ":" +
                             key + "=" + value)
Пример #16
0
 def post(self):
     posts = Post.all().order('-created')
     if (self.request.get('like')):
         likedpost = self.request.get('like')
         key = db.Key.from_path('Post', int(likedpost), parent=blog_key())
         post = db.get(key)
         likes = post.likes
         likers = post.likers
         error = ""
         if self.user:
             if post.author == self.user.name:
                 error = "The author of a post cannot like their own post"
             elif self.user.name in post.likers:
                 post.likes -= 1
                 post.likers.remove(self.user.name)
                 post.put()
             else:
                 post.likes = post.likes + 1
                 post.likers.append(self.user.name)
                 post.put()
         else:
             self.redirect("/login")
     time.sleep(0.2)
     self.render('front.html', posts=posts, user=self.user, error=error)
Пример #17
0
 def get(self):
     posts = greetings = Post.all().order('-created')
     self.render('front.html', posts = posts)
Пример #18
0
 def get(self):
     # Renders all posts on blog homepage
     posts = Post.all().order('-created')
     self.render('front.html', posts=posts)
Пример #19
0
def list_posts():
    return render_template('index.html', User = None, posts=Post.all())
Пример #20
0
def after_reg_log(id):
    return render_template('index.html', User = User.find_by_id(id), posts=Post.all())
Пример #21
0
def my_posts(id):
    return render_template('my_posts.html', User = User.find_by_id(id), posts = Post.all())
Пример #22
0
def view_post():
    return render_template("view.html", posts=Post.all())
Пример #23
0
def delete(id):
    post = Post.find(id)
    username = User.find_by_id(post.owner)
    post.delete()
    return render_template("my_posts.html", User=username, posts = Post.all())
Пример #24
0
def print_hello(id):
    username = User.find_by_id(id)
    print(username)
    return render_template("index.html", User = username, Post = Post.all())
Пример #25
0
def my_sold_posts(id):
    return render_template("my_sold_posts.html", User = User.find_by_id(id), Post = Post.all())
Пример #26
0
def list_posts():
    return render_template('posts.html', posts=Post.all())
Пример #27
0
def post_entries():
    return render_template("post_entries.html", posts=Post.all(request.args.get('available_from'), request.args.get('available_to')))
Пример #28
0
 def get(self):
     posts = greetings = Post.all().filter('parent_id =', None).order('-created')
     self.render('front.html', posts = posts)
Пример #29
0
 def get(self):
     posts = Post.all().order('-created')
     self.render('front.html', posts=posts, user=self.user)
Пример #30
0
 def get(self):
     posts = Post.all().order('-created_at')
     self.render('front.html', posts=posts)
Пример #31
0
 def my_cart():
     if not self.user:
         return redirect('/')
     return render_template('my_cart.html',
                            user=self.user,
                            posts=Post.all())
Пример #32
0
 def get(self):
     deleted_post_id = self.request.get('deleted_post_id')
     posts = Post.all().order('-created')
     self.render('main.html', posts=posts, deleted_post_id=deleted_post_id)
Пример #33
0
 def get(self):
     # renders all posts, sorted by date
     postId_deleted = self.request.get('postId_deleted')
     posts = greetings = Post.all().order('-created')
     self.render('front.html', posts=posts, postId_deleted=postId_deleted)
Пример #34
0
 def get(self):
     posts = Post.all().order('-created_at')
     self.render('front.html', posts=posts)
Пример #35
0
 def get(self):
     """
         Renders home page with posts sorted by date descending.
     """
     posts = Post.all().order('-created')
     self.render('front.html', posts=posts)