author | Madhusudan.C.S <madhusudancs@gmail.com> |
Tue, 08 Sep 2009 21:08:14 +0200 | |
changeset 2889 | 5c0728efdefb |
parent 2838 | 93e1f2bcfef0 |
permissions | -rw-r--r-- |
2838
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
2 |
# |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
4 |
# |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
8 |
# |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
10 |
# |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
16 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
17 |
"""A Django filter library for GHOP. |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
18 |
""" |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
19 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
21 |
'"Madhusudan.C.S" <madhusudancs@gmail.com>', |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
22 |
] |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
23 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
24 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
25 |
from django import template |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
26 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
27 |
from soc.modules.ghop.logic.models import task as ghop_task_logic |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
28 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
29 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
30 |
register = template.Library() |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
31 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
32 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
33 |
@register.filter() |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
34 |
def open_tasks(org): |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
35 |
"""Django template filter to get the number of open tasks for the given |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
36 |
organization. |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
37 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
38 |
Args: |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
39 |
org: The organization entity for which the number of open tasks much be |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
40 |
returned |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
41 |
""" |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
42 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
43 |
filter = { |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
44 |
'scope':org, |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
45 |
'status': ['Open', 'Reopened'], |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
46 |
} |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
47 |
task_entities = ghop_task_logic.logic.getForFields(filter) |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
48 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
49 |
return str(len(task_entities)) |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
50 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
51 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
52 |
@register.filter() |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
53 |
def claimed_tasks(org): |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
54 |
"""Django template filter to get the number of claimed tasks for the given |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
55 |
organization. |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
56 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
57 |
Args: |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
58 |
org: The organization entity for which the number of claimed tasks much be |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
59 |
returned |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
60 |
""" |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
61 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
62 |
filter = { |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
63 |
'scope':org, |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
64 |
'status': ['ClaimRequested', 'Claimed', 'ActionNeeded', |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
65 |
'NeedsReview', 'NeedsWork'] |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
66 |
} |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
67 |
task_entities = ghop_task_logic.logic.getForFields(filter) |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
68 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
69 |
return str(len(task_entities)) |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
70 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
71 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
72 |
@register.filter() |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
73 |
def closed_tasks(org): |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
74 |
"""Django template filter to get the number of closed tasks for the given |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
75 |
organization. |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
76 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
77 |
Args: |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
78 |
org: The organization entity for which the number of closed tasks much be |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
79 |
returned |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
80 |
""" |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
81 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
82 |
filter = { |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
83 |
'scope':org, |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
84 |
'status': ['AwaitingRegistration', 'Closed'] |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
85 |
} |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
86 |
task_entities = ghop_task_logic.logic.getForFields(filter) |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
87 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
88 |
return str(len(task_entities)) |