author | Madhusudan.C.S <madhusudancs@gmail.com> |
Fri, 04 Feb 2011 16:36:00 +0530 | |
changeset 555 | 20fe9db8bc81 |
parent 447 | b7faad734d6f |
permissions | -rw-r--r-- |
338 | 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 | 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 | 7 |
def show_msg(user, message, redirect_url=None, url_desc=None): |
8 |
""" simply redirect to homepage """ |
|
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") |