Skip to content

Commit

Permalink
JavaScript error fix when config-lock env var set (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc authored Apr 6, 2024
1 parent 515cadf commit d1c5d64
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 65 deletions.
5 changes: 3 additions & 2 deletions apprise_api/api/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 2 additions & 0 deletions apprise_api/api/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ <h1>{% trans "Apprise API" %}</h1>
<ul class="collection z-depth-1">
<a class="collection-item" href="{% url 'config' DEFAULT_CONFIG_ID %}"><i class="material-icons">settings</i>
{% trans "Configuration Manager" %}</a>
{% if not CONFIG_LOCK %}
<a class="collection-item" href="{% url 'config' UNIQUE_CONFIG_ID %}"><i class="material-icons">refresh</i>
{% trans "New Configuration" %}</a>
{% endif %}
</ul>
{% endif %}
<ul class="collection z-depth-1">
Expand Down
123 changes: 62 additions & 61 deletions apprise_api/api/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h4>{% trans "Management for Config ID:" %} <code class="config-id">{{ key }}</c
</li>
<li class="tab {% if CONFIG_LOCK %}disabled {% endif %}col s3"><a href="#review"><i class="material-icons">{% if not CONFIG_LOCK %}web{% else %}lock{% endif %}</i> {%trans "Review" %}</a>
</li>
<li class="tab col s3"><a href="#notify"><i class="material-icons">announcement</i> {%trans "Notifications" %} <span class="card-count"></span></a>
<li class="tab col s3"><a href="#notify"><i class="material-icons">announcement</i> {%trans "Notifications" %}{% if not CONFIG_LOCK %} <span class="card-count"></span>{% endif %}</a>
</li>
</ul>
</div>
Expand Down Expand Up @@ -60,68 +60,68 @@ <h5>{% trans "Getting Started" %}</h5>
</ol>
</div>
{% else %}
<div class="section">
<h5>{% trans "Apprise Configuration is Locked" %}</h5>
<p>
{% 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 %}</p>
</div>
<div class="section">
<h5>{% trans "Apprise Configuration is Locked" %}</h5>
<p>
{% 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 %}</p>
</div>
{% endif %}
<div class="has-config">
<div class="section">
<h5>{% trans "Working Remotely With Your Configuration" %}</h5>
<h6>{% trans "Using The Apprise CLI" %}</h6>
<p>
{% blocktrans %}The following command would cause apprise to directly notify all of your services:{% endblocktrans %}
<pre><code class="bash">apprise --body="Test Message" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;apprise{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/<em>{{key}}</em>/?tags=all</code></pre>
{% blocktrans %}Send one or more attachments like this:{% endblocktrans %}
<pre><code class="bash">apprise --body="Test Message" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;apprise{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/<em>{{key}}</em>/?tags=all \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;--attach=/path/to/an/attachment.jpeg \ <br/>
&nbsp;&nbsp;&nbsp;&nbsp;--attach=https://raw.githubusercontent.com/caronc/apprise/master/apprise/assets/themes/default/apprise-logo.png<br/>
</code></pre>
</p>
{% if not CONFIG_LOCK %}
<p>
{% blocktrans %}The following command would cause apprise to retrieve the configuration loaded and
send a test notification to all of your added services:{% endblocktrans %}
<br />
<pre><code class="bash">apprise --body="Test Message" --tag=all \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;--config={{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/get/<em>{{key}}</em></code></pre>
{% blocktrans %}You may also create an <a href="https://github.com/caronc/apprise/wiki/config#cli" target="_blank">Apprise configuration file</a> that contains this line somewhere in it:{% endblocktrans %}
<pre><code class="bash">include {{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/get/<em>{{key}}</em></code></pre>
{% blocktrans %}By leveraging the <em>include</em> directive, it will automatically be referenced for future calls to the <code>apprise</code> tool. All future calls using Apprise now simplify to:{% endblocktrans %}
<pre><code class="bash">apprise --body="Test Message" --tag=all</em></code></pre>
</p>

{% endif %}
<h6>{% trans "Using CURL" %}</h6>
<p>
{% blocktrans %}The following command would cause the apprise api to notify all of your services:{% endblocktrans %}
<pre><code class="bash">curl&nbsp;-X&nbsp;POST \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "body=Test Message" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "tags=all" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em></code></pre>
{% blocktrans %}Send one or more attachments like this:{% endblocktrans %}
<pre><code class="bash">curl&nbsp;-X&nbsp;POST \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "tags=all" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "body=Test Message" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F [email protected] \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F attach2=@/my/path/to/Apprise.doc \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em></code></pre>
{% blocktrans %}Sends a notification to our endpoints with an attachment{% endblocktrans %}
<pre><code class="bash">
curl -X POST \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "tag=all" \ <br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "attach=https://raw.githubusercontent.com/caronc/apprise/master/apprise/assets/themes/default/apprise-logo.png" \ <br/>
&nbsp;&nbsp;&nbsp;&nbsp;"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em>"</code></pre>
</p>
</div>
{% if not CONFIG_LOCK %}
<div class="section has-config">
<h5>{% trans "Working Remotely With Your Configuration" %}</h5>
<h6>{% trans "Using The Apprise CLI" %}</h6>
<p>
{% blocktrans %}The following command would cause apprise to directly notify all of your services:{% endblocktrans %}
<pre><code class="bash">apprise --body="Test Message" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;apprise{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/<em>{{key}}</em>/?tags=all</code></pre>
{% blocktrans %}Send one or more attachments like this:{% endblocktrans %}
<pre><code class="bash">apprise --body="Test Message" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;apprise{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/<em>{{key}}</em>/?tags=all \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;--attach=/path/to/an/attachment.jpeg \ <br/>
&nbsp;&nbsp;&nbsp;&nbsp;--attach=https://raw.githubusercontent.com/caronc/apprise/master/apprise/assets/themes/default/apprise-logo.png<br/>
</code></pre>
</p>
{% if not CONFIG_LOCK %}
<p>
{% blocktrans %}The following command would cause apprise to retrieve the configuration loaded and
send a test notification to all of your added services:{% endblocktrans %}
<br />
<pre><code class="bash">apprise --body="Test Message" --tag=all \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;--config={{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/get/<em>{{key}}</em></code></pre>
{% blocktrans %}You may also create an <a href="https://github.com/caronc/apprise/wiki/config#cli" target="_blank">Apprise configuration file</a> that contains this line somewhere in it:{% endblocktrans %}
<pre><code class="bash">include {{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/get/<em>{{key}}</em></code></pre>
{% blocktrans %}By leveraging the <em>include</em> directive, it will automatically be referenced for future calls to the <code>apprise</code> tool. All future calls using Apprise now simplify to:{% endblocktrans %}
<pre><code class="bash">apprise --body="Test Message" --tag=all</em></code></pre>
</p>

{% endif %}
<h6>{% trans "Using CURL" %}</h6>
<p>
{% blocktrans %}The following command would cause the apprise api to notify all of your services:{% endblocktrans %}
<pre><code class="bash">curl&nbsp;-X&nbsp;POST \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "body=Test Message" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "tags=all" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em></code></pre>
{% blocktrans %}Send one or more attachments like this:{% endblocktrans %}
<pre><code class="bash">curl&nbsp;-X&nbsp;POST \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "tags=all" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "body=Test Message" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F [email protected] \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F attach2=@/my/path/to/Apprise.doc \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em></code></pre>
{% blocktrans %}Sends a notification to our endpoints with an attachment{% endblocktrans %}
<pre><code class="bash">
curl -X POST \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "tag=all" \ <br/>
&nbsp;&nbsp;&nbsp;&nbsp;-F "attach=https://raw.githubusercontent.com/caronc/apprise/master/apprise/assets/themes/default/apprise-logo.png" \ <br/>
&nbsp;&nbsp;&nbsp;&nbsp;"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em>"</code></pre>
</p>
</div>
{% endif %}
</div>
<div id="config" class="col s12">
{% if not CONFIG_LOCK %}
Expand Down Expand Up @@ -328,6 +328,7 @@ <h4>{% trans "Persistent Store Endpoints" %}</h4>
const data = {
urls: []
};
const chipElement = document.querySelector('.chips');
M.Chips.init(chipElement, {
placeholder: '{% trans "Optional Tag" %}',
secondaryPlaceholder: '{% trans "Another Tag" %}'
Expand Down
1 change: 0 additions & 1 deletion apprise_api/api/tests/test_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
1 change: 0 additions & 1 deletion apprise_api/core/middleware/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#
import re
from django.conf import settings
from core.themes import SiteTheme, SITE_THEMES
import datetime


Expand Down

0 comments on commit d1c5d64

Please sign in to comment.