Пример #1
0
def make_participation_from_obj(obj, contrib_participation=None):
    """Convert a user-like object to a ContributionParticipation

    :param obj: The object to take the values of the ContributionParticipation
                from
    :param contrib_participation: In case the return object has been initialised
                                  outside of the function
    :return: a ContributionParticipation object
    """
    if contrib_participation is None:
        contrib_participation = ContributionParticipation()
    contrib_participation.setTitle(obj.getTitle())
    contrib_participation.setFirstName(obj.getName())
    contrib_participation.setFamilyName(obj.getSurName())
    contrib_participation.setEmail(obj.getEmail())
    contrib_participation.setAddress(obj.getAddress())
    contrib_participation.setFax(obj.getFax())
    contrib_participation.setAffiliation(obj.getAffiliation())
    contrib_participation.setPhone(obj.getPhone())
    return contrib_participation
Пример #2
0
def make_participation_from_obj(obj, contrib_participation=None):
    """Convert a user-like object to a ContributionParticipation

    :param obj: The object to take the values of the ContributionParticipation
                from
    :param contrib_participation: In case the return object has been initialised
                                  outside of the function
    :return: a ContributionParticipation object
    """
    if contrib_participation is None:
        contrib_participation = ContributionParticipation()
    contrib_participation.setTitle(obj.getTitle())
    contrib_participation.setFirstName(obj.getName())
    contrib_participation.setFamilyName(obj.getSurName())
    contrib_participation.setEmail(obj.getEmail())
    contrib_participation.setAddress(obj.getAddress())
    contrib_participation.setFax(obj.getFax())
    contrib_participation.setAffiliation(obj.getAffiliation())
    contrib_participation.setPhone(obj.getPhone())
    return contrib_participation
Пример #3
0
    def _process(self):
        params = self._getRequestParams()
        self._errorList = []

        #raise "%s"%params
        taskId = params["taskId"]

        taskObject = self._target.getTask(taskId)
        if params.get("orgin", "") == "new":
            if params.get("ok", None) is None:
                raise "not ok"
                url = urlHandlers.UHTaskDetails.getURL(self._target)
                url.addParam("taskId", params["taskId"])
                self._redirect(url)
                return
            else:
                person = ContributionParticipation()
                person.setFirstName(params["name"])
                person.setFamilyName(params["surName"])
                person.setEmail(params["email"])
                person.setAffiliation(params["affiliation"])
                person.setAddress(params["address"])
                person.setPhone(params["phone"])
                person.setTitle(params["title"])
                person.setFax(params["fax"])
                if not self._alreadyDefined(person,
                                            taskObject.getResponsibleList()):
                    taskObject.addResponsible(person)
                else:
                    self._errorList.append(
                        "%s has been already defined as %s of this task" %
                        (person.getFullName(), self._typeName))

        elif params.get("orgin", "") == "selected":
            selectedList = self._normaliseListParam(
                self._getRequestParams().get("selectedPrincipals", []))
            for s in selectedList:
                if s[0:8] == "*author*":
                    auths = self._conf.getAuthorIndex()
                    selected = auths.getById(s[9:])[0]
                else:
                    ph = user.PrincipalHolder()
                    selected = ph.getById(s)
                if isinstance(selected, user.Avatar):
                    person = ContributionParticipation()
                    person.setDataFromAvatar(selected)
                    if not self._alreadyDefined(
                            person, taskObject.getResponsibleList()):
                        taskObject.addResponsible(person)
                    else:
                        self._errorList.append(
                            "%s has been already defined as %s of this task" %
                            (person.getFullName(), self._typeName))

                elif isinstance(selected, user.Group):
                    for member in selected.getMemberList():
                        person = ContributionParticipation()
                        person.setDataFromAvatar(member)
                        if not self._alreadyDefined(
                                person, taskObject.getResponsibleList()):
                            taskObject.addResponsible(person)
                        else:
                            self._errorList.append(
                                "%s has been already defined as %s of this task"
                                % (person.getFullName(), self._typeName))

                else:
                    person = ContributionParticipation()
                    person.setTitle(selected.getTitle())
                    person.setFirstName(selected.getFirstName())
                    person.setFamilyName(selected.getFamilyName())
                    person.setEmail(selected.getEmail())
                    person.setAddress(selected.getAddress())
                    person.setAffiliation(selected.getAffiliation())
                    person.setPhone(selected.getPhone())
                    person.setFax(selected.getFax())
                    if not self._alreadyDefined(
                            person, taskObject.getResponsibleList()):
                        taskObject.addResponsible(person)
                    else:
                        self._errorList.append(
                            "%s has been already defined as %s of this task" %
                            (person.getFullName(), self._typeName))
            else:
                url = urlHandlers.UHTaskDetails.getURL(self._target)
                url.addParam("taskId", params["taskId"])
                self._redirect(url)
                return

        url = urlHandlers.UHTaskDetails.getURL(self._target)
        url.addParam("taskId", params["taskId"])
        self._redirect(url)
Пример #4
0
    def _process(self):
        params = self._getRequestParams()
        self._errorList = []

        #raise "%s"%params
        definedList = self._getDefinedList(self._typeName)
        if definedList is None:
            definedList = []

        if params.get("orgin", "") == "new":
            #raise "new"
            if params.get("ok", None) is None:
                raise "not ok"
                self._redirect(urlHandlers.UHTaskNew.getURL(self._target))
                return
            else:
                person = ContributionParticipation()
                person.setFirstName(params["name"])
                person.setFamilyName(params["surName"])
                person.setEmail(params["email"])
                person.setAffiliation(params["affiliation"])
                person.setAddress(params["address"])
                person.setPhone(params["phone"])
                person.setTitle(params["title"])
                person.setFax(params["fax"])
                if not self._alreadyDefined(person, definedList):
                    definedList.append(
                        [person, params.has_key("submissionControl")])
                else:
                    self._errorList.append(
                        _("%s has been already defined as %s of this contribution"
                          ) % (person.getFullName(), self._typeName))

        elif params.get("orgin", "") == "selected":
            selectedList = self._normaliseListParam(
                self._getRequestParams().get("selectedPrincipals", []))
            for s in selectedList:
                if s[0:8] == "*author*":
                    auths = self._conf.getAuthorIndex()
                    selected = auths.getById(s[9:])[0]
                else:
                    ph = user.PrincipalHolder()
                    selected = ph.getById(s)
                if isinstance(selected, user.Avatar):
                    person = ContributionParticipation()
                    person.setDataFromAvatar(selected)
                    if not self._alreadyDefined(person, definedList):
                        definedList.append(
                            [person,
                             params.has_key("submissionControl")])
                    else:
                        self._errorList.append(
                            _("%s has been already defined as %s of this contribution"
                              ) % (person.getFullName(), self._typeName))

                elif isinstance(selected, user.Group):
                    for member in selected.getMemberList():
                        person = ContributionParticipation()
                        person.setDataFromAvatar(member)
                        if not self._alreadyDefined(person, definedList):
                            definedList.append(
                                [person,
                                 params.has_key("submissionControl")])
                        else:
                            self._errorList.append(
                                _("%s has been already defined as %s of this contribution"
                                  ) %
                                (presenter.getFullName(), self._typeName))
                else:
                    person = ContributionParticipation()
                    person.setTitle(selected.getTitle())
                    person.setFirstName(selected.getFirstName())
                    person.setFamilyName(selected.getFamilyName())
                    person.setEmail(selected.getEmail())
                    person.setAddress(selected.getAddress())
                    person.setAffiliation(selected.getAffiliation())
                    person.setPhone(selected.getPhone())
                    person.setFax(selected.getFax())
                    if not self._alreadyDefined(person, definedList):
                        definedList.append(
                            [person,
                             params.has_key("submissionControl")])
                    else:
                        self._errorList.append(
                            _("%s has been already defined as %s of this contribution"
                              ) % (person.getFullName(), self._typeName))

        elif params.get("orgin", "") == "added":
            preservedParams = self._getPreservedParams()
            chosen = preservedParams.get("%sChosen" % self._typeName, None)
            if chosen is None or chosen == "":
                self._redirect(
                    urlHandlers.UHConfModScheduleNewContrib.getURL(
                        self._target))
                return
            index = chosen.find("-")
            taskId = chosen[0:index]
            resId = chosen[index + 1:len(chosen)]
            taskObject = self._target.getTask(taskId)
            chosenPerson = taskObject.getResponsibleList()[int(resId)]
            if chosenPerson is None:
                self._redirect(
                    urlHandlers.UHConfModScheduleNewContrib.getURL(
                        self._target))
                return
            person = ContributionParticipation()
            person.setTitle(chosenPerson.getTitle())
            person.setFirstName(chosenPerson.getFirstName())
            person.setFamilyName(chosenPerson.getFamilyName())
            person.setEmail(chosenPerson.getEmail())
            person.setAddress(chosenPerson.getAddress())
            person.setAffiliation(chosenPerson.getAffiliation())
            person.setPhone(chosenPerson.getPhone())
            person.setFax(chosenPerson.getFax())
            if not self._alreadyDefined(person, definedList):
                definedList.append(
                    [person, params.has_key("submissionControl")])
            else:
                self._errorList.append(
                    _("%s has been already defined as %s of this contribution")
                    % (person.getFullName(), self._typeName))
        else:
            self._redirect(urlHandlers.UHConfModifSchedule.getURL(
                self._target))
            return
        preservedParams = self._getPreservedParams()
        preservedParams["errorMsg"] = self._errorList
        self._preserveParams(preservedParams)
        self._websession.setVar("%sList" % self._typeName, definedList)

        self._redirect(urlHandlers.UHTaskNew.getURL(self._target))
Пример #5
0
    def _process( self ):
        params = self._getRequestParams()
        self._errorList = []

        #raise "%s"%params
        taskId = params["taskId"]

        taskObject = self._target.getTask(taskId)
        if params.get("orgin","") == "new" :
            if params.get("ok",None) is None :
                raise MaKaCError("not ok")
                url = urlHandlers.UHTaskDetails.getURL(self._target)
                url.addParam("taskId",params["taskId"])
                self._redirect(url)
                return
            else :
                person = ContributionParticipation()
                person.setFirstName(params["name"])
                person.setFamilyName(params["surName"])
                person.setEmail(params["email"])
                person.setAffiliation(params["affiliation"])
                person.setAddress(params["address"])
                person.setPhone(params["phone"])
                person.setTitle(params["title"])
                person.setFax(params["fax"])
                if not self._alreadyDefined(person, taskObject.getResponsibleList()) :
                    taskObject.addResponsible(person)
                else :
                    self._errorList.append("%s has been already defined as %s of this task"%(person.getFullName(),self._typeName))

        elif params.get("orgin","") == "selected" :
            selectedList = self._normaliseListParam(self._getRequestParams().get("selectedPrincipals",[]))
            for s in selectedList :
                if s[0:8] == "*author*" :
                    auths = self._conf.getAuthorIndex()
                    selected = auths.getById(s[9:])[0]
                else :
                    ph = user.PrincipalHolder()
                    selected = ph.getById(s)
                if isinstance(selected, user.Avatar) :
                    person = ContributionParticipation()
                    person.setDataFromAvatar(selected)
                    if not self._alreadyDefined(person, taskObject.getResponsibleList()) :
                        taskObject.addResponsible(person)
                    else :
                        self._errorList.append("%s has been already defined as %s of this task"%(person.getFullName(),self._typeName))

                elif isinstance(selected, user.Group) :
                    for member in selected.getMemberList() :
                        person = ContributionParticipation()
                        person.setDataFromAvatar(member)
                        if not self._alreadyDefined(person, taskObject.getResponsibleList()) :
                            taskObject.addResponsible(person)
                        else :
                            self._errorList.append("%s has been already defined as %s of this task"%(person.getFullName(),self._typeName))

                else :
                    person = ContributionParticipation()
                    person.setTitle(selected.getTitle())
                    person.setFirstName(selected.getFirstName())
                    person.setFamilyName(selected.getFamilyName())
                    person.setEmail(selected.getEmail())
                    person.setAddress(selected.getAddress())
                    person.setAffiliation(selected.getAffiliation())
                    person.setPhone(selected.getPhone())
                    person.setFax(selected.getFax())
                    if not self._alreadyDefined(person, taskObject.getResponsibleList()) :
                        taskObject.addResponsible(person)
                    else :
                        self._errorList.append("%s has been already defined as %s of this task"%(person.getFullName(),self._typeName))
            else :
                url = urlHandlers.UHTaskDetails.getURL(self._target)
                url.addParam("taskId",params["taskId"])
                self._redirect(url)
                return

        url = urlHandlers.UHTaskDetails.getURL(self._target)
        url.addParam("taskId",params["taskId"])
        self._redirect(url)
Пример #6
0
    def _process( self ):
        params = self._getRequestParams()
        self._errorList = []

        #raise "%s"%params
        definedList = self._getDefinedList(self._typeName)
        if definedList is None :
            definedList = []

        if params.get("orgin","") == "new" :
            #raise "new"
            if params.get("ok",None) is None :
                raise MaKaCError("not ok")
                self._redirect(urlHandlers.UHTaskNew.getURL(self._target))
                return
            else:
                person = ContributionParticipation()
                person.setFirstName(params["name"])
                person.setFamilyName(params["surName"])
                person.setEmail(params["email"])
                person.setAffiliation(params["affiliation"])
                person.setAddress(params["address"])
                person.setPhone(params["phone"])
                person.setTitle(params["title"])
                person.setFax(params["fax"])
                if not self._alreadyDefined(person, definedList) :
                    definedList.append([person,params.has_key("submissionControl")])
                else :
                    self._errorList.append( _("%s has been already defined as %s of this contribution")%(person.getFullName(),self._typeName))

        elif params.get("orgin","") == "selected" :
            selectedList = self._normaliseListParam(self._getRequestParams().get("selectedPrincipals",[]))
            for s in selectedList :
                if s[0:8] == "*author*" :
                    auths = self._conf.getAuthorIndex()
                    selected = auths.getById(s[9:])[0]
                else :
                    ph = user.PrincipalHolder()
                    selected = ph.getById(s)
                if isinstance(selected, user.Avatar) :
                    person = ContributionParticipation()
                    person.setDataFromAvatar(selected)
                    if not self._alreadyDefined(person, definedList) :
                        definedList.append([person,params.has_key("submissionControl")])
                    else :
                        self._errorList.append( _("%s has been already defined as %s of this contribution")%(person.getFullName(),self._typeName))

                elif isinstance(selected, user.Group) :
                    for member in selected.getMemberList() :
                        person = ContributionParticipation()
                        person.setDataFromAvatar(member)
                        if not self._alreadyDefined(person, definedList) :
                            definedList.append([person,params.has_key("submissionControl")])
                        else :
                            self._errorList.append( _("%s has been already defined as %s of this contribution")%(presenter.getFullName(),self._typeName))
                else :
                    person = ContributionParticipation()
                    person.setTitle(selected.getTitle())
                    person.setFirstName(selected.getFirstName())
                    person.setFamilyName(selected.getFamilyName())
                    person.setEmail(selected.getEmail())
                    person.setAddress(selected.getAddress())
                    person.setAffiliation(selected.getAffiliation())
                    person.setPhone(selected.getPhone())
                    person.setFax(selected.getFax())
                    if not self._alreadyDefined(person, definedList) :
                        definedList.append([person,params.has_key("submissionControl")])
                    else :
                        self._errorList.append( _("%s has been already defined as %s of this contribution")%(person.getFullName(),self._typeName))

        elif params.get("orgin","") == "added" :
            preservedParams = self._getPreservedParams()
            chosen = preservedParams.get("%sChosen"%self._typeName,None)
            if chosen is None or chosen == "" :
                self._redirect(urlHandlers.UHConfModScheduleNewContrib.getURL(self._target))
                return
            index = chosen.find("-")
            taskId = chosen[0:index]
            resId = chosen[index+1:len(chosen)]
            taskObject = self._target.getTask(taskId)
            chosenPerson = taskObject.getResponsibleList()[int(resId)]
            if chosenPerson is None :
                self._redirect(urlHandlers.UHConfModScheduleNewContrib.getURL(self._target))
                return
            person = ContributionParticipation()
            person.setTitle(chosenPerson.getTitle())
            person.setFirstName(chosenPerson.getFirstName())
            person.setFamilyName(chosenPerson.getFamilyName())
            person.setEmail(chosenPerson.getEmail())
            person.setAddress(chosenPerson.getAddress())
            person.setAffiliation(chosenPerson.getAffiliation())
            person.setPhone(chosenPerson.getPhone())
            person.setFax(chosenPerson.getFax())
            if not self._alreadyDefined(person, definedList) :
                definedList.append([person,params.has_key("submissionControl")])
            else :
                self._errorList.append( _("%s has been already defined as %s of this contribution")%(person.getFullName(),self._typeName))
        else :
            self._redirect(urlHandlers.UHConfModifSchedule.getURL(self._target))
            return
        preservedParams = self._getPreservedParams()
        preservedParams["errorMsg"] = self._errorList
        self._preserveParams(preservedParams)
        self._websession.setVar("%sList"%self._typeName,definedList)

        self._redirect(urlHandlers.UHTaskNew.getURL(self._target))