Move the user login template code to its own template file, so it can be reused.
--- a/pytask/templates/_right_sidebar.html Tue Jan 18 01:06:21 2011 +0530
+++ b/pytask/templates/_right_sidebar.html Tue Jan 18 01:08:01 2011 +0530
@@ -1,48 +1,8 @@
-{% load user_tags %}
-
-<div id="navheader">
- {% if user.is_authenticated %}
- {{ user.username }} Actions
- {% else %}
- Login Form
- {% endif %}
-</div>
-
-{% if user.is_authenticated %}
- <ul id="nav">
- <li>
- <a href="{% url browse_notifications %}" title="notifications">
- {{ user|notf_dsp }}
- </a>
- </li>
- <br>
- <li><a href="{% url view_profile %}">View Profile</a></li>
- <li><a href="{% url auth_logout %}">Logout</a></li>
- </ul>
-{% else %}
+{% comment %}
+ Currently this template only includes the user actions for logged
+ in and non-logged in users. This can be extended to include other,
+ side-wide actions on right sidemenu bar.
+{% endcomment %}
- <form action="{% url auth_login %}" method="post">
- <div id="loginform">
- <div id="field">
- <label for="username">Username</label>
- <input type="text" name="username" />
- </div>
- <div id="field">
- <label for="password">Password</label>
- <input type="password" name="password" />
- </div>
- <p class="submit"><button type="submit">Login</button></p>
- </div>
- </form>
- <div id="rightnav">
- <div id="register">
- <a href="{% url registration_register %}" title="register">
- Register
- </a>
-
- <a href="{% url auth_password_reset %}">Forgot password?</a>
- </div>
- </div>
-
-{% endif %}
+{% include "_user_login.html" %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pytask/templates/_user_login.html Tue Jan 18 01:08:01 2011 +0530
@@ -0,0 +1,47 @@
+{% load user_tags %}
+
+<div id="useraction">
+ {% if user.is_authenticated %}
+ <div id="navheader">
+ Welcome {{ user.first_name }}!
+ </div>
+ <ul id="nav">
+ <li>
+ <a href="{% url browse_notifications %}" title="notifications">
+ {{ user|notf_dsp }}
+ </a>
+ </li>
+ <br>
+ <li><a href="{% url view_profile %}">View Profile</a></li>
+ <li><a href="{% url auth_logout %}">Logout</a></li>
+ </ul>
+ {% else %}
+ <div id="navheader">
+ Login Form
+ </div>
+ <form id="form_login" method="post">
+ <div id="loginform">
+ {% csrf_token %}
+ <div id="field">
+ <label for="username">Username</label>
+ <input id="username" type="text" name="username" />
+ </div>
+ <div id="field">
+ <label for="password">Password</label>
+ <input id="password" type="password" name="password" />
+ </div>
+ <p class="submit"><button type="submit">Login</button></p>
+ </div>
+ </form>
+
+ <div id="rightnav">
+ <div id="register">
+ <a href="{% url registration_register %}" title="register">
+ Register
+ </a>
+
+ <a href="{% url auth_password_reset %}">Forgot password?</a>
+ </div>
+ </div>
+ {% endif %}
+</div>