Ejemplo n.º 1
0
def main_page(request):
    # GET method ('key', 'value')
    guestbook_name = request.GET.get('guestbook_name', 'default_guestbook')
    # get key
    guestbook_key = Greeting.get_key_from_name(guestbook_name)
    # make query for select data ordered dsec
    greetings_query = Greeting.all().ancestor(guestbook_key).order('-date')
    # get result set
    greetings = greetings_query.fetch(10)
    
    # get user, if exist current user
    if users.get_current_user():
        # create logout url
        url = users.create_logout_url(request.get_full_path())
        url_linktext = 'Logout'
    else:
        # create login url
        url = users.create_login_url(request.get_full_path())
        url_linktext = 'Login'
        
    # set up values for use in template
    template_values = {
        'greetings': greetings,
        'guestbook_name': guestbook_name,
        'url': url,
        'url_linktext': url_linktext,
    }
    
    return direct_to_template(request, 'guestbook/main_page.html', template_values)
Ejemplo n.º 2
0
def main_page(request):
    guestbook_name = request.GET.get('guestbook_name', 'default_guestbook')
    guestbook_key = Greeting.get_key_from_name(guestbook_name)
    greetings_query = Greeting.all().ancestor(guestbook_key).order('-date')
    greetings = greetings_query.fetch(10)
    if users.get_current_user():
        url = users.create_logout_url(request.get_full_path())
        url_linktext = 'Logout'
    else:
        url = users.create_login_url(request.get_full_path())
        url_linktext = 'Login'
    template_values = {
        'greetings': greetings,
        'guestbook_name': guestbook_name,
        'url': url,
        'url_linktext': url_linktext,
    }
    return direct_to_template(request, 'guestbook/main_page.html', template_values)
Ejemplo n.º 3
0
def list(request, context=None):
    greetings = Greeting.all().order('-date').fetch(10)
    return render_to_response('guestbook/list.html', { 'greetings': greetings }, RequestContext(request))
Ejemplo n.º 4
0
def list_entries(request):
    return object_list(request, Greeting.all())