VC: Fix error on clone page for legacy-ID events
[cds-indico.git] / indico / MaKaC / posterDesignConf.py
blob62bfcadea3243310059059bcef7fe46ee43122a5
1 # This file is part of Indico.
2 # Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
4 # Indico is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
9 # Indico is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Indico; if not, see <http://www.gnu.org/licenses/>.
17 from MaKaC.registration import Registrant
18 from conference import Conference
19 from poster import PosterTemplateItem
20 from MaKaC.webinterface.common.countries import CountryHolder
23 class ConferenceDates:
25 def getArgumentType(cls):
26 return Conference
27 getArgumentType = classmethod (getArgumentType)
29 def getValue(cls, conf):
30 if conf.getStartDate().date() == conf.getEndDate().date():
31 return conf.getAdjustedStartDate().strftime("%a %d/%m/%Y %H:%M")
32 else:
33 return str(conf.getAdjustedStartDate().date()) + ' - ' + str(conf.getAdjustedEndDate().date())
34 getValue = classmethod (getValue)
36 class ConferenceLocation:
38 def getArgumentType(cls):
39 return Conference
40 getArgumentType = classmethod (getArgumentType)
42 def getValue(cls, conf):
43 return conf.getLocation().getName() if conf.getLocation() else ""
44 getValue = classmethod (getValue)
47 class ConferenceAddress:
49 def getArgumentType(cls):
50 return Conference
51 getArgumentType = classmethod (getArgumentType)
53 def getValue(cls, conf):
54 return conf.getLocation().getAddress() if conf.getLocation() else ""
55 getValue = classmethod (getValue)
57 class LectureCategory:
58 def getArgumentType(cls):
59 return Conference
60 getArgumentType = classmethod (getArgumentType)
62 def getValue(cls, conf):
63 return conf.getOwner().getTitle()
64 getValue = classmethod (getValue)
66 class Organisers:
67 def getArgumentType(cls):
68 return Conference
69 getArgumentType = classmethod (getArgumentType)
71 def getValue(cls, conf):
72 return conf.getOrgText()
73 getValue = classmethod (getValue)
75 class ConferenceRoom:
76 def getArgumentType(cls):
77 return Conference
78 getArgumentType = classmethod (getArgumentType)
80 def getValue(cls, conf):
81 if conf.getRoom():
82 return conf.getRoom().getName()
83 else:
84 return ""
85 getValue = classmethod (getValue)
87 class ConferenceChairperson:
88 def getArgumentType(cls):
89 return Conference
90 getArgumentType = classmethod (getArgumentType)
92 def getValue(cls, conf):
93 list = conf.getChairList()
94 return list
96 getValue = classmethod (getValue)
99 class PosterDesignConfiguration:
100 """ This class has 2 objects:
101 -items_actions maps the name of an item to the action that should be taken
102 at the time it is drawed.
103 -groups organizes the item names into groups. These groups are used for the
104 <select> box in the WConfModifPosterDesign.tpl file.
107 """ Dictionary that maps the name of an item to the action that should be taken
108 at the time it is drawed.
109 An action can be:
110 -A method: depending on the class owning the method, a Conference object,
111 a Registrant object, or a PosterTemplateItem object should be passed to the method.
112 The method must return a string.
113 For example: 'Full Name' : Registrant.getFullName means that, if a posterTemplate
114 has a 'Full Name' item, each time a poster will be drawed, the Full Name of the
115 registrant will be drawed as returned by the method getFullName of the class Registrant.
116 -A class: when there is no method already available for what we need, we have
117 to write a custom class (see classes above).
118 These classes must have 2 methods:
119 *it must have a getArgumentType() method, which returns either Conference, Registrant or PosterTemplateItem.
120 Depending on what is returned, we will pass a different object to the getValue() method.
121 *it must have a getValue(object) method, to which a Conference instance, a Registrant instance or a
122 PosterTemplateItem instance must be passed, depending on the result of the getArgumentType() method.
125 def __init__(self):
127 self.items_actions = {
128 "Lecture Category": (_("Lecture Category"), LectureCategory),
129 "Lecture Name": (_("Lecture Name"), Conference.getTitle),
130 "Lecture Date(s)": (_("Lecture Date(s)"), ConferenceDates),
131 "Speaker(s)": (_("Speaker(s)"), ConferenceChairperson),
132 "Description": (_("Description"), Conference.getDescription),
133 "Location (name)": (_("Location (name)"), ConferenceLocation),
134 "Location (address)": (_("Location (address)"), ConferenceAddress),
135 "Location (room)": (_("Location (room)"), ConferenceRoom),
136 "Organisers": (_("Organisers"), Organisers),
137 "Fixed Text": (_("Fixed Text"), PosterTemplateItem.getFixedText)
140 """ Dictionary that maps group names to the item names that fall into that group.
141 The groups are only used for the <select> box in the WConfModifPosterDesign.tpl file.
143 self.groups = [( _("Lecture Data"), ["Lecture Category", "Lecture Name", "Lecture Date(s)","Speaker(s)",
144 "Description", "Location (name)", "Location (address)", "Location (room)","Organisers"]),
145 ( _("Fixed Elements"), ["Fixed Text"])]