added events/task.py and templates/error.html
authornishanth
Sat, 30 Jan 2010 13:04:58 +0530
changeset 12 c823b42970a4
parent 11 d28fcc644fbb
child 13 4da58abdf6ff
added events/task.py and templates/error.html
pytask/taskapp/events/task.py
pytask/templates/error.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pytask/taskapp/events/task.py	Sat Jan 30 13:04:58 2010 +0530
@@ -0,0 +1,34 @@
+from datetime import datetime
+from pytask.taskapp.models import Profile, Task, Comment, Credit
+
+def publishTask(task):
+    """ set the task status to open """
+    
+    task.status = "OP"
+    task.save()
+    return task
+
+def addMentor(task,mentor):
+    """ add the mentor to mentors list of the task """
+    
+    task.mentors.add(mentor)
+    task.save()
+    return task    
+    
+def createTask(title,desc,created_by,credits):
+    """ creates a bare minimum task with title, description and credits.
+    the creator of the task will be assigned as a mentor for the task.
+    """
+
+    try:
+        task = Task.objects.get(title=title)
+        return None
+    except Task.DoesNotExist:
+        task = Task(title=title)
+    task.desc = desc
+    task.created_by = created_by
+    task.credits = credits
+    task.creation_datetime = datetime.now()
+    task.save()
+    return task
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pytask/templates/error.html	Sat Jan 30 13:04:58 2010 +0530
@@ -0,0 +1,7 @@
+{% extends 'base.html' %}
+{% block content %}
+    {% if error_msg %}
+    {{error_msg}}<br />
+    <a href="/">click here</a> to return to Homepage
+    {% endif %}
+{% endblock %}