diff options
Diffstat (limited to 'taskapp')
-rw-r--r-- | taskapp/events/request.py | 14 | ||||
-rw-r--r-- | taskapp/events/task.py | 38 | ||||
-rw-r--r-- | taskapp/forms/task.py | 4 | ||||
-rw-r--r-- | taskapp/management/commands/seed_db.py | 16 | ||||
-rw-r--r-- | taskapp/models.py | 6 | ||||
-rw-r--r-- | taskapp/utilities/notification.py | 70 | ||||
-rw-r--r-- | taskapp/views/task.py | 112 | ||||
-rw-r--r-- | taskapp/views/user.py | 14 |
8 files changed, 137 insertions, 137 deletions
diff --git a/taskapp/events/request.py b/taskapp/events/request.py index fe2a643..d69f717 100644 --- a/taskapp/events/request.py +++ b/taskapp/events/request.py @@ -1,6 +1,6 @@ from datetime import datetime from pytask.taskapp.models import Profile -from pytask.taskapp.events.task import addMentor +from pytask.taskapp.events.task import addReviewer from pytask.taskapp.events.user import changeRole from pytask.taskapp.utilities.notification import create_notification @@ -33,24 +33,24 @@ def reply_to_request(request_obj, reply, replied_by): task = request_obj.task requested_by = request_obj.sent_by if reply: - ## tell the replied user that he is mentor for this task and give him learn more link + ## tell the replied user that he is reviewer for this task and give him learn more link create_notification("NT", request_obj.replied_by, task=task) ## now check if there are such similar requests and mark them as invalid ## they cannot be of type PY and so we can use the replied_by to get requests pending_requests = replied_by.request_sent_to.filter(is_valid=True, is_replied=False, role="MT",task=task) for req in pending_requests: - create_notification("MT", req.sent_by, replied_by, False, task=req.task, remarks = "User has already accepted one such request and is a mentor.", requested_by = req.sent_by) + create_notification("MT", req.sent_by, replied_by, False, task=req.task, remarks = "User has already accepted one such request and is a reviewer.", requested_by = req.sent_by) req.is_valid = False req.save() - ## alert all the mentors including who made request and all assigned users - for a_mentor in task.mentors.all(): - create_notification(request_obj.role, a_mentor, replied_by, True, task, request_obj.remarks, requested_by) + ## alert all the reviewers including who made request and all assigned users + for a_reviewer in task.reviewers.all(): + create_notification(request_obj.role, a_reviewer, replied_by, True, task, request_obj.remarks, requested_by) for a_user in task.assigned_users.all(): create_notification(request_obj.role, a_user, replied_by, True, task, request_obj.remarks, requested_by) - addMentor(task, request_obj.replied_by) + addReviewer(task, request_obj.replied_by) else: ## tell the requested user that his request was rejected due to these reasons. create_notification(request_obj.role, requested_by, replied_by, False, task, request_obj.remarks, requested_by) diff --git a/taskapp/events/task.py b/taskapp/events/task.py index ff5556f..ef68082 100644 --- a/taskapp/events/task.py +++ b/taskapp/events/task.py @@ -5,7 +5,7 @@ from pytask.taskapp.utilities.request import create_request from pytask.taskapp.utilities.helper import get_key from pytask.taskapp.utilities.notification import create_notification -def publishTask(task, rem_mentors=True, rem_comments=True): +def publishTask(task, rem_reviewers=True, rem_comments=True): """ set the task status to open """ # if task.sub_type == 'D': @@ -19,9 +19,9 @@ def publishTask(task, rem_mentors=True, rem_comments=True): else: task.status = "OP" - if rem_mentors: - task.mentors.clear() - task.mentors.add(task.created_by) + if rem_reviewers: + task.reviewers.clear() + task.reviewers.add(task.created_by) if rem_comments: task.comment_set.update(is_deleted=True) @@ -93,22 +93,22 @@ def addDep(main_task, dependency): main_task.save() -def reqMentor(task, mentor, req_by): +def reqReviewer(task, reviewer, req_by): """ create a request object with role as MT. """ - create_request(sent_by=req_by, role="MT", sent_to=mentor, task=task) + create_request(sent_by=req_by, role="MT", sent_to=reviewer, task=task) -def addMentor(task,mentor): - """ add the mentor to mentors list of the task """ +def addReviewer(task,reviewer): + """ add the reviewer to reviewers list of the task """ - task.mentors.add(mentor) + task.reviewers.add(reviewer) 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. + the creator of the task will be assigned as a reviewer for the task. """ while True: @@ -147,11 +147,11 @@ def addClaim(task, message, user): req.is_valid = False req.save() user_url = '<a href="/user/view/uid=%s">%s</a>'%(user.id, user.username) - reason = "User has claimed the task and hence cannot be a mentor and this request was made invalid." + reason = "User has claimed the task and hence cannot be a reviewer and this request was made invalid." create_notification("MT", req.sent_by, user, task=task, reply=False, remarks=reason, requested_by=req.sent_by) - for a_mentor in task.mentors.all(): - create_notification("CL", a_mentor, user, task=task, remarks=message) + for a_reviewer in task.reviewers.all(): + create_notification("CL", a_reviewer, user, task=task, remarks=message) def assignTask(task, added_user, assigned_by): """ check for the status of task and assign it to the particular user """ @@ -231,8 +231,8 @@ def completeTask(task, marked_by): for a_user in task.claimed_users.all(): create_notification(role="CM", sent_to=a_user, sent_from=marked_by, task=task) - for a_mentor in task.mentors.all(): - create_notification(role="CM", sent_to=a_mentor, sent_from=marked_by, task=task) + for a_reviewer in task.reviewers.all(): + create_notification(role="CM", sent_to=a_reviewer, sent_from=marked_by, task=task) def closeTask(task, closed_by, reason=None): """ set the status of task as CD. @@ -253,8 +253,8 @@ def closeTask(task, closed_by, reason=None): for a_user in task.claimed_users.all(): create_notification(role="CD", sent_to=a_user, sent_from=closed_by, task=task, remarks=reason) - for a_mentor in task.mentors.all(): - create_notification(role="CD", sent_to=a_mentor, sent_from=closed_by, task=task, remarks=reason) + for a_reviewer in task.reviewers.all(): + create_notification(role="CD", sent_to=a_reviewer, sent_from=closed_by, task=task, remarks=reason) def deleteTask(task, deleted_by, reason=None): """ set the task status as DL @@ -267,5 +267,5 @@ def deleteTask(task, deleted_by, reason=None): pending_requests = task.request_task.filter(is_replied=False,is_valid=True) pending_requests.update(is_valid=False) - for a_mentor in task.mentors.exclude(id=deleted_by.id): - create_notification("DL", sent_to=a_mentor, sent_from=deleted_by, task=task, remarks=reason) + for a_reviewer in task.reviewers.exclude(id=deleted_by.id): + create_notification("DL", sent_to=a_reviewer, sent_from=deleted_by, task=task, remarks=reason) diff --git a/taskapp/forms/task.py b/taskapp/forms/task.py index fe949aa..6719f30 100644 --- a/taskapp/forms/task.py +++ b/taskapp/forms/task.py @@ -45,11 +45,11 @@ class EditTaskForm(forms.ModelForm): except Task.DoesNotExist: return data -def AddMentorForm(choices,instance=None): +def AddReviewerForm(choices,instance=None): """ return a form object with appropriate choices """ class myform(forms.Form): - mentor = forms.ChoiceField(choices=choices, required=True) + reviewer = forms.ChoiceField(choices=choices, required=True) form = myform(instance) if instance else myform() return form diff --git a/taskapp/management/commands/seed_db.py b/taskapp/management/commands/seed_db.py index 398f774..c13abda 100644 --- a/taskapp/management/commands/seed_db.py +++ b/taskapp/management/commands/seed_db.py @@ -14,9 +14,9 @@ from pytask.taskapp.utilities.notification import create_notification def seed_db(): """ a method to seed the database with random data """ - defaultMentor = userEvents.createSuUser("admin", "admin@example.com", "123456", datetime.now(), "M") - mentor_profile = defaultMentor.get_profile() - userEvents.updateProfile(mentor_profile, {'rights':"AD"}) + defaultReviewer = userEvents.createSuUser("admin", "admin@example.com", "123456", datetime.now(), "M") + reviewer_profile = defaultReviewer.get_profile() + userEvents.updateProfile(reviewer_profile, {'rights':"AD"}) for i in range(1,21): @@ -29,11 +29,11 @@ def seed_db(): create_notification("NU", user) if i%4==0: - create_request(defaultMentor, "MG", user) + create_request(defaultReviewer, "MG", user) elif i%3==0: - create_request(defaultMentor, "DV", user) + create_request(defaultReviewer, "DV", user) elif i%2==0: - create_request(defaultMentor, "AD", user) + create_request(defaultReviewer, "AD", user) elif i in [7, 13]: user.is_active = False user.save() @@ -42,12 +42,12 @@ def seed_db(): title = "Task "+str(i) desc = "I am "+title - created_by = defaultMentor + created_by = defaultReviewer credits = 20 task = taskEvents.createTask(title,desc,created_by,credits) if task: - taskEvents.addMentor(task, defaultMentor) + taskEvents.addReviewer(task, defaultReviewer) if i%2==0:taskEvents.publishTask(task) class Command(NoArgsCommand): diff --git a/taskapp/models.py b/taskapp/models.py index 19268bf..8df5dc8 100644 --- a/taskapp/models.py +++ b/taskapp/models.py @@ -26,7 +26,7 @@ STATUS_CHOICES = ( ("CM", "Completed")) NOTIFY_CHOICES = ( - ("MT", "Add Mentor"), + ("MT", "Add Reviewer"), ("DV", "Developer"), ("MG", "Manager"), ("AD", "Admin"), @@ -35,7 +35,7 @@ NOTIFY_CHOICES = ( ("CD", "Task closed"), ("DL", "Task deleted"), ("NU", "New User"), - ("NT", "New Mentor"), + ("NT", "New Reviewer"), ("ND", "New Developer"), ("NG", "New Manager"), ("NA", "New Admin"), @@ -97,7 +97,7 @@ class Task(models.Model): credits = models.PositiveSmallIntegerField(help_text = u"No.of credits a user gets on completing the task") progress = models.PositiveSmallIntegerField(default = 0) - mentors = models.ManyToManyField(User, related_name = "%(class)s_mentors") + reviewers = models.ManyToManyField(User, related_name = "%(class)s_reviewers") created_by = models.ForeignKey(User, related_name = "%(class)s_created_by") claimed_users = models.ManyToManyField(User, blank = True, related_name = "%(class)s_claimed_users") assigned_users = models.ManyToManyField(User, blank = True, related_name = "%(class)s_assigned_users") diff --git a/taskapp/utilities/notification.py b/taskapp/utilities/notification.py index eda8e06..da6e6d0 100644 --- a/taskapp/utilities/notification.py +++ b/taskapp/utilities/notification.py @@ -9,12 +9,12 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re sent_to: a user to which the notification is to be sent sent_from : a user from which the message has originated A user who approves/rejects in case of request - A mentor who closes/complets the task + A reviewer who closes/complets the task reply: A boolean task: a task if applicable requested_by: a user makes the request - A mentor who assigns credits in case of pynts - A mentor who requests to act as a mentor + A reviewer who assigns credits in case of pynts + A reviewer who requests to act as a reviewer remarks: any remarks for rejecting receiving_user: user receiving pynts pynts: the obvious @@ -33,18 +33,18 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title) credits_url = '<a href="/task/assigncredits/tid=%s">%s</a>'%(task.id, "click here") - mentor_url = '<a href="/user/view/uid=%s">%s</a>'%(requested_by.id, requested_by.username) + reviewer_url = '<a href="/user/view/uid=%s">%s</a>'%(requested_by.id, requested_by.username) admin_url = '<a href="/user/view/uid=%s">%s</a>'%(sent_from.id, sent_from.username) user_url = '<a href="/user/view/uid=%s">%s</a>'%(receiving_user.id, receiving_user.username) if reply: notification.sub = "Approved request for assign of credits for %s"%task.title[:20] notification.message = """ Request made by %s to assign %s pynts to %s for the task %s has been approved by %s<br /> - %s if you want the view/assign pynts page of the task.<br />"""%(mentor_url, pynts, user_url, task_url, admin_url, credits_url) + %s if you want the view/assign pynts page of the task.<br />"""%(reviewer_url, pynts, user_url, task_url, admin_url, credits_url) else: notification.sub = "Rejected request for assign of credits for %s"%task.title[:20] - notification.message = """ Request made by %s to assign %s pynts to %s for the task %s has been rejected by %s.<br /> """%(mentor_url, pynts, user_url, task_url, admin_url) + notification.message = """ Request made by %s to assign %s pynts to %s for the task %s has been rejected by %s.<br /> """%(reviewer_url, pynts, user_url, task_url, admin_url) if remarks: notification.remarks = remarks notification.message += "Reason: %s<br />"%remarks @@ -56,18 +56,18 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re notification.sent_from = sent_from task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title) - requested_mentor_url = '<a href="/user/view/uid=%s">%s</a>'%(requested_by.id, requested_by.username) - new_mentor = sent_from - new_mentor_url = '<a href="/user/view/uid=%s">%s</a>'%(new_mentor.id, new_mentor.username) + requested_reviewer_url = '<a href="/user/view/uid=%s">%s</a>'%(requested_by.id, requested_by.username) + new_reviewer = sent_from + new_reviewer_url = '<a href="/user/view/uid=%s">%s</a>'%(new_reviewer.id, new_reviewer.username) if reply: - notification.sub = "New mentor for the task %s"%task.title[:20] - notification.message = "%s has accepted the request made by %s, asking him act as a mentor for the task %s<br />"%(new_mentor_url, requested_mentor_url, task_url) - notification.message += "He can be contacted on %s"%new_mentor.email + notification.sub = "New reviewer for the task %s"%task.title[:20] + notification.message = "%s has accepted the request made by %s, asking him act as a reviewer for the task %s<br />"%(new_reviewer_url, requested_reviewer_url, task_url) + notification.message += "He can be contacted on %s"%new_reviewer.email else: - notification.sub = "%s rejected request to act as a mentor"%new_mentor.username - notification.message = "%s has rejected your request asking him to act as a mentor for %s.<br />"%(new_mentor_url, task_url) + notification.sub = "%s rejected request to act as a reviewer"%new_reviewer.username + notification.message = "%s has rejected your request asking him to act as a reviewer for %s.<br />"%(new_reviewer_url, task_url) if remarks: notification.remarks = remarks notification.message += "Remarks: %s<br />"%remarks @@ -95,16 +95,16 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re elif role == "NT": notification.task = task - new_mentor = sent_to - mentor_learn_url = '<sup><a href="/about/mentor/">learn more</a></sup>' + new_reviewer = sent_to + reviewer_learn_url = '<sup><a href="/about/reviewer/">learn more</a></sup>' task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title) - notification.sub = "You are mentoring the task %s"%task.title[:20] - notification.message = "You have accepted to act as a mentor%s for the task %s.<br />"%(mentor_learn_url, task_url) - notification.message += " Here is a list of other mentors and their email addresses.<br /> <ul>" + notification.sub = "You are reviewering the task %s"%task.title[:20] + notification.message = "You have accepted to act as a reviewer%s for the task %s.<br />"%(reviewer_learn_url, task_url) + notification.message += " Here is a list of other reviewers and their email addresses.<br /> <ul>" - for a_mentor in task.mentors.exclude(id=new_mentor.id): - notification.message += "<li> %s - %s </li>"%(a_mentor.username, a_mentor.email) + for a_reviewer in task.reviewers.exclude(id=new_reviewer.id): + notification.message += "<li> %s - %s </li>"%(a_reviewer.username, a_reviewer.email) notification.message += "</ul>" working_users = task.assigned_users.all() @@ -114,7 +114,7 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re for a_user in working_users: notification.message += "<li> %s - %s </li>"%(a_user.username, a_user.email) notification.message += "</ul><br />" - notification.message += "Happy Mentoring." + notification.message += "Happy Reviewering." elif role == "NU": @@ -150,17 +150,17 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re notification.task = task notification.remarks = remarks - mentor = sent_from - mentor_url = '<a href="/user/view/uid=%s">%s</a>'%(mentor.id, mentor.username) + reviewer = sent_from + reviewer_url = '<a href="/user/view/uid=%s">%s</a>'%(reviewer.id, reviewer.username) task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title) if role == "CM": notification.sub = "%s has been marked complete"%task.title - notification.message = "The task %s has been marked complete by %s.<br />"%(task_url, mentor_url) + notification.message = "The task %s has been marked complete by %s.<br />"%(task_url, reviewer_url) elif role == "CD": notification.sub = "%s has been closed"%task.title - notification.message = "The task %s has been closed by %s.<br />"%(task_url, mentor_url) + notification.message = "The task %s has been closed by %s.<br />"%(task_url, reviewer_url) if remarks: notification.remarks = remarks @@ -171,17 +171,17 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re notification.task = task notification.sent_from = sent_from added_user = sent_to - mentor = sent_from - assigned_by_url = '<a href="/user/view/uid=%s">%s</a>'%(mentor.id, mentor.username) + reviewer = sent_from + assigned_by_url = '<a href="/user/view/uid=%s">%s</a>'%(reviewer.id, reviewer.username) task_url= '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title) notification.sub = "Your claim for the task %s accepted."%task.title[:20] notification.message = "You have been selected to work on the task %s by %s.<br />"%(task_url, assigned_by_url) - notification.message += "You can now start working on the task and will be credited by the mentors for your work.<br />" + notification.message += "You can now start working on the task and will be credited by the reviewers for your work.<br />" - notification.message += " Here is a list of mentors for the task and their email addresses.<br /> <ul>" - for a_mentor in task.mentors.all(): - notification.message += "<li> %s - %s </li>"%(a_mentor.username, a_mentor.email) + notification.message += " Here is a list of reviewers for the task and their email addresses.<br /> <ul>" + for a_reviewer in task.reviewers.all(): + notification.message += "<li> %s - %s </li>"%(a_reviewer.username, a_reviewer.email) notification.message += "</ul>" working_users = task.assigned_users.exclude(id=added_user.id) @@ -197,8 +197,8 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re notification.task = task notification.sent_from = sent_from removed_user = sent_to - mentor = sent_from - removed_by_url = '<a href="/user/view/uid=%s">%s</a>'%(mentor.id, mentor.username) + reviewer = sent_from + removed_by_url = '<a href="/user/view/uid=%s">%s</a>'%(reviewer.id, reviewer.username) task_url = '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title) claim_url = '<a href="/task/claim/tid=%s">%s</a>'%(task.id, "clicking here") @@ -233,7 +233,7 @@ def create_notification(role, sent_to, sent_from=None, reply=None, task=None, re task_url = '<a href="/task/view/tid=%s">%s</a>'%(task.id, task.title) notification.sub = 'New claim for the task "%s"'%(task.title[:20]) - notification.message = '%s has submitted a %s for the task "%s" mentored by you.<br />'%(claimed_by_url, claim_url, task_url) + notification.message = '%s has submitted a %s for the task "%s" reviewered by you.<br />'%(claimed_by_url, claim_url, task_url) notification.message += '<b>Claim proposal:</b> %s'%(remarks) diff --git a/taskapp/views/task.py b/taskapp/views/task.py index 472aeb7..2507b73 100644 --- a/taskapp/views/task.py +++ b/taskapp/views/task.py @@ -5,12 +5,12 @@ from django.shortcuts import render_to_response, redirect from pytask.taskapp.models import User, Task, Comment, Request, Notification from pytask.taskapp.utilities.task import getTask -from pytask.taskapp.forms.task import TaskCreateForm, AddMentorForm, AddTaskForm, ChoiceForm, AssignCreditForm, RemoveUserForm, EditTaskForm, ClaimTaskForm -from pytask.taskapp.events.task import createTask, reqMentor, publishTask, addSubTask, addDep, addClaim, assignTask, updateTask, removeTask, removeUser, assignCredits, completeTask, closeTask, addMentor, deleteTask +from pytask.taskapp.forms.task import TaskCreateForm, AddReviewerForm, AddTaskForm, ChoiceForm, AssignCreditForm, RemoveUserForm, EditTaskForm, ClaimTaskForm +from pytask.taskapp.events.task import createTask, reqReviewer, publishTask, addSubTask, addDep, addClaim, assignTask, updateTask, removeTask, removeUser, assignCredits, completeTask, closeTask, addReviewer, deleteTask from pytask.taskapp.views.user import show_msg from pytask.taskapp.utilities.user import get_user -## everywhere if there is no task, django should display 500 message.. but take care of that in sensitive views like add mentor and all +## everywhere if there is no task, django should display 500 message.. but take care of that in sensitive views like add reviewer and all ## do not create su user thro syncdb def browse_tasks(request): @@ -40,7 +40,7 @@ def show_textbooks(request): return render_to_response('task/browse.html', context) def publish_task(request, tid): - """ check if user is the mentor and also if the task status is UP. + """ check if user is the reviewer and also if the task status is UP. """ task_url = "/task/view/tid=%s"%tid @@ -49,7 +49,7 @@ def publish_task(request, tid): task = getTask(tid) is_guest = True if not user.is_authenticated() else False - is_mentor = True if user in task.mentors.all() else False + is_reviewer = True if user in task.reviewers.all() else False if user == task.created_by: context = { @@ -79,41 +79,41 @@ def view_task(request, tid): if task.status == "DL": return show_msg(user, 'This task no longer exists', '/task/browse/','browse the tasks') comments = task.comment_set.filter(is_deleted=False).order_by('creation_datetime') - mentors = task.mentors.all() + reviewers = task.reviewers.all() deps, subs = task.deps, task.subs is_guest = True if not user.is_authenticated() else False - is_mentor = True if user in task.mentors.all() else False + is_reviewer = True if user in task.reviewers.all() else False context = {'user':user, 'task':task, 'comments':comments, - 'mentors':mentors, + 'reviewers':reviewers, 'subs':subs, 'deps':deps, 'is_guest':is_guest, - 'is_mentor':is_mentor, + 'is_reviewer':is_reviewer, } claimed_users = task.claimed_users.all() - is_requested_mentor = True if user.is_authenticated() and user.request_sent_to.filter(is_valid=True,is_replied=False,role="MT",task=task) else False - task_viewable = True if ( task.status != "UP" ) or is_mentor or is_requested_mentor else False + is_requested_reviewer = True if user.is_authenticated() and user.request_sent_to.filter(is_valid=True,is_replied=False,role="MT",task=task) else False + task_viewable = True if ( task.status != "UP" ) or is_reviewer or is_requested_reviewer else False if not task_viewable: return show_msg(user, "You are not authorised to view this task", "/task/browse/", "browse the tasks") - context['is_requested_mentor'] = is_requested_mentor + context['is_requested_reviewer'] = is_requested_reviewer context['can_publish'] = True if task.status == "UP" and user == task.created_by else False - context['can_edit'] = True if task.status == "UP" and is_mentor else False - context['can_close'] = True if task.status not in ["UP", "CD", "CM"] and is_mentor else False + context['can_edit'] = True if task.status == "UP" and is_reviewer else False + context['can_close'] = True if task.status not in ["UP", "CD", "CM"] and is_reviewer else False context['can_delete'] = True if task.status == "UP" and user == task.created_by else False - context['can_mod_mentors'] = True if task.status in ["UP", "OP", "LO", "WR"] and is_mentor else False - context['can_mod_tasks'] = True if task.status in ["UP", "OP", "LO"] and is_mentor else False + context['can_mod_reviewers'] = True if task.status in ["UP", "OP", "LO", "WR"] and is_reviewer else False + context['can_mod_tasks'] = True if task.status in ["UP", "OP", "LO"] and is_reviewer else False - context['can_assign_credits'] = True if task.status in ["OP", "WR"] and is_mentor else False + context['can_assign_credits'] = True if task.status in ["OP", "WR"] and is_reviewer else False context['task_claimable'] = True if task.status in ["OP", "WR"] and not is_guest else False if task.status == "CD": @@ -160,7 +160,7 @@ def create_task(request): #publish = data['publish'] # just in case if we have to show the option task = createTask(title,desc,user,credits) - addMentor(task, user) + addReviewer(task, user) updateTask(task,tags_field=data['tags_field']) # if publish: publishTask(task) task_url = '/task/view/tid=%s'%task.id @@ -175,7 +175,7 @@ def create_task(request): else: return show_msg(user, 'You are not authorised to create a task.', "/", "home page") -def add_mentor(request, tid): +def add_reviewer(request, tid): """ check if the current user has the rights to edit the task and add him. if user is not authenticated, redirect him to concerned page. """ @@ -187,15 +187,15 @@ def add_mentor(request, tid): is_guest = True if not user.is_authenticated() else False - if (not is_guest) and user in task.mentors.all(): + if (not is_guest) and user in task.reviewers.all(): pending_requests = Request.objects.filter(is_replied=False,is_valid=True,role="MT",task=task).order_by('creation_date').reverse() user_pending_requests = pending_requests.filter(sent_by=user) ## now iam going for a brute force method user_list = list(User.objects.filter(is_active=True)) - for mentor in task.mentors.all(): - user_list.remove(mentor) + for reviewer in task.reviewers.all(): + user_list.remove(reviewer) for a_user in task.claimed_users.all(): user_list.remove(a_user) @@ -206,11 +206,11 @@ def add_mentor(request, tid): for req in user_pending_requests: user_list.remove(req.sent_to.all()[0]) - non_mentors = ((_.id, _.username) for _ in user_list) - non_mentor_ids = [ str(a_user.id) for a_user in user_list ] + non_reviewers = ((_.id, _.username) for _ in user_list) + non_reviewer_ids = [ str(a_user.id) for a_user in user_list ] ## code till must be made elegant and not brute force like above - form = AddMentorForm(non_mentors) + form = AddReviewerForm(non_reviewers) context = { 'user':user, @@ -221,18 +221,18 @@ def add_mentor(request, tid): if request.method == "POST": data = request.POST - uid = data.get('mentor', None) - if uid in non_mentor_ids: - new_mentor = User.objects.get(id=int(uid)) - reqMentor(task, new_mentor, user) - return redirect('/task/addmentor/tid=%s'%task.id) + uid = data.get('reviewer', None) + if uid in non_reviewer_ids: + new_reviewer = User.objects.get(id=int(uid)) + reqReviewer(task, new_reviewer, user) + return redirect('/task/addreviewer/tid=%s'%task.id) else: ## bogus post request raise Http404 else: - return render_to_response('task/addmentor.html', context) + return render_to_response('task/addreviewer.html', context) else: - return show_msg(user, 'You are not authorised to add mentors for this task', task_url, 'view the task') + return show_msg(user, 'You are not authorised to add reviewers for this task', task_url, 'view the task') def add_tasks(request, tid): """ first display tasks which can be subtasks for the task and do the rest. @@ -257,7 +257,7 @@ def add_tasks(request, tid): is_guest = True if not user.is_authenticated() else False - if (not is_guest) and user in task.mentors.all(): + if (not is_guest) and user in task.reviewers.all(): if task.status in ["UP", "OP", "LO"]: form = AddTaskForm(task_choices, is_plain) if request.method == "POST": @@ -304,7 +304,7 @@ def remove_task(request, tid): task = getTask(tid) is_guest = True if not user.is_authenticated() else False - if (not is_guest) and user in task.mentors.all(): + if (not is_guest) and user in task.reviewers.all(): if task.status in ["UP", "LO", "OP"]: @@ -362,19 +362,19 @@ def claim_task(request, tid): # this is what the next line should be when i re sync the db claims = Notification.objects.filter(task=task, sent_to=task.created_by, role="CL") - mentors = task.mentors.all() + reviewers = task.reviewers.all() claimed_users = task.claimed_users.all() assigned_users = task.assigned_users.all() is_guest = True if not user.is_authenticated() else False - is_mentor = True if user in mentors else False + is_reviewer = True if user in reviewers else False task_claimable = True if task.status in ["OP", "WR"] else False - user_can_claim = True if task_claimable and not ( is_guest or is_mentor ) and ( user not in claimed_users ) and ( user not in assigned_users ) else False + user_can_claim = True if task_claimable and not ( is_guest or is_reviewer ) and ( user not in claimed_users ) and ( user not in assigned_users ) else False task_claimed = True if claimed_users else False context = {'user':user, - 'is_mentor':is_mentor, + 'is_reviewer':is_reviewer, 'task':task, 'claims':claims, 'user_can_claim':user_can_claim, @@ -409,9 +409,9 @@ def rem_user(request, tid): task = getTask(tid) is_guest = True if not user.is_authenticated() else False - is_mentor = True if user in task.mentors.all() else False + is_reviewer = True if user in task.reviewers.all() else False - if (not is_guest) and is_mentor: + if (not is_guest) and is_reviewer: assigned_users = task.assigned_users.all() choices = [ (_.id,_.username) for _ in assigned_users ] @@ -457,14 +457,14 @@ def assign_task(request, tid): task = getTask(tid) is_guest = True if not user.is_authenticated() else False - is_mentor = True if user in task.mentors.all() else False + is_reviewer = True if user in task.reviewers.all() else False claimed_users = task.claimed_users.all() assigned_users = task.assigned_users.all() task_claimed = True if claimed_users else False - if (not is_guest) and is_mentor: + if (not is_guest) and is_reviewer: if task.status in ["OP", "WR"]: if task_claimed: user_list = ((user.id,user.username) for user in claimed_users) @@ -487,10 +487,10 @@ def assign_task(request, tid): return show_msg(user, 'You are not authorised to perform this action', task_url, 'view the task') def assign_credits(request, tid): - """ Check if the user is a mentor and credits can be assigned. + """ Check if the user is a reviewer and credits can be assigned. Then display all the approved credits. - Then see if mentor can assign credits to users also or only mentors. - Then put up a form for mentor to assign credits accordingly. + Then see if reviewer can assign credits to users also or only reviewers. + Then put up a form for reviewer to assign credits accordingly. """ task_url = "/task/view/tid=%s"%tid @@ -499,16 +499,16 @@ def assign_credits(request, tid): task = getTask(tid) ## the moment we see that user had requested credits, it means he had worked and hence we change the status to WR - ## we have to discuss on this since, credits may also be given to mentor + ## we have to discuss on this since, credits may also be given to reviewer task.status = "WR" task.save() is_guest = True if not user.is_authenticated() else False - is_mentor = True if (not is_guest) and user in task.mentors.all() else False + is_reviewer = True if (not is_guest) and user in task.reviewers.all() else False - if is_mentor: + if is_reviewer: if task.status in ["OP", "WR"]: - choices = [(_.id,_.username) for _ in task.mentors.all()] + choices = [(_.id,_.username) for _ in task.reviewers.all()] if task.status == "WR": choices.extend([(_.id, _.username) for _ in task.assigned_users.all() ]) prev_credits = task.request_task.filter(role="PY",is_valid=True,is_replied=True,reply=True).count() @@ -553,8 +553,8 @@ def edit_task(request, tid): task_url = "/task/view/tid=%s"%tid user = get_user(request.user) if request.user.is_authenticated() else request.user - is_mentor = True if user in task.mentors.all() else False - can_edit = True if is_mentor and task.status == "UP" else False + is_reviewer = True if user in task.reviewers.all() else False + can_edit = True if is_reviewer and task.status == "UP" else False if can_edit: form = EditTaskForm(instance=task) @@ -582,7 +582,7 @@ def complete_task(request, tid): task = getTask(tid) is_guest = True if not user.is_authenticated() else False - is_mentor = True if user in task.mentors.all() else False + is_reviewer = True if user in task.reviewers.all() else False claimed_users = task.claimed_users.all() assigned_users = task.assigned_users.all() @@ -591,7 +591,7 @@ def complete_task(request, tid): task_assigned_credits = task.credit_set.all() - if is_mentor: + if is_reviewer: if task.status in ["OP", "WR"]: context = { @@ -623,9 +623,9 @@ def close_task(request, tid): task = getTask(tid) is_guest = True if not user.is_authenticated() else False - is_mentor = True if user in task.mentors.all() else False + is_reviewer = True if user in task.reviewers.all() else False - if is_mentor: + if is_reviewer: context = { 'user':user, @@ -650,7 +650,7 @@ def close_task(request, tid): def delete_task(request, tid): """ mark the task status as DL. - take a reason from the user and pass on to all the other mentors. + take a reason from the user and pass on to all the other reviewers. """ task_url = "/task/view/tid=%s"%tid diff --git a/taskapp/views/user.py b/taskapp/views/user.py index 1ad0c20..153e9dd 100644 --- a/taskapp/views/user.py +++ b/taskapp/views/user.py @@ -17,8 +17,8 @@ from pytask.taskapp.utilities.notification import get_notification, create_notif from pytask.taskapp.utilities.user import get_user about = { - "addmentors": "about/addmentors.html", - "mentor": "about/mentor.html", + "addreviewers": "about/addreviewers.html", + "reviewer": "about/reviewer.html", "starthere": "about/starthere.html", "task": "about/task.html", "tasklife": "about/tasklife.html", @@ -39,7 +39,7 @@ def homepage(request): user = request.user is_guest = False - is_mentor = False + is_reviewer = False can_create_task = False task_list = [] @@ -52,18 +52,18 @@ def homepage(request): else: user = get_user(request.user) user_profile = user.get_profile() - is_mentor = True if user.task_mentors.all() else False + is_reviewer = True if user.task_reviewers.all() else False can_create_task = False if user_profile.rights == u"CT" else True context = {'user':user, 'is_guest':is_guest, - 'is_mentor':is_mentor, + 'is_reviewer':is_reviewer, 'task_list':task_list, 'can_create_task':can_create_task, } - context["unpublished_tasks"] = user.task_mentors.filter(status="UP") - context["mentored_tasks"] = user.task_mentors.exclude(status="UP").exclude(status="CM").exclude(status="CD").exclude(status="DL") + context["unpublished_tasks"] = user.task_reviewers.filter(status="UP") + context["reviewered_tasks"] = user.task_reviewers.exclude(status="UP").exclude(status="CM").exclude(status="CD").exclude(status="DL") context["claimed_tasks"] = user.task_claimed_users.exclude(status="UP").exclude(status="CM").exclude(status="CD").exclude(status="DL") context["working_tasks"] = user.task_assigned_users.filter(status="WR") |