# HG changeset patch # User nishanth # Date 1265004686 -19800 # Node ID c6038cbf8a3990c4cddebec3c019ca9d3d4d928a # Parent f2623fb8041a2c50d986e41f4d42ecd68d4db6ab addded link to view claims in 'view task' page . diff -r f2623fb8041a -r c6038cbf8a39 pytask/taskapp/admin.py --- a/pytask/taskapp/admin.py Mon Feb 01 11:10:29 2010 +0530 +++ b/pytask/taskapp/admin.py Mon Feb 01 11:41:26 2010 +0530 @@ -1,8 +1,9 @@ from django.contrib import admin -from pytask.taskapp.models import Profile, Task, Credit, Comment +from pytask.taskapp.models import Profile, Task, Credit, Comment, Claim admin.site.register(Profile) admin.site.register(Task) admin.site.register(Comment) admin.site.register(Credit) +admin.site.register(Claim) diff -r f2623fb8041a -r c6038cbf8a39 pytask/taskapp/forms/task.py --- a/pytask/taskapp/forms/task.py Mon Feb 01 11:10:29 2010 +0530 +++ b/pytask/taskapp/forms/task.py Mon Feb 01 11:41:26 2010 +0530 @@ -1,5 +1,5 @@ from django import forms -from pytask.taskapp.models import Task +from pytask.taskapp.models import Task, Claim class TaskCreateForm(forms.ModelForm): class Meta: @@ -15,7 +15,7 @@ form = myform(instance=instance) if instance else myform() return form -def ClaimTaskForm(models.ModelForm): +class ClaimTaskForm(forms.ModelForm): class Meta: model = Claim fields = ['message'] diff -r f2623fb8041a -r c6038cbf8a39 pytask/taskapp/models.py --- a/pytask/taskapp/models.py Mon Feb 01 11:10:29 2010 +0530 +++ b/pytask/taskapp/models.py Mon Feb 01 11:41:26 2010 +0530 @@ -14,7 +14,7 @@ ("LO", "Locked"), ("CL", "Claimed"), ("AS", "Assigned"), - ("RO", "Reopened"), + ("RE", "Reopened"), ("CD", "Closed"), ("DL", "Deleted"), ("CM", "Completed")) diff -r f2623fb8041a -r c6038cbf8a39 pytask/taskapp/views/task.py --- a/pytask/taskapp/views/task.py Mon Feb 01 11:10:29 2010 +0530 +++ b/pytask/taskapp/views/task.py Mon Feb 01 11:41:26 2010 +0530 @@ -3,7 +3,7 @@ from django.http import HttpResponse from django.shortcuts import render_to_response, redirect -from pytask.taskapp.models import User, Task, Comment +from pytask.taskapp.models import User, Task, Comment, Claim from pytask.taskapp.forms.task import TaskCreateForm, AddMentorForm from pytask.taskapp.events.task import createTask, addMentor, publishTask, addSubTask from pytask.taskapp.views.user import show_msg @@ -38,12 +38,16 @@ is_guest = True if not user.is_authenticated() else False is_mentor = True if user in task.mentors.all() else False + task_claimable = True if task.status in ["OP", "RE"] else False + user_can_view_claim = True if ( task_claimable and not ( is_guest or is_mentor ) ) else False + context = {'user':user, 'task':task, 'comments':comments, 'mentors':mentors, 'is_guest':is_guest, 'is_mentor':is_mentor, + 'user_can_view_claim':user_can_view_claim, 'errors':errors, } @@ -171,10 +175,22 @@ user = request.user task = Task.objects.get(id=tid) + claims = Claim.objects.filter(task=task) + + is_guest = True if not user.is_authenticated() else False + + task_claimable = True if task.status in ["OP", "RE"] else False + user_can_claim = True if ( task_claimable and not ( is_guest or is_mentor ) and ( user not in task.claimed_users.all() ) ) else False + + if not is_guest: + if task_claimable: + pass + else: + return show_msg('You are not logged in to view claims for this task', task_url, 'view the task') + else: + return show_msg('You are not logged in to view claims for this task', task_url, 'view the task') - - diff -r f2623fb8041a -r c6038cbf8a39 pytask/templates/task/view.html --- a/pytask/templates/task/view.html Mon Feb 01 11:10:29 2010 +0530 +++ b/pytask/templates/task/view.html Mon Feb 01 11:41:26 2010 +0530 @@ -20,7 +20,11 @@
{{ task.desc }}

status of task is {{task.status}}
- view claims goes here depending on availability of claim
+ {% if user_can_view_claim %} + View claims
+ view claims goes here depending on availability of claim
+ {% endif %} + {% if comments %}
comments:
{% for comment in comments %} diff -r f2623fb8041a -r c6038cbf8a39 pytask/urls.py --- a/pytask/urls.py Mon Feb 01 11:10:29 2010 +0530 +++ b/pytask/urls.py Mon Feb 01 11:41:26 2010 +0530 @@ -5,7 +5,7 @@ admin.autodiscover() from pytask.taskapp.views.user import homepage, register, user_login, user_logout -from pytask.taskapp.views.task import browse_tasks, view_task, create_task, add_mentor, add_tasks +from pytask.taskapp.views.task import browse_tasks, view_task, create_task, add_mentor, add_tasks, claim_task urlpatterns = patterns('', # Example: @@ -21,6 +21,7 @@ (r'^task/create/$', create_task), (r'^task/addmentor/tid=(\d+)', add_mentor), (r'^task/addtasks/tid=(\d+)', add_tasks), + (r'^task/claim/tid=(\d+)', claim_task), (r'^admin/', include(admin.site.urls)),