Commit graph

14 commits

Author SHA1 Message Date
Vadim Stepanov
b2f4ffb98a
apps.get_model -> import (#2619)
# What this PR does

Remove
[`apps.get_model`](https://docs.djangoproject.com/en/3.2/ref/applications/#django.apps.apps.get_model)
invocations and use inline `import` statements in places where models
are imported within functions/methods to avoid circular imports.

I believe `import` statements are more appropriate for most use cases as
they allow for better static code analysis & formatting, and solve the
issue of circular imports without being unnecessarily dynamic as
`apps.get_model`. With `import` statements, it's possible to:

- Jump to model definitions in most IDEs
- Automatically sort inline imports with `isort`
- Find import errors faster/easier (most IDEs highlight broken imports)
- Have more consistency across regular & inline imports when importing
models

This PR also adds a flake8 rule to ban imports of `django.apps.apps`, so
it's harder to use `apps.get_model` by mistake (it's possible to ignore
this rule by using `# noqa: I251`). The rule is not enforced on
directories with migration files, because `apps.get_model` is often used
to get a historical state of a model, which is useful when writing
migrations ([see this SO answer for more
details](https://stackoverflow.com/a/37769213)). So `apps.get_model` is
considered OK in migrations (even necessary in some cases).

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-07-25 09:43:23 +00:00
Matias Bordese
f0f49694a5
Reworked slack login pipeline errors (#2526)
Related to https://github.com/grafana/oncall/issues/313

---------

Co-authored-by: Yulia Shanyrova <yulia.shanyrova@grafana.com>
2023-07-18 13:31:11 +00:00
dimitar-ivanov-93
ef258f5f56
Social auth exception logging (#2041)
This will vastly improve troubleshooting when an unexpected error
occurs.

# What this PR does
Enables logging of the exception that might be thrown by
SocialAuthExceptionMiddleware. It vastly improves the speed and accuracy
of troubleshooting requests to external applications with the aim to
authenticate, since there is usually no response to look at.
## Which issue(s) this PR fixes
Closes [#2035](https://github.com/grafana/oncall/issues/2035)
## Checklist

- [ ] Unit, integration, and e2e (if applicable) tests updated
- [ ] Documentation added (or `pr:no public docs` PR label added if not
required)
- [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)

---------

Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
2023-06-02 11:20:54 +00:00
Innokentii Konstantinov
c68fdf5681
Fix insight_logs exceptions (#1757)
Most of the PR is just renaming ChatOpsType to ChatOpsPlug, core changes
are linked below:

- Fix insight_logs error writing unlink_backend error
https://github.com/grafana/oncall/pull/1757/files#diff-7ae187be84e55ebac962bad0984f7569186cdc83c896132b2ebcbcbb31bbf5dd
- Fix insight_logs error writing updated schedule with installed slack
integration
(https://github.com/grafana/oncall/pull/1757/files#diff-4037b7bbef9fc16d9b541beb3ed46f760916d7cd720847c3123adf7afb5ab4b4L690)
2023-04-17 07:16:18 +00:00
Innokentii Konstantinov
12b9a8e0d2
Slack team connector v2 (#1581)
# What this PR does
Support Slack team connector v2 introduced
[here](https://github.com/grafana/oncall-gateway/pull/24)
2023-03-28 03:27:45 +00:00
Matias Bordese
a121f84a89
Rework slack login to check backend before redirecting (#1306)
Also:
- Remove unused slack login views in `social_auth` app
- Disable unlink actions in the profile if user is not owner (otherwise
it will disconnect the logged in user, not the one being shown on
screen)
2023-02-08 09:08:18 -03:00
Innokentii Konstantinov
9c550af721
Support of oncall-gw (#741)
* Draft support of oncall-gw

* Clean up

* Create oncall connector on org create in gcom

* Naming fixes

* Rework oncall-gateway package. \nMove it from apps.

* Fix typo
2022-11-08 14:43:22 +08:00
Innokentii Konstantinov
434fe17617
user_id -> linked_user_id (#410) 2022-08-25 13:34:19 +05:00
Innokentii Konstantinov
4765c9b07c
Insight logs (#348)
* Entity events insight logs

* Insight logging

* Fix event for updating templates

* Format fixes

* Remove organization_log_type.py

* Simplify signature of chatops_insight_log

* insight logs formatting

* Add possibility to enable all insight logging via DynamicSetting

* Fixes

* Style fixes

* Add migration

* Fix migration
2022-08-24 12:04:44 +05:00
Andrew Grangaard
07b41fdfa8
Fix spelling of "lose" (#346) 2022-08-09 15:56:07 +03:00
Vadim Stepanov
8b553ce735
Validate Slack and Telegram host env variables (#307)
* Validate Slack and Telegram host env variables

* remove ImproperlyConfigured usage, improve Telegram creds handling

* update TELEGRAM_WEBHOOK_HOST description
2022-08-02 12:57:12 +03:00
Michael Derynck
ff57775368
Change slack URL to be built the same as other engine URLs (#280)
* Change slack login url to be built the same way as other engine urls

* Fix tests

* Change how to override base url in create_engine_url

* Change how to override base url in create_engine_url
2022-07-22 10:02:00 -06:00
Matvey Kukuy
34e94ce823 Slack polishing & docs 2022-06-13 15:33:56 +03:00
Michael Derynck
6b40f95033 World, meet OnCall!
Co-authored-by: Eve832 <eve.meelan@grafana.com>
    Co-authored-by: Francisco Montes de Oca <nevermind89x@gmail.com>
    Co-authored-by: Ildar Iskhakov <ildar.iskhakov@grafana.com>
    Co-authored-by: Innokentii Konstantinov <innokenty.konstantinov@grafana.com>
    Co-authored-by: Julia <ferril.darkdiver@gmail.com>
    Co-authored-by: maskin25 <kengurek@gmail.com>
    Co-authored-by: Matias Bordese <mbordese@gmail.com>
    Co-authored-by: Matvey Kukuy <motakuk@gmail.com>
    Co-authored-by: Michael Derynck <michael.derynck@grafana.com>
    Co-authored-by: Richard Hartmann <richih@richih.org>
    Co-authored-by: Robby Milo <robbymilo@fastmail.com>
    Co-authored-by: Timur Olzhabayev <timur.olzhabayev@grafana.com>
    Co-authored-by: Vadim Stepanov <vadimkerr@gmail.com>
    Co-authored-by: Yulia Shanyrova <yulia.shanyrova@grafana.com>
2022-06-03 08:09:47 -06:00