Guest User

Untitled

a guest
Apr 26th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. {% block optionsNav %}
  2.     {% load client_extra %}
  3.     {% if user.is_authenticated %}
  4.     {% client_navigations %}
  5.     {% else %}
  6.      {% form_login request.get_full_path messages %}
  7.     {% endif %}
  8. {% endblock %}
  9.  
  10.  
  11. #-*- encoding: utf-8 -*-
  12.  
  13. #import django
  14. from django import template
  15. from django.contrib.auth.models import User
  16. from django.template import RequestContext
  17. from django.http import HttpRequest
  18.  
  19.  
  20. #templates tag
  21.  
  22. #import app
  23. from client.forms import LoginForm
  24.  
  25. register = template.Library()
  26.    
  27. @register.inclusion_tag('client/login.html')   
  28. def form_login(full_path, messages):
  29.     forms = LoginForm()
  30.     return {'forms': forms, 'full_path':full_path, 'messages':messages}
  31.    
  32.    
  33. @register.inclusion_tag('client/navigations.html', takes_context=True)
  34. def client_navigations(context):
  35.     request = context['request']
  36.     username = request.session.get('connected_user',None)
  37.     if username:
  38.         user = User.objects.get(email__exact=username).get_full_name()
  39.         return {'user': user, }
  40.     form_login()
Add Comment
Please, Sign In to add comment