Site root query

This commit is contained in:
Oleg Lavrovsky 2018-06-12 22:52:31 +02:00
parent c9da4db6ac
commit e96c0a1528

View file

@ -8,13 +8,13 @@ register = template.Library()
def get_contacts(site_root): def get_contacts(site_root):
if not site_root: return {} if not site_root: return {}
site_id = site_root.id site = site_root.get_site()
top_contact = Contact.objects.filter(home_site=site_id) top_contact = Contact.objects.filter(home_site=site)
if top_contact.exists(): if top_contact.exists():
top_contact = top_contact.last() top_contact = top_contact.last()
else: else:
top_contact = Contact.objects.last() top_contact = Contact.objects.last()
social_contacts = SocialContact.objects.filter(home_site=site_id) social_contacts = SocialContact.objects.filter(home_site=site)
if social_contacts.exists(): if social_contacts.exists():
social_contacts = social_contacts.all() social_contacts = social_contacts.all()
else: else: