Browse Source

Project code in URL for the "Add Pagerteam" page. cc: #336

pull/340/head
Pēteris Caune 5 years ago
parent
commit
0ea2369dc0
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
5 changed files with 13 additions and 9 deletions
  1. +4
    -2
      hc/front/tests/test_add_pagerteam.py
  2. +1
    -1
      hc/front/urls.py
  3. +6
    -4
      hc/front/views.py
  4. +1
    -1
      templates/front/channels.html
  5. +1
    -1
      templates/integrations/add_pagerteam.html

+ 4
- 2
hc/front/tests/test_add_pagerteam.py View File

@ -3,7 +3,9 @@ from hc.test import BaseTestCase
class AddPagerTeamTestCase(BaseTestCase):
url = "/integrations/add_pagerteam/"
def setUp(self):
super(AddPagerTeamTestCase, self).setUp()
self.url = "/projects/%s/add_pagerteam/" % self.project.code
def test_instructions_work(self):
self.client.login(username="[email protected]", password="password")
@ -15,7 +17,7 @@ class AddPagerTeamTestCase(BaseTestCase):
self.client.login(username="[email protected]", password="password")
r = self.client.post(self.url, form)
self.assertRedirects(r, "/integrations/")
self.assertRedirects(r, self.channels_url)
c = Channel.objects.get()
self.assertEqual(c.kind, "pagerteam")


+ 1
- 1
hc/front/urls.py View File

@ -29,7 +29,6 @@ channel_urls = [
path("add_pdc/", views.add_pdc, name="hc-add-pdc"),
path("add_pdc/<str:state>/", views.add_pdc, name="hc-add-pdc-state"),
path("add_pagertree/", views.add_pagertree, name="hc-add-pagertree"),
path("add_pagerteam/", views.add_pagerteam, name="hc-add-pagerteam"),
path("add_slack/", views.add_slack, name="hc-add-slack"),
path("add_slack_btn/", views.add_slack_btn, name="hc-add-slack-btn"),
path("add_pushbullet/", views.add_pushbullet, name="hc-add-pushbullet"),
@ -64,6 +63,7 @@ project_urls = [
path("add_mattermost/", views.add_mattermost, name="hc-add-mattermost"),
path("add_msteams/", views.add_msteams, name="hc-add-msteams"),
path("add_opsgenie/", views.add_opsgenie, name="hc-add-opsgenie"),
path("add_pagerteam/", views.add_pagerteam, name="hc-add-pagerteam"),
path("add_webhook/", views.add_webhook, name="hc-add-webhook"),
path("badges/", views.badges, name="hc-badges"),
path("checks/", views.my_checks, name="hc-checks"),


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

@ -995,20 +995,22 @@ def add_pagertree(request):
@login_required
def add_pagerteam(request):
def add_pagerteam(request, code):
project = _get_project_for_user(request, code)
if request.method == "POST":
form = AddUrlForm(request.POST)
if form.is_valid():
channel = Channel(project=request.project, kind="pagerteam")
channel = Channel(project=project, kind="pagerteam")
channel.value = form.cleaned_data["value"]
channel.save()
channel.assign_all_checks()
return redirect("hc-channels")
return redirect("hc-p-channels", project.code)
else:
form = AddUrlForm()
ctx = {"page": "channels", "project": request.project, "form": form}
ctx = {"page": "channels", "project": project, "form": form}
return render(request, "integrations/add_pagerteam.html", ctx)


+ 1
- 1
templates/front/channels.html View File

@ -278,7 +278,7 @@
<h2>Pager Team</h2>
<p>On-call rotations without limits.</p>
<a href="{% url 'hc-add-pagerteam' %}" class="btn btn-primary">Add Integration</a>
<a href="{% url 'hc-add-pagerteam' project.code %}" class="btn btn-primary">Add Integration</a>
</li>
<li>


+ 1
- 1
templates/integrations/add_pagerteam.html View File

@ -40,7 +40,7 @@
<h2>Integration Settings</h2>
<form method="post" class="form-horizontal" action="{% url 'hc-add-pagerteam' %}">
<form method="post" class="form-horizontal">
{% csrf_token %}
<div class="form-group {{ form.value.css_classes }}">
<label for="post-url" class="col-sm-2 control-label">URL</label>


Loading…
Cancel
Save