mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-10 23:42:37 -07:00
Add custom body line to formatted email
This commit is contained in:
parent
f12de78370
commit
4aeafdae2d
7 changed files with 59 additions and 22 deletions
|
@ -3,9 +3,8 @@
|
|||
import json
|
||||
from plexpy import helpers, notifiers
|
||||
|
||||
all_notifiers = notifiers.get_notifiers()
|
||||
all_notifiers = sorted(notifiers.get_notifiers(), key=lambda k: (k['agent_label'].lower(), k['friendly_name'], k['id']))
|
||||
email_notifiers = [n for n in all_notifiers if n['agent_name'] == 'email']
|
||||
sorted(email_notifiers, key=lambda k: (k['agent_label'], k['friendly_name'], k['id']))
|
||||
email_notifiers = [{'id': 0, 'agent_label': 'New Email Configuration', 'friendly_name': ''}] + email_notifiers
|
||||
other_notifiers = [{'id': 0, 'agent_label': 'Select a Notification Agent', 'friendly_name': ''}] + all_notifiers
|
||||
%>
|
||||
|
@ -161,6 +160,10 @@
|
|||
Set the custom formatted text for each type of notification.
|
||||
<a href="#newsletter-text-sub-modal" data-toggle="modal">Click here</a> for a list of available parameters which can be used.
|
||||
</p>
|
||||
<p class="help-block">
|
||||
You can also add text modifiers to change the case or slice parameters with a list of items.
|
||||
<a href="#notify-text-modifiers-modal" data-toggle="modal">Click here</a> to view usage information.
|
||||
</p>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
|
@ -171,19 +174,18 @@
|
|||
</div>
|
||||
</div>
|
||||
<p class="help-block">
|
||||
Optional: Enter a subject line for the newsletter. Leave blank for default.
|
||||
Enter a custom subject line for the newsletter. Leave blank for default.
|
||||
</p>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="body">Body</label>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<input type="text" class="form-control" id="body" name="body" value="${newsletter['body']}" size="30">
|
||||
<textarea class="form-control" id="body" name="body" value="${newsletter['body']}" data-autoresize>${newsletter['body']}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<p class="help-block">
|
||||
Optional: Enter a body line for the newsletter. Leave blank for default.<br>
|
||||
Note: Only sent to notifications agents other than HTML formatted Emails.
|
||||
Enter a custom body line for the newsletter.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -638,6 +640,14 @@
|
|||
}
|
||||
});
|
||||
|
||||
// auto resizing textarea for custom notification message body
|
||||
$('textarea[data-autoresize]').each(function () {
|
||||
var offset = this.offsetHeight - this.clientHeight;
|
||||
var resizeTextarea = function (el) {
|
||||
$(el).css('height', 'auto').css('height', el.scrollHeight + offset);
|
||||
};
|
||||
$(this).on('focus keyup input', function () { resizeTextarea(this); }).removeAttr('data-autoresize');
|
||||
});
|
||||
</script>
|
||||
% else:
|
||||
<div class="modal-dialog" role="document">
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
from plexpy import common, notifiers, newsletters
|
||||
from plexpy.helpers import anon_url, checked
|
||||
|
||||
available_notification_agents = sorted(notifiers.available_notification_agents(), key=lambda k: k['label'])
|
||||
available_newsletter_agents = sorted(newsletters.available_newsletter_agents(), key=lambda k: k['label'])
|
||||
available_notification_agents = sorted(notifiers.available_notification_agents(), key=lambda k: k['label'].lower())
|
||||
available_newsletter_agents = sorted(newsletters.available_newsletter_agents(), key=lambda k: k['label'].lower())
|
||||
%>
|
||||
<%def name="headIncludes()">
|
||||
</%def>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<head>
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Tautulli Newsletter - ${title}</title>
|
||||
<title>Tautulli Newsletter - ${subject}</title>
|
||||
<style>
|
||||
/* -------------------------------------
|
||||
GLOBAL RESETS
|
||||
|
@ -264,7 +264,13 @@
|
|||
visibility: hidden;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.body-message {
|
||||
color: #282A2D;
|
||||
font-size: 16px;
|
||||
margin-bottom: 15px;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
.view-full {
|
||||
clear: both;
|
||||
color: #282A2D;
|
||||
|
@ -598,7 +604,13 @@
|
|||
<div class="content" style="box-sizing: border-box;display: block;margin: 0 auto;max-width: 1037px;padding: 10px;">
|
||||
|
||||
<!-- START CENTERED WHITE CONTAINER -->
|
||||
<span class="preheader" style="color: transparent;display: none;height: 0;max-height: 0;max-width: 0;opacity: 0;overflow: hidden;mso-hide: all;visibility: hidden;width: 0;">Tautulli Newsletter - ${title}</span>
|
||||
<span class="preheader" style="color: transparent;display: none;height: 0;max-height: 0;max-width: 0;opacity: 0;overflow: hidden;mso-hide: all;visibility: hidden;width: 0;">Tautulli Newsletter - ${subject}</span>
|
||||
|
||||
% if body:
|
||||
<div class="body-message" style="color: #282A2D;font-size: 16px;margin-bottom: 15px;text-align: center;width: 100%;">
|
||||
${'<br>'.join(l for l in body.splitlines()) | n}
|
||||
</div>
|
||||
% endif
|
||||
|
||||
% if base_url and not preview:
|
||||
<div class="view-full" style="clear: both;color: #282A2D;font-size: 12px;margin-bottom: 10px;text-align: center;width: 100%;"> <!-- IGNORE SAVE -->
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
<head>
|
||||
<meta name="viewport" content="width=device-width"/>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<title>Tautulli Newsletter - ${title}</title>
|
||||
<title>Tautulli Newsletter - ${subject}</title>
|
||||
<style>
|
||||
/* -------------------------------------
|
||||
GLOBAL RESETS
|
||||
|
@ -264,7 +264,13 @@
|
|||
visibility: hidden;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.body-message {
|
||||
color: #282A2D;
|
||||
font-size: 16px;
|
||||
margin-bottom: 15px;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
.view-full {
|
||||
clear: both;
|
||||
color: #282A2D;
|
||||
|
@ -598,7 +604,13 @@
|
|||
<div class="content">
|
||||
|
||||
<!-- START CENTERED WHITE CONTAINER -->
|
||||
<span class="preheader">Tautulli Newsletter - ${title}</span>
|
||||
<span class="preheader">Tautulli Newsletter - ${subject}</span>
|
||||
|
||||
% if body:
|
||||
<div class="body-message">
|
||||
${'<br>'.join(l for l in body.splitlines()) | n}
|
||||
</div>
|
||||
% endif
|
||||
|
||||
% if base_url and not preview:
|
||||
<div class="view-full"> <!-- IGNORE SAVE -->
|
||||
|
|
|
@ -294,7 +294,7 @@ class Newsletter(object):
|
|||
_DEFAULT_EMAIL_CONFIG['from_name'] = 'Tautulli Newsletter'
|
||||
_DEFAULT_EMAIL_CONFIG['notifier_id'] = 0
|
||||
_DEFAULT_SUBJECT = 'Tautulli Newsletter'
|
||||
_DEFAULT_BODY = 'Tautulli Newsletter'
|
||||
_DEFAULT_BODY = ''
|
||||
_TEMPLATE_MASTER = ''
|
||||
_TEMPLATE = ''
|
||||
|
||||
|
@ -389,7 +389,8 @@ class Newsletter(object):
|
|||
return serve_template(
|
||||
templatename=template,
|
||||
uuid=self.uuid,
|
||||
title=self.subject_formatted,
|
||||
subject=self.subject_formatted,
|
||||
body=self.body_formatted,
|
||||
parameters=self.parameters,
|
||||
data=self.data,
|
||||
preview=self.is_preview
|
||||
|
@ -528,7 +529,7 @@ class RecentlyAdded(Newsletter):
|
|||
_DEFAULT_CONFIG = Newsletter._DEFAULT_CONFIG.copy()
|
||||
_DEFAULT_CONFIG['incl_libraries'] = []
|
||||
_DEFAULT_SUBJECT = 'Recently Added to {server_name}! ({end_date})'
|
||||
_DEFAULT_BODY = 'View the full newsletter here: {newsletter_url}'
|
||||
_DEFAULT_BODY = ''
|
||||
_TEMPLATE_MASTER = 'recently_added_master.html'
|
||||
_TEMPLATE = 'recently_added.html'
|
||||
|
||||
|
|
|
@ -1345,13 +1345,13 @@ class CustomFormatter(Formatter):
|
|||
|
||||
def format_field(self, value, format_spec):
|
||||
if format_spec.startswith('[') and format_spec.endswith(']'):
|
||||
pattern = re.compile(r'\[(\d*):?(\d*)\]')
|
||||
pattern = re.compile(r'\[(-?\d*):?(-?\d*)\]')
|
||||
if re.match(pattern, format_spec): # slice
|
||||
items = [x.strip() for x in unicode(value).split(',')]
|
||||
slice_start, slice_end = re.search(pattern, format_spec).groups()
|
||||
slice_start = max(int(slice_start), 0) if slice_start else None
|
||||
slice_end = min(int(slice_end), len(items)) if slice_end else None
|
||||
return ', '.join(items[slice_start:slice_end])
|
||||
slice_start = helpers.cast_to_int(slice_start) or None
|
||||
slice_end = helpers.cast_to_int(slice_end) or None
|
||||
return ', '.join(items[slice(slice_start, slice_end)])
|
||||
else:
|
||||
return value
|
||||
else:
|
||||
|
|
|
@ -5636,7 +5636,9 @@ class WebInterface(object):
|
|||
newsletter_agent = newsletters.get_agent_class(agent_id=newsletter['agent_id'],
|
||||
config=newsletter['config'],
|
||||
start_date=start_date,
|
||||
end_date=end_date)
|
||||
end_date=end_date,
|
||||
subject=newsletter['subject'],
|
||||
body=newsletter['body'])
|
||||
preview = (preview == 'true')
|
||||
master = (master == 'true')
|
||||
raw = (raw == 'true')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue