Exemplo n.º 1
0
def list_greetings(request):
    greetings = Greeting.objects.all().order_by("-date")[:10]

    try:
        username = request.session["user"]
    except KeyError:
        username = "******"

    displays = []
    for greeting in greetings:
        d = dateutil.date_to_local(greeting.date)

        if username != "anonymous" or greeting.isprivate == 0:
            displays.append(
                {
                    "author": greeting.author.username,
                    "content": greeting.content,
                    "date": d,
                    "isprivate": greeting.isprivate,
                }
            )

    return direct_to_template(
        request, "guestbook/index.html", {"username": username, "greetings": displays, "page": "about"}
    )
Exemplo n.º 2
0
def index(request):
  blogs = Blog.objects.all().order_by('-date')
  result = User.objects.all().filter(username = '******')
  if len(result) > 0:
    paullzn = result[0]
  else:
    paullzn = "paullzn"
  result = User.objects.all().filter(username = '******')
  if len(result) > 0:
    lisa = result[0]
  else:
    lisa = "lisa"

  try:
    p_status = Status.objects.all().filter(author = paullzn ).order_by('-created_at')[0].content
  except IndexError:
    p_status = "nothing.."
  try:
    l_status = Status.objects.all().filter(author = lisa ).order_by('-created_at')[0].content
  except IndexError:
    l_status = "nothing.."

  try:
    username = request.session['user']
  except KeyError:
    username = '******'

  displays = []

  for blog in blogs:
    d = dateutil.date_to_local(blog.date)
    if username != 'anonymous' or blog.isprivate == 0:
      displays.append({'author': blog.author.username, \
          'content': blog.content, \
          'date': d, \
          'isprivate': blog.isprivate, \
          'title': blog.title})

  return direct_to_template(request, 'blog/index.html',
      {'username': username,
      'p_status': p_status,
      'l_status': l_status,
      'blogs': displays,
      'page': 'blog'})
Exemplo n.º 3
0
def list_greetings(request):
	greetings = Greeting.objects.all().order_by('-date')[:10]

	try:
		username = request.session['user']
	except KeyError:
		username = '******'

	displays = []
	for greeting in greetings:
		d = dateutil.date_to_local(greeting.date)

		if username != 'anonymous' or greeting.isprivate == 0:
			displays.append({'author': greeting.author.username,\
					'content': greeting.content,\
					'date': d, \
					'isprivate': greeting.isprivate})

	return direct_to_template(request, 'guestbook/index.html',
			{'username': username,
			'greetings': displays,
			'page': 'about'})