Skip to content

Commit

Permalink
Better custom subject and body prop handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ranbena committed Sep 24, 2019
1 parent 63b50e0 commit 5f8634a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions redash/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,8 +821,8 @@ def evaluate(self):
def subscribers(self):
return User.query.join(AlertSubscription).filter(AlertSubscription.alert == self)

def render_template(self, template):
if not template:
def render_template(self, template=None):
if template is None:
return ''

data = json_loads(self.query_rel.latest_query_data.data)
Expand Down Expand Up @@ -850,11 +850,13 @@ def render_template(self, template):

@property
def custom_body(self):
return self.render_template(self.options['custom_body'])
template = self.options.get('custom_body', self.options.get('template'))
return self.render_template(template)

@property
def custom_subject(self):
return self.render_template(self.options['custom_subject'])
template = self.options.get('custom_subject')
return self.render_template(template)

@property
def groups(self):
Expand Down

0 comments on commit 5f8634a

Please sign in to comment.