* squashed: Change Admin based OTP reset to role based reset (System Manager)
* fix: show `Reset OTP Secret` button only if applicable
* chore: flatten code, use `only_for` API
Co-authored-by: Leonard Goertz <leonard.goertz@noventive.com>
Co-authored-by: Sagar Vora <sagar@resilient.tech>
User Mention cache is deleted on 3 occasions:
* when a new user is inserted
* when allowed_in_mention or user_type value has changed
* when a user is deleted
But we didn't delete it when a user was enabled or disabled as we maintain the mention cache for enabled users
* chore: warn about missing scheduler / doc events
* fix: pass list instead of filter
filter can only be iterated upon once
* refactor: many typehints in __init__.py
refactor: clean up code to py39+ supported syntax
- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes
Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
When you create a Virtual DocType as a Child Table (which is possible without any warning), then it will lead to several errors when updating or deleting of the parent document.
This is because the following files just execute a SQL Statement for the doctype (which doesnt have a DB Table, as this is the nature of a virtual doctype ;-)
**apps/frappe/frappe/model/document.py**
```py
frappe.db.sql("""delete from `tab{0}` where parent=%s and parenttype=%s and parentfield=%s""".format(df.options), (self.name, self.doctype, fieldname))
```
**apps/frappe/frappe/model/delete_doc.py**
```py
frappe.db.sql(
"delete from `tab%s` where parenttype=%s and parent = %s" % (t, "%s", "%s"), (doctype, name)
)
```
So at these points, I added a check to not perform any sql command for virtual doctypes. With these changes, my affected situation is solved. Perhaps there are other situations, I didn't encounter yet.
As an additional feature, those virtual doctype models should also get an information about the parent is deleted, to propagate the deletion to the remote data pools; but for now I hope this bugfix can be approved.
If some sites have long pending old data that doesn't get cleared
automcatically then this patch now attempts to discard old data by using
"big-delete" code instead of typical delete query.
We have hardcoded "Log settings" to only apply on 3 doctypes, there are
few more logging doctypes in core which are not cleared right now, on
top of that it's not easy for user to configure all logging behaviour
from one place.
This change adds a table on log settings where logging doctypes that
support the interface required by log settings can auto-register and
show up in settings.
Currently only supported configuration is "number of days" to keep.