Revision 9efd0075 snf-astakos-app/astakos/im/templatetags/astakos_tags.py
b/snf-astakos-app/astakos/im/templatetags/astakos_tags.py | ||
---|---|---|
177 | 177 |
|
178 | 178 |
|
179 | 179 |
@register.simple_tag |
180 |
def get_grant_value(rname, form): |
|
181 |
grants = form.instance.grants |
|
182 |
try: |
|
183 |
r = form.instance.projectresourcegrant_set.get( |
|
184 |
resource__name=rname).member_capacity |
|
185 |
except Exception, e: |
|
186 |
r = '' |
|
187 |
return r |
|
180 |
def get_grant_value(rname, project_or_app, for_project=True): |
|
181 |
if not project_or_app: |
|
182 |
return None |
|
183 |
resource_set = project_or_app.grants |
|
184 |
r = resource_set.get(resource__name=rname) |
|
185 |
if for_project: |
|
186 |
return r.project_capacity |
|
187 |
else: |
|
188 |
return r.member_capacity |
|
188 | 189 |
|
189 | 190 |
|
190 | 191 |
@register.tag(name="provider_login_url") |
... | ... | |
233 | 234 |
'project ?'), |
234 | 235 |
'project_join': _('Are you sure you want to join this project ?'), |
235 | 236 |
'project_leave': _('Are you sure you want to leave from the project ?'), |
237 |
'project_cancel_member': _('Are you sure you want to cancel your join request ?'), |
|
236 | 238 |
} |
237 | 239 |
|
238 | 240 |
|
... | ... | |
250 | 252 |
if isinstance(urlarg, basestring) and "," in urlarg: |
251 | 253 |
args = urlarg.split(",") |
252 | 254 |
for index, arg in enumerate(args): |
255 |
property = None |
|
256 |
if "." in arg: |
|
257 |
arg, property = arg.split(".") |
|
253 | 258 |
if context.get(arg, None) is not None: |
254 |
args[index] = context.get(arg) |
|
259 |
val = context.get(arg) |
|
260 |
if property: |
|
261 |
val = getattr(val, property) |
|
262 |
args[index] = val |
|
255 | 263 |
urlargs = args |
256 | 264 |
else: |
257 | 265 |
urlargs = (urlarg,) |
Also available in: Unified diff