From d9aa86716d48b9ff8c1fd924cc3b057bfd9a705d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Oct 03 2016 13:44:33 +0000 Subject: Fix figuring out if the milestone of a ticket was edited or not Basically, before we always added an empty choice to the list of milestones. This lead to a situation where there was always something assigned as milestone even when the project had none. With this change, we first check if there is a milestone before adding the empty choice to the list of choices and before retrieving the milestone from the form. --- diff --git a/pagure/forms.py b/pagure/forms.py index b9ee0fa..b8a2243 100644 --- a/pagure/forms.py +++ b/pagure/forms.py @@ -310,7 +310,7 @@ class UpdateIssueForm(FlaskForm): ) self.milestone.choices = [] - if 'milestones' in kwargs: + if 'milestones' in kwargs and kwargs['milestones']: for key in sorted(kwargs['milestones']): self.milestone.choices.append((key, key)) self.milestone.choices.insert(0, ('', '')) diff --git a/pagure/ui/issues.py b/pagure/ui/issues.py index 6217af6..f63b376 100644 --- a/pagure/ui/issues.py +++ b/pagure/ui/issues.py @@ -174,7 +174,8 @@ def update_issue(repo, issueid, username=None, namespace=None): new_milestone = None try: - new_milestone = form.milestone.data.strip() or None + if repo.milestones: + new_milestone = form.milestone.data.strip() or None except: pass