diff options
author | Joey Hagedorn <hagedorn@mcs.anl.gov> | 2006-11-22 21:18:05 +0000 |
---|---|---|
committer | Joey Hagedorn <hagedorn@mcs.anl.gov> | 2006-11-22 21:18:05 +0000 |
commit | c57c79a36f1e4d2b66ef7f01bc0a82ef7d5996e8 (patch) | |
tree | 139b14f96b8baa53dc837c0402113475f00b75b4 /src/lib/Server/Reports/reports/templatetags | |
parent | ebf644b4c820244aad5019b5540ddac9401109de (diff) | |
download | bcfg2-c57c79a36f1e4d2b66ef7f01bc0a82ef7d5996e8.tar.gz bcfg2-c57c79a36f1e4d2b66ef7f01bc0a82ef7d5996e8.tar.bz2 bcfg2-c57c79a36f1e4d2b66ef7f01bc0a82ef7d5996e8.zip |
finishing move
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2521 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Reports/reports/templatetags')
-rw-r--r-- | src/lib/Server/Reports/reports/templatetags/__init__.py | 0 | ||||
-rw-r--r-- | src/lib/Server/Reports/reports/templatetags/django_templating_sigh.py | 40 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/lib/Server/Reports/reports/templatetags/__init__.py b/src/lib/Server/Reports/reports/templatetags/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/lib/Server/Reports/reports/templatetags/__init__.py diff --git a/src/lib/Server/Reports/reports/templatetags/django_templating_sigh.py b/src/lib/Server/Reports/reports/templatetags/django_templating_sigh.py new file mode 100644 index 000000000..85f4d61a2 --- /dev/null +++ b/src/lib/Server/Reports/reports/templatetags/django_templating_sigh.py @@ -0,0 +1,40 @@ +from django import template +#from brpt.reports.models import Client, Interaction, Bad, Modified, Extra + +register = template.Library() + +def set_interaction(parser, token): + try: + # Splitting by None == splitting by spaces. + tag_name, format_string = token.contents.split(None, 1) + except ValueError: + raise template.TemplateSyntaxError, "%r tag requires an argument" % token.contents[0] + if not (format_string[0] == format_string[-1] and format_string[0] in ('"', "'")): + raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name + return SetInteraction(format_string[1:-1]) + +def sortwell(value): + "sorts a list(or evaluates queryset to list) of bad, extra, or modified items in the best way for presentation" + configItems = list(value) + configItems.sort(lambda x,y: cmp(x.name, y.name)) + configItems.sort(lambda x,y: cmp(x.kind, y.kind)) + return configItems +def sortname(value): + "sorts a list( or evaluates queryset) by name" + configItems = list(value) + configItems.sort(lambda x,y: cmp(x.name, y.name)) + return configItems + +class SetInteraction(template.Node): + def __init__(self, times): + self.times = times#do soemthing to select different interaction with host? + def render(self, context): + try: + context['interaction'] = context['client_interaction_dict'][context['client'].id] + except:#I don't fully know what the implications of this are. + pass + return '' + +register.tag('set_interaction', set_interaction) +register.filter('sortwell', sortwell) +register.filter('sortname', sortname) |