# Path: pytask/helpers/exceptions.py
# DEFAULT_ERROR_MESSAGE = ugettext(
#   "There was some error in your request.")
# DEFAULT_LOGIN_MESSAGE = ugettext(
#   "You have to login to view this page.")
# class PyTaskException(Exception):
# class UnauthorizedAccess(PyTaskException):
#     def __init__(self, message=None, **response_args):
#     def __init__(self, message=None, **response_args):
# 
# Path: pytask/views.py
# def show_msg(user, message, redirect_url=None, url_desc=None):
#     """ simply redirect to homepage """
# 
#     context = {
#       'user': user,
#       'message': message,
#       'redirect_url': redirect_url,
#       'url_desc': url_desc
#     }
# 
#     return render_to_response('show_msg.html', context)
# 
# Path: pytask/profile/models.py
# GENDER_CHOICES = (
#   ('Male', 'Male'),
#   ('Female', 'Female'),
# )
# ROLES_CHOICES = (
#   ("Administrator", "Administrator"),
#   ("Coordinator", "Coordinator"),
#   ("Mentor", "Mentor"),
#   ("Contributor", "Contributor"),
# )
# ROLE_CHOICES = (
#   ("Administrator", "Request sent by Administrator \
#     to a user at lower level, asking him to act as a administrator"),
#   ("Coordinator", "Request sent by Coordinator \
#     to a user at lower level, asking him to act as a coordinator"),
# )
# class Profile(models.Model):
# class Notification(models.Model):
# class RoleRequest(models.Model):
#     def __unicode__(self):
# 
# Path: pytask/taskapp/forms.py
# class CreateTaskForm(forms.ModelForm):
#     class Meta:
# class EditTaskForm(forms.ModelForm):
#     class Meta:
# class TaskCommentForm(forms.ModelForm):
#     class Meta:
# class ClaimTaskForm(forms.ModelForm):
#     class Meta:
#     class myform(forms.Form):
# class CreateTextbookForm(forms.ModelForm):
#     class Meta:
# class CreateChapterForm(forms.ModelForm):
#     class Meta:
# class EditTextbookForm(forms.ModelForm):
#     class Meta:
#     class myForm(forms.Form):
#     class myForm(forms.Form):
#     class myForm(forms.Form):
# class WorkReportForm(forms.ModelForm):
#     class Meta:
#     def clean_title(self):
#     def clean_desc(self):
#     def clean_tags_field(self):
#     def clean_desc(self):
#     def clean_title(self):
#     def clean_tags_field(self):
#     def clean_data(self):
#     def clean_proposal(self):
# def ChoiceForm(choices, data=None, label="choice"):
#     def clean_tags_field(self):
#     def clean_tags_field(self):
#     def clean_tags_field(self):
# def AddTaskForm(task_choices, is_plain=False):
# def AssignPyntForm(choices, instance=None):
# def RemoveUserForm(choices, instance=None):
# 
# Path: pytask/taskapp/models.py
# TASK_STATUS_CHOICES = (
#         ("Unpublished", "Unpublished"),
#         ("Open", "Open"),
#         ("Locked", "Locked"),
#         ("Working", "Working"),
#         ("Closed", "Closed"),
#         ("Deleted", "Deleted"),
#         ("Completed", "Completed"))
# TB_STATUS_CHOICES = (
#     ("Unpublished", "Unpublished"),
#     ("Open", "Open"),
#     ("All tasks have users selected", "All tasks have users selected"),
#     ("Completed", "Completed"))
# UPLOADS_DIR = "/pytask/static/uploads"
# class Task(models.Model):
# class TaskComment(models.Model):
# class TaskClaim(models.Model):
# class WorkReport(models.Model):
# class ReportComment(models.Model):
# class PyntRequest(models.Model):
# class TextBook(models.Model):
#     def __unicode__(self):
#     def __unicode__(self):
#     def __unicode__(self):


from datetime import datetime
from django import shortcuts
from django import http
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core.context_processors import csrf
from django.core.urlresolvers import reverse
from django.template import RequestContext
from django.utils import simplejson as json
from django.utils.translation import ugettext
from tagging.models import Tag
from tagging.models import TaggedItem
from pytask.helpers import exceptions
from pytask.views import show_msg
from pytask.profile import models as profile_models
from pytask.taskapp import forms as taskapp_forms
from pytask.taskapp import models as taskapp_models

    context.update({"profile": profile})
    return shortcuts.render_to_response("task/view_report.html",
                                        RequestContext(request, context))

@login_required
def submit_report(request, task_id):
    """ Check if the work is in WR state and the user is in assigned_users.
    """
    task_url = reverse('view_task', kwargs={'task_id': task_id})
    task = shortcuts.get_object_or_404(taskapp_models.Task, pk=task_id)

    user = request.user
    old_reports = task.reports.all()

    if not task.status == taskapp_models.TASK_STATUS_CHOICES[3][0]:
        raise http.Http404

    can_upload = True if user in task.selected_users.all() else False

    context = {
        'user': user,
        'task': task,
        'can_upload': can_upload,
    }

    context.update(csrf(request))

    if request.method == "POST":
        if not can_upload:

# Path: pytask/helpers/exceptions.py
# DEFAULT_ERROR_MESSAGE = ugettext(
#   "There was some error in your request.")
# DEFAULT_LOGIN_MESSAGE = ugettext(
#   "You have to login to view this page.")
# class PyTaskException(Exception):
# class UnauthorizedAccess(PyTaskException):
#     def __init__(self, message=None, **response_args):
#     def __init__(self, message=None, **response_args):
# 
# Path: pytask/views.py
# def show_msg(user, message, redirect_url=None, url_desc=None):
#     """ simply redirect to homepage """
# 
#     context = {
#       'user': user,
#       'message': message,
#       'redirect_url': redirect_url,
#       'url_desc': url_desc
#     }
# 
#     return render_to_response('show_msg.html', context)
# 
# Path: pytask/profile/models.py
# GENDER_CHOICES = (
#   ('Male', 'Male'),
#   ('Female', 'Female'),
# )
# ROLES_CHOICES = (
#   ("Administrator", "Administrator"),
#   ("Coordinator", "Coordinator"),
#   ("Mentor", "Mentor"),
#   ("Contributor", "Contributor"),
# )
# ROLE_CHOICES = (
#   ("Administrator", "Request sent by Administrator \
#     to a user at lower level, asking him to act as a administrator"),
#   ("Coordinator", "Request sent by Coordinator \
#     to a user at lower level, asking him to act as a coordinator"),
# )
# class Profile(models.Model):
# class Notification(models.Model):
# class RoleRequest(models.Model):
#     def __unicode__(self):
# 
# Path: pytask/taskapp/forms.py
# class CreateTaskForm(forms.ModelForm):
#     class Meta:
# class EditTaskForm(forms.ModelForm):
#     class Meta:
# class TaskCommentForm(forms.ModelForm):
#     class Meta:
# class ClaimTaskForm(forms.ModelForm):
#     class Meta:
#     class myform(forms.Form):
# class CreateTextbookForm(forms.ModelForm):
#     class Meta:
# class CreateChapterForm(forms.ModelForm):
#     class Meta:
# class EditTextbookForm(forms.ModelForm):
#     class Meta:
#     class myForm(forms.Form):
#     class myForm(forms.Form):
#     class myForm(forms.Form):
# class WorkReportForm(forms.ModelForm):
#     class Meta:
#     def clean_title(self):
#     def clean_desc(self):
#     def clean_tags_field(self):
#     def clean_desc(self):
#     def clean_title(self):
#     def clean_tags_field(self):
#     def clean_data(self):
#     def clean_proposal(self):
# def ChoiceForm(choices, data=None, label="choice"):
#     def clean_tags_field(self):
#     def clean_tags_field(self):
#     def clean_tags_field(self):
# def AddTaskForm(task_choices, is_plain=False):
# def AssignPyntForm(choices, instance=None):
# def RemoveUserForm(choices, instance=None):
# 
# Path: pytask/taskapp/models.py
# TASK_STATUS_CHOICES = (
#         ("Unpublished", "Unpublished"),
#         ("Open", "Open"),
#         ("Locked", "Locked"),
#         ("Working", "Working"),
#         ("Closed", "Closed"),
#         ("Deleted", "Deleted"),
#         ("Completed", "Completed"))
# TB_STATUS_CHOICES = (
#     ("Unpublished", "Unpublished"),
#     ("Open", "Open"),
#     ("All tasks have users selected", "All tasks have users selected"),
#     ("Completed", "Completed"))
# UPLOADS_DIR = "/pytask/static/uploads"
# class Task(models.Model):
# class TaskComment(models.Model):
# class TaskClaim(models.Model):
# class WorkReport(models.Model):
# class ReportComment(models.Model):
# class PyntRequest(models.Model):
# class TextBook(models.Model):
#     def __unicode__(self):
#     def __unicode__(self):
#     def __unicode__(self):


# Path: pytask/taskapp/views/task.py
from datetime import datetime
from django import shortcuts
from django import http
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core.context_processors import csrf
from django.core.urlresolvers import reverse
from django.template import RequestContext
from django.utils import simplejson as json
from django.utils.translation import ugettext
from tagging.models import Tag
from tagging.models import TaggedItem
from pytask.helpers import exceptions
from pytask.views import show_msg
from pytask.profile import models as profile_models
from pytask.taskapp import forms as taskapp_forms
from pytask.taskapp import models as taskapp_models


    context.update({"profile": profile})
    return shortcuts.render_to_response("task/view_report.html",
                                        RequestContext(request, context))

@login_required
def submit_report(request, task_id):
    """ Check if the work is in WR state and the user is in assigned_users.
    """
    task_url = reverse('view_task', kwargs={'task_id': task_id})
    task = shortcuts.get_object_or_404(taskapp_models.Task, pk=task_id)

    user = request.user
    old_reports = task.reports.all()

    if not task.status == taskapp_models.TASK_STATUS_CHOICES[3][0]:
        raise http.Http404

    can_upload = True if user in task.selected_users.all() else False

    context = {
        'user': user,
        'task': task,
        'can_upload': can_upload,
    }

    context.update(csrf(request))

    if request.method == "POST":
        if not can_upload:

            return show_msg(user, "You are not authorised to upload data to this task", task_url, "view the task")