From 1cb5f0b635ec8034592a1fe0d2d5233631c47d23 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Mon, 19 Mar 2018 22:57:38 -0700 Subject: [PATCH] Add newsletter base URL setting --- data/interfaces/default/css/tautulli.css | 13 +++++++++++ data/interfaces/default/settings.html | 29 +++++++++++++++++++++++- plexpy/config.py | 3 ++- plexpy/newsletters.py | 24 +++++--------------- plexpy/webserve.py | 3 ++- 5 files changed, 51 insertions(+), 21 deletions(-) diff --git a/data/interfaces/default/css/tautulli.css b/data/interfaces/default/css/tautulli.css index 7ca8b0c3..a577c236 100644 --- a/data/interfaces/default/css/tautulli.css +++ b/data/interfaces/default/css/tautulli.css @@ -469,6 +469,19 @@ fieldset[disabled] .btn-bright.active { .btn-group select { margin-top: 0; } +.input-group-addon-form { + display: inline-block; + line-height: 1.42857143; + color: #e5e5e5; + background-color: #3B3B3B; + border: 1px solid transparent; + border-top-right-radius: 3px !important; + border-bottom-right-radius: 3px !important; + height: 32px; + width: 100%; + margin-top: 5px; + opacity: 0.65; +} #user-selection label { margin-bottom: 0; } diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index 0d981e85..a061bf34 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -52,6 +52,7 @@
  • Plex Media Server
  • Notifications
  • Notification Agents
  • +
  • Newsletters
  • Newsletter Agents
  • Import & Backups
  • Tautulli Remote Android App beta
  • @@ -692,7 +693,7 @@
    - + @@ -982,6 +983,32 @@
    +
    + +
    +

    Newsletters

    +
    + +
    + +
    +
    +
    + + + /newsletter + +
    +
    + +
    +

    Set your Tautulli base URL for self-hosted newsletters. (e.g. http://mydomain.com)

    +
    + +

    + +
    +
    diff --git a/plexpy/config.py b/plexpy/config.py index 7ac879fb..265532c8 100644 --- a/plexpy/config.py +++ b/plexpy/config.py @@ -308,7 +308,8 @@ _CONFIG_DEFINITIONS = { 'MONITOR_REMOTE_ACCESS': (int, 'Monitoring', 0), 'MONITORING_INTERVAL': (int, 'Monitoring', 60), 'MONITORING_USE_WEBSOCKET': (int, 'Monitoring', 0), - 'NEWSLETTER_DIR': (str, 'General', ''), + 'NEWSLETTER_DIR': (str, 'Newsletter', ''), + 'NEWSLETTER_BASE_URL': (str, 'Newsletter', ''), 'NMA_APIKEY': (str, 'NMA', ''), 'NMA_ENABLED': (int, 'NMA', 0), 'NMA_PRIORITY': (int, 'NMA', 0), diff --git a/plexpy/newsletters.py b/plexpy/newsletters.py index d8daac2a..5ed4520a 100644 --- a/plexpy/newsletters.py +++ b/plexpy/newsletters.py @@ -341,8 +341,6 @@ class Newsletter(object): self.is_preview = False def set_config(self, config=None, default=None): - self._add_config() - return self._validate_config(config=config, default=default) def _validate_config(self, config=None, default=None): @@ -353,14 +351,13 @@ class Newsletter(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): + new_config[k] = list(config.get(k, v)) else: new_config[k] = config.get(k, v) return new_config - def _add_config(self): - pass - def retrieve_data(self): pass @@ -448,12 +445,14 @@ class Newsletter(object): def _build_params(self): date_format = helpers.momentjs_to_arrow(plexpy.CONFIG.DATE_FORMAT) + base_url = plexpy.CONFIG.NEWSLETTER_BASE_URL or helpers.get_plexpy_url() + parameters = { 'server_name': plexpy.CONFIG.PMS_NAME, 'start_date': self.start_date.format(date_format), 'end_date': self.end_date.format(date_format), 'newsletter_days': self.config['last_days'], - 'newsletter_url': 'http://localhost:8181/dev'.rstrip('/') + '/newsletter/' + self.uuid, + 'newsletter_url': base_url.rstrip('/') + '/newsletter/' + self.uuid, 'newsletter_uuid': self.uuid } @@ -500,24 +499,13 @@ class RecentlyAdded(Newsletter): """ NAME = 'Recently Added' _DEFAULT_CONFIG = {'last_days': 7, - 'incl_libraries': None + 'incl_libraries': [] } _DEFAULT_SUBJECT = 'Recently Added to {server_name}! ({end_date})' _DEFAULT_BODY = 'View the newsletter here: {newsletter_url}' _TEMPLATE_MASTER = 'recently_added_master.html' _TEMPLATE = 'recently_added.html' - def __init__(self, config=None, email_config=None, start_date=None, end_date=None, subject=None, body=None): - super(RecentlyAdded, self).__init__(config=config, email_config=email_config, - start_date=start_date, end_date=end_date, - subject=subject, body=body) - - def _add_config(self): - if self.config['incl_libraries'] is None: - self.config['incl_libraries'] = [] - elif not isinstance(self.config['incl_libraries'], list): - self.config['incl_libraries'] = [self.config['incl_libraries']] - def _get_recently_added(self, media_type=None): pms_connect = pmsconnect.PmsConnect() diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 63b78895..08ae5b8a 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -2746,7 +2746,8 @@ class WebInterface(object): "themoviedb_lookup": checked(plexpy.CONFIG.THEMOVIEDB_LOOKUP), "tvmaze_lookup": checked(plexpy.CONFIG.TVMAZE_LOOKUP), "show_advanced_settings": plexpy.CONFIG.SHOW_ADVANCED_SETTINGS, - "newsletter_dir": plexpy.CONFIG.NEWSLETTER_DIR + "newsletter_dir": plexpy.CONFIG.NEWSLETTER_DIR, + "newsletter_base_url": plexpy.CONFIG.NEWSLETTER_BASE_URL } return serve_template(templatename="settings.html", title="Settings", config=config, kwargs=kwargs)