pytask/views.py
author Nishanth Amuluru <nishanth@fossee.in>
Sun, 09 Jan 2011 15:30:06 +0530
changeset 127 32457bce3437
parent 125 9b0812962133
child 129 13e171f09941
permissions -rw-r--r--
prettified a few pages
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
100
5a96ddc5e04a added view for show_msg
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     1
from django.shortcuts import render_to_response
5a96ddc5e04a added view for show_msg
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     2
5a96ddc5e04a added view for show_msg
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     3
def show_msg(user, message, redirect_url=None, url_desc=None):
5a96ddc5e04a added view for show_msg
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     4
    """ simply redirect to homepage """
5a96ddc5e04a added view for show_msg
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     5
5a96ddc5e04a added view for show_msg
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     6
    return render_to_response('show_msg.html',{'user': user,
5a96ddc5e04a added view for show_msg
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     7
                                               'message': message,
5a96ddc5e04a added view for show_msg
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     8
                                               'redirect_url': redirect_url,
5a96ddc5e04a added view for show_msg
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     9
                                               'url_desc': url_desc})
125
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    10
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    11
def home_page(request):
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    12
    """ get the user and display info about the project if not logged in.
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    13
    if logged in, display info of their tasks.
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    14
    """
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    15
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    16
    user = request.user
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    17
    if not user.is_authenticated():
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    18
        return render_to_response("index.html")
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    19
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    20
    profile = user.get_profile()
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    21
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    22
    claimed_tasks = user.claimed_tasks.all()
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    23
    selected_tasks = user.selected_tasks.all()
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    24
    reviewing_tasks = user.reviewing_tasks.all()
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    25
    can_create_task = True if profile.rights != "CT" else False
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    26
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    27
    context = {"user": user,
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    28
               "profile": profile,
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    29
               "claimed_tasks": claimed_tasks,
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    30
               "selected_tasks": selected_tasks,
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    31
               "reviewing_tasks": reviewing_tasks,
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    32
               "can_create_task": can_create_task
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    33
              }
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    34
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    35
    return render_to_response("index.html", context)