Commit Graph

36947 Commits

Author SHA1 Message Date
Anders Kaseorg 6480deaf27 python: Convert more "".format to Python 3.6 f-strings.
Generated by pyupgrade --py36-plus --keep-percent-format, with more
restrictions patched out.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-10 14:48:09 -07:00
Hemanth V. Alluri 7b2255597c outgoing-webhook: Fix check for empty content.
Prevent `JsonableError(_("Missing content"))` from
ever being triggered.

That error wasn't handle by anything, and thus just threw a 500, as
it's not a response to an HTTP request.

The right fix is to adjust the caller to ban the empty string in
content (or content that strips to the empty string).

Closes #15145.
2020-06-10 14:46:04 -07:00
Dinesh 0c45e0118f tests: Clear remove/remock approach for ACCESS_TOKEN_URL endpoint.
ACCESS_TOKEN_URL works a different for apple authentication, so,
we removed and remocked the ACCESS_TOKEN_URL mock in
`register_extra_endpoints` override of apple auth test class.
It is cleaner to have it as generic feature of `social_auth_test`.

So, this commit adds a function that returns token_data_dict that
we had earlier and is called in the ACCESS_TOKEN_URL mock.
This function is overriden in apple auth test class to generate
payload of the format that apple auth expects.

Thanks to Mateusz Mandera for the simple idea.

Co-authored-by: Mateusz Mandera <mateusz.mandera@zulip.com>
2020-06-10 14:38:49 -07:00
Tim Abbott 5fd7b519b7 templates: Add missing include file for owner-only.md. 2020-06-10 14:35:18 -07:00
YashRE42 4f6377d493 navbar: Correctly recolor navbar icon when stream is renamed.
Previously, renaming the stream would cause `colorize_tab_bar` to fail
because the search filter would provide it the old stream name and the
look up for the stream color would fail.

A quirk of how this system currently works makes it so that even
though the filter is set to the old stream name (and so becomes
inconsistent with the stream_data state) the `_stream_params` object
is maintained to be consistent with stream_data and as such can be
relied upon to find the correct color of the icon.
2020-06-10 14:25:18 -07:00
YashRE42 e389129f34 subs: Call `filter.fix_stream_params` when updating stream name.
Previously the navbar did not live update the stream name correctly.

The correct behaviour was blocked on the `_stream_name` prop on the
filter object. The original purpose for maintaining this prop was
convenience, to reduce calls to `subs`, however, it would become
inconsistent with the value from `subs` on stream rename.

In this commit we add a call to `filter.fix_stream_params` in
`subs.update_stream_name`. This fixes live rerendering in the navbar,
despite the fact that searchbox in the nav (and the filter object via
`filter.operands("stream")[0]`) will still have the old name.

This is a slightly hacky way of masking some of the problems in the
Filter object. However, it should make do until we migrate to a stream
ID based state there.

Fixes: #14728.
2020-06-10 14:25:18 -07:00
YashRE42 96e272081d navbar: Add globe icon to navbar for web public streams.
Prior to this commit, the navbar didn't display web public streams as
any different from ordinary streams.

Now, we show a globe icon for web public streams. This commit also
adds a node test for the same.

We also modified the navbar behaviour table, which is the following
dropbox paper:
https://paper.dropbox.com/doc/Navbar-behavior-table--A0sp57z~7R5PeHuxHL__Gn5ZAg-cNOGtu7kSdtnKBizKXJge
2020-06-10 14:25:18 -07:00
YashRE42 bb6ce47c33 navbar: Live update icon for stream privacy changes.
Prior to this commit the icon in the navbar didn't live update to
reflect changes in stream privacy.

Here, we add a call to `tab_bar.render_title_area` in
`subs.update_stream_privacy()`, to enable live updates on the icon.

Fixes #14728.
2020-06-10 14:25:18 -07:00
YashRE42 d496304caa subs: Call `filter.fix_stream_params` when updating stream privacy.
The navbar currently does not live update the stream icon correctly
for changes in stream privacy.

One place where the correct behaviour gets blocked is on the
`_is_stream_private` prop in the filter object. We keep props such as
this for convenience, to reduce calls to `subs`, however, this prop
becomes inconsistent with the value we get from `subs` when the stream
privacy is updated.

In this commit we add a call to `filter.fix_stream_params` in
`subs.update_stream_privacy`. This change does not fix the live
rerendering in the navbar because we don't call redraw yet, but
it's a prep commit to towards that goal
2020-06-10 14:25:18 -07:00
YashRE42 35c8dcb599 filter: Extract `get_stream_params` and `fix_stream_params`.
The navbar currently does not live update the stream name or the icon
for stream privacy correctly.

One place where the correct behaviour gets blocked is on the
`_stream_name` and `_is_stream_private` props on the filter object.
We keep these props for convenience, to reduce calls to `subs`,
however, these props become inconsistent with the values from `subs`
when the stream is renamed or stream privacy is changed.

This refactor extracts out `get_stream_params` and `fix_stream_params`
methods as a prep commit towards correcting the problem, but does not
make any behavioural changes.

This is a prep commit for solving #14728.
2020-06-10 14:25:18 -07:00
YashRE42 b292c30d6a subs: Move comment about live update for stream names in navbar.
A comment about the difficulties relating to live updating stream
names in the navbar was incorrectly placed within the function for
live updating stream descriptions in
023187b3f1.

This moves the comment to the right place.
2020-06-10 14:25:18 -07:00
Tim Abbott f0d8f60b66 help: Add basic documentation of organization owners. 2020-06-10 14:07:46 -07:00
Tim Abbott 94d0c330e4 management: Display organization owners in show_admins. 2020-06-10 14:07:38 -07:00
sahil839 22a188f12e migration: Add migration to set all realm admins as realm owners.
This migration is added to set all the realm admins as realm owners
and also creates RealmAuditLog entries for modified users.
2020-06-10 14:07:38 -07:00
sahil839 5cc937f670 events: Add 'is_owner' to page_params and raw_users dict of page_params.
This commit adds 'is_owner' field to page_params and also to the
raw_users dict of page_params.
2020-06-10 14:07:38 -07:00
sahil839 6d667dbe53 realm owner: Add ability to change realm owner status of user.
This commit adds some basic checks while adding or removing
realm owner status of a user and adds code to change owner
status of a user using update_user_backend.

This also adds restriction on removing owner status of the
last owner of realm. This restriction was previously on
revoking admin status, but as we have added a more privileged
role of realm owner, we now have this restriction on owner
instead of admin.

We need to apply that restriction both in the role change code path
and the deactivate code path.
2020-06-10 12:49:37 -07:00
sahil839 2c8c641556 realm owner: Make first user as realm owner on realm creation.
This commit sets the role of the user creating the realm as
realm owner after the realm is created.

Previously, the role of user creating the realm was set as admin.
But now we want it to be owner because owners have the highest
privilege level.
2020-06-10 12:44:52 -07:00
Clara Dantas 451ea753a2 settings_users: Simplify get_item function. 2020-06-10 12:14:58 -07:00
Tim Abbott 6f159ce5c5 templates: Clean up wording around topic moves.
This switches us to cleaner, simpler labels for moving topics; while
also avoiding claiming that we're only allowing moving topics to other
streams.
2020-06-10 12:12:17 -07:00
Tim Abbott 26083e4b10 popovers: Improve label for choosing colors. 2020-06-10 09:55:51 -07:00
Aman Agrawal 7585776c76 stream_header: Fix broken header color and outflowing boundary.
The stream header was moved below the selection option and the
boundary selection input was overflowing, both were fixed via
this commit.
2020-06-10 09:50:49 -07:00
Anders Kaseorg 5837560a82 dev_settings: Use Python 2-compatible annotation.
This file is imported from zthumbor.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-10 02:11:55 -07:00
Anders Kaseorg 3de3386c21 Revert "dev_settings: Deduplicate DEPLOY_ROOT definition."
This reverts commit b8acd82b72.
2020-06-10 02:11:00 -07:00
Anders Kaseorg d3e8af4ad2 python: Replace silly uses of filter().
The test_management_commands use in particular was causing pickling
errors when the test failed, because Python 3 filter returns an
iterator, not a list.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 23:31:59 -07:00
Anders Kaseorg 5c9d56d2f7 get_safe_redirect_to: Remove incorrect allowed_hosts setting.
set(redirect_host) is a set of characters, so the only non-relative
redirects being allowed were to certain one-character hostnames, which
certainly isn’t what was intended.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:51:52 -07:00
Anders Kaseorg 3decbd1e23 lint: Remove settings exemption for possibly undefined star imports.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:29:50 -07:00
Anders Kaseorg 3a15e4b51d settings: Extract most of test_settings to test_extra_settings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:29:50 -07:00
Anders Kaseorg 5546762bd9 settings: Extract computed settings to computed_settings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:29:50 -07:00
Anders Kaseorg 826ca3bfdf settings: Move LDAP_DEACTIVATE_NON_MATCHING_USERS default to default_settings.
Tweaked by tabbott to fix an incorrect translation to ONLY_SSO.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:27:55 -07:00
Anders Kaseorg 24d320f245 dev_settings: Move prod_settings_template import to configured_settings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:20:42 -07:00
Anders Kaseorg 34b03dcf8a settings: Move DEBUG default to default_settings.
This is overridden in the prod_settings_template.py generated by
build-release-tarball.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:20:42 -07:00
Anders Kaseorg c45962785c settings: Group {default,prod,dev}_settings as configured_settings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:20:42 -07:00
Anders Kaseorg 18eba18df7 settings: Move bot email defaults to default_settings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:15:34 -07:00
Anders Kaseorg 8ba25960e7 settings: Move NAGIOS_BOT_HOST default to default_settings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:15:34 -07:00
Anders Kaseorg 92a58e9ce0 settings: Move IS_DEV_DROPLET default to default_settings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:15:34 -07:00
Anders Kaseorg 9824405842 dev_settings: Set ZULIP_ADMINISTRATOR.
Fixes this error in the dev environment:

$ ./manage.py checkconfig
Error: You must set ZULIP_ADMINISTRATOR in /etc/zulip/settings.py.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:15:34 -07:00
Anders Kaseorg b8acd82b72 dev_settings: Deduplicate DEPLOY_ROOT definition.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:15:34 -07:00
Anders Kaseorg 59dec63da3 settings: Remove unused slack_importer_test_settings.
Commit 3ebd30120c (#8345) removed the
corresponding test.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:15:34 -07:00
Anders Kaseorg 9cb6a75da5 docs: Fix location of default settings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:15:34 -07:00
Anders Kaseorg a7a207d5d9 docs: Add missing code markers to settings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-09 22:15:34 -07:00
Aman Agrawal 9b9154be91 recent_topics: Set focus on input element on launch. 2020-06-09 22:08:31 -07:00
Aman Agrawal ec00e39e45 recent_topics: Fix misplaced thead border and adjacent css properties. 2020-06-09 22:08:31 -07:00
Aman Agrawal e5e02319b4 recent_topics: Show msg if no topics are visible. 2020-06-09 22:08:31 -07:00
Aman Agrawal ad2e7026c8 recent_topics: Add functionality to sort rows via header.
Add custom sorting for stream and topic headers.
2020-06-09 22:08:31 -07:00
Aman Agrawal 084cbd4ff7 recent_topics: Use list_render to display topic rows.
This fixes the laggy behaviour when there are 2k+ rows to processes,
since list_render uses lazy render based on what rows are visible
to the user.
2020-06-09 22:08:31 -07:00
Aman Agrawal 0aeadd2c86 recent_topics: Set 'unread' and 'participated' as default filters.
Decided after a poll on czo.
2020-06-09 22:08:31 -07:00
Aman Agrawal 33ace41ffe recent_topics: Add filter button to show muted topics.
We don't show muted streams/topics by defualt. Only when user
turns on muted filter.
2020-06-09 22:08:31 -07:00
Aman Agrawal 89fe133d2d recent_topics: Add button to clear search. 2020-06-09 22:08:31 -07:00
Aman Agrawal 9f50825610 recent_topics: Only rerender when recent_topics is visible.
We update the data in the background but only update the view
when recent topics is visible to user.
Also, we always do a complete rerender on launch.
2020-06-09 22:08:31 -07:00
Aman Agrawal e8cc9da4c7 recent_topics: Don't complete_rerender on filter change.
We store the relevant data to hide/show a topic in the row itself,
and use jquery to hide/show it on filter change.

This also fixes search breaking the set filters.
2020-06-09 22:08:31 -07:00