Skip to content
This repository has been archived by the owner on Aug 28, 2023. It is now read-only.

Commit

Permalink
Report errors from JIRA on fields marked as ignored
Browse files Browse the repository at this point in the history
Fixes #39
  • Loading branch information
thurloat committed Jun 26, 2013
1 parent 605ad0a commit 362bd5b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sentry_jira/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class JIRAIssueForm(forms.Form):
)

def __init__(self, *args, **kwargs):
ignored_fields = kwargs.pop("ignored_fields")
self.ignored_fields = kwargs.pop("ignored_fields")
initial = kwargs.get("initial")
jira_client = initial.pop("jira_client")

Expand Down Expand Up @@ -203,7 +203,7 @@ def __init__(self, *args, **kwargs):
dynamic_fields.sort(key=lambda f: anti_gravity.get(f) or 0)
# build up some dynamic fields based on required shit.
for field in dynamic_fields:
if field in self.fields.keys() or field in [x.strip() for x in ignored_fields.split(",")]:
if field in self.fields.keys() or field in [x.strip() for x in self.ignored_fields.split(",")]:
# don't overwrite the fixed fields for the form.
continue
mb_field = self.build_dynamic_field(self.issue_type["fields"][field])
Expand Down
16 changes: 14 additions & 2 deletions sentry_jira/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ def view(self, request, group, **kwargs):
request.POST or None,
initial=self.get_initial_form_data(request, group, event),
ignored_fields=self.get_option("ignored_fields", group.project))
########################################################################
#######################################################################
# to allow the form to be submitted, but ignored so that dynamic fields
# can change if the issuetype is different
#
if request.POST and request.POST.get("changing_issuetype") == "0":
########################################################################
#######################################################################
if form.is_valid():
issue_id, error = self.create_issue(
group=group,
Expand All @@ -148,6 +148,18 @@ def view(self, request, group, **kwargs):
if error:
form.errors.update(error)

# Register field errors which were returned from the JIRA
# API, but were marked as ignored fields in the
# configuration with the global error reporter for the form
ignored_errors = [v for k, v in error.items()
if k in form.ignored_fields.split(",")]
if len(ignored_errors) > 0:
errs = form.errors['__all__']
errs.append("Validation Error on ignored field, check"
" your plugin settings.")
errs.extend(ignored_errors)
form.errors['__all__'] = errs

if form.is_valid():
GroupMeta.objects.set_value(group, '%s:tid' % prefix, issue_id)

Expand Down

0 comments on commit 362bd5b

Please sign in to comment.