diff --git a/osc/commandline.py b/osc/commandline.py index 2268c9d1..d4673928 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -2503,7 +2503,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. if repl.lower() == 'y' or repl == '': (supersede, reqs) = check_existing_requests(apiurl, action.tgt_project, action.tgt_package, project, package) - msg = "%s (forwarded request %s from %s)" % (rq.description, reqid, rq.get_creator()) + msg = "%s (forwarded request %s from %s)" % (rq.description, reqid, rq.creator) rid = create_submit_request(apiurl, action.tgt_project, action.tgt_package, project, package, cgi.escape(msg)) print(msg) diff --git a/osc/core.py b/osc/core.py index 2992176d..c56610d0 100644 --- a/osc/core.py +++ b/osc/core.py @@ -2684,6 +2684,7 @@ class Request: def _init_attributes(self): """initialize attributes with default values""" self.reqid = None + self.creator = None self.title = '' self.description = '' self.priority = None @@ -2696,9 +2697,10 @@ class Request: def read(self, root): """read in a request""" self._init_attributes() - if not root.get('id'): + if not root.get('id') or not root.get('creator'): raise oscerr.APIError('invalid request: %s\n' % ET.tostring(root, encoding=ET_ENCODING)) self.reqid = root.get('id') + self.creator = root.get('creator') if root.find('state') is None: raise oscerr.APIError('invalid request (state expected): %s\n' % ET.tostring(root, encoding=ET_ENCODING)) self.state = RequestState(root.find('state')) @@ -2736,17 +2738,13 @@ class Request: return self.actions return [i for i in self.actions if i.type in types] - def get_creator(self): - """return the creator of the request""" - if len(self.statehistory): - return self.statehistory[0].who - return self.state.who - def to_xml(self): """serialize object to XML""" root = ET.Element('request') if not self.reqid is None: root.set('id', self.reqid) + if self.creator is not None: + root.set('creator', self.creator) for action in self.actions: root.append(action.to_xml()) if not self.state is None: @@ -4182,7 +4180,7 @@ def change_request_state_template(req, newstate): tmpl_name = '%srequest_%s_template' % (action.type, newstate) tmpl = conf.config.get(tmpl_name, '') tmpl = tmpl.replace('\\t', '\t').replace('\\n', '\n') - data = {'reqid': req.reqid, 'type': action.type, 'who': req.get_creator()} + data = {'reqid': req.reqid, 'type': action.type, 'who': req.creator} if req.actions[0].type == 'submit': data.update({'src_project': action.src_project, 'src_package': action.src_package, 'src_rev': action.src_rev,