zulip/tools/linter_lib
Mateusz Mandera 586a5facc9 models: Add is_realm_admin and is_guest setters.
Fixes #13452.

The migration from UserProfile.is_realm_admin/UserProfile.is_guest in
e10361a832 broke our LDAP-based support
for setting a user's role via LDAP properties, which relied on setting
those fields.  Because the django-auth-ldap feature powering that only
supports booleans (and in any case, we don't want to expose constants
like `ROLE_REALM_ADMINISTRATOR` to the LDAP configuration interface),
it makes sense to provide setters for these legacy fields for
backwards-compatibility.

We lint against using these setters directly in Zulip's codebase
directly.  The issue with using these is that when changing user's
.role we want to create appropriate RealmAuditLog entries and send
events. This isn't possible when using these setters - the log entries
and events should be created if the role change in the UserProfile is
actually save()-ed to the database - and on the level of the setter
function, it's not known whether the change will indeed be saved.

It would have to be somehow figured out on the level of post_save
signal handlers, but it doesn't seem like a good design to have such
complexity there, for the sake of setters that generally shouldn't be
used anyway - because we prefer the do_change_is_* functions.

The purpose of this change is narrowly to handle use cases like the
setattr on these boolean properties.
2019-12-09 11:54:01 -08:00
..
__init__.py Extract tools/linter_lib/custom_check.py. 2017-06-05 09:20:21 -07:00
custom_check.py models: Add is_realm_admin and is_guest setters. 2019-12-09 11:54:01 -08:00
exclude.py tools: Fix running check-openapi locally. 2019-08-07 14:18:27 -07:00
pep8.py tools: Remove unused imports. 2019-02-02 17:10:31 -08:00
pyflakes.py linter_lib: Fix mypy errors. 2019-08-09 17:22:45 -07:00