created the home page
authorNishanth Amuluru <nishanth@fossee.in>
Sun, 09 Jan 2011 15:01:30 +0530
changeset 363 9b0812962133
parent 362 070f01dd7d8e
child 364 2763afa1c2a2
created the home page
pytask/taskapp/views.py
pytask/templates/404.html
pytask/templates/index.html
pytask/templates/task/select_user.html
pytask/urls.py
pytask/views.py
--- a/pytask/taskapp/views.py	Sun Jan 09 12:01:57 2011 +0530
+++ b/pytask/taskapp/views.py	Sun Jan 09 15:01:30 2011 +0530
@@ -245,6 +245,7 @@
 
                     task.selected_users.add(selected_user)
                     task.claimed_users.remove(selected_user)
+                    task.status = "WR"
                     task.save()
 
                     return redirect(task_url)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pytask/templates/404.html	Sun Jan 09 15:01:30 2011 +0530
@@ -0,0 +1,5 @@
+{% extends 'base.html' %}
+{% block content %}
+    The page you requested does not exist.<br />
+    <a href="javascript:history.go(-1)">Click here</a> to get back to the previous page.
+{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pytask/templates/index.html	Sun Jan 09 15:01:30 2011 +0530
@@ -0,0 +1,54 @@
+{% extends 'base.html' %}
+{% block content %}
+    {% if not user %}
+        Welcome Guest<br>
+        <a href="/accounts/register/">Register</a>
+        <a href="/accounts/login/">Login</a><br /><br />
+    {% else %}
+        Logged in as {{ user.username }} <br /><br />
+    {% endif %}
+
+    {% if can_create_task %}
+    	<a href="/task/textbook/create/">Add a new textbook</a><br />
+        <a href="/task/create/">Create a task</a><br />
+    <br />
+    {% endif %}
+    
+    
+    {% if unpublished_tasks %}
+    Unpublished tasks viewable by you:<ul>
+        {% for a_task in unpublished_tasks %}
+            <li><a href="/task/view/tid={{a_task.id}}">{{a_task.title}}</a></li>
+        {% endfor %}
+        </ul>
+    <br />
+    {% endif %}
+
+    {% if reviewered_tasks %}
+    Tasks you are reviewering:<ul>
+        {% for a_task in reviewered_tasks %}
+            <li><a href="/task/view/tid={{a_task.uniq_key}}">{{a_task.title}}</a></li>
+        {% endfor %}
+        </ul>
+    <br />
+    {% endif %}
+
+    {% if selected_tasks %}
+    Tasks that have been assigned to you:<ul>
+        {% for a_task in selected_tasks %}
+            <li><a href="/task/view/tid={{a_task.uniq_key}}">{{a_task.title}}</a></li>
+        {% endfor %}
+        </ul>
+    <br />
+    {% endif %}
+
+    {% if claimed_tasks %}
+    Tasks claimed but still not assigned to you:<ul>
+        {% for a_task in claimed_tasks %}
+            <li><a href="/task/view/tid={{a_task.uniq_key}}">{{a_task.title}}</a></li>
+        {% endfor %}
+        </ul>
+    <br />
+    {% endif %}
+
+{% endblock %}
--- a/pytask/templates/task/select_user.html	Sun Jan 09 12:01:57 2011 +0530
+++ b/pytask/templates/task/select_user.html	Sun Jan 09 15:01:30 2011 +0530
@@ -1,6 +1,6 @@
 {% extends 'base.html' %}
 {% block content %}
-    <a href="/task/claim/tid={{task.id}}">click here</a> to return to the claims page.<br /><br />
+    <a href="/task/claim/tid={{task.uniq_key}}">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 %}
--- a/pytask/urls.py	Sun Jan 09 12:01:57 2011 +0530
+++ b/pytask/urls.py	Sun Jan 09 15:01:30 2011 +0530
@@ -5,6 +5,7 @@
 import pytask.profile.regbackend
 
 from pytask.profile.forms import CustomRegistrationForm
+from pytask.views import home_page
 
 from django.shortcuts import redirect
 
@@ -33,4 +34,5 @@
     (r'^accounts/', include('registration.urls')),
     (r'^profile/', include('pytask.profile.urls')),
     (r'^task/', include('pytask.taskapp.urls')),
+    (r'^$', home_page),
 )
--- a/pytask/views.py	Sun Jan 09 12:01:57 2011 +0530
+++ b/pytask/views.py	Sun Jan 09 15:01:30 2011 +0530
@@ -7,3 +7,29 @@
                                                'message': message,
                                                'redirect_url': redirect_url,
                                                'url_desc': url_desc})
+
+def home_page(request):
+    """ get the user and display info about the project if not logged in.
+    if logged in, display info of their tasks.
+    """
+
+    user = request.user
+    if not user.is_authenticated():
+        return render_to_response("index.html")
+
+    profile = user.get_profile()
+
+    claimed_tasks = user.claimed_tasks.all()
+    selected_tasks = user.selected_tasks.all()
+    reviewing_tasks = user.reviewing_tasks.all()
+    can_create_task = True if profile.rights != "CT" else False
+
+    context = {"user": user,
+               "profile": profile,
+               "claimed_tasks": claimed_tasks,
+               "selected_tasks": selected_tasks,
+               "reviewing_tasks": reviewing_tasks,
+               "can_create_task": can_create_task
+              }
+
+    return render_to_response("index.html", context)