Fix XML generation

This commit is contained in:
Théophile Bastian 2018-02-26 16:59:18 +01:00
parent 9dd1954067
commit 185c1cf8a4

View file

@ -43,9 +43,9 @@ class HistoryEntry(models.Model):
def to_xml(self, xml_root):
entry = ET.Element('history')
entry_url = ET.Element('url')
entry_url.text = self.search
entry_url.text = str(self.search)
entry_ts = ET.Element('timestamp')
entry_ts.text = self.timestamp.timestamp()
entry_ts.text = str(self.timestamp.timestamp())
entry.append(entry_url)
entry.append(entry_ts)
xml_root.append(entry)
@ -125,9 +125,9 @@ class History(models.Model):
xml_root = ET.Element('root')
hist_node = ET.Element("history", attrib={
'start-ts': self.start_ts,
'played': 1 if self.played else 0,
'user': self.user.pk,
'start-ts': str(self.start_ts),
'played': '1' if self.played else '0',
'user': str(self.user.pk),
})
xml_root.append(hist_node)
for entry in self.historyentry_set.all():