##// END OF EJS Templates
Added local download links for attachments
neko259 -
r1508:609c3572 decentral
parent child Browse files
Show More
@@ -23,6 +23,8 b" TAG_ATTACHMENTS = 'attachments'"
23 TAG_ATTACHMENT = 'attachment'
23 TAG_ATTACHMENT = 'attachment'
24 TAG_TAGS = 'tags'
24 TAG_TAGS = 'tags'
25 TAG_TAG = 'tag'
25 TAG_TAG = 'tag'
26 TAG_ATTACHMENT_REFS = 'attachment-refs'
27 TAG_ATTACHMENT_REF = 'attachment-ref'
26
28
27 TYPE_GET = 'get'
29 TYPE_GET = 'get'
28
30
@@ -32,6 +34,8 b" ATTR_NAME = 'name'"
32 ATTR_VALUE = 'value'
34 ATTR_VALUE = 'value'
33 ATTR_MIMETYPE = 'mimetype'
35 ATTR_MIMETYPE = 'mimetype'
34 ATTR_KEY = 'key'
36 ATTR_KEY = 'key'
37 ATTR_REF = 'ref'
38 ATTR_URL = 'url'
35
39
36 STATUS_SUCCESS = 'success'
40 STATUS_SUCCESS = 'success'
37
41
@@ -79,16 +83,16 b' class SyncManager:'
79 attachments = post.attachments.all()
83 attachments = post.attachments.all()
80 if len(images) > 0 or len(attachments) > 0:
84 if len(images) > 0 or len(attachments) > 0:
81 attachments_tag = et.SubElement(content_tag, TAG_ATTACHMENTS)
85 attachments_tag = et.SubElement(content_tag, TAG_ATTACHMENTS)
86 attachment_refs = et.SubElement(model, TAG_ATTACHMENT_REFS)
87
82 for image in images:
88 for image in images:
83 mimetype = get_file_mimetype(image.image.file)
89 SyncManager._attachment_to_xml(
84 attachment = et.SubElement(attachments_tag, TAG_ATTACHMENT)
90 attachments_tag, attachment_refs, image.image.file,
85 attachment.set(ATTR_MIMETYPE, mimetype)
91 image.hash, image.image.url)
86 attachment.text = image.hash
87 for file in attachments:
92 for file in attachments:
88 mimetype = get_file_mimetype(file.file.file)
93 SyncManager._attachment_to_xml(
89 attachment = et.SubElement(attachments_tag, TAG_ATTACHMENT)
94 attachments_tag, attachment_refs, file.file.file,
90 attachment.set(ATTR_MIMETYPE, mimetype)
95 file.hash, file.file.url)
91 attachment.text = file.hash
92
96
93 signatures_tag = et.SubElement(model, TAG_SIGNATURES)
97 signatures_tag = et.SubElement(model, TAG_SIGNATURES)
94 post_signatures = post.global_id.signature_set.all()
98 post_signatures = post.global_id.signature_set.all()
@@ -216,3 +220,14 b' class SyncManager:'
216 signatures.append(signature)
220 signatures.append(signature)
217
221
218 return signatures
222 return signatures
223
224 @staticmethod
225 def _attachment_to_xml(tag_attachments, tag_refs, file, hash, url):
226 mimetype = get_file_mimetype(file)
227 attachment = et.SubElement(tag_attachments, TAG_ATTACHMENT)
228 attachment.set(ATTR_MIMETYPE, mimetype)
229 attachment.text = hash
230
231 attachment_ref = et.SubElement(tag_refs, TAG_ATTACHMENT_REF)
232 attachment_ref.set(ATTR_REF, hash)
233 attachment_ref.set(ATTR_URL, url)
General Comments 0
You need to be logged in to leave comments. Login now