Example #1
0
 def FIELD_DATA(cls):
     title_item = {
         'price': 0,
         'is_billable': False,
         'places_limit': 0,
         'is_enabled': True
     }
     return [
         (cls.title, {
             'title': 'Title',
             'input_type': 'single_choice',
             'data': {
                 'item_type':
                 'dropdown',
                 'with_extra_slots':
                 False,
                 'choices': [
                     dict(title_item, id=unicode(uuid4()), caption=t)
                     for t in TitlesRegistry.getList() if t
                 ]
             }
         }),
         (cls.first_name, {
             'title': 'First Name',
             'input_type': 'text'
         }),
         (cls.last_name, {
             'title': 'Last Name',
             'input_type': 'text'
         }),
         (cls.email, {
             'title': 'Email Address',
             'input_type': 'email'
         }),
         (cls.affiliation, {
             'title': 'Affiliation',
             'input_type': 'text'
         }),
         (cls.address, {
             'title': 'Address',
             'input_type': 'textarea',
             'is_enabled': False
         }),
         (cls.country, {
             'title': 'Country',
             'input_type': 'country',
             'is_enabled': False
         }),
         (cls.phone, {
             'title': 'Phone Number',
             'input_type': 'phone',
             'is_enabled': False
         }),
         (cls.position, {
             'title': 'Position',
             'input_type': 'text',
             'is_enabled': False
         }),
     ]
Example #2
0
 def getVars(self):
     vars = wcomponents.WTemplated.getVars(self)
     vars["postURL"] = quoteattr(
         str(
             urlHandlers.UHSubContributionNewSpeaker.getURL(
                 self._subcontrib)))
     vars["titles"] = TitlesRegistry().getSelectItemsHTML()
     return vars
Example #3
0
 def getVars( self ):
     vars = wcomponents.WTemplated.getVars(self)
     vars["postURL"]=quoteattr(str(urlHandlers.UHSubContribModPresenter.getURL(self._auth)))
     vars["titles"]=TitlesRegistry.getSelectItemsHTML(self._auth.getTitle())
     vars["surName"]=quoteattr(self._auth.getFamilyName())
     vars["name"]=quoteattr(self._auth.getFirstName())
     vars["affiliation"]=quoteattr(self._auth.getAffiliation())
     vars["email"]=quoteattr(self._auth.getEmail())
     vars["address"]=self._auth.getAddress()
     vars["phone"]=quoteattr(self._auth.getPhone())
     vars["fax"]=quoteattr(self._auth.getFax())
     return vars
Example #4
0
 def getVars(self):
     vars = wcomponents.WTemplated.getVars(self)
     vars["postURL"] = quoteattr(
         str(urlHandlers.UHSubContribModPresenter.getURL(self._auth)))
     vars["titles"] = TitlesRegistry.getSelectItemsHTML(
         self._auth.getTitle())
     vars["surName"] = quoteattr(self._auth.getFamilyName())
     vars["name"] = quoteattr(self._auth.getFirstName())
     vars["affiliation"] = quoteattr(self._auth.getAffiliation())
     vars["email"] = quoteattr(self._auth.getEmail())
     vars["address"] = self._auth.getAddress()
     vars["phone"] = quoteattr(self._auth.getPhone())
     vars["fax"] = quoteattr(self._auth.getFax())
     return vars
Example #5
0
 def FIELD_DATA(cls):
     title_item = {'price': 0,
                   'is_billable': False,
                   'places_limit': 0,
                   'is_enabled': True}
     return [
         (cls.title, {
             'title': 'Title',
             'input_type': 'single_choice',
             'data': {
                 'item_type': 'dropdown',
                 'with_extra_slots': False,
                 'choices': [dict(title_item, id=unicode(uuid4()), caption=t) for t in TitlesRegistry.getList() if t]
             }
         }),
         (cls.first_name, {
             'title': 'First Name',
             'input_type': 'text'
         }),
         (cls.last_name, {
             'title': 'Last Name',
             'input_type': 'text'
         }),
         (cls.email, {
             'title': 'Email Address',
             'input_type': 'email'
         }),
         (cls.affiliation, {
             'title': 'Affiliation',
             'input_type': 'text'
         }),
         (cls.address, {
             'title': 'Address',
             'input_type': 'textarea',
             'is_enabled': False
         }),
         (cls.country, {
             'title': 'Country',
             'input_type': 'country',
             'is_enabled': False
         }),
         (cls.phone, {
             'title': 'Phone Number',
             'input_type': 'phone',
             'is_enabled': False
         }),
         (cls.position, {
             'title': 'Position',
             'input_type': 'text',
             'is_enabled': False
         }),
     ]
Example #6
0
    def _getAnswer(self):
        if self._user:
            idxs = indexes.IndexesHolder()
            funcGet = "get%s%s" % (self._dataType[0].upper(),
                                   self._dataType[1:])
            funcSet = "set%s%s" % (self._dataType[0].upper(),
                                   self._dataType[1:])
            if self._dataType == "title":
                if self._value in TitlesRegistry().getList():
                    self._user.setTitle(self._value)
                else:
                    raise NoReportError(_("Invalid title value"))
            elif self._dataType == "surName":
                self._user.setFieldSynced('surName', False)
                surName = idxs.getById("surName")
                surName.unindexUser(self._avatar)
                self._user.setSurName(self._value)
                surName.indexUser(self._avatar)
            elif self._dataType == "name":
                self._user.setFieldSynced('firstName', False)
                name = idxs.getById("name")
                name.unindexUser(self._avatar)
                self._user.setName(self._value)
                name.indexUser(self._avatar)
            elif self._dataType == "organisation":
                self._user.setFieldSynced('affiliation', False)
                org = idxs.getById("organisation")
                org.unindexUser(self._avatar)
                self._user.setOrganisation(self._value)
                org.indexUser(self._avatar)
            elif self._dataType == "email":
                # Check if there is any user with this email address
                if self._value != self._avatar.getEmail():
                    other = user.AvatarHolder().match({"email": self._value},
                                                      forceWithoutExtAuth=True)
                    if other and other[0] != self._avatar:
                        raise NoReportError(
                            _("The email address %s is already used by another user."
                              ) % self._value)
                email = idxs.getById("email")
                email.unindexUser(self._avatar)
                self._user.setEmail(self._value)
                email.indexUser(self._avatar)
            elif self._dataType == "secondaryEmails":
                emailList = self._buildEmailList()
                secondaryEmails = []
                # check if every secondary email is valid
                for email in emailList:
                    if email != "":
                        av = user.AvatarHolder().match(
                            {"email": email}, forceWithoutExtAuth=True)
                        if av and av[0] != self._avatar:
                            raise NoReportError(
                                _("The email address %s is already used by another user."
                                  ) % email)
                        else:
                            secondaryEmails.append(email)
                self._user.setSecondaryEmails(secondaryEmails)
                return ", ".join(self._user.getSecondaryEmails())
            elif self._dataType == "telephone":
                self._user.setFieldSynced('phone', False)
                self._user.setTelephone(self._value)
            elif self._dataType == "fax":
                self._user.setFieldSynced('fax', False)
                self._user.setFax(self._value)
            else:
                getattr(self._user, funcSet)(self._value)

            return getattr(self._user, funcGet)()
        else:
            raise ServiceError("ERR-U5", _("User id not specified"))
Example #7
0
    def _getAnswer(self):
        if self._user:
            idxs = indexes.IndexesHolder()
            funcGet = "get%s%s" % (self._dataType[0].upper(),
                                   self._dataType[1:])
            funcSet = "set%s%s" % (self._dataType[0].upper(),
                                   self._dataType[1:])
            if self._dataType == "title":
                if self._value in TitlesRegistry().getList():
                    self._user.setTitle(self._value)
                else:
                    raise NoReportError(_("Invalid title value"))
            elif self._dataType == "surName":
                self._user.setFieldSynced('surName', False)
                self._user.setSurName(self._value, reindex=True)
            elif self._dataType == "name":
                self._user.setFieldSynced('firstName', False)
                self._user.setName(self._value, reindex=True)
            elif self._dataType == "organisation":
                self._user.setFieldSynced('affiliation', False)
                self._user.setOrganisation(self._value, reindex=True)
            elif self._dataType == "email":
                # Check if there is any user with this email address
                if self._value != self._avatar.getEmail():
                    other = user.AvatarHolder().match(
                        {"email": self._value}, searchInAuthenticators=False)
                    if other and other[0] != self._avatar:
                        raise NoReportError(
                            _("The email address %s is already used by another user."
                              ) % self._value)
                self._user.setEmail(self._value, reindex=True)
            elif self._dataType == "secondaryEmails":
                emailList = self._buildEmailList()
                secondaryEmails = []
                newSecondaryEmailAdded = False
                # check if every secondary email is valid
                for sEmail in emailList:
                    sEmail = sEmail.lower().strip()
                    if sEmail != "":
                        av = user.AvatarHolder().match(
                            {"email": sEmail}, searchInAuthenticators=False)
                        if av and av[0] != self._avatar:
                            raise NoReportError(
                                _("The email address %s is already used by another user."
                                  ) % sEmail)
                        elif self._user.getEmail(
                        ) == sEmail:  # do not accept primary email address as secondary
                            continue
                        elif self._user.hasSecondaryEmail(sEmail):
                            secondaryEmails.append(sEmail)
                        else:
                            newSecondaryEmailAdded = True
                            self._user.addPendingSecondaryEmail(sEmail)
                            self._sendSecondaryEmailNotifiication(sEmail)
                self._user.setSecondaryEmails(secondaryEmails, reindex=True)
                if newSecondaryEmailAdded:
                    warn = Warning(
                        _("New secondary email address"),
                        _("You will receive an email in order to confirm\
                                      your new email address. Once confirmed, it will be shown in your profile."
                          ))
                    return ResultWithWarning(
                        ", ".join(self._user.getSecondaryEmails()),
                        warn).fossilize()
                else:
                    return ", ".join(self._user.getSecondaryEmails())

            elif self._dataType == "telephone":
                self._user.setFieldSynced('phone', False)
                self._user.setTelephone(self._value)
            elif self._dataType == "fax":
                self._user.setFieldSynced('fax', False)
                self._user.setFax(self._value)
            elif self._dataType == "address":
                self._user.setFieldSynced('address', False)
                self._user.setAddress(self._value)
            else:
                getattr(self._user, funcSet)(self._value)

            return getattr(self._user, funcGet)()
        else:
            raise ServiceError("ERR-U5", _("User id not specified"))