Browse Source

Add uuid/slug switcher in the Details page

master
Pēteris Caune 3 years ago
parent
commit
b8771b9eb8
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
3 changed files with 39 additions and 4 deletions
  1. +17
    -0
      hc/front/tests/test_details.py
  2. +4
    -0
      hc/front/views.py
  3. +18
    -4
      templates/front/details.html

+ 17
- 0
hc/front/tests/test_details.py View File

@ -177,3 +177,20 @@ class DetailsTestCase(BaseTestCase):
r = self.client.get(self.url)
self.assertNotContains(r, "Ping Key Required", status_code=200)
self.assertNotContains(r, "ping-now")
def test_it_handles_empty_slug(self):
self.project.show_slugs = True
self.project.save()
self.client.login(username="[email protected]", password="password")
r = self.client.get(self.url)
self.assertContains(r, "(unavailable, set name first)", status_code=200)
self.assertNotContains(r, "Copy URL")
self.assertNotContains(r, "ping-now")
def test_it_saves_url_format_preference(self):
self.client.login(username="[email protected]", password="password")
self.client.get(self.url + "?urls=slug")
self.project.refresh_from_db()
self.assertTrue(self.project.show_slugs)

+ 4
- 0
hc/front/views.py View File

@ -641,6 +641,10 @@ def details(request, code):
_refresh_last_active_date(request.profile)
check, rw = _get_check_for_user(request, code)
if request.GET.get("urls") in ("uuid", "slug") and rw:
check.project.show_slugs = request.GET["urls"] == "slug"
check.project.save()
channels = Channel.objects.filter(project=check.project)
channels = list(channels.order_by("created"))


+ 18
- 4
templates/front/details.html View File

@ -73,17 +73,27 @@
{% endif %}
<div id="how-to-ping" class="details-block">
<h2>How To Ping</h2>
<h2>
How To Ping
{% if rw %}
<div class="btn-group pull-right">
<a href="?urls=uuid" class="btn btn-default btn-xs {% if not project.show_slugs %}active{% endif %}">uuid</a>
<a href="?urls=slug" class="btn btn-default btn-xs {% if project.show_slugs %}active{% endif %}">slug</a>
</div>
{% endif %}
</h2>
<div>
<p>
Keep this check up by making HTTP
{% if check.methods == "POST" %}POST{% endif %}
requests to this URL:
</p>
{% if check.url %}
<code>{{ check.url }}</code>
<p>
Or by sending emails to this address:
</p>
{% else %}
<code>(unavailable, set name first)</code>
{% endif %}
<p>Ping by sending email:</p>
<code>{{ check.email }}</code>
<p>You can also explicitly
@ -101,6 +111,7 @@
data-target="#filtering-rules-modal"
class="btn btn-sm btn-default">Filtering Rules&hellip;</button>
{% endif %}
{% if check.url %}
<button
data-toggle="modal"
data-target="#show-usage-modal"
@ -109,6 +120,7 @@
data-label="Copy URL"
data-clipboard-text="{{ check.url }}"
class="btn btn-sm btn-default copy-btn">Copy URL</button>
{% endif %}
</div>
</div>
@ -142,6 +154,7 @@
</form>
{% endif %}
{% if check.url %}
{% if project.show_slugs and not project.ping_key %}
{% if rw %}
<button
@ -155,6 +168,7 @@
data-url="{{ check.url }}"
class="btn btn-sm btn-default">Ping Now!</button>
{% endif %}
{% endif %}
</div>
</div>


Loading…
Cancel
Save