Huh, please don't tell me I will have to refactor so much code again.
authorMadhusudan.C.S <madhusudancs@gmail.com>
Sun, 16 Jan 2011 23:17:13 +0530
changeset 431 fcc87a3f0311
parent 430 a11a778fca54
child 432 27cc6671193a
Huh, please don't tell me I will have to refactor so much code again.
pytask/templates/task/addreviewer.html
pytask/templates/task/approved_task.html
pytask/templates/task/approved_textbook.html
pytask/templates/task/browse.html
pytask/templates/task/browse_textbooks.html
pytask/templates/task/claim.html
pytask/templates/task/confirm_approval.html
pytask/templates/task/confirm_textbook_approval.html
pytask/templates/task/edit.html
pytask/templates/task/select_user.html
pytask/templates/task/submit_report.html
pytask/templates/task/view.html
pytask/templates/task/view_report.html
pytask/templates/task/view_textbook.html
pytask/templates/task/view_work.html
pytask/templates/templatetags/_as_div_form.html
pytask/templatetags/form_helpers.py
--- a/pytask/templates/task/addreviewer.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/addreviewer.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,9 +1,7 @@
-{% extends 'base.html' %}
+{% extends "base.html" %}
+
 {% block content %}
-    Select a user as a reviewer for this task.<br />
-    <form action="" method="POST">
-	    {% csrf_token %}
-    {{form.as_table}}
-    <input type="submit" value="Select">
-    </form>
+  Select a user as a reviewer for this task.<br />
+
+  {% as_div_form form "Add Reviewer Form" csrf_token "Select" %}
 {% endblock %}
--- a/pytask/templates/task/approved_task.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/approved_task.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,5 +1,9 @@
-{% extends 'base.html' %}
+{% extends "base.html" %}
+
 {% block content %}
-The task <a href="{% url view_task task.id %}">{{task.title}}</a> has been approved.<br />
+The task <a href="{% url view_task task.id %}">{{task.title}}</a>
+has been approved.
+<br />
+
 The task will be public. Now users can claim the task and work on it.
 {% endblock %}
--- a/pytask/templates/task/approved_textbook.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/approved_textbook.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,5 +1,8 @@
-{% extends 'base.html' %}
+{% extends "base.html" %}
 {% block content %}
-The textbook <a href="{% url view_textbook textbook.id %}">{{textbook.name}}</a> has been approved.<br />
+The textbook <a href="{% url view_textbook textbook.id %}">
+{{textbook.name}}</a> has been approved.
+<br />
+
 The textbook will now be public.
 {% endblock %}
--- a/pytask/templates/task/browse.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/browse.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,4 +1,5 @@
-{% extends 'base.html' %}
+{% extends "base.html" %}
+
 {% block content %}
 
     {% if open_tasks %}
--- a/pytask/templates/task/browse_textbooks.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/browse_textbooks.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,4 +1,5 @@
-{% extends 'base.html' %}
+{% extends "base.html" %}
+
 {% block content %}
     {% if comp_textbooks %}
     Textbooks that were completed recently<ul>
--- a/pytask/templates/task/claim.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/claim.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,4 +1,5 @@
-{% extends 'base.html' %}
+{% extends "base.html" %}
+
 {% block content %}
     {% if can_claim %}
     Propose a claim to work on this task.<br />
@@ -27,13 +28,10 @@
     {% endif %}
 
     {% if can_claim %}
-        <hr />
-        <form action="" method="post">
-	{% csrf_token %}
-        {{form.as_p}}
-        <input type="submit" value="Submit Claim"><br />
-        Please note that you can claim only once and so write your proposal carefully.<br />
-        </form>
+      <hr />
+      Please note that you can claim only once and so write your
+      proposal carefully.<br />
+      {% as_div_form form "Task Claim Form" csrf_token "Request Claim" %}
     {% endif %}
 
 {% endblock %}
--- a/pytask/templates/task/confirm_approval.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/confirm_approval.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,8 +1,20 @@
-{% extends 'base.html' %}
+{% extends "base.html" %}
+
 {% block content %}
-You are about to approve the task <a href="{% url view_task task.id %}">{{task.title}}</a><br />
-This action cannot be undone. Please confirm <br /> <br />
+  You are about to approve the task <a href="{% url view_task task.id %}">
+  {{task.title}}</a>
+  <br />
+  This action cannot be undone. Please confirm
+  <br /><br />
 
-<a href="{% url approve_task task.id %}">Yes, I approve the task</a><br />
-<a href="{% url view_task task.id %}">No, take me back to the task</a> <br />
+  <a href="{% url approve_task task.id %}">
+    Yes, I approve the task
+  </a>
+  <br />
+
+  <a href="{% url view_task task.id %}">
+    No, take me back to the task
+  </a>
+  <br />
+
 {% endblock %}
--- a/pytask/templates/task/confirm_textbook_approval.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/confirm_textbook_approval.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,8 +1,20 @@
-{% extends 'base.html' %}
+{% extends "base.html" %}
+
 {% block content %}
-You are about to approve the textbook <a href="{% url view_textbook textbook.id %}">{{textbook.name}}</a><br />
-This action cannot be undone. Please confirm <br /> <br />
+You are about to approve the textbook 
+<a href="{% url view_textbook textbook.id %}">{{textbook.name}}</a>
+<br />
+
+This action cannot be undone. Please confirm
+<br /> <br />
 
-<a href="{% url approve_textbook textbook.id %}">Yes, I approve the textbook</a><br />
-<a href="{% url view_textbook textbook.id %}">No, take me back to the textbook</a> <br />
+<a href="{% url approve_textbook textbook.id %}">
+  Yes, I approve the textbook
+</a>
+<br />
+
+<a href="{% url view_textbook textbook.id %}">
+  No, take me back to the textbook
+</a>
+<br />
 {% endblock %}
--- a/pytask/templates/task/edit.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/edit.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,4 +1,5 @@
 {% extends "base.html" %}
+
 {% load form_helpers %}
 
 {% block css %}
@@ -19,5 +20,5 @@
 {% endblock %}
 
 {% block content %}
-  {% as_div_form form "Create Task Form" csrf_token "" "Submit" %}
+  {% as_div_form form "Create Task Form" csrf_token "Submit" %}
 {% endblock %}
--- a/pytask/templates/task/select_user.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/select_user.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,10 +1,10 @@
-{% extends 'base.html' %}
+{% extends "base.html" %}
+
 {% block content %}
-    <a href="{% url claim_task task.id %}">click here</a> to return to the claims page.<br /><br />
-    Select a user to assign this task.<br />
-    <form action="" method="POST">
-	    {% csrf_token %}
-    {{form.as_table}}
-    <input type="submit" value="Assign Task">
-    </form>
+  <a href="{% url claim_task task.id %}">
+    Click here
+  </a> to return to the claims page.
+  <br /><br />
+  Select a user to assign this task.<br />
+  {% as_div_form form "Assign Task Form" csrf_token "Assign Task" %}
 {% endblock %}
--- a/pytask/templates/task/submit_report.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/submit_report.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,12 +1,9 @@
-{% extends 'base.html' %}
+{% extends "base.html" %}
+
 {% block title %}
-    {{task.title}}
+  {{task.title}}
 {% endblock %}
+
 {% block content %}
-Submit a report: <br />
-<form action='' method=post enctype="multipart/form-data">
-	{% csrf_token %}
-{{ form.as_p }}
-<input type=submit value=submit />
-</form>
+  {% as_div_form form "Submit Report" csrf_token "Submit" "" "True" %}
 {% endblock %}
--- a/pytask/templates/task/view.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/view.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,82 +1,98 @@
-{% extends 'base.html' %}
+{% extends "base.html" %}
+
 {% block title %}
-    {{task.title}}
+  {{task.title}}
 {% endblock %}
+
 {% block content %}
-    <h3>{{ task.title }}</h3>
-
-    {% if can_edit %}
-        <a href="{% url edit_task task.id %}">Edit task</a>
-    {% endif %}
+  <h3>{{ task.title }}</h3>
 
-    {% if can_approve %}
-        <a href="{% url approve_task task.id %}">Approve task</a>
-    {% endif %}
-
-    {% if can_close %}
-        <a href="{% url close_task task.id %}">Close task</a>
-    {% endif %}
+  {% if can_edit %}
+    <a href="{% url edit_task task.id %}">Edit task</a>
+  {% endif %}
 
-    <hr />created by <a href="{% url view_user_profile task.created_by.id %}">{{ task.created_by.username }}</a>
-    on {{task.creation_datetime|date:"D d M Y"}} at {{task.creation_datetime|time:"H:i"}}<br />
-    
-    {% if reviewers %}
-    Reviewers:
-	    {% for reviewer in reviewers %}
-		<a href="{% url view_user_profile reviewer.id %}">{{reviewer.username}}</a>
-	    {% endfor %}
-    {% endif %}
+  {% if can_approve %}
+    <a href="{% url approve_task task.id %}">Approve task</a>
+  {% endif %}
+
+  {% if can_close %}
+      <a href="{% url close_task task.id %}">Close task</a>
+  {% endif %}
 
-    {% if can_mod_reviewers %}
-        <a href="{% url addreviewer_task task.id %}">
-		Add a Reviewer to this task</a>
-    {% endif %}
-    <br />
-    
-    <hr />
-    <b>Description:</b><br />
-    {{ task.desc|linebreaksbr }}
-    <br /><br /><hr />
-    {% if task.tags.count %}
-        Tags: 
-        {% for tag in task.tags %}
-            {{tag}}
-        {% endfor %}
-        <hr />
-    {% endif %}
+  <hr />created by
+  <a href="{% url view_user_profile task.created_by.id %}">
+    {{ task.created_by.username }}
+  </a>
+  on {{task.creation_datetime|date:"D d M Y"}} at 
+  {{task.creation_datetime|time:"H:i"}}
+  <br />
+
+  {% if reviewers %}
+    Reviewers:
+    {% for reviewer in reviewers %}
+      <a href="{% url view_user_profile reviewer.id %}">{{reviewer.username}}</a>
+    {% endfor %}
+  {% endif %}
 
-    {% if selected_users %}
-        Users working on this task:
-        {% for user in selected_users %}
-            <a href="{% url view_profile user.id %}">{{user.username}}</a>
-        {% endfor %}
-        <br />
-    {% endif %}
-    
-    {% if task_claimable %}
-  <a href="{% url claim_task task.id %}">View claims</a>
-    {% endif %}
+  {% if can_mod_reviewers %}
+    <a href="{% url addreviewer_task task.id %}">
+    Add a Reviewer to this task</a>
+  {% endif %}
+  <br />
+
+  <hr />
+  <b>Description:</b><br />
 
-    <a href="{% url view_work task.id %}">View submitted work reports</a>
+  {{ task.desc|linebreaksbr }}
+  <br /><br /><hr />
+
+  {% if task.tags.count %}
 
-        <hr />
-    {% if comments %}
-        comments:<br /><br />
-        {% for comment in comments %}
-            <a href="{% url view_profile comment.commented_by.id %}">{{ comment.commented_by.username }}</a> 
-            on {{ comment.comment_datetime|date:"D d M Y"}} at {{comment.comment_datetime|time:"H:i"}} wrote:<br />
-        {{ comment.data|linebreaksbr }}<br />
-        {% endfor %}
-    {% endif %}
+    Tags: 
+    {% for tag in task.tags %}
+      {{tag}}
+    {% endfor %}
     <hr />
 
-    {% if can_comment %}
+  {% endif %}
+
+  {% if selected_users %}
+
+    Users working on this task:
+    {% for user in selected_users %}
+      <a href="{% url view_profile user.id %}">{{user.username}}</a>
+    {% endfor %}
+    <br />
+
+  {% endif %}
+
+  {% if task_claimable %}
+    <a href="{% url claim_task task.id %}">View claims</a>
+  {% endif %}
+
+  <a href="{% url view_work task.id %}">View submitted work reports</a>
+  <hr />
+
+
+  {% if comments %}
+
+    comments:<br /><br />
+    {% for comment in comments %}
+      <a href="{% url view_profile comment.commented_by.id %}">
+        {{ comment.commented_by.username }}
+      </a> 
+      on {{ comment.comment_datetime|date:"D d M Y"}} at 
+      {{comment.comment_datetime|time:"H:i"}} wrote:
+      <br />
+      {{ comment.data|linebreaksbr }}<br />
+    {% endfor %}
+
+  {% endif %}
+  <hr />
+
+  {% if can_comment %}
     Add comment:<br />
-	<form action="" method="post">
-	    {% csrf_token %}
-	    {{form.as_p}}
-	<input type="submit" value="Submit">
-	</form>                
-    {% endif %}
+    {% as_div_form form "Comment Form" csrf_token "Submit" %}
+  {% endif %}
 
 {% endblock %}
--- a/pytask/templates/task/view_report.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/view_report.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,12 +1,19 @@
-{% extends 'base.html' %}
+{% extends "base.html" %}
+
 {% block content %}
 Report for {{report.task.title}} <br />
 
 <hr />
-Description:<br />
+Description:
+<br />
+
 {{ report.data|linebreaksbr }}
+
 <hr />
-Summary: {{ report.summary }} <br />
+Summary: {{ report.summary }}
+<br />
 <hr />
-Attachment: <a href="{{report.attachment.url}}">{{report.attachment.name}}</a> 
+
+Attachment: <a href="{{report.attachment.url}}">{{report.attachment.name}}</a>
+ 
 {% endblock %}
--- a/pytask/templates/task/view_textbook.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/view_textbook.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,7 +1,9 @@
-{% extends 'base.html' %}
+{% extends "base.html" %}
+
 {% block title %}
     {{textbook.name}}
 {% endblock %}
+
 {% block content %}
     <h3>{{ textbook.name }}</h3>
 
@@ -51,12 +53,7 @@
     <hr />
 
     {% if can_comment %}
-    Add comment:<br />
-	<form action="" method="post">
-	    {% csrf_token %}
-	    {{form.as_p}}
-	<input type="submit" value="Submit">
-	</form>                
+      {% as_div_form form "Comment Form" csrf_token "Submit" %}
     {% endif %}
 
 {% endblock %}
--- a/pytask/templates/task/view_work.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/task/view_work.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,23 +1,29 @@
-{% extends 'base.html' %}
+{% extends "base.html" %}
+
 {% block title %}
-    {{task.title}}
+  {{task.title}}
 {% endblock %}
+
 {% block content %}
-{% if not old_reports %}
-There are no reports submitted as of now<br />
-{% else %}
-<table >
-{% for rep in old_reports %}
-<tr>
-	<td>{{rep.submitted_by}}</td>
-	<td><a href="{% url view_report rep.id %}">{{rep.data}}</a></td>
-	<td><a href="{{rep.attachment.url}}">{{rep.attachment.name}}</a> </td>
-</tr>
-{% endfor %}
-</table>
-{% endif %}
-{% if is_working %}
-<a href="{% url submit_report rep.id %}">Submit report</a>
-<hr />
-{% endif %}
+
+  {% if not old_reports %}
+    There are no reports submitted as of now<br />
+  {% else %}
+
+    <table >
+      {% for rep in old_reports %}
+        <tr>
+          <td>{{rep.submitted_by}}</td>
+          <td><a href="{% url view_report rep.id %}">{{rep.data}}</a></td>
+          <td><a href="{{rep.attachment.url}}">{{rep.attachment.name}}</a> </td>
+        </tr>
+    {% endfor %}
+    </table>
+
+  {% endif %}
+
+  {% if is_working %}
+    <a href="{% url submit_report rep.id %}">Submit report</a>
+    <hr />
+  {% endif %}
 {% endblock %}
--- a/pytask/templates/templatetags/_as_div_form.html	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templates/templatetags/_as_div_form.html	Sun Jan 16 23:17:13 2011 +0530
@@ -1,6 +1,11 @@
 {% load form_helpers %}
 
-<form action="{{ action_url }}" method="post">
+<form action="{{ action_url }}" method="post"
+    {% if file_support %}
+      enctype="multipart/form-data"
+    {% else %}
+      >
+    {% endif %}
   {% csrf_token %}
   <div id="form">
     {% for field in form %}
--- a/pytask/templatetags/form_helpers.py	Sun Jan 16 23:16:21 2011 +0530
+++ b/pytask/templatetags/form_helpers.py	Sun Jan 16 23:17:13 2011 +0530
@@ -14,7 +14,8 @@
 
 
 @register.inclusion_tag('templatetags/_as_div_form.html')
-def as_div_form(form, form_name, csrf_token, action_url, button_label):
+def as_div_form(form, form_name, csrf_token, button_label,
+                action_url='', file_support=False):
     """Returns a form to be constructed by the template specified.
     """
 
@@ -24,6 +25,7 @@
       'csrf_token': csrf_token,
       'action_url': action_url,
       'button_label': button_label,
+      'file_support': file_support,
     }