Example #1
0
def home():
    #Some backend to be added to do the following:
    #1. Get some stats to be displayed on top.
    #2. Get the top 5 projects of each category.
    #The above function needs to be written both in models.py

    #Debugger code to get all posts and backers
    posts = dbHandler.getPost()
    backers = dbHandler.getBackers()
    no_of_posts = dbHandler.getPostCount()
    no_of_backings = dbHandler.getBackingCount()
    tot_backing_funds = dbHandler.getBackingFunds()
    no_of_users = dbHandler.getUserCount()
    if 'username' in session:
        user = dbHandler.getUserInfo(session['username'])
        return render_template('index.html',
                               no_of_users=no_of_users,
                               profile_pic=user['photo'],
                               logged_user=session['username'],
                               posts=posts,
                               backers=backers,
                               no_of_posts=no_of_posts,
                               no_of_backings=no_of_backings,
                               tot_backing_funds=tot_backing_funds)
    else:
        return render_template('index.html',
                               profile_pic="default.png",
                               no_of_users=no_of_users,
                               logged_user="",
                               posts=posts,
                               backers=backers,
                               no_of_backings=no_of_backings,
                               no_of_posts=no_of_posts,
                               tot_backing_funds=tot_backing_funds)
Example #2
0
 def get(self,url=''):
   visitor.register(self.request)
   data={ 
     'options' : models.getConfig(),
     'history' : models.getLastEntries(10), 
     'entry'   : models.getPost(url) 
   }
   path = os.path.join(os.path.dirname(__file__),view)
   self.response.out.write(template.render(path,data))
Example #3
0
File: views.py Project: peroo/Bog
def blog_post(request):
    form = forms.Comment(request.POST)
    post = models.getPost(request.context.key)
    if request.method == 'POST' and form.validate():
        comment = models.Comment()
        form.populate_obj(comment)
        comment.post = post
        comment.save()

        url = resource_url(request.context, request, anchor='test')
        #url = current_route_url(request, None, _anchor = 'test') 
        #url = current_route_url(request)
        return HTTPFound(location = url)

    return {'post': post, 'form': form}
Example #4
0
File: views.py Project: peroo/Bog
def blog_view(request):
    return models.getPost()