diff options
-rwxr-xr-x | pytask/taskapp/views.py | 1 | ||||
-rw-r--r-- | pytask/templates/404.html | 5 | ||||
-rw-r--r-- | pytask/templates/index.html | 54 | ||||
-rw-r--r-- | pytask/templates/task/select_user.html | 2 | ||||
-rwxr-xr-x | pytask/urls.py | 2 | ||||
-rw-r--r-- | pytask/views.py | 26 |
6 files changed, 89 insertions, 1 deletions
diff --git a/pytask/taskapp/views.py b/pytask/taskapp/views.py index af0848f..f26fd69 100755 --- a/pytask/taskapp/views.py +++ b/pytask/taskapp/views.py @@ -245,6 +245,7 @@ def select_user(request, tid): task.selected_users.add(selected_user) task.claimed_users.remove(selected_user) + task.status = "WR" task.save() return redirect(task_url) diff --git a/pytask/templates/404.html b/pytask/templates/404.html new file mode 100644 index 0000000..d65d1a7 --- /dev/null +++ b/pytask/templates/404.html @@ -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 %} diff --git a/pytask/templates/index.html b/pytask/templates/index.html new file mode 100644 index 0000000..d3cbbf6 --- /dev/null +++ b/pytask/templates/index.html @@ -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 %} diff --git a/pytask/templates/task/select_user.html b/pytask/templates/task/select_user.html index 369e630..04d1d43 100644 --- a/pytask/templates/task/select_user.html +++ b/pytask/templates/task/select_user.html @@ -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 %} diff --git a/pytask/urls.py b/pytask/urls.py index e0d6911..18f9c51 100755 --- a/pytask/urls.py +++ b/pytask/urls.py @@ -5,6 +5,7 @@ from registration.backends.default import DefaultBackend 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 @@ urlpatterns = patterns('', (r'^accounts/', include('registration.urls')), (r'^profile/', include('pytask.profile.urls')), (r'^task/', include('pytask.taskapp.urls')), + (r'^$', home_page), ) diff --git a/pytask/views.py b/pytask/views.py index a2b5d1b..ab1c745 100644 --- a/pytask/views.py +++ b/pytask/views.py @@ -7,3 +7,29 @@ def show_msg(user, message, redirect_url=None, url_desc=None): '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) |