pytask/views.py
author Madhusudan.C.S <madhusudancs@gmail.com>
Fri, 28 Jan 2011 02:27:40 +0530
changeset 519 84709567f47a
parent 447 b7faad734d6f
permissions -rw-r--r--
Use the release version of South than the latest version. South is very critical for our application. So don't take any risk with the users data. Use the release version.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
338
5a96ddc5e04a added view for show_msg
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     1
from django.shortcuts import render_to_response
447
b7faad734d6f Replaces all occurences of context with RequestContext.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 442
diff changeset
     2
from django.template import RequestContext
338
5a96ddc5e04a added view for show_msg
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     3
442
7e6da295b90a Use the right name for the profile role's values.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 369
diff changeset
     4
from pytask.profile import models as profile_models
7e6da295b90a Use the right name for the profile role's values.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 369
diff changeset
     5
7e6da295b90a Use the right name for the profile role's values.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 369
diff changeset
     6
338
5a96ddc5e04a added view for show_msg
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     7
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
     8
    """ simply redirect to homepage """
5a96ddc5e04a added view for show_msg
Nishanth Amuluru <nishanth@fossee.in>
parents:
diff changeset
     9
447
b7faad734d6f Replaces all occurences of context with RequestContext.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 442
diff changeset
    10
    context = {
b7faad734d6f Replaces all occurences of context with RequestContext.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 442
diff changeset
    11
      'user': user,
b7faad734d6f Replaces all occurences of context with RequestContext.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 442
diff changeset
    12
      'message': message,
b7faad734d6f Replaces all occurences of context with RequestContext.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 442
diff changeset
    13
      'redirect_url': redirect_url,
b7faad734d6f Replaces all occurences of context with RequestContext.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 442
diff changeset
    14
      'url_desc': url_desc
b7faad734d6f Replaces all occurences of context with RequestContext.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 442
diff changeset
    15
    }
b7faad734d6f Replaces all occurences of context with RequestContext.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 442
diff changeset
    16
b7faad734d6f Replaces all occurences of context with RequestContext.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 442
diff changeset
    17
    return render_to_response('show_msg.html', context)
363
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    18
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    19
def home_page(request):
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    20
    """ get the user and display info about the project if not logged in.
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    21
    if logged in, display info of their tasks.
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    22
    """
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    23
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    24
    user = request.user
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    25
    if not user.is_authenticated():
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    26
        return render_to_response("index.html")
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    27
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    28
    profile = user.get_profile()
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    29
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    30
    claimed_tasks = user.claimed_tasks.all()
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    31
    selected_tasks = user.selected_tasks.all()
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    32
    reviewing_tasks = user.reviewing_tasks.all()
367
13e171f09941 added unpublished tasks to home_page
Nishanth Amuluru <nishanth@fossee.in>
parents: 363
diff changeset
    33
    unpublished_tasks = user.created_tasks.filter(status="UP").all()
442
7e6da295b90a Use the right name for the profile role's values.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 369
diff changeset
    34
    can_create_task = True if profile.role != profile_models.ROLES_CHOICES[3][0] else False
363
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    35
447
b7faad734d6f Replaces all occurences of context with RequestContext.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 442
diff changeset
    36
    context = {"profile": profile,
363
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    37
               "claimed_tasks": claimed_tasks,
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    38
               "selected_tasks": selected_tasks,
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    39
               "reviewing_tasks": reviewing_tasks,
367
13e171f09941 added unpublished tasks to home_page
Nishanth Amuluru <nishanth@fossee.in>
parents: 363
diff changeset
    40
               "unpublished_tasks": unpublished_tasks,
363
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    41
               "can_create_task": can_create_task
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    42
              }
9b0812962133 created the home page
Nishanth Amuluru <nishanth@fossee.in>
parents: 338
diff changeset
    43
447
b7faad734d6f Replaces all occurences of context with RequestContext.
Madhusudan.C.S <madhusudancs@gmail.com>
parents: 442
diff changeset
    44
    return render_to_response("index.html", RequestContext(request, context))
369
602a909e9e16 added under_construction view and used it
Nishanth Amuluru <nishanth@fossee.in>
parents: 367
diff changeset
    45
602a909e9e16 added under_construction view and used it
Nishanth Amuluru <nishanth@fossee.in>
parents: 367
diff changeset
    46
def under_construction(request):
602a909e9e16 added under_construction view and used it
Nishanth Amuluru <nishanth@fossee.in>
parents: 367
diff changeset
    47
602a909e9e16 added under_construction view and used it
Nishanth Amuluru <nishanth@fossee.in>
parents: 367
diff changeset
    48
    return render_to_response("under_construction.html")