Commit graph

1936 commits

Author SHA1 Message Date
Pēteris Caune
7e503d9c33
Move the "join Matrix room" code to hc.lib.matrix 2023-10-23 09:32:03 +03:00
Pēteris Caune
1004ca776a
Switch to using Pydantic for validating Matrix join responses 2023-10-23 08:53:15 +03:00
Pēteris Caune
cf552c86cb
Switch to using Pydantic for validating Pushbullet OAuth responses 2023-10-23 08:52:31 +03:00
Pēteris Caune
06328dbecf
Fix mypy warning 2023-10-22 16:57:02 +03:00
Pēteris Caune
5911075282
Fix HTTP verb in hc.lib.curl.post 2023-10-22 12:38:44 +03:00
Pēteris Caune
7e7cbe9f75
Fix the Login form to not perform form validation in GET requests 2023-10-22 10:45:06 +03:00
Pēteris Caune
30a3a784c3
Move AuthenticatedHttpRequest to hc.accounts.http module
If AuthenticatedHttpRequest lives in the hc.lib.typealias
module then hc.lib.typealias imports User and Profile,
and so needs configured Django settings. Most of the stuff
in hc.lib is intended to work standalone, and not rely on Django.
2023-10-21 18:16:48 +03:00
Pēteris Caune
0971051418
Refactor Webhook transport 2023-10-21 18:04:27 +03:00
Pēteris Caune
2d447d5bc8
Enable mock autospeccing in more places 2023-10-21 11:55:30 +03:00
Pēteris Caune
470f70b164
Update curl.get and curl.post to closer match requests fn signatures
In requests, "params" is a positional argument for the get function:

    requests.get(url, params=None, **kwargs)

So I made params positional here too.

In requests, "data" is a positional argument for the post function:

    requests.post(url, data=None, json=None, **kwargs)

So I data positional here too.
2023-10-21 11:45:45 +03:00
Pēteris Caune
7c7774d18c
Replace **kwargs with explicit keyword arguments in hc.lib.curl
This makes the code more verbose, but at the same time
makes type hinting cleaner, and allows mock autospeccing
to catch more problems.
2023-10-21 11:21:42 +03:00
Pēteris Caune
4226ec4059
Remove unnecessary type conversion 2023-10-20 19:14:44 +03:00
Pēteris Caune
52ab8c4703
Improve type hints in hc.lib.curl and hc.api.transports
This results in changes in other places too:

* curl.post() does not accept `data` as positional arg,
  it must now be a keyword argument
* we need asserts and if clauses in a few places to make sure
  we are not passing `None` in the arguments to hc.lib.curl.request
2023-10-20 19:11:08 +03:00
Pēteris Caune
33a0f65144
Improve type hints in hc.api.decorators 2023-10-20 18:41:11 +03:00
Pēteris Caune
a308997b3a
Remove most of the hc.payments stuff
Why remove:

* For self-hosters, payment-related features are unused and dead weight
* For SaaS (any would-be Healthchecks.io competitors), the existing
  payment handling logic is not very useful either, as it would need to
  be heavily modified to match their business model, pricing, chosen
  payment gateway
* For the hosted service (Healthchecks.io), the up-to-date billing code
  lives in a private fork of this repo. Maintenance is easier if this
  repo does not have an older, diverging version of the same
  functionality

A few payment-related bits are staying at least for time being:

* the "USE_PAYMENTS" setting
* the hc.payments.models.Subscription model
* tiny stubs for the "Pricing" and "Billing" pages

They are used in various places in the code and templates,
and I think ripping them out in one go would be too disruptive.
2023-10-19 14:17:44 +03:00
Pēteris Caune
fa2e456353
Fix mypy warning 2023-10-19 10:56:59 +03:00
Pēteris Caune
fdfe03158d
Fix mypy warnings 2023-10-18 16:33:15 +03:00
Pēteris Caune
1aec03dfc6
Improve type hints in management commands 2023-10-18 16:15:01 +03:00
Pēteris Caune
e8be347d1a
Improve type hints in management commands 2023-10-18 13:47:02 +03:00
Pēteris Caune
ce622da6bd
Improve type hints and remove threading support which was unused
sendalerts had support for sending notifications
synchronously (with the --no-threads flag) and asynchronously using
threads (the default).

It turns out there was a bug in argument handling and sendalerts
was always using the synchronous mode regardless of the
presence/absence of the "--no-threads" flag. Since noone seems to
have noticed, I removed the unused async code.
2023-10-18 13:45:23 +03:00
Pēteris Caune
286b8a5a3b
Improve type hints in hc.front.templatetags.hc_extras 2023-10-18 10:08:29 +03:00
Pēteris Caune
3d5850d2da
Improve type hints, use pydantic for parsing Zulip configurations 2023-10-17 16:58:57 +03:00
Pēteris Caune
bb7632f467
Fix mypy warning 2023-10-17 16:15:37 +03:00
Pēteris Caune
42a137e128
Switch to pydantic for validating Telegram incoming webhooks 2023-10-17 16:10:35 +03:00
Pēteris Caune
86eb2e43e5
Make the "notification" parameter non-optional in Transport.notify()
Its signature was "notification: Notification | None = None".

But callers always specify it, the default value is never used.

So I changed the signature to "notification: Notification".
2023-10-17 14:56:54 +03:00
Pēteris Caune
02888e6db9
Fix sending test notification to a group integration 2023-10-17 11:37:12 +03:00
Pēteris Caune
37caa94ff5
Improve channel rendering in the group form
* Use the custom-styled checkbox
* Use PNG instead of icon font for channel kind logos
* Show channel's description the same way as in the channels list
  (using a reusable template, templates/front/channel_description.html)
2023-10-12 14:37:00 +03:00
Pēteris Caune
7b03e1f95b
Fix mypy warning 2023-10-12 11:55:47 +03:00
Pēteris Caune
2276fcff60
Rename my_checks -> checks; my_checks_desktop -> checks_table 2023-10-12 11:48:42 +03:00
Pēteris Caune
12114c647e
Fix channel sorting in the "my checks" page to show groups first 2023-10-12 11:43:20 +03:00
Pēteris Caune
51b9bf7ca1
Add testcases for "Add group" and "Edit group" forms 2023-10-07 10:59:57 +03:00
Pēteris Caune
e537a38dd8
Temporarily remove type hints for the view_on_site method 2023-10-06 20:02:00 +03:00
Pēteris Caune
93fcc79926
Improve tests, fix the handling of "no-op" errors 2023-10-06 19:51:08 +03:00
Florian Apolloner
ca10841503
Fix mypy warnings in hc.font.views (#904) 2023-10-06 17:39:20 +03:00
Pēteris Caune
4fc6ff5c26
Tweak CSS in the group form, make sure channel's name is preloaded 2023-10-06 17:06:41 +03:00
Florian Apolloner
7057f6d3a5
Notification groups. Fixes #894 (#901)
* MVP for notification groups.

* Addressed review comments.

* Push notification group to the front.

* Updated icons.

* Reduce code duplication.

* Show groups at the top.

* Add label to group forms.

* Add checkboxes for integration selection.

* CSS for checkboxes.

* Added tests for group notify.
2023-10-06 17:02:41 +03:00
Pēteris Caune
24bad5af52
Tighten type hints in hc.api.admin 2023-10-06 15:33:10 +03:00
Pēteris Caune
fa9db53631
Update admin to use format_html instead of string interpolation 2023-10-06 13:54:15 +03:00
Pēteris Caune
f68b2c01a6
Simplify the counting of updated objects in admin actions 2023-10-06 11:35:32 +03:00
Pēteris Caune
7b1258ceaa
Improve type hints in accounts admin, fix HTML escaping issue
In Project admin, when listing project members, for single-member
projects the owner's email address was being displayed
unescaped. This allowed unescaped amperstand and quote characters
to appear in HTML output.
2023-10-05 16:04:21 +03:00
Pēteris Caune
97830deb29
Improve type hints in test_notify_signal 2023-10-05 15:55:41 +03:00
Pēteris Caune
fd87cad455
Remove unused imports 2023-10-05 12:44:40 +03:00
Pēteris Caune
8fb7d16864
Improve type hints, simplify pagination in Ping admin
Pagination, filtering, and result counting in Ping admin is tricky
as the pings table can contain millions of rows.

We previously used "select reltuples from pg_class" trick to
estimate the total number of rows. This only works on Postgres,
and does not handle WHERE filters.

This commit removes the search box, and changes the pagination
template to allow pagination between pages 1-9 and nothing more.
2023-10-04 16:00:41 +03:00
Pēteris Caune
5d99c544ee
Increase the precision in hc.lib.date.format_approx_duration
Format durations in one of the following forms:

* "{x} days {y} h"
* "{y} h {z} min"
* "{z} min {w} sec"
2023-10-02 12:50:59 +03:00
Pēteris Caune
d40ce1eaac
Rename DowntimeSummary -> DowntimeRecorder 2023-09-28 09:02:13 +03:00
Pēteris Caune
95b92a9b3b
Fix type warning 2023-09-27 17:47:25 +03:00
Pēteris Caune
2a0ae809a7
Add DowntimeRecord.no_data field 2023-09-27 17:43:18 +03:00
Pēteris Caune
58d7c8cc55
Simplify DowntimeSummary 2023-09-27 17:16:16 +03:00
Pēteris Caune
f7af738c76
Add monthly uptime percentage display in Check Details page
Fixes: #773
2023-09-27 13:44:35 +03:00
Pēteris Caune
db5d8adeb5
Switch from namedtuple to dataclass for mutability 2023-09-27 11:03:58 +03:00