| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | ## |
|---|
| 3 | ## |
|---|
| 4 | ## This file is part of CDS Indico. |
|---|
| 5 | ## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN. |
|---|
| 6 | ## |
|---|
| 7 | ## CDS Indico is free software; you can redistribute it and/or |
|---|
| 8 | ## modify it under the terms of the GNU General Public License as |
|---|
| 9 | ## published by the Free Software Foundation; either version 2 of the |
|---|
| 10 | ## License, or (at your option) any later version. |
|---|
| 11 | ## |
|---|
| 12 | ## CDS Indico is distributed in the hope that it will be useful, but |
|---|
| 13 | ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 15 | ## General Public License for more details. |
|---|
| 16 | ## |
|---|
| 17 | ## You should have received a copy of the GNU General Public License |
|---|
| 18 | ## along with CDS Indico; if not, write to the Free Software Foundation, Inc., |
|---|
| 19 | ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 20 | |
|---|
| 21 | import math |
|---|
| 22 | from datetime import timedelta |
|---|
| 23 | import MaKaC.webinterface.pages.registrationForm as registrationForm |
|---|
| 24 | import MaKaC.webinterface.urlHandlers as urlHandlers |
|---|
| 25 | import MaKaC.common.filters as filters |
|---|
| 26 | from MaKaC.webinterface import wcomponents |
|---|
| 27 | from xml.sax.saxutils import quoteattr |
|---|
| 28 | from MaKaC.webinterface.pages.conferences import WPConferenceModifBase, WPConferenceDefaultDisplayBase |
|---|
| 29 | from MaKaC.common import Config |
|---|
| 30 | from MaKaC.webinterface.common.countries import CountryHolder |
|---|
| 31 | from MaKaC.webinterface.common.person_titles import TitlesRegistry |
|---|
| 32 | from MaKaC.webinterface.common.registrantNotificator import EmailNotificator |
|---|
| 33 | from MaKaC import registration |
|---|
| 34 | from conferences import WConfModifBadgePDFOptions |
|---|
| 35 | from MaKaC.i18n import _ |
|---|
| 36 | from indico.util.i18n import i18nformat |
|---|
| 37 | from xml.sax.saxutils import escape |
|---|
| 38 | import string |
|---|
| 39 | |
|---|
| 40 | # ----------------- MANAGEMENT AREA --------------------------- |
|---|
| 41 | class WPConfModifRegistrantListBase( registrationForm.WPConfModifRegFormBase ): |
|---|
| 42 | |
|---|
| 43 | def _setActiveTab( self ): |
|---|
| 44 | self._tabRegistrants.setActive() |
|---|
| 45 | |
|---|
| 46 | class WPConfModifRegistrantList( WPConfModifRegistrantListBase ): |
|---|
| 47 | def __init__( self, rh, conference, filterUsed = False ): |
|---|
| 48 | WPConfModifRegistrantListBase.__init__(self, rh, conference) |
|---|
| 49 | self._filterUsed = filterUsed |
|---|
| 50 | |
|---|
| 51 | def _getTabContent( self, params ): |
|---|
| 52 | filterCrit=params.get("filterCrit",None) |
|---|
| 53 | sortingCrit=params.get("sortingCrit",None) |
|---|
| 54 | display = params.get("display",None) |
|---|
| 55 | order = params.get("order",None) |
|---|
| 56 | sessionFilterName=params.get("sessionFilterName", "session") |
|---|
| 57 | websession = self._rh._getSession() |
|---|
| 58 | |
|---|
| 59 | filterParams = {} |
|---|
| 60 | fields = getattr(filterCrit, '_fields') |
|---|
| 61 | for field in fields.values(): |
|---|
| 62 | id = field.getId() |
|---|
| 63 | showNoValue = field.getShowNoValue() |
|---|
| 64 | values = field.getValues() |
|---|
| 65 | if showNoValue: |
|---|
| 66 | filterParams['%sShowNoValue' % id] = '--none--' |
|---|
| 67 | filterParams[id] = values |
|---|
| 68 | |
|---|
| 69 | requestParams = self._rh.getRequestParams() |
|---|
| 70 | |
|---|
| 71 | operationType = requestParams.get('operationType') |
|---|
| 72 | if operationType != 'resetFilters': |
|---|
| 73 | operationType = 'filter' |
|---|
| 74 | urlParams = dict(isBookmark='y', operationType=operationType) |
|---|
| 75 | |
|---|
| 76 | urlParams.update(self._rh.getRequestParams()) |
|---|
| 77 | if not requestParams.has_key('disp'): |
|---|
| 78 | urlParams['disp'] = display |
|---|
| 79 | urlParams.update(filterParams) |
|---|
| 80 | filterUrl = self._rh._uh.getURL(None, **urlParams) |
|---|
| 81 | |
|---|
| 82 | wc = WConfModifRegistrants(self._conf, filterCrit, sortingCrit, display, websession, filterUrl, order, sessionFilterName, self._filterUsed) |
|---|
| 83 | return wc.getHTML() |
|---|
| 84 | |
|---|
| 85 | class WConfModifRegistrants( wcomponents.WTemplated ): |
|---|
| 86 | |
|---|
| 87 | def __init__( self, conference,filterCrit, sortingCrit, display, websession, filterUrl, order="down", sessionFilterName="session", filterUsed = False ): |
|---|
| 88 | |
|---|
| 89 | self._conf = conference |
|---|
| 90 | self._filterCrit = filterCrit |
|---|
| 91 | self._sortingCrit = sortingCrit |
|---|
| 92 | self._order = order |
|---|
| 93 | self._sessionFilterName = sessionFilterName |
|---|
| 94 | self._filterUrl = filterUrl |
|---|
| 95 | self._display = display |
|---|
| 96 | self._filterUsed = filterUsed |
|---|
| 97 | self._setDispOpts() |
|---|
| 98 | self._setStatusesOpts() |
|---|
| 99 | |
|---|
| 100 | def _setStatusesOpts(self): |
|---|
| 101 | """ |
|---|
| 102 | """ |
|---|
| 103 | self._statuses = {} |
|---|
| 104 | for st in self._conf.getRegistrationForm().getStatusesList(False): |
|---|
| 105 | self._statuses[st.getId()] = st.getStatusValues() |
|---|
| 106 | |
|---|
| 107 | def _setDispOpts(self): |
|---|
| 108 | """ |
|---|
| 109 | Dictionary with the available options you can choose for the display. |
|---|
| 110 | Within the dictionary we store the "ids" of the options. |
|---|
| 111 | """ |
|---|
| 112 | self._dispopts = {"PersonalData":[ "Id", "LastName", "FirstName", "Email", "Position", "Institution","Phone","City","Country","Address","isPayed","idpayment","amountToPay"]} |
|---|
| 113 | self._dispopts["statuses"]=[] |
|---|
| 114 | for st in self._conf.getRegistrationForm().getStatusesList(False): |
|---|
| 115 | self._dispopts["statuses"].append("s-%s"%st.getId()) |
|---|
| 116 | #if self._conf.getRegistrationForm().getAccommodationForm().isEnabled(): |
|---|
| 117 | self._dispopts["Accommodation"]=["Accommodation", "ArrivalDate","DepartureDate"] |
|---|
| 118 | #if self._conf.getRegistrationForm().getSocialEventForm().isEnabled(): |
|---|
| 119 | self._dispopts["SocialEvents"] = ["SocialEvents"] |
|---|
| 120 | #if self._conf.getRegistrationForm().getSessionsForm().isEnabled(): |
|---|
| 121 | self._dispopts["Sessions"] = ["Sessions"] |
|---|
| 122 | #if self._conf.getRegistrationForm().getReasonParticipationForm().isEnabled(): |
|---|
| 123 | self._dispopts["ReasonParticipation"]=["ReasonParticipation"] |
|---|
| 124 | self._dispopts["more"]=["RegistrationDate"] |
|---|
| 125 | for sect in self._conf.getRegistrationForm().getGeneralSectionFormsList(): |
|---|
| 126 | self._dispopts[sect.getId()]=[] |
|---|
| 127 | |
|---|
| 128 | for fld in sect.getSortedFields(): |
|---|
| 129 | self._dispopts[sect.getId()].append("%s-%s"%(sect.getId(),fld.getId())) |
|---|
| 130 | |
|---|
| 131 | def _getKeyDispOpts(self, value): |
|---|
| 132 | """ |
|---|
| 133 | Returns the key which contains the done value. |
|---|
| 134 | """ |
|---|
| 135 | for key in self._dispopts.keys(): |
|---|
| 136 | if value in self._dispopts[key]: |
|---|
| 137 | return key |
|---|
| 138 | return None |
|---|
| 139 | |
|---|
| 140 | def _getColumnTitlesDict(self): |
|---|
| 141 | """ |
|---|
| 142 | Dictionary with the translation from "ids" to "name to display" for each of the options you can choose for the display. |
|---|
| 143 | This method complements the method "_setDispOpts" in which we get a dictonary with "ids". |
|---|
| 144 | """ |
|---|
| 145 | try: |
|---|
| 146 | if self._columns: |
|---|
| 147 | pass |
|---|
| 148 | except AttributeError: |
|---|
| 149 | columns ={"PersonalData":_("Personal Data"),"Id":_("Id"), "Email": _("Email"), "Position":_("Position"), "Institution":_("Institution"),"Phone":_("Phone"),"City":_("City"),\ |
|---|
| 150 | "Country":_("Country"), "Address":_("Address"), "ArrivalDate": _("Arrival Date"), "DepartureDate": _("Departure Date"), \ |
|---|
| 151 | "RegistrationDate": i18nformat("""_("Registration date") (%s)""")%self._conf.getTimezone()} |
|---|
| 152 | |
|---|
| 153 | tit=self._conf.getRegistrationForm().getSessionsForm().getTitle() |
|---|
| 154 | if not self._conf.getRegistrationForm().getSessionsForm().isEnabled(): |
|---|
| 155 | tit='%s <span style="color:red;font-size: 75%%">(disabled)</span>'%tit |
|---|
| 156 | columns["Sessions"]=tit |
|---|
| 157 | tit=self._conf.getRegistrationForm().getAccommodationForm().getTitle() |
|---|
| 158 | if not self._conf.getRegistrationForm().getAccommodationForm().isEnabled(): |
|---|
| 159 | tit='%s <span style="color:red;font-size: 75%%">(disabled)</span>'%tit |
|---|
| 160 | columns["Accommodation"]=tit |
|---|
| 161 | tit=self._conf.getRegistrationForm().getSocialEventForm().getTitle() |
|---|
| 162 | if not self._conf.getRegistrationForm().getSocialEventForm().isEnabled(): |
|---|
| 163 | tit='%s <span style="color:red;font-size: 75%%">(disabled)</span>'%tit |
|---|
| 164 | columns["SocialEvents"]=tit |
|---|
| 165 | tit=self._conf.getRegistrationForm().getReasonParticipationForm().getTitle() |
|---|
| 166 | if not self._conf.getRegistrationForm().getReasonParticipationForm().isEnabled(): |
|---|
| 167 | tit='%s <span style="color:red;font-size: 75%%">(disabled)</span>'%tit |
|---|
| 168 | columns["ReasonParticipation"]=tit |
|---|
| 169 | columns["more"]=_("General info") |
|---|
| 170 | columns["statuses"]=_("Statuses") |
|---|
| 171 | columns["isPayed"]=_("Paid") |
|---|
| 172 | columns["idpayment"]=_("Payment ID") |
|---|
| 173 | columns["amountToPay"]=_("Amount") |
|---|
| 174 | columns["LastName"]=_("Surname") |
|---|
| 175 | columns["FirstName"]=_("First name") |
|---|
| 176 | |
|---|
| 177 | for st in self._conf.getRegistrationForm().getStatusesList(False): |
|---|
| 178 | columns["s-%s"%st.getId()]=st.getCaption() |
|---|
| 179 | for sect in self._conf.getRegistrationForm().getGeneralSectionFormsList(): |
|---|
| 180 | tit=sect.getTitle() |
|---|
| 181 | if not sect.isEnabled(): |
|---|
| 182 | tit='%s <span style="color:red;font-size: 75%%">(disabled)</span>'%tit |
|---|
| 183 | columns[sect.getId()]=tit |
|---|
| 184 | ############ |
|---|
| 185 | # jmf-start |
|---|
| 186 | #for fld in sect.getFields(): |
|---|
| 187 | # columns["%s-%s"%(sect.getId(),fld.getId())]=fld.getCaption() |
|---|
| 188 | for fld in sect.getSortedFields(): |
|---|
| 189 | columns["%s-%s"%(sect.getId(),fld.getId())]=fld.getCaption() |
|---|
| 190 | # jmf-end |
|---|
| 191 | ############ |
|---|
| 192 | self._columns=columns |
|---|
| 193 | return self._columns |
|---|
| 194 | |
|---|
| 195 | def _getDisplay(self): |
|---|
| 196 | """ |
|---|
| 197 | These are the 'display' options selected by the user. In case no options were selected we add some of them by default. |
|---|
| 198 | """ |
|---|
| 199 | display=self._display[:] |
|---|
| 200 | |
|---|
| 201 | if display == []: |
|---|
| 202 | display=["Email", "Institution","Phone","City","Country"] |
|---|
| 203 | if self._conf.getModPay().isActivated(): |
|---|
| 204 | display.extend(["isPayed","idpayment","amountToPay"]) |
|---|
| 205 | return display |
|---|
| 206 | |
|---|
| 207 | def _getURL( self ): |
|---|
| 208 | #builds the URL to the contribution list page |
|---|
| 209 | # preserving the current filter and sorting status in the websesion |
|---|
| 210 | url = urlHandlers.UHConfModifRegistrantList.getURL(self._conf) |
|---|
| 211 | |
|---|
| 212 | return url |
|---|
| 213 | |
|---|
| 214 | def _getStatusesHTML(self): |
|---|
| 215 | self._statusesObjects = {} |
|---|
| 216 | for st in self._conf.getRegistrationForm().getStatusesList(False): |
|---|
| 217 | self._statusesObjects[st.getId()] = st |
|---|
| 218 | return WRegistrantsFilterStatuses(self._statuses, self._filterCrit, self._statusesObjects).getHTML() |
|---|
| 219 | |
|---|
| 220 | def _getDispHTML(self): |
|---|
| 221 | """ |
|---|
| 222 | Filtering criteria: table with all the options for the columns we need to display. |
|---|
| 223 | """ |
|---|
| 224 | res=["""<table width="100%%" cellpadding="0" cellspacing="0" valign="top">"""] |
|---|
| 225 | columns=self._getColumnTitlesDict() |
|---|
| 226 | checked = " checked" |
|---|
| 227 | display=self._getDisplay() |
|---|
| 228 | counter=0 |
|---|
| 229 | # sorting dispopts by |
|---|
| 230 | auxdict={} |
|---|
| 231 | for key in self._dispopts.keys(): |
|---|
| 232 | if not auxdict.has_key(len(self._dispopts[key])): |
|---|
| 233 | auxdict[len(self._dispopts[key])]=[] |
|---|
| 234 | auxdict[len(self._dispopts[key])].append(key) |
|---|
| 235 | auxlens=auxdict.keys() |
|---|
| 236 | auxlens.sort() |
|---|
| 237 | auxlens.reverse() |
|---|
| 238 | dispoptssortedkeys=[] |
|---|
| 239 | for l in auxlens: |
|---|
| 240 | for k in auxdict[l]: |
|---|
| 241 | dispoptssortedkeys.append(k) |
|---|
| 242 | #---end sorting |
|---|
| 243 | for key in dispoptssortedkeys: |
|---|
| 244 | if self._dispopts[key] == []: |
|---|
| 245 | continue |
|---|
| 246 | if counter == 0: |
|---|
| 247 | res.append("""<tr>""") |
|---|
| 248 | res.append("""<td style="border-bottom:1px solid lightgrey; width:33%%" valign="top" align="left"><span style="color:black"><b>%s</b></span><br>"""%(columns[key])) |
|---|
| 249 | for keyfld in self._dispopts[key]: |
|---|
| 250 | res.append("""<table width="100%%" cellpadding="0" cellspacing="0" valign="top">""") |
|---|
| 251 | checked ="" |
|---|
| 252 | if keyfld in display: |
|---|
| 253 | checked=" checked" |
|---|
| 254 | res.append("""<tr><td align="left" valign="top"><input type="checkbox" name="disp" value="%s"%s></td><td width="100%%" align="left" valign="top">%s</td></tr>"""%(keyfld,checked,columns[keyfld].replace('<span style="color:red;font-size: 75%">(disabled)</span>',''))) |
|---|
| 255 | res.append("""</table>""") |
|---|
| 256 | res.append("""</td>""") |
|---|
| 257 | if counter==2: |
|---|
| 258 | counter=0 |
|---|
| 259 | res.append("""</tr>""") |
|---|
| 260 | |
|---|
| 261 | else: |
|---|
| 262 | counter+=1 |
|---|
| 263 | if counter in [1,2]: |
|---|
| 264 | res.append("""<td colspan="2" style="border-bottom:1px solid lightgrey; width:100%%"> </td>""") |
|---|
| 265 | res.append("""</table>""") |
|---|
| 266 | return "".join(res) |
|---|
| 267 | |
|---|
| 268 | |
|---|
| 269 | def _getRegColumnHTML(self, sortingField): |
|---|
| 270 | """ |
|---|
| 271 | Titles for the columns of the list. |
|---|
| 272 | """ |
|---|
| 273 | resgroups={} |
|---|
| 274 | columns=self._getColumnTitlesDict() |
|---|
| 275 | currentSorting="" |
|---|
| 276 | if sortingField is not None: |
|---|
| 277 | currentSorting=sortingField.getSpecialId() |
|---|
| 278 | currentSortingHTML = "" |
|---|
| 279 | display=self._getDisplay() |
|---|
| 280 | resgroups["PersonalData"]=[] |
|---|
| 281 | if "Id" in display: |
|---|
| 282 | url=self._getURL() |
|---|
| 283 | url.addParam("sortBy","Id") |
|---|
| 284 | idImg="" |
|---|
| 285 | if currentSorting == "Id": |
|---|
| 286 | currentSortingHTML = """<input type="hidden" name="sortBy" value="Id">""" |
|---|
| 287 | if self._order == "down": |
|---|
| 288 | idImg = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow"))) |
|---|
| 289 | url.addParam("order","up") |
|---|
| 290 | elif self._order == "up": |
|---|
| 291 | idImg = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow"))) |
|---|
| 292 | url.addParam("order","down") |
|---|
| 293 | idSortingURL=quoteattr("%s#results"%str(url)) |
|---|
| 294 | resgroups["PersonalData"]=[ i18nformat("""<td nowrap class="titleCellFormat" style="border-left:5px solid #FFFFFF;border-bottom: 1px solid #888;">%s<a href=%s> _("Id")</a></td>""")%(idImg, idSortingURL)] |
|---|
| 295 | |
|---|
| 296 | url=self._getURL() |
|---|
| 297 | url.addParam("sortBy","Name") |
|---|
| 298 | nameImg="" |
|---|
| 299 | if currentSorting == "Name": |
|---|
| 300 | currentSortingHTML = """<input type="hidden" name="sortBy" value="Name">""" |
|---|
| 301 | if self._order == "down": |
|---|
| 302 | nameImg = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow"))) |
|---|
| 303 | url.addParam("order","up") |
|---|
| 304 | elif self._order == "up": |
|---|
| 305 | nameImg = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow"))) |
|---|
| 306 | url.addParam("order","down") |
|---|
| 307 | nameSortingURL=quoteattr("%s#results"%str(url)) |
|---|
| 308 | |
|---|
| 309 | resgroups["PersonalData"].append( i18nformat("""<td nowrap class="titleCellFormat" style="border-left:5px solid #FFFFFF;border-bottom: 1px solid #888;">%s<a href=%s> _("Name")</a></td>""")%(nameImg, nameSortingURL)) |
|---|
| 310 | if "Id" in display: |
|---|
| 311 | pdil=["Id", "Name"] |
|---|
| 312 | else: |
|---|
| 313 | pdil=["Name"] |
|---|
| 314 | self._groupsorder={"PersonalData":pdil}#list used to display the info of the registrants in the same order |
|---|
| 315 | for key in display: |
|---|
| 316 | if key == "Id" or not columns.has_key(key): |
|---|
| 317 | continue |
|---|
| 318 | url=self._getURL() |
|---|
| 319 | url.addParam("sortBy",key) |
|---|
| 320 | img="" |
|---|
| 321 | if currentSorting == key: |
|---|
| 322 | currentSortingHTML = """<input type="hidden" name="sortBy" value="%s">"""%key |
|---|
| 323 | if self._order == "down": |
|---|
| 324 | img = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow"))) |
|---|
| 325 | url.addParam("order","up") |
|---|
| 326 | elif self._order == "up": |
|---|
| 327 | img = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow"))) |
|---|
| 328 | url.addParam("order","down") |
|---|
| 329 | sortingURL=quoteattr("%s#results"%str(url)) |
|---|
| 330 | kg=self._getKeyDispOpts(key) |
|---|
| 331 | if not resgroups.has_key(kg): |
|---|
| 332 | self._groupsorder[kg]=[] |
|---|
| 333 | resgroups[kg]=[] |
|---|
| 334 | self._groupsorder[kg].append(key) |
|---|
| 335 | resgroups[kg].append("""<td class="titleCellFormat" style="border-left:5px solid #FFFFFF;border-bottom: 1px solid #888;">%s<a href=%s>%s</a></td>"""%(img, sortingURL, self.htmlText(columns[key].replace('<span style="color:red;font-size: 75%">(disabled)</span>','')))) |
|---|
| 336 | fields=[""" |
|---|
| 337 | <tr> |
|---|
| 338 | <td align="right" nowrap></td>"""] |
|---|
| 339 | # First we want to display the personal data... |
|---|
| 340 | groupkey="PersonalData" |
|---|
| 341 | fields += resgroups[groupkey] |
|---|
| 342 | del resgroups[groupkey] |
|---|
| 343 | #...and them all the other info: |
|---|
| 344 | for groupkey in resgroups.keys(): |
|---|
| 345 | fields += resgroups[groupkey] |
|---|
| 346 | fields.append(""" |
|---|
| 347 | </tr> |
|---|
| 348 | """) |
|---|
| 349 | return "<tr><td colspan=4 style='padding: 5px 0px 10px;' nowrap>Select: <a style='color: #0B63A5;' alt='Select all' onclick='javascript:selectAll()'> All</a>, <a style='color: #0B63A5;' alt='Unselect all' onclick='javascript:deselectAll()'>None</a></td></tr>%s"%("\r\n".join(fields)) |
|---|
| 350 | |
|---|
| 351 | |
|---|
| 352 | def _getRegistrantsHTML( self, reg ): |
|---|
| 353 | url = urlHandlers.UHRegistrantModification.getURL(reg) |
|---|
| 354 | fullName = reg.getFullName() |
|---|
| 355 | regdict = registration.RegistrantMapping(reg) |
|---|
| 356 | res = ("""<td valign="top" align="right" width="3%%"><input onchange="javascript:isSelected('registrant%s')" type="checkbox" name="registrant" value="%s"></td> |
|---|
| 357 | """%(reg.getId(),self.htmlText(reg.getId()))) |
|---|
| 358 | if "Id" in self._groupsorder["PersonalData"]: |
|---|
| 359 | res += ("""<td valign="top" nowrap class="CRLabstractLeftDataCell">%s</td> |
|---|
| 360 | """%reg.getId()) |
|---|
| 361 | res += ("""<td valign="top" nowrap class="CRLabstractDataCell"><a href=%s>%s</a></td> |
|---|
| 362 | """%(quoteattr(str(url)), self.htmlText(fullName))) |
|---|
| 363 | # Fisrtly the "PersonalData" |
|---|
| 364 | res += "".join(["""<td valign="top" class="CRLabstractDataCell">%s</td>"""%regdict[key] for key in self._groupsorder["PersonalData"] if key != "Name" and key != "Id"]) |
|---|
| 365 | res += "".join(["""<td valign="top" class="CRLabstractDataCell">%s</td>"""%regdict[key] for groupkey in self._groupsorder.keys() if groupkey != "PersonalData" for key in self._groupsorder[groupkey] ]) |
|---|
| 366 | html = """ |
|---|
| 367 | <tr id="registrant%s" style="background-color: transparent;" onmouseout="javascript:onMouseOut('registrant%s')" onmouseover="javascript:onMouseOver('registrant%s')"> |
|---|
| 368 | %s |
|---|
| 369 | </tr> |
|---|
| 370 | """%(reg.getId(),reg.getId(),reg.getId(), res) |
|---|
| 371 | return html |
|---|
| 372 | |
|---|
| 373 | def _getDisplayOptionsHTML(self): |
|---|
| 374 | html=[] |
|---|
| 375 | if self._display == []: |
|---|
| 376 | html.append("""<input type="hidden" name="disp" value="Email">""") |
|---|
| 377 | html.append("""<input type="hidden" name="disp" value="Institution">""") |
|---|
| 378 | html.append("""<input type="hidden" name="disp" value="Phone">""") |
|---|
| 379 | html.append("""<input type="hidden" name="disp" value="City">""") |
|---|
| 380 | html.append("""<input type="hidden" name="disp" value="Country">""") |
|---|
| 381 | html.append("""<input type="hidden" name="disp" value="isPayed">""") |
|---|
| 382 | html.append("""<input type="hidden" name="disp" value="idpayment">""") |
|---|
| 383 | html.append("""<input type="hidden" name="disp" value="amountToPay">""") |
|---|
| 384 | else: |
|---|
| 385 | for d in self._display: |
|---|
| 386 | html.append("""<input type="hidden" name="disp" value="%s">"""%(d)) |
|---|
| 387 | html.append("""<input type="hidden" name="sortBy" value="%s">"""%(self._sortingCrit.getField().getId())) |
|---|
| 388 | return "".join(html) |
|---|
| 389 | |
|---|
| 390 | def _getOpenMenuURL(self): |
|---|
| 391 | url = urlHandlers.UHConfModifRegistrantsOpenMenu.getURL(self._conf) |
|---|
| 392 | url.addParam("currentURL", self._getURL()) |
|---|
| 393 | return url |
|---|
| 394 | |
|---|
| 395 | def _getCloseMenuURL(self): |
|---|
| 396 | url = urlHandlers.UHConfModifRegistrantsCloseMenu.getURL(self._conf) |
|---|
| 397 | url.addParam("currentURL", self._getURL()) |
|---|
| 398 | return url |
|---|
| 399 | |
|---|
| 400 | def _getFilterMenu(self): |
|---|
| 401 | |
|---|
| 402 | regForm = self._conf.getRegistrationForm() |
|---|
| 403 | |
|---|
| 404 | options = [ |
|---|
| 405 | ('accomm', regForm.getAccommodationForm()), |
|---|
| 406 | ('event', regForm.getSocialEventForm()), |
|---|
| 407 | (self._sessionFilterName, regForm.getSessionsForm()) |
|---|
| 408 | ] |
|---|
| 409 | |
|---|
| 410 | extraInfo = "" |
|---|
| 411 | if self._conf.getRegistrationForm().getStatusesList(False): |
|---|
| 412 | extraInfo = i18nformat("""<table align="center" cellspacing="0" width="100%%"> |
|---|
| 413 | <tr> |
|---|
| 414 | <td align="left" class="titleCellFormat" style="border-bottom: 1px solid #888; padding-right:10px"> _("Statuses") <img src=%s border="0" alt="Select all" onclick="javascript:selectStatuses()"><img src=%s border="0" alt="Unselect all" onclick="javascript:unselectStatuses()"></td> |
|---|
| 415 | </tr> |
|---|
| 416 | <tr> |
|---|
| 417 | <td valign="top">%s</td> |
|---|
| 418 | </tr> |
|---|
| 419 | </table> |
|---|
| 420 | """)%(quoteattr(Config.getInstance().getSystemIconURL("checkAll")),quoteattr(Config.getInstance().getSystemIconURL("uncheckAll")),self._getStatusesHTML()) |
|---|
| 421 | |
|---|
| 422 | p = WFilterCriteriaRegistrants(options, self._filterCrit, extraInfo) |
|---|
| 423 | |
|---|
| 424 | return p.getHTML() |
|---|
| 425 | |
|---|
| 426 | def _getDisplayMenu(self): |
|---|
| 427 | menu = i18nformat("""<div class="CRLDiv" style="display: none;" id="displayMenu"><table width="95%%" align="center" border="0"> |
|---|
| 428 | <tr> |
|---|
| 429 | <td> |
|---|
| 430 | <table width="100%%"> |
|---|
| 431 | <tr> |
|---|
| 432 | <td> |
|---|
| 433 | |
|---|
| 434 | </td> |
|---|
| 435 | </tr> |
|---|
| 436 | <tr> |
|---|
| 437 | <td> |
|---|
| 438 | <table align="center" cellspacing="0" width="100%%"> |
|---|
| 439 | <tr> |
|---|
| 440 | <td align="left" class="titleCellFormat" style="border-bottom: 1px solid #888; padding-right:10px" nowrap> <a onclick="selectDisplay()">_("Select all")</a> | <a onclick="unselectDisplay()">_("Unselect all")</a> </td> |
|---|
| 441 | </tr> |
|---|
| 442 | <tr> |
|---|
| 443 | <td valign="top">%(disp)s</td> |
|---|
| 444 | </tr> |
|---|
| 445 | </table> |
|---|
| 446 | </td> |
|---|
| 447 | </tr> |
|---|
| 448 | <tr> |
|---|
| 449 | <td align="center"><input type="submit" class="btn" name="OK" value= _("apply filter")></td> |
|---|
| 450 | </tr> |
|---|
| 451 | </table> |
|---|
| 452 | </td> |
|---|
| 453 | </tr> |
|---|
| 454 | </table></div>""") |
|---|
| 455 | return menu |
|---|
| 456 | |
|---|
| 457 | def getVars( self ): |
|---|
| 458 | |
|---|
| 459 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 460 | |
|---|
| 461 | vars["filterUrl"] = str(self._filterUrl) |
|---|
| 462 | |
|---|
| 463 | sortingField = self._sortingCrit.getField() |
|---|
| 464 | vars["filterPostURL"]=quoteattr("%s#results"%str(urlHandlers.UHConfModifRegistrantList.getURL(self._conf))) |
|---|
| 465 | cl = self._conf.getRegistrantsList(False) |
|---|
| 466 | f = filters.SimpleFilter(self._filterCrit,self._sortingCrit) |
|---|
| 467 | vars["eve"]="" |
|---|
| 468 | vars["columns"]=self._getRegColumnHTML(sortingField) |
|---|
| 469 | filtered = f.apply(cl) |
|---|
| 470 | l = [self._getRegistrantsHTML(reg) for reg in filtered] |
|---|
| 471 | regl = [reg.getId() for reg in filtered] |
|---|
| 472 | if self._order =="up": |
|---|
| 473 | l.reverse() |
|---|
| 474 | regl.reverse() |
|---|
| 475 | vars["registrants"] = "".join(l) |
|---|
| 476 | vars["filteredNumberRegistrants"]=str(len(l)) |
|---|
| 477 | vars["totalNumberRegistrants"]=str(len(cl)) |
|---|
| 478 | vars["filterUsed"] = self._filterUsed |
|---|
| 479 | |
|---|
| 480 | |
|---|
| 481 | vars["actionPostURL"]=quoteattr(str(urlHandlers.UHConfModifRegistrantListAction.getURL(self._conf))) |
|---|
| 482 | |
|---|
| 483 | if l == []: |
|---|
| 484 | vars ["reglist"]="" |
|---|
| 485 | else: |
|---|
| 486 | vars ["reglist"]=",".join(regl) |
|---|
| 487 | vars["emailIconURL"]="""<input type="image" name="email" src=%s border="0">"""%quoteattr(str(Config.getInstance().getSystemIconURL("envelope"))) |
|---|
| 488 | vars["infoIconURL"]="""<input type="image" name="info" src=%s border="0">"""%quoteattr(str(Config.getInstance().getSystemIconURL("info"))) |
|---|
| 489 | vars["excelIconURL"]=quoteattr(str(Config.getInstance().getSystemIconURL("excel"))) |
|---|
| 490 | vars["pdfIconURL"] = quoteattr(str(Config.getInstance().getSystemIconURL("pdf"))) |
|---|
| 491 | vars["excelUrl"] = quoteattr(str(Config.getInstance().getSystemIconURL("excel"))) |
|---|
| 492 | |
|---|
| 493 | vars ["disp"]= self._getDispHTML() |
|---|
| 494 | tit=self._conf.getRegistrationForm().getAccommodationForm().getTitle() |
|---|
| 495 | if not self._conf.getRegistrationForm().getAccommodationForm().isEnabled(): |
|---|
| 496 | tit='%s <span style="color:red;font-size: 75%%">(disabled)</span>'%tit |
|---|
| 497 | vars ["accomtitle"]=tit |
|---|
| 498 | tit=self._conf.getRegistrationForm().getSessionsForm().getTitle() |
|---|
| 499 | if not self._conf.getRegistrationForm().getSessionsForm().isEnabled(): |
|---|
| 500 | tit='%s <span style="color:red;font-size: 75%%">(disabled)</span>'%tit |
|---|
| 501 | vars["sesstitle"]=tit |
|---|
| 502 | tit=self._conf.getRegistrationForm().getSocialEventForm().getTitle() |
|---|
| 503 | if not self._conf.getRegistrationForm().getSocialEventForm().isEnabled(): |
|---|
| 504 | tit='%s <span style="color:red;font-size: 75%%">(disabled)</span>'%tit |
|---|
| 505 | vars["eventtitle"]=tit |
|---|
| 506 | vars["displayOptions"]=self._getDisplayOptionsHTML() |
|---|
| 507 | vars["sortingOptions"]="""<input type="hidden" name="sortBy" value="%s"> |
|---|
| 508 | <input type="hidden" name="order" value="%s">"""%(self._sortingCrit.getField().getId(), self._order) |
|---|
| 509 | vars["closeMenuURL"] = self._getCloseMenuURL() |
|---|
| 510 | vars["closeMenuImg"] = quoteattr(Config.getInstance().getSystemIconURL("openMenu")) |
|---|
| 511 | vars["openMenuURL"] = self._getOpenMenuURL() |
|---|
| 512 | vars["openMenuImg"] = quoteattr(Config.getInstance().getSystemIconURL("closeMenu")) |
|---|
| 513 | |
|---|
| 514 | vars["checkAcco"] = """<img src=%s border="0" alt="Select all" onclick="javascript:selectAcco()">"""%quoteattr(Config.getInstance().getSystemIconURL("checkAll")) |
|---|
| 515 | vars["uncheckAcco"] = """<img src=%s border="0" alt="Unselect all" onclick="javascript:unselectAcco()">"""%quoteattr(Config.getInstance().getSystemIconURL("uncheckAll")) |
|---|
| 516 | vars["checkEvent"] = """<img src=%s border="0" alt="Select all" onclick="javascript:selectEvent()">"""%quoteattr(Config.getInstance().getSystemIconURL("checkAll")) |
|---|
| 517 | vars["uncheckEvent"] = """<img src=%s border="0" alt="Unselect all" onclick="javascript:unselectEvent()">"""%quoteattr(Config.getInstance().getSystemIconURL("uncheckAll")) |
|---|
| 518 | vars["checkSession"] = """<img src=%s border="0" alt="Select all" onclick="javascript:selectSession()">"""%quoteattr(Config.getInstance().getSystemIconURL("checkAll")) |
|---|
| 519 | vars["uncheckSession"] = """<img src=%s border="0" alt="Unselect all" onclick="javascript:unselectSession()">"""%quoteattr(Config.getInstance().getSystemIconURL("uncheckAll")) |
|---|
| 520 | vars["checkDisplay"] = """<img src=%s border="0" alt="Select all" onclick="javascript:selectDisplay()">"""%quoteattr(Config.getInstance().getSystemIconURL("checkAll")) |
|---|
| 521 | vars["uncheckDisplay"] = """<img src=%s border="0" alt="Unselect all" onclick="javascript:unselectDisplay()">"""%quoteattr(Config.getInstance().getSystemIconURL("uncheckAll")) |
|---|
| 522 | vars["displayMenu"] = self._getDisplayMenu()%vars |
|---|
| 523 | vars["filterMenu"] = self._getFilterMenu() |
|---|
| 524 | |
|---|
| 525 | return vars |
|---|
| 526 | |
|---|
| 527 | class WRegistrantsFilterStatuses (wcomponents.WTemplated): |
|---|
| 528 | |
|---|
| 529 | def __init__(self, statuses, filter, statusObjects): |
|---|
| 530 | wcomponents.WTemplated.__init__(self) |
|---|
| 531 | self._statuses = statuses |
|---|
| 532 | self._filterCrit = filter |
|---|
| 533 | self._statusObjects = statusObjects |
|---|
| 534 | |
|---|
| 535 | def getVars(self): |
|---|
| 536 | |
|---|
| 537 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 538 | vars["statuses"] = self._statuses |
|---|
| 539 | vars["filter"] = self._filterCrit |
|---|
| 540 | vars["showNoAnswer"] = self._filterCrit.getField("statuses").getShowNoValue() |
|---|
| 541 | vars["statusObjects"] = self._statusObjects |
|---|
| 542 | |
|---|
| 543 | return vars |
|---|
| 544 | |
|---|
| 545 | class WFilterCriteriaRegistrants(wcomponents.WFilterCriteria): |
|---|
| 546 | """ |
|---|
| 547 | Draws the options for a filter criteria object |
|---|
| 548 | This means rendering the actual table that contains |
|---|
| 549 | all the HTML for the several criteria |
|---|
| 550 | """ |
|---|
| 551 | |
|---|
| 552 | def __init__(self, options, filterCrit, extraInfo=""): |
|---|
| 553 | wcomponents.WFilterCriteria.__init__(self, options, filterCrit, extraInfo) |
|---|
| 554 | |
|---|
| 555 | def _drawFieldOptions(self, formName, form): |
|---|
| 556 | |
|---|
| 557 | # since sessions have a special extra checkbox ("only by first choice"), |
|---|
| 558 | # we need to use a different template |
|---|
| 559 | |
|---|
| 560 | if formName in ['session', 'sessionfirstpriority']: |
|---|
| 561 | page = WFilterSessionCriterionOptions(formName, form, self._filterCrit) |
|---|
| 562 | else: |
|---|
| 563 | page = WFilterCriterionOptions(formName, form, self._filterCrit) |
|---|
| 564 | |
|---|
| 565 | return page.getHTML() |
|---|
| 566 | |
|---|
| 567 | class WFilterCriterionOptions(wcomponents.WTemplated): |
|---|
| 568 | """ |
|---|
| 569 | Draws the list of options (and checkboxes) for a specific filter criterion, |
|---|
| 570 | with all the checkboxes (properly checked if necessary) |
|---|
| 571 | """ |
|---|
| 572 | |
|---|
| 573 | def __init__(self, formName, formData, filterCrit): |
|---|
| 574 | self._formName = formName |
|---|
| 575 | self._formData = formData |
|---|
| 576 | self._filterCrit = filterCrit |
|---|
| 577 | |
|---|
| 578 | def getVars(self): |
|---|
| 579 | parentVars = wcomponents.WTemplated.getVars( self ) |
|---|
| 580 | parentVars["critFormName"] = self._formName |
|---|
| 581 | parentVars["htmlFormName"] = self._formName |
|---|
| 582 | parentVars["form"] = self._formData |
|---|
| 583 | parentVars["filterCrit"] = self._filterCrit |
|---|
| 584 | |
|---|
| 585 | return parentVars |
|---|
| 586 | |
|---|
| 587 | class WFilterSessionCriterionOptions(WFilterCriterionOptions): |
|---|
| 588 | """ |
|---|
| 589 | Sub-class for the session "criterion", since it requires an |
|---|
| 590 | extra checkbox. |
|---|
| 591 | """ |
|---|
| 592 | |
|---|
| 593 | def getVars(self): |
|---|
| 594 | parentVars = WFilterCriterionOptions.getVars( self ) |
|---|
| 595 | parentVars["htmlFormName"] = "session" |
|---|
| 596 | |
|---|
| 597 | return parentVars |
|---|
| 598 | |
|---|
| 599 | |
|---|
| 600 | class WRegSentMail (wcomponents.WTemplated): |
|---|
| 601 | def __init__(self,conf): |
|---|
| 602 | self._conf = conf |
|---|
| 603 | |
|---|
| 604 | def getVars(self): |
|---|
| 605 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 606 | vars["BackURL"]=urlHandlers.UHConfModifRegistrantList.getURL(self._conf) |
|---|
| 607 | return vars |
|---|
| 608 | |
|---|
| 609 | |
|---|
| 610 | class WPSentEmail( WPConfModifRegistrantListBase ): |
|---|
| 611 | def _getTabContent(self,params): |
|---|
| 612 | wc = WRegSentMail(self._conf) |
|---|
| 613 | return wc.getHTML() |
|---|
| 614 | |
|---|
| 615 | |
|---|
| 616 | class WRegPreviewMail(wcomponents.WTemplated): |
|---|
| 617 | def __init__(self,conf, params): |
|---|
| 618 | self._conf = conf |
|---|
| 619 | self._params=params |
|---|
| 620 | |
|---|
| 621 | def getVars(self): |
|---|
| 622 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 623 | fromAddr=self._params.get("from","") |
|---|
| 624 | cc=self._params.get("cc","") |
|---|
| 625 | subject=self._params.get("subject","") |
|---|
| 626 | body=self._params.get("body","") |
|---|
| 627 | regsIds=self._params.get("regsIds",[]) |
|---|
| 628 | if type(regsIds) != list: |
|---|
| 629 | regsIds=[regsIds] |
|---|
| 630 | registrant=None |
|---|
| 631 | if len(regsIds)>0: |
|---|
| 632 | registrant=self._conf.getRegistrantById(regsIds[0]) |
|---|
| 633 | vars["From"]= i18nformat("""<center> _("No preview avaible") </center>""") |
|---|
| 634 | vars["subject"]= i18nformat("""<center> _("No preview avaible") </center>""") |
|---|
| 635 | vars["body"]= i18nformat("""<center> _("No preview avaible") </center>""") |
|---|
| 636 | vars["to"]= i18nformat("""<center> _("No preview avaible") </center>""") |
|---|
| 637 | vars["cc"]= i18nformat("""<center> _("No preview avaible") </center>""") |
|---|
| 638 | if registrant != None: |
|---|
| 639 | notif=EmailNotificator().apply(registrant,{"subject":subject, "body":body, "from":fromAddr, "to":[registrant.getEmail()], "cc": [cc]}) |
|---|
| 640 | vars["From"]=notif.getFromAddr() |
|---|
| 641 | vars["to"]=notif.getToList() |
|---|
| 642 | vars["subject"]=notif.getSubject() |
|---|
| 643 | vars["body"] = notif.getBody() |
|---|
| 644 | vars["cc"] = notif.getCCList() |
|---|
| 645 | vars["params"]=[] |
|---|
| 646 | for regId in regsIds: |
|---|
| 647 | vars["params"].append("""<input type="hidden" name="regsIds" value="%s">"""%(regId)) |
|---|
| 648 | vars["params"].append("""<input type="hidden" name="registrant" value="%s">"""%(regId)) |
|---|
| 649 | vars["params"].append("""<input type="hidden" name="from" value=%s>"""%(quoteattr(fromAddr))) |
|---|
| 650 | vars["params"].append("""<input type="hidden" name="subject" value=%s>"""%(quoteattr(subject))) |
|---|
| 651 | vars["params"].append("""<input type="hidden" name="body" value=%s>"""%(quoteattr(body))) |
|---|
| 652 | vars["params"].append("""<input type="hidden" name="cc" value=%s>"""%(quoteattr(cc))) |
|---|
| 653 | vars["params"]="".join(vars["params"]) |
|---|
| 654 | vars["postURL"]=urlHandlers.UHRegistrantsSendEmail.getURL(self._conf) |
|---|
| 655 | vars["backURL"]=urlHandlers.UHConfModifRegistrantListAction.getURL(self._conf) |
|---|
| 656 | return vars |
|---|
| 657 | |
|---|
| 658 | |
|---|
| 659 | class WPPreviewEmail( WPConfModifRegistrantListBase ): |
|---|
| 660 | |
|---|
| 661 | def __init__(self, rh, conf, params): |
|---|
| 662 | WPConfModifRegistrantListBase.__init__(self, rh, conf) |
|---|
| 663 | self._params = params |
|---|
| 664 | |
|---|
| 665 | def _getTabContent(self,params): |
|---|
| 666 | wc = WRegPreviewMail(self._conf, self._params) |
|---|
| 667 | return wc.getHTML() |
|---|
| 668 | |
|---|
| 669 | |
|---|
| 670 | class WEmailToRegistrants(wcomponents.WTemplated): |
|---|
| 671 | def __init__(self, conf, user, reglist, fromA, cc, subject, body): |
|---|
| 672 | self._conf = conf |
|---|
| 673 | self._from = fromA |
|---|
| 674 | self._cc = cc |
|---|
| 675 | self._subject = subject |
|---|
| 676 | self._body = body |
|---|
| 677 | try: |
|---|
| 678 | self._fromemail = self._from or user.getEmail() |
|---|
| 679 | except: |
|---|
| 680 | self._fromemail = "" |
|---|
| 681 | self._regList = reglist |
|---|
| 682 | |
|---|
| 683 | def _getAvailableTagsHTML(self): |
|---|
| 684 | res=[] |
|---|
| 685 | for var in EmailNotificator.getVarList(): |
|---|
| 686 | res.append(""" |
|---|
| 687 | <tr> |
|---|
| 688 | <td width="100%%" nowrap class="blacktext" style="padding-left:10px;padding-right:5px;">%s</td> |
|---|
| 689 | <td>%s</td> |
|---|
| 690 | </tr>"""%(self.htmlText(var.getLabel()),self.htmlText(var.getDescription()))) |
|---|
| 691 | return "".join(res) |
|---|
| 692 | |
|---|
| 693 | def getVars(self): |
|---|
| 694 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 695 | toEmails=[] |
|---|
| 696 | toIds=[] |
|---|
| 697 | for regId in self._regList: |
|---|
| 698 | reg=self._conf.getRegistrantById(regId) |
|---|
| 699 | if reg!=None: |
|---|
| 700 | toEmails.append(reg.getEmail()) |
|---|
| 701 | toIds.append("""<input type="hidden" name="regsIds" value="%s">"""%reg.getId()) |
|---|
| 702 | vars["From"] = self._fromemail |
|---|
| 703 | vars["cc"] = self._cc |
|---|
| 704 | vars["toEmails"]= ", ".join(toEmails) |
|---|
| 705 | if vars["toEmails"] == "": |
|---|
| 706 | vars["toEmails"] = "No registrants have been selected" |
|---|
| 707 | vars["toIds"]= "".join(toIds) |
|---|
| 708 | vars["postURL"]=urlHandlers.UHRegistrantsSendEmail.getURL(self._conf) |
|---|
| 709 | vars["subject"] = self._subject |
|---|
| 710 | vars["body"] = self._body |
|---|
| 711 | vars["vars"]=self._getAvailableTagsHTML() |
|---|
| 712 | return vars |
|---|
| 713 | |
|---|
| 714 | class WPRegistrantModifRemoveConfirmation(WPConfModifRegistrantListBase): |
|---|
| 715 | |
|---|
| 716 | def __init__(self,rh, conf, registrantList): |
|---|
| 717 | WPConfModifRegistrantListBase.__init__(self,rh,conf) |
|---|
| 718 | self._regList = registrantList |
|---|
| 719 | |
|---|
| 720 | def _getTabContent(self,params): |
|---|
| 721 | wc=wcomponents.WConfirmation() |
|---|
| 722 | regs=[] |
|---|
| 723 | for reg in self._regList: |
|---|
| 724 | regs.append("<li><i>%s</i></li>"%self._conf.getRegistrantById(reg).getFullName()) |
|---|
| 725 | msg= i18nformat(""" _("Are you sure you want to delete the following registrants")?:<br><ul>%s</ul> |
|---|
| 726 | <font color="red"> _("(note you will permanently lose all the information about the registrants)")</font><br>""")%("".join(regs)) |
|---|
| 727 | url=urlHandlers.UHConfModifRegistrantPerformRemove.getURL(self._conf) |
|---|
| 728 | return wc.getHTML(msg,url,{"registrants":self._regList}) |
|---|
| 729 | |
|---|
| 730 | class WPEMail ( WPConfModifRegistrantListBase ): |
|---|
| 731 | def __init__(self, rh, conf, reglist, fromA, cc, subject, body): |
|---|
| 732 | WPConfModifRegistrantListBase.__init__(self, rh, conf) |
|---|
| 733 | self._regList = reglist |
|---|
| 734 | self._from = fromA |
|---|
| 735 | self._cc = cc |
|---|
| 736 | self._subject = subject |
|---|
| 737 | self._body = body |
|---|
| 738 | |
|---|
| 739 | def _getTabContent(self,params): |
|---|
| 740 | wc = WEmailToRegistrants(self._conf, self._getAW().getUser(), self._regList, self._from, self._cc, self._subject, self._body) |
|---|
| 741 | return wc.getHTML() |
|---|
| 742 | |
|---|
| 743 | class WConfModifRegistrantsInfo(wcomponents.WTemplated): |
|---|
| 744 | |
|---|
| 745 | def __init__(self,conf,reglist): |
|---|
| 746 | self._conf = conf |
|---|
| 747 | self._reglist = reglist |
|---|
| 748 | |
|---|
| 749 | def _getAccommodationTypesInfoHTML(self): |
|---|
| 750 | accoDict = {} |
|---|
| 751 | for acco in self._conf.getRegistrationForm().getAccommodationForm().getAccommodationTypesList(): |
|---|
| 752 | if acco is not None: |
|---|
| 753 | accoDict[acco]=0 |
|---|
| 754 | total = 0 |
|---|
| 755 | for reg in self._reglist: |
|---|
| 756 | acco = reg.getAccommodation().getAccommodationType() |
|---|
| 757 | if acco is not None: |
|---|
| 758 | if accoDict.has_key(acco): |
|---|
| 759 | accoDict[acco] += 1 |
|---|
| 760 | else: |
|---|
| 761 | accoDict[acco] = 1 |
|---|
| 762 | total += 1 |
|---|
| 763 | html = [] |
|---|
| 764 | for acco in accoDict.keys(): |
|---|
| 765 | html.append(""" |
|---|
| 766 | <tr> |
|---|
| 767 | <td nowrap>%s</td> |
|---|
| 768 | <td> </td> |
|---|
| 769 | <td width="100%%" align="left"><b>%s</b></td> |
|---|
| 770 | </tr> |
|---|
| 771 | """%(acco.getCaption(), accoDict[acco])) |
|---|
| 772 | html.sort() |
|---|
| 773 | return "".join(html), total |
|---|
| 774 | |
|---|
| 775 | def _getSocialEventsInfoHTML(self): |
|---|
| 776 | seCounter = {} |
|---|
| 777 | seObj = {} |
|---|
| 778 | for se in self._conf.getRegistrationForm().getSocialEventForm().getSocialEventList(): |
|---|
| 779 | if se is not None: |
|---|
| 780 | seCounter[se.getId()]=0 |
|---|
| 781 | seObj[se.getId()]=se |
|---|
| 782 | total = 0 |
|---|
| 783 | for reg in self._reglist: |
|---|
| 784 | for se in reg.getSocialEvents(): |
|---|
| 785 | if se is not None: |
|---|
| 786 | if seCounter.has_key(se.getId()): |
|---|
| 787 | seCounter[se.getId()] += se.getNoPlaces() |
|---|
| 788 | else: |
|---|
| 789 | seCounter[se.getId()] = se.getNoPlaces() |
|---|
| 790 | seObj[se.getId()]=se |
|---|
| 791 | total += se.getNoPlaces() |
|---|
| 792 | html = [] |
|---|
| 793 | for se in seCounter.keys(): |
|---|
| 794 | html.append(""" |
|---|
| 795 | <tr> |
|---|
| 796 | <td nowrap>%s</td> |
|---|
| 797 | <td> </td> |
|---|
| 798 | <td width="100%%" align="left"><b>%s</b></td> |
|---|
| 799 | </tr> |
|---|
| 800 | """%(seObj[se].getCaption(), seCounter[se])) |
|---|
| 801 | html.sort() |
|---|
| 802 | return "".join(html), total |
|---|
| 803 | |
|---|
| 804 | def _getSessionsInfoHTML(self): |
|---|
| 805 | sesCounter = {} |
|---|
| 806 | sesObj = {} |
|---|
| 807 | for ses in self._conf.getRegistrationForm().getSessionsForm().getSessionList(): |
|---|
| 808 | if ses is not None: |
|---|
| 809 | sesCounter[ses.getId()]=0 |
|---|
| 810 | sesObj[ses.getId()]=ses |
|---|
| 811 | total = 0 |
|---|
| 812 | for reg in self._reglist: |
|---|
| 813 | for ses in reg.getSessionList(): |
|---|
| 814 | if ses is not None: |
|---|
| 815 | if sesCounter.has_key(ses.getId()): |
|---|
| 816 | sesCounter[ses.getId()] += 1 |
|---|
| 817 | else: |
|---|
| 818 | sesCounter[ses.getId()] = 1 |
|---|
| 819 | sesObj[ses.getId()]=ses |
|---|
| 820 | total += 1 |
|---|
| 821 | html = [] |
|---|
| 822 | for ses in sesCounter.keys(): |
|---|
| 823 | html.append(""" |
|---|
| 824 | <tr> |
|---|
| 825 | <td nowrap>%s</td> |
|---|
| 826 | <td> </td> |
|---|
| 827 | <td width="100%%" align="left"><b>%s</b></td> |
|---|
| 828 | </tr> |
|---|
| 829 | """%(sesObj[ses].getTitle(), sesCounter[ses])) |
|---|
| 830 | html.sort() |
|---|
| 831 | return "".join(html), total |
|---|
| 832 | |
|---|
| 833 | def getVars(self): |
|---|
| 834 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 835 | vars["accommodationTypes"], vars["numAccoTypes"] = self._getAccommodationTypesInfoHTML() |
|---|
| 836 | vars["socialEvents"], vars["numSocialEvents"] = self._getSocialEventsInfoHTML() |
|---|
| 837 | vars["sessions"], vars["numSessions"] = self._getSessionsInfoHTML() |
|---|
| 838 | vars["accoCaption"] = self._conf.getRegistrationForm().getAccommodationForm().getTitle() |
|---|
| 839 | vars["socialEventsCaption"] = self._conf.getRegistrationForm().getSocialEventForm().getTitle() |
|---|
| 840 | vars["sessionsCaption"] = self._conf.getRegistrationForm().getSessionsForm().getTitle() |
|---|
| 841 | vars["backURL"]=quoteattr(str(urlHandlers.UHConfModifRegistrantList.getURL(self._conf))) |
|---|
| 842 | return vars |
|---|
| 843 | |
|---|
| 844 | class WPRegistrantsInfo ( WPConfModifRegistrantListBase ): |
|---|
| 845 | |
|---|
| 846 | def _getTabContent(self,params): |
|---|
| 847 | reglist = params["reglist"] |
|---|
| 848 | wc = WConfModifRegistrantsInfo(self._conf, reglist) |
|---|
| 849 | return wc.getHTML() |
|---|
| 850 | |
|---|
| 851 | |
|---|
| 852 | class WPRegistrantBase( WPConferenceModifBase ): |
|---|
| 853 | |
|---|
| 854 | def __init__( self, rh, registrant ): |
|---|
| 855 | self._registrant = self._target = registrant |
|---|
| 856 | WPConferenceModifBase.__init__( self, rh, self._registrant.getConference() ) |
|---|
| 857 | |
|---|
| 858 | |
|---|
| 859 | class WPRegistrantModifBase( WPRegistrantBase ): |
|---|
| 860 | |
|---|
| 861 | def _getNavigationDrawer(self): |
|---|
| 862 | pars = {"target": self._conf, "isModif": True} |
|---|
| 863 | return wcomponents.WNavigationDrawer( pars, bgColor = "white" ) |
|---|
| 864 | |
|---|
| 865 | def _createTabCtrl( self ): |
|---|
| 866 | self._tabCtrl = wcomponents.TabControl() |
|---|
| 867 | self._tabMain = self._tabCtrl.newTab( "main", _("Main"), \ |
|---|
| 868 | urlHandlers.UHRegistrantModification.getURL( self._target ) ) |
|---|
| 869 | self._setActiveTab() |
|---|
| 870 | self._setupTabCtrl() |
|---|
| 871 | |
|---|
| 872 | def _setActiveTab( self ): |
|---|
| 873 | pass |
|---|
| 874 | |
|---|
| 875 | def _setupTabCtrl(self): |
|---|
| 876 | pass |
|---|
| 877 | |
|---|
| 878 | def _setActiveSideMenuItem(self): |
|---|
| 879 | self._regFormMenuItem.setActive(True) |
|---|
| 880 | |
|---|
| 881 | def _getPageContent( self, params ): |
|---|
| 882 | self._createTabCtrl() |
|---|
| 883 | banner = wcomponents.WRegFormBannerModif(self._target).getHTML() |
|---|
| 884 | html = wcomponents.WTabControl( self._tabCtrl, self._getAW() ).getHTML( self._getTabContent( params ) ) |
|---|
| 885 | return banner+html |
|---|
| 886 | |
|---|
| 887 | def _getTabContent( self, params ): |
|---|
| 888 | return _("nothing") |
|---|
| 889 | |
|---|
| 890 | class WPRegistrantModifMain( WPRegistrantModifBase ): |
|---|
| 891 | |
|---|
| 892 | def _setActiveTab( self ): |
|---|
| 893 | self._tabMain.setActive() |
|---|
| 894 | |
|---|
| 895 | |
|---|
| 896 | class WPRegistrantModification( WPRegistrantModifMain ): |
|---|
| 897 | |
|---|
| 898 | def _getTabContent( self, params ): |
|---|
| 899 | wc = WRegistrantModifMain(self._registrant) |
|---|
| 900 | return wc.getHTML() |
|---|
| 901 | |
|---|
| 902 | class WRegistrantModifMain( wcomponents.WTemplated ): |
|---|
| 903 | |
|---|
| 904 | def __init__( self, registrant ): |
|---|
| 905 | self._registrant = registrant |
|---|
| 906 | self._conf = self._registrant.getConference() |
|---|
| 907 | |
|---|
| 908 | |
|---|
| 909 | def _getTransactionHTML(self): |
|---|
| 910 | if self._registrant.getPayed(): |
|---|
| 911 | total=0 |
|---|
| 912 | html=[] |
|---|
| 913 | currency = "" |
|---|
| 914 | html.append( i18nformat(""" |
|---|
| 915 | <tr> |
|---|
| 916 | <tr><td colspan="4" class="title"><b> _("details") </b></td></tr> |
|---|
| 917 | <tr> |
|---|
| 918 | <td style="color:black"><b> _("Quantity") </b></td> |
|---|
| 919 | <td style="color:black"><b> _("Item") </b></td> |
|---|
| 920 | <td style="color:black"><b> _("Unit Price") </b></td> |
|---|
| 921 | <td style="color:black"><b> _("Cost") </b></td> |
|---|
| 922 | <td></td> |
|---|
| 923 | </tr> |
|---|
| 924 | """)) |
|---|
| 925 | for gsf in self._registrant.getMiscellaneousGroupList(): |
|---|
| 926 | regForm = self._conf.getRegistrationForm() |
|---|
| 927 | miscGroup=self._registrant.getMiscellaneousGroupById(gsf.getId()) |
|---|
| 928 | |
|---|
| 929 | if miscGroup is not None: |
|---|
| 930 | for miscItem in miscGroup.getResponseItemList(): |
|---|
| 931 | _billlable=False |
|---|
| 932 | price=0.0 |
|---|
| 933 | quantity=0 |
|---|
| 934 | caption=miscItem.getCaption() |
|---|
| 935 | currency=miscItem.getCurrency() |
|---|
| 936 | v= i18nformat("""-- _("no value selected") --""") |
|---|
| 937 | if miscItem is not None: |
|---|
| 938 | v=miscItem.getValue() |
|---|
| 939 | if miscItem.isBillable(): |
|---|
| 940 | _billlable=miscItem.isBillable() |
|---|
| 941 | caption=miscItem.getValue() |
|---|
| 942 | price=string.atof(miscItem.getPrice()) |
|---|
| 943 | quantity=miscItem.getQuantity() |
|---|
| 944 | total+=price*quantity |
|---|
| 945 | |
|---|
| 946 | gs = miscGroup.getGeneralSection() |
|---|
| 947 | disSect = "" |
|---|
| 948 | if not regForm.hasGeneralSectionForm(gs): |
|---|
| 949 | disSect = """ <span style="color:red">(disabled or removed)</span>""" |
|---|
| 950 | if(quantity>0): |
|---|
| 951 | html.append(""" |
|---|
| 952 | <tr> |
|---|
| 953 | <td ><b>%i</b></td> |
|---|
| 954 | <td>%s:%s</td> |
|---|
| 955 | <td align="right"nowrap >%s</td> |
|---|
| 956 | <td align="right"nowrap >%s %s</td> |
|---|
| 957 | <td>%s</td> |
|---|
| 958 | </tr> |
|---|
| 959 | """%(quantity,gsf.getTitle(),caption,price,price*quantity,currency,disSect) ) |
|---|
| 960 | for bf in self._registrant.getBilledForms(): |
|---|
| 961 | for item in bf.getBilledItems(): |
|---|
| 962 | caption = item.getCaption() |
|---|
| 963 | currency = item.getCurrency() |
|---|
| 964 | price = item.getPrice() |
|---|
| 965 | quantity = item.getQuantity() |
|---|
| 966 | total += price*quantity |
|---|
| 967 | if quantity > 0: |
|---|
| 968 | html.append(""" |
|---|
| 969 | <tr> |
|---|
| 970 | <td><b>%i</b></td> |
|---|
| 971 | <td>%s</td> |
|---|
| 972 | <td align="right" style="padding-right:10px" nowrap >%s</td> |
|---|
| 973 | <td align="right"nowrap >%s %s</td> |
|---|
| 974 | <td></td> |
|---|
| 975 | </tr> |
|---|
| 976 | """%(quantity, caption, price, price*quantity, currency)) |
|---|
| 977 | html.append( i18nformat(""" |
|---|
| 978 | <tr> </tr> |
|---|
| 979 | <tr> |
|---|
| 980 | <td ><b> _("TOTAL") </b></td> |
|---|
| 981 | <td></td> |
|---|
| 982 | <td></td> |
|---|
| 983 | <td align="right"nowrap>%s %s</td> |
|---|
| 984 | </tr> |
|---|
| 985 | """)%(total,currency)) |
|---|
| 986 | transHTML = "" |
|---|
| 987 | if self._registrant.getTransactionInfo(): |
|---|
| 988 | transHTML = self._registrant.getTransactionInfo().getTransactionHTML() |
|---|
| 989 | return i18nformat("""<form action=%s method="POST"> |
|---|
| 990 | <tr> |
|---|
| 991 | <td class="dataCaptionTD"><span class="dataCaptionFormat"> _("Amount")</span></td> |
|---|
| 992 | <td bgcolor="white" class="blacktext">%s</td> |
|---|
| 993 | <td valign="bottom"><input type="submit" name="Payment" value="_("modify")"></td> |
|---|
| 994 | </tr> |
|---|
| 995 | <tr> |
|---|
| 996 | <td class="dataCaptionTD"><span class="dataCaptionFormat"> _("Payment")</span></td> |
|---|
| 997 | <td bgcolor="white" class="blacktext">%s</td> |
|---|
| 998 | <td valign="bottom"></td> |
|---|
| 999 | </tr> |
|---|
| 1000 | <td class="dataCaptionTD"></td> |
|---|
| 1001 | <td bgcolor="white" class="blacktext"><table>%s</table></td> |
|---|
| 1002 | <td valign="bottom"></td> |
|---|
| 1003 | </tr> |
|---|
| 1004 | <tr> |
|---|
| 1005 | <td colspan="3" class="horizontalLine"> </td> |
|---|
| 1006 | </tr> |
|---|
| 1007 | </form> |
|---|
| 1008 | """)%(quoteattr(str(urlHandlers.UHConfModifRegistrantTransactionModify.getURL(self._registrant))), "%.2f %s"%(self._registrant.getTotal(), self._registrant.getConference().getRegistrationForm().getCurrency()), transHTML,"".join(html)) |
|---|
| 1009 | elif self._registrant.doPay(): |
|---|
| 1010 | urlEpayment="" |
|---|
| 1011 | if self._registrant.getConference().getModPay().isActivated() and self._registrant.doPay(): |
|---|
| 1012 | urlEpayment = """<br/><br/><i>Direct access link for epayment:</i><br/><small>%s</small>"""%escape(str(urlHandlers.UHConfRegistrationFormCreationDone.getURL(self._registrant))) |
|---|
| 1013 | return i18nformat(""" <form action=%s method="POST"> |
|---|
| 1014 | <tr> |
|---|
| 1015 | <td class="dataCaptionTD"><span class="dataCaptionFormat">_("Amount")</span></td> |
|---|
| 1016 | <td bgcolor="white" class="blacktext">%s</td> |
|---|
| 1017 | </tr> |
|---|
| 1018 | <tr> |
|---|
| 1019 | <td class="dataCaptionTD"><span class="dataCaptionFormat">_("Payment")</span></td> |
|---|
| 1020 | <td bgcolor="white" class="blacktext">%s%s</td> |
|---|
| 1021 | <td valign="bottom"><input type="submit" name="Payment" value="_("modify")" class="btn"></td> |
|---|
| 1022 | </tr> |
|---|
| 1023 | <tr> |
|---|
| 1024 | <td colspan="3" class="horizontalLine"> </td> |
|---|
| 1025 | </tr> |
|---|
| 1026 | </form> |
|---|
| 1027 | """)%(quoteattr(str(urlHandlers.UHConfModifRegistrantTransactionModify.getURL(self._registrant))), "%.2f %s"%(self._registrant.getTotal(), self._registrant.getConference().getRegistrationForm().getCurrency()),"unpaid",urlEpayment) |
|---|
| 1028 | else : |
|---|
| 1029 | return i18nformat(""" <form action="" method="POST"> |
|---|
| 1030 | <tr> |
|---|
| 1031 | <td class="dataCaptionTD"><span class="dataCaptionFormat"> _("Payment")</span></td> |
|---|
| 1032 | <td bgcolor="white" class="blacktext">%s</td> |
|---|
| 1033 | <td valign="bottom"></td> |
|---|
| 1034 | </tr> |
|---|
| 1035 | <tr> |
|---|
| 1036 | <td colspan="3" class="horizontalLine"> </td> |
|---|
| 1037 | </tr> |
|---|
| 1038 | </form> |
|---|
| 1039 | """)%(" --- ") |
|---|
| 1040 | |
|---|
| 1041 | |
|---|
| 1042 | def _getSessionsHTML(self): |
|---|
| 1043 | regForm = self._conf.getRegistrationForm() |
|---|
| 1044 | sessions = self._registrant.getSessionList() |
|---|
| 1045 | if regForm.getSessionsForm().isEnabled(): |
|---|
| 1046 | if regForm.getSessionsForm().getType() == "2priorities": |
|---|
| 1047 | session1 = i18nformat("""<font color=\"red\">-- _("not selected") --</font>""") |
|---|
| 1048 | session2 = i18nformat("""-- _("not selected") --""") |
|---|
| 1049 | if len(sessions) > 0: |
|---|
| 1050 | session1 = sessions[0].getTitle() |
|---|
| 1051 | if sessions[0].isCancelled(): |
|---|
| 1052 | session1 = i18nformat("""%s <font color=\"red\">( _("cancelled") )""")%session1 |
|---|
| 1053 | if len(sessions) > 1: |
|---|
| 1054 | session2 = sessions[1].getTitle() |
|---|
| 1055 | if sessions[1].isCancelled(): |
|---|
| 1056 | session2 = i18nformat("""%s <font color=\"red\"> ( _("cancelled") )""")%session2 |
|---|
| 1057 | text= i18nformat(""" |
|---|
| 1058 | <table> |
|---|
| 1059 | <tr> |
|---|
| 1060 | <td align="right"><b> _("First Priority"):</b></td> |
|---|
| 1061 | <td align="left">%s</td> |
|---|
| 1062 | </tr> |
|---|
| 1063 | <tr> |
|---|
| 1064 | <td align="right"><b> _("Other option"):</b></td> |
|---|
| 1065 | <td align="left">%s</td> |
|---|
| 1066 | </tr> |
|---|
| 1067 | </table> |
|---|
| 1068 | """)%(session1, session2) |
|---|
| 1069 | return i18nformat(""" |
|---|
| 1070 | <form action=%s method="POST"> |
|---|
| 1071 | <tr> |
|---|
| 1072 | <td class="dataCaptionTD"><span class="dataCaptionFormat"> _("Sessions")</span></td> |
|---|
| 1073 | <td bgcolor="white" class="blacktext">%s</td> |
|---|
| 1074 | <td valign="bottom"><input type="submit" class="btn" name="sesmod" value="_("modify")"></td> |
|---|
| 1075 | </tr> |
|---|
| 1076 | <tr> |
|---|
| 1077 | <td colspan="3" class="horizontalLine"> </td> |
|---|
| 1078 | </tr> |
|---|
| 1079 | </form> |
|---|
| 1080 | """)%(quoteattr(str(urlHandlers.UHConfModifRegistrantSessionModify.getURL(self._registrant))), text) |
|---|
| 1081 | if regForm.getSessionsForm().getType() == "all": |
|---|
| 1082 | sessionList = i18nformat("""<font color=\"red\">--_("not selected")--</font>""") |
|---|
| 1083 | if len(sessions) > 0: |
|---|
| 1084 | sessionList=["<ul>"] |
|---|
| 1085 | for ses in sessions: |
|---|
| 1086 | sesText = "<li>%s</li>"%ses.getTitle() |
|---|
| 1087 | if ses.isCancelled(): |
|---|
| 1088 | sesText = i18nformat("""<li>%s <font color=\"red\"> ( _("cancelled") )</font></li>""")%ses.getTitle() |
|---|
| 1089 | sessionList.append(sesText) |
|---|
| 1090 | sessionList.append("</ul>") |
|---|
| 1091 | sessionList="".join(sessionList) |
|---|
| 1092 | text= """ |
|---|
| 1093 | <table> |
|---|
| 1094 | <tr> |
|---|
| 1095 | <td align="left">%s</td> |
|---|
| 1096 | </tr> |
|---|
| 1097 | </table> |
|---|
| 1098 | """%(sessionList) |
|---|
| 1099 | return i18nformat(""" |
|---|
| 1100 | <form action=%s method="POST"> |
|---|
| 1101 | <tr> |
|---|
| 1102 | <td class="dataCaptionTD"><span class="dataCaptionFormat"> _("Sessions")</span></td> |
|---|
| 1103 | <td bgcolor="white" class="blacktext">%s</td> |
|---|
| 1104 | <td valign="bottom"><input type="submit" class="btn" name="sesmod" value="_("modify")"></td> |
|---|
| 1105 | </tr> |
|---|
| 1106 | <tr> |
|---|
| 1107 | <td colspan="3" class="horizontalLine"> </td> |
|---|
| 1108 | </tr> |
|---|
| 1109 | </form> |
|---|
| 1110 | """)%(quoteattr(str(urlHandlers.UHConfModifRegistrantSessionModify.getURL(self._registrant))), text) |
|---|
| 1111 | return "" |
|---|
| 1112 | |
|---|
| 1113 | def _getAccommodationHTML(self): |
|---|
| 1114 | regForm = self._conf.getRegistrationForm() |
|---|
| 1115 | if regForm.getAccommodationForm().isEnabled(): |
|---|
| 1116 | accommodation = self._registrant.getAccommodation() |
|---|
| 1117 | accoType = i18nformat("""<font color=\"red\">--_("not selected")--</font>""") |
|---|
| 1118 | cancelled = "" |
|---|
| 1119 | if accommodation is not None and accommodation.getAccommodationType() is not None: |
|---|
| 1120 | accoType = accommodation.getAccommodationType().getCaption() |
|---|
| 1121 | if accommodation.getAccommodationType().isCancelled(): |
|---|
| 1122 | cancelled = i18nformat("""<font color=\"red\"> _("(disabled)")</font>""") |
|---|
| 1123 | arrivalDate = i18nformat("""<font color=\"red\">--_("not selected")--</font>""") |
|---|
| 1124 | if accommodation is not None and accommodation.getArrivalDate() is not None: |
|---|
| 1125 | arrivalDate = accommodation.getArrivalDate().strftime("%d-%B-%Y") |
|---|
| 1126 | departureDate = i18nformat("""<font color=\"red\">--_("not selected")--</font>""") |
|---|
| 1127 | if accommodation is not None and accommodation.getDepartureDate() is not None: |
|---|
| 1128 | departureDate = accommodation.getDepartureDate().strftime("%d-%B-%Y") |
|---|
| 1129 | text = i18nformat(""" |
|---|
| 1130 | <table> |
|---|
| 1131 | <tr> |
|---|
| 1132 | <td align="right"><b> _("Arrival date"):</b></td> |
|---|
| 1133 | <td align="left">%s</td> |
|---|
| 1134 | </tr> |
|---|
| 1135 | <tr> |
|---|
| 1136 | <td align="right"><b> _("Departure date"):</b></td> |
|---|
| 1137 | <td align="left">%s</td> |
|---|
| 1138 | </tr> |
|---|
| 1139 | <tr> |
|---|
| 1140 | <td align="right"><b> _("Accommodation type"):</b></td> |
|---|
| 1141 | <td align="left">%s %s</td> |
|---|
| 1142 | </tr> |
|---|
| 1143 | </table> |
|---|
| 1144 | """)%(arrivalDate, departureDate, \ |
|---|
| 1145 | accoType, cancelled) |
|---|
| 1146 | return i18nformat(""" |
|---|
| 1147 | <form action=%s method="POST"> |
|---|
| 1148 | <tr> |
|---|
| 1149 | <td class="dataCaptionTD"><span class="dataCaptionFormat"> _("Accommodation")</span></td> |
|---|
| 1150 | <td bgcolor="white" class="blacktext">%s</td> |
|---|
| 1151 | <td valign="bottom"><input type="submit" class="btn" name="acomod" value="_("modify")"></td> |
|---|
| 1152 | </tr> |
|---|
| 1153 | <tr> |
|---|
| 1154 | <td colspan="3" class="horizontalLine"> </td> |
|---|
| 1155 | </tr> |
|---|
| 1156 | </form> |
|---|
| 1157 | """)%(quoteattr(str(urlHandlers.UHConfModifRegistrantAccoModify.getURL(self._registrant))), text) |
|---|
| 1158 | return "" |
|---|
| 1159 | |
|---|
| 1160 | def _getSocialEventsHTML(self): |
|---|
| 1161 | regForm = self._conf.getRegistrationForm() |
|---|
| 1162 | text = "" |
|---|
| 1163 | if regForm.getSocialEventForm().isEnabled(): |
|---|
| 1164 | socialEvents = self._registrant.getSocialEvents() |
|---|
| 1165 | r = [] |
|---|
| 1166 | for se in socialEvents: |
|---|
| 1167 | cancelled = "" |
|---|
| 1168 | if se.isCancelled(): |
|---|
| 1169 | cancelled = i18nformat("""<font color=\"red\"> ( _("cancelled") )</font>""") |
|---|
| 1170 | if se.getCancelledReason().strip(): |
|---|
| 1171 | cancelled = i18nformat("""<font color=\"red\">( _("cancelled"): %s)</font>""")%se.getCancelledReason().strip() |
|---|
| 1172 | r.append( i18nformat(""" |
|---|
| 1173 | <tr> |
|---|
| 1174 | <td align="left">%s <b>[%s _("place(s) needed")]</b> %s</td> |
|---|
| 1175 | </tr> |
|---|
| 1176 | """)%(se.getCaption(), se.getNoPlaces(), cancelled)) |
|---|
| 1177 | if r == []: |
|---|
| 1178 | text = i18nformat("""--_("no social events selected")--""") |
|---|
| 1179 | else: |
|---|
| 1180 | text = """ |
|---|
| 1181 | <table> |
|---|
| 1182 | %s |
|---|
| 1183 | </table> |
|---|
| 1184 | """%("".join(r)) |
|---|
| 1185 | text = i18nformat(""" |
|---|
| 1186 | <form action=%s method="POST"> |
|---|
| 1187 | <tr> |
|---|
| 1188 | <td class="dataCaptionTD"><span class="dataCaptionFormat"> _("Social events")</span></td> |
|---|
| 1189 | <td bgcolor="white" class="blacktext">%s</td> |
|---|
| 1190 | <td valign="bottom"><input type="submit" class="btn" name="socmod" value="_("modify")"></td> |
|---|
| 1191 | </tr> |
|---|
| 1192 | <tr> |
|---|
| 1193 | <td colspan="3" class="horizontalLine"> </td> |
|---|
| 1194 | </tr> |
|---|
| 1195 | </form> |
|---|
| 1196 | """)%(quoteattr(str(urlHandlers.UHConfModifRegistrantSocialEventsModify.getURL(self._registrant))), text) |
|---|
| 1197 | return text |
|---|
| 1198 | |
|---|
| 1199 | def _getReasonParticipationHTML(self): |
|---|
| 1200 | regForm = self._conf.getRegistrationForm() |
|---|
| 1201 | if regForm.getReasonParticipationForm().isEnabled(): |
|---|
| 1202 | return i18nformat(""" |
|---|
| 1203 | <form action=%s method="POST"> |
|---|
| 1204 | <tr> |
|---|
| 1205 | <td class="dataCaptionTD"><span class="dataCaptionFormat"> _("Reason for participation") </span></td> |
|---|
| 1206 | <td bgcolor="white" class="blacktext">%s</td> |
|---|
| 1207 | <td valign="bottom"><input type="submit" class="btn" name="reamod" value="_("modify")"></td> |
|---|
| 1208 | </tr> |
|---|
| 1209 | <tr> |
|---|
| 1210 | <td colspan="3" class="horizontalLine"> </td> |
|---|
| 1211 | </tr> |
|---|
| 1212 | </form> |
|---|
| 1213 | """)%(quoteattr(str(urlHandlers.UHConfModifRegistrantReasonPartModify.getURL(self._registrant))), self.htmlText( self._registrant.getReasonParticipation() )) |
|---|
| 1214 | return "" |
|---|
| 1215 | |
|---|
| 1216 | def _getItemValueDisplay(self, responseItem): |
|---|
| 1217 | value = responseItem.getValue() |
|---|
| 1218 | try: |
|---|
| 1219 | return responseItem.getGeneralField().getInput().getValueDisplay(value) |
|---|
| 1220 | except: |
|---|
| 1221 | return value |
|---|
| 1222 | |
|---|
| 1223 | def _getMiscInfoItemsHTML(self, gsf): |
|---|
| 1224 | miscGroup=self._registrant.getMiscellaneousGroupById(gsf.getId()) |
|---|
| 1225 | html=["""<table>"""] |
|---|
| 1226 | ######### |
|---|
| 1227 | #jmf start |
|---|
| 1228 | #for f in gsf.getFields(): |
|---|
| 1229 | for f in gsf.getSortedFields(): |
|---|
| 1230 | #jmf end |
|---|
| 1231 | ######### |
|---|
| 1232 | miscItem=None |
|---|
| 1233 | if miscGroup is not None: |
|---|
| 1234 | miscItem=miscGroup.getResponseItemById(f.getId()) |
|---|
| 1235 | v= i18nformat("""--_("no value selected")--""") |
|---|
| 1236 | if miscItem is not None: |
|---|
| 1237 | v = self._getItemValueDisplay(miscItem) |
|---|
| 1238 | html.append(""" |
|---|
| 1239 | <tr> |
|---|
| 1240 | <td align="left" style="max-width: 25%%" valign="top"><b>%s:</b></td> |
|---|
| 1241 | <td align="left" valign="top">%s</td> |
|---|
| 1242 | </tr> |
|---|
| 1243 | <tr><td> </td></tr> |
|---|
| 1244 | """%(f.getCaption(), v)) |
|---|
| 1245 | if miscGroup is not None: |
|---|
| 1246 | for miscItem in miscGroup.getResponseItemList(): |
|---|
| 1247 | f=gsf.getFieldById(miscItem.getId()) |
|---|
| 1248 | if f is None: |
|---|
| 1249 | html.append( _(""" |
|---|
| 1250 | <tr> |
|---|
| 1251 | <td align="left" style="max-width: 25%%"><b>%s:</b></td> |
|---|
| 1252 | <td align="left">%s <font color="red">(cancelled)</font></td> |
|---|
| 1253 | </tr> |
|---|
| 1254 | <tr><td> </td></tr> |
|---|
| 1255 | """) %(miscItem.getCaption(), self._getItemValueDisplay(miscItem)) ) |
|---|
| 1256 | if len(html)==1: |
|---|
| 1257 | html.append( i18nformat(""" |
|---|
| 1258 | <tr><td><font color="black"><i> --_("No fields")--</i></font></td></tr> |
|---|
| 1259 | """)) |
|---|
| 1260 | html.append("</table>") |
|---|
| 1261 | return "".join(html) |
|---|
| 1262 | |
|---|
| 1263 | def _getMiscellaneousInfoHTML(self, gsf): |
|---|
| 1264 | regForm = self._conf.getRegistrationForm() |
|---|
| 1265 | html=[] |
|---|
| 1266 | url=urlHandlers.UHConfModifRegistrantMiscInfoModify.getURL(self._registrant) |
|---|
| 1267 | url.addParam("miscInfoId", gsf.getId()) |
|---|
| 1268 | html.append( i18nformat(""" |
|---|
| 1269 | <form action=%s method="POST"> |
|---|
| 1270 | <tr> |
|---|
| 1271 | <td class="dataCaptionTD" valign="top"><span class="dataCaptionFormat">%s</span></td> |
|---|
| 1272 | <td bgcolor="white" class="blacktext" valign="top">%s</td> |
|---|
| 1273 | <td valign="bottom"><input type="submit" class="btn" name="" value="_("modify")"></td> |
|---|
| 1274 | </tr> |
|---|
| 1275 | <tr> |
|---|
| 1276 | <td colspan="3" class="horizontalLine"> </td> |
|---|
| 1277 | </tr> |
|---|
| 1278 | </form> |
|---|
| 1279 | """)%(quoteattr(str(url)), gsf.getTitle(), self._getMiscInfoItemsHTML(gsf) ) ) |
|---|
| 1280 | return "".join(html) |
|---|
| 1281 | |
|---|
| 1282 | def _getFormSections(self): |
|---|
| 1283 | sects = [] |
|---|
| 1284 | regForm = self._conf.getRegistrationForm() |
|---|
| 1285 | for formSection in regForm.getSortedForms(): |
|---|
| 1286 | if formSection.getId() == "reasonParticipation": |
|---|
| 1287 | sects.append(self._getReasonParticipationHTML()) |
|---|
| 1288 | elif formSection.getId() == "sessions": |
|---|
| 1289 | sects.append(self._getSessionsHTML()) |
|---|
| 1290 | elif formSection.getId() == "accommodation": |
|---|
| 1291 | sects.append(self._getAccommodationHTML()) |
|---|
| 1292 | elif formSection.getId() == "socialEvents": |
|---|
| 1293 | sects.append(self._getSocialEventsHTML()) |
|---|
| 1294 | elif formSection.getId() == "furtherInformation": |
|---|
| 1295 | pass |
|---|
| 1296 | else: |
|---|
| 1297 | sects.append(self._getMiscellaneousInfoHTML(formSection)) |
|---|
| 1298 | return "".join(sects) |
|---|
| 1299 | |
|---|
| 1300 | def _getStatusesHTML(self): |
|---|
| 1301 | regForm = self._conf.getRegistrationForm() |
|---|
| 1302 | url=urlHandlers.UHConfModifRegistrantStatusesModify.getURL(self._registrant) |
|---|
| 1303 | if regForm.getStatusesList() == []: |
|---|
| 1304 | return "" |
|---|
| 1305 | html=["""<table>"""] |
|---|
| 1306 | for st in regForm.getStatusesList(): |
|---|
| 1307 | rst=self._registrant.getStatusById(st.getId()) |
|---|
| 1308 | vcap=" -- no value --" |
|---|
| 1309 | if rst.getStatusValue() is not None: |
|---|
| 1310 | vcap=rst.getStatusValue().getCaption() |
|---|
| 1311 | html.append(""" |
|---|
| 1312 | <tr> |
|---|
| 1313 | <td align="left"><b>%s</b>: %s</td> |
|---|
| 1314 | </tr> |
|---|
| 1315 | """%(rst.getCaption(), vcap)) |
|---|
| 1316 | html.append("""</table>""") |
|---|
| 1317 | html=[ i18nformat(""" |
|---|
| 1318 | <form action=%s method="POST"> |
|---|
| 1319 | <tr> |
|---|
| 1320 | <td class="dataCaptionTD"><span class="dataCaptionFormat"> _("Statuses")</span></td> |
|---|
| 1321 | <td bgcolor="white" class="blacktext">%s</td> |
|---|
| 1322 | <td valign="bottom"><input type="submit" class="btn" name="" value="_("modify")"></td> |
|---|
| 1323 | </tr> |
|---|
| 1324 | <tr> |
|---|
| 1325 | <td colspan="3" class="horizontalLine"> </td> |
|---|
| 1326 | </tr> |
|---|
| 1327 | </form> |
|---|
| 1328 | """)%(quoteattr(str(url)), "".join(html) ) ] |
|---|
| 1329 | return "".join(html) |
|---|
| 1330 | |
|---|
| 1331 | def getVars( self ): |
|---|
| 1332 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 1333 | vars["id"] = self._registrant.getId() |
|---|
| 1334 | vars["title"] = self.htmlText( self._registrant.getTitle() ) |
|---|
| 1335 | vars["familyName"] = self.htmlText( self._registrant.getFamilyName() ) |
|---|
| 1336 | vars["firstName"] = self.htmlText( self._registrant.getFirstName() ) |
|---|
| 1337 | vars["position"] = self.htmlText( self._registrant.getPosition() ) |
|---|
| 1338 | vars["institution"] = self.htmlText( self._registrant.getInstitution() ) |
|---|
| 1339 | vars["address"] = self.htmlText( self._registrant.getAddress() ) |
|---|
| 1340 | vars["city"] = self.htmlText( self._registrant.getCity() ) |
|---|
| 1341 | vars["country"] = self.htmlText( CountryHolder().getCountryById(self._registrant.getCountry()) ) |
|---|
| 1342 | vars["phone"] = self.htmlText( self._registrant.getPhone() ) |
|---|
| 1343 | vars["fax"] = self.htmlText( self._registrant.getFax() ) |
|---|
| 1344 | vars["email"] = self.htmlText( self._registrant.getEmail() ) |
|---|
| 1345 | vars["personalHomepage"] = self.htmlText( self._registrant.getPersonalHomepage() ) |
|---|
| 1346 | vars["registrationDate"] = i18nformat("""--_("date unknown")--""") |
|---|
| 1347 | if self._registrant.getRegistrationDate() is not None: |
|---|
| 1348 | vars["registrationDate"] = "%s (%s)"%(self._registrant.getAdjustedRegistrationDate().strftime("%d-%B-%Y %H:%M"), self._conf.getTimezone()) |
|---|
| 1349 | vars["dataModificationURL"] = quoteattr(str(urlHandlers.UHRegistrantDataModification.getURL(self._registrant))) |
|---|
| 1350 | vars["sections"] = self._getFormSections() |
|---|
| 1351 | vars["statuses"]=self._getStatusesHTML() |
|---|
| 1352 | |
|---|
| 1353 | vars["transaction"]=self._getTransactionHTML() |
|---|
| 1354 | return vars |
|---|
| 1355 | |
|---|
| 1356 | class WPRegistrantDataModification( WPRegistrantModifMain ): |
|---|
| 1357 | |
|---|
| 1358 | def _getTabContent( self, params ): |
|---|
| 1359 | wc = WRegistrantDataModification(self._registrant) |
|---|
| 1360 | return wc.getHTML() |
|---|
| 1361 | |
|---|
| 1362 | class WRegistrantDataModification( wcomponents.WTemplated ): |
|---|
| 1363 | |
|---|
| 1364 | def __init__( self, registrant ): |
|---|
| 1365 | self._registrant = registrant |
|---|
| 1366 | self._conf = self._registrant.getConference() |
|---|
| 1367 | |
|---|
| 1368 | def _getItemHTML(self, item, value): |
|---|
| 1369 | inputHTML = "" |
|---|
| 1370 | if item.getInput() == "list": |
|---|
| 1371 | if item.getId() == "title": |
|---|
| 1372 | for title in TitlesRegistry().getList(): |
|---|
| 1373 | selected = "" |
|---|
| 1374 | if value == title: |
|---|
| 1375 | selected = "selected" |
|---|
| 1376 | inputHTML += """<option value="%s" %s>%s</option>"""%(title, selected, title) |
|---|
| 1377 | inputHTML = """<select name="%s">%s</select>"""%(item.getId(), inputHTML) |
|---|
| 1378 | elif item.getId() == "country": |
|---|
| 1379 | for ck in CountryHolder().getCountrySortedKeys(): |
|---|
| 1380 | selected = "" |
|---|
| 1381 | if value == ck: |
|---|
| 1382 | selected = "selected" |
|---|
| 1383 | inputHTML += """<option value="%s" %s>%s</option>"""%(ck, selected, CountryHolder().getCountryById(ck)) |
|---|
| 1384 | inputHTML = """<select name="%s">%s</select>"""%(item.getId(), inputHTML) |
|---|
| 1385 | else: |
|---|
| 1386 | input = item.getInput() |
|---|
| 1387 | if item.getId() == "email": |
|---|
| 1388 | input = "text" |
|---|
| 1389 | inputHTML = """<input type="%s" name="%s" size="40" value="%s">"""%(input, item.getId(), value) |
|---|
| 1390 | mandatory=" " |
|---|
| 1391 | if item.isMandatory(): |
|---|
| 1392 | mandatory = """<font color="red">* </font>""" |
|---|
| 1393 | html = """ |
|---|
| 1394 | <tr> |
|---|
| 1395 | <td nowrap class="titleCellTD">%s<span class="titleCellFormat">%s</span></td> |
|---|
| 1396 | <td width="100%%" align="left" bgcolor="white" class="blacktext">%s</td> |
|---|
| 1397 | </tr> |
|---|
| 1398 | """%(mandatory, item.getName(), inputHTML) |
|---|
| 1399 | return html |
|---|
| 1400 | |
|---|
| 1401 | def getVars( self ): |
|---|
| 1402 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 1403 | personalData = self._conf.getRegistrationForm().getPersonalData() |
|---|
| 1404 | data = [] |
|---|
| 1405 | sortedKeys = personalData.getSortedKeys() |
|---|
| 1406 | formValues = personalData.getValuesFromRegistrant(self._registrant) |
|---|
| 1407 | for key in sortedKeys: |
|---|
| 1408 | item = personalData.getDataItem(key) |
|---|
| 1409 | data.append(self._getItemHTML(item, formValues.get(item.getId(), ""))) |
|---|
| 1410 | vars["data"] = "".join(data) |
|---|
| 1411 | vars["postURL"] = quoteattr(str(urlHandlers.UHRegistrantPerformDataModification.getURL(self._registrant))) |
|---|
| 1412 | return vars |
|---|
| 1413 | |
|---|
| 1414 | class WConfModifRegistrantSessionsBase(wcomponents.WTemplated): |
|---|
| 1415 | |
|---|
| 1416 | def __init__(self, registrant): |
|---|
| 1417 | self._registrant = registrant |
|---|
| 1418 | self._conf = self._registrant.getConference() |
|---|
| 1419 | self._sessionForm = self._conf.getRegistrationForm().getSessionsForm() |
|---|
| 1420 | |
|---|
| 1421 | def getVars(self): |
|---|
| 1422 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 1423 | vars["title"] = self._sessionForm.getTitle() |
|---|
| 1424 | return vars |
|---|
| 1425 | |
|---|
| 1426 | class WConfModifRegistrantSessions2PrioritiesModify(WConfModifRegistrantSessionsBase): |
|---|
| 1427 | |
|---|
| 1428 | def _getSessionsHTML(self, selectName, sessionValue): |
|---|
| 1429 | selected = "" |
|---|
| 1430 | if sessionValue is None: |
|---|
| 1431 | selected = "selected" |
|---|
| 1432 | html = [ i18nformat("""<select name="%s"> |
|---|
| 1433 | <option value="nosession" %s>--_("None selected")--</option>""")%(selectName, selected)] |
|---|
| 1434 | for ses in self._sessionForm.getSessionList(True): |
|---|
| 1435 | selected = "" |
|---|
| 1436 | if ses == sessionValue: |
|---|
| 1437 | selected = "selected" |
|---|
| 1438 | html.append(""" |
|---|
| 1439 | <option value="%s" %s>%s</option> |
|---|
| 1440 | """%(ses.getId(), selected, ses.getTitle()) ) |
|---|
| 1441 | html = """%s</select>"""%("".join(html)) |
|---|
| 1442 | return html |
|---|
| 1443 | |
|---|
| 1444 | def getVars(self): |
|---|
| 1445 | vars = WConfModifRegistrantSessionsBase.getVars( self ) |
|---|
| 1446 | ses1 = None |
|---|
| 1447 | if len(self._registrant.getSessionList())>0: |
|---|
| 1448 | ses1 = self._registrant.getSessionList()[0] |
|---|
| 1449 | vars ["sessions1"] = self._getSessionsHTML("session1", ses1) |
|---|
| 1450 | ses2 = None |
|---|
| 1451 | if len(self._registrant.getSessionList())>1: |
|---|
| 1452 | ses2 = self._registrant.getSessionList()[1] |
|---|
| 1453 | vars["sessions2"] = self._getSessionsHTML("session2", ses2) |
|---|
| 1454 | return vars |
|---|
| 1455 | |
|---|
| 1456 | |
|---|
| 1457 | |
|---|
| 1458 | class WPRegistrantTransactionModify( WPRegistrantModifMain ): |
|---|
| 1459 | |
|---|
| 1460 | def _getTabContent( self, params ): |
|---|
| 1461 | wc = WConfModifRegistrantTransactionModify(self._registrant) |
|---|
| 1462 | p={"postURL":quoteattr(str(urlHandlers.UHConfModifRegistrantTransactionPeformModify.getURL(self._registrant)))} |
|---|
| 1463 | return wc.getHTML(p) |
|---|
| 1464 | |
|---|
| 1465 | class WConfModifRegistrantTransactionModify(WConfModifRegistrantSessionsBase): |
|---|
| 1466 | |
|---|
| 1467 | def _getTransactionHTML(self): |
|---|
| 1468 | transaction = self._registrant.getTransactionInfo() |
|---|
| 1469 | tmp="" |
|---|
| 1470 | checkedYes="" |
|---|
| 1471 | checkedNo="" |
|---|
| 1472 | if (transaction is None): |
|---|
| 1473 | checkedNo="selected" |
|---|
| 1474 | elif (transaction is None or transaction.isChangeable()): |
|---|
| 1475 | checkedYes="selected" |
|---|
| 1476 | tmp= i18nformat("""<select name="isPayed"><option value="yes" %s> _("yes")</option><option value="no" %s> _("no")</option></select>""")%(checkedYes, checkedNo) |
|---|
| 1477 | return tmp |
|---|
| 1478 | |
|---|
| 1479 | def getVars(self): |
|---|
| 1480 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 1481 | vars ["transation"] = self._getTransactionHTML() |
|---|
| 1482 | vars ["price"] = self._registrant.getTotal() |
|---|
| 1483 | vars ["Currency"] = self._registrant.getRegistrationForm().getCurrency() |
|---|
| 1484 | return vars |
|---|
| 1485 | |
|---|
| 1486 | class WPRegistrantSessionModify( WPRegistrantModifMain ): |
|---|
| 1487 | |
|---|
| 1488 | def _getTabContent( self, params ): |
|---|
| 1489 | if self._registrant.getRegistrationForm().getSessionsForm().getType()=="all": |
|---|
| 1490 | wc = WConfModifRegistrantSessionsAllModify(self._registrant) |
|---|
| 1491 | else: |
|---|
| 1492 | wc = WConfModifRegistrantSessions2PrioritiesModify(self._registrant) |
|---|
| 1493 | p={"postURL":quoteattr(str(urlHandlers.UHConfModifRegistrantSessionPeformModify.getURL(self._registrant)))} |
|---|
| 1494 | return wc.getHTML(p) |
|---|
| 1495 | |
|---|
| 1496 | class WConfModifRegistrantSessionsAllModify(WConfModifRegistrantSessionsBase): |
|---|
| 1497 | |
|---|
| 1498 | def _getSessionsHTML(self, alreadyPaid): |
|---|
| 1499 | html=[] |
|---|
| 1500 | registeredSessions = [ses.getRegSession() for ses in self._registrant.getSessionList()] |
|---|
| 1501 | for session in self._registrant.getRegistrationForm().getSessionsForm().getSessionList(): |
|---|
| 1502 | selected="" |
|---|
| 1503 | if session in registeredSessions: |
|---|
| 1504 | selected=" checked" |
|---|
| 1505 | disabled = "" |
|---|
| 1506 | if alreadyPaid and session.isBillable(): |
|---|
| 1507 | disabled = " disabled" |
|---|
| 1508 | price = "" |
|---|
| 1509 | if session.isBillable() and self._sessionForm.getType() != "2priorities": |
|---|
| 1510 | price = " [%s %s]" % (session.getPrice(), self._conf.getRegistrationForm().getCurrency()) |
|---|
| 1511 | html.append("""<input type="checkbox" name="sessions" value="%s"%s%s>%s%s"""%(session.getId(), selected, disabled, session.getTitle(), price) ) |
|---|
| 1512 | return "<br>".join(html) |
|---|
| 1513 | |
|---|
| 1514 | def getVars(self): |
|---|
| 1515 | vars = WConfModifRegistrantSessionsBase.getVars( self ) |
|---|
| 1516 | vars ["sessions"] = self._getSessionsHTML(self._registrant.getPayed()) |
|---|
| 1517 | return vars |
|---|
| 1518 | |
|---|
| 1519 | class WConfModifRegistrantAccommodationModify(wcomponents.WTemplated): |
|---|
| 1520 | |
|---|
| 1521 | def __init__(self, registrant): |
|---|
| 1522 | self._registrant = registrant |
|---|
| 1523 | self._conf = self._registrant.getConference() |
|---|
| 1524 | self._accommodation = self._conf.getRegistrationForm().getAccommodationForm() |
|---|
| 1525 | |
|---|
| 1526 | def _getDatesHTML(self, name, currentDate, startDate=None, endDate=None, alreadyPaid=False): |
|---|
| 1527 | if name=="arrivalDate": |
|---|
| 1528 | dates = self._accommodation.getArrivalDates() |
|---|
| 1529 | elif name=="departureDate": |
|---|
| 1530 | dates = self._accommodation.getDepartureDates() |
|---|
| 1531 | else: |
|---|
| 1532 | dates = [] |
|---|
| 1533 | curDate = startDate = self._conf.getStartDate() - timedelta(days=1) |
|---|
| 1534 | endDate = self._conf.getEndDate() + timedelta(days=1) |
|---|
| 1535 | while curDate <= endDate: |
|---|
| 1536 | dates.append(curDate) |
|---|
| 1537 | curDate += timedelta(days=1) |
|---|
| 1538 | selected = "" |
|---|
| 1539 | if currentDate is None: |
|---|
| 1540 | selected = "selected" |
|---|
| 1541 | disabled = "" |
|---|
| 1542 | if alreadyPaid: |
|---|
| 1543 | disabled = " disabled" |
|---|
| 1544 | html = [""" |
|---|
| 1545 | <select name="%s"%s> |
|---|
| 1546 | <option value="nodate" %s>-- select a date --</option> |
|---|
| 1547 | """%(name, disabled, selected)] |
|---|
| 1548 | for date in dates: |
|---|
| 1549 | selected = "" |
|---|
| 1550 | if currentDate is not None and currentDate.strftime("%d-%B-%Y") == date.strftime("%d-%B-%Y"): |
|---|
| 1551 | selected = "selected" |
|---|
| 1552 | html.append(""" |
|---|
| 1553 | <option value=%s %s>%s</option> |
|---|
| 1554 | """%(quoteattr(str(date.strftime("%d-%m-%Y"))), selected, date.strftime("%d-%B-%Y"))) |
|---|
| 1555 | html.append("</select>") |
|---|
| 1556 | return "".join(html) |
|---|
| 1557 | |
|---|
| 1558 | def _getAccommodationTypesHTML(self, currentAccoType, alreadyPaid): |
|---|
| 1559 | html=[] |
|---|
| 1560 | for type in self._accommodation.getAccommodationTypesList(): |
|---|
| 1561 | if not type.isCancelled(): |
|---|
| 1562 | selected = "" |
|---|
| 1563 | disabled = "" |
|---|
| 1564 | if currentAccoType == type: |
|---|
| 1565 | selected = "checked=\"checked\"" |
|---|
| 1566 | if alreadyPaid and (type.isBillable() or (currentAccoType and currentAccoType.isBillable())): |
|---|
| 1567 | disabled = ' disabled="disabled"' |
|---|
| 1568 | priceCol = "" |
|---|
| 1569 | if type.isBillable(): |
|---|
| 1570 | priceCol = """<td align="right">%s %s per night</td>""" % (type.getPrice(), type.getRegistrationForm().getCurrency()) |
|---|
| 1571 | html.append("""<tr> |
|---|
| 1572 | <td align="left" style="padding-left:10px"><input type="radio" name="accommodationType" value="%s" %s%s>%s</td> |
|---|
| 1573 | %s |
|---|
| 1574 | </tr> |
|---|
| 1575 | """%(type.getId(), selected, disabled, type.getCaption(), priceCol ) ) |
|---|
| 1576 | else: |
|---|
| 1577 | html.append( i18nformat("""<tr> |
|---|
| 1578 | <td align="left" style="padding-left:10px"> <b>-</b> %s <font color="red">( _("not available at present") )</font></td> |
|---|
| 1579 | </tr> |
|---|
| 1580 | """)%(type.getCaption() ) ) |
|---|
| 1581 | if currentAccoType is not None and currentAccoType.isCancelled() and currentAccoType not in self._accommodation.getAccommodationTypesList(): |
|---|
| 1582 | html.append("""<tr> |
|---|
| 1583 | <td align="left" style="padding-left:10px"> <b>-</b> %s <font color="red">( _("not available at present") )</font></td> |
|---|
| 1584 | </tr> |
|---|
| 1585 | """%(currentAccoType.getCaption() ) ) |
|---|
| 1586 | return "".join(html) |
|---|
| 1587 | |
|---|
| 1588 | |
|---|
| 1589 | def getVars(self): |
|---|
| 1590 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 1591 | acco = self._registrant.getAccommodation() |
|---|
| 1592 | currentArrivalDate = None |
|---|
| 1593 | currentDepartureDate = None |
|---|
| 1594 | currentAccoType = None |
|---|
| 1595 | alreadyPaid = self._registrant.getPayed() |
|---|
| 1596 | if acco is not None: |
|---|
| 1597 | currentArrivalDate = acco.getArrivalDate() |
|---|
| 1598 | currentDepartureDate = acco.getDepartureDate() |
|---|
| 1599 | currentAccoType = acco.getAccommodationType() |
|---|
| 1600 | alreadyPaidAcco = alreadyPaid and acco.isBillable() |
|---|
| 1601 | vars["title"] = self._accommodation.getTitle() |
|---|
| 1602 | vars["arrivalDate"] = self._getDatesHTML("arrivalDate", currentArrivalDate, alreadyPaid=alreadyPaidAcco) |
|---|
| 1603 | vars["departureDate"] = self._getDatesHTML("departureDate", currentDepartureDate, alreadyPaid=alreadyPaidAcco) |
|---|
| 1604 | vars["accommodationTypes"] = self._getAccommodationTypesHTML(currentAccoType, alreadyPaid) |
|---|
| 1605 | return vars |
|---|
| 1606 | |
|---|
| 1607 | class WPRegistrantAccommodationModify( WPRegistrantModifMain ): |
|---|
| 1608 | |
|---|
| 1609 | def _getTabContent( self, params ): |
|---|
| 1610 | wc = WConfModifRegistrantAccommodationModify(self._registrant) |
|---|
| 1611 | p={"postURL":quoteattr(str(urlHandlers.UHConfModifRegistrantAccoPeformModify.getURL(self._registrant)))} |
|---|
| 1612 | return wc.getHTML(p) |
|---|
| 1613 | |
|---|
| 1614 | class WConfModifRegistrantSocialEventsModify(wcomponents.WTemplated): |
|---|
| 1615 | |
|---|
| 1616 | def __init__(self, registrant): |
|---|
| 1617 | self._registrant = registrant |
|---|
| 1618 | self._conf = self._registrant.getConference() |
|---|
| 1619 | self._socialEvents = self._conf.getRegistrationForm().getSocialEventForm() |
|---|
| 1620 | |
|---|
| 1621 | def _getSocialEventsHTML(self, socialEvents=[], alreadyPaid=False): |
|---|
| 1622 | html=[] |
|---|
| 1623 | for se in self._socialEvents.getSocialEventList(): |
|---|
| 1624 | if not se.isCancelled(): |
|---|
| 1625 | checked = "" |
|---|
| 1626 | for ser in socialEvents: |
|---|
| 1627 | if se == ser.getSocialEventItem(): |
|---|
| 1628 | se = ser |
|---|
| 1629 | checked = "checked=\"checked\"" |
|---|
| 1630 | break |
|---|
| 1631 | optList = [] |
|---|
| 1632 | for i in range(1, 10): |
|---|
| 1633 | selected = "" |
|---|
| 1634 | if isinstance(se, registration.SocialEvent) and i == se.getNoPlaces(): |
|---|
| 1635 | selected = " selected" |
|---|
| 1636 | optList.append("""<option value="%s"%s>%s"""%(i, selected, i)) |
|---|
| 1637 | |
|---|
| 1638 | priceCol = "" |
|---|
| 1639 | disabled = "" |
|---|
| 1640 | if se.isBillable(): |
|---|
| 1641 | perPlace = "" |
|---|
| 1642 | if se.isPricePerPlace(): |
|---|
| 1643 | perPlace = ' <acronym title="" onmouseover="IndicoUI.Widgets.Generic.tooltip(this, event, \'per place\')">pp</acronym>' |
|---|
| 1644 | priceCol = """<td align="left" nowrap>%s %s%s</td>""" % (se.getPrice(), self._conf.getRegistrationForm().getCurrency(), perPlace) |
|---|
| 1645 | if alreadyPaid: |
|---|
| 1646 | disabled = ' disabled="disabled"' |
|---|
| 1647 | |
|---|
| 1648 | html.append("""<tr> |
|---|
| 1649 | <td align="left" nowrap style="padding-left:10px"><input type="checkbox" name="socialEvents" value="%s" %s%s>%s |
|---|
| 1650 | </td> |
|---|
| 1651 | <td align="left" nowrap> |
|---|
| 1652 | <select name="places-%s"%s> |
|---|
| 1653 | %s |
|---|
| 1654 | </select> |
|---|
| 1655 | </td> |
|---|
| 1656 | %s |
|---|
| 1657 | </tr> |
|---|
| 1658 | """%(se.getId(), checked, disabled, se.getCaption(), se.getId(), disabled, "".join(optList), priceCol ) ) |
|---|
| 1659 | else: |
|---|
| 1660 | cancelledReason = "(cancelled)" |
|---|
| 1661 | if se.getCancelledReason().strip(): |
|---|
| 1662 | cancelledReason = "(cancelled: %s)"%se.getCancelledReason().strip() |
|---|
| 1663 | html.append("""<tr> |
|---|
| 1664 | <td align="left" colspan="2" nowrap style="padding-left:10px"> <b>-</b> %s <font color="red">%s</font></td> |
|---|
| 1665 | </tr> |
|---|
| 1666 | """%(se.getCaption(), cancelledReason ) ) |
|---|
| 1667 | for se in socialEvents: |
|---|
| 1668 | if se.isCancelled and se.getSocialEventItem() not in self._socialEvents.getSocialEventList(): |
|---|
| 1669 | cancelledReason = "cancelled" |
|---|
| 1670 | if se.getCancelledReason().strip(): |
|---|
| 1671 | cancelledReason = "(cancelled: %s)"%se.getCancelledReason().strip() |
|---|
| 1672 | html.append("""<tr> |
|---|
| 1673 | <td align="left" colspan="2" nowrap style="padding-left:10px"> <b>-</b> %s <font color="red">%s</font></td> |
|---|
| 1674 | </tr> |
|---|
| 1675 | """%(se.getCaption(), cancelledReason ) ) |
|---|
| 1676 | return "".join(html) |
|---|
| 1677 | |
|---|
| 1678 | |
|---|
| 1679 | def getVars(self): |
|---|
| 1680 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 1681 | regSocialEvents = self._registrant.getSocialEvents() |
|---|
| 1682 | vars["title"] = self._socialEvents.getTitle() |
|---|
| 1683 | vars["socialEvents"] = self._getSocialEventsHTML(regSocialEvents, self._registrant.getPayed()) |
|---|
| 1684 | return vars |
|---|
| 1685 | |
|---|
| 1686 | class WPRegistrantSocialEventsModify( WPRegistrantModifMain ): |
|---|
| 1687 | |
|---|
| 1688 | def _getTabContent( self, params ): |
|---|
| 1689 | wc = WConfModifRegistrantSocialEventsModify(self._registrant) |
|---|
| 1690 | p={"postURL":quoteattr(str(urlHandlers.UHConfModifRegistrantSocialEventsPeformModify.getURL(self._registrant)))} |
|---|
| 1691 | return wc.getHTML(p) |
|---|
| 1692 | |
|---|
| 1693 | class WConfModifRegistrantReasonParticipationModify(wcomponents.WTemplated): |
|---|
| 1694 | |
|---|
| 1695 | def __init__(self, registrant): |
|---|
| 1696 | self._registrant = registrant |
|---|
| 1697 | self._conf = self._registrant.getConference() |
|---|
| 1698 | self._reasonParticipation = self._conf.getRegistrationForm().getReasonParticipationForm() |
|---|
| 1699 | |
|---|
| 1700 | |
|---|
| 1701 | def getVars(self): |
|---|
| 1702 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 1703 | vars["title"] = self._reasonParticipation.getTitle() |
|---|
| 1704 | vars["reasonParticipation"] = self._registrant.getReasonParticipation() |
|---|
| 1705 | return vars |
|---|
| 1706 | |
|---|
| 1707 | class WPRegistrantReasonParticipationModify( WPRegistrantModifMain ): |
|---|
| 1708 | |
|---|
| 1709 | def _getTabContent( self, params ): |
|---|
| 1710 | wc = WConfModifRegistrantReasonParticipationModify(self._registrant) |
|---|
| 1711 | p={"postURL":quoteattr(str(urlHandlers.UHConfModifRegistrantReasonPartPeformModify.getURL(self._registrant)))} |
|---|
| 1712 | return wc.getHTML(p) |
|---|
| 1713 | |
|---|
| 1714 | class WConfModifRegistrantMiscInfoModify(wcomponents.WTemplated): |
|---|
| 1715 | |
|---|
| 1716 | def __init__(self, miscGroup): |
|---|
| 1717 | self._miscGroup = miscGroup |
|---|
| 1718 | self._registrant = self._miscGroup.getRegistrant() |
|---|
| 1719 | self._conf = self._registrant.getConference() |
|---|
| 1720 | |
|---|
| 1721 | def _getFieldsHTML(self): |
|---|
| 1722 | html=[] |
|---|
| 1723 | ############ |
|---|
| 1724 | # jmf-start |
|---|
| 1725 | #for f in self._miscGroup.getGeneralSection().getFields(): |
|---|
| 1726 | for f in self._miscGroup.getGeneralSection().getSortedFields(): |
|---|
| 1727 | # jmf-start |
|---|
| 1728 | ############ |
|---|
| 1729 | v="" |
|---|
| 1730 | miscItem = None |
|---|
| 1731 | if self._miscGroup.getResponseItemById(f.getId()) is not None: |
|---|
| 1732 | miscItem=self._miscGroup.getResponseItemById(f.getId()) |
|---|
| 1733 | v=miscItem.getValue() |
|---|
| 1734 | price=v=miscItem.getPrice() |
|---|
| 1735 | html.append(""" |
|---|
| 1736 | <tr> |
|---|
| 1737 | <td> |
|---|
| 1738 | %s |
|---|
| 1739 | </td> |
|---|
| 1740 | </tr> |
|---|
| 1741 | """%(f.getInput().getModifHTML(miscItem, self._registrant)) ) |
|---|
| 1742 | return "".join(html) |
|---|
| 1743 | |
|---|
| 1744 | |
|---|
| 1745 | def getVars(self): |
|---|
| 1746 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 1747 | vars["title"] = self._miscGroup.getTitle() |
|---|
| 1748 | vars["fields"] = self._getFieldsHTML() |
|---|
| 1749 | return vars |
|---|
| 1750 | |
|---|
| 1751 | class WPRegistrantMiscInfoModify( WPRegistrantModifMain ): |
|---|
| 1752 | |
|---|
| 1753 | def __init__( self, rh, miscGroup ): |
|---|
| 1754 | WPRegistrantModifMain.__init__( self, rh, miscGroup.getRegistrant() ) |
|---|
| 1755 | self._miscGroup=miscGroup |
|---|
| 1756 | |
|---|
| 1757 | def _getTabContent( self, params ): |
|---|
| 1758 | wc = WConfModifRegistrantMiscInfoModify(self._miscGroup) |
|---|
| 1759 | p={"postURL":quoteattr(str(urlHandlers.UHConfModifRegistrantMiscInfoPerformModify.getURL(self._miscGroup)))} |
|---|
| 1760 | return wc.getHTML(p) |
|---|
| 1761 | |
|---|
| 1762 | class WConfModifRegistrantStatusesModify(wcomponents.WTemplated): |
|---|
| 1763 | |
|---|
| 1764 | def __init__(self, reg): |
|---|
| 1765 | self._conf = reg.getConference() |
|---|
| 1766 | self._registrant = reg |
|---|
| 1767 | |
|---|
| 1768 | def _getStatusHTML(self, st): |
|---|
| 1769 | html=["""<table>"""] |
|---|
| 1770 | rst=self._registrant.getStatusById(st.getId()) |
|---|
| 1771 | somechecked=False |
|---|
| 1772 | for v in st.getStatusValuesList(): |
|---|
| 1773 | checked="" |
|---|
| 1774 | if rst.getStatusValue() is not None and v.getId() == rst.getStatusValue().getId(): |
|---|
| 1775 | somechecked=True |
|---|
| 1776 | checked=" checked" |
|---|
| 1777 | html.append(""" |
|---|
| 1778 | <tr><td><input type="radio" name="statuses-%s" value="%s"%s>%s</td></tr> |
|---|
| 1779 | """%(st.getId(), v.getId(), checked, v.getCaption())) |
|---|
| 1780 | checked="" |
|---|
| 1781 | if not somechecked: |
|---|
| 1782 | checked=" checked" |
|---|
| 1783 | html.insert(1, i18nformat(""" |
|---|
| 1784 | <tr><td><input type="radio" name="statuses-%s" value="novalue"%s>--_("no value")--</td></tr> |
|---|
| 1785 | """)%(st.getId(), checked)) |
|---|
| 1786 | html.append("""</table>""") |
|---|
| 1787 | return "".join(html) |
|---|
| 1788 | |
|---|
| 1789 | |
|---|
| 1790 | def getVars(self): |
|---|
| 1791 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 1792 | html=["""<table border="0" cellpadding="0" cellspacing="0" valign="top">"""] |
|---|
| 1793 | for st in self._conf.getRegistrationForm().getStatusesList(): |
|---|
| 1794 | html.append(""" |
|---|
| 1795 | <tr> |
|---|
| 1796 | <td align="right" valign="top" style="border-bottom:1px solid #777777"><b>%s:</b> </td> |
|---|
| 1797 | <td align="left" valign="top" style="border-bottom:1px solid #777777">%s</td> |
|---|
| 1798 | </tr> |
|---|
| 1799 | """%(st.getCaption(), self._getStatusHTML(st))) |
|---|
| 1800 | html.append("""</table>""") |
|---|
| 1801 | vars["statuses"]="".join(html) |
|---|
| 1802 | return vars |
|---|
| 1803 | |
|---|
| 1804 | class WPRegistrantStatusesModify( WPRegistrantModifMain ): |
|---|
| 1805 | |
|---|
| 1806 | def _getTabContent( self, params ): |
|---|
| 1807 | wc = WConfModifRegistrantStatusesModify(self._registrant) |
|---|
| 1808 | p={"postURL":quoteattr(str(urlHandlers.UHConfModifRegistrantStatusesPerformModify.getURL(self._registrant)))} |
|---|
| 1809 | return wc.getHTML(p) |
|---|
| 1810 | |
|---|
| 1811 | # ----------------- DISPLAY AREA --------------------------- |
|---|
| 1812 | |
|---|
| 1813 | class WPConfRegistrantsList( WPConferenceDefaultDisplayBase ): |
|---|
| 1814 | |
|---|
| 1815 | def _getBody( self, params ): |
|---|
| 1816 | sortingCrit=params.get("sortingCrit",None) |
|---|
| 1817 | filterCrit=params.get("filterCrit",None) |
|---|
| 1818 | sessionFilterName=params.get("sessionFilterName", "session") |
|---|
| 1819 | order = params.get("order",None) |
|---|
| 1820 | wc = WConfRegistrantsList( self._conf, filterCrit, sortingCrit, order, sessionFilterName) |
|---|
| 1821 | return wc.getHTML() |
|---|
| 1822 | |
|---|
| 1823 | def _defineSectionMenu( self ): |
|---|
| 1824 | WPConferenceDefaultDisplayBase._defineSectionMenu( self ) |
|---|
| 1825 | self._sectionMenu.setCurrentItem(self._registrantsListOpt) |
|---|
| 1826 | |
|---|
| 1827 | class WConfRegistrantsList( wcomponents.WTemplated ): |
|---|
| 1828 | |
|---|
| 1829 | def __init__( self, conference, filterCrit, sortingCrit, order, sessionFilterName ): |
|---|
| 1830 | self._conf = conference |
|---|
| 1831 | self._regForm = self._conf.getRegistrationForm() |
|---|
| 1832 | self._filterCrit=filterCrit |
|---|
| 1833 | self._sortingCrit=sortingCrit |
|---|
| 1834 | self._order=order |
|---|
| 1835 | self._sessionFilterName=sessionFilterName |
|---|
| 1836 | |
|---|
| 1837 | def _getURL( self ): |
|---|
| 1838 | #builds the URL to the contribution list page |
|---|
| 1839 | # preserving the current filter and sorting status |
|---|
| 1840 | url = urlHandlers.UHConfRegistrantsList.getURL(self._conf) |
|---|
| 1841 | # if self._filterCrit.getField("accomm"): |
|---|
| 1842 | # url.addParam("accomm",self._filterCrit.getField("accomm").getValues()) |
|---|
| 1843 | # if self._filterCrit.getField("accomm").getShowNoValue(): |
|---|
| 1844 | # url.addParam("accommShowNoValue","1") |
|---|
| 1845 | # |
|---|
| 1846 | if self._filterCrit.getField(self._sessionFilterName): |
|---|
| 1847 | url.addParam("session",self._filterCrit.getField(self._sessionFilterName).getValues()) |
|---|
| 1848 | if self._filterCrit.getField(self._sessionFilterName).getShowNoValue(): |
|---|
| 1849 | url.addParam("sessionShowNoValue","1") |
|---|
| 1850 | |
|---|
| 1851 | if self._sessionFilterName == "sessionfirstpriority": |
|---|
| 1852 | url.addParam("firstChoice", "1") |
|---|
| 1853 | # |
|---|
| 1854 | # if self._filterCrit.getField("event"): |
|---|
| 1855 | # url.addParam("event",self._filterCrit.getField("event").getValues()) |
|---|
| 1856 | # if self._filterCrit.getField("event").getShowNoValue(): |
|---|
| 1857 | # url.addParam("eventShowNoValue","1") |
|---|
| 1858 | # |
|---|
| 1859 | if self._sortingCrit.getField(): |
|---|
| 1860 | url.addParam("sortBy",self._sortingCrit.getField().getId()) |
|---|
| 1861 | url.addParam("order","down") |
|---|
| 1862 | |
|---|
| 1863 | # url.addParam("disp",self._getDisplay()) |
|---|
| 1864 | |
|---|
| 1865 | return url |
|---|
| 1866 | |
|---|
| 1867 | def _getRegistrantsHTML( self, reg ): |
|---|
| 1868 | fullName = reg.getFullName() |
|---|
| 1869 | institution = "" |
|---|
| 1870 | if self._regForm.getPersonalData().getDataItem("institution").isEnabled(): |
|---|
| 1871 | institution = """<td valign="top" class="abstractDataCell">%s</td>"""%(self.htmlText(reg.getInstitution()) or " ") |
|---|
| 1872 | position = "" |
|---|
| 1873 | if self._regForm.getPersonalData().getDataItem("position").isEnabled(): |
|---|
| 1874 | position = """<td valign="top" class="abstractDataCell">%s</td>"""%(self.htmlText(reg.getPosition()) or " ") |
|---|
| 1875 | city = "" |
|---|
| 1876 | if self._regForm.getPersonalData().getDataItem("city").isEnabled(): |
|---|
| 1877 | city = """<td valign="top" class="abstractDataCell">%s</td>"""%(self.htmlText(reg.getCity()) or " ") |
|---|
| 1878 | country = "" |
|---|
| 1879 | if self._regForm.getPersonalData().getDataItem("country").isEnabled(): |
|---|
| 1880 | country = """<td valign="top" class="abstractDataCell">%s</td>"""%(self.htmlText(CountryHolder().getCountryById(reg.getCountry())) or " ") |
|---|
| 1881 | sessions="" |
|---|
| 1882 | if self._regForm.getSessionsForm().isEnabled(): |
|---|
| 1883 | sessionList = [] |
|---|
| 1884 | for ses in reg.getSessionList(): |
|---|
| 1885 | sessionList.append(self.htmlText(ses.getCode())) |
|---|
| 1886 | sessions = "<br>".join(sessionList) |
|---|
| 1887 | sessions = """<td valign="top" class="abstractDataCell" nowrap>%s</td>"""%(sessions or " ") |
|---|
| 1888 | html = """ |
|---|
| 1889 | <tr> |
|---|
| 1890 | <td valign="top" nowrap class="abstractLeftDataCell">%s</td> |
|---|
| 1891 | %s |
|---|
| 1892 | %s |
|---|
| 1893 | %s |
|---|
| 1894 | %s |
|---|
| 1895 | %s |
|---|
| 1896 | </tr> |
|---|
| 1897 | """%(self.htmlText(fullName), |
|---|
| 1898 | institution, |
|---|
| 1899 | position, city, |
|---|
| 1900 | country, |
|---|
| 1901 | sessions) |
|---|
| 1902 | return html |
|---|
| 1903 | |
|---|
| 1904 | def _getSessHTML(self): |
|---|
| 1905 | sessform =self._regForm.getSessionsForm() |
|---|
| 1906 | sesstypes = sessform.getSessionList() |
|---|
| 1907 | checked="" |
|---|
| 1908 | if self._filterCrit.getField(self._sessionFilterName).getShowNoValue(): |
|---|
| 1909 | checked=" checked" |
|---|
| 1910 | res=[ i18nformat("""<input type="checkbox" name="sessionShowNoValue" value="--none--"%s> --_("not specified")--""")%checked] |
|---|
| 1911 | for sess in sesstypes: |
|---|
| 1912 | checked="" |
|---|
| 1913 | if sess.getId() in self._filterCrit.getField(self._sessionFilterName).getValues(): |
|---|
| 1914 | checked=" checked" |
|---|
| 1915 | res.append("""<input type="checkbox" name="session" value=%s%s>%s"""%(quoteattr(str(sess.getId())),checked,self.htmlText(sess.getTitle()))) |
|---|
| 1916 | if sessform.getType() == "2priorities": |
|---|
| 1917 | checked="" |
|---|
| 1918 | if self._sessionFilterName == "sessionfirstpriority": |
|---|
| 1919 | checked=" checked" |
|---|
| 1920 | res.append( i18nformat("""<b>------</b><br><input type="checkbox" name="firstChoice" value="firstChoice"%s><i> _("Only by first choice") </i>""")%checked) |
|---|
| 1921 | return "<br>".join(res) |
|---|
| 1922 | |
|---|
| 1923 | def _getFilterOptionsHTML(self, currentSortingHTML): |
|---|
| 1924 | filterPostURL=quoteattr("%s#results"%str(urlHandlers.UHConfRegistrantsList.getURL(self._conf))) |
|---|
| 1925 | return i18nformat("""<tr> |
|---|
| 1926 | <td width="100%%"> |
|---|
| 1927 | <br> |
|---|
| 1928 | <form action=%s method="POST"> |
|---|
| 1929 | %s |
|---|
| 1930 | <table width="100%%" align="center" border="0" style="border-left: 1px solid #777777;border-top: 1px solid #777777;"> |
|---|
| 1931 | <tr> |
|---|
| 1932 | <td class="groupTitle" style="background:#E5E5E5; color:gray"> _("Display options") </td> |
|---|
| 1933 | </tr> |
|---|
| 1934 | <tr> |
|---|
| 1935 | <td> |
|---|
| 1936 | <table width="100%%"> |
|---|
| 1937 | <tr> |
|---|
| 1938 | <td> |
|---|
| 1939 | <table align="center" cellspacing="10" width="100%%"> |
|---|
| 1940 | <tr> |
|---|
| 1941 | <td align="center" class="titleCellFormat" style="border-bottom: 1px solid #5294CC;"> _("show sessions") </td> |
|---|
| 1942 | </tr> |
|---|
| 1943 | <tr> |
|---|
| 1944 | <td valign="top" style="border-right:1px solid #777777;">%s</td> |
|---|
| 1945 | </tr> |
|---|
| 1946 | </table> |
|---|
| 1947 | </td> |
|---|
| 1948 | </tr> |
|---|
| 1949 | <tr> |
|---|
| 1950 | <td align="center" style="border-top:1px solid #777777;padding:10px"><input type="submit" class="btn" name="OK" value="_("apply filter")"></td> |
|---|
| 1951 | </tr> |
|---|
| 1952 | </table> |
|---|
| 1953 | </td> |
|---|
| 1954 | </tr> |
|---|
| 1955 | </table> |
|---|
| 1956 | </form> |
|---|
| 1957 | </td> |
|---|
| 1958 | </tr> |
|---|
| 1959 | """)%(filterPostURL, currentSortingHTML, self._getSessHTML()) |
|---|
| 1960 | |
|---|
| 1961 | def getVars( self ): |
|---|
| 1962 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 1963 | vars["regForm"]= self._regForm |
|---|
| 1964 | l=[] |
|---|
| 1965 | lr=self._conf.getRegistrantsList(True) |
|---|
| 1966 | f = filters.SimpleFilter(self._filterCrit,self._sortingCrit) |
|---|
| 1967 | for rp in f.apply(lr): |
|---|
| 1968 | l.append(self._getRegistrantsHTML(rp)) |
|---|
| 1969 | if self._order =="up": |
|---|
| 1970 | l.reverse() |
|---|
| 1971 | vars["registrants"] = "".join(l) |
|---|
| 1972 | vars["numRegistrants"]=str(len(l)) |
|---|
| 1973 | |
|---|
| 1974 | # Head Table Titles |
|---|
| 1975 | currentSorting="" |
|---|
| 1976 | if self._sortingCrit.getField() is not None: |
|---|
| 1977 | currentSorting=self._sortingCrit.getField().getSpecialId() |
|---|
| 1978 | |
|---|
| 1979 | currentSortingHTML = "" |
|---|
| 1980 | # --- Name |
|---|
| 1981 | url=self._getURL() |
|---|
| 1982 | url.addParam("sortBy","Name") |
|---|
| 1983 | nameImg="" |
|---|
| 1984 | vars["imgNameTitle"]="" |
|---|
| 1985 | if currentSorting == "Name": |
|---|
| 1986 | currentSortingHTML = """<input type="hidden" name="sortBy" value="Name">""" |
|---|
| 1987 | if self._order == "down": |
|---|
| 1988 | vars["imgNameTitle"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow"))) |
|---|
| 1989 | url.addParam("order","up") |
|---|
| 1990 | elif self._order == "up": |
|---|
| 1991 | vars["imgNameTitle"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow"))) |
|---|
| 1992 | url.addParam("order","down") |
|---|
| 1993 | vars["urlNameTitle"]=quoteattr("%s#results"%str(url)) |
|---|
| 1994 | |
|---|
| 1995 | # --- Institution |
|---|
| 1996 | url=self._getURL() |
|---|
| 1997 | url.addParam("sortBy","Institution") |
|---|
| 1998 | nameImg="" |
|---|
| 1999 | vars["imgInstitutionTitle"]="" |
|---|
| 2000 | if currentSorting == "Institution": |
|---|
| 2001 | currentSortingHTML = """<input type="hidden" name="sortBy" value="Institution">""" |
|---|
| 2002 | if self._order == "down": |
|---|
| 2003 | vars["imgInstitutionTitle"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow"))) |
|---|
| 2004 | url.addParam("order","up") |
|---|
| 2005 | elif self._order == "up": |
|---|
| 2006 | vars["imgInstitutionTitle"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow"))) |
|---|
| 2007 | url.addParam("order","down") |
|---|
| 2008 | vars["urlInstitutionTitle"]=quoteattr("%s#results"%str(url)) |
|---|
| 2009 | |
|---|
| 2010 | # --- Position |
|---|
| 2011 | url=self._getURL() |
|---|
| 2012 | url.addParam("sortBy","Position") |
|---|
| 2013 | nameImg="" |
|---|
| 2014 | vars["imgPositionTitle"]="" |
|---|
| 2015 | if currentSorting == "Position": |
|---|
| 2016 | currentSortingHTML = """<input type="hidden" name="sortBy" value="Position">""" |
|---|
| 2017 | if self._order == "down": |
|---|
| 2018 | vars["imgPositionTitle"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow"))) |
|---|
| 2019 | url.addParam("order","up") |
|---|
| 2020 | elif self._order == "up": |
|---|
| 2021 | vars["imgPositionTitle"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow"))) |
|---|
| 2022 | url.addParam("order","down") |
|---|
| 2023 | vars["urlPositionTitle"]=quoteattr("%s#results"%str(url)) |
|---|
| 2024 | |
|---|
| 2025 | # --- City |
|---|
| 2026 | url=self._getURL() |
|---|
| 2027 | url.addParam("sortBy","City") |
|---|
| 2028 | nameImg="" |
|---|
| 2029 | vars["imgCityTitle"]="" |
|---|
| 2030 | if currentSorting == "City": |
|---|
| 2031 | currentSortingHTML = """<input type="hidden" name="sortBy" value="City">""" |
|---|
| 2032 | if self._order == "down": |
|---|
| 2033 | vars["imgCityTitle"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow"))) |
|---|
| 2034 | url.addParam("order","up") |
|---|
| 2035 | elif self._order == "up": |
|---|
| 2036 | vars["imgCityTitle"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow"))) |
|---|
| 2037 | url.addParam("order","down") |
|---|
| 2038 | vars["urlCityTitle"]=quoteattr("%s#results"%str(url)) |
|---|
| 2039 | |
|---|
| 2040 | |
|---|
| 2041 | # --- Country |
|---|
| 2042 | url=self._getURL() |
|---|
| 2043 | url.addParam("sortBy","Country") |
|---|
| 2044 | nameImg="" |
|---|
| 2045 | vars["imgCountryTitle"]="" |
|---|
| 2046 | if currentSorting == "Country": |
|---|
| 2047 | currentSortingHTML = """<input type="hidden" name="sortBy" value="Country">""" |
|---|
| 2048 | if self._order == "down": |
|---|
| 2049 | vars["imgCountryTitle"] = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow"))) |
|---|
| 2050 | url.addParam("order","up") |
|---|
| 2051 | elif self._order == "up": |
|---|
| 2052 | vars["imgCountryTitle"] = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow"))) |
|---|
| 2053 | url.addParam("order","down") |
|---|
| 2054 | vars["urlCountryTitle"]=quoteattr("%s#results"%str(url)) |
|---|
| 2055 | |
|---|
| 2056 | # --- Sessions |
|---|
| 2057 | |
|---|
| 2058 | vars["sessionsTitle"] = "" |
|---|
| 2059 | |
|---|
| 2060 | if self._regForm.getSessionsForm().isEnabled(): |
|---|
| 2061 | url=self._getURL() |
|---|
| 2062 | url.addParam("sortBy","Sessions") |
|---|
| 2063 | nameImg="" |
|---|
| 2064 | imgSessionTitle="" |
|---|
| 2065 | if currentSorting == "Sessions": |
|---|
| 2066 | currentSortingHTML = """<input type="hidden" name="sortBy" value="Sessions">""" |
|---|
| 2067 | if self._order == "down": |
|---|
| 2068 | imgSessionTitle = """<img src=%s alt="down">"""%(quoteattr(Config.getInstance().getSystemIconURL("downArrow"))) |
|---|
| 2069 | url.addParam("order","up") |
|---|
| 2070 | elif self._order == "up": |
|---|
| 2071 | imgSessionTitle = """<img src=%s alt="up">"""%(quoteattr(Config.getInstance().getSystemIconURL("upArrow"))) |
|---|
| 2072 | url.addParam("order","down") |
|---|
| 2073 | urlSessionTitle=quoteattr("%s#results"%str(url)) |
|---|
| 2074 | vars["sessionsTitle"] = """<td nowrap class="titleCellFormat" style="border-right:5px solid #FFFFFF;border-left:5px solid #FFFFFF;border-bottom: 1px solid #5294CC;">%s<a href=%s>%s</a></td>"""%(imgSessionTitle, urlSessionTitle, self._conf.getRegistrationForm().getSessionsForm().getTitle()) |
|---|
| 2075 | |
|---|
| 2076 | # --- Filter Options |
|---|
| 2077 | vars["filterOptions"]="" |
|---|
| 2078 | if self._regForm.getSessionsForm().isEnabled(): |
|---|
| 2079 | vars["filterOptions"]=self._getFilterOptionsHTML(currentSortingHTML) |
|---|
| 2080 | return vars |
|---|
| 2081 | #------------------------------------------------------------------------------------------------------------------------ |
|---|
| 2082 | """ |
|---|
| 2083 | Badge Printing classes |
|---|
| 2084 | """ |
|---|
| 2085 | class WRegistrantModifPrintBadges( wcomponents.WTemplated ): |
|---|
| 2086 | |
|---|
| 2087 | def __init__( self, conference, selectedRegistrants, user=None ): |
|---|
| 2088 | self.__conf = conference |
|---|
| 2089 | self._user=user |
|---|
| 2090 | self.__selectedRegistrants = selectedRegistrants |
|---|
| 2091 | |
|---|
| 2092 | def getVars( self ): |
|---|
| 2093 | vars = wcomponents.WTemplated.getVars( self ) |
|---|
| 2094 | |
|---|
| 2095 | vars['CreatePDFURL']=str(urlHandlers.UHConfModifBadgePrintingPDF.getURL(self.__conf)) |
|---|
| 2096 | vars['registrantNamesList'] = "; ".join([self.__conf.getRegistrantById(id).getFullName() for id in self.__selectedRegistrants]) |
|---|
| 2097 | vars['registrantList'] = ",".join(self.__selectedRegistrants) |
|---|
| 2098 | vars['badgeDesignURL'] = str(urlHandlers.UHConfModifBadgePrinting.getURL(self.__conf)) |
|---|
| 2099 | |
|---|
| 2100 | templateListHTML = [] |
|---|
| 2101 | first = True |
|---|
| 2102 | |
|---|
| 2103 | nTemplates = len(self.__conf.getBadgeTemplateManager().getTemplates()) |
|---|
| 2104 | nColumns = 3 |
|---|
| 2105 | nPerColumn = int(math.ceil(nTemplates / nColumns)) |
|---|
| 2106 | |
|---|
| 2107 | n = 0 |
|---|
| 2108 | templateListHTML.append(""" <tr>""") |
|---|
| 2109 | |
|---|
| 2110 | sortedTemplates = self.__conf.getBadgeTemplateManager().getTemplates().items() |
|---|
| 2111 | sortedTemplates.sort(lambda item1, item2: cmp(item1[1].getName(), item2[1].getName())) |
|---|
| 2112 | for templateId, template in sortedTemplates: |
|---|
| 2113 | |
|---|
| 2114 | templateListHTML.append(""" <td>""") |
|---|
| 2115 | |
|---|
| 2116 | radio = [] |
|---|
| 2117 | radio.append(""" <input type="radio" name="templateId" value='""") |
|---|
| 2118 | radio.append(str(templateId)) |
|---|
| 2119 | radio.append("""' id='""") |
|---|
| 2120 | radio.append(str(templateId)) |
|---|
| 2121 | radio.append("""'""") |
|---|
| 2122 | if first: |
|---|
| 2123 | first = False |
|---|
| 2124 | radio.append(""" CHECKED """) |
|---|
| 2125 | radio.append(""">""") |
|---|
| 2126 | templateListHTML.append("".join(radio)) |
|---|
| 2127 | templateListHTML.append("".join ([""" """, |
|---|
| 2128 | """<label for='""", |
|---|
| 2129 | str(templateId), |
|---|
| 2130 | """'>""", |
|---|
| 2131 | template.getName(), |
|---|
| 2132 | """</label>""", |
|---|
| 2133 | """ """])) |
|---|
| 2134 | |
|---|
| 2135 | templateListHTML.append(""" </td>""") |
|---|
| 2136 | |
|---|
| 2137 | n = n + 1 |
|---|
| 2138 | if n == nPerColumn + 1: |
|---|
| 2139 | n = 0 |
|---|
| 2140 | templateListHTML.append(""" </tr>""") |
|---|
| 2141 | templateListHTML.append(""" <tr>""") |
|---|
| 2142 | |
|---|
| 2143 | |
|---|
| 2144 | |
|---|
| 2145 | templateListHTML.append(""" </tr>""") |
|---|
| 2146 | vars["templateList"] = "\n".join(templateListHTML) |
|---|
| 2147 | |
|---|
| 2148 | wcPDFOptions = WConfModifBadgePDFOptions(self.__conf) |
|---|
| 2149 | vars['PDFOptions'] = wcPDFOptions.getHTML() |
|---|
| 2150 | |
|---|
| 2151 | return vars |
|---|
| 2152 | |
|---|
| 2153 | |
|---|
| 2154 | class WPRegistrantModifPrintBadges( WPConfModifRegistrantListBase ): |
|---|
| 2155 | |
|---|
| 2156 | def __init__(self, rh, conf, selectedRegistrants): |
|---|
| 2157 | WPConfModifRegistrantListBase.__init__(self, rh, conf) |
|---|
| 2158 | self._selectedRegistrants = selectedRegistrants |
|---|
| 2159 | |
|---|
| 2160 | def _getTabContent( self, params ): |
|---|
| 2161 | wc = WRegistrantModifPrintBadges( self._conf, selectedRegistrants = self._selectedRegistrants ) |
|---|
| 2162 | return wc.getHTML() |
|---|