pytask/views.py
author Nishanth Amuluru <nishanth@fossee.in>
Wed, 12 Jan 2011 00:22:27 +0530
changeset 149 32dd15eaf9d0
parent 131 602a909e9e16
permissions -rw-r--r--
fixed a bug where guest users were not able to view the page correctly
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()
129
13e171f09941 added unpublished tasks to home_page
Nishanth Amuluru <nishanth@fossee.in>
parents: 125
diff changeset
    25
    unpublished_tasks = user.created_tasks.filter(status="UP").all()
125
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    26
    can_create_task = True if profile.rights != "CT" else False
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    27
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    28
    context = {"user": user,
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    29
               "profile": profile,
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    30
               "claimed_tasks": claimed_tasks,
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    31
               "selected_tasks": selected_tasks,
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    32
               "reviewing_tasks": reviewing_tasks,
129
13e171f09941 added unpublished tasks to home_page
Nishanth Amuluru <nishanth@fossee.in>
parents: 125
diff changeset
    33
               "unpublished_tasks": unpublished_tasks,
125
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    34
               "can_create_task": can_create_task
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    35
              }
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    36
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 100
diff changeset
    37
    return render_to_response("index.html", context)
131
602a909e9e16 added under_construction view and used it
Nishanth Amuluru <nishanth@fossee.in>
parents: 129
diff changeset
    38
602a909e9e16 added under_construction view and used it
Nishanth Amuluru <nishanth@fossee.in>
parents: 129
diff changeset
    39
def under_construction(request):
602a909e9e16 added under_construction view and used it
Nishanth Amuluru <nishanth@fossee.in>
parents: 129
diff changeset
    40
602a909e9e16 added under_construction view and used it
Nishanth Amuluru <nishanth@fossee.in>
parents: 129
diff changeset
    41
    return render_to_response("under_construction.html")