Show More
@@ -61,8 +61,20 b' class SyncManager:' | |||||
61 |
|
61 | |||
62 | global_id = post.global_id |
|
62 | global_id = post.global_id | |
63 |
|
63 | |||
|
64 | images = post.images.all() | |||
|
65 | attachments = post.attachments.all() | |||
64 | if global_id.content: |
|
66 | if global_id.content: | |
65 | model.append(et.fromstring(global_id.content)) |
|
67 | model.append(et.fromstring(global_id.content)) | |
|
68 | if len(images) > 0 or len(attachments) > 0: | |||
|
69 | attachment_refs = et.SubElement(model, TAG_ATTACHMENT_REFS) | |||
|
70 | for image in images: | |||
|
71 | SyncManager._attachment_to_xml( | |||
|
72 | None, attachment_refs, image.image.file, | |||
|
73 | image.hash, image.image.url) | |||
|
74 | for file in attachments: | |||
|
75 | SyncManager._attachment_to_xml( | |||
|
76 | None, attachment_refs, file.file.file, | |||
|
77 | file.hash, file.file.url) | |||
66 | else: |
|
78 | else: | |
67 | content_tag = et.SubElement(model, TAG_CONTENT) |
|
79 | content_tag = et.SubElement(model, TAG_CONTENT) | |
68 |
|
80 | |||
@@ -89,8 +101,6 b' class SyncManager:' | |||||
89 | pub_time = et.SubElement(content_tag, TAG_PUB_TIME) |
|
101 | pub_time = et.SubElement(content_tag, TAG_PUB_TIME) | |
90 | pub_time.text = str(post.get_pub_time_str()) |
|
102 | pub_time.text = str(post.get_pub_time_str()) | |
91 |
|
103 | |||
92 | images = post.images.all() |
|
|||
93 | attachments = post.attachments.all() |
|
|||
94 | if len(images) > 0 or len(attachments) > 0: |
|
104 | if len(images) > 0 or len(attachments) > 0: | |
95 | attachments_tag = et.SubElement(content_tag, TAG_ATTACHMENTS) |
|
105 | attachments_tag = et.SubElement(content_tag, TAG_ATTACHMENTS) | |
96 | attachment_refs = et.SubElement(model, TAG_ATTACHMENT_REFS) |
|
106 | attachment_refs = et.SubElement(model, TAG_ATTACHMENT_REFS) | |
@@ -248,10 +258,11 b' class SyncManager:' | |||||
248 |
|
258 | |||
249 | @staticmethod |
|
259 | @staticmethod | |
250 | def _attachment_to_xml(tag_attachments, tag_refs, file, hash, url): |
|
260 | def _attachment_to_xml(tag_attachments, tag_refs, file, hash, url): | |
251 | mimetype = get_file_mimetype(file) |
|
261 | if tag_attachments is not None: | |
252 | attachment = et.SubElement(tag_attachments, TAG_ATTACHMENT) |
|
262 | mimetype = get_file_mimetype(file) | |
253 | attachment.set(ATTR_MIMETYPE, mimetype) |
|
263 | attachment = et.SubElement(tag_attachments, TAG_ATTACHMENT) | |
254 | attachment.text = hash |
|
264 | attachment.set(ATTR_MIMETYPE, mimetype) | |
|
265 | attachment.text = hash | |||
255 |
|
266 | |||
256 | attachment_ref = et.SubElement(tag_refs, TAG_ATTACHMENT_REF) |
|
267 | attachment_ref = et.SubElement(tag_refs, TAG_ATTACHMENT_REF) | |
257 | attachment_ref.set(ATTR_REF, hash) |
|
268 | attachment_ref.set(ATTR_REF, hash) |
General Comments 0
You need to be logged in to leave comments.
Login now