context_processors.py 907 B

12345678910111213141516171819202122232425262728
  1. from django.urls import reverse
  2. from .models import Agreement
  3. def legal_links(request):
  4. agreements = Agreement.objects.get_agreements()
  5. legal_context = {}
  6. terms_of_service = agreements.get(Agreement.TYPE_TOS)
  7. if terms_of_service:
  8. if terms_of_service['link']:
  9. legal_context['TERMS_OF_SERVICE_URL'] = terms_of_service['link']
  10. elif terms_of_service['text']:
  11. legal_context['TERMS_OF_SERVICE_URL'] = reverse('misago:terms-of-service')
  12. privacy_policy = agreements.get(Agreement.TYPE_PRIVACY)
  13. if privacy_policy:
  14. if privacy_policy['link']:
  15. legal_context['PRIVACY_POLICY_URL'] = privacy_policy['link']
  16. elif privacy_policy['text']:
  17. legal_context['PRIVACY_POLICY_URL'] = reverse('misago:privacy-policy')
  18. if legal_context:
  19. request.frontend_context.update(legal_context)
  20. return legal_context