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 template tag library containing GHOP forms helpers. |
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 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
28 |
register = template.Library() |
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 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
31 |
@register.inclusion_tag( |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
32 |
'modules/ghop/templatetags/_as_filter_multiselect.html') |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
33 |
def as_filter_multiselect(label, value): |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
34 |
"""Prints a field value and it's verbose name as a form multiple select . |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
35 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
36 |
Args: |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
37 |
label: label of the field to render |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
38 |
value: value of the field to render |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
39 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
40 |
Returns: |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
41 |
a simple context containing the supplied newforms field instance: |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
42 |
{ 'field_label': field_label', |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
43 |
'field_value': field_value'} |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
44 |
""" |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
45 |
|
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
46 |
return {'field_label': label, |
93e1f2bcfef0
Added templatetag and filter libraries for GHOP.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
47 |
'field_value': value} |