2017-10-22 18:37:24 -04:00
|
|
|
from django.shortcuts import get_object_or_404, render
|
|
|
|
from users.models import User
|
2017-10-24 09:25:41 -04:00
|
|
|
from lemoncurry import breadcrumbs
|
2017-10-26 18:52:03 -04:00
|
|
|
from lemoncurry.templatetags.lemoncurry_tags import request_uri
|
2017-10-24 09:25:41 -04:00
|
|
|
|
|
|
|
breadcrumbs.add('home:index', 'home')
|
2017-10-22 18:37:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
def index(request):
|
2017-10-26 17:52:26 -04:00
|
|
|
query = User.objects.prefetch_related('entries', 'profiles', 'keys')
|
|
|
|
user = get_object_or_404(query, pk=1)
|
2017-10-26 18:52:03 -04:00
|
|
|
uri = request_uri(request)
|
|
|
|
person = {
|
|
|
|
'@context': 'http://schema.org',
|
|
|
|
'@type': 'Person',
|
|
|
|
'@id': uri,
|
|
|
|
'url': uri,
|
|
|
|
'name': '{0} {1}'.format(user.first_name, user.last_name),
|
|
|
|
'email': user.email,
|
|
|
|
'image': user.avatar.url,
|
|
|
|
'givenName': user.first_name,
|
|
|
|
'familyName': user.last_name,
|
|
|
|
'sameAs': [profile.url for profile in user.profiles.all()]
|
|
|
|
}
|
|
|
|
|
2017-10-26 17:52:26 -04:00
|
|
|
entries = user.entries.all()
|
2017-10-24 06:57:07 -04:00
|
|
|
return render(request, 'home/index.html', {
|
|
|
|
'user': user,
|
2017-10-26 18:52:03 -04:00
|
|
|
'person': person,
|
2017-10-24 21:55:24 -04:00
|
|
|
'entries': entries,
|
2017-10-24 06:57:07 -04:00
|
|
|
'meta': user.as_meta(request),
|
|
|
|
})
|