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