Move the user login template code to its own template file, so it can be reused.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Tue, 18 Jan 2011 01:08:01 +0530
changeset 449 50c45258b00e
parent 448 870235dbac86
child 450 7984094bf6c4
Move the user login template code to its own template file, so it can be reused.
pytask/templates/_right_sidebar.html
pytask/templates/_user_login.html
--- 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>
-      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-      <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>
+        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+        <a href="{% url auth_password_reset %}">Forgot password?</a>
+      </div>
+    </div>
+  {% endif %}
+</div>