This is a snapshot of Indico's old Trac site. Any information contained herein is most probably outdated. Access our new GitHub site here.

Ticket #289: materials.diff

File materials.diff, 2.0 KB (added by pferreir, 6 years ago)

This patch introduces a slightly different behavior

Line 
1diff --git a/indico/MaKaC/common/output.py b/indico/MaKaC/common/output.py
2index 78656e7..d1a6ea8 100644
3--- a/indico/MaKaC/common/output.py
4+++ b/indico/MaKaC/common/output.py
5@@ -735,7 +735,8 @@ class outputGenerator:
6         if len(mat.getResourceList()) > 0:
7             out.openTag("files")
8             for res in mat.getResourceList():
9-                try:
10+                # if the material is a local file, check the file type
11+                if isinstance(res, conference.LocalFile):
12                     type = res.getFileType().lower()
13                     if type=="pdf":
14                         pdfs.append(res)
15@@ -757,10 +758,11 @@ class outputGenerator:
16                         out.writeTag("type",res.getFileType().lower())
17                         out.writeTag("url",vars["resourceURLGen"](res))
18                         out.closeTag("file")
19-                except:
20+                else:
21+                    # else, just add as a link
22                     links.append(res)
23             out.closeTag("files")
24-            if not len(pdfs) > 1 and not len(docs) > 1 and not len(ppts) > 1 and not len(odps) > 1 and not len(odts) > 1 and not len(odss) > 1 and len(others) == 0 and not len(links) > 1:
25+            if not len(pdfs) > 1 and not len(docs) > 1 and not len(ppts) > 1 and not len(odps) > 1 and not len(odts) > 1 and not len(odss) > 1:
26                 if vars:
27                     if len(pdfs)==1:
28                         out.writeTag("pdf",vars["resourceURLGen"](pdfs[0]))
29@@ -774,8 +776,8 @@ class outputGenerator:
30                         out.writeTag("odt",vars["resourceURLGen"](odts[0]))
31                     if len(odss)==1:
32                         out.writeTag("ods",vars["resourceURLGen"](odss[0]))
33-                if len(links)==1:
34-                    out.writeTag("link",str(links[0].getURL()))
35+            if len(links)==1:
36+                out.writeTag("link",str(links[0].getURL()))
37         if mat.isItselfProtected():
38             out.writeTag("locked","yes")
39         out.closeTag("material")