From 0ead3325bba116fed05fc98e9cde9d08f0a287d1 Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Sat, 6 Apr 2024 11:59:05 -0400 Subject: [PATCH] JavaScript error fix when config-lock env var set --- apprise_api/api/forms.py | 5 +- apprise_api/api/templates/base.html | 2 + apprise_api/api/templates/config.html | 123 +++++++++++++------------- apprise_api/api/tests/test_notify.py | 1 - apprise_api/core/middleware/config.py | 1 - 5 files changed, 67 insertions(+), 65 deletions(-) diff --git a/apprise_api/api/forms.py b/apprise_api/api/forms.py index 62ef47d..4844395 100644 --- a/apprise_api/api/forms.py +++ b/apprise_api/api/forms.py @@ -152,8 +152,9 @@ class NotifyForm(forms.Form): required=False, ) - # Allow support for tags keyword in addition to tag; the 'tag' field will always take priority over this - # however adding `tags` gives the user more flexibilty to use either/or keyword + # Allow support for tags keyword in addition to tag; the 'tag' field will + # always take priority over this however adding `tags` gives the user more + # flexibilty to use either/or keyword tags = forms.CharField( label=_('Tags'), widget=forms.HiddenInput(), diff --git a/apprise_api/api/templates/base.html b/apprise_api/api/templates/base.html index 60fe6d7..2ebe111 100644 --- a/apprise_api/api/templates/base.html +++ b/apprise_api/api/templates/base.html @@ -50,8 +50,10 @@

{% trans "Apprise API" %}

{% endif %} @@ -60,68 +60,68 @@
{% trans "Getting Started" %}
{% else %} -
-
{% trans "Apprise Configuration is Locked" %}
-

- {% blocktrans %}At this time, the administrator of this server has locked down all configuration. This means - That pre-created configuration is securely hidden for the purpose of notification transmission only. - - New configuration can not be set, and existing configuration can not be modified or viewed. - {% endblocktrans %}

-
+
+
{% trans "Apprise Configuration is Locked" %}
+

+ {% blocktrans %}At this time, the administrator of this server has locked down all configuration. This means + That pre-created configuration is securely hidden for the purpose of notification transmission only. + + New configuration can not be set, and existing configuration can not be modified or viewed. + {% endblocktrans %}

+
{% endif %} -
-
-
{% trans "Working Remotely With Your Configuration" %}
-
{% trans "Using The Apprise CLI" %}
-

- {% blocktrans %}The following command would cause apprise to directly notify all of your services:{% endblocktrans %} -

apprise --body="Test Message" \
-     apprise{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/{{key}}/?tags=all
- {% blocktrans %}Send one or more attachments like this:{% endblocktrans %} -
apprise --body="Test Message" \
-     apprise{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/{{key}}/?tags=all \
-     --attach=/path/to/an/attachment.jpeg \
-     --attach=https://raw.githubusercontent.com/caronc/apprise/master/apprise/assets/themes/default/apprise-logo.png
-
-

- {% if not CONFIG_LOCK %} -

- {% blocktrans %}The following command would cause apprise to retrieve the configuration loaded and - send a test notification to all of your added services:{% endblocktrans %} -
-

apprise --body="Test Message" --tag=all \
-     --config={{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/get/{{key}}
- {% blocktrans %}You may also create an Apprise configuration file that contains this line somewhere in it:{% endblocktrans %} -
include {{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/get/{{key}}
- {% blocktrans %}By leveraging the include directive, it will automatically be referenced for future calls to the apprise tool. All future calls using Apprise now simplify to:{% endblocktrans %} -
apprise --body="Test Message" --tag=all
-

- - {% endif %} -
{% trans "Using CURL" %}
-

- {% blocktrans %}The following command would cause the apprise api to notify all of your services:{% endblocktrans %} -

curl -X POST \
-     -F "body=Test Message" \
-     -F "tags=all" \
-     http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/{{key}}
- {% blocktrans %}Send one or more attachments like this:{% endblocktrans %} -
curl -X POST \
-     -F "tags=all" \
-     -F "body=Test Message" \
-     -F attach1=@Screenshot-1.png \
-     -F attach2=@/my/path/to/Apprise.doc \
-     http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/{{key}}
- {% blocktrans %}Sends a notification to our endpoints with an attachment{% endblocktrans %} -

-        curl -X POST \
-     -F "tag=all" \
-     -F "attach=https://raw.githubusercontent.com/caronc/apprise/master/apprise/assets/themes/default/apprise-logo.png" \
-     "{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/{{key}}"
-

-
+ {% if not CONFIG_LOCK %} +
+
{% trans "Working Remotely With Your Configuration" %}
+
{% trans "Using The Apprise CLI" %}
+

+ {% blocktrans %}The following command would cause apprise to directly notify all of your services:{% endblocktrans %} +

apprise --body="Test Message" \
+     apprise{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/{{key}}/?tags=all
+ {% blocktrans %}Send one or more attachments like this:{% endblocktrans %} +
apprise --body="Test Message" \
+     apprise{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/{{key}}/?tags=all \
+     --attach=/path/to/an/attachment.jpeg \
+     --attach=https://raw.githubusercontent.com/caronc/apprise/master/apprise/assets/themes/default/apprise-logo.png
+
+

+ {% if not CONFIG_LOCK %} +

+ {% blocktrans %}The following command would cause apprise to retrieve the configuration loaded and + send a test notification to all of your added services:{% endblocktrans %} +
+

apprise --body="Test Message" --tag=all \
+     --config={{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/get/{{key}}
+ {% blocktrans %}You may also create an Apprise configuration file that contains this line somewhere in it:{% endblocktrans %} +
include {{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/get/{{key}}
+ {% blocktrans %}By leveraging the include directive, it will automatically be referenced for future calls to the apprise tool. All future calls using Apprise now simplify to:{% endblocktrans %} +
apprise --body="Test Message" --tag=all
+

+ + {% endif %} +
{% trans "Using CURL" %}
+

+ {% blocktrans %}The following command would cause the apprise api to notify all of your services:{% endblocktrans %} +

curl -X POST \
+     -F "body=Test Message" \
+     -F "tags=all" \
+     http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/{{key}}
+ {% blocktrans %}Send one or more attachments like this:{% endblocktrans %} +
curl -X POST \
+     -F "tags=all" \
+     -F "body=Test Message" \
+     -F attach1=@Screenshot-1.png \
+     -F attach2=@/my/path/to/Apprise.doc \
+     http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/{{key}}
+ {% blocktrans %}Sends a notification to our endpoints with an attachment{% endblocktrans %} +

+      curl -X POST \
+     -F "tag=all" \
+     -F "attach=https://raw.githubusercontent.com/caronc/apprise/master/apprise/assets/themes/default/apprise-logo.png" \
+     "{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/{{key}}"
+

+ {% endif %}
{% if not CONFIG_LOCK %} @@ -328,6 +328,7 @@

{% trans "Persistent Store Endpoints" %}

const data = { urls: [] }; + const chipElement = document.querySelector('.chips'); M.Chips.init(chipElement, { placeholder: '{% trans "Optional Tag" %}', secondaryPlaceholder: '{% trans "Another Tag" %}' diff --git a/apprise_api/api/tests/test_notify.py b/apprise_api/api/tests/test_notify.py index eb598bb..949e504 100644 --- a/apprise_api/api/tests/test_notify.py +++ b/apprise_api/api/tests/test_notify.py @@ -1014,7 +1014,6 @@ def test_notify_by_loaded_urls_with_json(self, mock_notify): assert response.status_code == 200 assert mock_notify.call_count == 1 - # Reset our mock object mock_notify.reset_mock() diff --git a/apprise_api/core/middleware/config.py b/apprise_api/core/middleware/config.py index 4aaa7fd..a014bbb 100644 --- a/apprise_api/core/middleware/config.py +++ b/apprise_api/core/middleware/config.py @@ -25,7 +25,6 @@ # import re from django.conf import settings -from core.themes import SiteTheme, SITE_THEMES import datetime