mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-06-30 22:30:14 +02:00
* Added i18n hooks, eg _() and {% trans %} tags around all helpdesk-generated
text to assist with future translation efforts. I've no doubt missed a few. Also we don't have a "Change Language" view in here, unsure if this should be a helpdesk function or a function of the parent project. * Updated svn:ignore to ignore .pyc files * Added new function to replace cursor.dictfetchall() which is available in psycopg1 but not psycopg2. New function should work across other database systems, but is untested.
This commit is contained in:
17
lib.py
17
lib.py
@ -184,3 +184,20 @@ def bar_chart(data):
|
||||
chart_url += '&chxl=0:|%s|1:|0|%s' % ('|'.join(column_headings), max) # Axis Label Text
|
||||
|
||||
return chart_url
|
||||
|
||||
def query_to_dict(results, descriptions):
|
||||
""" Replacement method for cursor.dictfetchall() as that method no longer
|
||||
exists in psycopg2, and I'm guessing in other backends too.
|
||||
|
||||
Converts the results of a raw SQL query into a list of dictionaries, suitable
|
||||
for use in templates etc. """
|
||||
output = []
|
||||
for data in results:
|
||||
row = {}
|
||||
i = 0
|
||||
for column in descriptions:
|
||||
row[column[0]] = data[i]
|
||||
i += 1
|
||||
|
||||
output.append(row)
|
||||
return output
|
||||
|
Reference in New Issue
Block a user