Commit graph

453 commits

Author SHA1 Message Date
Pēteris Caune
45b8bd64df
Simplify hosting under subpath
Instead of using SCRIPT_NAME / FORCE_SCRIPT_NAME, PATH_INFO
and their associated issues, update urls.py to add the subpath
to all routes. This allows us to get rid of several hacks:

* the uwsgi.ini magic which parses SITE_ROOT, sets SCRIPT_NAME
  and fixes PATH_INFO
* set_script_prefix() in sendalerts
* chopping the subpath off an URL in hc.accounts.views._allow_redirect

The idea comes from @apollo13
in https://code.djangoproject.com/ticket/35985#comment:5

cc: #1091
2024-12-19 09:04:45 +02:00
Pēteris Caune
a2c7259d1b
Fix redirects after login when using a path in SITE_ROOT
Fixes: #382

cc: #1091
2024-12-09 12:35:02 +02:00
Pēteris Caune
22268c1484
Move absolute URL construction to hc.lib.urls.absolute_reverse()
absolute_reverse() works the same as django.urls.reverse()
except it generates absolute URLs (starting with http[s]://)
2024-12-03 17:24:27 +02:00
Pēteris Caune
79da9e9f4f
Fix auto-fixable ruff warnings
(`ruff check --fix`)
2024-11-07 15:15:58 +02:00
Pēteris Caune
4907073c55
Remove unneeded quotes 2024-11-06 19:32:44 +02:00
Pēteris Caune
e048ec4c48
Fix "class Foo(object):" -> "class Foo:"
In Python 3 these are equivalent, and shorter is better.
2024-10-29 17:57:50 +02:00
Pēteris Caune
e3cbe79f57
Update CustomHeaderMiddleware to normalize email addresses to lower case
Also add a data migration to normalize any already existing user
accounts with non-lower-case email addresses too.

Fixes: #1074
2024-10-24 13:22:37 +03:00
Pēteris Caune
fd96cc794b
Remove unused bits 2024-10-04 17:34:30 +03:00
Pēteris Caune
12cccaf7d1
Fix Project.num_checks naming collision
The Project model has (well, had) a num_checks() method.
In the project admin we are also annotating project queryset
with a "num_checks" property. Using the same name for two different
things causes type confusion for mypy and can also lead to
coding accidents.

This commit removes the Project.num_checks() method. This was easier
to do than changing admin, as the method is very simple and was used
in only two places.
2024-09-24 10:18:22 +03:00
Pēteris Caune
b859a71920
Rename "sign in" to "log in"
I like "sign in" better, but users from time
to time confuse "sign in" and "sign up" forms. To reduce
confusion potential, I'm renaming "sign in" to "log in".
2024-08-12 15:09:58 +03:00
Pēteris Caune
f7876f67d7
Remove unused code 2024-08-07 17:38:43 +03:00
Pēteris Caune
ba8a58a8a7
Fix type annotation 2024-07-29 09:57:28 +03:00
Pēteris Caune
410b56baef
Fix type hints for django-stubs 5.0.1 2024-05-27 14:35:32 +03:00
Pēteris Caune
1bdfbac775
Fix Sign In page to hide "Email Link" option if SMTP is not configured
Fixes: #922
2024-05-10 11:04:21 +03:00
Pēteris Caune
602ff2b667
Fix senddeletionscheduled to set the "created" field on flip objects
The "senddeletionscheduled" management command creates dummy
Flip objects, but does not save them to the database.
Some transport classes expect the flip object to have a non-null
"created" field. Normally it gets set when saving the flip object
to the database, here we need to do that manually.
2024-04-22 09:21:46 +03:00
Pēteris Caune
a4d2094cef
Update the remove_project view to delete checks using lock_and_delete()
If we delete project by naively calling project.delete() then checks
can receive pings during the deletion, causing the deletion operation
to fail with an IntegrityError.

So instead do it like so:

* iterate over project's checks, call Check.lock_and_delete() on each
* in the end, call project.delete()
2024-04-16 16:36:49 +03:00
moraj-turing
3718ff57c7
Add support for system theme (#987)
Add support for system theme

---------

Co-authored-by: Juan Mora <juan@nimble.gt>
Co-authored-by: Pēteris Caune <cuu508@gmail.com>
2024-04-15 10:42:16 +03:00
Pēteris Caune
28fdfd1362
Change Channel.notify() signature to take Flip object as an argument
... and pass it to Transport.notify_flip().

This allows us to pass flip-specific information (the flip timestamp,
the new status) to transport classes.
2024-04-12 13:54:16 +03:00
Pēteris Caune
33e58fa014
Change the signup flow to accept registered users
(and sign them in instead)
2024-03-15 17:30:06 +02:00
Pēteris Caune
ce1d7bd4cb
Add a test for #930 2023-12-18 15:58:04 +02:00
Marlene Koh
2b318cab84
Fix crash when email host not configured (#930)
* Log exception when email host not configured instead of raising assertion error

* Fix tests

* Reset to master

* Check email host before sending email for project invites
2023-12-18 15:53:35 +02:00
Pēteris Caune
96823a7f90
Add logging for failed webauthn key registrations 2023-11-17 16:06:39 +02:00
Pēteris Caune
6872ab3eb6
Improve type hints in hc.accounts.backends 2023-10-26 09:31:11 +03:00
Pēteris Caune
8a42d2b66b
Add type hints in hc.accounts.middleware 2023-10-26 09:16:18 +03:00
Pēteris Caune
343e55bd4f
Improve type hints 2023-10-25 18:12:12 +03:00
Pēteris Caune
06328dbecf
Fix mypy warning 2023-10-22 16:57:02 +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
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
e8be347d1a
Improve type hints in management commands 2023-10-18 13:47:02 +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
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
Pēteris Caune
46dbaff2c3
Update Check.downtimes() to return records in descending datetime order
This way we can avoid one sort operation in Check.downtimes()
and one reverse operation in the "details_downtimes.html" template.
2023-09-27 10:42:05 +03:00
Pēteris Caune
dcf9f327f6
Add Channel.email property
It replaces:

* Channel.email_value
* Channel.email_notify_up
* Channel.email_notify_down
2023-09-11 11:45:25 +03:00
Pēteris Caune
a6ab647a46
Improve type hints in hc.accounts.models 2023-09-08 15:54:47 +03:00
Pēteris Caune
05d2d0065e
Remove usage of backports.zoneinfo 2023-09-06 12:54:27 +03:00
Pēteris Caune
77e1ea731c
Improve type hints in hc.accounts.views 2023-09-06 12:51:27 +03:00
Pēteris Caune
d79069f669
Fix type warnings, improve type hints in hc.front.views 2023-09-06 11:18:47 +03:00
Pēteris Caune
e9ac841d01
Move reusable type aliases to hc.lib.typealias 2023-09-06 10:52:47 +03:00
Pēteris Caune
65b3acf964
Improve type hints in hc.accounts.views 2023-09-06 10:02:50 +03:00
Pēteris Caune
0c83ca4fd8
Improve type hints in hc.accounts.forms 2023-09-05 18:31:35 +03:00
Pēteris Caune
9153c1a552
Improve type hints 2023-09-05 13:31:59 +03:00
Pēteris Caune
2901f03146
Fix type warnings 2023-09-03 09:04:38 +03:00
Pēteris Caune
23eadc5e64
Fix type warnings 2023-09-02 17:19:31 +03:00
Pēteris Caune
3311712610
Improve type hints, add reusable JSON type aliases in hc.lib.typealias 2023-08-31 12:17:15 +03:00
Pēteris Caune
aaa172cd28
Improve type hints 2023-08-29 17:52:20 +03:00