mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-03 10:06:17 +01:00
- added template support for a submitrequest accept/decline message
This commit is contained in:
parent
7ade282e6e
commit
ca794fe87f
@ -1858,7 +1858,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
raise oscerr.UserAbort()
|
||||
|
||||
if not opts.message:
|
||||
opts.message = edit_message()
|
||||
tmpl = change_request_state_template(rq, state_map[cmd])
|
||||
opts.message = edit_message(template=tmpl)
|
||||
r = change_request_state(apiurl,
|
||||
reqid, state_map[cmd], opts.message or '')
|
||||
print 'Result of change request state: %s' % r
|
||||
|
@ -123,6 +123,8 @@ DEFAULTS = { 'apiurl': 'https://api.opensuse.org',
|
||||
# what to do with the source package if the submitrequest has been accepted
|
||||
'submitrequest_on_accept_action': '',
|
||||
'request_show_interactive': '0',
|
||||
'submitrequest_accepted_template': '',
|
||||
'submitrequest_declined_template': '',
|
||||
'linkcontrol': '0',
|
||||
|
||||
# Maintenance defaults to OBS instance defaults
|
||||
@ -257,6 +259,12 @@ apiurl = %(apiurl)s
|
||||
# nothing is specified the API default is used
|
||||
#submitrequest_on_accept_action = cleanup|update|noupdate
|
||||
|
||||
# template for an accepted submitrequest
|
||||
#submitrequest_accepted_template = Hi %%(who)s,\\nthanks for working on %%(dst_project)s/%%(dst_package)s. SR %%(reqid)s has been accepted.\\n\\nYour maintainers
|
||||
|
||||
# template for a declined submitrequest
|
||||
#submitrequest_declined_template = Hi %%(who)s,\\nsorry your SR %%(reqid)s for %%(dst_project)s/%%(dst_package)s has been declined because ...
|
||||
|
||||
#review requests interactively (default: off)
|
||||
#request_show_review = 1
|
||||
|
||||
|
28
osc/core.py
28
osc/core.py
@ -2218,6 +2218,11 @@ class Request:
|
||||
dst_prj, dst_pkg, src_update, role_person, role_group, role)
|
||||
)
|
||||
|
||||
def get_creator(self):
|
||||
if len(self.statehistory):
|
||||
return self.statehistory[-1].who
|
||||
return self.state.who
|
||||
|
||||
def list_view(self):
|
||||
ret = '%6d State:%-7s By:%-12s When:%-12s' % (self.reqid, self.state.name, self.state.who, self.state.when)
|
||||
|
||||
@ -3321,6 +3326,24 @@ def change_request_state(apiurl, reqid, newstate, message='', supersed=''):
|
||||
|
||||
return r
|
||||
|
||||
def change_request_state_template(req, newstate):
|
||||
if not len(req.actions):
|
||||
return ''
|
||||
action = req.actions[0]
|
||||
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()}
|
||||
if req.actions[0].type == 'submit':
|
||||
data.update({'src_project': action.src_project,
|
||||
'src_package': action.src_package, 'src_rev': action.src_rev,
|
||||
'dst_project': action.dst_project, 'dst_package': action.dst_package})
|
||||
try:
|
||||
return tmpl % data
|
||||
except KeyError, e:
|
||||
print >>sys.stderr, 'error: cannot interpolate \'%s\' in \'%s\'' % (e.args[0], tmpl_name)
|
||||
return ''
|
||||
|
||||
def get_review_list(apiurl, project='', package='', user='', group='', states=('new')):
|
||||
xpath = ''
|
||||
xpath = xpath_join(xpath, 'state/@name=\'review\'', inner=True)
|
||||
@ -5598,7 +5621,10 @@ def request_interactive_review(apiurl, request):
|
||||
# the read bytes probably have a moderate size so the str won't be too large
|
||||
footer += '\n\n' + tmpfile.read()
|
||||
if msg is None:
|
||||
msg = edit_message(footer = footer)
|
||||
tmpl = ''
|
||||
if not state is None:
|
||||
tmpl = change_request_state_template(request, state)
|
||||
msg = edit_message(footer = footer, template=tmpl)
|
||||
else:
|
||||
msg = msg.strip('\'').strip('"')
|
||||
if state is None:
|
||||
|
Loading…
Reference in New Issue
Block a user