def __unicode__(self):
return u""
+ def __str__(self):
+ return ""
+
def valuetype(val):
valuetype = "string"
elif isinstance(value, (int, float, Decimal)):
kwargs['valuetype'] = "float"
kwargs['value'] = float(value)
- elif type(value) == type(None):
+ elif type(value) == type(None) or isinstance(value, Separator):
kwargs['stringvalue'] = u""
else:
kwargs['stringvalue'] = unicode(value)
verticalalign=kwargs['verticalalign'], wrapoption='wrap'))
del kwargs['verticalalign']
- if isinstance(value, Separator):
+ if isinstance(value, Separator) or type(value) == type(Separator()):
style.addElement(odf.style.TableCellProperties(
backgroundcolor='#D3D3D3'))
import urllib
from datetime import date
from itertools import izip
+import StringIO
import pygraphviz as pgv
from django import forms
from django.contrib.auth.decorators import login_required
from django.contrib.admin import widgets as adminwidgets
+from django.core.servers.basehttp import FileWrapper
from datamaster_modeles import models as ref
masse = MasseSalariale(date_debut, date_fin, custom_filter,
request.GET.get('ne_pas_grouper', False))
if masse.rapport:
- c['rapport'] = masse.rapport
- c['header_keys'] = [h[0] for h in masse.headers]
- #on enleve le background pour le header
- for h in (h for h in masse.headers if 'background-color' in h[2]):
- h[2]['background'] = 'none'
- h = SortHeaders(request, masse.headers, order_field_type="ot",
- not_sortable=c['header_keys'], order_field="o")
- c['headers'] = list(h.headers())
- for key, nom, opts in masse.headers:
- c['headers']
- c['total'] = masse.grand_totaux[0]
- c['total_euro'] = masse.grand_totaux[1]
- c['colspan'] = len(c['header_keys']) - 1
+ if request.GET.get('ods'):
+ for h in (h for h in masse.headers if 'background-color' in h[2]):
+ del h[2]['background-color']
+ masse.ods()
+ output = StringIO.StringIO()
+ masse.doc.save(output)
+ output.seek(0)
+
+ response = HttpResponse(FileWrapper(output), content_type=
+ 'application/vnd.oasis.opendocument.spreadsheet')
+ response['Content-Disposition'] = \
+ 'attachment; filename=Masse Salariale %s.ods' % \
+ masse.annee
+ return response
+ else:
+ c['rapport'] = masse.rapport
+ c['header_keys'] = [h[0] for h in masse.headers]
+ #on enleve le background pour le header
+ for h in (h for h in masse.headers if 'background-color' in h[2]):
+ h[2]['background'] = 'none'
+ h = SortHeaders(request, masse.headers, order_field_type="ot",
+ not_sortable=c['header_keys'], order_field="o")
+ c['headers'] = list(h.headers())
+ for key, nom, opts in masse.headers:
+ c['headers']
+ c['total'] = masse.grand_totaux[0]
+ c['total_euro'] = masse.grand_totaux[1]
+ c['colspan'] = len(c['header_keys']) - 1
+ get_filtre.append(('ods', True))
+ query_string = urllib.urlencode(get_filtre)
+ c['url_ods'] = "%s?%s" % (
+ reverse('rhr_masse_salariale'), query_string)
return render_to_response('rh/rapports/masse_salariale.html', c, RequestContext(request))