submit: change status on submit and ask for assignment to myself if not already the case

This commit is contained in:
Benjamin Dauvergne 2018-06-22 22:53:29 +02:00
parent 93ce294512
commit 4d6c9c3f7f
1 changed files with 20 additions and 1 deletions

View File

@ -26,6 +26,10 @@ def slugify(title):
return title
def user_fullname(user):
return (user.firstname + u' ' + user.lastname).strip()
def get_config(name, default=Ellipsis):
repo = git.Repo()
reader = repo.config_reader()
@ -54,6 +58,7 @@ def get_redmine_api():
redmine.engine.session.mount('http://', HTTPAdapter(max_retries=3))
redmine.engine.session.mount('https://', HTTPAdapter(max_retries=3))
redmine.rustine = [cf for cf in redmine.custom_field.all() if cf.name == u'Rustine proposée'][0]
redmine.solution = [st for st in redmine.issue_status.all() if st.name == u'Solution proposée'][0]
return redmine
@ -249,7 +254,21 @@ def submit(issue, number_of_commits):
if message is not None:
message = message.split(MARKER, 1)[0].rstrip('\n')
api = get_redmine_api()
api.issue.update(issue.id, notes=message, uploads=patches, custom_fields=[{'id': api.rustine.id, 'value': u'1'}])
kwargs = {}
if click.confirm('Propose this patch as a solution ?'):
current_user = api.user.get('current')
if not hasattr(issue, 'assigned_to'):
issue.assigned_to_id = current_user.id
issue.save()
elif issue.assigned_to.id != current_user.id:
if click.confirm('Issue is currently assigned to %s, do you want '
'to assign the issue to yourself ?' % user_fullname(issue.assigned_to), abort=True):
issue.assigned_to_id = current_user.id
issue.save()
kwargs['status_id'] = api.solution.id
api.issue.update(issue.id, notes=message, uploads=patches,
custom_fields=[{'id': api.rustine.id, 'value': u'1'}],
**kwargs)
@issue.command()