def unprocess_field_data(cls, versioned_data, unversioned_data): choices = sorted([{ 'caption': v, 'countryKey': k } for k, v in CountryHolder.getCountries().iteritems()], key=itemgetter('caption')) return {'choices': choices}
def get_friendly_data(self, registration_data, for_humans=False): return CountryHolder.getCountryById(registration_data.data) if registration_data.data else ''
def unprocess_field_data(cls, versioned_data, unversioned_data): choices = sorted([{'caption': v, 'countryKey': k} for k, v in CountryHolder.getCountries().iteritems()], key=itemgetter('caption')) return {'choices': choices}
def wtf_field_kwargs(self): return {'choices': sorted(CountryHolder.getCountries().items(), key=itemgetter(1))}
def getValue(cls, reg): return CountryHolder().getCountryById(reg.getCountry())
def compare(self, r1, r2): return cmp(CountryHolder().getCountryById(r1.getCountry()).lower(), CountryHolder().getCountryById(r2.getCountry()).lower())
def wtf_field_kwargs(self): return {'choices': CountryHolder.getCountries().items()}
def get_friendly_data(self, registration_data): return CountryHolder.getCountries()[registration_data.data] if registration_data.data else ''
def getExcelFile(self): excelGen = ExcelGenerator() excelGen.addValue("Name") for key in self._display: if key in [ "Id", "Email", "Position", "Institution", "Phone", "City", "Country", "Address" ]: excelGen.addValue(key) elif key == "Accommodation": excelGen.addValue( self._regForm.getAccommodationForm().getTitle()) elif key == "SocialEvents": excelGen.addValue( self._regForm.getSocialEventForm().getTitle()) elif key == "Sessions": excelGen.addValue(self._regForm.getSessionsForm().getTitle()) elif key == "ArrivalDate": excelGen.addValue("Arrival Date") elif key == "DepartureDate": excelGen.addValue("Departure Date") elif key == "RegistrationDate": excelGen.addValue("Registration Date") elif key == "ReasonParticipation": excelGen.addValue( self._regForm.getReasonParticipationForm().getTitle()) elif key == "isPayed": excelGen.addValue("Paid") elif key == "idpayment": excelGen.addValue("Payment ID") elif key == "amountToPay": excelGen.addValue("Amount") elif key == "FirstName": excelGen.addValue("First name") elif key == "LastName": excelGen.addValue("Last name") elif key.startswith("s-"): ids = key.split("-") if len(ids) == 2: status = self._regForm.getStatusById(ids[1]) excelGen.addValue(status.getCaption()) else: excelGen.addValue("") else: ids = key.split("-") if len(ids) == 2: group = self._regForm.getSectionById(ids[0]) if group is not None: i = group.getFieldById(ids[1]) if i is not None: excelGen.addValue(i.getCaption()) continue excelGen.addValue("") excelGen.newLine() if self._regList == None: self._regList = self._conf.getRegistrantsList(True) for reg in self._regList: excelGen.addValue(reg.getFullName()) for key in self._display: if key == "Id": excelGen.addValue(reg.getId()) elif key == "Email": excelGen.addValue(reg.getEmail()) elif key == "Institution": excelGen.addValue(reg.getInstitution()) elif key == "Position": excelGen.addValue(reg.getPosition()) elif key == "City": excelGen.addValue(reg.getCity()) elif key == "Country": excelGen.addValue(CountryHolder().getCountryById( reg.getCountry())) elif key == "Address": excelGen.addValue(reg.getAddress()) elif key == "Phone": excelGen.addNumberAsString(reg.getPhone(), self._excelSpecific) elif key == "Sessions": p7 = [] for ses in reg.getSessionList(): if ses is not None: p7.append(ses.getTitle().strip() or "") excelGen.addValue("; ".join(p7)) elif key == "SocialEvents": p8 = [] for se in reg.getSocialEvents(): if se is not None: p8.append( "%s (%s)" % (se.getCaption().strip(), se.getNoPlaces()) or "") excelGen.addValue("; ".join(p8)) elif key == "Accommodation": if reg.getAccommodation( ) is not None and reg.getAccommodation( ).getAccommodationType() is not None: excelGen.addValue(reg.getAccommodation(). getAccommodationType().getCaption()) else: excelGen.addValue("") elif key == "ArrivalDate": if reg.getAccommodation( ) is not None and reg.getAccommodation().getArrivalDate( ) is not None: excelGen.addValue( reg.getAccommodation().getArrivalDate().strftime( "%d-%B-%Y")) else: excelGen.addValue("") elif key == "DepartureDate": if reg.getAccommodation( ) is not None and reg.getAccommodation().getDepartureDate( ) is not None: excelGen.addValue( reg.getAccommodation().getDepartureDate().strftime( "%d-%B-%Y")) else: excelGen.addValue("") elif key == "ReasonParticipation": excelGen.addValue(reg.getReasonParticipation()) elif key == "isPayed": excelGen.addValue(reg.isPayedText()) elif key == "idpayment": excelGen.addValue(reg.getIdPay()) elif key == "FirstName": excelGen.addValue(reg.getFirstName()) elif key == "LastName": excelGen.addValue(reg.getSurName()) elif key == "amountToPay": excelGen.addValue("%.2f %s" % (reg.getTotal(), reg.getConference(). getRegistrationForm().getCurrency())) elif key == "RegistrationDate": if reg.getRegistrationDate() is not None: excelGen.addValue( reg.getAdjustedRegistrationDate().strftime( "%d-%B-%Y-%H:%M")) else: excelGen.addValue("") elif key.startswith("s-"): ids = key.split("-") if len(ids) == 2: status = reg.getStatusById(ids[1]) cap = "" if status.getStatusValue() is not None: cap = status.getStatusValue().getCaption() excelGen.addValue(cap) else: ids = key.split("-") if len(ids) == 2: group = reg.getMiscellaneousGroupById(ids[0]) if group is not None: i = group.getResponseItemById(ids[1]) if i is not None: value = self._formatGenericValue( i.getGeneralField().getInput(), i.getValue()) if self._isNumberAsString( i.getGeneralField().getInput(), i.getValue()): excelGen.addNumberAsString( value, self._excelSpecific) else: excelGen.addValue(value) continue excelGen.addValue("") excelGen.newLine() return excelGen.getExcelContent()