mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 13:41:15 -07:00
Fix email config for newsletters
This commit is contained in:
parent
5b1ff402bc
commit
b712874ed2
3 changed files with 27 additions and 30 deletions
|
@ -239,7 +239,7 @@
|
|||
</div>
|
||||
<p class="help-block">${item['description'] | n}</p>
|
||||
</div>
|
||||
% elif item['input_type'] == 'checkbox' and item['name'] != 'email_html_support':
|
||||
% elif item['input_type'] == 'checkbox' and item['name'] != 'newsletter_email_html_support':
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" data-id="${item['name']}" class="checkboxes" value="1" ${helpers.checked(item['value'])}> ${item['label']}
|
||||
|
@ -294,7 +294,7 @@
|
|||
</div>
|
||||
% endif
|
||||
% endfor
|
||||
<input type="hidden" id="email_html_support" name="email_html_support" value="1">
|
||||
<input type="hidden" id="newsletter_email_html_support" name="newsletter_email_html_support" value="1">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -387,7 +387,7 @@
|
|||
|
||||
var REGEX_EMAIL = '([a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@' +
|
||||
'(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)';
|
||||
var $email_selectors = $('#email_to, #email_cc, #email_bcc').selectize({
|
||||
var $email_selectors = $('#newsletter_email_to, #newsletter_email_cc, #newsletter_email_bcc').selectize({
|
||||
plugins: ['remove_button'],
|
||||
maxItems: null,
|
||||
render: {
|
||||
|
@ -453,9 +453,9 @@
|
|||
var email_to = $email_selectors[0].selectize;
|
||||
var email_cc = $email_selectors[1].selectize;
|
||||
var email_bcc = $email_selectors[2].selectize;
|
||||
email_to.setValue(${json.dumps(next((c['value'] for c in newsletter['email_config_options'] if c['name'] == 'email_to'), [])) | n});
|
||||
email_cc.setValue(${json.dumps(next((c['value'] for c in newsletter['email_config_options'] if c['name'] == 'email_cc'), [])) | n});
|
||||
email_bcc.setValue(${json.dumps(next((c['value'] for c in newsletter['email_config_options'] if c['name'] == 'email_bcc'), [])) | n});
|
||||
email_to.setValue(${json.dumps(next((c['value'] for c in newsletter['email_config_options'] if c['name'] == 'newsletter_email_to'), [])) | n});
|
||||
email_cc.setValue(${json.dumps(next((c['value'] for c in newsletter['email_config_options'] if c['name'] == 'newsletter_email_cc'), [])) | n});
|
||||
email_bcc.setValue(${json.dumps(next((c['value'] for c in newsletter['email_config_options'] if c['name'] == 'newsletter_email_bcc'), [])) | n});
|
||||
|
||||
function reloadModal() {
|
||||
$.ajax({
|
||||
|
|
|
@ -209,7 +209,7 @@ def set_newsletter_config(newsletter_id=None, agent_id=None, **kwargs):
|
|||
return False
|
||||
|
||||
config_prefix = agent['name'] + '_'
|
||||
email_config_prefix = 'email_'
|
||||
email_config_prefix = 'newsletter_email_'
|
||||
|
||||
newsletter_config = {k[len(config_prefix):]: kwargs.pop(k)
|
||||
for k in kwargs.keys() if k.startswith(config_prefix)}
|
||||
|
@ -350,7 +350,11 @@ class Newsletter(object):
|
|||
if isinstance(v, int):
|
||||
new_config[k] = helpers.cast_to_int(config.get(k, v))
|
||||
elif isinstance(v, list):
|
||||
new_config[k] = list(config.get(k, v))
|
||||
c = config.get(k, v)
|
||||
if not isinstance(c, list):
|
||||
new_config[k] = [c]
|
||||
else:
|
||||
new_config[k] = c
|
||||
else:
|
||||
new_config[k] = config.get(k, v)
|
||||
|
||||
|
@ -489,7 +493,10 @@ class Newsletter(object):
|
|||
return config_options
|
||||
|
||||
def return_email_config_options(self):
|
||||
return EMAIL(self.email_config).return_config_options()
|
||||
config_options = EMAIL(self.email_config).return_config_options()
|
||||
for c in config_options:
|
||||
c['name'] = 'newsletter_' + c['name']
|
||||
return config_options
|
||||
|
||||
|
||||
class RecentlyAdded(Newsletter):
|
||||
|
|
|
@ -767,13 +767,19 @@ class Notifier(object):
|
|||
for k, v in default.iteritems():
|
||||
if isinstance(v, int):
|
||||
new_config[k] = helpers.cast_to_int(config.get(k, v))
|
||||
elif isinstance(v, list):
|
||||
c = config.get(k, v)
|
||||
if not isinstance(c, list):
|
||||
new_config[k] = [c]
|
||||
else:
|
||||
new_config[k] = c
|
||||
else:
|
||||
new_config[k] = config.get(k, v)
|
||||
|
||||
return new_config
|
||||
|
||||
def return_default_config(self):
|
||||
return self._DEFAULT_CONFIG
|
||||
return self._DEFAULT_CONFIG.copy()
|
||||
|
||||
def notify(self, subject='', body='', action='', **kwargs):
|
||||
if self.NAME != 'Script':
|
||||
|
@ -1274,9 +1280,9 @@ class EMAIL(Notifier):
|
|||
NAME = 'Email'
|
||||
_DEFAULT_CONFIG = {'from_name': 'Tautulli',
|
||||
'from': '',
|
||||
'to': '',
|
||||
'cc': '',
|
||||
'bcc': '',
|
||||
'to': [],
|
||||
'cc': [],
|
||||
'bcc': [],
|
||||
'smtp_server': '',
|
||||
'smtp_port': 25,
|
||||
'smtp_user': '',
|
||||
|
@ -1285,16 +1291,6 @@ class EMAIL(Notifier):
|
|||
'html_support': 1
|
||||
}
|
||||
|
||||
def __init__(self, config=None):
|
||||
super(EMAIL, self).__init__(config=config)
|
||||
|
||||
if not isinstance(self.config['to'], list):
|
||||
self.config['to'] = [x.strip() for x in self.config['to'].split(';')]
|
||||
if not isinstance(self.config['cc'], list):
|
||||
self.config['cc'] = [x.strip() for x in self.config['cc'].split(';')]
|
||||
if not isinstance(self.config['bcc'], list):
|
||||
self.config['bcc'] = [x.strip() for x in self.config['bcc'].split(';')]
|
||||
|
||||
def agent_notify(self, subject='', body='', action='', **kwargs):
|
||||
if self.config['html_support']:
|
||||
msg = MIMEMultipart('alternative')
|
||||
|
@ -2005,7 +2001,7 @@ class JOIN(Notifier):
|
|||
"""
|
||||
NAME = 'Join'
|
||||
_DEFAULT_CONFIG = {'api_key': '',
|
||||
'device_names': '',
|
||||
'device_names': [],
|
||||
'priority': 2,
|
||||
'incl_subject': 1,
|
||||
'incl_poster': 0,
|
||||
|
@ -2014,12 +2010,6 @@ class JOIN(Notifier):
|
|||
'music_provider': ''
|
||||
}
|
||||
|
||||
def __init__(self, config=None):
|
||||
super(JOIN, self).__init__(config=config)
|
||||
|
||||
if not isinstance(self.config['device_names'], list):
|
||||
self.config['device_names'] = [x.strip() for x in self.config['device_names'].split(',')]
|
||||
|
||||
def agent_notify(self, subject='', body='', action='', **kwargs):
|
||||
data = {'apikey': self.config['api_key'],
|
||||
'deviceNames': ','.join(self.config['device_names']),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue