Compare commits

...

3301 Commits

Author SHA1 Message Date
Tim Abbott
7bf16f4bc9 i18n: Update translations from transifex. 2018-04-03 10:20:21 -07:00
sinwar
a66a15a519 requirements: Upgrade pyldap to latest version.
The pyldap fork was merged back into python-ldap, and released as
python-ldap 3.0.0; `pyldap` is now just a wrapper package that depends
on python-ldap.

Fixes #8912.
2018-04-03 09:33:44 -07:00
Abhigyan Khaund
6f15e635d2 hotkeys: Add shortcuts for pan and zoom in lightbox view
This commit adds support for '+' and 'Z' for "zoom in" and '-' and 'z'
for "zoom out" shortcut keys in the lightbox image viewer for Pan and
Zoom.

Fixes: #8689.
2018-04-03 09:20:55 -07:00
novokrest
a613f3c0a1 get_owned_bot_dicts: Optimize admin's bot dicts loading from database.
Implement few optimizations for reading admin's bot dicts from database
for a constants number of requests:
- add models.get_user_profiles_by_ids() for reading bots profiles
  by single query from database
- add models.get_services_for_bots() for reading services for bots
  by single query from database
- add bot_config.get_bot_configs() for reading config data for bots
  by single query from database

Fixes #8838
2018-04-03 09:10:32 -07:00
Tim Abbott
e59c85c382 casper: Fix tests for custom profile fields. 2018-04-03 09:04:03 -07:00
Tim Abbott
4bf6904dca message_live_update: Fix double re-rendering of home_msg_list.
The previous logic incorrectly did current_msg_list plus
home_msg_list, so if one wasn't narrowed, we did all the work twice.
2018-04-02 18:58:51 -07:00
Tim Abbott
ee939f4c1a message_list: Fix unnecessary work re-rendering all_msg_list.
Since all_msg_list is never displayed, there's no reason to do work
re-rendering it in these code paths.
2018-04-02 18:58:51 -07:00
Tim Abbott
2804a8c4f4 message_list: Fix scrolling upwards when users change names.
This fixes a messy bug where users would be randomly scrolled upwards
a large amount whenever a user's name was changed in Zulip.

Fixes #8921.
2018-04-02 18:58:51 -07:00
Tim Abbott
758d7b9146 bots: Clean up editing bots impacting non-bot users.
This fixes a bug where the endpoint for editing bot users would allow
an organization administrator to edit the full name of a bot user.

A combination of this an another recently fixed bug made it possible
for this process to set a `bot_owner` for a non-bot user; so we also
include a migration to fix that for any users that might have had our
model invariants corrupted in that way.
2018-04-02 18:58:26 -07:00
Tim Abbott
3d900a733f settings_users: Fix sending queries to /json/bots endpoint.
Apparently, since 1948cb6a89, we've been
sending requests by an administrator to change a user's name to the
/json/bots endpoint, which would end up changing the "bot owner" of
these objects to some random user.

We fix this by re-splitting the views code.
2018-04-02 18:48:55 -07:00
Tim Abbott
f6a355ec14 user settings: Disable autocomplete for name-change form. 2018-04-02 18:37:16 -07:00
Tim Abbott
938c4cee08 settings: Add option to control Jitsi video chat integration.
Fixes #8922.
2018-04-02 16:55:16 -07:00
Greg Price
e792fc6c07 spelling: Correctly write "cannot".
None of these errors were user-facing; mainly in comments, plus
one bit of internal docs and a developer tool.
2018-04-02 15:36:31 -07:00
Eeshan Garg
026ff48020 webhooks/bitbucket2: Detect pushes that remove branches correctly.
This was a user-reported bug and a very subtle and painful one
to track down.

Previously, if payload['push']['changes'][i]['closed'] was True,
we assumed that a branch was removed. Looking at whether `closed`
was set to True or not was our way to tell whether a push removed
a branch or not.

However, this is wrong! `closed` being set to True can also mean
that the pull request associated with the branch was approved but
the branch itself was not deleted. According to the BitBucket docs,
the correct way to see if a branch is deleted is to check if `new`
is null.

This bug was leading to KeyErrors about not being able to find
the `commits` key, which shouldn't happen anymore!
2018-04-02 19:30:09 -02:30
novokrest
ad3ea775df actions.py: Rename get_service_dicts_for_bots() to get_service_dicts_for_bot() 2018-04-02 11:18:50 -07:00
guaca
83f4c0a723 ui.js: Add minimum scrollbar length. 2018-04-02 10:48:28 -07:00
Tim Abbott
da27461491 bugdown: Rename rewrite_if_relative_link to more clear name.
The name was actually sorta the reverse of what that function did.
2018-04-02 10:37:18 -07:00
Tim Abbott
7d4234b167 bugdown: Only open #narrow hash links inside the app. 2018-04-02 10:34:48 -07:00
Tim Abbott
6744938b6d bugdown: Simplify implementation for target_blank.
The previous version not using startswith() was harder to read.
2018-04-02 10:30:50 -07:00
Tim Abbott
6055a7bceb bugdown: Clean up rewrite_if_relative_link.
This implementation is more obviously correct, and may fix a corner
case where a `/` is missing after the realm URI.
2018-04-02 10:29:32 -07:00
Tim Abbott
b58cd46e48 profile: Fix field types on the frontend. 2018-04-02 10:25:37 -07:00
Umair Khan
e48f8bdafd check_short_string: Use check_capped_string for impl. 2018-04-02 09:51:09 -07:00
Umair Khan
7fdf043564 profile: Set max length for long text to 500. 2018-04-02 09:51:09 -07:00
Umair Khan
1d4b74482c check_short_string: Change max_length to 50. 2018-04-02 09:51:09 -07:00
Umair Khan
c30a282dd9 profile: Remove integer and float fields. 2018-04-02 09:46:21 -07:00
Vishnu Ks
c473ce0919 requirements: Upgrade Django to 1.11.11. 2018-04-02 09:29:12 -07:00
Vishnu Ks
bdf6e08fc0 requirements: Upgrade python-twitter to 3.4.1. 2018-04-02 09:29:12 -07:00
Rhea Parekh
1bba6cc4ce slack importer: Support custom emoji reactions. 2018-04-01 23:24:35 -07:00
Rhea Parekh
2c116e46ce slack importer: Get custom emojis. 2018-04-01 23:24:35 -07:00
Rhea Parekh
00c1f25b58 import script: Support custom emojis.
'processing_emojis' check is added in the 'import_uploads'
function, so that the emoji files present in the to be imported
data file can be uploaded.

The procedure of saving emoji files in slack importer is same as
saving attachments and avatars, and the import has the similar
procedure too.
2018-04-01 23:24:35 -07:00
Rhea Parekh
c650b8fa3e slack importer: Add zerver_realmemoji. 2018-04-01 23:24:35 -07:00
Rhea Parekh
b133d175a7 slack importer: Change 'get_user_data' function implementation.
Change 'get_user_data' function to a more general function
to get data from the slack api using legacy tokens.

Also, change the error handling as upon invalid token,
the response is 200, but the response has an error
field in it.

For eg. Go to the following link with invalid token:
https://slack.com/api/emoji.list?token=xoxp-249056023425
2018-04-01 23:24:35 -07:00
Rhea Parekh
220ad6a386 slack importer: Map standard reactions.
As mentioned in
https://get.slack.help/hc/en-us/articles/202931348-Use-emoji-and-emoticons,
slack supports the standard emoji codes
(https://www.webpagefx.com/tools/emoji-cheat-sheet/)
and majority of them are already supported in Zulip.
2018-04-01 23:24:35 -07:00
Rhea Parekh
6f867fee40 import script: Support import of reactions. 2018-04-01 23:24:33 -07:00
Rhea Parekh
8a028142d8 slack importer: Remove id allocation function and its implementation.
Remove allocation ID function from slack import script. All the IDs
count will start from 0. Hence the ID List returned
by the allocation function is of no use, and we remove its implementation.
(example: get_total_messages_and_attachments function is of no use anymore,
hence we remove it)
2018-04-01 23:10:55 -07:00
Rhea Parekh
d147bd25d0 import script: Change file path of the upload in the import script.
In importing avatars, we use the implementation where the 'avatar_path'
is seperately calculated using realm and user ID and then the content
of the path provided in the avatar's 'records.json' are copied to this
'avatar_path'.

Similary, here for the uploads, 's3_file_name' is seperately calculated
using the realm ID and uploaded file name and then the content of the
path provided in upload's 'records.json' are copied to this 's3_file_name'.
2018-04-01 23:04:14 -07:00
Rhea Parekh
ff34d07fa0 import script: Add function to update model ids after allocation.
Add function 'update_model_ids' to remove repetitive code.
2018-04-01 22:29:23 -07:00
Rhea Parekh
a2ecdeb28d import script: re_map minor foreign keys. 2018-04-01 22:29:23 -07:00
Rhea Parekh
078453554e import script: re_map Message foreign keys. 2018-04-01 22:29:23 -07:00
Rhea Parekh
93aabcb81c import script: re_map Subscription foreign keys. 2018-04-01 22:29:23 -07:00
Rhea Parekh
9ef7870c5a import script: re_map Recipient foreign keys. 2018-04-01 22:29:23 -07:00
Rhea Parekh
4537223ba7 import script: re_map UserProfile foreign keys. 2018-04-01 22:29:23 -07:00
Rhea Parekh
1314e7d247 import script: re_map Stream foreign keys.
'recipient_field' is added as a bool variable in the function
'update_id_map' to update the recipient foreign keys.

Recipient Foreign Key is equal to the UserProfile ID, if the
type is 1, and the same is equal to Stream ID, if the type is 2.
Hence a check is added in the 'update_id_map' field for this.
2018-04-01 22:29:23 -07:00
Rhea Parekh
8624ba4132 import script: re_map Realm foreign keys.
All the objects with realm ID as the foreign keys need to
be remapped with updated with the allocated ID.
Also the ID of the realm object itself is updated with the allocated
ID.
2018-04-01 22:29:23 -07:00
Rhea Parekh
2b0ee472af import script: Refactor re_map_foreign_keys.
The 'id_field' bool variable is added to the function just to check
if the field is the ID of that object, and not the foreign key relation.
For foreign key field names, a "_id" has to be added after the field name,
however we don't need that for the ID field of the object.
2018-04-01 22:29:23 -07:00
Rhea Parekh
cd0871bae4 Import script: Add id allocation functions. 2018-04-01 22:29:23 -07:00
Shubham Padia
10115491a3 real-time sync: Server sends recipent data with delete_message event.
Fixes #8853.
In certain cases, the browser is not able to look up the message.
Include the recipient data for the message in the delete_message event,
so look up of those attributes by the browser isn't required.
2018-04-01 22:19:08 -07:00
Shubham Padia
e1d9e3ae03 real-time sync: Use process_read_messages_event in delete_message event.
Replace mark_message_as_read with process_read_messages_event as the
latter function is only correct for marking a message as having been
read by this browser.
2018-04-01 22:17:18 -07:00
Tim Abbott
a65f6288b6 docs: Fix a broken link to the Cloud9 documentation. 2018-04-01 22:13:38 -07:00
Puneeth Chaganti
986e55e5b0 docs: Move summer with Zulip doc from Dropbox paper to ReadTheDocs.
Originally authored mostly by Tim Abbott.
2018-04-01 22:11:45 -07:00
Balaji2198
15d42f86f1 left sidebar: Fix "Compose" in stream actions popover prefills topic.
Fixes #8824.
2018-04-01 16:24:15 -07:00
Tim Abbott
3cfc760506 deprecation: Add fallback for if local storage is not available.
This falls back to a persistent variable for situations where local
storage is not enabled on the system.
2018-04-01 16:19:47 -07:00
Anurag Sharma
1227857de6 hotkeys: Replace C with x for composing PM.
Pressing the 'x' key can now be used to compose a PM.
Pressing the 'C' key displays a modal that shows a deprecation notice.

Fixes #6548.
2018-04-01 16:13:05 -07:00
Tim Abbott
af004fa6f5 rabbitmq: Connect to rabbitmq via 127.0.0.1 rather than localhost.
This should eliminate the occasional problems that some installations
have had with RabbitMQ trying to load-balance requests between
127.0.0.1 and ::1 (the ipv6 version of localhost).
2018-04-01 16:11:12 -07:00
Shubham Dhama
ad066ca444 org settings: Use get_property_value to get property elem value. 2018-04-01 16:11:12 -07:00
Shubham Dhama
8d70e59ad0 org settings: Rename functions for more clarity. 2018-04-01 16:11:12 -07:00
Shubham Dhama
7fbf613f89 org settings: Unexport functions not used in other modules. 2018-04-01 16:11:12 -07:00
Marco Burstein
7def65d7a3 style: Give inputs with type="number" a dark background in night mode.
Fix #8905.
2018-04-01 15:14:42 -07:00
Vishnu Ks
ca34b8e864 version: Bump version to facilitate py dependency upgrade. 2018-04-01 14:24:00 -07:00
Vishnu Ks
9e7a8d1603 requirements: Upgrade lxml to 4.2.1. 2018-04-01 14:24:00 -07:00
Vishnu Ks
03475362c4 requirements: Upgrade cryptography to 2.2.2. 2018-04-01 14:24:00 -07:00
Vishnu Ks
082f8bb682 requirements: Upgrade cffi to 1.11.5. 2018-04-01 14:24:00 -07:00
Vishnu Ks
47f79a0bf0 requirements: Upgrade stripe to 1.79.1. 2018-04-01 14:24:00 -07:00
Vishnu Ks
211826a0d8 requirements: Upgrade twilio to 6.11.0. 2018-04-01 14:24:00 -07:00
Vishnu Ks
94c107747f requirements: Upgrade SQLAlchemy to 1.2.6. 2018-04-01 14:24:00 -07:00
Vishnu Ks
ab81d8361e requirements: Upgrade Sphinx to 1.7.2. 2018-04-01 14:24:00 -07:00
Vishnu Ks
0cba334b6c requirements: Upgrade setuptools to 39.0.1. 2018-04-01 14:24:00 -07:00
Vishnu Ks
dda3aad198 requirements: Upgrade PyJWT to 1.6.1. 2018-04-01 14:23:55 -07:00
Vishnu Ks
eb109c620b requirements: Upgrade pip to 9.0.3. 2018-04-01 14:23:55 -07:00
Vishnu Ks
685ae4050f requirements: Upgrade pika to 0.11.2. 2018-04-01 14:23:55 -07:00
Vishnu Ks
82c1c86707 requirements: Upgrade oauthlib to 2.0.7. 2018-04-01 14:23:55 -07:00
Vishnu Ks
d17f9d3f09 requirements: Upgrade moto to 1.3.1. 2018-04-01 14:23:55 -07:00
Vishnu Ks
eeb454df31 requirements: Upgrade imagesize to 1.0.0. 2018-04-01 14:23:55 -07:00
Vishnu Ks
c046451fbc requirements: Upgrade httplib2 to 0.11.3. 2018-04-01 14:23:55 -07:00
Vishnu Ks
47afc015b3 requirements: Upgrade google-api-python-client to 1.6.6. 2018-04-01 14:23:55 -07:00
Vishnu Ks
64e6db5b88 requirements: Upgrade django-webpack-loader to 0.6.0. 2018-04-01 14:23:55 -07:00
Vishnu Ks
46ed1b3d78 requirements: Upgrade disposable-email-domains to 0.0.23. 2018-04-01 14:10:43 -07:00
Shubham Dhama
85077fbc9c org settings: De-duplicate template content for checkboxes. 2018-04-01 15:02:13 +05:30
Shubham Dhama
e317cd2c17 org settings: Add labels as a context to admin templates.
(It is a preliminary change for deduplication of org settings template.)
This adds org settings labels as a context to admin templates so that
they can be used as a context variables in admin templates.
The reason we did this in JS code because of translation issue when
passed (as a context in `partial` handlebars helper) directly within
template.
2018-04-01 14:52:12 +05:30
Shubham Dhama
07af13ccb3 org settings: Extend settings checkbox template for label & prefixed id.
(It is a preliminary change for deduplication of org settings template.)
This is done because of some settings like organization-settings
has ids which match the pattern of having a prefix `id_`
before the property name.

For those settings which don't have any prefix, there will be no
effect.
Here obsolete `t` in the label is removed since we do
label translations in JS files.
2018-04-01 14:44:24 +05:30
Shubham Dhama
b7aae89029 org settings: Add realm level default time format setting. 2018-03-31 16:23:26 -07:00
Shubham Dhama
f4d6b2a853 org settings: Split "Language and notifications" section.
This splits "Language and notifications" section into "Default user
settings" and "Notifications".
With this, we can easily add other default user settings in the
same place.
2018-03-31 16:22:52 -07:00
Shubham Dhama
e04b8271ca org settings: Remove obsolete UI updating code for realtime sync.
In our new system for updating realm settings, we don't need to create
separate functions to update the input elements for each feature.
Most of the work is done automatically by
`settings_org.sync_realm_settings`.
2018-03-31 16:19:09 -07:00
Balaji2198
724117cd45 org settings: Refactor the render_notifications_stream_ui function.
We are having a same code in `render_notifications_stream_ui`
and `render_signup_notifications_stream_ui` functions aside from
the HTML element. So this commit will remove the duplicate code in
`render_signup_notifications_stream_ui` and make use of
`render_notifications_stream_ui`.

Fixes #8886.
2018-03-31 16:08:47 -07:00
Balaji2198
21fe9fe20a org settings: Add elem param to the render_notifications_stream_ui. 2018-03-31 16:08:47 -07:00
Tim Abbott
072bd306ce tests: Add another test for the can_admin_user code path.
This is just a clear version of our validation of this part of Zulip's
security model.
2018-03-31 16:06:56 -07:00
Eeshan Garg
87cc548e30 pypa: Upgrade to release 0.4.2. 2018-03-31 15:49:07 -07:00
Aastha Gupta
9d052bcf5e copy_and_paste.js: Fix exception on IE11 with clipboardData.
On IE11, ClipboardData isn't defined; one can instead access it with
`window.clipboardData`, but that doesn't support text/html, so this
code path couldn't do anything special anyway.

So we instead just let the default paste handler run on IE11.

Fixes #8850.
2018-03-31 15:47:33 -07:00
Steve Howell
cd8c15f1cf pills: Use a template to render the pills. 2018-03-31 09:32:52 -07:00
Steve Howell
d48fb1d776 pills: Use insertText for copy/paste. 2018-03-31 09:32:52 -07:00
Tim Abbott
3fd8d718f4 websockets: Fix race condition in CSRF token initialization.
It appears that we were not always initializing the Socket object
after `setup.js` had the opportunity to set csrf_token.

This should fix #6961.
2018-03-31 09:29:56 -07:00
Puneeth Chaganti
4ce8f2aaa2 upload: Rename upload_message_image to upload_message_file.
Tweaked by tabbott to also fix a Slack import comment.
2018-03-30 13:38:31 -07:00
Eeshan Garg
f839d528d8 decorators: Log custom HTTP headers in webhook requests.
This aids in debugging because many of our Git-based integrations
use custom HTTP headers to indicate the type of event/payload.
2018-03-30 13:37:35 -07:00
Akash Nimare
51113baebc desktop-app: Update app to latest v1.9.0. 2018-03-30 13:14:10 -07:00
Tim Abbott
e840e5b3a8 Revert "Ignore new messages when lists are behind."
This reverts commit bcdd12773e.

We need to do some improvements in handling FetchStatus for initial
narrows before this will be safe to deploy in production.
2018-03-30 11:52:14 -07:00
Tim Abbott
8b91ea3a74 Revert "Suppress local echo when we are not caught up."
This reverts commit 80ed8294a1.

We need to do some improvements to FetchStatus for narrows before this
is safe to have running in production.
2018-03-30 11:51:52 -07:00
Rishi Gupta
96845147c9 help: Fix a few errors in edit-or-delete-a-message.md.
Still some errors (e.g. "Hover over a message to replace the message's
timestamp with its message actions" is no longer correct), and a lot of
other improvements to be made, but just doing a quick fix of a few things I
noticed.
2018-03-30 10:55:23 -07:00
Tim Abbott
5c1dd162be settings: Eliminate remaining NEW_USER_BOT code.
I somehow missed this when removing the rest of the custom
NEW_USER_BOT logic.

This may fix a Casper test that has been failing.
2018-03-30 09:16:22 -07:00
Steve Howell
9ce9c2f9db Extract info_overlay.js.
There are several ways we open help for keyboard shortcuts,
markdown help, and search operators.

    - from the gear menu
    - from the compose box
    - from the search box
    - hitting ? for keyboard help
    - arrowing/clicking through the tabs

This just moves the relevant code into a module and changes a
bunch of one-line calls in various places.
2018-03-30 09:07:23 -07:00
Shubham Dhama
efeee28b12 settings: Remove obsolete lines of code.
There don't exist any element with this classes and it seems they
are accidentally added during addition of `bot_creation_policy`.
2018-03-30 16:07:53 +05:30
Shubham Dhama
aca2364455 settings: Focus "Add a new bot" tab when there is no active bot.
Fixes: #8872.
2018-03-30 16:07:01 +05:30
Shubham Dhama
0ef195ecc2 settings: Refactor code for focussing bot tabs. 2018-03-30 16:07:01 +05:30
Shivamgera
2a0491c47a docs: Update help/messages_sent_over_time.png 2018-03-29 16:15:11 -07:00
Steve Howell
90e10a11de components: Simplify toggle component.
This adds some helpers to avoid some duplication, and we also
now track the selected idx directly, since it's all under our
control.

The main addition is `select_tab`, which we now use for some
things that used to simulate clicks.
2018-03-29 16:13:46 -07:00
Tim Abbott
0d35bbc464 install: Install the wget package.
We depend on it for installing node, and it's a standard package, not
a required one, so we do need to explicitly declare the dependency.
2018-03-29 16:03:44 -07:00
Rohitt Vashishtha
a3ed83f4e2 markdown: Update bugdown emoticon translation logic to match frontend.
This PR solves some of the parity issues in the emoticon translation
logic. I was unable to find a way of matching only one of the
lookaround groups, so we still have some inconsistency (see
testcase). The approach of having another check while converting just
for this seemed like an inefficient way, so I've left that last change
as it is.
2018-03-29 15:56:24 -07:00
Umair Khan
c14cefc24c settings: Add support for adding/removing custom profile fields.
Now that we have support for displaying custom profile fields, this
adds administrator-level support for creating them.

Tweaked by tabbott to fix a few small bugs and clean up the commit message.

Fixes #1760.
2018-03-29 13:59:16 -07:00
Umair Khan
7885dd4408 profile: Send field types to client side. 2018-03-29 13:09:12 -07:00
Umair Khan
f6fb88549f profile: Send operation in the event.
This allows us to show a useful message in the handler when the
event is received.
2018-03-29 13:09:11 -07:00
Tim Abbott
d8cfb499c0 css: Remove obsolete .markdown .footer block.
The template inheritance structure changed a long time ago such that
this no longer does anything.
2018-03-29 12:40:54 -07:00
Tim Abbott
656f882a44 bots: Eliminate NEW_USER_BOT.
This bot was basically a duplicate of NOTIFICATION_BOT for some
specific corner cases, and didn't add much value.  It's better to just
eliminate it, which also removes some ugly corner cases around what
happens if the user account doesn't exist.
2018-03-29 12:01:21 -07:00
Tim Abbott
2bc51931a8 test_fixtures: Add settings files to things that require reprovision.
Since the test database is in part controlled by the Zulip settings
files for testing, these settings files should be included in the list
of files that require populate_db to be rerun.

This issue was found due to changes to internal bots.
2018-03-29 11:53:12 -07:00
Tim Abbott
4570936ac2 models: Fix default value for last_reminder.
This was causing a rather confusing test flake in
test_stream_error_pm_to_bot_owner.  What was happening was that if
this test (which used that code path) ran within 5 minutes of the
populate_db run, it would fail.
2018-03-29 11:53:12 -07:00
Yago González
044fb0a42b i18n: Fix handling of OR on login/register pages.
Closes #8860
2018-03-29 11:13:59 -07:00
Tim Abbott
ff92cdaaaf clean-npm-cache: Use islink to check node_modules.
Very old Zulip deployments might have node_modules be an actual
directory, which we should ignore for the purposes of
garbage-collection.
2018-03-29 10:57:41 -07:00
Marco Burstein
382f93189f night mode: Fix unreadable new user tips.
Fix the border color, shadow color, arrow color, and background color
of the tips popovers for new users in dark mode.

Fix #8868.
2018-03-29 10:28:12 -07:00
Steve Howell
e145258fee node tests: Add 100% coverage for components.js. 2018-03-29 08:09:38 -07:00
Yago González
1237f819bb settings: Fix typo. 2018-03-29 08:04:51 -07:00
Shubham Dhama
b580c62bd4 settings: Fix exception on updating bot_creation_policy.
This initializes the bot_creation_policy_values after the page
is loaded.

Previously we initialize these values in `settings.js` when settings page
is loaded at least once, so if we open two tabs, one(1) in which we
haven't opened the settings page yet and if in another tab (2) we
update the `bot_creation_policy` value, then because of the event
which calls `settings_bots.update_bot_permissions_ui` causes exception
in (1) because `bot_creation_policy_values` isn't initialized yet.

Fixes: #8852.
2018-03-29 08:03:42 -07:00
Tim Abbott
9f2a3c2921 settings_org: Fix spelling in set_create_stream_permission_dropdwon. 2018-03-29 08:02:19 -07:00
Shubham Dhama
35cfb86723 org settings: Fix real-time sync for realm_waiting_period_threshold.
This fixes a minor bug in which the value of `input` element of
`realm_waiting_period_threshold` don't get updated because in
`set_create_stream_permission_dropdwon` we don't change the
value of the input.
So, this minor refactor handles this more carefully.
2018-03-29 08:00:58 -07:00
Shubham Dhama
7eea186306 org settings: Make sync_realm_settings to be available at load time.
This moves `sync_realm_settings` function out of `_setup` so that
we can call `settings_org.sync_realm_settings` without opening
settings page at least once.

This also fixes a minor bug in which if we have two tabs opened and
in one we haven't opened settings page at least once and in
another we change an org setting, then we get an exception in
the former tab because of the event as `sync_realm_settings`
isn't defined yet.
2018-03-29 08:00:50 -07:00
Shubham Dhama
29f57d54a0 org settings: Move discard_property_element_changes out of _setup. 2018-03-29 17:44:39 +05:30
Shubham Dhama
e53c6f5639 org settings: Move independent functions out of _setup function.
This commit moves some functions out of `_setup` function which are
independent of each other and any function inside `_setup` function.
2018-03-29 17:44:39 +05:30
Shubham Dhama
4472f5b230 org settings: Prefer val over attr to change value of dropdown.
Changing the selected value of dropdown by `val` has more advantage
over `attr` especially in the case when dropdown value is chnaged
multiple times like due to events and discarding changes.

Though it is applicable to other elements but in this commit it is just
used for `id_realm_create_stream_permission` dropdown.

There are many question about this at stackoverflow:
https://stackoverflow.com/a/22093618/7418550
https://stackoverflow.com/a/4837162/7418550
2018-03-29 17:44:38 +05:30
Shubham Dhama
6ec5c28e97 org settings: Move property types out of _setup function.
Since we don't have any string needed to be translated in
property_types we can move it outside `_setup` function to
get to the safe side if they needed to get accessed before
`_setup` is called.
2018-03-29 17:44:27 +05:30
Rohitt Vashishtha
115b633551 markdown-tests: Allow ignoring certain fixtures while developing.
Usually, to debug a small change, you have to remove some tests from JSON
because of lack of support for comments in JSON. This commit allows to
ignore some tests by setting `"ignore" : true` in the bugdown fixtures.

Also, since this is only for while developing, the complete test suite will
throw an error if we leave an 'ignored' test in a commit.
2018-03-28 17:35:47 -07:00
Rohitt Vashishtha
c0ea4f2d5a markdown-tests: Show bugdown testcase name on failure. 2018-03-28 17:35:47 -07:00
Tim Abbott
5fb3bff67e certbot: Don't prompt when installing apt packages.
The comment included in this commit explains the somewhat messy
situation that requires running certbot twice as part of this
installer.

Fixes #8486.
2018-03-28 17:09:38 -07:00
Shubham Dhama
f5a57dc614 settings notification: De-duplicate template content for checkboxes.
This creates a new template `settings_checkbox.handlebars` to de-duplicate
the checkboxes in notification settings page.
2018-03-28 16:17:45 -07:00
Shubham Dhama
86967c2be1 settings: Include settings label as context to template.
This is a preliminary commit which includes settings' (checkboxes)
label as a context for rendering template.
The reason we did this in JS code because of translation issue when
passed (as a context in `partial` handlebars helper) directly within
template.
Currently this is done for notifications' settings.
(There will be no UI change)
2018-03-28 16:17:45 -07:00
Steve Howell
431ede77c6 minor: Clean up how we set flags in events.
This is basically a simple fix, where we consistently set
`flags` to an empty array when we pass it around.  The history
here is that we had kind of a nasty bug from setting it to
`None`, which only showed up in the somewhat obscure circumstance
of somebody subscribing to all stream events in our API.

Fixes #7921
2018-03-28 15:56:03 -07:00
Tim Abbott
838e5880b6 clean-emoji-cache: Stop recalculating paths for other deployments.
This is the analog of 7b2c9223e7 for the
emoji cache; the only difference is that the existing code was working
correctly.  It's still worth changing for improved robustness.
2018-03-28 15:48:29 -07:00
Tim Abbott
7b2c9223e7 clean-npm-cache: Fix buggy garbage-collection logic.
We saw issues with /srv/zulip_npm_cache being cleaned incorrectly by
this tool in production (more correctly, we noticed broken symlinks to
those directories, even from the current deployment).  Print-debugging
showed that indeed older deployments were being ignored, because the
logic for `get_caches_in_use` was totally broken (this was sorta
masked because we also keep the last week's deployments).

The specific bug here turned out to be that we weren't passing the
`production` argument to generate_sha1sum_node_modules, but the
broader problem is that this logic isn't robust to changes in the
hashing algorithm.

Fix this by replacing the broken logic for trying to compute the
correct hash for that deployment with just checking the symlink inside
the deployment to let it self-report.

We can't easily do this same change for clean-venv-cache, because we
use multiple virtualenvs there.  But a similar change could be useful
for the emoji cache as well.

Fixes #8116.
2018-03-28 15:42:02 -07:00
Ghislain Antony Vaillant
00dd86967b puppet: Add Debian 9 package names to definitions.
This doesn't add support for Debian 9, but it will save time for folks
working on Stretch support in the future.
2018-03-28 12:33:45 -07:00
neiljp (Neil Pilgrim)
6e89b60e44 tools/mypy: Enforce a more explicit checking of Optional. 2018-03-28 12:31:51 -07:00
neiljp (Neil Pilgrim)
704c33331c mypy: Add explicit Optional for default=None parameters in export.py. 2018-03-28 12:31:51 -07:00
neiljp (Neil Pilgrim)
090b47ed19 mypy: Add explicit Optional for default=None parameters in various files. 2018-03-28 12:31:51 -07:00
Tim Abbott
9a90c225a6 dialogflow: Fix invalid coding tag in top of file. 2018-03-28 12:28:12 -07:00
Tim Abbott
3d5b6539d1 unread: Fix confusing aliasing of variable names. 2018-03-28 12:21:36 -07:00
Balaji2198
e1eabe286a integrations: Add Gocd webhook integration.
Fixes #38.
2018-03-28 11:08:27 -07:00
Balaji2198
a583733723 settings: Fix error handling for uploading an invalid file for Upload icon.
Fixes #8842.
2018-03-28 10:52:16 -07:00
Tim Abbott
013a8886b2 styles: Rename dark.css to night_mode.css. 2018-03-28 10:42:28 -07:00
Tim Abbott
d92af69cce styles: Rename dark-mode to night-mode.
This matches the externally-facing name for the feature as well as the
setting variable in the code.
2018-03-28 10:41:26 -07:00
Tim Abbott
c94deff920 mypy: Remove some now-unnecessary type: ignores. 2018-03-28 10:39:05 -07:00
Steve Howell
df857fb214 Test maybe_load_newer_messages. 2018-03-28 09:13:46 -07:00
Steve Howell
084ef0bea9 Fetch new messages when you scroll forward in narrows.
Note from tabbott: This is a somewhat surprising feature to be adding
this late in Zulip's development, but the model we've had of what
narrows are easy to access via clicking around has meant that it was
fairly difficult to get into a narrow that didn't include the very
latest messages in that narrow.

Fixes #3465.
2018-03-28 09:12:59 -07:00
Steve Howell
80ed8294a1 Suppress local echo when we are not caught up. 2018-03-28 09:12:25 -07:00
Steve Howell
bcdd12773e Ignore new messages when lists are behind.
If individual messages arrive before we get the latest
messages from the server, they can create gaps in rendering,
and would often be offscreen anyway, so we just ignore them.
2018-03-28 09:12:25 -07:00
Steve Howell
4e431516bf Update message_list.all.fetch_status during frontfill. 2018-03-27 18:14:09 -07:00
Steve Howell
60c77ddf6c Update message_list.all in do_backfill(). 2018-03-27 18:14:09 -07:00
Shubham Dhama
419208cabe settings: Refactor to use pluck to extract setting attribute.
This is just a small refactor to use `pluck` over manually using `map`.
2018-03-27 18:01:03 -07:00
Shubham Dhama
6427afec43 settings notification: Wrap subsections in seperate divs.
This wraps each subsection in notification settings in a parent div.
This is done just to make the code more readable and clean.
There will be no UI change.
2018-03-27 18:01:03 -07:00
Shubham Dhama
1d88eb5d6a org permissions: Remove redundant status elements. 2018-03-27 18:01:03 -07:00
Rohitt Vashishtha
3c96b04763 emoji: Add translate_emoticons flag in bugdown testcases.
Also switches the default behaviour of the code to not translate the
emoticons. Earlier, the code was testing-aware, and used to translate
when there was no user profile data available(assuming that as a testing
environment).
2018-03-27 17:16:55 -07:00
Rohitt Vashishtha
b976447102 markdown: Test the translate_emoticons flag.
The main testing of the translate emoticons code is in the
node_tests/emoji.js file. This code just checks if the setting
to enable/disable the emoticon translation is being honored.
2018-03-27 17:16:55 -07:00
Rohitt Vashishtha
6dda3fe83e emoji: Do selective local echo of emoticon conversions.
Earlier, we used to convert all occurrences of an emoticon on the
frontend. That behavior has been altered to do conversions only
when the emoticon has some terminal symbols around them, and not
any alphabet or number. Also adds tests for emoji conversions for
the above logic.

Fixes #8585.
2018-03-27 17:16:55 -07:00
Shubham Dhama
33b6e19e31 org settings: Remove obsolete property_types's status messages.
Since now we use buttons as a method to show saving status,
we don't need anymore `msg`, `checked_msg` etc.
2018-03-27 16:48:29 -07:00
Shubham Dhama
2f496ffe1f org profile: Use new org setting changes saving framework.
With this we have the same way to save changes done in org profile
subsection, i.e. show "Save" button beside header of subsection,
add "Discard changes" button for org profile subsection and
show "Save" and "Discard" button only when needed.

Also, there is so much code which become obsolete which is removed
in this commit.
2018-03-27 16:48:28 -07:00
Shubham Dhama
034eaf0aa1 org settings: Restructure org-profile-admin template. 2018-03-27 16:45:32 -07:00
Marco Burstein
6279a9ef09 message view: Hide "view source" and "quote" for deleted messages.
Fix #8839.
2018-03-27 16:43:24 -07:00
sinwar
79672fffc6 populate_db: Pre-populate open graph cache to avoid network activity.
This prevents annoying network errors when trying to populate the
database without Internet access.

Cleaned up a bit by tabbott.

Fixes #8289.
2018-03-27 16:42:59 -07:00
Tim Abbott
ac7031de3a message_list_view: Add a workaround for Chrome scrolling down bug.
Based on extensive manual testing with print-debugg (the exact
situation here was highly reproducible), in the absence of this line
here or slightly above here, Chrome 64 will consistently trigger an
extra scroll-forward-by-12000-pixels size downward scrolling event
immediately after it finishes rendering the 5th batch of ~100 messages
one gets from hitting the End key in `near:1` narrows.

I don't understand clearly why this change would protect against such
a Chrome bug, but my best guess is that Chrome was doing some sort of
incorrect optimization, and querying the scrollTop was forcing it to
come to a clear conclusion about the scrolling position before
appending more content.

But runs with the scrollTop() line not present in that function show a
scrollTop of around 25K in `append()` just before the call to
`render()`, and 37K at the end; while runs with this scrollTop line
always show 25K both before and after, so it does seem to work.
2018-03-27 13:51:28 -07:00
Tim Abbott
5404edaf03 tests: Verify database queries for realm administrators.
This number is way too high, because of a recent regression.  Adding a
test here lets us prevent similar regressions in the future and
provides an easy way to be sure if we've fixed the issue.
2018-03-27 11:56:13 -07:00
neiljp (Neil Pilgrim)
07971d3a66 linter: Add check that Optional models are tagged with null=True.
Exclude NullBooleanField explicitly.

Amend one line in models.py found from this linter change.
2018-03-27 10:21:25 -07:00
neiljp (Neil Pilgrim)
7d93f5726c linter: Add check that null=True lines are annotated as Optional.
Also add two missing annotations of this type that were missed
until linted.
2018-03-27 10:21:25 -07:00
neiljp (Neil Pilgrim)
9d26c78ece mypy: Annotate last null=true in models.py; modify mypy.ini exclusions. 2018-03-27 10:21:25 -07:00
neiljp (Neil Pilgrim)
1416c9f0c9 mypy: Broaden model variables with null=True to be Optional. 2018-03-27 10:21:25 -07:00
Tim Abbott
43ec04dcff narrow: Fix a buggy condense_and_collapse call.
Previously, when unnarrowing, we were calling this on the wrong
selector (this was missed years ago when we refactored Zulip to use
divs rather than table rows in the main message feed).

Noticed while debugging #5312.
2018-03-27 09:53:45 -07:00
Puneeth Chaganti
97b90c1e87 condense: Re-condense all messages on window resize.
Previously, if you started out with a very small window, loaded the
Zulip webapp, and then resized the window to be larger, you'd get the
condensed "[More]" links on essentially every message.  This failure
mode was most visible with multi-protocol Electron apps like Rambox
that would sloppily start with a tiny window and then resize it when
loading Zulip.

The Rambox experience was essential to our being able to track this
down; once we knew what was happening, the fix was simply to
re-compute the condense state on resize.

Commit message rewritten by tabbott to explain the debugging and
context involved here, since this was one of our longest-lived mystery
bugs.

Fixes #5312.
2018-03-27 09:53:45 -07:00
Tim Abbott
3b29d00c69 setup-apt-repo: Fix use of shasum alias for sha1sum.
This is apparently installed by the perl package; I hadn't even known
it existed.  We of course want to use the sha1sum command from
coreutils.

Fixes #8836.
2018-03-27 09:47:14 -07:00
Shubham Dhama
4cf42ce478 settings: Move remove-default-stream-button handler to settings_streams. 2018-03-26 10:27:09 -07:00
Steve Howell
825f5feba4 stream_create: Finish handler cleanup.
This commit is similar to the prior commit, in that we are
more disciplined about setting up handlers.  We set them up right
as the widgets get rendered, and the handlers only delegate
up to the container div (id="stream_creation").
2018-03-26 06:44:19 -04:00
Steve Howell
954fceeed6 stream_create: Make handlers more modular for users.
We now wire up the handlers that correspond to elements in
the 'new_stream_users' template when we render that template,
rather than at startup time.

We also delegate the events only up to #people_to_add, rather
than all the way up to body/document.
2018-03-26 06:44:19 -04:00
Steve Howell
04e25fe2a2 Extract stream_create.create_handlers_for_users(). 2018-03-26 06:44:19 -04:00
Joshua Pan
0f58f20ad8 tests: Clean up test-js-with-node output on success. 2018-03-26 06:35:58 -04:00
Joshua Pan
ed9eb3bdb5 tests: Make test-js-with-node handling smarter.
Added support for passing a filename without `.js` suffix.
This then fixed the issue of no complaints for invalid test
files. Now, throws an error for invalid test files.

Fixes #8579.
2018-03-26 06:35:58 -04:00
Shubham Dhama
eb0da20b78 settings: Clean up repeating code in error callbacks.
This cleans repeating code in error callback in settings.
We made a generic function in `ui_report.js` which require two
arguments `xhr` and `btn`; we preferred `btn` over `row` as argument
because a row may have more than one buttons.

Fixes: #8788.
2018-03-25 10:40:40 -07:00
Steve Howell
cb54acf120 stream create: Make docs open in another tab.
We really don't want to make the user hit the back button right in
the middle of creating a stream.
2018-03-25 10:21:44 -07:00
Steve Howell
f8e0137678 node test: Add message_fetch.js tests.
This tests the initialize() function for now.

It goes deep on this:
    * uses "mostly real" message lists
    * asserts on fetch parameters

It stubs out many modules that aren't really central to
the logic of fetching.  In particular, when messages are
processed, we notify things like the buddy list that messages
have been added.
2018-03-25 10:18:00 -07:00
Steve Howell
3dd1d784cb node tests: Add test_render_windows(). 2018-03-25 10:18:00 -07:00
neiljp (Neil Pilgrim)
9a6e84a1c3 requirements: Upgrade mypy to 0.580. 2018-03-25 10:17:47 -07:00
Umair Khan
d1c7a400ee i18n: Ignore var directory.
Previously, makemessages command was also searching var directory for
translatable strings. This commit ignores that directory.

Fixes #8751
2018-03-25 09:08:37 -07:00
neiljp (Neil Pilgrim)
8810245d48 mypy.ini: Expand tests wildcard from strict-optional into files list. 2018-03-25 08:59:08 -07:00
neiljp (Neil Pilgrim)
ac09687fa2 mypy: Raise in commands/create_user.py if initial_password returns None. 2018-03-25 08:59:08 -07:00
neiljp (Neil Pilgrim)
de76297f31 mypy.ini: Move purge_queue exclusion into re-architecting section. 2018-03-25 08:59:08 -07:00
neiljp (Neil Pilgrim)
3b28d6ab8b mypy: Rewrite sign_is_valid in zthumbor helpers.py for None secret_key. 2018-03-25 08:59:08 -07:00
neiljp (Neil Pilgrim)
8b697b4093 mypy: Annotate stream_data in populate_analytics_db.py handle function. 2018-03-25 08:59:08 -07:00
Eeshan Garg
a95e9000fb css: Apply the CSS for !!! tip syntax to integrations.
We should be able to use the `!!! tip` syntax within our integration
docs. This commit adds the requisite CSS.
2018-03-25 08:58:08 -07:00
Eeshan Garg
ee895fa182 integrations/rss: Recommend integrating RSS via Zapier.
An integration with RSS can be much easier to set up with Zapier.
Since the current RSS integration predates Zapier, we should at
least mention that there is an easier way to set it up via
Zapier!
2018-03-25 08:58:08 -07:00
Shubham Dhama
3e47a9fe22 org settings: Add real-time syncing for property changes. 2018-03-25 08:30:47 -07:00
Shubham Dhama
315058498b org settings: Handle dependent sub settings manually.
This replaces the previous logic of triggering change() event.
(Also, when we trigger the change() event whole path for detecting
changes in a subsection are triggered which isn't good.)
2018-03-25 08:30:04 -07:00
Shubham Dhama
84a5786b2e org settings: Refactor the discard changes function.
This extract the logic of resetting the value of a single property element
at a time so that we can reuse this for real-time-syncing.
2018-03-25 08:30:04 -07:00
Shubham Dhama
a779fc6095 org settings: Use disable_sub_setting_onchange for dependent checkbox.
This makes use of `settings_ui.disable_sub_setting_onchange` for
handling dependent `id_realm_disallow_disposable_email_addresses`
checkbox when `id_realm_restricted_to_domain` is changed.
2018-03-25 08:30:04 -07:00
Shubham Dhama
f17fa3305b org settings: Fix discard changes for realm_create_stream_permission.
On discarding changes made for `realm_create_stream_permission` always
"by_admin_user_with_custom_time" get selected because
`create_stream_by_admins_only` isn't a valid page_param.
2018-03-25 08:30:04 -07:00
Shubham Dhama
ce156dd21d settings_ui: Revert extension for success callback in do_settings_change.
This reverts success callback extension for `do_settings_change` function
because it seems it is better to make the request directly rather
than calling `do_settings_change`.
And hence `error` callback extension is also removed  for the same
reason, but a error_continuation is added to do additional tasks when
errors happened.
2018-03-25 08:30:04 -07:00
Steve Howell
aac76c14bd settings: Avoid duplicate form handlers.
For forms that are built early in setting up the settings panel,
we don't want to attach multiple submit handlers every time we
go into the gear menu, so we use "off" to clear any old handlers.

We also attach handlers directly to the form, instead of
using delegation up to the container div.
2018-03-25 08:28:04 -07:00
Steve Howell
e30b619ad5 Fix leaky O(N) email hint handler.
We only have one possible email hint, so there's no reason
to create one for each stream row, especially since we don't
clean them out when we close stream settings.
2018-03-25 08:28:04 -07:00
Steve Howell
f97fe7842e zjquery: Add support for off(). 2018-03-25 08:28:04 -07:00
Eeshan Garg
4886d92405 webhooks/pivotal: Check if content == "" before sending a message.
If a message is empty, it means that this event is unsupported, in
which case, we should raise JsonableError.
2018-03-24 13:54:31 -07:00
Eeshan Garg
538746fc65 webhooks: Stop raising an exception if stream does not exist.
webhook-errors.log file is cluttered with Stream.DoesNotExist
errors, which hides the errors that we actually need to see. So,
since check_message already sends the bot_owner a PM if the webhook
bot tries to send a message to a non-existent stream, we can ignore
such exceptions.
2018-03-24 13:50:17 -07:00
Ricky
4b8bd0bc3b webhooks: Add Dialogflow integration.
With minor fixes by eeshangarg!

Fixes #6990
2018-03-24 15:03:35 -02:30
Steve Howell
45f0df6d31 message view: Removed message_rendered.zulip event.
We don't have any consumers for this event after removing
some obsolete code related to subscribe buttons.

Handling this event reliably consumed about 75% of the time
spent in _post_process_dom_messages, and maybe a percentage
point or two of overall rendering, so this will be a minor
speedup.
2018-03-24 12:31:36 -04:00
Steve Howell
4f05cefb32 Remove obsolete code for stream subscribe buttons.
In 18e43895ff we replaced
stream subscribe buttons with stream links.  The new feature
has been well tested and well received for over a year now,
so it's safe to remove the older feature at this point.

Older sites will have super old messages that still have the
rendered markup; this commit does not attempt to address those
situations.  Most likely, clicking on an old button in the old
message will either do nothing or look like a message reply.
2018-03-24 12:31:36 -04:00
Aayush Agrawal
d32d7a9b4d test_logging_handlers: Mock out git describe because can be slow.
This cuts out about 11 calls to `git describe`.  In a nice fast LXC
container following our instructions for development on a Linux host,
this might save "only" about 1.5s; in a dev environment on a Windows
host, the savings have been clocked at 49s, presumably due to an
extremely slow filesystem in the VM.

The tests weren't doing much with this codepath as they were, and
there isn't a lot of value to be gained by testing it anyway; it's
totally non-critical and rarely changes.

[Commit message rewritten by greg.]
2018-03-23 18:24:51 -07:00
neiljp (Neil Pilgrim)
b9fdb2cbf5 mypy: Add warn_no_return option to mypy.ini.
This option "shows errors for missing return statements on some
execution paths." according to the mypy docs.

It doesn't currently bring up anything, after cleaning the cache.
2018-03-23 16:53:43 -07:00
neiljp (Neil Pilgrim)
9a49812cde mypy: Extract default run-mypy options into mypy.ini. 2018-03-23 16:53:43 -07:00
neiljp (Neil Pilgrim)
fb4f5c8570 tools: remove strict-optional command from run-mypy.
This is now controlled globally and on a per-file basis in mypy.ini.
2018-03-23 16:53:43 -07:00
Tim Abbott
f262936c25 docs: Update changelog through current master. 2018-03-23 16:43:39 -07:00
Tim Abbott
51073afc36 subs: Remove incorrect expectOne() in settings_button_for_sub.
This removes an assertion added in
b6408a0383 that was only true if that
stream's edit UI was visible.
2018-03-23 15:24:42 -07:00
Tim Abbott
195b96c989 lightbox: Add debugging code for unknown message IDs.
This should help debug a traceback we've been seeing in production
where the fetched message was undefined.
2018-03-23 15:17:21 -07:00
Aayush Agrawal
78a4924ecc markdown: Apply both bold and italic for words like ***text***.
Adds rule 'strong_em' to markdown parser to recognize ***{TEXT}***
Fixes #8155.
2018-03-23 15:01:24 -07:00
Tarun Kumar
d403b7a2d5 user-groups: Prevent user not in user group from editing/deleting it.
Admin and user group members are allowed to edit/delete group.
Add node-tests to maintain 100% coverage for settings_user_groups.js
Fixes #8315.
2018-03-23 14:44:47 -07:00
Tarun Kumar
5ac767149c user-groups: Update UI to mention only members can edit a user group.
Also, we remove unnecessary tips regarding modification settings.

Remove 'Only organization administrators can edit these settings'.
Remove 'Anyone in this organization can add user groups'.
2018-03-23 14:44:47 -07:00
Tarun Kumar
86eaa553a6 user-groups: Add backend enforcing for new modification settings.
Add function in user-groups.py for getting member ids
for a group.
Update view to enforce checks for modifying user-groups.
Only admins and user group members can modify user-groups.
2018-03-23 14:44:47 -07:00
Tarun Kumar
f3501b7f60 user-groups: Update css for a user who is not in a user group.
Add required css in input_pill.css.
Add required css in settings.css.
2018-03-23 14:42:55 -07:00
Tim Abbott
b637cc68ad display-settings: Fix indentation of emoticons checkbox.
This didn't look good indented.
2018-03-23 14:38:26 -07:00
Tim Abbott
4b8dda24d0 display-settings: Move emoticons option after emoji style.
This new position is clearer about its role.
2018-03-23 14:38:00 -07:00
Greg Price
b42a7b1701 digest: Add a server setting, and disable by default.
This feature isn't really ready yet -- the relevance isn't good, so
the emails aren't a great experience.  More work needed; pending that,
just don't send them.

There's already a per-realm setting, which doesn't have a control in
the org settings UI but does suppress it in the per-user settings UI.
Piggyback on that to suppress that UI control when the feature is
disabled at the server level too.

Also cut a comment that hasn't really made sense since the logic was
changed months ago -- the comment originally explained why we sent
digests on Tuesday, Wednesday, and Thursday, and doesn't correspond to
why we dialled back to weekly on Tuesdays.
2018-03-23 14:12:01 -07:00
Greg Price
42a641421f digest: Split out tests into their own file.
The digest emails have little in common with the email mirror, beyond
that they both involve email.  Give their tests their own file, with a
corresponding name, so it's easy to find this code's tests.
2018-03-23 14:12:01 -07:00
neiljp (Neil Pilgrim)
9ec3b588b1 mypy: Add mypy.ini, including strict-optional by default. 2018-03-23 13:07:39 -07:00
neiljp (Neil Pilgrim)
70117f0e83 mypy: Add asserts of intermediate values in update-authors-json. 2018-03-23 13:07:39 -07:00
neiljp (Neil Pilgrim)
2762aabad1 mypy: Add assert for re search being None in appfollow webhook. 2018-03-23 13:07:39 -07:00
neiljp (Neil Pilgrim)
f32f3cbf72 mypy: Amend zulip-ec2-configure-interfaces to avoid None. 2018-03-23 11:39:54 -07:00
neiljp (Neil Pilgrim)
f0e3fcb937 mypy: Amend test-backend:internet_guard to return NoReturn.
It is guaranteed to raise an exception, so this is reasonable,
and it satisfies mypy.
2018-03-23 11:39:54 -07:00
neiljp (Neil Pilgrim)
97836c4bac mypy: Remove Optional & Mutable from do_schedule_message.
Removes various mypy errors.
2018-03-23 11:32:00 -07:00
neiljp (Neil Pilgrim)
306f042cf4 mypy: Add Optional to function return in groove integration. 2018-03-23 11:32:00 -07:00
neiljp (Neil Pilgrim)
2079c5e4d7 mypy: Mark Subscription as Optional in lib/streams.py:access_stream*. 2018-03-23 11:32:00 -07:00
neiljp (Neil Pilgrim)
d741e0ea01 mypy: Introduce query variable in lib/users.py for clarity.
This also avoids mypy showsing an error.
2018-03-23 11:32:00 -07:00
Tim Abbott
0b3b363cd8 zilencer: Fix buggy RemotePushDeviceToken __str__.
Caught by mypy!
2018-03-23 11:30:50 -07:00
Eeshan Garg
9286a97c7f webhooks/gitlab: Stop filtering comments when description is null.
We filter out hidden comments out of Issue descriptions but this
breaks when description is null (which is unusual). So this commit
just checks to see if the description is None and if so, not to
filter anything out.
2018-03-23 11:20:21 -07:00
Tim Abbott
62c0d27d1e push_notifications: Handle errors with token reuse.
If an Android token has been used to connect a given device with
multiple Zulip servers, and then is expired, we would 500 in trying to
remove the Zulip-side registration for it, because the code assumed
there was only one such registration.  If a token is no longer valid,
it's invalid for all servers, so the correct fix is to just remove them all.
2018-03-23 11:02:55 -07:00
Tim Abbott
5e4b445649 zilencer: Add __str__ methods for Remote models. 2018-03-23 11:02:51 -07:00
Tim Abbott
f7c563dfcc migrations: Fix 0149_realm_emoji migration for S3 case.
The original migration implementation didn't follow the S3 API correctly.
2018-03-23 10:48:50 -07:00
YJDave
886e77e858 subscription: Fix bug in display email hint popover on hover.
Fixes #8743
2018-03-23 09:55:44 -07:00
YJDave
917b214411 subscription: Improve email-hint popover style. 2018-03-23 09:55:44 -07:00
Tim Abbott
dfb364ecb7 settings: De-duplicate template content for save/discard widgets.
This just uses a simple handlebars template for this repeated block.
2018-03-23 08:25:05 -07:00
Shubham Dhama
c50117418e org settings: Fix unexpected saving of input-text fields on "Enter".
Before this commit when we press enter in the text-input field the
first subsection get saved because a click event is triggered for
the first save button (of first subsection) irrespective of the
location of text input field in the whole form which is expected
as a default behavior of the forms.

The simple fix is to make the button of type "button" and override
action of "enter" in an input field.

More info at https://stackoverflow.com/a/12914700/7418550 and
https://stackoverflow.com/a/7060762/7418550
2018-03-23 07:28:46 -07:00
Shubham Dhama
8304c37dfb org settings: Make each subsection of org-permissions independent.
This makes each subsection of org-permissions independent from the
perspective of saving changes.
All the behavior we have for org-settings are also ultimately
reflected here as well like individual "Save" button for each
subsection, "Discard" button for discarding changes done in a
subsection and appearance of this button only when required.
2018-03-23 07:28:46 -07:00
Shubham Dhama
3b7f045da5 org settings: Extract function to discard changes done in a subsection.
In the new function, property values are handled more carefully i.e.
we first check whether property_name refers to a property values
which we can't get from the value of input elements like we have in org
permissions section for properties like realm_add_emoji_by_admins_only
where we have used dropdown and hence we get a string value but we
expect a true/false (check/uncheck) value.

Also, it is better to trigger a `change` event after changing a value
because we have properties which are dependent on the values of another
settings. Previously we trigger `click` event for checkboxes but
there exist some settings other than checkboxes like dropdown
for realm_create_stream_permission where realm_waiting_period_threshold
only appears after selecting custom values for threshold value from
dropdown.
2018-03-23 07:28:46 -07:00
Aastha Gupta
f900f955c0 message edit: show spinner on topic change.
On clicking the checkbox in topic edit form, display a spinner and
hide the cancel icon.  Also, do not display any success message.

Fixes #8793.
2018-03-23 07:21:22 -07:00
YJDave
c786413178 custom profile data: Remove up/down spin button from integer field. 2018-03-23 07:12:35 -07:00
YJDave
f4d660dee4 custom profile data: Change size of textarea input field. 2018-03-23 07:12:10 -07:00
YJDave
ea8af14a44 custom profile data: Remove placeholder for input fields. 2018-03-23 16:27:52 +05:30
Priyank
603dc4a2ef electron_bridge: Notify electron app when realm name is updated. 2018-03-22 22:05:44 -07:00
Priyank
f0190fe0b8 electron_bridge: Notify electron app when org avatar is updated. 2018-03-22 22:05:12 -07:00
Cynthia Lin
93f732406d dark-mode: Darken background color of unread topic/PM counts.
Fixes #8763.
2018-03-22 21:26:15 -07:00
Cynthia Lin
fd486f7839 input-pill: Fix vertically-misaligned PM compose pills.
Fixes #8775.
2018-03-22 21:26:15 -07:00
Cynthia Lin
9d89d0edb6 dark-mode: Change miscolored popover arrow colors.
Fixes #8768.
2018-03-22 21:26:15 -07:00
Cynthia Lin
b7f6dbf44f input-pill: Force words to break to prevent text overflow. 2018-03-22 21:26:15 -07:00
Cynthia Lin
af8271ad0f message-view: Align controls and timestamps to the right on mobile.
Aligning timestamps/controls to the right instead of their original
position on the left increases visual consistensy. Fixes #8110.
2018-03-22 21:26:15 -07:00
sinwar
675e844e6b team page: Add contributors of zulip-terminal.
It adds zulip terminal contributions to
team page using github apis.
2018-03-22 21:06:18 -07:00
sinwar
1ea6bee263 team page: Clean up navbar.
It replace Zulip server with Server and
Javascript API with JS API in navbar.
2018-03-22 21:06:18 -07:00
Tarun Kumar
59b1f59605 user-groups: Add function wrappers to reduce variable scope.
Extract set_up_typeahead function.
Extract pill_remove function.
2018-03-22 16:48:46 -07:00
Tarun Kumar
9969762f01 input_pill: Change user group pills to be same as PM pills.
Fixes #8686.
2018-03-22 16:45:05 -07:00
Tim Abbott
fcd265304c message editing: Fix buggy timestamp check.
This somehow got messed up in a final refactoring before merging
91197fa4f1.
2018-03-22 16:26:18 -07:00
Sarah
91197fa4f1 org settings: Add logic for applying allow_community_topic_editing.
Applies the logic to allow community members to edit topics
of others' messages if this setting is True. Otherwise,
only administrators can update the topic of others' messages.

This logic includes a 24-hour time limit for community topic editing.
2018-03-22 16:13:36 -07:00
Sarah
f5c2fb8438 org settings: Create backend api for allow_community_topic_editing.
Adds the code for updating the allow_community_topic_editing
setting.
2018-03-22 16:02:27 -07:00
Sarah
ecd75ccba6 models: Add allow_community_topic_editing setting. 2018-03-22 16:02:24 -07:00
Tim Abbott
08a6271b54 update-authors-json: Improve error handling for duplicate commits.
It's possible that a user with duplicate commits might not be in the
top 100 users for a given repo.
2018-03-22 14:58:13 -07:00
Gooca
91185b7170 Updated source-map-loader to 0.2.3. 2018-03-22 14:43:26 -07:00
Gooca
2b3eb7f541 Updated i18next-xhr-backend to 1.5.1. 2018-03-22 14:43:26 -07:00
Gooca
a9ba630a37 Updated jquery to 3.3.1. 2018-03-22 14:43:26 -07:00
Gooca
a4da724f22 Updated typescript to 2.7.2. 2018-03-22 14:43:26 -07:00
Gooca
f0e49e6cbb Updated webpack-bundle-tracker to 0.3.0. 2018-03-22 14:43:26 -07:00
Anupam-dagar
865480ec42 portico: Fix positioning of "disposable email address" errors.
Modified by tabbott to prevent losing the frontend errors, and make it
more clear which errors are from the frontend vs. backend.

Fixes: #8784.
2018-03-22 14:38:57 -07:00
Jack Weatherilt
8535625341 parse_user_agent: Assert user agent is not None.
This commit asserts that parse_user_agent never returns None. The
RegEx will match any string, so that `match` is never None. This
brings test coverage of lib/user_agent.py to 100%. Changes were also
made in test/test_decorators.py and views/compatibility.py to reflect
that parse_user_agent cannot return None.

Improves: #7089.
Fixes: #8779.
2018-03-22 14:29:29 -07:00
sinwar
66b007acf0 docs: Replace SEND_ALL with ALWAYS_SEND_ALL_HOTSPOTS in hotspots. 2018-03-22 14:28:25 -07:00
Alena Volkova
4accf06cda webhooks/front: Update text and remove screenshots. 2018-03-22 16:25:30 -04:00
Alena Volkova
9ae0cc0a18 webhooks/front: Remove numbers from fixture names. 2018-03-22 16:25:29 -04:00
Alena Volkova
05386f262a webhooks/front: Use a separate function for each event. 2018-03-22 16:25:29 -04:00
Alena Volkova
428e5057f5 webhooks/front: Eliminate unnecessary error handling. 2018-03-22 16:25:29 -04:00
Shubham Dhama
f97cff54aa org settings: Fix casper failing due to check_property_changed. 2018-03-22 12:51:09 -07:00
sinwar
4e277bc4d7 docs: Remove unnecessary lines from oauth docs. 2018-03-22 12:49:06 -07:00
Shubham Dhama
6cdbcfd80c org settings: Refactor check_property_changed.
In this refactor property values are handled more carefully i.e.
we first check whether property_name refers to a property values
which we can't get from the input elements like we do have in org
permissions section for properties like realm_add_emoji_by_admins_only.

Small refactor in property_value_element_refers is to prevent many
return statements on further addition of property names.
2018-03-22 11:44:58 -07:00
Shubham Dhama
393d4d320f org settings: Use same CSS for new saving buttons in all settings.
Generalize the CSS for new subsection changes saving buttons
for all the organization settings sections.
2018-03-22 23:17:13 +05:30
Shubham Dhama
42ee40d1bc org settings: Refactor failed status element to use class.
This changes failed status element to use class
`.admin-realm-failed-change-status` rather than id so that we can use
the same code in `save_organization_settings()` in future to refer to
failed-status element of that section.
2018-03-22 23:17:13 +05:30
Shubham Dhama
22ab571b8f org permissions: Extract logic to complete request data for subsection.
To keep click handler for "save" button clean, we extracted the
the `if` statements where we complete request data for certain fields
which aren't mentioned in `property_types`.
2018-03-22 23:17:13 +05:30
Shubham Dhama
c5696f8008 org permissions: Restructure org-permissions-admin template.
We restructured template to make org-permissions-template have more
separated subsections and so that we can easily apply event handlers
and selectors to their corresponding subsections (there will
be no change in UI).
(This is similar to 8b54b08)
2018-03-22 23:17:13 +05:30
Greg Price
e44a8b8de9 logging: Add a setting to aid manual testing of error-notif changes.
This is nicer than the "For manual testing ..." comment. :-)
Also as a proper setting we can have it control some logging I
added locally while testing my recent changes to pika logging.
2018-03-21 18:03:05 -07:00
Greg Price
fe0f1edddb settings: Fix double negative in LOGGING_NOT_DISABLED.
Saying "not disabled" just makes it more work to read than it needs to
be -- instead say ENABLED.
2018-03-21 18:03:05 -07:00
Greg Price
73559e5320 queue: Suppress error mail from brief rabbitmq downtimes.
Details in comment.  Together with a few previous commits, this should
completely eliminate sending error mail to admins when the RabbitMQ
server is simply restarted and comes back up normally.
2018-03-21 18:03:05 -07:00
Jack Weatherilt
d857f26cd3 refactoring: Remove unused assignment on ensure_stream.
There were two instances of `ensure_stream` being called and assigned to
a variable with the variable not being used elsewhere. pyflakes picked
up on this (where it didn't in the previous version likely due to tuple
unpacking), so the the variable assignment has been replaced with a call
to `ensure_stream`.
2018-03-21 16:47:52 -07:00
Jack Weatherilt
3396cfc2ef refactoring: Replaced occurences of create_stream_if_needed.
Issue #2088 asked for a wrapper to be created for
`create_stream_if_needed` (called `ensure_stream`) for the 25 times that
`create_stream_if_needed` is called and ignores whether the stream was
created. This commit replaces relevant occurences of
`create_stream_if_needed` with `ensure_stream`, including imports.

The changes weren't significant enough to add any tests or do any
additional manual testing.

The refactoring intended to make the API easier to use in most cases.
The majority of uses of `create_stream_if_needed` ignored the second
parameter.

Fixes: #2088.
2018-03-21 16:47:36 -07:00
YJDave
11c995b70f custom profile data: Send event to active user on update.
On update of custom profile fields, send an event to all
active users of realm.
2018-03-21 16:08:12 -07:00
YJDave
82c8d43209 custom profile data: Enable user to edit custom field's value in settings.
This will enable user to edit the value of custom fields from
user settings.
2018-03-21 16:08:12 -07:00
YJDave
b404d0e156 custom profile data: Set custom field's values in user setting page on load.
Set realm custom field's values for current user in user setting page
when page gets load.
2018-03-21 16:08:12 -07:00
YJDave
66f80441ce custom profile data: Add template for custom user profile fields. 2018-03-21 16:08:12 -07:00
YJDave
14fba1b9ed user settings: Move deactivate account setting to the bottom of page. 2018-03-21 16:08:11 -07:00
YJDave
6f1955a78a zerver/tests/test_events: Fix test_custom_profile_fields_events tests. 2018-03-21 16:05:31 -07:00
YJDave
6ac687790c populate_db: Remove the test_suite check for custom profile fields.
To ensure that we have some basic data for custom profile settings,
in the `populate_db` data set, remove `options['test_suite']` check
for adding intial custom profile data.
2018-03-21 16:05:31 -07:00
Steve Howell
a110736584 Use do_backfill() in start_backfilling_messages().
This change mostly de-duplicates code, but it also prevents
some unnecessary backfills if you're in the home view and
happen to scroll back while the idle loop is right in the middle
of a backfill fetch, or if the idle loop has taken you back
to the oldest message already.  This is a consequence of
do_backfill() calling msg_list.fetch_status functions.

Everything else should work pretty much the same, since
do_backfill() computes anchor essentially the same way we
originally doing it in the onIdle() function.
2018-03-21 14:07:00 -07:00
Steve Howell
7242fa8eb8 message_fetch: Extract do_backfill().
This slightly changes the order of operations of what we do in
the `cont` callback, so that we update fetch status earlier.
The order is somewhat arbitrary here, but we generally want to
update data structures first.
2018-03-21 14:07:00 -07:00
Steve Howell
e8bc781fd5 Use message_list.all for backfill anchor for home view.
The "all" list and "home" list are basically kept in sync, and
the former is a superset of the latter.

Whenever we are backfilling, we want to backfill "all", so we use
it as the anchor, even though home_msg_list is the message list
we are actually rendering.
2018-03-21 14:07:00 -07:00
Steve Howell
f524a095a2 refactor: Extract message_fetch.get_backfill_anchor().
This is just moving code.
2018-03-21 14:07:00 -07:00
Aditya Bansal
2a2df0ef5e auth: Make redirects to next work for REMOTE_USER based Apache SSO.
It's possible that this won't work with some versions of the
third-party backend, but tabbott has tested carefully that it does
work correctly with the Apache basic auth backend in our test
environment.
2018-03-21 14:01:05 -07:00
Aditya Bansal
b62bdde303 login_redirects: Make redirects to narrows from login page work. 2018-03-21 13:35:44 -07:00
Aditya Bansal
1e48dac8f3 auth.py: Make redirects to 'next' url work for google and github.
In this commit we start to support redirects to urls supplied as a
'next' param for the following two backends:
* GoogleOAuth2 based backend.
* GitHubAuthBackend.
2018-03-21 13:35:44 -07:00
Aditya Bansal
9a100b1f55 auth.py: Make redirects to 'next' url work for dev environment.
This makes these redirects work for the local authentication
backend.
2018-03-21 13:35:44 -07:00
Aditya Bansal
1d4e4d0411 test_auth_backends: Add next='' in data dicts for subdomain login tests. 2018-03-21 13:35:44 -07:00
Tim Abbott
1e7dc70c7f reactions: Fix the hotkey for adding an emoji reaction.
This was incorrectly migrated in
a49655e0d4a868d3973e53cf8482b91aa2df1bb1; the toggle_emoji_reaction
function didn't expect this type.
2018-03-21 13:26:24 -07:00
Harshit Bansal
64372690f9 emoji: Fix the filtering condition in check_emoji_admin().
This commit fixes an unreported bug which if hadn't been fixed would
have caused errors while deactivating realm emojis in some corner
cases.
2018-03-20 22:24:44 -07:00
Harshit Bansal
a49655e0d4 emoji: Migrate realm emoji to be addressed by id rather than name.
This commit migrates realm emoji to be addressed by their `id` rather
than their name. This fixes a long standing issue which was causing
an error on uploading an emoji with same name as a deactivated realm
emoji.

Fixes: #6977.
2018-03-20 22:24:44 -07:00
Puneeth Chaganti
7bda069ced vagrant: Graciously fail when vagrant user can't write to /srv/zulip.
Fixes #1410.
2018-03-20 22:20:50 -07:00
Puneeth Chaganti
7929bf5c76 Don't replace the DEFAULT_SERVER_URL unless required
Trying to replace the string on newer versions of vagrant fails with a
'RuntimeError: can't modify frozen String' error. On newer versions of Vagrant,
the server URL is correct already.
2018-03-20 22:11:00 -07:00
Shivam Gera
a3bb819e4c docs: Fix broken link in features advertisement.
This adds a missing /keyboard-shorcuts to the /help/ link in the
Keyboard shorcuts section.
2018-03-20 22:05:48 -07:00
Gooca
2363c9955a ui scrollbar: Update perfect-scrollbar to 1.3.0.
Update perfect-scrollbar to fix stutter space-scrolling in #8544. Also
reworked deprecated `element.perfectScrollbar` to `new
PerfectScrollbar(element)`.  Lastly, updated provision version and
changed node module path to new path.

This also refactors perfect-scrollbar in help.js to work with updated
version of perfect-scrollbar. Because the update also changed
perfect-scrollbar's css selectors for all scrollbars in zulip, we
update those too.

Fixes #8544.
2018-03-20 21:59:11 -07:00
knovokresch
a021485b2e copy_and_paste.js: Support copying recipient headers from several topics.
Algorithm for copying messages from serveral topics was changed:
 - if there are selected messages from more than 1 recipient block
   then the recipient bar headers are copied;
 - If there are multiple messages from only one recipient block
   then recipient bar header is not copied.
Fixes #7217.

Also adds a full suite of Casper tests for the copy-paste functionality.
2018-03-20 21:56:05 -07:00
knovokresch
cdd3b816bf copy_and_paste.js: Extract method for constructing recipient header. 2018-03-20 21:55:01 -07:00
knovokresch
2320a38a9c copy_and_paste.js: Extract method for constructing div with copied text. 2018-03-20 21:55:01 -07:00
Tim Abbott
b94a24ffe3 reactions: Fix buggy migration for realm emoji.
The original implementation of this migration had a highly unfortunate
bug that would result in it deleting all reactions to realm emoji on
the server; we missed this in review, so essentially all historical
realm emoji reactions on chat.zulip.org were lost :(.

We both correct the problem, and also add logging of the deleted rows
that would help should anything be deleted erroneously.
2018-03-20 21:50:47 -07:00
Greg Price
2a178b52fb logging: Suppress error mail from routine pika connection failures.
In some environments, these exceptions happen regularly on upgrading
Zulip.  They're harmless because we reconnect, so avoid complaining
noisily about them.
2018-03-20 16:49:05 -07:00
Greg Price
3b3154527f queue: Don't blow up when a connection closes quickly. 2018-03-20 16:49:05 -07:00
Greg Price
9dcc436766 queue: Fix __init__ logic so heartbeat choice works fully.
Because the base class's __init__ calls `_connect`, when we set the
value after that call has already returned, our new value only takes
effect if the first connection fails and we have to reconnect.
Make it take effect from the beginning.
2018-03-20 16:49:05 -07:00
Greg Price
5edc26a0df queue: Cut disused, broken parameter to _connect.
This parameter isn't used anywhere.  A good thing, because if it were,
the code would immediately raise an exception -- `self._on_open_cbs`
hasn't been initialized yet when we first call `_connect`, from the
base class's `__init__`.

So, just cut it.  If we later need something like this, it's easy to
add a working version then.
2018-03-20 16:49:05 -07:00
Steve Howell
4edf66f927 Track fetch status of initial home message load.
This has a small stylistic change.  The load_more function
is recursive, and we now early-exit when the recursion is
finished (i.e. when we've found the newest row).
2018-03-20 15:23:29 -07:00
Steve Howell
df4d325d6c Extract start_backfilling_messages(). 2018-03-20 15:23:29 -07:00
Steve Howell
c282b94bab Track fetch status for initial narrow. 2018-03-20 15:23:29 -07:00
Steve Howell
0169a06f99 stream_data: Fix traceback with opening the compose box.
We need to call update_calculated_fields earlier since we
use can_access_subscribers in user_is_subscribed.
2018-03-20 15:23:29 -07:00
Tim Abbott
51018e12f5 message_edit: Remove obsolete block for diff highlighting.
We disabled the original "colorized HTML edit-history" feature way
back in 2013 in c51056ff8e.

That original feature involved showing what had been edited inline in
message bodies, so one could easily see what had been changed.

That old feature has since been replaced with the "view edit history"
menu option, and we're unlikely to ever want the old feature back.
So, we can just remove its code.  There's a few supporting variables
that were created to help implement this; we can clean those up and
simplify the `update_message` code now that this feature is fully
removed.
2018-03-20 15:22:53 -07:00
Shubham Dhama
679941b319 compose: Fix "compose fade" not working when private message focused.
The problem was that we now have pills instead of emails in the compose
recipient box for private messages.
Fixes: #8755.
2018-03-20 15:09:47 -07:00
Akash Nimare
64bca56747 docs: Update screenshot tools. 2018-03-20 15:05:28 -07:00
Priyank
b8840108bb yarn: Update broken yarn lockfile.
This commit fixes currupted yarn lockfile, which generated this warning:
```
warning Lockfile has incorrect entry for "d3-queue@2". Ignoring it.
warning Lockfile has incorrect entry for "inherits@2". Ignoring it.
warning Lockfile has incorrect entry for "request@2". Ignoring it.
warning Lockfile has incorrect entry for "rimraf@2". Ignoring it.
```
2018-03-20 14:55:11 -07:00
Shubham Dhama
9ca335bcb2 org settings: Add discard button to discard changes for a subsection.
This will reset the changes done in a subsection to the current ones
in page_params.

It will only appear when there are some user-provided changes to be reset.
2018-03-20 14:48:59 -07:00
Shubham Dhama
62f646816d org settings: Show "save" button only when setting is changed.
With this "Save" button is only shown when there are changes in a
subsection. This means if we changed a setting and reverted it back to
original ones, then, "Save" button will get disappear. Hence, we're shown
"Save" when there are some property changes to send to the server.
2018-03-20 14:48:12 -07:00
Shubham Dhama
be0298314a org settings: Make each subsection independent for saving changes.
This makes each subsection(like "Message feed") independent of changes
done in any other subsection and the save button of each subsection
saves the changes done in that subsection only.
2018-03-20 14:48:10 -07:00
Rhea Parekh
d0355f52cb slack importer: Show when files are being downloaded. 2018-03-20 14:42:26 -07:00
Rhea Parekh
e7291148e8 slack importer: Add '/me' in content for specific subtypes. 2018-03-20 14:42:26 -07:00
Nikhil Kumar Mishra
f29a1918f3 hotspots: Add ALWAYS_SEND_ALL_HOTSPOTS in dev_settings.
Replace the local variable SEND_ALL from get_next_hotspots.
Add unit test for the same.
2018-03-19 10:39:43 -07:00
Nikhil Kumar Mishra
a5472ddee7 initial_password: Add unit test for INITIAL_PASSWORD_SALT = None. 2018-03-19 10:36:26 -07:00
Nikhil Kumar Mishra
9e17692d94 markdown: Add unit test for render_tex.
Test for invalid path of Katex.
2018-03-19 10:36:26 -07:00
Nikhil Kumar Mishra
1579f8cb4b messages: Add unit test for get_raw_unread_data.
Add test with 2 messages to the same group PM thread.
2018-03-19 10:36:26 -07:00
Nikhil Kumar Mishra
3b4ff4f75c markdown: Clean render_markdown.
Remove Message is None and not None case as the
render_message_backend passes a fake Message object.
2018-03-19 10:36:26 -07:00
Tim Abbott
1e453981a3 stream settings: Fix exceptions when rerendering subscribers.
If another user subscribed to or unsubscribed from a stream while the
current user was not subscribed, we previously would attempt to
rerender the subscriber counts for that stream, even though they
weren't rendered at all in the first place; this would trigger
blueslip errors from the expectOne() check in this function.

Fixes #8720.
2018-03-19 10:28:24 -07:00
YJDave
2cbfcbb740 subscription: Fix unexpected blueslip warnings on add subscriber.
In stream settings, if user add subscriber to unsubscribed public
stream from `Add` input widget it gives lots of blueslip warnings,
cause user isn't subscribed to public stream.

Fix this by changing condition to `sub.can_access_subscriber` from
`sub.subscribed` in blueslip warning, cause user can access
subscribers in such cases even if not subscribed to stream.

Tweaked by tabbott to make the node tests pass.
2018-03-19 10:24:14 -07:00
gooca
64dac1bb2e Docs: Added "connect the zulip upstream repo" to more places. 2018-03-18 23:02:09 -07:00
Nikhil Kumar Mishra
70ccc30465 management command: Add unit test for MultipleObjectsReturned case.
Verify error on using get_user if server has multiple users with that email.
2018-03-18 22:50:03 -07:00
Cynthia Lin
333b8b095c subscriptions: Use tooltips for stream info hover content.
Fixes #8718.
2018-03-18 19:44:53 -07:00
Harshit Bansal
646700b144 emoji: Start using get_active_emoji() in emoji_name_to_emoji_code(). 2018-03-18 19:34:02 -07:00
Harshit Bansal
23c8da205c models: Extract 'get_realm_emoji_dicts()'. 2018-03-18 19:34:02 -07:00
neiljp (Neil Pilgrim)
f2e8fff221 ifttt: Support topic as preferred alternative to subject.
Fixes #8698.
2018-03-18 19:19:44 -07:00
neiljp (Neil Pilgrim)
2a2549ce9d zapier: Support topic as preferred alternative to subject. 2018-03-18 19:18:34 -07:00
Aastha Gupta
7485461cc6 notifications: Check if localstorage is enabled.
This checks for whether local storage is enabled and if it
is not enabled, then it will skip checking the value of
"dontAskForNotifications" key in the local storage.

This should eliminate an occasional JavaScript traceback we were
seeing in production.

Fixes #8721.
2018-03-18 12:54:11 -07:00
Tim Abbott
500fa9d2c1 webhooks: Improve explanation of setting specific topics. 2018-03-18 10:53:45 -07:00
Eeshan Garg
8fbd8c68f4 webhooks: Update macros to specify custom topics and default PMs.
These changes are the result of migrating to
check_send_webhook_message.
2018-03-18 10:53:45 -07:00
Eeshan Garg
857569cbf7 webhooks/teamcity: Use check_send_webhook_message.
For a personal build, the teamcity webhook still sends a private
message using check_send_private_message since a personal build
should never trigger a public notification.

For a non-personal build, check_send_webhook_message is used,
which can either send a PM or a stream message based on whether
a stream is specified in the webhook URL or not.
2018-03-18 10:44:09 -07:00
Eeshan Garg
3dafbfa5f4 webhooks/beeminder: Use check_send_webhook_message and update docs.
We now only give users two options, to specify a stream and receive
public notifications for their goals, or to leave it out and receive
PMs and thus, keep their goals private. This simplifies the docs!
2018-03-18 10:44:09 -07:00
Eeshan Garg
a4bdd5b98c tests: Add unit test for get_user_profile_by_email.
This lost test coverage once beeminder was migrated to use
check_send_webhook_message.
2018-03-18 10:44:09 -07:00
Cynthia Lin
ae080287ad subscriptions: Prevent long stream names from overflowing header area. 2018-03-18 10:25:13 -07:00
Cynthia Lin
149cc01ccf dark-mode: Change grey color of .subscriber-count and .message-count.
The original code featured a broken selector for .message-count. Instead
of using the right selector, the color selectors are removed altogether
for better contrast in dark mode.
2018-03-18 10:25:13 -07:00
Cynthia Lin
41bfeef633 subscriptions: Fix broken color property for .mute-note.
Instead of changing the property to color, we use opacity for dark mode
compatibility.
2018-03-18 10:25:13 -07:00
Cynthia Lin
01a7e86ac6 subscriptions: Remove obsolete CSS class. 2018-03-18 10:25:13 -07:00
Shubham Dhama
b34b8cdb97 hotspots: Fix real-time sync for dismissing hotspots.
This closes all the hotspots which aren't included in the event.hotspots.
This means we treat all the hotspots in event.hotspots as the hotspot
which need to be shown.

Fixes: #8690.
2018-03-18 10:22:09 -07:00
Shubham Dhama
120ebc8f13 hotspots: Move the code for closing hotspot icon to hotspots.js. 2018-03-18 10:22:09 -07:00
neiljp (Neil Pilgrim)
e58534022e mypy: Re-annotate capture_and_throw in terms of ViewFuncT.
Requires addition of a type ignore.
2018-03-17 23:25:05 +00:00
neiljp (Neil Pilgrim)
2ed6da77c7 mypy: Rewrite some middleware annotations to use ViewFuncT. 2018-03-17 23:25:05 +00:00
Greg Price
22071a44a7 antispam: Add a sitewide ratelimit on invites by new realms.
This applies only on a server open for anyone to create a realm.
Moreover, if the server admins have granted any given realm a
max_invites greater than the default, that realm is exempt too.
2018-03-16 18:00:11 -07:00
Greg Price
dc1eeef30a antispam: Make a setting for default Realm.max_invites.
This makes this value much easier for a server admin to change than it
was when embedded directly in the code.  (Note this entire mechanism
already only applies on a server open for anyone to create a realm.)

Doing this also means getting the default out of the database.
Instead, we make the column nullable, and when it's NULL in the
database, treat that as whatever the current default is.  This better
matches anyway the likely model where there are a few realms with
specially-set values, and everything else should be treated uniformly.

The migration contains a `RenameField` step, which sounds scary
operationally -- but it really does mean just the *field*, in
the model within the Python code.  The underlying column's name
doesn't change.
2018-03-16 18:00:11 -07:00
Tim Abbott
69a7069ac4 migrations: Fix text version to Custom Emoji.
The fact that we need to do this is basically a Django bug; these
strings aren't used in the database itself.
2018-03-16 17:16:18 -07:00
Tim Abbott
791953963b check-capitalization: Include banned words in overall output.
This locks down the ban on use of "Realm" in translated strings in the
codebase.
2018-03-16 16:59:02 -07:00
Tim Abbott
9dcc2781ac models: Rename realm emoji to custom emoji. 2018-03-16 16:59:02 -07:00
Tim Abbott
c3f94fa388 stream_create: Fix use of "realm" in an error string. 2018-03-16 16:59:02 -07:00
Tim Abbott
209c813424 decorator: Improve error message for a deactivated organization. 2018-03-16 16:59:02 -07:00
Tim Abbott
0e5c954393 users: Fix error string for disposable email addresses.
This should not use the term "realm", and doesn't need to name the
organization, either.
2018-03-16 16:59:01 -07:00
Tim Abbott
149f3efe5a realm: Clean up use of "Realm" in more user-facing strings.
We should be talking about organization names.
2018-03-16 16:59:01 -07:00
Tim Abbott
8e334b0f64 check-capitalization: Exclude certain uses of the word "realm".
Uses that are actually a variable name don't make sense to exclude.
2018-03-16 16:58:49 -07:00
Tim Abbott
c147d2e140 notifications: Fix missed-message emails for presence-idle users.
This fixes an unpleasant regression in
f5edeb01ae, where we stopped correctly
filtering users who have an open browser session that's idle.  These
users are tagged as "UserPresence.IDLE" with an current timestamp in
the database, and should be treated as idle for presence purposes.

As a result, if you had an open Zulip browser session, you incorrectly
wouldn't get missed-message emails for PMs and mentions before this fix.
2018-03-16 16:30:23 -07:00
Tim Abbott
34e165c100 webhooks: Fix passing client string to authenticated webhook API views.
This fixes a regression in 93678e89cd
and a4979410f9, where the webhooks using
authenticated_rest_api_view were migrated to a new model that didn't
include setting a custom Client string for the webhook.

When restoring these webhooks' client strings, we also fix places
where the client string was not capitalized the same was as the
product's name.
2018-03-16 15:43:19 -07:00
Eeshan Garg
a4979410f9 webhooks: Migrate most integrations to use check_send_webhook_message.
This commit migrates all of our webhooks to use
check_send_webhook_message, except the following:

beeminder: Rishi wanted to wait on this one.
teamcity: This one is slightly more work.

yo: This one is PM-only. I am still trying to decide whether we
    should have a force_private argument or something in
    check_send_webhook_message.

facebook: No point in migrating this, will be removed as part of
          #8433.

slack: Slightly more work too with the `channel_to_topics` feature.
       Warrants a longer discussion.
2018-03-16 19:23:50 -02:30
Eeshan Garg
a1e3c91213 webhooks: Delete duplicate statuspage.io fixtures from GCI.
These fixtures were submitted by a GCI student but then another
student wrote the webhook from scratch anyway.
2018-03-16 19:12:09 -02:30
Tim Abbott
a3e60ed3b4 docs: Update setup docs for postgres extensions.
Fixes #8494.

Further work is required to properly support newer Ubuntu.
2018-03-16 13:45:13 -07:00
Shubham Dhama
610f2cbacf notification email: Send followup_day2 email two days later.
This changes the followup_day2 emails delay from one day later to two days
later if it is getting delivered on any working days(i.e. Mon - Fri).
For Thursday it is compromised to next day as it would be too late to
postponed to Monday and for Friday it should be Monday.
At last actually, emails should send one hour before the above calculated so
that user can catch them when they are dealing with these kinds of stuff.
Fixes: #7078.
2018-03-16 13:35:57 -07:00
neiljp (Neil Pilgrim)
5f7f2d6e76 mypy: Remove type: ignore from check_url test, as is now true Validator. 2018-03-16 13:30:32 -07:00
neiljp (Neil Pilgrim)
5726d26d50 mypy: Use centralized Validator in request.pyi & validator.py.
These changes are in one commit, since the previous typing of check_url
does not match the centralized strict definition (object/Any vs Text),
actually already used elsewhere in validator.py, and also had a different
API.

check_url is updated here to match the API of the other check_* functions,
ie. val is an object (not Text) & returns Optional[str]. It also now checks
the value is text explicitly at run-time, which was only type-checked
previously. Tests are updated accordingly.
2018-03-16 13:30:32 -07:00
Tim Abbott
8a53e83cf6 help: Use more consistent module name for perfectScrollbar.
The `Ps` alias that we were using previously was potentially confusing
and made this usage harder to grep for.
2018-03-16 12:50:33 -07:00
gooca
591624972e Refactor perfect-scrollbar: Call ui methods in stream_list.js. 2018-03-16 12:47:47 -07:00
gooca
26eb60b382 Refactor perfect-scrollbar: Call ui methods in topic_list.js. 2018-03-16 12:47:46 -07:00
gooca
336d81ca4a Refactor perfect-scrollbar: Call ui methods in resize.js. 2018-03-16 12:47:46 -07:00
gooca
a50054bdc1 Refactor perfect-scrollbar: Call ui methods in scroll_bar.js. 2018-03-16 12:47:46 -07:00
gooca
ba05ac5c77 Refactor perfect-scrollbar: Call ui methods in emoji_picker.js. 2018-03-16 12:47:44 -07:00
YJDave
0281079a39 stream settings: Send all private streams subs to realm admins on load.
Tweaked by tabbott to simplify the conditionals in actions.py.

Fixes #8695.
2018-03-16 12:26:56 -07:00
YJDave
72a440a86d stream settings: Fix error in real time sync in subs add/remove event.
Currently, when other private stream subscriber add realm admin to
stream, new copy private stream is created in realm admin's streams.
Which resulted in error, cause there are two similar stream element
in stream settings.

If new subscriber is added to private stream, we first send them
stream `create` event, cause private stream are not visible until
user don't get subscribed at least once. But realm admins can now
always access private stream, so when realm admin is subscribed to
stream, realm admin get stream `create` event even if stream already
exist in on realm admin client side.

Fix this by extracting realm admins from stream `create` event on
`add` subscription operation and sending private stream `create`
event to all realm admins on stream creation operation.

Fixes #8695
2018-03-16 12:22:06 -07:00
YJDave
e8f6b9e575 js/stream_edit.js: Remove function to update stream on subs add/remove.
Remove the functions call for updating stream settings UI in
frontend, cause we are already handling this in the subscription
add and remove event we get after successful operation.
2018-03-16 12:22:06 -07:00
Balaji2198
6ffe2cc815 compose: Fix "New Topic" button behaviour auto-populates the current topic.
Previously, Clicking a "New Topic" in a topic narrow auto-populates
the current topic.

Fixes #8608.
2018-03-16 12:01:24 -07:00
Steve Howell
12509515ae message_viewport: Call set_message_offset() for prepending.
This is consistent with other places in the code.
2018-03-16 11:44:20 -07:00
Steve Howell
58c1427859 message_fetch: Use found_oldest flag from server.
We now use the found_oldest flag from the server to determine
whether we should load older messages.

This requires us to change a few places in the code where we
pass the whole payload around now instead of just the messages.

Actually, many of the "cont" callbacks don't even look at the
data, so this change wasn't as invasive as I might have
predicted.
2018-03-16 11:42:52 -07:00
Eeshan Garg
93678e89cd webhooks: Migrate 14 webhooks to use check_send_webhook_message.
These are the straightforward ones.

Note that there is a line in zerver.lib.test_classes.build_webhook_url
that lost test coverage. That's because most of our tests test using
stream messages so the webhook URLs being tested always have a query
parameter. So the line that accounts for there being no query
parameters never gets called, which is fine, but we should still
keep it.
2018-03-16 11:34:20 -07:00
Eeshan Garg
af56df7723 webhooks: Enable custom topics and default PM notifications.
This commit adds a generic function called check_send_webhook_message
that does the following:
* If a stream is specified in the webhook URL, it sends a stream
  message, otherwise sends a PM to the owner of the bot.
* In the case of a stream message, if a custom topic is specified
  in the webhook URL, it uses that topic as the subject of the
  stream message.

Also, note that we need not test this anywhere except for the
helloworld webhook. Since helloworld is our default example for
webhooks, it is here to stay and it made sense that tests for a
generic function such as check_send_webhook_message be tested
with an actual generic webhook!

Fixes #8607.
2018-03-16 11:34:20 -07:00
Tim Abbott
707af5ab56 cache: Remove a now-unnecessary TODO.
We solved the problem the TODO raised by using a different type
annotation syntax, and I'm not sure whether that refactor would
actually improve the code.
2018-03-16 11:32:14 -07:00
neiljp (Neil Pilgrim)
966ca7015f mypy: Finalize migration of cache.py to python3 function annotation.
- Use forward declarations of some types from models.py to avoid cycles.
- Remove cache.py from linter rule exclude list to ensure it stays that way.
2018-03-16 11:29:12 -07:00
neiljp (Neil Pilgrim)
005cb6bd03 mypy: Improve [get_]cache_with_key typing & use py3 annotation. 2018-03-16 11:29:12 -07:00
neiljp (Neil Pilgrim)
bf4dce2a7b mypy: Use centralized Validator definition from types.py in models.py. 2018-03-16 11:16:38 -07:00
neiljp (Neil Pilgrim)
b79c3840da mypy: Introduce strict definition of Validator into types.py. 2018-03-16 11:16:38 -07:00
Tim Abbott
99bae7fa5d slack import: Improve algorithm and formatting for attachments.
The previous system would crash with some files (because for some
reason the comment count was 1 but there was no "initial comment") and
also the file comment and file name were sorta redundant.
2018-03-16 11:12:58 -07:00
Rhea Parekh
06071166c7 slack importer: Handle case where attachment download link is not from slack. 2018-03-16 11:12:58 -07:00
Rhea Parekh
6f3c87006b slack importer: Move output folder being extracted from /tmp to var/. 2018-03-16 11:12:58 -07:00
Rhea Parekh
b7d6608ba6 slack importer: Clean 'create_converted_data_files' function.
The 'make_new_dir' bool value was used to create a new directory
every time True is passed. Now that avatars and uploads directory
are being created seperately, we don't need this anymore.
2018-03-16 11:12:58 -07:00
Rhea Parekh
4b66a2d0dc slack importer: Add function to fetch and save uploads. 2018-03-16 11:12:58 -07:00
Rhea Parekh
e62945eb86 slack importer: Implement changes in script due to zerver_attachment. 2018-03-16 11:12:58 -07:00
Rhea Parekh
8e2d930644 slack importer: Implement changes in script due to user upload object. 2018-03-16 11:12:58 -07:00
Rhea Parekh
b0851eb20b slack importer: Add helper functions to build attachment object. 2018-03-16 11:12:58 -07:00
Rhea Parekh
68af6e4b7a slack importer: Add helper functions to build user uploads object. 2018-03-16 11:12:58 -07:00
Steve Howell
9105692b07 Add typing.initialize() to prevent tracebacks.
We now wait to start typing notifications until everything else
is initialized.  This prevents traceback where things like compose
pills have not been initialized.
2018-03-16 09:23:23 -07:00
Rhea Parekh
6d85f8c9ef slack importer: Randomize stream colors. 2018-03-15 23:50:32 -07:00
Rhea Parekh
90a3ffc5c0 slack importer: Include only slack's purpose field in description. 2018-03-15 23:50:32 -07:00
Rhea Parekh
8a4f307c43 slack importer: Change topic for imported content. 2018-03-15 23:50:32 -07:00
Greg Price
4139e6c763 reactions: Fix migration to correctly handle corner case.
If an emoji that was deleted was the only realm emoji, or more
generally if all realm emoji were deleted, then we would just leave
the reaction unchanged, with an `emoji_code` that is now corrupt.

Instead, treat this case the same as if only this emoji was deleted
while others remain.
2018-03-15 18:53:51 -07:00
Tim Abbott
ec21997bfe slack import: Fix importing of bot users from Slack. 2018-03-15 18:35:40 -07:00
Rhea Parekh
a5b0957e5d slack importer: Set domain name in 'do_convert_data'.
The domain name is being set in the helper function
'slack_workspace_to_realm', but it should be set in the main function
'do_convert_data', as we need it in other child functions of
'do_convert_data'.
2018-03-15 18:34:51 -07:00
sreenivas alapati
a2fa087235 attachments_ui: Remove unnecessary export of bytes_to_size. 2018-03-15 18:06:04 -07:00
Tim Abbott
14e8ac5675 migrate: Remove dead migration code.
This code was originally written when we were using the old South
system, and hasn't been used in a few years.  It probably doesn't
work, and thus only serves to clutter the codebase.
2018-03-15 17:56:32 -07:00
Shubham Padia
4fb1704e6e settings: Add save instructions below pill container on changes.
Fixes #8088.
2018-03-15 17:29:12 -07:00
Shubham Padia
dd5ce49ce0 settings: Add button to cancel user group auto save on blur.
Clicking the cancel button removes all the changes and the user
group returns back to the original state. Saved button is showed
once the changes are saved on blur.
2018-03-15 17:29:12 -07:00
Shubham Padia
40d6ee54ca settings: Move user group delete button to top right corner.
Also replaces trash icon with "Delete" for the button.
2018-03-15 17:29:12 -07:00
Shubham Padia
28f0ac2e14 settings: Save user group name/desc changes along with member changes.
Add do_not_blur func to not save changes when blur event's origin
is one of name/description/pill input from the current user group.
Changes in any of name/desc/members are saved together on blur from
any of the input field given do_not_blur is false.
2018-03-15 17:29:12 -07:00
Shubham Padia
9aec2b8b74 settings: Auto save user group members on blur.
Auto saves group members if focus moves from the input field in the
pill container.
2018-03-15 17:29:12 -07:00
Shubham Dhama
8b54b08064 org settings: Restructure org-settings-admin template.
This restructures the organization-settings-admin template into
different subsections. With this, we can easily limit the scope of
event handlers and selectors within their subsection to which
are applied.
There will be no change in UI because of this.
2018-03-15 17:06:45 -07:00
Shubham Dhama
c4fda0e19e org settings: Extend populate_data_for_request for selected property types.
To populate data for requests limited to only selected input elements,
we have to extend `populate_data_for_request` for objects other
than `property_types`, e.g. now we can collect data only for user identity
by passing org_permissions.user_identity as changing_property_types.
2018-03-15 17:06:45 -07:00
Shubham Dhama
c4d0fb602c org settings: Split property_types according to sections.
This splits property types according to sections in
"Organization settings" viz. Organization settings, Organization
permissions, and Organization profile. Where org. settings and
org. permissions are further categorized according to the
subsections.
These changes are made to save changes for each subsection independently.
2018-03-15 17:06:45 -07:00
Shubham Dhama
0bd5a7cf29 settings_ui: Extend do_settings_change for other request methods also.
With this, we need to send channel request method callback as an
argument while calling.
2018-03-15 17:06:45 -07:00
Shubham Dhama
01a160de5e settings_ui: Extend do_settings_change for other optional parameters.
This extends `do_settings_change` function for parameters like
`success` and `error` functions which will replace the default ones,
for functions that need to be excuted in success callbacks and for
desired success message.
All these parameters are optional.
2018-03-15 17:06:45 -07:00
Tim Abbott
c89ae4ef39 stream settings: Improve strings in traffic level section. 2018-03-15 16:47:09 -07:00
Tim Abbott
242f6d67b3 stream settings: Show subscriber counts unconditionally. 2018-03-15 16:47:09 -07:00
Nikhil Kumar Mishra
ae7fe85ec5 stream settings: Improves visual appearance of "subscriber counts".
Fixes #8660.
2018-03-15 16:47:08 -07:00
amanagr
301a28e58e docs: Add user guide for Zulip in a Terminal.
Text tweaked by tabbott.

Fixes #3361.
2018-03-15 15:13:05 -07:00
Tim Abbott
68f816bba1 forms: Fix missing translation tag for disposable emails. 2018-03-15 14:43:40 -07:00
Vishnu Ks
c385fcefa8 templates: Fix translation tag for disposable email tooltip. 2018-03-15 14:35:24 -07:00
Vishnu Ks
b13150a438 models: Do the check for disposable email in email_allowed_for_realm. 2018-03-15 14:35:24 -07:00
Vishnu Ks
951b88dd30 models: Make email_allowed_for_realm raise exception. 2018-03-15 14:35:24 -07:00
Vishnu Ks
1df2ed4c68 models: Remove unused GetRealmByDomainException,. 2018-03-15 14:35:24 -07:00
neiljp (Neil Pilgrim)
88046f815a mypy: Rewrite zulip_login_required annotations in terms of ViewFuncT. 2018-03-15 14:33:56 -07:00
neiljp (Neil Pilgrim)
8edb47e212 mypy: Fully use ViewFuncT in decorators.py; remove WrappedViewFuncT.
Many declarations were previously annotated with
Callable[..., HttpResponse]; this is equivalent to ViewFuncT, so here we
switch to it.

To enable this migration, the WrappedViewFuncT alias is removed; this is
equivalent to the simple & legible Callable[[ViewFuncT], ViewFuncT], so
for relatively no space change, a clearer return type is possible.
2018-03-15 14:33:56 -07:00
neiljp (Neil Pilgrim)
a8f7a49e7b mypy: Apply type: ignore to api decorator tests. 2018-03-15 14:33:56 -07:00
neiljp (Neil Pilgrim)
e30ba19b79 mypy: Apply type: ignore to api_github_webhook_dispatch calls. 2018-03-15 14:33:56 -07:00
neiljp (Neil Pilgrim)
31dce7c87c minor: Request parameter should be of type HttpRequest. 2018-03-15 14:33:53 -07:00
neiljp (Neil Pilgrim)
80a7c16baf minor: Remove unused WrapperT from zerver/decorator.py. 2018-03-15 14:33:28 -07:00
neiljp (Neil Pilgrim)
3dbe772b50 mypy: Migrate some Callable[..., HttpResponse] to ViewFuncT in decorator.py. 2018-03-15 14:33:27 -07:00
neiljp (Neil Pilgrim)
17937175ac mypy: Centralize ViewFuncT definition into new file zerver/lib/types.py.
Originally was going to centralize this in zerver/lib/request.pyi, but this
file is not visible at run-time, being only a stub. The matching request.py
file seemed inappropriate, as it doesn't actually use ViewFuncT.
2018-03-15 14:16:40 -07:00
Shubham Dhama
95067ddb08 org settings: Disable "Add filter" button when a request is in transit.
This prevents accidental multiple click requests due to which we get
some errors like "This field cannot be blank" (though we have successfully
added the desired filter).
Fixes: #8699.
2018-03-15 13:56:15 -07:00
Shubham Dhama
233e1b4b1b org settings: Clear input fields of filter settings on success. 2018-03-15 13:56:15 -07:00
neiljp (Neil Pilgrim)
a3d8cc1f86 Mypy: Migrate tornado/descriptors.py to python3 function annotations.
Use quoted form of ClientDescriptor to break presumed circular dependency,
and modify import statement to shorten quotes.
2018-03-15 12:54:43 -07:00
neiljp (Neil Pilgrim)
a7bfb09067 Mypy: Use models.py QuerySet annotation approach in stream_subscription.py.
Namely, annotate as best as possible, and add notes to indicate preference,
if QuerySet develops generic typing.

Note that the return values of functions with annotations changed in this
commit are used elsewhere as QuerySets, so the Sequence[T] approach used
for some functions in models.py is not applicable.
2018-03-15 12:54:43 -07:00
neiljp (Neil Pilgrim)
ce4ac0d2cf Mypy: Ensure consistency of QuerySet return types in models.py.
Other functions took the form of returning Sequence[T] when the QuerySet
functionality is unused beyond the function, with T being the objects
filtered for in the function body; this commit follows that practice for the
one remaining python2 comment-annotated function, completing the transition
of models.py to py3.5 function annotations.

A note is also added to another function regarding a need to return a
QuerySet, and ideally a QuerySet[T] in line with the other functions, as and
when QuerySet becomes annotated as a generic.
2018-03-15 12:54:43 -07:00
Steve Howell
a4a8527ec5 search: Return info flags in payload.
We now return these:
    anchor
    found_anchor
    found_oldest
    found_newest

Fixes #8639
2018-03-15 12:36:06 -07:00
Steve Howell
c6839e07c0 search: Fix num_after/num_before semantics precisely.
We now post-process query results so that you never get
more than `num_after` rows with id < `anchor`, and likewise
for `num_before`.
2018-03-15 12:36:06 -07:00
Steve Howell
6f3ebf6c4c Add post_process_limited_query(). 2018-03-15 12:36:06 -07:00
Steve Howell
bd95b37d67 search: Make num_after/num_after more consistent.
We now consistently set our query limits so that we get at
least `num_after` rows such that id > anchor.  (Obviously, the
caveat is that if there aren't enough rows that fulfill the
query, we'll return the full set of rows, but that may be less
than `num_after`.)  Likewise for `num_before`.

Before this change, we would sometimes return one too few rows
for narrow queries.

Now, we're still a bit broken, but in a more consistent way.  If
we have a query that does not match the anchor row (which could
be true even for a non-narrow query), but which does match lots
of rows after the anchor, we'll return `num_after + 1` rows
on the right hand side, whether or not the query has narrow
parameters.

The off-by-one semantics here have probably been moot all along,
since our windows are approximate to begin with.  If we set
num_after to 100, its just a rough performance optimization to
begin with, so it doesn't matter whether we return 99 or 101 rows,
as long as we set the anchor correctly on the subsequent query.

We will make the results more rigorous in a follow up commit.
2018-03-15 12:36:06 -07:00
Steve Howell
ec5299b1f2 search refactor: Rename query_result to rows.
The name `query_result` seems to suggest something more complex.
2018-03-15 12:36:06 -07:00
Steve Howell
61a184bf7d tests: Add first_visible_id_as() helper.
This is a purely cosmetic change to avoid long lines.
2018-03-15 12:36:06 -07:00
Tarun Kumar
c8d5cf7d6c user-groups: Achieve 100% node-test coverage of user_groups.js.
Fixes #8704.
2018-03-15 10:09:28 -07:00
Tarun Kumar
dafaf28099 user-groups: Update user_group_name_dict, when name/description is edited.
We do not update user_group_name_dict when name or description is edited,
which may lead to errors if get_user_group_from_name is called, so to fix
that we update user_group_name_dict also.
2018-03-15 10:09:28 -07:00
Eeshan Garg
5c1858e584 webhooks/taiga: Update text to conform to the new style guide.
Note that the "Save" button has no text in the Taiga webhook
setup UI. There is a small floppy disk symbol for saving which
is visible right beside the form fields. So I simply said,
"Save the form".
2018-03-14 18:13:13 -07:00
Eeshan Garg
f89b3fdb1c webhooks/heroku: Update text to conform to new style guide. 2018-03-14 18:13:13 -07:00
Aditya Bansal
d4360e2287 uploads: Make django-sendfile to force downloading attachments.
We start to force downloads for the attachment files. We do this
for all files except images or pdf's. We would like images or pdf's
to open up in browser itself.

Tweaked by tabbott for comment clarity and correctness.
2018-03-14 11:22:10 -07:00
Shubham Dhama
8f4523e8dd compose typeahead: Add all public streams including unsubscribed streams.
This makes it convenient to mention a stream you're not subscribed to,
which can be useful for communicating about where a topic is
discussed, for example.

Fixes: #5757.
2018-03-14 11:10:43 -07:00
Shubham Dhama
342ec0a544 drafts: Add tests for draft formatting and sorting. 2018-03-14 10:57:11 -07:00
Shubham Dhama
5a9b1f863f drafts: Fix same day's timestamp when language is other than english. 2018-03-14 10:57:11 -07:00
Shubham Dhama
7aeae688e7 compose: Remove draft older than 30 days.
This removes drafts older than 30 days as they become irrelevant
for the user. Those drafts are removed before populating them.

Fixes: #7602.
2018-03-14 10:57:11 -07:00
Harshit Bansal
40958e0824 emoji: Switch to 64px 256 color indexed sprite sheets.
This commit switches our emoji infrastructure to use 256 color indexed
64px spritesheets. Earlier we were using non-indexed 32px spritesheets
which were blurry on high dpi displays. These indexed spritesheets not
only provide a crispier display but are also smaller in size.

This commit also removes the `emoji-datasource` package as a dependency
as all the data is now sourced from individual datasource packages.

Fixes: #7862.
2018-03-14 10:28:45 -07:00
Tarun Kumar
81a1612cbd user-groups: Fix reordering when name/description is edited.
The edited group iswas going to the bottom, it is not staying at its
position, so to fix this we sort by ids of the groups to maintain
proper relative order.

(Original commit also fixed another issue, but Tim replaced that with
the previous commit for a better solution).

Fixes #8692.
2018-03-14 10:12:46 -07:00
Tim Abbott
bea9b6a748 user_groups: Fix real-time sync of user groups.
This fixes the user groups UI to follow the Zulip standard mechanisms
(using the appropriate server_events system to update all browsers
properly).  It also, as a side effect, fixes #8692, since it
eliminates the weird behavior of trying to re-insert a user group
after reformatting it in the frontend.

Thanks to Tarun Kumar for preliminary work on this.
2018-03-14 10:12:14 -07:00
YJDave
efffc07351 stream settings: Don't show add-subs-btn if user can't add subscribers.
Even if realm admin can access unsubscribed private stream subscribers,
admin can't add subscriber to stream. Hide the option to add subs to
stream in UI.
2018-03-14 09:21:14 -07:00
YJDave
6226a48355 tests: Use iago user in case of admin in attempt_unsubscribe_of_principal.
In `attempt_unsubscribe_of_principal` function in `test_subs.py`, use
iago user if `is_admin` is true, instead of making the hamlet user
an admin.
2018-03-14 09:21:14 -07:00
Tim Abbott
4d55dc9db5 alerts: Fix z-index of alert panels to be above settings.
I noticed that our nice feature to show JavaScript errors collected by
blueslip in view of users was hidden in the background if you had one
of our settings screens open.

Further investigation determined the same was true for our other
panels.js alerts (e.g. the one for get_events failing, etc.).  This is
easily fixed by just raising the z-index of the alerts panels; I
tested and a variety of our possible alerts look good on top of stream
settings, so no need to do anything special here.

Fixes #8576.
2018-03-14 09:21:14 -07:00
Eeshan Garg
cad422f4b6 webhooks/travis: Update text to conform to doc style guide.
Note that this file runs into the CSS bug addressed in #8433.
2018-03-13 20:15:04 -07:00
Eeshan Garg
71619f7d32 webhooks/insping: Update text to conform to style guide. 2018-03-13 20:12:26 -07:00
Eeshan Garg
5fdb0666dc webhooks/zapier: Update text to conform to doc style guide. 2018-03-13 20:12:26 -07:00
Eeshan Garg
0a3961502f webhooks/ifttt: Update text to conform to doc style guide. 2018-03-13 20:12:26 -07:00
Tim Abbott
1a3ae8a376 stream settings: Fix inadvertently merged broken whitespace.
I'm not sure why the pre-commit linter didn't flag this for me; maybe
it did and I just missed it.
2018-03-13 15:12:45 -07:00
YJDave
93ee0aace7 stream settings: Allow realm admins to remove others from any stream.
This will allow realm admins to remove others from private stream to
which the realm administrator is not subscribed; this is important for
managing those streams, because previously nobody could remove users
from private streams that didn't have any realm administrators
subscribed.
2018-03-13 14:59:09 -07:00
YJDave
2031118545 stream settings: Allow realm admins to access all private stream subs.
This will allow realm admins to access subscribers of unsubscribed
private stream.  This is a preparatory commit for letting realm admins
remove those users.
2018-03-13 14:59:09 -07:00
YJDave
37f9d5c193 stream settings: Allow realm admins to update any stream name & description.
This will allow realm admins to update the names and descriptions of
private streams even if they are not subscribed, which fixes the buggy
behavior that previously nobody could(!).
2018-03-13 14:59:09 -07:00
Steve Howell
1ff653c986 search refactor: Extract limit_query_to_range.
This generic function isolates the before/after logic that really
is independent of Message and doesn't need to clutter up
`get_messages_backend`.  Also, introducing a new namespace
reduces some shadowing/mutation with variables like `query`.

It's a pure code move, with some very minor renaming (e.g.
inner_msg_id_col -> id_col).
2018-03-13 13:51:22 -07:00
Steve Howell
74a4a69333 search refactor: Move code that increments num_after/num_before.
We move the code that increments num_after/num_before to be closer
to where we do all the before/after logic.
2018-03-13 13:51:22 -07:00
Steve Howell
63c21707ee search refactor: Tighten up before/after logic.
If anchor is 0, there is no sense doing a before_query.

Likewise, if anchor is `LARGER_THAN_MAX_MESSAGE_ID`, there is
no sense doing an after_query.

We introduce variables called `need_before_query` and
`need_after_query` to enforce those conditions.

This also adds some comments explaining the fallthrough case
where neither query makes sense.
2018-03-13 13:51:22 -07:00
Steve Howell
129faa2c21 search refactor: Avoid message_id >= 0 in queries.
We don't need things like `AND message_id >= 0` in our queries.

We can short circuit the syntax when `anchor` or
`first_message_visible` are zero.
2018-03-13 13:51:22 -07:00
Steve Howell
e232a0bd57 search refactor: Streamline queries for caught-up users.
If use_first_unread_anchor is set and we don't have any unread
messages, then our anchor is effectively "positive infinity" and
we can streamline queries.

In the past we'd have clauses like `message_id <= 999999999999999`
in the query that were harmless but crufty.
2018-03-13 13:51:22 -07:00
Steve Howell
e77350dc8e search refactor: Replace confusing != 0 idiom in search code.
We want to say `if num_after > 0` when we expect num_after to be
a positive integer.  We don't want any confusion that we will
execute the blocks for values of -7 or None.
2018-03-13 13:51:22 -07:00
Steve Howell
988f28630b search: Add test coverage for corner cases.
With small values of num_after/num_before (0/1), we may be amenable
(good) or brittle (bad) to future optimizations.
2018-03-13 13:51:22 -07:00
neiljp (Neil Pilgrim)
43ff4ea1f7 tools: Ensure mypy is run on .pyi files. 2018-03-13 13:49:39 -07:00
YJDave
3b8c2e45be user settings: Fix user avatar not updated in settings page.
On uploading new avatar, user avatar in settings page doesn't
get updated. Cause we have set `src` attribute of wrong html
element instead of image element in user settings page.

Fixes #8680.
2018-03-13 10:57:36 -07:00
Brock Whittaker
5eccb9f63e components: Add ":focus" styles to button classes.
This gives the ":focus" state the same styling as the ":hover" state
for the standard, ".sea-green" and ".btn-danger" classes.
2018-03-13 10:10:24 -07:00
Brock Whittaker
40316ed343 components: Make "sea-green" button darker.
This makes it a bit darker so it is a bit more visually bold than it was before.
2018-03-13 10:09:08 -07:00
Brock Whittaker
1cb06cb359 organization-settings: Fix organization description textarea style.
This makes the textarea responsive by making the width 100% and
the max-width 500px so that it doesn't get *too* wide.

Please close #8511 when this is merged.

Fixes: #8504.
2018-03-13 09:51:33 -07:00
Tim Abbott
c7b560cdc2 docs: Clarify documentation of remote development environment. 2018-03-13 09:45:37 -07:00
feorlen
4631a2bfc3 Set REALM_HOSTS based on EXTERNAL_HOST if it is available.
Also update remote.md to recommend setting EXTERNAL_HOST in an environment
variable.

Fixes #8670
2018-03-13 09:45:37 -07:00
Rohitt Vashishtha
b22e8dc2b7 lint: Replace 'return undefined;' with 'return;'.
Also adds a custom rule to eslint. Since the recommended way of extending
eslint is to create plugins as standalone npm packages, the separate rule
is published as 'eslint-plugins-empty-returns'.

Fixes #8669.
2018-03-13 08:22:42 -04:00
Lyla Fischer
7ce139a798 user docs: Remove view-messages-containing-files-or-links. 2018-03-12 20:07:17 -07:00
Lyla Fischer
a94325de53 user docs: Move private message information to view-your-pms-and-group-pms. 2018-03-12 20:06:12 -07:00
Lyla Fischer
ffa629bee5 user docs: Merge view-messages-from-a-stream and view-messages-from-a-topic. 2018-03-12 20:06:04 -07:00
Lyla Fischer
e53f334fd6 user docs: Merge add and remove someone from a stream. 2018-03-12 18:14:17 -07:00
Lyla Fischer
835ac3dd85 user docs: Split label for change-the-privacy-of-a-stream. 2018-03-12 18:14:17 -07:00
Lyla Fischer
7912a118bf user docs: Add 'or archive' to label of delete-a-stream. 2018-03-12 18:14:17 -07:00
Lyla Fischer
502264f208 user docs: Merge user restrictions on email address and name. 2018-03-12 18:14:17 -07:00
Lyla Fischer
e396897a06 user docs: Merge docs for organization name, avatar, and description. 2018-03-12 16:53:59 -07:00
Lyla Fischer
9b30fc9bf1 user docs: Add reference to notify-everyone-on-a-stream to notifications. 2018-03-12 16:53:54 -07:00
Lyla Fischer
d85a5562fb user docs: Marge audible-notifications into desktop-notifications. 2018-03-12 16:53:45 -07:00
Tim Abbott
4ae1418831 popovers: Rename confusing my_email to user_popover_email. 2018-03-12 12:24:50 -07:00
Priyank Patel
29c6d23043 user profiles: Add copy-to-clipboard btn for long emails.
Implements copy to clipboard btn that shows up if email is too long.
Making it easier for user to copy long emails.
2018-03-12 12:06:40 -07:00
Priyank Patel
413ea99373 email tooltip: Adjust background color of email toolip in dark-mode.
This commit adjust the email tooltip of popover in dark-mode.
2018-03-12 12:06:40 -07:00
Tim Abbott
8866c23b5e test-backend: Enforce 100% test coverage on models.py.
Following the exclusions and code deletions we just did, we can now
lock down 100% test coverage on zerver/models.py.
2018-03-12 11:52:39 -07:00
Tim Abbott
c63b8983a0 models: Delete legacy convert_bot_to_outgoing_webhook.
We also delete a couple helper functions that were only used there.

This management command was primarily used before we had a UI for
creating outgoing webhook bots.
2018-03-12 11:52:39 -07:00
Tim Abbott
9bd535f914 models: Delete unused UserProfile.is_service_bot.
This function had the wrong format for its use case (in
zerver/lib/actions.py) anyway, since we don't have a full UserProfile
object there.
2018-03-12 11:52:39 -07:00
Tim Abbott
1b744c5c84 models: Add nocoverage for a couple presence code paths.
Both of these we should eventually add test coverage for or delete,
but they're pretty low-value (code paths that don't do anything in
production).
2018-03-12 11:52:38 -07:00
Tim Abbott
c26147538a models: Add comments explaining weird presence conditional.
In theory, we should be able to delete this, since first, if there are
no users in the organization, we'll end up with an equivalent value
(an empty collection of users), and second, it shouldn't be possible
for an active Zulip realm to have 0 active users in it anyway.

But the way we construct the database query in query_for_ids is such
that it's necessary to avoid a 500.
2018-03-12 11:51:47 -07:00
Tim Abbott
d6213c3f82 models: Delete unused function get_realm_outgoing_webhook_services_name.
This was implemented as part of some preparatory work for outgoing
webhooks, but isn't actually used.
2018-03-12 11:40:01 -07:00
Tim Abbott
5f3fa2c6b6 models: Don't require test coverage for clear_database.
This function is only used in populate_db, not at runtime, and is
inefficient to test, since it's main role is deleting everything in
the database.
2018-03-12 11:35:28 -07:00
neiljp (Neil Pilgrim)
ee2b8bfbfb linter: Require Py3 function annotations, with some exceptions.
Main exceptions are scripts/tools/puppet & tests.

Other current exclusions:
- api_test_helpers.py (avoid changing test code);
- cache.py, due to comments in file;
- models.py, due to failure on QuerySet[Message];
- stream_subscription.py, due to failure on QuerySet[Subscription];
- tornado/descriptors.py;
- views/streams.py, due to remaining FuncKwargPair issue;
- zthumbor/, since thumbor is in python2.

Tweaked by tabbott to partially document the stauts in comments.
2018-03-12 11:23:30 -07:00
neiljp (Neil Pilgrim)
9e1dbde82d mypy: Final small migrations to python3.5 annotations in many files. 2018-03-12 11:23:30 -07:00
neiljp (Neil Pilgrim)
34db2e59dd mypy: Migrate templatetags/minified_js.py to python3.5 annotations.
Requires introduction of full Parser & Token dependency for minified_js
function annotation.
2018-03-12 11:23:30 -07:00
neiljp (Neil Pilgrim)
88b3abb464 mypy: Migrate templatetags/app_filters.py to python3.5 annotations. 2018-03-12 11:23:30 -07:00
neiljp (Neil Pilgrim)
aa48929f66 mypy: Minor zthumbor annotation changes.
- Any->Text in helpers.py;
- Remove ignore and add generic params.

revert thumbor except type.
2018-03-12 11:23:30 -07:00
neiljp (Neil Pilgrim)
21033669a8 mypy: Migrate lib/bugdown/__init__.py to python3.5 annotations. 2018-03-12 11:23:30 -07:00
neiljp (Neil Pilgrim)
bb1585b2c2 mypy: Migrate lib/debug.py to python3.5 annotations. 2018-03-12 11:23:30 -07:00
neiljp (Neil Pilgrim)
6b9671c95c mypy: Migrate views/storage.py to python3.5 type annotations. 2018-03-12 11:23:30 -07:00
neiljp (Neil Pilgrim)
6bda59f3d7 mypy: Almost migrate views/streams.py to python3.5 annotations.
One remaining issue with FuncKwargPair use.
2018-03-12 11:23:30 -07:00
Rohitt Vashishtha
3710252eba portico: Prevent Firefox from bfcaching the page.
Firefox stores the last state of the page in its back/forward cache
in memory and uses that for quickly rendering the page. Since our page's
last state was 'faded-out', the content wasn't visible when the browser
rendered the page from it's bfcache.

Fixes #7907.
2018-03-11 22:17:18 -07:00
Vishnu Ks
3da2a1e18d admin: Add a realm setting to disallow signups using disposable emails.
Fixes #2955
2018-03-11 22:05:58 -07:00
Vishnu Ks
a44255eedb emails: Add backend for disallowing disposable email addresses. 2018-03-11 22:05:58 -07:00
Vishnu Ks
41f8618c04 email: Use PyPi module for disposable email providers list. 2018-03-11 21:48:56 -07:00
Aastha Gupta
dc60b3a44b compose: Don't clear compose box on narrow if it matches compose.
If we're entering a topic narrow, and the compose topic is the same as
narrowed topic, then leave the compose box open.

This is important if you open compose in a topic narrow, click on a
narrow, and then use the back button to return to that original
narrow.  Before this change, we'd close the compose box for no reason.

Fixes #6510.
2018-03-11 21:25:23 -07:00
Tim Abbott
25d9731a3c custom profiles: Fix totally broken events.py logic.
Apparently, my manual testing here was in error; the new version
actaully works for delivering custom profile data to the frontend.
2018-03-11 21:25:23 -07:00
Tim Abbott
ef92fcbe2b topic history: Fix fetching topic history of public streams.
Apparently, we did essentially all the work to support showing full
topic history to newly subscribed users from a data flow perspective,
but didn't actually enable this feature by having the topic history
endpoint grant access to historical topics.  This fixes that gap.

I'm not altogether happy with how the code and tests read for this
feature; the code itself has more duplication than I'd like, and the
tests do too, but it works.
2018-03-11 20:59:20 -07:00
Ricky
9e52a9f879 webhooks/flock: Add flock integration. 2018-03-11 20:31:13 -07:00
Tim Abbott
6d8b6bda1a custom profiles: Fix missing mypy annotations. 2018-03-11 19:30:30 -07:00
Tim Abbott
56b1239ad5 populate_db: Include some initial data for custom profile fields.
This is currently only for manual testing; creating these would break
the existing custom profile test suite.
2018-03-11 18:08:17 -07:00
Tim Abbott
02b8453367 custom profiles: Send custom profile data to frontend.
This will fetch the data of custom fields for all users.
2018-03-11 18:08:17 -07:00
Tim Abbott
6d64fd6e08 custom profile data: Provide a clear print statement. 2018-03-11 18:00:29 -07:00
Harshit Bansal
e41067a833 emoji: Refactor bugdown to use only active realm emojis.
This commit refactors the bugdown to perform a lookup only on active
realm emojis. This was needed because once we migrate realm emojis
to be addressed by `id` rather than name, it will be costly to
perform a lookup on all the realm emojis.
2018-03-11 16:24:44 -07:00
Harshit Bansal
089fede9b0 commands: Delete 'realm_emoji' management command.
We no longer accept URLs while creating emoji; so this management
command was probably left out while migrating realm emoji
infrastructure to upload backend.

We could fix this to work properly today, but the command was
originally written in a context when Zulip didn't have a UI for
managing realm emoji at all.  Now that we do have such a UI, it
doesn't have a compelling use case, and work on migrating the realm
emoji schema demonstrates that this does have a maintenance cost.

So, we simply remove this command.
2018-03-11 16:23:20 -07:00
Harshit Bansal
52e5b78613 models: Change text representation for realm emoji.
This commit changes the textual representation for realm emoji to
give more info.
2018-03-11 16:17:47 -07:00
Harshit Bansal
e3c09e0308 settings: Prevent multiple requests while adding custom emoji.
This commit fixes a hard to reproduce issue which was causing
multiple requests while creating a realm emoji.

Fixes: #8475.
2018-03-11 16:17:47 -07:00
YJDave
158f0f3297 stream settings: Fix display of stream subscribers count. 2018-03-11 15:58:18 -07:00
YJDave
b6408a0383 stream settings: Fix sub-unsub btn not showing on private stream creation. 2018-03-11 15:58:18 -07:00
YJDave
ff6d83b2f2 stream settings: Fix subscribers not showing on private stream creation.
Previously, stream subscribers were not rendering correctly. Due to
following reasons:
- Subscribers list didn't get initialized
- Subscriber members template add subscriber-list-table DOM element
  conditionally, which doesn't handle case if user have access to
  subscribers later.

Fix this by cleaning subscriber member template to hide the
elements, instead of conditionally adding DOM elements and
initialize subscribers list even if user can't access subscribers.
2018-03-11 15:58:18 -07:00
Umair Khan
728cd04c4d check-capitalization: Check for banned words.
Fixes #8619
2018-03-11 15:34:47 -07:00
neiljp (Neil Pilgrim)
e322c2161c mypy: Remove need for cast by using ConcreteQueueWorker TypeVar. 2018-03-11 15:34:11 -07:00
neiljp (Neil Pilgrim)
cb8d574648 mypy: Replace Any by Type[QueueProcessingWorker] in queue_processors.py. 2018-03-11 15:34:11 -07:00
neiljp (Neil Pilgrim)
fed51666d6 mypy: Migrate queue_processors.py to python3 syntax.
Forward-declarations of QueueProcessingWorker allow code order to remain
unchanged.

Note added re use of Dict vs Mapping.
2018-03-11 15:34:11 -07:00
Tim Abbott
6e048c5d3f copy_and_paste: Enable copy-paste handler in production.
Now that we've fixed the issues we encountered when first testing
this, we can try it out in production again.
2018-03-11 15:26:27 -07:00
Archana BS
f876fd1423 streams page: Show weekly stream traffic. 2018-03-11 15:26:06 -07:00
neiljp (Neil Pilgrim)
8d188f50eb bugdown: Clarify walk_tree_with_family via ElementPair NamedTuple. 2018-03-11 08:30:56 +00:00
neiljp (Neil Pilgrim)
aa465a6710 requirements: Upgrade mypy to 0.570.
Fixes #8582.
2018-03-10 10:04:14 -08:00
neiljp (Neil Pilgrim)
d4cfab4823 mypy: Use cast in walk_tree_with_family to access inside opaque Element. 2018-03-10 10:04:14 -08:00
neiljp (Neil Pilgrim)
6fc4d5bf40 mypy: Correct annotations in queue_processors.py. 2018-03-10 10:04:14 -08:00
Tim Abbott
87f1516f5d subs: Harden subscriber count code path against bugs.
This expectOne() should catch some classes of bugs here.
2018-03-10 10:00:14 -08:00
Tim Abbott
12db219305 stream settings: Fix subscriber counts when creating invite-only streams.
Previously, when creating an invite-only stream, the subscriber counts
were not being rendered properly, in that the "create" event for the
stream had the user not yet subscribed (so can_add_subscribers was
false), and then the rerendering we did when the user susbcribed just
tried to update the number, not actually rerender the thing.
2018-03-10 10:00:14 -08:00
Tim Abbott
ddef39832f subs: Reverse conditional for rerender_subscribers_count.
This is for more consistency with rerender_subscribers_list.
2018-03-10 10:00:14 -08:00
Tim Abbott
a0d33fa1cf subs: Use sub_for_stream_row helper more consistently.
This cleans up a bunch of hard-to-read duplicated jQuery code.
2018-03-10 09:41:24 -08:00
YJDave
e50cedfcb8 stream settings: Remove stream from subscribed list immediately on unsub.
When user click on unsubscribe button, to unsubscribe from private stream
immediately remove unsubscribed stream from all subscribed stream list.
We don't remove public stream immediately on unsubscription, cause
user may want to undo/subscribe back to stream.
2018-03-10 09:35:47 -08:00
YJDave
32407b4dc0 stream settings: Hide stream members immediately on unsub, if can't access.
If user unsubscribe from private stream, then user can't
access unsubscribed stream members.
After subscription removal, immediately render subscription members
template in case of user can't access stream subscriber.
2018-03-10 09:32:45 -08:00
Tim Abbott
920afb9447 notifications: Fix missing mypy annotations. 2018-03-09 23:34:14 -08:00
YJDave
ee87c146ff settings: If message content disabled, flush all missed emails informations.
If user has disabled message content in missed email notifications,
we shouldn't send any informations about missed messages i.e. sender,
stream, message text, etc. to email servers.
We are already hiding this informations in email templates, but we
shoudln't expose any information about message content if user
has disabled this setting.
2018-03-09 21:16:02 -08:00
Tim Abbott
dfbe1e4914 notifications: Improve "why you were away" content lines.
We now include whether the message was a private or group private
message; this is particularly important with the new setting to
disable including any message content in these emails (since in that
case, one doesn't know anything about the message types).
2018-03-09 21:16:02 -08:00
YJDave
c94b21e9ac settings: Add setting to disable message content in missed message emails.
Fixes #6938.
2018-03-09 21:16:02 -08:00
YJDave
382ac24151 create stream: Fix real time sync bug in private stream creation.
If new private stream is created by realm admin without realm admin
subscribed to it, then it doesn't automatically add created stream to
realm admin's stream list. We have to reload the browser to get newly
created stream in stream list. Cause private stream creation event is
only sent to the subscribed users to private stream, so even if realm
admin is acting user, they don't get creation event.

We should send private stream creation event to realm admin users along
with subscribed user to stream, as realm admins can access unsubscribed
private streams.

Tweaked by tabbott to fix various typos and clean up the code.
2018-03-09 18:35:12 -08:00
YJDave
7cc675cfc1 create stream: On stream create event, add sub to stream lists.
Currently, our stream creation do not add stream list to all
stream list. Only subscription-add event add stream list to
stream list. If public stream is created without acting user
subscribed to stream, then newly created stream is not listed
to all stream list.

On stream creation add sub to all stream list table.
2018-03-09 18:29:16 -08:00
Tim Abbott
2a7e365b6f tests: Fix mock setup for update_calculated_fields.
This fixes a test failure introduced in
c5904499db.  It's not clear to me that
this mocking approach is a good idea; it's pretty messy.
2018-03-09 18:23:18 -08:00
YJDave
9183d59426 create stream: Restrict non-admin to create stream without subscribing.
Only allow realm admins to create stream without subscribing
themselves, restrict non realm admin users.

This new restriction is only for the UI; we don't actually block it at
the backend/API level (one could always create and then remove oneself
anyway).
2018-03-09 18:20:14 -08:00
Tim Abbott
b8fd24b13d stream_create: Clear errors when re-submitting form.
Previously, if you fixed the errors and then tried to re-create a
stream, you'd see an error.
2018-03-09 18:15:46 -08:00
YJDave
e9e6b126ec create stream: Don't allow creating stream with zero subscribers.
Restrict users(even realm admins) from creating stream with zero
subscribers only in UI.
In backend, if subscribers are zero, we automatically subscribe
current user to stream.
2018-03-09 18:09:38 -08:00
YJDave
c3a289b473 create stream: Add div element indicating stream creation result.
Add div element to inform user whether stream is successfully
created or not. This will help to inform user in case if current
user is not subscribed to created stream.
2018-03-09 18:09:38 -08:00
YJDave
3280135a4c stream settings: Update subscription count on subscription event.
On subscription add or removal event, render subscription count
template in case of user can't access subscribers.
2018-03-09 18:00:49 -08:00
Tim Abbott
c5904499db stream_data: Move calls to update_calculated_fields to events layer.
This migrates what were effectively data update functions to be called
from the main stream_events handlers, instead of being called from the
view-update code in subs.js.
2018-03-09 18:00:31 -08:00
YJDave
cc2eb60ca5 stream settings: Fix error in rendering stream members in UI.
To re-render stream members on subscription add or remove event,
we are accessing undefined value "active_stream.stream_id" rather
than "active_stream.id", which resulted in falsey value and our
stream members were not updated unconditionally.
2018-03-09 18:00:20 -08:00
YJDave
777841781f stream settings: Hide stream membership part, if can't access subs.
Do not display stream membership section in stream settings,
if user not allowed to access stream subscribers.
2018-03-09 16:24:05 -08:00
YJDave
c1f9b04435 stream settings: Don't show never subscribed private stream's preview-link.
For public stream, always show stream preview link.
For private stream, only show stream preview link if user is currently
subscribed or previously subscribed to private stream.
2018-03-09 16:24:05 -08:00
Umair Khan
54e56481e6 auth: Retain email value if login fails.
Fixes #7795
2018-03-09 14:51:24 -08:00
Abhigyan Khaund
0e8cadf980 compose: Move "Sending..." to appear to the right of "Drafts".
Fixes #8570.
2018-03-09 14:44:48 -08:00
Tim Abbott
51dc46bfb1 node: Fix test failures due to missing import.
I missed this when reviewing the last batch of changes.
2018-03-09 14:24:08 -08:00
Steve Howell
616a06e5b2 Use msg_list.fetch_status instead of load_enabled.
We now attach a fetch_status to message lists, so that they
can track their fetch status individually.  When you go
back in a narrow and get all the older messages, we turn
off future fetches.

The narrow.js code no longer needs to orchestrate anything
here.  The "home" message list won't have as many redundant
fetches after this commit, because we don't need to reset
flags every time we do `narrow.deactivate`.

And then actual narrows get a new message list every time
you narrow, so their fetch status gets reset implicitly
as part of constructing the MessageList object.
2018-03-09 14:20:58 -08:00
Steve Howell
1e446fcb1a refactor: Call message_scroll.hide_indicators() directly.
We are going to remove message_fetch.reset_for_narrow() soon,
but its callers probably still want to hide any scrolling
indicators, and we just let them do that directly.
2018-03-09 14:20:58 -08:00
Steve Howell
fef2840531 Add FetchStatus class.
We will use this in subsequent commits to replace the
`load_more_enabled` flag.
2018-03-09 14:20:58 -08:00
Steve Howell
ec305149be Extract message_fetch.load_messages_for_narrow().
This helps us consolidate the fetching constants without
having to export them.  It will also remove some
responsibility for narrow.js to track fetching state.
2018-03-09 14:20:58 -08:00
Steve Howell
22162a02a8 Remove unused cont_will_add_messages flag.
(It was always false.)
2018-03-09 14:20:58 -08:00
Priyank
cd48236756 electron_bridge: Send unread count to electron app on update. 2018-03-09 14:12:33 -08:00
Harshit Bansal
5aa8629a10 reactions: Migrate emoji_code to store id for realm emoji.
Till now, we had been storing realm emoji's name in emoji code field
in reactions' model. This commit migrates it to store realm emoji's id.
It is a part of effort to migrate realm emojis to be referenced by their
id and not by name.
2018-03-09 13:46:27 -08:00
Tim Abbott
b2cadf6817 Revert "Fix clipping of stream and topic name in left sidebar"
This reverts commit 617aea7507.

This changes the line-height by accident.
2018-03-09 13:43:04 -08:00
Vishnu Ks
e5fb0961f5 help: Rename signing-out.md to logging-out.md. 2018-03-09 13:31:36 -08:00
Vishnu Ks
cbadecb466 emails: Replace signing in with logging in.
Fixes #7884
2018-03-09 13:31:36 -08:00
Vishnu Ks
e7005cfd0e help: Replace signin with login in zulip-on-android.md. 2018-03-09 13:31:36 -08:00
Vishnu Ks
ff3a8f27c7 help: Rename signing-in.md to logging-in.md. 2018-03-09 13:31:36 -08:00
Vishnu Ks
8da2820024 help: Replace signin with login in signing-in.md. 2018-03-09 13:31:36 -08:00
Vishnu Ks
0d313aacb4 templates: Replace sign in with log in in register and login page. 2018-03-09 13:31:36 -08:00
Shubham Dhama
3b92f6115a hotkey: Add 'delete' to delete focused draft. 2018-03-09 13:30:09 -08:00
Tim Abbott
f3413d3b59 org settings: Fix confusing label for custom emoji settings.
Adding custom emoji is very different from just adding emoji.
2018-03-09 13:25:40 -08:00
Shubham Dhama
7fdf5e67e2 org settings: Remove redundant create-stream-dropdown class.
This removes `create-stream-dropdown` class from the template and css
because it is causing irregularity in size of other permissions dropdown
because of `right-margin` and removing it makes all the dropdown
regularly sized.
2018-03-09 13:21:55 -08:00
Shubham Dhama
777b6de689 org settings: Add setting to prevent users from adding bots.
Fixes: #7908.
2018-03-09 13:21:55 -08:00
Ricky
7c830c5767 webhooks/beeminder: Mock time.time() to avoid race.
Rewritten in significant part by tabbott to actually be correct.

One particularly nasty thing the original webhook integration did is
do `current_time = time.time()` at the top of the `view.py` function
-- that means that code ran at import time, not runtime.
2018-03-09 11:12:40 -08:00
Vishnu Ks
713ca1e5f2 yarn: Update yarn.lock for moment and moment-timezone upgrade. 2018-03-09 11:05:18 -08:00
Steve Howell
7bbdf79b78 Rename functions to show_loading_older/hide_loading_older. 2018-03-09 11:04:29 -08:00
Steve Howell
389421d9c2 Rename reset_load_more_status to reset_for_new_narrow.
We are about to make this logic a little more specific to
what happens when you make a new narrow.
2018-03-09 11:04:29 -08:00
Steve Howell
ae84908eca Rename load_more_messages to maybe_load_older_messages.
We will soon have maybe_load_newer_messages as well.
2018-03-09 11:04:29 -08:00
Steve Howell
68d3441de1 Rename load_old_messages to load_messages.
This function will eventually sometimes load messages that
are "new" relative to the messages that have already been
loaded.
2018-03-09 11:04:29 -08:00
Shubham Padia
077475c563 compose: Don't warn if mentioned stream members form a superset.
Fixes #8634.
Suppress private stream warning if you're to a stream whose
membership is a subset of #mentioned-stream-name.
2018-03-09 10:46:41 -08:00
retsediv
617aea7507 Fix clipping of stream and topic name in left sidebar
Changed a little bit the rule for line-height and now it does not clip "g" letter in of stream and topic name in the left sidebar

Fixes #8209.
2018-03-09 10:40:27 -05:00
YJDave
a598befc9e pills: Show data-some-recipients placeholder text only on focus.
Show data-some-recipients placeholder text only when input
element to add recipients is focused.

Fixes #8622
2018-03-08 15:11:01 -08:00
YJDave
c035acce6c pills: Show data-no-recipients text only if no recipients selected.
Currently, we shows data-no-recipients placeholder text even if
there are recipients selected. It's not visible cause it's value
is override by data-some-recipients helper text in case if there
are recipients selected.

Show data-no-recipients placeholder text only when `input` element
is first child of `pill-container`, which means there are no `pills`
selected by user yet.
2018-03-08 15:11:01 -08:00
cg-cnu
e1ab6ceccc docs: Clarify description by changing 'disrupting' to 'disturbing'. 2018-03-08 15:10:23 -08:00
Robert Hönig
649e76e932 Display error when creating embedded bot with incorrect config data.
"incorrect" here means rejected by a bot's validate_config() method.
A common scenario for this is validating API keys before the bot is
created. If validate_config() fails, the bot will not be created.
2018-03-08 15:05:42 -08:00
Robert Hönig
194b2fd8c0 Upgrade the zulip_bots dependency to python-zulip-api:192e9e1.
192e9e1 introduces bot-specific validate_config()
methods that are used in subsequent commits.
2018-03-08 15:05:38 -08:00
Robert Hönig
35c7428490 frontend: Add create-bot loading indicator.
The former "the-bot-is-being-created" indicator was useless,
since it only edited the value attribute of the "create-bot" button;
that attribute only sets the text of a button when it is initially created.

This commit replaces the old code with a spinning loading indicator,
like the one used for editing bots.
2018-03-08 15:05:00 -08:00
Steve Howell
47f3af9e50 refactor: Extract constants in message_fetch.js.
Having constants at the top is particularly convenient
for tweaking things while testing the fetch code.
2018-03-08 15:03:47 -08:00
Steve Howell
571773564f minor: Use message_viewport.at_top() in scroll_finished.
This effectively changes a condition from `=== 0` to `<= 0`,
but that probably doesn't matter (and would only help).  More
importantly, it just makes the code more consistent.
2018-03-08 15:03:47 -08:00
Steve Howell
b8f39b2ff1 refactor: Early-exit in message_scroll.scroll_finished.
This is just cosmetic to flatten the function a bit.
2018-03-08 15:03:47 -08:00
Steve Howell
8063f73f6d Extract message_scroll.js.
This mostly moves code from ui.js.

We change the arguments to `message_fetch.load_more_messages()`
to be `opts` with callbacks for `show_loading` and `hide_loading`.

We also defer starting the scroll handler until `message_fetch.js`
has been initialized.
2018-03-08 15:03:47 -08:00
Steve Howell
7819319695 minor: Remove unused ui.have_scrolled_away_from_top. 2018-03-08 15:03:47 -08:00
Vishnu Ks
254548d093 package.json: Upgrade moment-timezone to 0.5.14. 2018-03-08 14:57:28 -08:00
Vishnu Ks
8d8c102192 package.json: Upgrade moment to 2.21.0. 2018-03-08 14:57:28 -08:00
Eeshan Garg
fa8525c862 webhooks/hellosign: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Eeshan Garg
f3590dc2f5 webhooks/gosquared: Update text to conform to doc style guide.
Note that the 5th step cannot be reached unless a webhook has been
configured first, which is why it is the last step.
2018-03-08 08:19:32 -08:00
Eeshan Garg
12396dd39b webhooks/gogs: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Eeshan Garg
88a198041a webhooks/gitlab: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Eeshan Garg
f7a21b18dc webhooks/github_webhook: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Eeshan Garg
b6fc33e1da webhooks/gci: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Eeshan Garg
fa1583bf45 webhooks/dropbox: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Eeshan Garg
4f039e4536 webhooks/delighted: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Eeshan Garg
18c6cd9dd2 webhooks/codeship: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Eeshan Garg
1c44a9c4c0 webhooks/bitbucket2: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Eeshan Garg
f551f3a9b8 webhooks/beanstalk: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Eeshan Garg
9de90645f3 webhooks/basecamp: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Eeshan Garg
7ee7d4a4d1 webhooks/appfollow: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Shubham Padia
a78024f53d bots: Delete bot from bot_data set on realm_bot delete event.
Fixes #8577.
2018-03-08 07:54:19 -08:00
Shubham Padia
32e38d36aa bots: Send add/delete event on bot ownership change.
Adds realm_bot delete event. On bot ownership change, add event is
sent to the bot_owner(if not admin) and delete event to the
previous bot owner(if not admin). For admin, update event is sent.
2018-03-08 07:54:19 -08:00
Rhea Parekh
d4374880d5 slack importer: Clear 'output_dir' at the beginning of test.
if the test fails, the 'output_dir' would not be deleted and
hence it would give an error when we run the tests next time,
as 'do_convert_data' expects an empty 'output_dir'.

Also the unzipped data file should be removed if the test fails
at 'do_convert_data'.
2018-03-08 07:53:09 -08:00
Shubham Dhama
a0ab87bef2 notifications: Clean and automate global notifications update handler.
To prevent specifying notifications individually for global
updates, automate handle_global_notification_updates using
settings_notifications.notification_settings where we have
the keys of all the types of notifications.
2018-03-08 07:19:48 -08:00
Tim Abbott
c0f5ac801d team: Fix ugly line-wrapping when showing total.
Eventually, we'll want a slightly different design for this section of
the page, for for now, "Total" is both clearer and fits better.
2018-03-07 17:25:42 -08:00
sinwar
6bed6ccdcf team page: Remove duplicate contribution counts.
It removes duplicate contribution count from zulip-server.

Fixes #7836.
2018-03-07 17:25:41 -08:00
Tim Abbott
c3964dff6e i18n: Fix a last few strings mentioning realms. 2018-03-07 17:15:29 -08:00
Tim Abbott
c47403b024 i18n: Fix message-send error messages using 'realm'.
We also do some small quality improvements to these strings, while
we're at it.
2018-03-07 17:15:29 -08:00
Tim Abbott
798fbb687c i18n: Rename 'Closed Realm' to 'Private organization'.
This is a clearer explanation for what the organization is like, anyway.
2018-03-07 17:15:29 -08:00
Tim Abbott
e2a6541133 i18n: Fix use of 'realm administrator' in translated strings.
These are user-facing and thus should refer to being an "organization
administrator".
2018-03-07 17:15:29 -08:00
Tim Abbott
8fba40fdd5 emoji: Clean up strings for emoji errors.
The main goal here is to remove the use of the term "realm", but we
also make these strings more consistent and using better English.
2018-03-07 17:15:29 -08:00
Tim Abbott
342d8cd4e0 i18n: Fix use of realm to refer to an organization. 2018-03-07 17:15:29 -08:00
Rishi Gupta
158697c41c dev environment: Properly close triple quotes in fixture messages. 2018-03-07 16:26:30 -08:00
Yago González
3186b09e43 i18n: Remove unnecessary string. 2018-03-07 16:19:44 -08:00
Steve Howell
fb3293a24a node tests: Add tests for input_pill.js.
This gets us coverage on most of the core "data" code, but it
doesn't get deep into the key handlers.
2018-03-07 15:53:11 -08:00
Steve Howell
3e76d523c7 node tests: Add tests for user_pill.js.
This gets coverage to 100%.  (We already had a lot of indirect
coverage, but these tests should have more obvious failure
symptoms.)
2018-03-07 15:53:11 -08:00
Steve Howell
60f08b069c reload: Handle errors with compose_actions.start().
If we have bugs in our compose code, we don't want them to
cause other strange side effects during reload.  (We recently
had a test deployment that was a bit buggy, and the reload
problem was tough to chase down due to the misleading
symptoms.)
2018-03-07 15:53:11 -08:00
Steve Howell
c7ad2a5a8e minor: Simplify declaration for reload.initialize().
We are moving away from this pattern in our code.

    export.foo = function bar__foo() { ...};
2018-03-07 15:53:11 -08:00
Steve Howell
3a1bf04a56 compose: Add pills for typing in PM recipients.
@brockwhittaker wrote the original prototype for having
pills in the recipient box when users compose PMs (either
1:1 or huddle).  The prototype was test deloyed on our
main realm for several weeks.

This commit includes all the original CSS and HTML from
the prototype.

After some things changed with the codebase after the initial
test deployment, I made the following changes:

    * In prior commits I refactored out a module called
      `user_pill.js` that implemented some common functions
      against a more streamlined version of `input_pill.js`,
      and this commit largely integrates with that.

    * I made changes in a prior commit to handle Zephyr
      semantics (emails don't get validated) and tested
      this commit with zephyr.

    * I fixed a reload bug by extracting code out to
      `compose_pm_pill.js` and re-ordering some
      calls to `initialize`.

There are still two flaws related to un-pill-ified text in the
input:

    * We could be more aggressive about trying to pill-ify
      emails when you blur or tab away.

    * We only look at the pills when you send the message,
      instead of complaining about the un-pill-ified text.
      (Some folks may consider that a feature, but it's
      probably surprising to others.)
2018-03-07 15:53:11 -08:00
Steve Howell
1aba722e63 user_pill: Add Zephyr logic.
For Zephyr realms we have to be more lax with email validation.

This will be relevant for compose pills.
2018-03-07 15:53:11 -08:00
Steve Howell
f0d101edf5 pills: Streamline input pills (for user groups).
The main point of this change is to streamline the core
code for input pills, and we use also modify user groups.

The main change to input_pill.js is that you now
configure a function called `create_item_from_text`, and
that can return an arbitrary object, and it just needs
a field called `display_value`.

Other changes:
    * You now call `input.create(opts)` to create the
      widget.
    * There is no longer a cache, because we can
      write smarter code in typeahead `source` functions
      that exclude ids up front.
    * There is no value/optinalKey complexity, because
      the calling code can supply arbitrary objects and
      do their own external data management on the pill
      items.
    * We eliminate `prependPill`.
    * We eliminate `data`, `keys`, and `values`, and just
      have `items`.
2018-03-07 15:53:11 -08:00
Tim Abbott
0d29864c6a setting: De-duplicate logic for bulk-updating notifications settings.
In the new data model, this duplication was unnecessary.
2018-03-07 15:21:17 -08:00
Shubham Dhama
2782a5d8dc settings: Update notification settings to new feedback style.
This split notification settings to separate settings for streams,
PM/mention and other notifications settings.
Previously we have to treat them combined, but with this refactor,
we can treat them separately for future changes.

Fixes #8587.
2018-03-07 15:21:17 -08:00
Tim Abbott
b55f881447 settings: Split notification_settings into a few sub-variables.
This refactor has no functional effect, but sets us up to be able to
do the next refactor.
2018-03-07 15:20:53 -08:00
Akash Nimare
cd84fde8c5 apps: Update desktop app to latest release v1.8.2. 2018-03-07 14:09:35 -08:00
Rhea Parekh
0d788823c2 slack importer: realm_id cleanup. 2018-03-07 14:07:24 -08:00
Rhea Parekh
7878cc53a3 slack importer: Cleanup build_subscription. 2018-03-07 14:07:24 -08:00
Rhea Parekh
f947194e4c slack importer: Cleanup build_avatar. 2018-03-07 14:07:24 -08:00
Rhea Parekh
5efe05d5b6 slack importer: Cleanup build_zerver_usermessage. 2018-03-07 14:07:24 -08:00
YJDave
b358fb2c42 org settings: Hide table-list-data until page gets load.
Until page gets load, table lists are empty. Which results in
showing empty-data-text("No data match to search query") in
setting page parallel to loading spinner.

Hide table-list and show loading spniner until
setting page and table-list gets load.
2018-03-07 13:34:50 -08:00
YJDave
f46d925208 org settings: Fix issue, loading spinners are not visible.
In org settings, loading spinners are not visible, currently
because their size is very small.

Fix this, by increasing width and height of spinners and
adding spinner text, to make spinners more visible.
Fixes #8502
2018-03-07 13:34:50 -08:00
Shubham Dhama
a5812544ec settings: Fix real-time sync with notifications settings.
The if condition in "update_global_notifications" case was always false.
Similar to c672a1c.
2018-03-07 17:05:15 +05:30
Greg Price
e022b9e7ea install docs: Cut SSL cert from requirements summary.
The summary already has a qualifier that basically says it shouldn't
matter for most people -- making it simultaneously the most
complicated bullet there, and among the least likely to matter.

And in fact, this requirement shouldn't matter for *anyone* when first
experimenting with Zulip.  If certbot won't work in a given admin's
environment, and the available ways to get a cert aren't convenient,
they can always let the installer generate a self-signed cert to get
going, and circle back to the issue later.

So, make that option clear in the main requirements text, and then
just cut the whole bullet from the summary.
2018-03-06 19:43:02 -08:00
Greg Price
d99ec6426d install docs: Move requirements tl;dr to requirements doc.
This further reduces the wall of text on the install instructions.
Simultaneously it lightens up the pressure on this summary to be quite
so terse; expand a couple of items into multiple bullets (yet with
fewer words!) for greater readability.
2018-03-06 19:43:02 -08:00
Greg Price
1215245be6 install: Check for a supported OS release. 2018-03-06 19:43:02 -08:00
Greg Price
c1d5364077 install docs: Consolidate follow-up steps.
Now down to just 4 steps!

This version tries to prioritize: just two items that we really want
all admins to look at even if they aren't already mentally committed
to running a big production service and reading all the docs.
Namely, the two required in order to really try out Zulip effectively
with one's colleagues.
2018-03-06 19:43:02 -08:00
Greg Price
526e301177 install docs: Tighten "create organization" step.
The screenshots weren't doing much good without being embedded in the
text... and in fact, looking at them for I think the first time,
they're badly out of date with the app.  So cut them.

We might add screenshots later, but on the other hand if we do a good
job with the forms themselves, they should be superfluous.
2018-03-06 19:43:02 -08:00
Greg Price
4edc121b49 install docs: Move background details to after main flow too.
This further shortens the wall of text inside the instructions.

Note that thanks to embedded reST, we now have the power to provide
custom anchors at section headings!  Which in particular means this
link won't break if we later tweak the wording of this heading.
2018-03-06 19:43:02 -08:00
Greg Price
53f80336ee install docs: Consolidate troubleshooting at bottom.
This helps shorten the wall of text between the start of the
instructions and the end.  Conversely, now that there are fewer
followup steps, the troubleshooting section at the end isn't so
far away to point.
2018-03-06 19:43:02 -08:00
Greg Price
0505036965 install docs: Reduce prose in requirements bullets. 2018-03-06 19:43:02 -08:00
Greg Price
678fcef5bd install: Fix up success message in --no-init-db case.
The installation isn't really complete here, and wasn't even when this
was the only success case; the instructions we're giving are for the
next step in the installation.

These instructions don't say what to do in an actual use case for this
option, but decent instructions there will require having a concrete
use case in front of us and designing the flow for it.  At this stage,
just say where we are in the normal flow, and an admin who's chosen to
go off that flow can figure out how they want to vary it from there.
2018-03-06 19:43:02 -08:00
Greg Price
f22712e8e8 install: Go straight through by default.
This flips the experimental `--express` option to be the default.

We retain the old behavior, where the script exits before
`initialize-database`, as an option `--no-init-db`; it might be useful
in e.g. a migration scenario (from a Zulip install elsewhere, or
another chat system) where the admin wants to set up the database
separately.

The install instructions are adjusted to match, getting shorter by two
steps and a bunch of words.  I think this opens up opportunities to
refactor the text to simplify things further, too, but leaving that
for another commit.

Also tweak the "production" test suite to match.
2018-03-06 19:43:02 -08:00
Greg Price
b1ad4e88d4 install: Switch some more uses of sudo to su.
Kind of unfortunate because the `sudo` interface for running a command
is objectively better -- a list of arguments, rather than a string to
be re-parsed by the shell.  But some bare-bones machine images lack
`sudo`, so this makes things a bit more portable.
2018-03-06 19:43:02 -08:00
Greg Price
eb7eef02e8 install: Suppress initialize-database instructions when redundant.
To do it, add a blob of getopt boilerplate at the top of the script;
and also fix a couple of nits of shell style while here.
2018-03-06 19:43:02 -08:00
Greg Price
8111848ac4 test-install: Do a dist-upgrade in prepare-base.
This keeps the base tree up to date, saving the time we'd spend
doing the same upgrades in each test install.
2018-03-06 19:43:02 -08:00
Lyla Fischer
96c5bf5dcc user docs: Move make-an-announcement to notify-everyone-on-a-stream. 2018-03-06 17:11:20 -08:00
Lyla Fischer
05e18ef60b user docs: Merge two private message docs and mention shortcut. 2018-03-06 17:11:20 -08:00
Rhea Parekh
6c4eef16e9 slack importer: Sort messages in the order of their dates.
Sort the list of all messages in the order of their timestamp.
2018-03-06 14:07:09 -08:00
Rhea Parekh
c2d4b49bf3 slack importer: Use precomputed value in 'channel_message_to_zerver_message'.
Use the List of all messages in this helper function
instead of using the messages channel-wise.
2018-03-06 14:07:09 -08:00
Rhea Parekh
3e4086d1b8 slack importer: Use precomputed value in 'get_total_messages_and_usermessages'.
Use the List of all messages in this helper function
instead of using the messages channel-wise.
2018-03-06 14:07:09 -08:00
Rhea Parekh
10c73ae577 slack importer: Add function to precompute all the messages.
The messages were first being read and passed to the helper
functions channel wise.
This function makes a list of all the messages in the all the channels
beforehand which would be used to pass in the helper functions.
2018-03-06 14:07:09 -08:00
Vishnu Ks
59b8f85c63 bugdown: Do only image preview if relative URL. 2018-03-06 13:50:02 -08:00
Tim Abbott
553634536c beeminder: Mostly eliminate nondeterministic failures in test suite.
There's probably follow-up work to do here to eliminate these
completely, but this dramatically shrinks the ~1 minute race window
that was previously present between import and test function being
called.
2018-03-06 13:44:06 -08:00
Tim Abbott
d98be2f19f puppet: Only run analytics Nagios checks on machine running cron.
Running this on additional machines would be redundant; additionally,
the FillState checker cron job runs only on cron systems, so this will
crash on other app frontends.
2018-03-06 13:38:27 -08:00
Tim Abbott
8e8faab006 puppet: Move clearsessions cron job to app_frontend_once.
While this is a different system than I'd written up in #8004, I think
this is a better solution to the general problem of cron jobs to run
on just one server.

Fixes #8004.
2018-03-06 13:35:51 -08:00
Tim Abbott
9a74ef5056 puppet: Move some cron jobs to app_frontend_once.pp.
Several cron jobs had incorrectly ended up in the app_frontend.pp
template, and thus would only run on voyager instances.
2018-03-06 13:35:51 -08:00
Tim Abbott
3ae645ed12 puppet: Rename analytics.pp to app_frontend_once.pp. 2018-03-06 13:35:51 -08:00
Tim Abbott
ad7f38ab3b puppet: Move analytics cron job to analytics.pp.
This better groups it with the related code.
2018-03-06 13:35:51 -08:00
Tim Abbott
24b6106c9c puppet: Dsiable checking for evictions in memcached nagios.
Zulip's caching model for message history is such that it is normal
and healthy for there to eventually be a nontrivial volume of
evictions.
2018-03-06 13:34:02 -08:00
Tim Abbott
11b31b3584 requirements: Update uwsgi to the latest version.
Apparently, older uwsgi doesn't install properly on systems with newer
versions of OpenSSL; see https://github.com/unbit/uwsgi/issues/1395
for details.

This fixes #7609.
2018-03-06 13:14:26 -08:00
Cynthia Lin
5e251e5ca0 compose: Improve line wrapping for multiline compose box alerts. 2018-03-06 13:01:41 -08:00
Cynthia Lin
f0f6bdf077 compose: Improve error message for mentioning unsubcribed users.
Previously, some users were confused as to whether or not they needed
to hit the subscribe button here.

Fixes #8550.
2018-03-06 13:00:45 -08:00
Xavier Cooney
769052d9c7 css: Allow the bot API key to be selected on all browsers.
The problem that prompted this PR is that I couldn't select the API
key of a bot in chrome to copy it, but I could on Firefox.

Using the `auto` proerty value to override the `user-select`
property  of a parent does not seem to be compatible
with all browsers.
2018-03-06 12:55:53 -08:00
Eeshan Garg
12c4a8293d webhooks/crashlytics: Update the text.
This commit:

* Restructures the doc to use a numbered-step format.

Note that there are no screenshots. I signed up for a
Fabric/Crashlyics account but you have to link an Android/iOS app
to even get to the settings panel, which seemed like too much work
just to get a screenshot.

However, the way we can verify (somewhat) the correctness of the
last step is that it is a paraphrase of the first paragraph of
Fabric's Webhook docs, which can be found here:

https://docs.fabric.io/apple/crashlytics/custom-web-hooks.html
2018-03-06 12:52:22 -08:00
Eeshan Garg
53ccbdcfd6 webhooks/dropbox: Update text and remove screenshots.
This commit modifies the text to:

1. Removes unnecessary screenshots.

2. Use the numbered-style format.

3. I also removed the instructions for generating an access token.
   I took a look at Dropbox's docs and you shouldn't need that
   for a webhook setup. The whole point behind a webhook is that
   one can get by without using OAuth.

4. Rearranges the instructions to only contain 4 steps. For
   uncomplicated instructions, that seems to be the ideal number.
2018-03-06 12:52:22 -08:00
YJDave
a059247398 message editing: Fix bugs in recipient-row template rendering.
In `recipient-row` template, if conditions to add/hide/show edit
icon for message topic is incorrect.
In some cases, we only want to just hide the edit icon, but icon
should be in DOM, cause in future if organization settings are
changed we want to show edit icon in message row.

If user can edit topic of message, surely add edit icon element to
DOM regardless of user is allowed to edit or not. If user is
allowed to edit then show edit icon otherwise hide edit icon element.
2018-03-06 07:17:28 -08:00
YJDave
eb67c46928 message editing: Move update msg-topic-edit-icon func to message_edit.js.
Move function `update_message_topic_editing_pencil` to file
`message_edit.js` from `settings_org.js`.
2018-03-06 07:17:28 -08:00
YJDave
a4366d9a6d message editing: Clean update msg-topic-edit-icon function.
`update_message_topic_editing_pencil` function update edit
icon for message topic in message row header.

- Remove erroneous `meta.loaded` check.
- Add proper check of message editing permission in realm
  before updating message-topic-edit-icon in function.
- Update `always-visible-topic-edit` element in function
  simultaneously.
2018-03-06 07:17:28 -08:00
YJDave
d360a70523 static/js/settings_org.js: Rename func which updates msg-topic-edit-pencil.
Rename `toggle_allow_message_editing_pencil` to
`update_message_topic_editing_pencil` in `settings_org.js`.
As this function update the pencil icon for updating message
topic in message row header.
2018-03-06 07:17:28 -08:00
Aditya Bansal
06cabc1e8a popovers: Fix issue with user-info-popover in legacy mention messages.
We fallback to using data-user-email attrib for mention messages
from the times when we use to expose user emails to frontend.
This is only required for cases where we are dealing with anything
that isn't rendered dynamically (like the messages that were already
sent and stored long time ago). Hopefully we won't be needing this
kind of fallback logic in more places so I am putting off efforts
to try to extract fallback logic for common use. Also this is like
this because it will probably be tricky to extract out a common
fallback logic in this case because of different situations involved.

Fixes: #8588.
2018-03-06 06:41:17 -08:00
Shivam Gera
baffcf0948 Fix: broken link zulip/zulipbot 2018-03-05 10:51:56 -08:00
Shubham Dhama
3fb862533f upload: Fix upload under message edit mode when edited using hotkeys.
This refactors the attachment of jQuery-filedrop handler into
`message_edit.start_edit_with_content`.
2018-03-05 10:42:38 -08:00
Tommy Ip
5ee6c608c0 message edit: Allow uploading files.
Fixes: #198.
2018-03-05 10:42:38 -08:00
Tim Abbott
787d5c50e0 upload: Inline clear_out_file_list.
This provides a slightly clearer interface, allowing us to remove the
unnecessary split of the code for the clone_file_input concept across
multiple modules (we now just clone it on-demand).
2018-03-05 10:42:38 -08:00
Tim Abbott
f253f96211 lint: Add "Gravatar" to capitalized terms in linter. 2018-03-05 10:29:18 -08:00
Anupam-dagar
f531d37e4f Reorder "create bot UI" for embedded bots.
Fixes: #8580
2018-03-05 10:22:00 -08:00
synicalsyntax
a615b21bde signup: Wrap hostname overflow with scrolling in realm creation form.
Tweaked by tabbott to adjust the widths a bit.

Fixes #8488.
2018-03-05 09:47:35 -08:00
Tim Abbott
3d8e45f1cb cache: Avoid caching /help/ documentation page content.
This should make it a lot less annoying to edit these pages locally,
without regressing the test performance which motivated the cache.
2018-03-05 09:26:58 -08:00
amanagr
4d2c6efa09 help: Correct broken link and clarify email gateway integration.
This helps make it clear that this feature isn't supported on all
Zulip installations.
2018-03-05 09:26:10 -08:00
Rhea Parekh
416f11030f user settings: Display avatar source.
This makes it easier for users to tell how Zulip ended up with an
avatar for them without them uploading one: through the Gravatar
service used across many Wordpress blogs.

Fixes #8225.
2018-03-05 09:12:59 -08:00
Aditya Bansal
9eeb1c59f6 bugdown: Remove email from rendered content of messages with mentions.
This field has been unused by clients for some time, and isn't great
for our public archive feature plans (where we'll not want to be
including email addresses in messages).
2018-03-04 20:04:27 -08:00
YJDave
d36ec962bb deactivation-stream-modal: Make stream name a template variable.
In stream deactivation modal, make "stream_name" a template variable,
rather than patching stream name to modal header in javascript.
Add tests for deactivation stream modal.
2018-03-04 19:26:50 -08:00
YJDave
8ba91e48c1 stream settings: Add delete stream button.
Add option to delete stream in stream setting page for
realm admins only.
2018-03-04 19:26:50 -08:00
YJDave
077e56e3b6 static/js/settings_streams.js: Refactor delete stream method. 2018-03-04 19:26:50 -08:00
Tim Abbott
14f1f10662 display_settings: Mark night mode as no longer experimental.
It's now been tested enough to be a solid feature.
2018-03-04 19:24:11 -08:00
Tim Abbott
fb340811a4 display_settings: Fix pencil being lost updating default language.
The HTML was just done sloppily in the first version of this feature.
2018-03-04 19:23:58 -08:00
Tim Abbott
9acf30b3d3 display_settings: Fix real-time sync of default language.
We apparently weren't sending to the frontend the data needed to
update the display of the current language.
2018-03-04 19:23:58 -08:00
Tim Abbott
c9724fe284 display_settings: Clean up and mark real-time sync issues.
This fixes the real-time sync of the settings state for night mode,
and also makes it clear where a few outstanding bugs are in this
page's sync.
2018-03-04 18:38:14 -08:00
Tim Abbott
c672a1c112 settings: Fix real-time sync for display settings.
The conditional we previously had in server_events.js was always
false.
2018-03-04 18:32:05 -08:00
Tim Abbott
cec34302be settings_ui: Move main function for new settings system to library code.
This should make it much easier to convert other checkboxes in the
product to use this mechanism.
2018-03-04 18:26:27 -08:00
Tim Abbott
4d8e18e58f settings: Move display_checkmark to settings_ui.js. 2018-03-04 18:26:27 -08:00
Tim Abbott
6a06e453c7 display_settings: Extend de-duplication of unnecessary logic.
We add a new option to the change_display_setting function to support
cases with a custom on-success or on-failure message.
2018-03-04 18:09:46 -08:00
Tim Abbott
7dbd515191 settings: De-duplicate code for managing display settings.
Now that we have a common framework here, there's no need for so many
copies of the channel.post logic.
2018-03-04 17:59:54 -08:00
Balaji2198
5aa7098c81 display_settings: Change success/failure feedback interface.
This replaces the cumbersome system we had for giving users feedback
on settings state changes in the display settings UI.

We expect this new system to be what we will attempt to migrate other
settings widgets to match over the coming weeks and months.  It also
provides the opportunity to significant refactor away a lot of the
code duplication in settings_display.js.

Thanks to Brock Whittaker for redoing the styling and improving the
code simplicity.

Fixes #7622.
2018-03-04 17:47:05 -08:00
Balaji2198
b846ab1000 settings: Change wordings of all alert-status in Display settings. 2018-03-04 16:36:56 -08:00
Tim Abbott
a3ca7ee1c7 lint: Add a few strings to capitalization linter.
My hope is that we'll be able to eliminate these strings from the UI
altogether soon, but this is needed to keep CI passing for now.
2018-03-04 16:34:00 -08:00
Yago González
bb83486509 i18n: Keep URLs from being translated. 2018-03-04 15:44:12 -08:00
Yago González
b475e74c47 i18n: Fix string interpolation. 2018-03-04 15:44:12 -08:00
Yago González
c8ad1cf209 settings: Improve warning in signup notifications. 2018-03-04 15:44:12 -08:00
Yago González
48709b4890 i18n: Add new terms to the Spanish translation guide. 2018-03-04 15:44:12 -08:00
Cynthia Lin
777df12744 help: Hide y-scrollbar on collapsed sidebar view.
Closes #8497 and fixes #8495.
2018-03-04 15:42:48 -08:00
Marco Burstein
bdb86f1b5e emoji: Add support for translating emoticons.
Add `translate_emoticons` to `prop_types` and `expected_keys`.
Furthermore, create a emoji-translating Markdown inline pattern.

Also use a JavaScript version of `translate_emoticons` and then use
this function during Markdown previews and as a preprocessor. This
is only needed for previews, because usually emoticon translation
happens on the backend after sending.

Add tests for emoticon translation, a settings UI, and a /help/ page
as well.

Tweaked by tabbott to fix various test failurse as well as how this
handles whitespace, requiring emoticons to not have adjacent
characters.

Fixes #1768.
2018-03-04 15:37:24 -08:00
Tim Abbott
038579b840 streams: Fix counts using only one data point.
We had the aggregation query for StreamCount done slightly wrong.
2018-03-04 14:06:29 -08:00
YJDave
8cd3e55fae default stream: Fix default stream suggestion do not include private stream.
Private streams were not included in stream suggestions for default streams
in org settings.
Remove function, which exclude private streams from stream suggestions
for default streams.
2018-03-04 13:42:28 -08:00
Robert Hönig
81ba7a1e40 Mark DigestWorker and PushNotificationsWorker as nocoverage.
These two classes are tricky to test, and nocoverage-ing them
allows us to mark queue_processors.py as fully covered. We
still want to cover these two workers at some point, but for
now, it's nice to enforce full coverage for any future changes
to queue_processors.py.

Fixes (sort of) #6542.
2018-03-04 13:31:33 -08:00
Robert Hönig
93b2f0ea35 Mark MissedMessageSendingWorker as nocoverage.
The MissedMessageSendingWorker queue will be removed
after the 1.8 release, so covering it in tests is
useless.
2018-03-04 13:31:33 -08:00
Robert Hönig
e69af3011e Add basic test for FeedbackBot.
This sets up a new test class with a simple
test, mostly for increasing coverage. The class
should in the future be extended to properly
verify the handle_feedback() logic.
2018-03-04 13:31:33 -08:00
Robert Hönig
4381ce74aa EmbeddedBotWorker: Remove @-mention check.
We already check in get_service_bot_events() if a bot is mentioned,
and then only pass on the call to the bot handler if it is. The
commit removes the additional check in the embedded bot queue
processor simply because it is impossible to obtain test coverage
for it (there is no meaningful way to trigger the content of the
if-clause, because there will never be a message reaching the bot
without @-mentioning it.

To alleviate the danger of a potential regression, the check is not
removed completely, but rather replaced by an assert statement.
2018-03-04 13:31:33 -08:00
Archana BS
c7650c0d9d streams: send data for recent streams traffic to frontend.
Significantly edited by Tim Abbott and Vishnu Ks.
2018-03-04 13:24:53 -08:00
Vishnu Ks
385ee95038 streams: Show subscriber count icon before count. 2018-03-04 13:20:06 -08:00
Archana BS
b5a860b234 analytics: Populate messages_in_stream:is_bot:day in dev. 2018-03-04 13:17:00 -08:00
Shubham Dhama
bfcfe84bdd compose: Append space when text added at the end of textarea.
This appends a space when text is inserted at the end of a message
using `compose_ui.insert_syntax_and_focus`.  This is definitely what
users expect when using this feature.

Fixes: #8569.
2018-03-04 13:16:17 -08:00
Robert Hönig
4c7dd971d0 embedded bots: Dispatch all config data on update event.
Previously, when a user updated the config data of an
embedded bot, only the updated fields were dispatched
back to the client. Dispatching all config data fields
makes the client updating code less brittle.
2018-03-04 13:11:23 -08:00
Shubham Padia
e15a22dae2 message-editing: Topic_data.remove_message on delete_message dispatch.
Fixes #8411.
If the last msg in a topic is removed, that topic is removed
from recent topics in the streams left sidebar.
2018-03-04 13:10:26 -08:00
Tim Abbott
530e098916 node: Remove 100% coverage requirement for user groups.
This is a temporary change to get CI passing again; we lost some
coverage in aed8cc9062, which fixed some
major bugs in the feature.
2018-03-04 10:11:11 -08:00
Tim Abbott
aed8cc9062 user_groups: Handle add/remove members events.
This fixes the real-time sync for the user groups membership data
structure to work like these work in the rest of Zulip; now, edits
made in one browser are immediately and correctly reflected in other
browsers.
2018-03-04 09:45:31 -08:00
Tim Abbott
0147826042 user_groups: Convert members to a dict in frontend. 2018-03-04 09:45:31 -08:00
Tim Abbott
3a14317376 user_groups: Move meta.loaded check to actual exported interface.
This should fix an exception that we were seeing where the expectOne()
check would fail if the user groups page hadn't been rendered yet.
2018-03-04 09:40:56 -08:00
cPhost
7f144b9b95 setup-non-vagrant: Document how to setup zulip dev env on cloud9.
Significantly tweaked by tabbott for instructional clarity.
2018-03-03 15:43:38 -08:00
Eeshan Garg
75ce1261c1 webhooks/github: Log payloads that aren't handled properly.
Webhook functions wrapped by the decorator:

@authenticated_api_view(is_webhook=True)

now log payloads that cause exceptions to webhook-errors.log.

Note that authenticated_api_view is only used by webhooks/github
and not anywhere else.
2018-03-03 15:30:36 -08:00
Eeshan Garg
5af55d7845 requirements: Upgrade to virtualenv-clone 0.3.0. 2018-03-03 15:24:18 -08:00
YJDave
59cf67062f settings: Add generic func to disable settings elements in UI.
We have some settings which are inter-dependent. If one setting
is checked or unchecked, it's dependent-sub-setting get disabled
or enabled. i.e. If user unchecked setting allow-message-editing
then message-editing-time-limit setting should get disabled in UI.

Add generic function to change disable attribute of sub settings
on checked or unchecked event of main setting in `settings_ui.js`.
2018-03-03 08:38:54 -08:00
YJDave
f5a24efdd8 static/js: Add settings_ui.js file for common settings UI functions. 2018-03-03 08:38:54 -08:00
knovokresch
eb7a744639 docs: Extend troubleshooting guide to cover MacOS High Sierra issue.
Significantly tweaked by tabbott to provide more clarity about the
bug, and also link to this issue early in the MacOS requirements
sections.
2018-03-03 08:37:26 -08:00
Eeshan Garg
59581f6a32 tools/lint: Require a space after every : in JSON files. 2018-03-02 14:10:53 -08:00
Eeshan Garg
50a66725a1 json: Ensure consistent formatting in api/fixtures.json.
Now, the fixtures.json file:
* Has all keys sorted alphabetically.
* Has a space after every `:`.

The file was generated using json.dumps with the appropriate
formatting parameters.
2018-03-02 14:10:53 -08:00
Eeshan Garg
393b9eec99 api_docs: Move get-events-from-queue fixture to fixtures.json.
Note that this is one of the few fixtures that isn't tested against
a running server. But it still makes sense to move it to fixtures.json so
that it is rendered with indenting and a space after every `:` by
the api_code_example extension.
2018-03-02 14:10:53 -08:00
Shubham Padia
13664f1289 uploads: Convert CMYK to RGB when saving avatar/realm icon as png.
Fixes #8546.
PNG does not support CMYK mode. CMYK file is converted to RGB and
then saved as PNG.
2018-03-02 12:57:22 -08:00
Tim Abbott
92ba40b0c7 settings: Use .attr() properly for disabling name/email change.
It turns out the consistent `.prop()` approach I switched to a few
commits back didn't actually work.  Instead, we establish consistency
by always using `.attr`, which does.

Usually, I'd go back and fix the older commits, but in this case it
feels not worth it.
2018-03-02 12:49:46 -08:00
Tim Abbott
72a31150f7 settings: Move name/email change display commits to correct file.
These most properly belong in settings_account.js, since they are
updating the UI widgets on that page.
2018-03-02 12:49:36 -08:00
Tim Abbott
9fe0f81f4a settings: Simplify is_admin logic for name changes.
This now also should correctly handle when a user's state as to
whether they are an admin changes.
2018-03-02 12:49:36 -08:00
Tim Abbott
4e32b5df00 settings: Rename functions for updating email/name change UI.
These functions no longer do a toggle.
2018-03-02 12:49:36 -08:00
Tim Abbott
63db3e0b3d settings: Fix erroneous meta.loaded check for name/email change.
That check is for the settings_org.js page, which is of course not
actually the page that these fields are on.
2018-03-02 12:49:36 -08:00
Tim Abbott
9b8c541a74 settings: Set state of name/email change fields from data.
Rather than having a toggle function that just flips the state, it's
more correct to have the state just be set to what it should be.

Also, we clean up the use of .attr() for a thing better accessed via
.prop().

We should probably rename the function at this point, but we save that
for a future commit.
2018-03-02 12:49:32 -08:00
YJDave
ce46cd914a settings: Allow admin to change email/name even if it is disabled in realm.
Allow realm admin users to change their email or name even,
changing name or email is disabled in realm.
2018-03-02 12:17:00 -08:00
Vishnu Ks
f0d651f9fe invites: Only admins should be able to create multiuse invites. 2018-03-02 11:59:32 -08:00
Eeshan Garg
5069683cad decorators: Refactor the webhook_logger code.
Just to make the code a bit cleaner and to be able to reuse the
same logging code in other decorator functions.
2018-03-02 11:56:20 -08:00
Tim Abbott
335c383bbb lint: Add some excludes to capitalization linter. 2018-03-02 11:55:46 -08:00
Tim Abbott
895b5642f1 commit-message-list: Don't print anything if no commits.
This fixes some output spam when running the linter at
upstream/master.
2018-03-02 11:51:08 -08:00
Eeshan Garg
ea7ce7e0da api docs: Ensure consistent formatting for arguments.json.
Ideally, there should be a space after every `:`.

Note that the JSON isn't displayed as is but is formatted as an
HTML table.
2018-03-02 09:44:17 -08:00
Eeshan Garg
ce56ee80e7 api_docs: Document the POST /api/v1/user_uploads endpoint.
Fixes #1353.
2018-03-02 09:44:17 -08:00
Tim Abbott
50d8a24368 styling: Fix red styling for message edit close button. 2018-03-02 09:39:17 -08:00
Utkarsh Patil
0dde559cf7 Uniform color styling for all 'Cancel' buttons.
Change the color of all red Cancel buttons to black. Fixes #8548.
2018-03-02 09:38:13 -08:00
Tim Abbott
14764d015a settings: Tag cookie bot placeholder short name for translation. 2018-03-02 09:33:16 -08:00
Tim Abbott
e18537d842 emoji: Add a translation tag for new_emoji placeholder. 2018-03-02 09:32:09 -08:00
Tim Abbott
9c4b0cc100 lint: Clean up translation tag lint for filter settings. 2018-03-02 09:30:42 -08:00
Tim Abbott
f9210bace8 lint: Add a translation tag for marketing. 2018-03-02 09:28:57 -08:00
Joshua Pan
5777582013 lint: Tighten placeholder lint rule to exclude links.
Fixes #8420.
2018-03-02 09:24:09 -08:00
Tim Abbott
5ccd3aa71b i18n: Run process-mobile-i18n when syncing translations. 2018-03-02 08:59:00 -08:00
Tim Abbott
66e543443e i18n: Update translations data from transifex. 2018-03-02 08:57:37 -08:00
Vishnu Ks
56e54262c3 api: Create api for creating multiuse invites. 2018-03-02 11:28:36 +00:00
Umair Khan
5086ba8568 push_notification: Update comment for unregister. 2018-03-01 22:14:32 -08:00
Umair Khan
8a8b0dd87d code-search: Add comments to help grepping. 2018-03-01 22:14:32 -08:00
Tim Abbott
483876ff9a typeahead: Remove check for impossible case.
The pre-matching that occurs before we even get here makes it
impossible for this case to occur, and it causes a test coverage
error.
2018-03-01 21:22:59 -08:00
Tim Abbott
ff197b209f help: Advertise custom linkification filters better.
Closes #5931, by merging the result of the discussion there.
2018-03-01 21:08:03 -08:00
Tim Abbott
3be0b3dd91 mypy: Fix errors in linter.
We should figure out a better way to manage this issue.
2018-03-01 20:33:30 -08:00
Shubham Padia
8722c755e3 onboarding: Add bouncing ? next to hotspots.
Fixes #8124.
Adds bouncing question mark with twice the frequency of the
pulse.
2018-03-01 20:23:51 -08:00
Rhea Parekh
6a07897d3a slack importer: Fetch and save the avatars.
This gets the avatar of size 512 px and saves it in the
user's avatar directory with both the extensions
'.png' and '.original'.
2018-03-01 16:49:37 -08:00
Rhea Parekh
0f183981e6 Import script: Make sure medium avatars exist during import.
During a slack import, we don't have medium-size avatars already
available in the export data set (and possibly also with a normal
import/export?).  The medium size avatar can be created by the
'ensure_medium_avatar_image' function, which checks if the medium
image exists, and if it doesn't, it creates the image.

This commit was substantially edited by tabbott to get rid of an
undefined variable bug, avoid initializing the upload backend classes
in a loop, and add some TODO notes on things that could be improved
later.
2018-03-01 16:48:06 -08:00
Rhea Parekh
7076a49e04 slack importer: Pass avatar data through the import script. 2018-03-01 16:41:49 -08:00
Rhea Parekh
30b9d35d5e slack importer: Add helper functions to get user avatars.
Here, we create the slack avatar url using the user data and
build the avatar object. Added Tests for the same.
2018-03-01 16:38:55 -08:00
Rhea Parekh
95df8452be slack importer: Remove function 'get_user_avatar_source'.
slack avatar urls have the format:
'https://ca.slack-edge.com/<team_id>-<user_id>-<avatar_hash>-<size>'
For any url of this form, if the user hasn't uploaded an image,
Slack uses default gravatar, but we don't have a way of knowing if Slack
has used the uploaded image or the custom gravatar
eg: https://ca.slack-edge.com/T5YFFM2QY-U6006P1CN-gd41c3c33cbe-512.
Hence, avatar_source should be mapped to 'U'.
2018-03-01 16:38:55 -08:00
Tim Abbott
8d00266fd6 lint: Add a linter rule banning use of sudo in most scripts.
This should help prevent against bugs where we accidentally introduce
use of sudo somewhere in the production installer or upgrade code path
(these used to happen all the time), which doesn't work on production
systems that don't have sudo setup.
2018-03-01 16:30:31 -08:00
Tim Abbott
542f4766d3 typeahead: Fix last word issues with latest typeahead feature.
Apparently, a bug in my refactor in
5edbcb87fd meant that "King L" would end
up matching "King Hamlet", because we weren't requiring a match at the
start of the word for the last word of a multi-word query.

Thanks to Greg Price for the report.
2018-03-01 16:00:33 -08:00
Greg Price
53c57cf002 errors: Include request info on error mails for JSON routes too.
When our code raises an exception and Django converts it to a 500
response (in django.core.handlers.exception.handle_uncaught_exception),
it attaches the request to the log record, and we use this in our
AdminNotifyHandler to include data like the user and the URL path
in the error email sent to admins.

On this line, when our code raises an exception but we've decided (in
`TagRequests`) to format any errors as JSON errors, we suppress the
exception so we have to generate the log record ourselves.  Attach the
request here, just like Django does when we let it do the job.

This still isn't an awesome solution, in that there are lots of other
places where we call `logging.error` or `logging.exception` while
inside a request; this just covers one of them.  This is one of the
most common, though, so it's a start.
2018-03-01 15:12:32 -08:00
Lyla Fischer
2692ffd408 user docs: Split sidebar link for change-the-privacy-of-a-stream. 2018-03-01 15:11:05 -08:00
Lyla Fischer
63841f4567 user docs: Add 'See all images in a narrow' to sidebar. 2018-03-01 15:11:05 -08:00
Lyla Fischer
1bd56d416e user docs: Reword sidebar link for mute-a-topic and mute-a-stream. 2018-03-01 15:11:05 -08:00
Greg Price
72497d61c1 test-migrations: Clean up a bit. 2018-03-01 15:03:55 -08:00
Greg Price
6d35a697af antispam: Don't let new accounts in open realms immediately send invites.
We haven't had a problem with this yet, but this should help prevent it.
2018-03-01 14:56:19 -08:00
Tim Abbott
5edbcb87fd typeahead: Rewrite query_matches_source_attrs to be obviously correct.
This restructures this fairly complicated function to a much cleaner
implementation, with fewer unnecessary variables and a cleaner flow.
While we're at it, we document the function.
2018-03-01 14:45:09 -08:00
YJDave
245d65eb9e compose typeahead: Don't autocomplete for suffixes followed by a space.
For "#word text" (and similar situations, like "@word text" and
":word text"), we should only show the autocomplete for entries
where word matches the full first word of something being
completed (and similarly for multi-word phrases).

Fixes #8279
2018-03-01 14:45:09 -08:00
Steve Howell
1338b99356 casper: Avoid nesting wait statements to avoid flakes.
This test had flaked before. Nesting waitUntilVisible
statements is generally discouraged in casper tests.
2018-03-01 14:20:22 -08:00
Aditya Bansal
bd0a5d5d69 css-minifier: Lint for '+' operator in calc().
Fixes: #8403.
2018-03-01 13:26:16 -08:00
Vishwesh Jainkuniya
aae11bf88d setting: Fix password label is even shown when email auth is disabled. 2018-03-01 12:38:07 -08:00
Weronika Grzybowska
1f52eea0e4 user docs: Document auto-numbering of ordered lists.
Fixes #8246
2018-03-01 12:05:31 -08:00
Tim Abbott
6b31752f82 user_groups: Change placeholder group to "Marketing team".
This is much more something that would apply to likely customer
organizations.
2018-03-01 11:28:24 -08:00
Vishnu Ks
36f6ad76b4 admin ui: Set usergroup name input maxlength to 100.
Same as that of the maxlength defined in backend.
2018-03-01 11:27:26 -08:00
Vishnu Ks
ed4fbcfd73 admin ui: Set usergroup description input maxlength to 300. 2018-03-01 11:27:26 -08:00
Vishnu Ks
497ee97ce3 models: Change description attribute of user group to textfield. 2018-03-01 11:27:26 -08:00
rht
71ff8c370e django-2.0: Don't assign directly to Many-to-Many field.
The old pattern of setting the value and then using .save() here has
been deprecated.  set() also saves the record.
2018-03-01 08:49:35 -08:00
Alena Volkova
e4a62aa778 compose: Add a function for handling validation errors. 2018-03-01 08:40:51 -08:00
Robert Hönig
695b3e48e8 frontend: Add embedded bot config data editing. 2018-03-01 08:25:43 -08:00
Robert Hönig
7b7f4cc62d bot settings: Generate embedded bot selector in handlebars.
It's better to do stuff like this in HTML templates like
handlebars instead of JS.
2018-03-01 08:25:43 -08:00
Robert Hönig
044b0beeab frontend: Store embedded bot data in bot_data.js.
In specific, this stores config_data and service_name
for embedded bots.
2018-03-01 08:25:43 -08:00
Robert Hönig
48b2e4eb66 backend: Add bot config data patching. 2018-03-01 08:25:43 -08:00
Robert Hönig
312cabb9a6 models.py: Move two long functions with circular imports to actions.py.
models.py should only contain thin wrapper functions. Furthermore,
this move allows us to remove the circular imports. The two moved
functions are interdependent and are thus moved in one commit.
2018-03-01 08:25:43 -08:00
Robert Hönig
ade077ff73 backend: Add bot config data to initial state data. 2018-03-01 08:25:43 -08:00
Tim Abbott
fd4aa88046 api: Do paragraphs within bullets with better indentation.
This is necessary to ensure the "Hint" appears indented as part of the
bullet.
2018-03-01 08:21:53 -08:00
Viraat Chandra
9284d32837 docs: Improve consistency and quality of API Documentation. 2018-03-01 08:21:53 -08:00
Shubham Dhama
d6a38901ae compose: Fix clearing of existing text on replying from popovers.
compose_action.respond_to_message and compose_action.start starts new
compose box so we should check whether we are already composing
or not. So, behavior, when we are composing, is that the user we want
to mention is added to the same compose-text without the changing stream
and topic name.
2018-03-01 08:00:42 -08:00
Shubham Dhama
dcac002213 compose: Use insert_syntax_and_focus to insert text in compose textarea.
Use compose_ui.insert_syntax_and_focus() when we need to insert text
inline-ly followed by the focus to compose textarea because it does
this job more smartly(it take cares of spaces).
2018-03-01 08:00:42 -08:00
Shubham Dhama
c995c1a36a popovers: Fix two click handler attached to (rightbar) user_popovers.
No need to have separate click handler for user_popovers and
message_info_popovers as the same user-id can be extracted similarly
from the target of both the click events.

Another refactor, `sender_info_popover` was confusing as it doesn't
fix into the context of rightbar user popovers so changed it to
`info_popover_actions` since that section of popovers contains popover
actions.
2018-03-01 08:00:42 -08:00
Steve Howell
2d8c1f6d93 zjquery: Give clear error when handlers are not set. 2018-03-01 06:46:17 -05:00
sinwar
5e6649ba87 docs: change the dev login image.
It updates the image of developer login on localhost.
2018-02-28 13:50:13 -08:00
Vishnu Ks
8152532535 urls: Use /new endpoint for creating new realm.
This is just nicer-looking for potentially nontechnical users than
/create_realm.
2018-02-28 13:47:54 -08:00
Alena Volkova
91983834e6 integrations: Add documentation for Front. 2018-02-28 16:18:19 -05:00
Alena Volkova
822dfc6a34 integrations: Add webhook code, API endpoint, and tests for Front. 2018-02-28 16:18:19 -05:00
Alena Volkova
c45acad24b integrations: Add webhook payloads for Front. 2018-02-28 16:18:19 -05:00
Abhishek Sharma
b4a6df8547 portico: Fix text overflow on Zulip features page.
This (hackishly) fixes a minor issue in the features page's responsive
design.
2018-02-28 13:07:49 -08:00
Vishnu Ks
120ac21515 bugdown: Create a constant for inline preview limit. 2018-02-28 12:53:36 -08:00
Tim Abbott
f24c0203fd dev_tools: Add invalid confirmation error page to devtools.
This just makes it a bit easier and more self-service to get to this
category of error pages.
2018-02-28 12:51:19 -08:00
Utkarsh Patil
2e6b65ac22 Fix styling for confirmation error links.
This converts our confirmation error links to match the nicer visual
style of our configuration error and 404 pages.

Fixes #7193.
2018-02-28 12:50:58 -08:00
Tim Abbott
2787ae01f5 error_pages: Shrink heading font size.
This will make things look better with longer heading-error messages
(e.g. the confirmation link errors).
2018-02-28 12:45:13 -08:00
Aastha Gupta
d124597f4b org-settings: Add setting to turn off welcome emails.
This adds an organization-level setting to provide an option to turn
off the welcome emails.

Fixes #8000.
2018-02-28 12:39:01 -08:00
Robert Hönig
71829f3373 Test MessageSenderWorker with Electron as user agent.
This brings MessageSenderWorker coverage to 100%.
2018-02-28 12:31:38 -08:00
Robert Hönig
f8338803d9 Add tests for SignupWorker error handling.
This brings SignupWorker coverage to 100%.
2018-02-28 12:31:38 -08:00
Robert Hönig
1ba1851664 QueueProcessingWorker: Test that problems get logged.
This brings QueueProcessingWorker coverage to 100%.
2018-02-28 12:31:38 -08:00
Robert Hönig
9bee64de93 Exclude QueueProcessingWorker.stop() from coverage test.
This function is just a one-line wrapper, so adding
coverage isn't important.
2018-02-28 12:31:38 -08:00
Robert Hönig
3294aa6ac4 embedded bots: Test that BotHandler.initialize is called.
This brings coverage for EmbeddedBotWorker to 100%.
2018-02-28 12:31:38 -08:00
Greg Price
4475950ddf queue: Restore prematurely-cut upgrade path.
Revert c8f034e9a "queue: Remove missedmessage_email_senders code."
As the comment in the code says, it ensures a smooth upgrade path
from 1.7.x; we can delete it in master after 1.8.0 is released.
The removal commit was merged early due to a communication failure.
2018-02-28 11:15:53 -08:00
Greg Price
49252c97d2 docs: Fix explanation of Debian LXC installation.
This didn't really make much sense - it presented a quickstart summary
of the instructions as an item in the list of differences from the
Ubuntu case, plus that quickstart only incorporated one of the two
actual differences so it didn't work anyway.  Given the networking
stuff, an actual quickstart isn't in the cards, so just cut that.

Also fix some small things while we're here.
2018-02-27 17:16:31 -08:00
Alicja Raszkowska
f6f1236c71 translations: Improve Polish style guide.
Co-authored-by: AjgorXD <34320704+AjgorXD@users.noreply.github.com>
2018-02-27 14:56:33 -08:00
Robert Hönig
ae9952c763 backend tests: Repurpose test_invalid_embedded_bot_service.
Previously, this function executed the same test as
test_bots.py/test_create_embedded_bot_with_incorrect_service_name().
Now, instead of testing to add an embedded bot with an incorrect service
name, we test messaging an embedded bot with an incorrect service
name.
2018-02-27 12:20:08 -05:00
Robert Hönig
b780b16f57 test_bots.py: Split up test_create_embedded_bot. 2018-02-27 12:20:08 -05:00
Robert Hönig
a99cc6170f test_bots.py: Create test bots with create_test_bot(). 2018-02-27 12:20:08 -05:00
Robert Hönig
19bbc0e6f8 backend tests: Use correct bot owner in create_test_bot().
The correct owner is the one specified in the user_profile
parameter, which is different from self.user_profile.
2018-02-27 12:20:08 -05:00
elenaoat
7b455f597b compose: Add spaces around markdown for attachments.
If your cursor is in the middle of a word when you upload
an image, the code will now properly put spaces in the markdown
around the attachment link.

Fixes: #7212.
2018-02-27 11:58:36 -05:00
Rishi Gupta
76898dd4d3 integrations: Make minor wording changes to integrations docs. 2018-02-27 08:23:51 -08:00
Abhigyan Khaund
a75f0aa594 hotkeys: Add "p" to narrow to next unread PM thread.
This works simimlar to the "n" key for next topics.

This commit does a few things:

    * It wires up the hotkey to an existing function
      that could change narrows.
    * It adds documentation.
    * It adds logic to make sure the compose box does
      not open.

@showell helped a bit with the wording of comments here.

Fixes #4874
2018-02-27 07:20:31 -05:00
Tim Abbott
68664acf1f requirements: Update sqlalchemy to 1.2.4.
This requires updating one of the tests for the group_pm_with feature
in test_narrow to use the new style of tautology generated by SQLAlchemy.

Thanks to Sinwar for investigating this.

Fixes #8381.
2018-02-26 21:32:27 -08:00
Tim Abbott
227e5fdcc2 test_narrow: Improve group_with_with search test.
The previous test structure was weird, in that it didn't cover the
case where there was at least one group PM thread.
2018-02-26 21:32:27 -08:00
Catherine Kleimeier
d032e1ad96 Node Unit Tests: Create test for notifications.message_is_notifiable
We create a node unit test,
with 'muting' and 'stream_data' modules as dependencies,
to test the logic in notifications.message_is_notifiable.

Part of #2945
2018-02-26 16:50:14 -05:00
Eeshan Garg
1516e51126 webhooks/gitlab: Support both "Build Hook" and "Job Hook" events.
GitLab recently changed their event name for build notifications
from "Build Hook" to "Job Hook". Instead of just supporting the
latter, we should support both just in case people are running
older versions of GitLab.
2018-02-25 09:35:07 -08:00
Rhea Parekh
3bb14a867b slack importer: Change 'invite_only' mapping in streams.
'invite_only' should always be true for the slack's
standard export plan as the private channels are not
supported in it.
2018-02-25 09:22:01 -08:00
Rhea Parekh
a2f6f4ba1c slack importer: Handle case where messages have no users. 2018-02-25 09:20:55 -08:00
Rhea Parekh
15a6f62fe7 slack importer: Refactor defaultstream handling.
The check for the channel ('general' and 'random') must be added before
'build_defaultstream' function is called and then the id is incremented.
Otherwise, the id appended at the end of second defaultstream object, which would be
greater than the total number of defaultstream objects would crash at
'defaultstream_id_list[defaultstream_id]' which is a paramater of 'build_defaultstream'.
Added tests to prevent the same.
2018-02-25 09:20:55 -08:00
Tim Abbott
710f5f7c97 auth: Add support for mobile_flow_otp for RemoteUserBackend.
Because we have a pretty good framework for the existing
mobile_flow_otp system, this requires very little new code.

Fixes #8291.
2018-02-24 08:14:17 -08:00
Tim Abbott
34efab9157 auth: Report to mobile apps the availability of RemoteUserBackend.
This is necessary for mobile apps to do the right thing when only
RemoteUserBackend is enabled, namely, directly redirect to the
third-party SSO auth site as soon as the user enters the server URL
(no need to display a login form, since it'll be useless).
2018-02-24 08:14:17 -08:00
Nick Al
cab3c8c32c populate_db: Spread message timestamps over a few days.
This makes it easier to work on features that depend on messages
having been sent in the past (E.g. the date parts of recipient bars).

The new feature only works with --threads=1; since with the ~100
default messages that populate_db generates, the multi-threaded
feature shouldn't have significant performance impact (and it would be
tricky to make increasing timestamps work with the multi-threaded
model), it's reasonable to just set the default number of threads to 1
for now and have this timestamp-spreading feature only supported with
--threads=1.

Fixes #8277.
2018-02-24 08:11:27 -08:00
Tim Abbott
db88634bcf docs: Better document how Debian LXC installation works.
This fixes an issue where users would try to setup LXC networking
before installing the LXC package.

Fixes #8503, thanks to @Shobitha-M for reporting.
2018-02-24 07:45:58 -08:00
Eeshan Garg
fbbdc0110a webhooks/gitlab: Replace "Build Hook" with "Job Hook".
At some point, GitLab decided to change the name of the event for
CI notifications from "Build Hook" to "Job Hook" and we started
running into errors in webhook-logger.log.
2018-02-24 06:22:19 -05:00
Eeshan Garg
6ddc0b75ac webhook_md_macros: Stop using transition words.
Transition words make it harder to reuse macros in different
contexts and can lead to unintended errors. Thanks to Rishi
Gupta for suggesting this!
2018-02-24 06:21:02 -05:00
Eeshan Garg
096c0b68f3 webhooks/basecamp: Update text and remove screenshots.
This commit:

* Removes the unnecessary screenshot. The UI is intuitive enough
  and standalone instructions should suffice.
* Rearranges the instructions into 4 steps.
* Makes the wording more explicit.
2018-02-24 06:21:02 -05:00
Eeshan Garg
3b7598014f webhooks/appfollow: Update text and remove screenshot.
This commit:

* Removes the unnecessary screenshot. The user should be able to
  easily see the fields in question in this case.
* Wraps the text at 80 chars.
* Combines the instructions into 4 steps.
2018-02-24 06:21:02 -05:00
Eeshan Garg
ed345427e5 webhooks/airbrake: Combine instructions into 4 steps.
The docs for this can easily be combined into 4 steps. For
uncomplicated setups, 4 seems to be like a good number.

Again, I have no way of verifying the correctness of the instructions
here because Airbrake doesn't let you do anything till you specify
your credit card information, which I didn't want to.
2018-02-24 06:21:02 -05:00
Eeshan Garg
4d410a5eb7 webhooks/gci: Update text.
This commit modifies the text to:

* Use number 1 for all steps and let Markdown take care of the rest.
* Removes the line that says this webhook is "experimental". It isn't
  anymore.
2018-02-24 06:21:02 -05:00
Eeshan Garg
9667594a34 webhook/delighted: Update text and remove screenshot.
This commit modifies the doc.md to:
* Use consistent language and style.
* Use the number 1 for all numbered steps and let Markdown take
  care of the rest.
* Have detailed steps on how to get to the Integrations settings
  instead of just linking to the page.
* Remove unnecessary screenshots.
2018-02-24 06:21:02 -05:00
Eeshan Garg
e139d29fca webhooks/codeship: Update text and remove screenshots.
This commit:

* Adds a missing step to the documentation.
* Replaces wording such as "Go to X" with "Click on X".
* Removes the unnecessary screenshots.
* Rearranges the doc to contain only 4 steps. For uncomplicated
  setups, 4 seems to be the right number.
2018-02-24 06:21:02 -05:00
Eeshan Garg
0d39b05cf6 webhooks/beanstalk: Update text and remove screenshots.
This commit:

* Removes the unnecessary screenshot.
* Reorders the instructions and combines them in to 4 steps.
* Improves the contents of the webhook-url-with-bot-email-indented.md
  macro and makes it more consistent with create-bot-construct-url.md.
* Sets the recommended stream name to "commits", since that's what
  the webhook function for Beanstalk expects in
  zerver/webhooks/beanstalk/view.py. This allows us to use the
  create-stream.md macro.
2018-02-24 06:21:02 -05:00
Eeshan Garg
df4c645587 integrations: Make sure settings.EXTERNAL_URI_SCHEME renders.
This got broken at some point when we moved around the context
processing logic for integrations/webhooks. Thankfully, the
context value for external_uri_scheme was only used in a couple of
our less popular integration docs. It should render perfectly now.
2018-02-24 06:21:02 -05:00
Eeshan Garg
e94efe5497 markdown macros: Add create-a-bot-indented macro. 2018-02-24 06:21:02 -05:00
Eeshan Garg
bd787c12c4 webhooks/bitbucket2: Update text and remove screenshots.
* Remove unnecessary screenshot. It doesn't help very much in this
  case.
* Update text to instruct users to not leave the `Title` field
  empty (it cannot be blank).
* Replace wording such as `Go to Settings` with `Click on Settings`.
* Combine the "fill out the form" and "click 'Save'" steps.
* Replace "Choose X on the left-hand side" with "Choose X".
* Replace "Remember to check the X" with "Check the X".
2018-02-24 06:21:02 -05:00
Aastha Gupta
2f99e6b7b2 settings: Add loading indicator for account deactivation.
Fixes #8175.
2018-02-23 08:20:45 -08:00
Tim Abbott
65767e5226 localhost_sso: Fix missing enabling of mod_wsgi.
This is apparently required on Ubuntu Xenial, at least.
2018-02-22 10:09:29 -08:00
Aditya Bansal
f50e325075 RealmAuditLog: Fill subscription events with event_last_message_id=None.
Creating the very first organization administrator user and
subscribing them to streams before any messages were sent resulted in
RealmAuditLog entries being created with a `event_last_message_id` of
None, because that's the maximum ID in the empty set.

We correct this by fixing the incorrectly created RealmAuditLog
entries, both for new servers and also fixing old broken entries on
existing servers.

This fixes an issue where if a user setup a Zulip server with just the
organization administrator, and then forgot about it (so that the
initial user became soft-deactivated), trying to sign in 3 weeks later
would throw an exception.

This fixes the issue reported here:

https://chat.zulip.org/#narrow/stream/9-issues/subject/500.20error.20on.20login/near/511981
2018-02-22 09:45:22 -08:00
Sampriti Panda
90c89dcc5a copy_and_paste: Fix quirks with some parts of toMarkdown.
* Raw links don't use the proper markdown syntax and get pasted as is.
* Text in Ordered List format are not escaped like in normal markdown.
2018-02-22 08:26:45 -08:00
Umair Khan
db1e090c6a django-auth-ldap: Bump version to 1.3.0.
The name of _get_user_attrs was changed to attrs in
152d40a2a0

Fixes #8380
2018-02-22 05:39:04 -08:00
Umair Khan
7ad177abe6 i18n: Flag emojiset type name string for translation.
The other emojiset types are things like "Google", and "Twitter",
which don't need to be translated.  And the string is already tagged
for translation as a variable where it is used here:

  static/templates/settings/display-settings.handlebars#L87

Fixes #7970.
2018-02-22 05:36:03 -08:00
Tim Abbott
faa3c275de test_narrow: Use a better assert for easier debugging.
This should provide much better error messages.
2018-02-22 05:32:03 -08:00
Umair Khan
c8f034e9a0 queue: Remove missedmessage_email_senders code.
After 68513952fb, all emails are sent through email_senders queue.
This commit removes code related to the legacy queue.
2018-02-21 16:43:56 -08:00
Vishnu Ks
7d3b41b039 requirements: Upgrade psycopg2 to 2.7.3.4.
psycopg2 package contains both binary and source
currently.The binary would soon be only available
in psycopg2-binary. So currently installing psycopg2
will show a warning about the future migration of binary.
To avoid the warning we should only install the source.

https://www.postgresql.org/message-id/CA%2Bmi_8bd6kJHL
TGkuyHSnqcgDrJ1uHgQWvXCKQFD3tPQBUa2Bw%40mail.gmail.com
2018-02-21 13:14:59 -08:00
Shubham Dhama
b17d4e193c popovers: Show hotkey reminder for sender info popovers only.
Hotkey reminders in user popovers( i.e. `@` and `R`) should be present
only for sender info popovers, hence for user-mention and user-presence
popovers it will show no such reminders.

Fixes: #8313.
2018-02-21 13:06:22 -08:00
Harshit Bansal
cf203db78a emoji: Remove now unused emojis_name_to_css_class dict. 2018-02-21 12:48:27 -08:00
Harshit Bansal
31baf25783 emoji picker: Change the delimiter used in emoji_id.
We were using underscore as a delimiter in `emoji_id` in emoji picker
but since `emoji_type` also contains underscores, it seems wrong to
use underscore as a delimiter. This commit switches `emoji_id` to use
comma as a delimiter instead of underscore.
2018-02-21 12:48:27 -08:00
YJDave
87a5cd306e org settings: Fix bug of reloading page on Enter in active user setting.
In active user section, while editing user's full name,
if we press enter it reloads the whole page, rather than
submitting the form.
Change button type of user-name-form to submit.
2018-02-21 09:23:41 -08:00
YJDave
105093e3f4 org settings: Fix bug in edit user-name-form in active user setting.
In active user settings, when user click on user-name-form to edit
user's full name, we don't set any default value for full-name
input field, which results in garbage or falsy value in input field.

Set true value of selected user's full name in input field by default
in user-name-form.
2018-02-21 09:16:45 -08:00
YJDave
4119eb342d org settings: Display error message on top of active user setting page.
Currently, an error message on active user setting is showing at
the row of edited user profile in user-profiles-list-table.
Instead, show error message on top of setting page.

Tweaked by tabbott to also remove the HTML element.
2018-02-21 09:11:53 -08:00
YJDave
dc2b505acb org settings: Fix bug in error reporting on active users setting.
In active users setting, an errors occurred on editing user
profiles, are not reported correctly because there is missing
argument in call of ui_report.error() function.
Fix the issue by passing proper arguments in ui_report.error()
function call.
2018-02-21 09:11:46 -08:00
Abhishek Sharma
d17bdf19dd portico: Highlight active page's title in navbar on why-zulip page. 2018-02-21 09:02:20 -08:00
Rhea Parekh
e98dd63415 fixtures: Update description in zerver_realm_skeleton.json. 2018-02-21 08:58:27 -08:00
Rhea Parekh
816024455c fixtures: Remove unnecessary field from zerver_realm_skeleton.json
'string_id' is already being set in the slack import script.
See https://github.com/zulip/zulip/blob/master/zerver/lib/slack_data_to_zulip_data.py#L111.
2018-02-21 08:58:27 -08:00
Rhea Parekh
aff9099c3b slack importer: Get domain name from settings.EXTERNAL_HOST. 2018-02-21 08:58:27 -08:00
Anurag Sharma
a6e5a5f86d user docs: Fix double scrollbar on navigation on /help.
Only one scrollbar now appears on the navigation
on /help page, for smaller screen sizes.

Fixes #8470.
2018-02-21 08:43:20 -08:00
Rhea Parekh
f6d267e773 slack importer: Change 'total_users' to 'total_channels'.
The total number of stream objects are allocated to
total_users. They should be allocated to the total_channels.
This passed the tests as the total number of users in the test
where greater than the total number of channels.
2018-02-21 08:06:10 -08:00
Umair Khan
d22639717c auth: Redirect to an error page instead of 500.
Previously, we used to raise an exception if the direct dev login code
path was attempted when:

* we were running under production environment.
* dev. login was not enabled.

Now we redirect to an error page and give an explanatory message to the
user.

Fixes #8249.
2018-02-20 22:34:53 -08:00
Eeshan Garg
96036f07a3 api_code_example: Use json instead of ujson; specify separators.
The Markdown extension that lives inside
zerver/lib/bugdown/api_code_example.py previously used ujson.
ujson's `dumps` function doesn't accept a `separators` argument,
which means we have no control over how the JSON is pretty-printed.
This resulted in JSON fixtures with no spaces after the colon, which
looks unnecessarily convoluted.

So now, we use the built-in `json` module to get around this.

For further reading, this issue
<https://github.com/esnme/ultrajson/issues/82> opened on ujson's
repo explains why they are reluctant to support such formatting
due to performance considerations.
2018-02-20 20:10:38 -03:30
Eeshan Garg
e80609a3e9 api docs: Test sample fixture for invalid stream name error.
This commit adds a test for the sample fixture for when an invalid
stream name is passed to a query that expects a valid stream name
as an argument. This is the case with almost all of our queries
documented under the sidebar heading "Streams".

EDIT: Actually, I was wrong. This payload is highly specific to
get-stream-id, so it shouldn't be a part of common-error-payloads
at all.
2018-02-20 20:03:55 -03:30
Eeshan Garg
9add5bf6a7 api/delete-queue: Test fixture for BAD_EVENT_QUEUE_ID error.
In templates/zerver/api/delete-queue.md, we have a sample fixture
for when the queue_id passed to client.deregister_queue is not
valid or the event queue in question has already been deleted.
This commit tests that fixture.

Note that this error payload is specific to client.deregister_queue.
2018-02-20 14:54:12 -08:00
Eeshan Garg
a0818975fb api/create-user: Test fixture for "email already in use" error.
In templates/zerver/api/create-user.md, we have a sample fixture
for when a client attempts to create a user with the same email
as an existing user. This commit adds a test for that fixture.

Note that this error payload is specific to client.create_user
and this error payload isn't generated anywhere else.
2018-02-20 14:54:12 -08:00
Eeshan Garg
be0a04f33e api docs: Test sample fixtures for unauthorized_errors_fatal.
This commit adds tests for the sample fixtures for when
unauthorized_errors_fatal is passed to client.add_subscriptions.
2018-02-20 14:54:12 -08:00
Eeshan Garg
806476173f api/add-subscriptions: Test fixture for "already_subscribed".
In templates/zerver/api/add-subscriptions, we have a sample fixture
for when the user being subscribed is already subscribed to a
stream. This commit tests that fixture against a running server.
2018-02-20 14:54:12 -08:00
Eeshan Garg
06bf47d2f5 api docs: Test sample fixture for user not authorized error.
This commit adds tests for the fixture for when a user is not
authorized (perhaps because the query requires the use of admin
privileges) for a particular query.
2018-02-20 14:52:09 -08:00
Eeshan Garg
124c672a7c api docs: Test sample fixture for message edit permission error.
In templates/zerver/api/update-message.md, we have a sample fixture
for when a zulip.Client does not have the permission to update/edit
a particular message. This commit adds a test for that fixture.
Also, tools/test-api now also uses a non-admin client for this test,
which might come in handy in the future.
2018-02-20 14:52:09 -08:00
Eeshan Garg
1c32163bb9 api docs: Test sample fixture for missing request args error.
This commit adds tests for the sample fixture for when a required
request argument is missing. Also, it moves the sample fixture
to common-error-payloads.md, since this is an error payload that
is common to most requests (except the ones that don't take any
arguments).
2018-02-20 14:52:09 -08:00
Eeshan Garg
d1a5bbc2a5 api docs: Test sample fixture for invalid PM recipient error.
In templates/zerver/api/private-message.md, we have a sample fixture
for when the email address of the PM's recipient is invalid. This
commit makes sure that fixture is tested against a running server.
2018-02-20 14:52:09 -08:00
Eeshan Garg
93b44a41c5 api docs: Test sample fixture for nonexistent stream error.
In templates/zerver/api/stream-message.md, we have a sample fixture
for when the target stream does not exist. This commit adds a test
for that sample fixture.
2018-02-20 14:52:09 -08:00
Brock Whittaker
4d54515455 input-pill: Add copy override functionality for input pills.
When a pill is selected and you press copy, it will by default return
the value, but it can be overridden with the `onCopyReturn` function.
2018-02-20 14:18:11 -08:00
Brock Whittaker
bee0fa4001 input-pill: Disable input of commas with invalid pills.
A user should not be able to start forming a new pill if the previous
pill is invalid.
2018-02-20 14:11:51 -08:00
Brock Whittaker
4cd25fb861 input-pill: Add multiple pill support with pasting.
This allows for pasting in comma separated lists that will validate
pills on paste, along with creating an API for inserting many pills.

This now allows in the `input_pill.pill.append` a comma separated list
that will then call the `insertManyPills` method that will break up the
input and then call `append`.
2018-02-20 14:11:47 -08:00
Tim Abbott
6479f32c7c dependencies: Downgrade pika to avoid constantly logged errors.
With the new pika 0.11.2, we got a lot of errors from pika on
chat.zulip.org.  See #8466 for details.
2018-02-20 14:03:07 -08:00
Aditya Bansal
b1417860a9 create-thumbor-venv: Specify python 2.7 use for production thumbor venv. 2018-02-21 01:00:40 +05:30
Aditya Bansal
dedef11fe5 thumbor: Upgrade thumbor to v6.4.1. 2018-02-21 01:00:40 +05:30
Tim Abbott
a1408a9d3a mypy: Remove unnecessary use of typing.Text. 2018-02-20 10:57:59 -08:00
Aditya Bansal
b0c0648a4f clean-venv-cache: Handle cleaning up zulip-thumbor-venv properly. 2018-02-20 10:57:32 -08:00
Akash Nimare
9dba134c7a markdown: Do not use CMD+CTRL on macOS.
This fixes an issue where we allowed both the CMD+CTRL keys for our
compose markdown shortcuts.  The correct behavior is to allow either
Cmd or Ctrl, based on whether it's MacOS (Cmd) or Ctrl
(Linux/Windows), to match how those platforms work.

Fixes #8430.
2018-02-20 09:50:10 -08:00
Steve Howell
1f6ddf0110 refactor: Extract transmit.js from compose.js.
We now isolate the code to transmit messages into transmit.js.
It is stable code that most folks doing UI work in compose.js don't
care about the details of, so it's just clutter there.  Also, we may
soon have other widgets than the compose box that send messages.

This change mostly preserves test coverage, although in some cases
we stub at a higher level for the compose path (this is a good thing).
Extracting out transmit.js allows us to lock down 100% coverage on that
file.
2018-02-20 09:29:26 -08:00
Vaida Plankyte
80ff3d8da5 frontend: Reduce opacity of hotkey hints.
This helps these draw a bit less attention.
2018-02-19 11:53:37 -08:00
Vaida Plankyte
0e17d7763b frontend: Replace collapse hotkey (-) with em-dash (–) for readability. 2018-02-19 11:50:46 -08:00
Tim Abbott
4a92ed4332 test_signup: Remove accidentally merged print statements. 2018-02-19 11:46:39 -08:00
Steve Howell
61aaf06abe tests: Fix hard coded "Over 80 native integrations".
This is a quick fix to get the builds working again.  Our
code will say "Over <N> integrations", where N keeps growing over
time.
2018-02-19 14:18:03 -05:00
Vishnu Ks
1a1bc84d2c subdomain: Check for invalid characters before length.
I think it makes more sense to first tell the user that
the character you are entering is invalid than telling
minimum length requirement is not satisfied.

Fixes #3058.
2018-02-19 10:45:17 -08:00
Vishnu Ks
6664c76a10 signup: Remove old frontend validation of subdomain.
We make request to check availibity of subdomain which also checks the
subdomain for illegal characters.  Duplicating the backend logic in
frontend in this case is thus no longer necessary.
2018-02-19 10:45:17 -08:00
Vishnu Ks
d34dd4cd02 signup: Show subdomain availability during signup.
This uses an actual query to the backend to check if the subdomain is
available, using the same logic we would use to check when the
subdomain is in fact created.
2018-02-19 10:45:17 -08:00
rht
70a41cc2eb tools/tests: Use Python 3 syntax for typing. 2018-02-19 10:17:03 -08:00
Shubham Dhama
da65e1dcb6 drafts: Sort drafts by last modified.
This moves the last modified draft to bottom.
2018-02-19 09:55:50 -08:00
Shubham Dhama
804a5f3306 drafts: Add timestamps showing when last modified.
Fixes: #3790.
2018-02-19 09:55:50 -08:00
Tim Abbott
be9dbccdfa settings: Link to documentation on changing settings.
This is obviously more important than the pre-existing link to the
developer documentation for this system.

Fixes #7910.
2018-02-19 09:55:50 -08:00
Tim Abbott
c732313c36 docs: Rename customize.html to settings.html.
This is a better description of what this is for.
2018-02-19 09:55:49 -08:00
nyan-salmon
03624b78c2 webhooks: Add Facebook integration. 2018-02-19 09:41:49 -08:00
Aayush Agrawal
65eeda7c9a vagrant: Replace guest motd with a custom Zulip motd.
Edits Vagrantfile to set custom motd message at /etc/motd and remove
all files under /etc/update-motd.d.

Fixes #7271.
2018-02-19 09:35:04 -08:00
neiljp (Neil Pilgrim)
354d552a10 mypy: Add two mypy-pacifying asserts in upload & bugdown tests. 2018-02-19 09:24:50 -08:00
neiljp (Neil Pilgrim)
15b16c23a1 mypy: Add assertions to test_bots.py to satisfy mypy. 2018-02-19 09:24:50 -08:00
neiljp (Neil Pilgrim)
3a301acf4b mypy: Annotate upload_quota_gb as Optional.
This is both correct and removes a mypy error in test_upload.py.
2018-02-19 09:24:50 -08:00
neiljp (Neil Pilgrim)
3e98e77638 mypy: Amend typing of storage parameter to update_storage to be non-Optional. 2018-02-19 09:24:50 -08:00
neiljp (Neil Pilgrim)
2176f4789b mypy: Rewrite conditional to clarify message-sending defer_until code.
This actually fixes a small bug.
2018-02-19 09:24:28 -08:00
neiljp (Neil Pilgrim)
4efb83ee29 mypy: Amend logic in check_upload_within_quota to avoid None. 2018-02-19 09:20:30 -08:00
neiljp (Neil Pilgrim)
435bfb3159 mypy: Amend annotation of get_emoji. 2018-02-19 09:20:30 -08:00
Steve Howell
c7724c6ec4 minor: Fix typos in hashchange comments.
We make the URL slightly more realistic and fix a spelling typo.
2018-02-19 09:03:11 -08:00
Steve Howell
ffb7a371ed minor: Make relative link tests slightly more realistic.
The two tests changed here are exercising some URL rewrite
logic, and now the URL for stream narrows is slightly more
realistic.
2018-02-19 09:03:11 -08:00
Steve Howell
a474af8d58 Use newer stream urls in missed message emails.
This changes the missed-message logic to use the new encoding
scheme for stream url fragments that prefixes them with
"{stream_id}-".

For simplicity sake, we just get a Stream object to pass to
the helper functions, and we only call get_display_recipient()
now for the HUDDLE case.  (We were calling it wastefully before
for the PM case.)
2018-02-19 09:03:11 -08:00
Steve Howell
46a49777c4 Add stream ids to urls for stream-related narrows.
This commit prefixes stream names in urls with stream ids,
so that the urls don't break when we rename streams.

strean name: foo bar.com%
before: #narrow/stream/foo.20bar.2Ecom.25
after: #narrow/stream/20-foo-bar.2Ecom.25

For new realms, everything is simple under the new scheme, since
we just parse out the stream id every time to figure out where
to narrow.

For old realms, any old URLs will still work under the new scheme,
assuming the stream hasn't been renamed (and of course old urls
wouldn't have survived stream renaming in the first place).  The one
exception is the hopefully rare case of a stream name starting with
something like "99-" and colliding with another stream whose id is 99.

The way that we enocde the stream name portion of the URL is kind
of unimportant now, since we really only look at the stream id, but
we still want a safe encoding of the name that is mostly human
readable, so we now convert spaces to dashes in the stream name.  Also,
we try to ensure more code on both sides (frontend and backend) calls
common functions to do the encoding.

Fixes #4713
2018-02-19 09:03:11 -08:00
Rhea Parekh
b702bbe5a1 slack importer: Allocate ids in a single db query.
We use the command
'select nextval('sequence') from generate_series(1, increment_number)'
which returns a list of allocated values for the ids.

This list is used to assign ids to the to be converted objects.
2018-02-19 08:55:50 -08:00
Rhea Parekh
5dfacfcfca slack importer: Change 'allocate_ids' to return a list of ids.
Update the callers of this function to process the list and add
tests for the same.
2018-02-18 20:47:45 -08:00
Shubham Dhama
25e78abf53 group popovers: Fix entire vertical scrollbar motion on overflow.
This fixes the motion of entire vertical scrollbar (along with
the sliding of bar) when we have many users in group.
2018-02-18 20:20:51 -08:00
Shubham Dhama
1192111ce2 group popovers: Refactor setting up scrollbar.
Using a wheelspeed of 0.68 is fine as used throughtout Zulip.
2018-02-18 20:20:51 -08:00
Shubham Dhama
9feae472f8 org settings: Add button to deactivate organization.
This adds button under "Organization profile" settings, which
deactivates the organization and sends an "event" to all the
active user and log out them.

Fixes: #8212.
2018-02-18 10:20:38 -08:00
Shivam Gera
2733c0551e docs: Add VT-X unavailability error 2018-02-18 08:09:55 -05:00
ryan
dea7d1d1b6 profile menu: Show profile-edit option when a user clicks on self-profile.
This removes some options when a user clicks on their own profile, and
replaces them with an option to edit their own profile settings.

Front end test adjusted because it was testing an option that does not
appear if a user clicks on their own profile.

Fixes #5075.
2018-02-16 16:59:45 -08:00
Greg Price
693a9a5e70 push notifs: For group PMs, identify the users in the group. 2018-02-16 16:06:03 -08:00
ihsavru
4103996a22 org-settings: Fix styling of Allowed Domains modal.
Fixes: #7628.

Cleaned up by Brock Whittaker and Node tests fixed by Steve Howell.
2018-02-16 16:00:21 -08:00
Eric Eslinger
e8fffe295e portico: Make /features responsive.
This really only touches a couple of key points, but it does most of
what's needed to collapse stuff down into columns or a single column
when stuff is narrow.

Fixes #7925.
2018-02-16 15:39:45 -08:00
Eric Eslinger
786bda674c popovers: Add a popover for group mentions.
This adds a click handler to `.user-group-mention` which works in a
fashion that is quite similar to `.user-mention`. It generates and
displays a popover.

The popover has a list of members, their online status (if they are
not bots) or their bot status if they are bots (it's not clear whether
ultimately bots should be able to be members of usergroups, but I'm
able to add one, so I thought it would be worth supporting).

The popover's `UL` element has max-height and overflow-y atttributes
so large groups will grow a scrollbar.

Fixes #8300.
2018-02-16 13:37:02 -08:00
Eric Eslinger
bc21344dc6 popovers: Fix memory leak with old popovers.
This change resets the list_of_popovers array to a new empty array after
hide_all has been called. Prior behavior kept it around, and it kept
pointers to orphaned DOM nodes.

Fixes #8416.
2018-02-16 13:33:06 -08:00
Shubham Padia
9802264302 message-editing: Mark message as read before deleting it.
Fixes most of #8411.

Unread counts in the left sidebar were previously not updated
immediately on message delete.
2018-02-16 12:53:20 -08:00
Brock Whittaker
1dbab6496c landing-page: Change "Help Center" => "Why Zulip".
We have a good "Help Center" section in the footer, where a user
may already expect to look for help/support related requests, so
we can replace the navbar spot there with the "Why Zulip" page link.
2018-02-16 12:43:55 -08:00
Brock Whittaker
d30a6c64c3 Revert "Make recipient bar styling more compact and clean."
This reverts commit 8e2d9b8f68.

This adds the arrows back to the recipient bars because even though
it's not our end state, it looks better than the boxy design that we
had in between.
2018-02-16 11:55:00 -08:00
Shubham Dhama
a32e1eb913 markdown: Require double-asterisk around all mentions.
This enforces `**` around all the mentions including "at-all" and
"at-everyone" mentions. Hence this makes `@all` and `@everyone`
invalid mentions, resulting into proper syntax for these mentions as
`@**all**` and `@**everyone**` respectively.

Note from tabbott: This removes an old feature/syntax, which made
sense back when @Tim was also a way to mention a user with Tim as
their first name.  Given how nice typeahead is now, the user part of
the feature was removed a while ago; this should have gone at the same
time.

Fixes: #8143.
2018-02-16 11:45:08 -08:00
Tim Abbott
55feafb513 unread_ops: Add a quick comment explaining an interface. 2018-02-16 11:44:41 -08:00
Greg Price
424c887a27 Vagrantfile: Test directly for lxc-ls.
This avoids giving the same "no such command" error on Linux machines
that don't have LXC installed as we now avoid on non-Linux.
2018-02-16 11:29:29 -08:00
Vishnu Ks
718b3fcd6a Vagrantfile: Check for OS before patching the lxc-config.
Followup of e68b45d089
Without this vagrant up will fail on Windows.
https://chat.zulip.org/#narrow/stream/development.20help/topic/
Vagrant.20up.20error
2018-02-16 11:29:29 -08:00
Shubham Padia
b12a5a2da0 stream settings: Use a bulk query when changing all streams.
This avoids hitting Zulip's rate limits when there are more than 100
streams involved.

Manual testing:
- Changed notification settings for all streams from notifications tab of user settings
- Monitored the network tab to make sure 1 query is being sent
- Checked notification settings of individual streams

Fixes #5898.
2018-02-16 11:28:55 -08:00
Shubham Dhama
152da74e73 typeahead: Fix typeahead ordering for user group mentions.
Previously, a user with "ham" anywhere in their email address would be
sorted before a group whose name starts with "ham", which resulted in
a lot of frustrating when trying to mention groups.

Fixes: #8301.
2018-02-16 10:10:39 -08:00
Eeshan Garg
6206647641 bugdown/api_code_examples: Add support for multiple languages.
This commit modifies the Markdown extension in bugdown/api_code_examples.py
to support rendering code examples in multiple languages by specifying
the language like so:

{generate_code_example(python)|doc.md|example}

This makes us one step closer towards adding support for testable
JavaScript code examples.
2018-02-16 10:07:13 -08:00
Eeshan Garg
73a1f8aa3e api docs: Add comment about why the event queue example isn't tested.
This commit simply adds a comment in zerver/lib/api_test_helpers.py
explaining why it isn't worth the effort to explicitly test the
code example in api/get-events-from-queue.md.
2018-02-16 10:07:13 -08:00
Shubham Padia
a4b686297a api: Return anchor in get_messages when use_first_unread_anchor=True.
This may be helpful for some API clients, since it avoids them needed
to do somewhat messy post-processing on the results (the data was
always available via scanning for the first unread message in the result).

Fixes #6244.
2018-02-16 10:06:20 -08:00
Greg Price
bb5c44aa50 github: Suggest GIFs too in PR template. 2018-02-16 09:59:22 -08:00
Rohitt Vashishtha
f215fbe89c dark-mode: Show dark background in popover while avatar loads. 2018-02-16 07:47:56 -08:00
Vishnu Ks
a46e21ee3e bankruptcy: Add UI widget to mark all messages as read.
This is the natural analog of the similar streams UI feature.

Fixes #7585.
2018-02-15 18:01:03 -08:00
Brock Whittaker
395d476435 portico: Temporarily fix CSS compilation bug with calc property.
This temporarily fixes a CSS compilation bug with `calc`, that is
outlined in Issue #8403 in the Zulip project.
2018-02-15 17:55:33 -08:00
Tim Abbott
b3d37b5412 sendfile: Clean up sendfile settings code. 2018-02-16 05:10:19 +05:30
Aditya Bansal
efe8545303 local-uploads: Start running authentication checks on file requests.
From here on we start to authenticate uploaded file request before
serving this files in production. This involves allowing NGINX to
pass on these file requests to Django for authentication and then
serve these files by making use on internal redirect requests having
x-accel-redirect field. The redirection on requests and loading
of x-accel-redirect param is handled by django-sendfile.

NOTE: This commit starts to authenticate these requests for Zulip
servers running platforms either Ubuntu Xenial (16.04) or above.

Fixes: #320 and #291 partially.
2018-02-16 05:06:37 +05:30
Aditya Bansal
6fce1d7834 template_parser: Add parsing support for self closing tags as per HTML5.
In this commit we add support for some tags which are also called
void-elements according to
http://w3c.github.io/html/syntax.html#void-elements to be parsed by
our template parser and get tagged as singleton_html_tags.

Fixes: #8387.
2018-02-15 17:47:43 -05:00
Greg Price
271cfd4d7a translation: Try the new err_ marking on a handful of messages. 2018-02-15 13:38:09 -08:00
Greg Price
76cc6d8352 translation: Add configuration for a zulip-test Transifex project.
Because the Transifex API is hilariously bad at namespacing, this will
work for uploading to any project with its "slug" set to `zulip-test`
that you have access to; for me, this is a fresh test project I
created in my own personal Transifex organization.

To use, just follow the command in `tools/push-translations`, but
s/zulip/zulip-test/g.
2018-02-15 13:38:09 -08:00
Greg Price
b0b0777cd0 translation: Make new tagmessages script a bit easier to run.
Now executable! Just run `tools/tagmessages`.

Also, get the username and password from a `.transifexrc` file.

And hardcode the project slug to `zulip-test` rather than to `zulip`;
the Transifex API is bad at namespacing, so this makes it possible to
run this script on a test project (the only way we're currently using
it) even for people like me who can also upload to the real Zulip
project on Transifex.
2018-02-15 13:38:09 -08:00
Greg Price
c4285ef4a7 gitignore: Ignore a Transifex secrets file.
This makes it easier to keep one's .transifexrc in the Zulip working
tree, instead of (or shadowing one in) one's homedir.
2018-02-15 13:38:09 -08:00
Robert Hönig
ebf79427ca translation: Add script to tag strings in Transifex.
For now, tags are only used for backend translations with django.
2018-02-15 13:38:09 -08:00
Robert Hönig
b9c6cd19f7 translation: Mark error strings in django.po files.
In `django.po`, strings are marked with comments specifying the
type of string.
2018-02-15 11:12:42 -08:00
Greg Price
8d98ce1648 errors: Note upstream fix for that Django DisallowedHost bug. 2018-02-15 10:37:29 -08:00
Umair Khan
e68b45d089 lxc: Fix lxc-config file from vagrant-lxc for LXC 2.1.0.
Fixed by greg to act only on version 2.1.0, not later; and
rewrote comment.

Fixes #7838.
2018-02-14 14:06:37 -08:00
Greg Price
6424b3c7b9 github: Add a short template for pull requests.
Hopefully this will help communicate our expectations right up front
for new contributors, with a minimum of boilerplate or busywork.
2018-02-14 13:38:38 -08:00
Vishnu Ks
2102d962a5 version: Bump version to facilitate dependency upgrade. 2018-02-14 09:44:26 -08:00
Vishnu Ks
a1db814e4e requirements: Upgrade python-digital-ocean to 1.13.2. 2018-02-14 09:44:26 -08:00
Vishnu Ks
caaa7d1b82 requirements: Upgrade ndg-httpsclient to 0.4.4. 2018-02-14 09:44:26 -08:00
Vishnu Ks
18436c100a requirements: Upgrade google-api-python-client to 1.6.5. 2018-02-14 09:44:25 -08:00
Vishnu Ks
f93f1972e9 requirements: Upgrade certifi to 2018.1.18. 2018-02-14 09:41:49 -08:00
Vishnu Ks
026d835d3a requirements: Upgrade twilio to two. 2018-02-14 09:41:49 -08:00
Vishnu Ks
88e73c9677 requirements: Upgrade transifex-client to 0.12.5. 2018-02-14 09:41:49 -08:00
Vishnu Ks
adac6c0cf2 requirements: Upgrade tornado to 4.5.3. 2018-02-14 09:41:49 -08:00
Vishnu Ks
9effe27eab requirements: Upgrade typing to 3.6.4. 2018-02-14 09:41:49 -08:00
Vishnu Ks
3f3f876187 requirements: Upgrade stripe to 1.77.2. 2018-02-14 09:41:49 -08:00
Vishnu Ks
416338c9b6 requirements: Upgrade Sphinx to 1.7.0. 2018-02-14 09:41:49 -08:00
Vishnu Ks
351f780ab2 requirements: Upgrade Scrapy to 1.5.0. 2018-02-14 09:41:49 -08:00
Vishnu Ks
48f93a7460 requirements: Upgrade pytz to 2018.3. 2018-02-14 09:41:49 -08:00
Vishnu Ks
0aa6f00cf2 requirements: Upgrade pyasn1 to pyasn1-modules. 2018-02-14 09:41:49 -08:00
Vishnu Ks
f1098a77f2 requirements: Upgrade polib to 1.1.0. 2018-02-14 09:41:49 -08:00
Vishnu Ks
ab7695879a requirements: Upgrade pip-tools to 1.11.0. 2018-02-14 09:41:49 -08:00
Vishnu Ks
2b081f882a requirements: Upgrade Pillow to 5.0.0. 2018-02-14 09:41:49 -08:00
Vishnu Ks
0e2058ae48 requirements: Upgrade pika to 0.11.2. 2018-02-14 09:41:49 -08:00
Vishnu Ks
31abe1a6f8 requirements: Upgrade moto to 1.2.0. 2018-02-14 09:41:49 -08:00
Vishnu Ks
3780b8ce04 requirements: Upgrade Markdown to 2.6.11. 2018-02-14 09:41:49 -08:00
Vishnu Ks
6ca3f72e6e requirements: Upgrade lxml to 4.1.1. 2018-02-14 09:41:49 -08:00
Vishnu Ks
617549fec5 requirements: Upgrade Jinja2 to 2.10. 2018-02-14 09:41:49 -08:00
Vishnu Ks
151702d7c1 requirements: Upgrade isort to 4.3.4. 2018-02-14 09:41:49 -08:00
Vishnu Ks
51577b788a requirements: Upgrade html2text to 2018.1.9. 2018-02-14 09:41:49 -08:00
Vishnu Ks
66e34be480 requirements: Upgrade gitlint to 0.9.0. 2018-02-14 09:41:49 -08:00
Vishnu Ks
449c1d5064 requirements: Upgrade django-two-factor-auth to 1.7.0. 2018-02-14 09:41:49 -08:00
Vishnu Ks
2b0099f696 requirements: Upgrade django-pipeline to 1.6.14. 2018-02-14 09:41:49 -08:00
Vishnu Ks
7a8b174a01 requirements: Upgrade cryptography to 2.1.4. 2018-02-14 09:41:49 -08:00
Vishnu Ks
1b8ca55dd2 requirements: Upgrade cffi to 1.11.4. 2018-02-14 09:41:49 -08:00
Vishnu Ks
d8eb4a115c requirements: Upgrade Babel to 2.5.3. 2018-02-14 09:41:49 -08:00
Vishnu Ks
9b93e8cba8 requirements: Upgrade argon2-cffi to 18.1.0. 2018-02-14 09:41:49 -08:00
Shubham Dhama
995138d730 settings: Allow uploading same image as avatar after deleting.
Previous hack wasn't working but changing the value of
file input element to empty works.
For more info https://stackoverflow.com/questions/20549241.

Fixes: #8377.
2018-02-14 09:37:16 -08:00
Tim Abbott
118dfb9690 hotkey: Document message_view_only with a comment.
fixes #8323.
2018-02-14 09:34:32 -08:00
Tim Abbott
dcda633b3a help: Fix scroll position when reloading browser window with hash.
This uses the same technique as the last commit, just with the final
case for how we navigate to/from these pages.
2018-02-14 09:26:42 -08:00
Aman Jain
d48664fc5f help: Fix links with query selector from left sidebar.
This resolves the issue of scrolling to correct position when loaded
from left sidebar to a link with query selector.

Fixes #6714.
2018-02-14 09:25:26 -08:00
Patrick Naughton
ced9cba5ff hotspots: Fix resizing of `Got It!` box.
This dynamically resizes the box to fit the variable text size present
with different languages.

At the same time, it adds padding to the English version to make it
look similar to previous versions.

Fixes #8275.
2018-02-14 09:23:16 -08:00
Rishi Gupta
08efd7828a integrations: Update text for bitbucket2 doc.
With minor fixes by eeshangarg.

Eeshan: I added a screenshot because I thought it would be helpful.
2018-02-13 22:28:48 -03:30
Rishi Gupta
7697adfcdc integrations: Update text for appfollow doc.
With minor fixes by eeshangarg.
2018-02-13 22:19:05 -03:30
Rishi Gupta
80a0976afe integrations: Update text for basecamp doc.
With minor fixes by eeshangarg.

Eeshan: I updated the screenshot. The old one was blurry, the
whole process is largely the same.
2018-02-13 22:15:10 -03:30
Rishi Gupta
de3d478a80 integrations: Update text for airbrake doc.
With minor fixes by eeshangarg!

Eeshan: I decided to remove the screenshot. It looks very old and
was blurry and the instructions were very screenshot-agnostic
anyway!

I couldn't update the screenshot because Airbrake doesn't even let
you use the free trial till you give them your credit card info,
which I didn't want to do!
2018-02-13 21:56:31 -03:30
Rishi Gupta
9449556eff integrations: Add missing instruction to create-a-bot docs macros. 2018-02-13 21:47:39 -03:30
Tim Abbott
be3d43bb46 lint: Add linter rule banning $.get and friends.
These are not allowed in our style guide.
2018-02-13 16:47:59 -08:00
Robert Hönig
a19a69bfe3 embedded bots: Log warning when bot quit()s.
External bots may call bot_handler.quit() when
they wish to terminate, e.g. due to a misconfiguration.
Currently, embedded bots ignore calls to quit(), even
though they signal a problem. This commit does the first
step in handling quit() calls by logging a warning.
2018-02-13 14:56:37 -08:00
Tim Abbott
6638c12aef upload: Extract feature_check helper function. 2018-02-13 14:37:26 -08:00
Tim Abbott
8836161611 upload: Refactor file upload code path to use more variables.
Now, all the various DOM elements are named by a variable, keyed off
the configuration of the upload_options object.

This is most of the work required to support file upload in the
message edit area.
2018-02-13 14:37:26 -08:00
Tim Abbott
9de7a69b13 upload: Move compose initialization back to compose module.
This makes the lines of logic a bit simpler.
2018-02-13 14:37:26 -08:00
Tim Abbott
7af769a272 upload: Extract upload.options structure.
This is a nonfunctional refactor that is key preparation for allowing
uploading files in message editing.

Note that this makes no actual changes to the code; it just changes
the function structure.
2018-02-13 14:37:22 -08:00
Greg Price
7bfd22a0b0 mypy: Give types to some kwargs in makemessages.
Based on types identified by Neil Pilgrim.
2018-02-13 11:40:52 -08:00
neiljp (Neil Pilgrim)
756af7518c REQ: Add type parameter to act as hint for typing. 2018-02-13 11:40:52 -08:00
neiljp (Neil Pilgrim)
f184249191 mypy: Clarify valid types in tornado views via new variable. 2018-02-13 11:40:52 -08:00
neiljp (Neil Pilgrim)
ec829ea832 mypy: Add 2 Optional[StreamTopicTarget] annotations in actions.py. 2018-02-13 11:40:52 -08:00
neiljp (Neil Pilgrim)
79582a59f1 mypy: Move assertion into similar branch in get_recipient_info. 2018-02-13 11:40:52 -08:00
neiljp (Neil Pilgrim)
2ed1ab4b7a mypy: Amend topic REQ parameters in helloworld/mention webhooks. 2018-02-13 11:40:52 -08:00
neiljp (Neil Pilgrim)
b8f81801c1 mypy: Annotate existing_user_profile in accounts_register(). 2018-02-13 11:40:52 -08:00
neiljp (Neil Pilgrim)
3cb12230b2 mypy: Annotate email_gateway_bot in export_files_from_s3(). 2018-02-13 11:40:52 -08:00
neiljp (Neil Pilgrim)
bed56b253e mypy: Add clarifying variable in add_new_user.py. 2018-02-13 11:40:52 -08:00
neiljp (Neil Pilgrim)
16b939a964 REQ: Ensure only initial parameter is positional & adjust views/messages.py. 2018-02-13 11:40:52 -08:00
neiljp (Neil Pilgrim)
b0126ca8dc mypy: Amend diff_strings to return str or raise DiffException. 2018-02-13 11:40:51 -08:00
neiljp (Neil Pilgrim)
23cc7e1671 mypy: Allow acting_user of do_change_full_name() to be None.
This is based on usage in bulk_change_user_names.py, and that
the RealmAuditLog acting_user field is Optional[UserProfile].

This could be more meaningfully changed in future, perhaps to
indicate that the command was run by a specific zulip user.
2018-02-13 11:40:51 -08:00
neiljp (Neil Pilgrim)
a88c083aa7 mypy: Annotate user variable in ZulipPasswordResetForm.save.
[greg: moved annotation to avoid a mypy error, from second assignment.]
2018-02-13 11:40:07 -08:00
Greg Price
c6ce6dd5c6 settings: Try to clarify how AUTH_LDAP_USER_ATTR_MAP works.
This comment didn't really explain things unless you were looking at
the code, and/or had a strong enough association for what "cn" means
that it was obvious what must be meant.  Maybe this will be clearer.

There is one other meaningful key, which is optional: "short_name",
for which I guess a typical value if supplied would be "uid" or
"userid".  I'm not sure we really do much with a user's `short_name`,
though, so didn't add a comment for it.  When this key is omitted,
we set the user's `short_name` to the same thing as `full_name`.
2018-02-13 11:18:14 -08:00
Vishnu Ks
81f18bd69a actions: Create do_create_multiuse_invite_link function. 2018-02-13 09:31:45 -08:00
Shubham Dhama
03e4026c62 bots: Check bot owner for deactivated users and bots.
We should not allow deactivated users and bots as a
bot owner.
2018-02-13 09:24:42 -08:00
Shubham Dhama
adfc905c3f bots: Handle exception on changing bot owner to invalid user.
It catches the `UserProfile.DoesNotExist` exception and
hence prevent internal server error.
Also remove option to select empty bot owner.
Fixes: #8334.
2018-02-13 09:23:13 -08:00
Shubham Padia
e1f943913a lint: Allow revert commit messages in gitlint.
Fixes #8145.
2018-02-13 09:21:01 -08:00
Tim Abbott
ddf83f65ce docs: Update dead references to puppet/zulip_internal.
This was renamed in the codebase to puppet/zulip_ops months ago.
2018-02-12 16:00:56 -08:00
Aman Agrawal
0db9f55924 Update versions for Vagrant and VirtualBox.
Update version of Vagrant from 1.8.6 to 2.0.2.
Update version of VirtualBox from 5.1.8 to 5.2.6.

We needed to update Vagrant because older versions have networking
problems on modern Macs, resulting in weird `apt` errors when
provisioning.

Commit message and some text tweaked by tabbott.
2018-02-12 15:46:59 -08:00
Florian Jüngermann
ec3e0caece right-sidebar: Enable up and down arrow keys.
This users the new generic functions in stream_list.js to implement a
similar behaviour for the right sidebar (user list).

Fixes #5920.
2018-02-12 15:38:23 -08:00
Florian Jüngermann
b489ccc126 left-sidebar: Enable up and down arrow keys.
When in the stream-searchbar, a user can now use the arrow keys to iterate
through the suggestions. Therefore the currently selected list element is
assigned a CSS class 'highlighted_user'.
The main functional testing is done with casper but node test are still
included to keep the high coverage.
Line-wrapping issues are resolved. Night-mode CSS handling is included.
2018-02-12 15:35:56 -08:00
Aditya Bansal
35969edd66 deps: Replace libz-dev with zlib1g-dev since the former was renamed. 2018-02-12 14:40:26 -08:00
Aditya Bansal
d5736ef65a provision.py: Remove duplicate install candidated from APT_DEPENDENCIES.
This is necessary, since we now have some dependencies in common
between the Thumbor and main Zulip dependency lists.
2018-02-12 14:40:26 -08:00
Aditya Bansal
a137ed9e27 thumbor: Fix issue with dependencies.
We do the following here:
* Remove libjasper-dev from THUMBOR_VENV_DEPENDENCIES.
Reason: This dependancy wasn't really needed by us for using
thumbor. It was a dependancy for using open-cv as Imaging Engine
in thumbor but we use PIL (Pillow now) as Imaging Engine.
* Add zlib1g-dev, libfreetype6-dev to THUMBOR_VENV_DEPENDENCIES.
Reason: These are dependancies of Pillow which are required for it
Pillow to function. Since we use Pillow in thumbor as Imaging Engine
we need these. Stuff before this didn't break because we also use
Pillow in development Environment and have these dependancies
installed from VENV_DEPENDENCIES as well.
2018-02-12 14:40:26 -08:00
Greg Price
ecbc72b857 push notifs: Add a diagnostic in API of whether push notifs enabled.
When the answer is False, this will allow the mobile app to show a
warning that push notifications will not work and the server admin
should set them up.

Based partly on Kunal's PR #7810.  Provides the necessary backend API
for zulip/zulip-mobile#1507.
2018-02-12 14:34:59 -08:00
Greg Price
cc1d64edf8 tests: Dedupe a bit the test for server_settings.
We keep having to change the same thing in three places here; and also
the duplicates have accumulated unnecessary variation that makes it
hard to see what's actually supposed to be different and not different
in the three cases.
2018-02-12 14:34:28 -08:00
Greg Price
3fba90f6c3 billing: Make several small style fixes to new tests.
* Put imports in order.
* `import stripe`; that's the style upstream docs recommend, and it avoids
  confusion e.g. between our StripeError and the library's StripeError.
* Simplify loading JSON.
* Keep lines largely to 100 columns.
2018-02-12 12:46:01 -08:00
Vishnu Ks
bed4ca642a stripe: Add backend tests for stripe. 2018-02-12 12:45:46 -08:00
Vishnu Ks
003cb0478a stripe: Use sources.list instead of sources.all.
Sources.all would be depricated soon in favor of sources.list.
See https://github.com/stripe/stripe-python/blob/
v1.77.1/stripe/api_resources/list_object.py#L18
2018-02-12 12:45:46 -08:00
Tim Abbott
b9ca7bd954 beeminder: Clean up messy imports in tests. 2018-02-12 12:06:12 -08:00
Ricky
3f832b95de webhooks/beeminder: Fix documentation to append email to URL.
The Beeminder integration requires an `email` parameter that
our bot creation documentation macros don't yet support.
2018-02-12 12:03:25 -08:00
Ricky
76c56ad81d webhooks/beeminder: Make deadline time (time_remain) positive. 2018-02-12 12:03:25 -08:00
Tim Abbott
6bbce451bc analytics: Fix a minor mypy error. 2018-02-12 11:57:47 -08:00
Steve Howell
35cc206dcc Add narrow.narrow_to_next_pm_string().
This helper function will allow us to cycle through PM narrows
that are unread, once we map it to a hotkey and/or other UI.

(We intend to make something like the "n" key for topics, but
that works on PM narrows instead.)
2018-02-12 09:34:59 -08:00
Steve Howell
13abed229c Add narrow_state.pm_string(). 2018-02-12 09:34:59 -08:00
Steve Howell
6ea2765c9f Add topic_generator.get_next_unread_pm_string().
We will use this for keyboard navigation to cycle through
our unread PM narrows.
2018-02-12 09:34:59 -08:00
Steve Howell
9f8526ce29 Add pm_conversations.recent.get_strings().
We will use this method for hotkey navigation through recent
pms.
2018-02-12 09:34:59 -08:00
Steve Howell
4f52e095e8 refactor: Extract pm_conversations.recent.
This is a pretty pure code move, where we moved stuff from
message_store to pm_conversations:

    insert_recent_private_message() -> recent.insert()
    recent_private_messages -> recent.get()

The object message_store.recent_private_messages was not
encapsulated in a function before this change.  Now it is
hidden in the scope of pm_conversations.recent.

Both of the modules touched here maintain 100% line coverage.
2018-02-12 09:34:59 -08:00
Aman Jain
a0b58b1560 activity: Add a link to copy list of realm admins.
Tweaked by tabbott to do the database queries properly.

This should help user to copy realm admin emails in a go.
Fixes: #7885
2018-02-12 08:55:45 -08:00
Rhea Parekh
3ebd30120c slack importer: Remove depreciated test.
This test was added in '/tests/test_slack_importer' in
6addf79edb.
2018-02-12 00:43:02 +05:30
Greg Price
7925e258a2 mypy: Tweak a bit of syntax to avoid a mypy bug.
The error message, in relevant part:
```
zerver/templatetags/app_filters.py: error: INTERNAL ERROR --
  please report a bug at https://github.com/python/mypy/issues version: 0.560
  File ".../site-packages/mypy/nodes.py", line 497, in accept
    return visitor.visit_func_def(self)
  File ".../site-packages/mypy/report.py", line 317, in visit_func_def
    assert start_indent is not None and start_indent > old_indent
AssertionError:
zerver/templatetags/app_filters.py: : note: use --pdb to drop into pdb
```

Seems mypy gets confused by the comment following the decorator.
2018-02-09 19:43:27 -08:00
Greg Price
b374ea7357 mypy: Pass --show-traceback.
This saves a bit of debugging in the event that we hit a crash
inside mypy.
2018-02-09 19:42:49 -08:00
Greg Price
8be2dfa81c APNs: Fix a case I broke while working out tests.
I got distracted, came back later to a successful test run in my
terminal, and thought I remembered finishing the change and just
kicking off a final test run to check.

In fact, there was an `assert False` right in the normal case for
production, and I just hadn't finished a test for that path. (m.-)
Definitely the most grateful I've been for our coverage checks,
which highlighted this for me.

Remove the `assert False`, and also finish writing the test it was
there to help me write.  Those lines are covered now.
2018-02-09 18:28:16 -08:00
Umair Khan
59f61c2525 render_markdown_path: Use limited caching.
This results in an almost 50% increase in performance in the slow
test_urls test.

Fixes #6901.
2018-02-09 18:14:17 -08:00
Umair Khan
0eca2e102d cache: Add ignore_unhashable_lru_cache function.
This is a wrapper over lru_cache function. It adds following features on
top of lru_cache:

    * It will not cache result of functions with unhashable arguments.
    * It will clear cache whenever zerver.lib.cache.KEY_PREFIX changes.
2018-02-09 18:14:08 -08:00
Umair Khan
91ce455ac3 app_filters: Remove unused lru_cache import. 2018-02-09 18:12:55 -08:00
Priscilla
6badac5d33 docs: Add v shortcut to the lightbox article. 2018-02-09 18:02:24 -08:00
Greg Price
20c734c90a puppet: Fix type error in new Nagios check for analytics state. 2018-02-09 17:46:46 -08:00
Brock Whittaker
6028e79440 subs: Remove call to go to "all-streams" on stream creation.
This will essentially run the code paths to go from whatever you were
at before to /all and back in the case of /new, which will call the
render function three times (!!), so remove this call because it isn’t
really necessary anyways.
2018-02-09 17:29:59 -08:00
Brock Whittaker
ad4e976406 streams: Have new streams list only populate once.
Currently the new streams user list will populate twice when you click
the new stream button (or “+”), because it is triggered once directly
by the button click and then once by the hash change to /new, so we
want to ignore the changes by the hash change.
2018-02-09 17:29:59 -08:00
Greg Price
7f6a1714aa APNs: Don't try to send anything when not configured. 2018-02-09 17:16:21 -08:00
Greg Price
12d878c785 APNs: Drop disused setting from old implementation. 2018-02-09 17:16:21 -08:00
Tim Abbott
005b0fb566 puppet: Clean up ssh authorized_keys configuration rules. 2018-02-09 16:37:03 -08:00
Tim Abbott
aca25b6f0a puppet: Move ssh configuration to use notify.
This handles more correctly the case where we're using the upstream
sshd_config file.
2018-02-09 16:37:03 -08:00
Tim Abbott
486de8abfc puppet: Edit some rules to support chat.zulip.org.
This should make it possible to use the zulip_ops base rules
successfully on chat.zulip.org.  Many of the changes in this commit
are hacks and probably can be cleaned up later, but given that we plan
to drop trusty support soon, it's likely that most of them will simply
be deleted then.
2018-02-09 16:37:03 -08:00
Rishi Gupta
1d581a9c6e nagios: Add nagios check for analytics state.
This should help us detect issues where the analytics cron jobs aren't
running properly.

The cron/nagios part of the implementation done by tabbott.
2018-02-09 16:36:05 -08:00
Priyank Patel
dcec2e3a4d dark-mode: Make all modals compatible with night mode.
This should cover the remaining modals that didn't already support this.
2018-02-09 14:21:13 -08:00
Robert Hönig
3e1b817376 bot settings: Move config item generation from js to handlebars. 2018-02-09 12:30:24 -08:00
Robert Hönig
c0a0e6fd70 Set add_bot_backend() config_data param default to {}.
Previously, the default was None. This caused 500s when
adding a bot without adding a config_data argument.
2018-02-09 12:30:24 -08:00
Robert Hönig
02bc506518 bot_data.js: Fix dict indentation. 2018-02-09 12:30:24 -08:00
Robert Hönig
0abb0315f3 test_events.py: Properly check the bot added event dict.
Previously, the 'services' entry in the bot added event dict,
did not get verified, because the test didn't include a service bot.
2018-02-09 12:30:24 -08:00
Robert Hönig
760cbcc98e test_events.py: Use create_test_bot(). 2018-02-09 12:30:24 -08:00
Robert Hönig
323284e0b6 backend: Call real endpoint in create_test_bot().
This allows tests to be more realistical and to
directly test payload added to add_bot_backend().
2018-02-09 12:30:24 -08:00
Robert Hönig
33322fed51 bot_settings.js: Narrow config item selector.
Needed to avoid selector conflicts with the future
config items in the edit sidebar.
2018-02-09 12:30:24 -08:00
Robert Hönig
561e0ffe3b frontend: Delete page_params.realm_bots after first usage.
The data in page_params.realm_bots is parsed and captured
in bot_data. bot_data provides a safe system for accessing
this data.
2018-02-09 12:30:24 -08:00
Robert Hönig
7539512af8 settings-bots.js: Restructure bot edit event handler.
Shift and unify some variables to make the code more
logical and concise.
2018-02-09 12:30:03 -08:00
Robert Hönig
f371c79c22 settings-bots.js: Fully generate bot owner list in handlebars. 2018-02-09 12:30:03 -08:00
Robert Hönig
f57d592d88 edit-outgoing-webhook-service.handlebars: Fix typo. 2018-02-09 12:30:03 -08:00
Robert Hönig
273f62f8cd settings-bots.js: Remove redundant sidebar close event handler.
All the event handler did was resetting some entries in the edit
bot form. This is unnecessary, because the whole form gets
destroyed anyway when closed.
2018-02-09 12:30:03 -08:00
Robert Hönig
338bba7a0f edit_bot.handlebars: Extract outgoing webhook form.
This removes ugly .show() .hide() constructions that
were previously used to dynamically display the form.
2018-02-09 12:30:03 -08:00
Robert Hönig
1ec9932aec settings_bots.js: Clean up bot edit event handler.
This is done by rewriting JS manipulations of the DOM tree
in the bot-settings.handlebars template. Dead code involving
the affected JS variables is removed.
2018-02-09 12:30:03 -08:00
Robert Hönig
032cc8497f settings sidebar: Extract bot edit form.
This is the first step in cleaning up the bot edit code.
Since the bot edit form appears dynamically, we remove
it from the static HTML scaffold, of which settings_sidebar
is a part of.
2018-02-09 12:30:03 -08:00
Rhea Parekh
721a241901 slack importer: Update doc about slack user's skype and phone data. 2018-02-09 12:17:10 -08:00
Rhea Parekh
fbc11b141b slack importer: Add 'realm_name_in_notifications' field in zerver_userprofile.
This was recently added in b875fe07eb and
hence should be updated here.
2018-02-09 12:17:10 -08:00
Rhea Parekh
6addf79edb slack importer: Test import in existing database with fixtures.
Check in sample slack dataset fixtures, test data conversion and import of
this converted data into an existing database.
2018-02-09 12:17:10 -08:00
Rhea Parekh
be05bccb5b slack importer: optimize allocation of id range before import. 2018-02-09 12:17:10 -08:00
Rhea Parekh
a0b7976f77 slack importer: Fix output_dir path and remove sys.exit(0).
Also, as the exception is being handled in 'slack_data_to_zulip_data'
remove it from the manage.py command 'convert_slack_data'.
2018-02-09 12:17:10 -08:00
Rhea Parekh
699021e7d8 slack importer: Update Documentation with slack's legacy token method. 2018-02-09 12:17:10 -08:00
Rhea Parekh
c0e30079f6 slack importer: Get user data from a get request to slack users api.
The fresh imported data shows that the users emails are not included
in the data. However, the data received from the older method of slack
(which is using legacy tokens) contains the email data of the users.
2018-02-09 12:17:10 -08:00
Sumana Harihareswara
6e30da9f92 doc: Add blog link to CONTRIBUTING. 2018-02-09 12:04:28 -08:00
YJDave
1f8b6938a7 stream settings: Fix error in updates of stream description.
When removing the description from a stream (i.e. setting it to ""),
the UI was not correctly updating the description.  This is because we
were checking incorrectly for a falsey value, rather than the specific
value undefined (which means the description wasn't changed).
2018-02-09 12:02:22 -08:00
YJDave
08533ba787 stream settings: Show message in case of no stream description.
Show "No description." message if stream doesn't have any
description in stream settings.
2018-02-09 12:00:45 -08:00
Tim Abbott
afda05adc4 rate limiting: Increase default rate limits.
It's too easy to go over the rate limits when using the webapp.

The correct fix for this probably involves some changes to which
routes get covered by what sort of rate limit, but for now, just
increase the limits.
2018-02-09 11:55:08 -08:00
Sumana Harihareswara
ea0fe90367 webhooks/beeminder/doc.md: Use better macros. 2018-02-09 11:53:32 -08:00
Tim Abbott
77addc5456 bugdown: Fix handling of ultra-long renderings.
If some bug in Bugdown results in a rendered message content that is
bigger than twice the message size, we now just throw an exception
from Bugdown.  This is considerably better than the old behavior,
which might result in an enormous message being placed in the database
(potentially, bigger than the 1MB limit to store in memcached), which
would in turn result in tragic consequences.

This fixes #8322, in that it prevents the super bad outcome seen there
(where basically Zulip became unusable for everyone on the stream
where the message is posted).  Now, the failure mode is just the
message failing to send.  Still not ideal (and requires further work
on the URL embed feature), but not a minor problem, not a major one.
2018-02-09 10:57:55 -08:00
Shubham Dhama
9cd7f59c9b recent senders: Use message ids instead of timestamps for sorting.
This matches the convention that we use everywhere else in Zulip.

Fixes: #5956.
2018-02-08 18:39:10 -08:00
Vishnu Ks
ebe16e064e README: Include CircleCI build status badge.
For now, we still need the Travis badge, since Travis is where we test the 
production installation process.  But ideally, we'll end up removing that too.
2018-02-08 18:24:43 -08:00
Greg Price
7df29e7a7c puppet: Only use those "modern" options when on xenial.
On trusty, we of course have an older version -- 1.4.14 -- and it is
not so modern, so this just gives an error.
2018-02-08 18:11:52 -08:00
Eeshan Garg
3853577486 api tests: Add example/tests for unsubscribing other users.
This commit adds tests (and thus, an extra code example) for
unsubscribing another user from a particular stream by passing in
the `principals` argument to client.remove_subscriptions. The
ability to pass in `principals` was added in the latest release
of the zulip API PyPI package.
2018-02-08 17:58:41 -08:00
Eeshan Garg
ac5c355a60 api/delete-queue: Make fixtures/examples testable.
api/delete-queue now uses the Markdown extension in
bugdown/api_code_examples to generate code examples and fixtures
from tests.
2018-02-08 17:58:41 -08:00
Eeshan Garg
344cf2c8ee api_tests: Add tests for client.register_queue. 2018-02-08 17:58:41 -08:00
Eeshan Garg
66ca0c725f api/get-all-users: Make fixtures/examples testable.
api/get-all-users now uses the Markdown extension in
bugdown/api_code_examples to generate code examples and fixtures
from tests.
2018-02-08 17:58:41 -08:00
Eeshan Garg
929724e5e7 api docs: Add page for common error payloads.
We now have a separate page for common error payloads, for example,
the payload for when the client's API key is invalid. All error
payloads that are presented on this page will be tested similarly
to our other non-error sample fixtures.
2018-02-08 17:58:41 -08:00
Eeshan Garg
037c891fcf webhooks/delighted: Reformat documentation steps into numbered list.
This is a part of our efforts to migrate our webhook docs to have
a more structured numbered-list format similar to our /help docs.
2018-02-08 17:45:56 -08:00
Eeshan Garg
69f248aaf9 webhooks/codeship: Reformat documentation steps into numbered list.
This is a part of our efforts to migrate our webhook docs to have
a more structured numbered-list format similar to our /help docs.
2018-02-08 17:45:56 -08:00
Eeshan Garg
06e86ce50d webhooks/bitbucket2: Reformat documentation steps into numbered list.
This is a part of our efforts to migrate our webhook docs to have
a more structured numbered-list format similar to our /help docs.
2018-02-08 17:45:56 -08:00
Eeshan Garg
5e1a193e76 webhooks/circleci: Reformat documentation steps into numbered list.
This is a part of our efforts to migrate our webhook docs to have
a more structured numbered-list format similar to our /help docs.
2018-02-08 17:45:56 -08:00
Eeshan Garg
af683800fd webhooks/basecamp: Reformat documentation steps into numbered list.
This is a part of our efforts to migrate our webhook docs to have
a more structured numbered-list format similar to our /help
docs.
2018-02-08 17:45:56 -08:00
Eeshan Garg
ad6dae1bf5 webhooks/appfollow: Reformat documentation steps into numbered list.
This is a part of our efforts to migrate our webhook docs to have
a more structured numbered-list format similar to our /help docs.
2018-02-08 17:45:56 -08:00
Eeshan Garg
2733540492 webhooks/airbrake: Reformat documentation steps into numbered list.
This is a part of our efforts to migrate our webhook docs to have
a more structured numbered-list format similar to our /help docs.
2018-02-08 17:45:56 -08:00
Greg Price
86590dfdbe test-install: Add command destroy-all to clean up test containers.
This is just the one-liner I've been keeping in my shell history,
cleaned up a bit (newlines!) and with 28 lines of CLI boilerplate
added in front.
2018-02-08 17:29:41 -08:00
Greg Price
6e633f8e2f install: Use readlink -f rather than realpath.
It does exactly the same thing, though the name is less transparent; and
it simplifies the script by avoiding an extra, early `apt-get install`.
2018-02-08 17:22:02 -08:00
Greg Price
8d86a6e331 install: Slightly clean up another couple of bits of style. 2018-02-08 17:14:28 -08:00
Greg Price
218b653930 install: Clean up organization of option parsing.
The parsing of options from environment variables belongs right next
to the normal kind; and `show_help` was unnecessary indirection.
2018-02-08 17:12:36 -08:00
Greg Price
08135e3666 install: Don't try to chown a self-signed cert to zulip.
The zulip user has no need to see this file; it's used by nginx.
And when we set up the cert early in install, there's no zulip user
yet anyway, so this fails.
2018-02-08 17:08:16 -08:00
Greg Price
f68c485a86 install: Clean up some shell style: use here-docs, and compact getopt. 2018-02-08 17:05:13 -08:00
Greg Price
8f4b7f6e1e install: On --express, check up front for --hostname and --email. 2018-02-08 16:34:49 -08:00
Greg Price
31ec9a4627 install: Implement --self-signed-cert earlier.
Otherwise when puppet tries to install and start nginx, that can
give an error.
2018-02-08 16:34:49 -08:00
Greg Price
4c5326ce85 test-install: Factor out booted-yet-p polling loop, use in prepare-base.
Otherwise prepare-base is likely to fail when first run (but then
succeed when rerun, because the container is left running), because
the container isn't up yet when we try to operate in it.

Also clean up the placement of `set -e` vs `set -x`.
2018-02-08 16:34:49 -08:00
Greg Price
fc9970e561 test-install: Add xenial support. 2018-02-08 16:34:49 -08:00
Greg Price
23e6a2e579 puppet: Update memcached config to turn on this decade's technology.
We've been running this change on zulipchat.com for a couple of months
now.  Before then, we used to regularly get exceptions like this:

     File "./zerver/views/messages.py", line 749, in get_messages_backend
       setter=stringify_message_dict)
     File "./zerver/lib/cache.py", line 275, in generic_bulk_cached_fetch
       cache_set_many(items_for_remote_cache)
     File "./zerver/lib/cache.py", line 215, in cache_set_many
       get_cache_backend(cache_name).set_many(items, timeout=timeout)
     File "/home/zulip/deployments/2017-09-28-21-04-12/zulip-py3-venv/lib/python3.5/site-packages/django/core/cache/backends/memcached.py", line 150, in set_many
       self._cache.set_multi(safe_data, self.get_backend_timeout(timeout))
   pylibmc.Error: error 48 from memcached_set_multi

This error means memcached was unable to find space for the new value.
You might think that because memcached provides an LRU cache, this
shouldn't happen because it would just evict something... but in fact
  * memcached splits its data into "slabs" by object size, and
  * until recently, once a 1MiB "chunk" is allocated to a given "slab"
    i.e. size class, it wouldn't be reclaimed to allocate to another.

So once the cache has been filled up with objects of some distribution
of sizes, if some objects come in that would go in a different size
class, we have no chunks for that size class / slab, and can't get one.
And that's exactly what was happening on zulipchat.com.

Useful background can be found in
  https://github.com/memcached/memcached/wiki/ServerMaint#slab-imbalance
  https://github.com/memcached/memcached/wiki/ReleaseNotes1411
  https://github.com/memcached/memcached/wiki/ReleaseNotes1425
  https://github.com/memcached/memcached/wiki/ReleaseNotes150
We're already running v1.4.25, which provides an "automover" that should
be well equipped to fix this; v1.5.0 turns it on by default.

With this commit, adopt the "modern start line" recommended in the
release notes for our v1.4.25, including turning on the automover.
2018-02-08 16:34:49 -08:00
Eeshan Garg
4414f2b24b webhooks/beeminder: Use create-a-bot.md macro. 2018-02-08 16:22:55 -08:00
Eeshan Garg
ab700fb662 markdown: Add a macro with instructions for creating a bot. 2018-02-08 16:22:55 -08:00
Rhea Parekh
48640fd28f slack importer: Suppress logger output from the unit tests. 2018-02-08 16:21:35 -08:00
Vishnu Ks
680983d10e vagrantfile: Workaround for the atlas.hashicorp.com redirect removal.
This workaround is only for new users. Users who are/were using old
versions of Vagrant has to manually change the value of box
metadata_url. See https://github.com/hashicorp/vagrant/issues/9442
2018-02-08 13:54:19 -08:00
Tim Abbott
9249454518 update-authors-json: Fix handling deleted GitHub accounts.
Apparently, we've now had the first time one of our contributors had
their account deleted (at least, the author page for the contributor
who has 21 commits in python-zulip-api now 404s).
2018-02-08 12:17:20 -08:00
Greg Price
9e70026741 settings: Slightly clarify LDAP setup docs.
There's kind of a lot of prose in this LDAP section; and empirically
this bit about zulip-secrets.conf is easy to miss.
2018-02-08 10:05:25 -08:00
Robert Hönig
537203102a api tests: Update remove-subscriptions fixture.
The remove-subscriptions API client response
changed with python-zulip-api:67cdb6f
2018-02-08 09:37:41 -08:00
Brock Whittaker
e82564c82c dark-mode: Fix bug with open graph previews.
This fixes a bug where the open graph preview bottom fade is dark
rather than white when not in dark mode, which results in a heavy
dark faded line at the bottom of the description.
2018-02-08 09:22:58 -08:00
Eeshan Garg
61e4fc3b74 api/remove-subscriptions: Make fixtures/examples testable.
api/remove-subscriptions now uses the Markdown extension in
bugdown/api_code_examples to generate code example and fixtures
from tests.
2018-02-07 15:58:57 -08:00
Eeshan Garg
f4cb5e70ed api/add-subscriptions: Make fixtures/examples testable.
api/add-subscriptions now uses the Markdown extension in
bugdown/api_code_examples to generate code example and fixtures
from tests.
2018-02-07 15:58:57 -08:00
Eeshan Garg
09721e9ec3 bugdown/api_code_examples: Support multiple fixtures per doc.
This commit adds support for passing in an argument to the macro
"call" to explicitly specify a fixture to render, like so:

{generate_code_example|doc_name|fixture(stream_message_with_args)}
2018-02-07 15:58:57 -08:00
Eeshan Garg
7ae704d1bb api/get-all-streams: Render multiple examples from single test method.
api/get-all-streams - make use of the api_code_example Markdown extension's
feature of recursively extracting multiple code examples from a single
test method.
2018-02-07 15:58:57 -08:00
Eeshan Garg
0cca39d1fc bugdown/api_code_examples: Support multiple examples in one test.
This commit adds support for recursively extracting multiple code
examples from a single test method.
2018-02-07 15:58:57 -08:00
Eeshan Garg
ffe930d50d bugdown/api_generate_examples: Replace 'method' with 'example'.
To generate a code exammple,

{generate_code_example|<api_doc_md>|example} sounds better and
more intuitive than,

{generate_code_example|<api_doc_md>|method}
2018-02-07 15:58:57 -08:00
Greg Price
ccb8c79edb test_docs: Fix a now-brittle test.
The count of integrations is automatically computed now, so this will
change every time we add 10 more.  Just stop asserting on the number.

Thanks to @hackerkid for spotting the issue.
2018-02-07 13:01:42 -08:00
Josh Mandel
15eaafa50f Add underscores to thumbs_up and thumbs_down emoji 2018-02-07 11:55:02 -08:00
Ricky
db152da7c9 webhooks/beeminder/doc.md: Add instructions for creating a bot. 2018-02-07 10:03:31 -08:00
Ricky
77760d9f6c webhooks/beeminder: Update sample message screenshot. 2018-02-07 10:03:31 -08:00
Ricky
1303248b0b integration: Add statuspage.io webhook integration. 2018-02-07 09:59:12 -08:00
Eeshan Garg
d7903d25e9 pypi_packages: Upgrade to release 0.4.1. 2018-02-07 09:52:51 -08:00
Greg Price
c80802ff1e bots: Clean up create_realm_internal_bots.
This code duplicated the code in setup_realm_internal_bots, with some
added logic to avoid trying to create the same bot twice.  That logic
was buggy so that it would never work at all -- it subtracted a set of
UserProfile objects from a set of email strings -- so it looked like
the command might blow up when run after the users already existed.

In fact, the buggy logic wasn't necessary, because the work the
command does after it is idempotent -- in particular `create_users`,
within its subroutine `bulk_create_users`, already filters out users
that already exist.  So just cut the buggy stuff out, deduplicate the
rest with `setup_realm_internal_bots`, and document that invariant on
the latter.

While we're here, in the common case bail early without doing any
per-realm work in Python, since we're running this on every upgrade.
2018-02-06 18:59:57 -08:00
Greg Price
a9752c5163 left-sidebar: Add back link underlines on hover, just for topics and PMs.
These were removed in 953ee778f, along with the stream names and
right-sidebar user names mentioned in the commit message.  But unlike
those, these don't get any background change on hover, so we need some
way to show the hover.

We can probably still do something that looks nicer than this, but
it's better than not having it.
2018-02-06 17:17:14 -08:00
Greg Price
52c57056cb left-sidebar: Strengthen global filter icons partway back.
This makes them roughly the same visual weight as the (non-muted)
stream icons below -- though that's imprecise because the latter
varies with color.  Tested in both normal and dark-mode.
2018-02-06 17:02:12 -08:00
Greg Price
3c1349b199 stream settings: Clean up a permissions message. 2018-02-06 16:37:18 -08:00
Aditya Bansal
643074edb2 notifications: Add test for realm_name_in_notifications setting. 2018-02-07 05:09:46 +05:30
Rhea Parekh
83a7fd84ab slack importer: Import primary owner user first.
According to https://get.slack.help/hc/en-us/articles/201912948-Owners-and-Administrators,
only one Primary owner of a slack organsation exists. This allocates the first id
to the Primary owner and hence makes sure that the primary owner is imported first.
Added tests for the same.
2018-02-06 14:48:30 -08:00
Rhea Parekh
052e3e1540 slack importer: Change organization admin mappings.
Map 'Primary owner', 'owner' and 'admin' to 'organization admin'.
Added tests for the same.
2018-02-06 14:48:30 -08:00
Rhea Parekh
b3b6023230 slack importer: Always map 'is_staff' to false in user data.
"staff" is only for server administrators, which doesn't exist in Slack.
Hence, this should always be false.
2018-02-06 14:48:29 -08:00
Greg Price
756bbef1f2 Revert "settings: Check if xhr response text include ':' or not."
This reverts commit dd406e87e.  Whatever awkward error message might
have motivated that change, we can fix in a more targeted way when we
see it again.  This version would delete the potentially-informative
context the caller provided in `response` -- even just "Failed" --
based on whether an error message happened to contain a colon
somewhere in it, which is sure to end up feeling unpredictable.
2018-02-06 13:44:10 -08:00
Umair Khan
764cd977d6 test-queue-worker-reload: Increase delay to 1.3s.
See 625939 for more information. In short, the purpose of this delay is
to give autoreload code enough time to touch every watched file at least
once before the change is made.
2018-02-06 10:35:20 -08:00
synicalsyntax
9bb267a016 settings: Force strings to wrap in Filter settings table.
Fixes #8140.
2018-02-06 09:00:11 -08:00
Rishi Gupta
77817410a1 settings: Change wordings of a few notification settings.
The last bit of #8059 (merged as b875fe07) didn't get merged, so just adding
it as a followup.

The "Other notification settings" section will also eventually house the
"pick your notification sound" setting, which is why it isn't called "Other
email settings" or similar.
2018-02-06 08:58:52 -08:00
Robert Hönig
146b833454 marketing: Update integration count.
This also automizes the integrations count update for
the /integrations page.
2018-02-06 08:50:41 -08:00
Greg Price
52f1c57c2a migrations: Fix mypy error in placeholder migration. 2018-02-05 18:03:07 -08:00
Roman Godov
b875fe07eb settings: Added setting to turn on and off realm name in email subject.
Users having only account in one realm will not be distracted by realm
name in subject lines of every email.  Users who have multiple
accounts in realms can turn this setting on and receive a
corresponding realm name in email's subject.

Tweaked by tabbott to rebase and address a few small issues.

Fixes #5489.
2018-02-05 18:01:54 -08:00
Aditya Bansal
ecbb763e79 notifications: Handle an edge case in relative_to_full_url.
For messages where the entire rendered body is a message_inline_image
object, we actually don't display any text and just display the
image. These messages may have links to images which might or might
not be internal to Zulip but in both cases there is a chance of this
links being broken when accessed by an email server like Gmail that
doesn't possess the recipient user's cookies.

We don't want to have ugly looking broken images displayed in email
notifications.  So we patch this by inserting a replacement for the
`message_inline_image` block in which we essentially replace the
content with the textual link.

Edited for clarity by tabbott.
2018-02-05 17:30:55 -08:00
Greg Price
6f128279e8 migrations: Add reverser for emoji_alt_code migration.
This is easy to do, and prevents this feature from getting a server
admin stuck in potentially a pretty uncomfortable way -- unable to
roll back a deploy.
2018-02-05 16:55:21 -08:00
Greg Price
ca1129dea3 Revert "Streams: Disallow certain markdown characters in stream names."
This reverts commit dd1b14378b.

Deleted a conflicted test entirely.
2018-02-05 16:55:21 -08:00
Greg Price
44a0cd77cb Revert "UserProfile: Disallow markdown character in the user profile name."
This reverts commit d30fb5a341.
2018-02-05 16:55:21 -08:00
Greg Price
0b3a414be1 Revert "migrations: Replace special chars in stream & user names with space."
This reverts commit acebd3a5e, as well as a subsequent fixup commit
0975bebac "quick fix: Fix migrations to be linear."

These changes need more work and thought before they're ready to
deploy on any large established Zulip server, such as zulipchat.com.
See discussion on #6534.

In place of the removed migration, leave behind a placeholder so
`manage.py migrate` doesn't get confused on installs where it was
already applied.
2018-02-05 16:55:21 -08:00
Shubham Dhama
9a75a10d48 tests: Test invalid "default stream group" name. 2018-02-05 16:33:42 -08:00
Shubham Dhama
dffedeb053 tests: Test bots deactivation with owner deactivation.
This also cover the `zerver.lib.actions.do_deactivate_user` when
`_cascade=true`.
2018-02-05 16:33:42 -08:00
Brock Whittaker
06f3cb2b78 message-feed: Add some styling to open graph previews.
This adds some styling to make the open graph previews look a bit nicer,
including:

1. Adding a bottom fading gradient to slowly fade out text that is out
of bounds rather than chopping it off.
2. Using font anti-aliasing to make the characters appear smoother.
3. Increasing the font size of the title to give it prominence.
4. Changing the height to 80px from 70px.
2018-02-05 16:27:31 -08:00
Umair Khan
c415cc74d7 validate_stream_message_address_info: Add i18n tags.
Fixes #7076
2018-02-05 16:26:24 -08:00
Brock Whittaker
1a93cd4ffe panels: Give admins a red warning banner when email isn't configured.
Also refactor the "panels"/banner code to be a bit clearer about how
it's supposed to generically work, using [data-process] as a uniquely
identifying marker.

Fixes: #8166.

[greg: rebased and squashed a series of fixup commits.]
2018-02-05 16:00:52 -08:00
Brock Whittaker
fe3a5665da panels: Rename "desktop_notifications_panel" => "panels".
The original code made a 3/4-hearted effort to generically accommodate
more banners/"panels" later, but named itself after the first one made.

[greg: expanded commit message.]
2018-02-05 16:00:52 -08:00
Brock Whittaker
f485abf522 page_params: Pass through settings.WARN_NO_EMAIL, as warn_no_email.
[greg: fixed test]
2018-02-05 16:00:33 -08:00
Tim Abbott
64cb05be67 import: Update the documentation slightly. 2018-02-05 14:53:07 -08:00
Rhea Parekh
78e0a2613f slack importer: Add documentation for Zulip default stream. 2018-02-05 14:46:39 -08:00
Rhea Parekh
811294c6cc slack importer: Add test for checking link in message conversion. 2018-02-05 14:46:39 -08:00
Rhea Parekh
eb7a9675a4 slack importer: Add unit tests. 2018-02-05 14:46:39 -08:00
Rhea Parekh
2b11bff9ad slack importer: Refactor script for easier unit tests.
This is to break the bigger functions into smaller
ones and hence, makes unit testing easier.

Also includes renaming the stream's topic name to 'from slack'.
2018-02-05 14:46:39 -08:00
Rhea Parekh
3006f1eedf slack importer: Change 'restricted_to_domain' to False.
Slack has no email domain restriction, as per 'Step 4 — Invite members to your workspace',
https://get.slack.help/hc/en-us/articles/217626298-Getting-started-for-workspace-creators.
Hence, we should not be hard coding this term to 'True'.
2018-02-05 14:46:39 -08:00
Brock Whittaker
61dad0701a /login/: Remove previous alerts before displaying new alerts.
The issue is that the server wants to display an error when you make a
request and fail, but the jQuery form validator also wants to display
errors at the same time. This removes the server errors to display the
jQuery.

Fixes: #8239.
2018-02-05 13:42:48 -08:00
VishalCR7
68df428de9 portico: Add a loading indicator to login button.
Added a loading indicator when user clicks on Log in button.

Fixes #6477.
2018-02-05 13:42:46 -08:00
Tim Abbott
16162b75b8 settings: Move "High contrast mode" later.
Night mode should be the top item here.
2018-02-05 13:39:21 -08:00
Brock Whittaker
659b533126 settings: Remove indent from checkboxes groups.
This removes the indent we put on checkbox groups and now has them
line up with their respective headers above.
2018-02-05 13:39:17 -08:00
Brock Whittaker
9a71a0fbff settings: Change <h3> to be smaller, bolder. 2018-02-05 13:36:52 -08:00
ihsavru
0f443c89f2 settings: Allow selecting 'restrict to domain' even if no domains selected.
Fixes #7626
2018-02-05 13:34:36 -08:00
Brock Whittaker
e280e3b074 settings: Properly center deactivation modal.
This properly vertically centers the deactivation modal in the
user settings section by setting the top to 50% and the transform
to -50% (50% of the height of the actual modal).

This is an alternate solution to #7888, which just removes the
animation, breaking the normal modal behavior.
2018-02-05 13:31:35 -08:00
Brock Whittaker
eacdc13e46 portico-header: Make vertical padding equal for header.
The header had a padding of "20px 0 15px", which meant that there
was more padding on the top than the bottom, so it has been changed
to "15px 0" instead.

This is a partial revert of c5cdede891.
2018-02-05 13:27:06 -08:00
Brock Whittaker
799dc773f0 portico-header: Fix dropdown pill to be centered.
The added 4px padding made the dropdown pill not vertically center
within the portico header. This removes the padding as it was a
cosmetic change that was not necessary.

This is a partial revert of a37e993907.
2018-02-05 13:27:06 -08:00
Greg Price
70d203c1c8 install: Add experimental option to go straight through more install steps.
We'll make this the normal behavior soon, once we're satisfied with
our arrangements for sending the admin straight to realm creation and
using the app without configuring email.  The instructions in the docs
will also have to change accordingly, of course.
2018-02-05 12:59:12 -08:00
Greg Price
12e08a4fa7 test_management_commands: Fix a few comments. 2018-02-05 12:59:12 -08:00
Greg Price
1d6b072626 test_management_commands: Dedent with override_settings. 2018-02-05 12:59:12 -08:00
Greg Price
48791b731e create_realm: Let server admin skip confirming email.
This will let us defer configuring outbound email to the end of the
install procedure, so we can greatly simplify it by consolidating
several scripted steps.

The new flow could be simplified further by giving the user the full
form in the first place, rather than first a form for just their
email address and then a form with the other details.  We'll leave
that improvement for a separate change.
2018-02-05 12:59:12 -08:00
Greg Price
0dceeebd05 create_realm: Refactor to deal ASAP with key record, not string.
Now, there's just one spot at the beginning of the function where we
inspect the string key the user gave us; and after that point, we not
only have validated that string but in fact are working from our own
record that it pointed to, not the string itself.

This simplifies the code a bit, e.g. by not repeatedly searching the
database for the key (and hoping everything agrees so that we keep
getting the same row), and it will simplify adding logic to inspect
row attributes like `presume_email_valid`.
2018-02-05 12:59:12 -08:00
Greg Price
f766ac6c10 create_realm: Reject invalid key even if no key required.
There's no use case for presenting a key that's invalid; if we haven't
given the user a valid key, we needn't send them to a URL that
presents an invalid one.  And the code is simpler to think about if
the only keys that can exist (after the validation at the top of the
function) are valid ones.

Apart from the case where creation_key is None, but invalid, and
settings.OPEN_REALM_CREATION is True so that we'd previously let the
invalid key slide, this is a pure refactor.
2018-02-05 12:59:12 -08:00
Greg Price
b21cc8103f confirmation: Presume email valid when admin creates realm.
A followup commit will actually act on this presumption.
2018-02-05 12:59:12 -08:00
Greg Price
c932c8400a confirmation: Add a field presume_email_valid to RealmCreationKey. 2018-02-05 12:58:58 -08:00
Tim Abbott
b84f2223a5 avatars: Always include a working URL for the user's own avatar.
This fixes an issue where the user's own avatar was being sent down
the wire as None.  We could have fixed it, as in #8265, by adding code
in the webapp and mobile apps to compute medium-size gravatar URLs as
well, but that would be messy, and there's little benefit to that
complexity (saving at most 2 URLs from the payload).

Fixes #8253.
2018-02-05 12:45:41 -08:00
rht
9161f8c39b zerver/lib: Remove u prefix from strings. 2018-02-05 12:12:58 -08:00
rht
32f1523de2 zerver/worker: Remove u prefix from strings. 2018-02-05 12:12:58 -08:00
rht
71e883b602 zerver/tornado: Remove u prefix from strings. 2018-02-05 12:11:33 -08:00
rht
fae8d23039 zerver/views: Remove u prefix from strings. 2018-02-05 12:11:33 -08:00
rht
2b19f17fc9 scripts: Remove u prefix from strings. 2018-02-05 12:11:33 -08:00
rht
4e0fc593cf docs: Remove u prefix from strings. 2018-02-05 12:11:33 -08:00
rht
4ddc8edbb1 confirmation: Remove u prefix from strings. 2018-02-05 12:11:33 -08:00
rht
396a8b644d provision.py: Colorize error messages for fail condition. 2018-02-05 11:44:33 -08:00
Tim Abbott
0c4aa48895 provision: Clean up error message for missing virtualenv.
This new message should be clearer; it does come up occasionally.
2018-02-05 11:44:33 -08:00
rht
e8a5f68980 provision: Extract color codes into standard variables.
This uses the standard color codes we have in the Python
`zulip_tools` library.

Tweaked by tabbott to clean up some bugs.
2018-02-05 11:44:33 -08:00
AmAnAgr
60dd3a7223 Correct broken links on gsoc-ideas.md 2018-02-05 10:41:49 -08:00
Shubham Dhama
c8d038a239 popovers: Fix user-mention popover errors of @all mention.
`@all` and `@everyone` mentions don't have specific popover, so
constraint added to prevent console errors.
2018-02-05 10:34:47 -08:00
Greg Price
93e29629ab settings: In ALLOWED_HOSTS example, show a list and an IP address.
Different formats for configuration files have a wide variety of ways
of representing lists; so if you're not accustomed to Python syntax,
or aren't thinking of this file as Python code, the syntax for several
ALLOWED_HOSTS entries may not be obvious.  And this setting is one
that an admin is likely to want to touch quite early in using Zulip.
So, demonstrate a multi-element list.

For similar reasons, demonstrate an IP address.  This one is in a
range reserved for documentation (by RFC 5737), like `example.com`.
2018-02-05 10:27:04 -08:00
Robert Hönig
12e7e2557e writing-bots.md: Add fixture JSON skeleton. 2018-02-05 10:19:32 -08:00
Robert Hönig
7d977dd059 writing-bots.md: Remove obsolete bot_handler.storage disclaimer.
Permanent storage is now supported for external bots.
2018-02-05 10:19:32 -08:00
Robert Hönig
31a1c3e5d6 Efficiently clear typeahead when renaming a bot.
There's no reason to clear every user from the typeahead to handle a
single bot being renamed.

This amends 1df3e04.
2018-02-05 10:19:21 -08:00
Tim Abbott
6e0f3a9d75 dict: Add documentation for why we have dict.js. 2018-02-05 10:16:37 -08:00
Tarun Kumar
19acc17f7e markdown_help: Fix katex markdown rendering.
Fixes improper katex rendering in markdown help template.  The
rendering was originally correct, but was broken when we upgraded to a
new version of KaTeX with a different HTML/CSS interface.
2018-02-05 10:08:54 -08:00
Greg Price
42c6abedc4 portico: Fix some untranslated text on login page.
"Sign up" -- pretty important for people to be able to read that!

There's also the "or" that gets rendered as a big "OR" in a divider --
but that styling is too brittle, so that if "or" becomes e.g. "oder",
the lines stay the length they should be for "or" and the lot of them
wrap.  Yuck.  Better to leave it as "or" until that's fixed.
2018-02-05 09:22:41 -08:00
YJDave
32ede6a355 settings: Restrict opening full name and email change overlay modal.
Set condition before opening full name and email change overlay modal,
to check whether changing full name or email is allowed in realm.
2018-02-02 17:50:37 -08:00
YJDave
2a62979cda settings: Remove data-dismiss property of submit-btn in password modal.
In password modal, submit button's data-dismiss property should be
removed, as on data-dismiss we flush all data of form fields,
which results in passing empty string to json request.

We already flush all data of fields after compeletion of request.
2018-02-02 17:50:37 -08:00
Balaji2198
f49d9d016f hotkeys: Add '>' as a hotkey for quote and reply to message.
Tweaked by tabbott to fix a few minor issues.

Fixes #8146.
2018-02-02 17:37:53 -08:00
Vishnu Ks
79e731ec50 hello: Add links to contributor stats of chat applications. 2018-02-02 16:37:11 -08:00
Umair Khan
302e106860 compose: Add parentheses for correct precedence. 2018-02-02 07:24:12 -05:00
Brock Whittaker
693ad9eac8 dark-mode: Make .dropdown-menu links base color in dark mode. 2018-02-01 18:19:48 -08:00
Brock Whittaker
90ffef864e dark-mode: Make deactivate self modal compatible. 2018-02-01 18:08:52 -08:00
Brock Whittaker
535e19e837 dark-mode: Make change full name modal compatible. 2018-02-01 18:08:52 -08:00
Brock Whittaker
5c335b5399 dark-mode: Make change email modal compatible. 2018-02-01 18:08:52 -08:00
Brock Whittaker
f7334663e4 dark-mode: Make message deletion modal compatible.
This makes the message deletion modal compatible with dark mode by
making the background color dark.
2018-02-01 18:08:50 -08:00
Brock Whittaker
b336bb7b97 dark-mode: Make language settings modal compatible.
This makes the language settings modal compatible with dark mode by
making the background color dark.
2018-02-01 18:08:44 -08:00
YJDave
ff8be1ac94 markdown shortcuts: Set cursor position for link insertion shortcut.
For link insertion shortcut without text selection,set the cursor
position between "[]" rather than selecting "url" in "[](url)" string.
2018-02-01 17:35:08 -08:00
YJDave
dbefdad0ab markdown shortcuts: Stop triggering italic shortcut with Ctrl+Shift+i.
The Italic shortcut(Ctrl+i) should not be trigged by Ctrl+Shift+i,
since ctrl+shift+i opens the web inspector in major browsers.
2018-02-01 17:34:27 -08:00
YJDave
b519f1c640 markdown shortcuts: Replace Ctrl+L with Ctrl+L+Shift for link insertion.
As Ctrl-L was interfering with browsers's Ctrl-L, the shortcut key
for link insertion is changed to Ctrl+L+Shift.
2018-02-01 17:31:01 -08:00
Tim Abbott
ef42bb2e73 settings: Fix real-time sync for account settings.
This restores the property that changing one's name in on browser's
"account settings" also changes the user's name in other browser windows'
"account settings" pages.
2018-02-01 16:38:26 -08:00
YJDave
77fefcf8b7 settings: Change design of your-account-page in user settings.
This new organization is much cleaner than the old version.
2018-02-01 16:08:07 -08:00
Tim Abbott
d62cce40f8 settings: Move full-name-change form before password form.
This leaves things in an ugly state, but helps make clear the design
changes in the next commit.
2018-02-01 16:08:07 -08:00
YJDave
7e8da54209 settings: Move full name setting UI into modal.
This makes this UI widget more consistent with its neighbors.

tabbott: This introduces a bug with how the `full_name_field` HTML is
managed; it should be done via the `server_events.js` handler.
2018-02-01 16:08:07 -08:00
YJDave
8582e757cd settings: Improve email change modal in user setting.
- On error, do not close the modal and show the error in the modal.
- Change the order of the `Cancel` and `Change` buttons.
2018-02-01 16:08:07 -08:00
YJDave
21cbdfdb79 settings: Improve password change modal UI.
- When password fields are cleared, update password strength bar.
- On data dismiss, clear password fields.
- Exclude forgot-password div from focus.
- On enter key, modal should be submitted not dismissed.
- Change password btn text from "Change password" to "*****"
2018-02-01 16:08:07 -08:00
YJDave
39604eb18b user settings: Add method and action in account setting ajax form.
This fixes the fact that changing one's name has been totally broken
since the last batch of changes to the account settings page :(.
2018-02-01 16:08:07 -08:00
Greg Price
a717ac6d85 gitattributes: Mark yarn.lock as "binary", i.e. suppress diffs.
This makes many diffs that touch our JS dependencies in package.json
much, much more readable by suppressing multi-thousand-line changes.
With that kind of change routine, it's clear this isn't a file people
are closely reviewing the text diffs in anyway.
2018-02-01 13:37:19 -08:00
Greg Price
e3c82fa3ec tools/test-all: Fix small desync with CI scripts.
This script and our CI scripts tools/travis/{backend,frontend} have
stayed pretty well in sync in the 6 months since 360c27ded made that
relationship explicit and easy to check!

Just one small exception; so fix that.
2018-02-01 11:38:51 -08:00
Greg Price
34f4c822cb ci: Cut out commented-out versions of tools/lint calls.
This may or may not be temporary, but either way, the other code is
there in source control, and the "why" of disabling gitlint is the
helpful bit for a comment.
2018-02-01 11:37:00 -08:00
Greg Price
eef0d2a776 create stream: Use English grammar for message about announcement.
This can still be improved -- e.g., the message should be different if
you actually are an org admin -- but this text at least parses.
2018-02-01 11:26:57 -08:00
Mukul Agrawal
2668af9abd translation: Add hindi translation guide.
Cleaned up by Akash Nimare.
2018-02-01 07:43:24 -08:00
Tim Abbott
f64cf87d14 Update changelog through current master. 2018-01-31 18:05:14 -08:00
Aditya Shridhar Hegde
707915116d portico: Hide realm details when registering new realm.
If there was a realm on the base URL, its logo and name were being
displayed when registering a new realm (i.e. the page where realm details
are entered, after confirming email). This commit prevents the realm
details from being displayed.

Fixes #8186
2018-01-31 15:17:07 -08:00
Brock Whittaker
957d1ee896 landing-page: Click anywhere to close sidebar.
This makes it so you can click anywhere over the grey-ed out area
to close the sidebar.

Fixes: #8208.
2018-01-31 14:50:17 -08:00
Privisus
9fdd6f2bd4 integrations: Add Insping integration. 2018-01-31 14:36:54 -08:00
Umair Khan
41a867ec45 tests: Fix non-deterministic behavior. 2018-01-31 12:07:36 -08:00
Umair Khan
b19d6e99bf django-2.0: Pass string to reverse.
urlsafe_base64_encode returns bytes. These can safely be converted to
ascii encoding. If we pass bytes to reverse, the match fails.
2018-01-31 12:07:36 -08:00
rht
0c4066b0f3 django-2.0: Change parameter name to app_label.
showmigrations command expects a parameter with the name app_label.
2018-01-31 12:07:36 -08:00
Umair Khan
0d796e6c02 django-2.0: Add on_delete to OneToOneField. 2018-01-31 12:07:36 -08:00
Rishi Gupta
a446c030c5 plans: Move LDAP into the community support column. 2018-01-31 11:55:47 -08:00
Robert Hönig
53b4c793f6 setup_venvs.py: Enforce Python 2.7 for zulip-thumbor-venv setup.
zulip-thumbor-venv runs only with Python 2.7. This could cause
provision failures on setups where Python 2.7 is not the default.
2018-01-31 11:29:34 -08:00
Greg Price
3f75b78912 travis: Disable most suites in favor of CircleCI!
Circle has been much more robust than Travis in the few weeks we've
had them both enabled, as well as somewhat faster.  By disabling
Travis, we're no longer exposed to its spurious failures.

One suite remains on Travis: the "production" suite.  This work is
being tracked in #7748.
2018-01-31 11:10:03 -08:00
Greg Price
badbd744f6 travis: Cut webhook config pointing at zulipbot.
We haven't actually been using this zulipbot feature for a long time
(haven't applied the `travis updates` label which it looks for.)
Rather than port the config to CircleCI, just cut it for now; we can
always add something like it back if we start using it.
2018-01-31 11:07:38 -08:00
Greg Price
ba7d06eb12 circleci: Bump the Trusty image to one from the new Dockerfile.
The new Dockerfile is barely different from the old and shouldn't
matter, but in the unlikely case it does, best to find out promptly.
2018-01-31 10:53:13 -08:00
Greg Price
f995ad1ed5 circleci: Simplify Dockerfile templating a bit.
Injecting the generated-file warning into the settings dict felt a
little unnecessarily magical.  A warning like this is always going
to be at the top; the way it might differ between files is mainly
if the syntax for a comment varies, and in that case a simple
substitution like we're doing in this template wouldn't be enough
to express the difference anyway.  So, embrace the hardcoding.

Now, the template and the images.yml entry have a very simple
relationship: the keys in one are exactly the keys in the other.
That's good for people quickly and confidently understanding it.
2018-01-31 10:53:13 -08:00
Greg Price
8a0b5a29b9 circleci: Use the joy of os.makedirs(..., exist_ok=True).
Since Python 3.2, we no longer need to write this little wrapper
all over our own code!  There was much rejoicing.
2018-01-31 10:53:13 -08:00
Greg Price
1d8ce4bdad circleci: Upload to codecov on xenial too.
Only takes about 11 seconds; and there may be some codepaths that are
exercised on one release and not the other.
2018-01-31 10:53:13 -08:00
Vishnu Ks
f8227dc0c3 circleci: Set working_directory to zulip.
Doesn't do much except that when you ssh
into circleci you get a directory called
zulip instead of repo.
2018-01-31 10:53:13 -08:00
Vishnu Ks
d6ffd4d220 circleci: Run xenial py3.5 backend tests alongside trusty. 2018-01-31 10:53:13 -08:00
Vishnu Ks
91506f1bb3 circleci: Generate xenial dockerfiles along with trusty. 2018-01-31 10:53:13 -08:00
Vishnu Ks
be328b2c7b circleci: Create script for generating Dockerfiles.
[greg: updated Dockerfile comment]
2018-01-31 10:53:13 -08:00
Greg Price
9798bb51c8 notifications: Restore a comment explaining received_messages.
A comment like this was removed in
  fa44d2ea6 "settings: Remove autoscroll_forever setting."
The comment went on to say something about autoscroll, but this
part still seems relevant.  While here, adjust grammar and caps.
2018-01-31 07:51:16 -05:00
Eeshan Garg
162f34f0d0 api/get-profile: Make code examples/fixtures testable.
This commit uses the Markdown extension defined in
zerver/lib/bugdown/api_generate_examples to generate the
example fixture and code example, so that both are tested
in zerver/lib/api_test_helpers.
2018-01-31 07:30:54 -05:00
Eeshan Garg
2bea4b70de api/create-user: Make code examples/fixtures testable.
This commit uses the Markdown extension defined in
zerver/lib/bugdown/api_generate_examples to generate the
example fixture and code example, so that both are tested
in zerver/lib/api_test_helpers.
2018-01-31 07:30:54 -05:00
Eeshan Garg
fe98a59f5c bugdown/api_code_examples: Add macro for admin zuliprc lines.
Some of our code examples can only be run with administrator
credentials (such as create-user). Thus, the Markdown extension
for generating code examples should have an option to include
the lines that recommend using an admin zuliprc instead of a
non-admin one.
2018-01-31 07:30:54 -05:00
Eeshan Garg
73a3755120 api/get-all-streams: Make code examples/fixtures testable.
This commit uses the Markdown extension defined in
zerver/lib/bugdown/api_generate_examples to generate the
example fixture and code example, so that both are tested
in zerver/lib/api_test_helpers.
2018-01-31 07:30:54 -05:00
Eeshan Garg
dcf3a9cd18 api/get-subscribed-streams: Make code examples/fixtures testable.
This commit uses the Markdown extension defined in
zerver/lib/bugdown/api_generate_examples to generate the
example fixture and code example, so that both are tested
in tools/lib/api_tests.
2018-01-31 07:30:54 -05:00
Eeshan Garg
6c634d6847 api/get-stream-id: Make code examples and fixtures testable.
This commit uses the Markdown extension defined in
zerver/lib/bugdown/api_generate_examples to generate the
example fixture and code example, so that both are tested
in tools/lib/api_tests.
2018-01-31 07:30:54 -05:00
Eeshan Garg
d46753c26d markdown: Remove macro for successful API JSON response.
Now that we have a Markdown extension-based test framework for
generating and testing code examples on our /api pages, we don't
need this macro anymore!
2018-01-31 07:30:54 -05:00
Eeshan Garg
b1878f14a2 api/update-message: Make code examples and fixtures testable.
This commit uses the Markdown extension defined in
zerver/lib/bugdown/api_generate_examples to generate the
example fixture and code example, so that both are tested in
tools/lib/api_tests.
2018-01-31 07:30:54 -05:00
Eeshan Garg
cf80587f47 api/private-message: Make code examples and fixtures testable.
This commit uses the Markdown extension defined in
zerver/lib/bugdown/api_generate_examples to generate the example
fixture and code example, so that both are tested in
tools/lib/api_tests.
2018-01-31 07:30:54 -05:00
Eeshan Garg
f58ecee2d8 api/stream-message: Make code examples and fixtures testable.
This commit uses the Markdown extension defined in
zerver/lib/bugdown/api_generate_examples to generate the example
fixture and code example, so that both are tested in
tools/lib/api_tests.
2018-01-31 07:30:54 -05:00
Eeshan Garg
c158869096 Rename tools/lib/api_tests.py to zerver/lib/api_test_helpers.py.
Now that the Markdown extension defined in
zerver/lib/bugdown/api_generate_examples depended on code in the
tools/lib/* directory, it caused the production tests to fail since
the tools/ directory wouldn't exist in a production environment.
2018-01-31 07:30:54 -05:00
Eeshan Garg
a1a69a0ac2 api/render-message: Make code examples and fixtures testable.
This commit uses the Markdown extension defined in
zerver/lib/bugdown/api_generate_example to generate the example
fixture and code example, so that both are tested in
tools/lib/api_tests.
2018-01-31 07:30:54 -05:00
Eeshan Garg
c89550cfa0 api docs: Add Markdown extension for generating examples/fixtures.
This commit adds a Markdown extension that allows the following
syntax,

{generate_code_example|<md_file_name>|<fixture or method>}

to generate code examples and fixtures found in tools/lib/api_tests.py
and templates/zerver/api/fixtures.json, respectively.
2018-01-31 07:30:54 -05:00
Greg Price
8147897ac5 test-run-dev: Clean up some basic Python style. 2018-01-30 16:08:43 -08:00
Greg Price
ff8e588340 test-run-dev: Delete commented-out code.
We don't disable code by commenting it out -- that leaves a mess.
We delete it.  Remembering what the code was is what source control
is for.

This fixes cd849bc3f "test-run-dev: Disable Nagios check."
from a few weeks ago.
2018-01-30 15:57:58 -08:00
Greg Price
cad4083987 export: Fix an unnecessary Any.
This was introduced a few weeks ago in
ed4054d11 "Import script: Check and add system bots after every import."
2018-01-30 15:34:47 -08:00
Tim Abbott
49a009eebc Update changelog through end of November.
This covers commits through 3be8e95d13.
2018-01-30 14:01:20 -08:00
Greg Price
f9b12952f8 stripe: Move error handling into stripe.py too.
This completes the separation of our logic for managing Stripe
customers from the view code for the billing page.

As we add more features to our Customer model and to our Stripe
integration, we might further separate those two things; but for now
they're nearly synonymous and there's no problem in them being mixed
together.
2018-01-30 12:44:35 -08:00
Greg Price
0b81762350 billing: Move most Stripe code to its own file.
We'll handle the error-handling in a separate commit, as it's still
entangled with the view function.
2018-01-30 12:44:35 -08:00
Greg Price
5feb31a957 billing: Start pulling apart the page from the logic.
Pull the code that talks to Stripe out into its own functions.
In a followup commit we'll move these to a separate file, as well
as the error-handling logic that remains in the view function
for now.

Also fix the translation markings: the translated string must be a
constant (e.g. a format string), or else translation is impossible.

Viewing with `-b` shows the few changes that happen in the logic
as it moves out of the view function; viewing without shows the
few changes in the rest of the view function.
2018-01-30 12:44:35 -08:00
Tim Abbott
c2ceb3c13b EmailSendingWorker: Fix retry for sending emails.
If an exception was thrown inside `send_email` resulting in a retry,
we would include the `failed_tries` data in the event, which turned
out to thrown an exception itself.

This fixes that flow, including deepening the test so that it would
fail if we didn't have the new logic.
2018-01-30 11:28:09 -08:00
rht
f190888dfb django-2.0: Bump social auth version to 2.1.0. 2018-01-30 10:53:54 -08:00
rht
9a8d2244ca django-2.0: Shift to resolvers from urlresolvers.
The old name is deprecated.
2018-01-30 10:53:54 -08:00
rht
8106a25e61 django-2.0: Add on_delete on ForeignKeys.
In Django 2.0, one must specify the on_delete behavior for all
ForeignKeys explicitly.
2018-01-30 10:53:54 -08:00
akashnimare
8e268b5a7b Fix favicon generator script.
This commit fixes the path for generated favicons.
2018-01-30 10:32:55 -08:00
Vishnu Ks
57d2d3ada5 circleci: Upload coverage reports to codecov.io.
The Travis config does this by a `pip install codecov` in setup and
running the resulting `codecov` command at the end.  That risks
confusion because it makes the library look like something we might
be using *during* the tests to collect coverage information.
Instead, install and run codecov together at the end.

(The docs also suggest using their bash-based uploader instead;
but following those directions seems to result in coverage.xml
not getting included (maybe not even built), and no coverage data
getting uploaded for Python source files, only JavaScript.  Not
sure why that is, but using the pip package is fine.)

Also, because this step is inherently about talking to a
third-party service whose reliability we can't control, and because
it's purely a reporting step that happens after our actual test
suite has succeeded, don't fail if it fails; just print a message.
(I'd prefer a somewhat louder message, like turning that step
yellow or something in the Circle web UI, but Circle doesn't offer
an option like that.  If the coverage reports start consistently
failing for some reason, then if we're actually reading them we'll
notice anyway.)

[greg: Edited step name and error message; wrote this commit message.]
2018-01-29 18:31:53 -08:00
Brock Whittaker
3b600d5591 /billing/: Rename "payment.html" => "billing.html".
This matches the URL path /billing/ to the filename "billing.html".
2018-01-29 17:24:28 -08:00
Vishnu Ks
43a6439b3b upload: Enforce per-realm quota. 2018-01-29 16:06:11 -08:00
Greg Price
b69873522b upload: Handle JSON errors from server generically. 2018-01-29 16:06:11 -08:00
Greg Price
d053e07760 upload: Make filedrop error handling more consistent.
The first argument to the error callback is *usually* a string code
from a list in the filedrop source; but sometimes it was the text
the server sent in the HTTP status line, instead.  The latter isn't
predictable, and so it's not possible to write app code that uses it
to handle error consistently.

Instead, use that parameter for the numeric HTTP status code.  This
still isn't totally clean in that sometimes it's internal filedrop
errors, as strings, and sometimes it's HTTP status codes, as numbers;
but at least both of those are things we can sanely handle with a
`switch` statement.

Also pass through `serverResponse`, which for a nice JSON error from
the server will contain meaningful information about the error which
the calling code can use for nice error handling.  And just drop the
HTTP status text, which at best is redundant with the numeric code.

In passing, fix one case where for no obvious reason filedrop was
passing the file object but not the index.

This should be a pure refactor.
2018-01-29 16:06:11 -08:00
Vishnu Ks
fe787c617c upload: Add a quota field to Realm. 2018-01-29 16:06:11 -08:00
Vishnu Ks
035d3c5e97 upload: Remove UserProfile field for old per-user quota. 2018-01-29 16:06:11 -08:00
Greg Price
55cf54c087 upload: Remove old per-user quota feature.
We'll replace this primarily with per-realm quotas (plus the simple
per-file limit of settings.MAX_FILE_UPLOAD_SIZE, 25 MiB by default).

We do want per-user quotas too, but they'll need some more management
apparatus around them so an admin has a practical way to set them
differently for different users.  And the error handling in this
existing code is rather confused.  Just clear this feature out
entirely for now; then we'll build the per-realm version more cleanly,
and then we can later add back per-realm quotas modelled after that.

The migration to actually remove the field is in a subsequent commit.

Based in part on work by Vishnu Ks (hackerkid).
2018-01-29 16:06:11 -08:00
Aditya Bansal
0fcf0c5052 thumbor: Add thumbor on port 9995 in development.
For now, this does nothing in a production environment, but it should
simplify the process of doing testing on the Thumbor implementation,
by integrating a lot of dependency management logic.
2018-01-29 13:10:29 -08:00
Umair Khan
bb7d21c77f i18n: Make Git ignore mobile.json resources. 2018-01-29 12:49:51 -08:00
Umair Khan
8b2efcbf27 i18n: Include mobile stats in percent translated.
Fixes #7499
2018-01-29 12:49:51 -08:00
Umair Khan
39645eeb27 i18n: Check in mobile_info.json. 2018-01-29 12:49:51 -08:00
Umair Khan
8700e8aeaf i18n: Retrieve mobile translations.
This commit also adds a tool to push translation sources to Transifex.
This tool makes sure that we don't push mobile source file. Mobile
source file is supposed to be handled from Zulip-Mobile repo.
2018-01-29 12:49:51 -08:00
Logan Williams
53e4dc1a46 left sidebar: Clicking on a stream clears the stream search.
Clears and hides the search bar when a stream is selected from the
filtered stream list.

Fixes: #7909.
2018-01-29 11:04:48 -08:00
Greg Price
0f99610478 signup: Small refactor to isolate actually sending mail.
This is a little cleaner in that the try/except blocks for
SMTPException are a lot narrower; and it'll facilitate an upcoming
change to sometimes skip sending mail.
2018-01-29 10:27:11 -08:00
Greg Price
9476a3a334 test-install: Give the host a direct view of the guest's /tmp/src/.
(This is a small fixup to the main change, which was accidentally
included in a previous commit:
  08bbd7e61 "settings: Slightly simplify EMAIL_BACKEND logic."
Oops.  See there for most of the changes described here.)

The installer works out of a release-tarball tree.  We typically want
to share this tree between successive test-install runs (with an rsync
or similar command to update source files of interest) because
rebuilding a release tree from scratch is slow.  But the installer
will munge the tree; so instead of directly bind-mounting the tree
into the container, we need to give it an overlay over the tree, as a
sandbox to play in.

Previously we used lxc-copy's `-m overlay=...` feature to do this,
mounting an overlay in the container.  But then sometimes in
development we want to reach in and edit some code in the tree,
e.g. before rerunning the installer after something failed.  Reaching
inside the container for this is a pain (`ssh` would add latency, and
I haven't installed sshd in the containers; and getting rsync to work
with `lxc-attach` was beyond what I could figure out in a few minutes
of fiddling); and editing the base tree often doesn't work.

So, create the overlay with our own `mount -t overlay`, and have
`lxc-copy` just bind-mount that in.  Now the host has direct access to
the same overlay which the guest is working from.

Also this makes it past time to help the user out in finding the fresh
names we've created: first the container, now this shared tree.  Print
those at the end, rather than make the user scroll to the top and find
the right `set -x` line to copy-paste from.
2018-01-29 10:27:11 -08:00
Shubham Dhama
70079e0a12 settings: Makes selector look better in firefox.
This adds a custom selector icon to make our dropdowns look
well-designed in Firefox.

Fixes: #6707.
2018-01-28 12:40:42 -08:00
YJDave
65592375ce dark-mode: Fix background color of dropdown menus. 2018-01-28 12:40:42 -08:00
YJDave
2b1b477fc7 org settings: Set default value on top of dropdowns. 2018-01-28 12:32:35 -08:00
aedorado
c98d355321 right-sidebar: Fix clicking between Users label and search icon.
This brings the right sidebar UI to match the similar widget in the
left sidebar.  Since there's no other plausible effect for a click in
this whitespace, this small tweak should make using Zulip a bit more
convenient.

Fixes #8161.
2018-01-27 16:29:44 -08:00
Brock Whittaker
2c3b30bf2c landing-page: Change dropdown height to "auto" on mobile.
The height was too large (at 85px), so this makes it auto again.
2018-01-27 16:22:14 -08:00
Brock Whittaker
70b80a2cfb landing-page: Darken body when mobile sidebar is open.
This signals that you should not access the body before trying to close the sidebar.
2018-01-27 16:22:14 -08:00
Brock Whittaker
931261f017 dark-mode: Make all ".modal-bg .modal-header" styles the same.
This is a master selector that selects all the cases that were removed
along with one more (password modal).
2018-01-27 16:19:59 -08:00
Brock Whittaker
ca548e8fa9 dark-mode: Add support for password inputs.
This allows for password inputs to be the darker blue in the dark theme now.
2018-01-27 16:18:09 -08:00
Aditya Bansal
c714235922 keyboard_shortcuts.html: Clean up to use 4 space indentation. 2018-01-27 16:06:36 -08:00
Rohitt Vashishtha
e2a42650c9 emails: Fix link to org-admin help docs. 2018-01-27 15:33:36 -08:00
Aditya Bansal
fbd0e190d0 zerver/navbar.html: Clean up to use 4 space indentation. 2018-01-27 15:26:51 -08:00
Aditya Bansal
52c40668bc compose.html: Clean up to use 4 space indentation. 2018-01-27 15:25:40 -08:00
Brock Whittaker
709ffe6361 informational-overlays: Fix category duplication bug, change map to array.
There is a bug on MacOS on Zulip where the categories are all
duplicated due to faulty looping logic, while also changing the Map to
an Array since maps have less cross-browser support.
2018-01-27 15:20:49 -08:00
Brock Whittaker
c129bba1af informational-overlays: Move CSS => informational-overlays.css.
This moves the CSS to a specialized stylesheet and adds a custom class ".hotkeys_full_table".
2018-01-27 15:20:12 -08:00
Brock Whittaker
e5f04c51e0 informational-overlays: "Spacebar" => "Space". 2018-01-27 15:20:12 -08:00
Brock Whittaker
1d3c6ee375 informational-overlays: Add "The basics" section to keyboard shortcuts.
This adds a section for basic shortcuts.
2018-01-27 15:20:12 -08:00
Tim Abbott
87beacd015 check-templates: Update comments on linter. 2018-01-27 15:17:28 -08:00
Aditya Bansal
bc7614645d zerver/login.html: Clean up to use 4 space and valid indentation.
This is the last commit in the series of commits for completing the
project of cleaning up our html templates to have 4 space and
valid indentation.

Fixes: #1236.
2018-01-27 15:12:23 -08:00
Aditya Bansal
0435e1d05d zerver/index.html: Clean up to use 4 space indentation.
In this commit we also fix a test which would fail as a result of
doing this cleanup since the test wasn't designed to take into
account the space chars which might occur in the beginning of a
html line.
2018-01-27 15:12:11 -08:00
Aditya Bansal
33a150b1dd hello.html: Clean up to use 4 space indentation. 2018-01-27 15:12:04 -08:00
Aditya Bansal
642e27d2b7 analytics/stats.html: Clean up to use 4 space indentation. 2018-01-27 23:06:59 +05:30
Aditya Bansal
16c40ea023 analytics/activity.html: Clean up to use 4 space indentation. 2018-01-27 23:06:58 +05:30
Aditya Bansal
a5c0f286ec static/html/5xx.html: Clean up to use 4 space indentation. 2018-01-27 23:06:58 +05:30
Aditya Bansal
b083c894a8 check-templates: Remove obsolete excludes.
In this commit we remove the excludes for api.html and
api_endpoints.html because those files no longer exist.
2018-01-27 23:06:58 +05:30
Umair Khan
8b33c46165 i18n: Add script to process mobile locales.
This script iterates over all the mobile.json resources and creates a
single file at static/locale/mobile_info.json which contains total and
not-translated strings information against each language. After doing
this, it deletes all the mobile i18n resources downloaded by
tools/sync-translations because we neither want to check them in our
repository nor we want to make our repository dirty.
2018-01-26 16:55:40 -08:00
Umair Khan
151b3e9f1a language_options: Add newline at the end. 2018-01-26 16:55:40 -08:00
Umair Khan
c6bfac0e18 language_name_map: Add newline at the end. 2018-01-26 16:55:40 -08:00
Greg Price
73f682ad7a Slack importer: Disable often-breaking test in CI.
This test randomly fails far too often in Travis -- I think more than
all our other tests combined.  It needs to be fixed before we can ask
everyone to look at build failures it causes.
2018-01-26 15:42:41 -08:00
Eeshan Garg
428134e54b test_docs: Test that settings.EMAIL_GATEWAY_EXAMPLE gets rendered.
In the email integration, previously, EMAIL_GATEWAY_EXAMPLE wasn't
rendered at all, which was recently fixed. So, now, we should make
sure that it gets rendered!
2018-01-25 15:08:02 -08:00
Shubham Dhama
dbce49ac53 refactor: Move topic name checks to Addressee class.
In order to get test coverage on topic name checks, we
do them in Addressee, so that we don't hit an assertion
first. The assertion in question is in Addressee.topic(),
and it was added partly to appease mypy.
2018-01-25 06:21:01 -05:00
VishalCR7
b863782cf8 portico: Add realm name, link, and icon to top of /accounts/register.
Fixes #6329.
2018-01-24 18:44:38 -08:00
Vishnu Ks
bf2961418b puppet: Remove comment about period of soft deactivate users.
This often becomes wrong over time as it is currently.
2018-01-24 17:15:08 -08:00
Vishnu Ks
a11b742984 messages: Calculate value of first visible message ID using cron job.
[greg: Fixed buggy time conversion in estimate_recent_messages.]
2018-01-24 17:15:08 -08:00
Tim Abbott
4f3f2a2af5 docs: Add links to the GSoC guide from CONTRIBUTING.md. 2018-01-24 16:42:22 -08:00
Harshit Bansal
e0ffab8e05 emoji picker: Fix categories overflow in Firefox at 90% zoom.
Explanatory comments added by tabbott.

Fixes: #7511.
2018-01-24 16:20:10 -08:00
Vishwesh Jainkuniya
b1e16d55ac dark-mode: Fix text color of emoji_alt_code. 2018-01-24 15:48:26 -08:00
Jerry Zhang
15ac79cb51 user docs: Add user guide for enabling night mode.
Advertisement for the feature tweaked by tabbott.

Fixes #7405.
2018-01-24 15:16:28 -08:00
Greg Price
3230d35d7f settings: Clean up EMAIL_HOST documentation a bit.
Gmail is a bad example for outbound email; use a generic example.

Also leave the `= None` default out of the config file, as it's
redundant with DEFAULT_SETTINGS in our internal settings.py ; and
explain in the latter why we don't mention the other SMTP settings.
2018-01-24 14:58:21 -08:00
Greg Price
68d5471045 docs: Add code-of-conduct to the main navigation tree.
This quiets the last of the warnings that Sphinx was giving us about
documents not being in any toctree, now that we've explicitly told it
with `:orphan:` about the documents we intentionally don't link there.
2018-01-24 14:37:17 -08:00
Greg Price
e677a87fdd docs: Explicitly exclude gsoc-ideas from toctree.
This silences a warning.
2018-01-24 14:37:17 -08:00
Greg Price
644579c368 docs: Remove our forked RTD layout template.
Now that we have `eval_rst` and can explicitly exclude pages from the
toctree completely, we no longer need to set `includehidden`, and we
can return to using upstream's template.

(Meanwhile, our feature request upstream was successful!  See
rtfd/sphinx_rtd_theme#485, which upstream implemented just a week
after we requested it.  So that would have been another option.)

This reverts commit 11b8b8f48 "docs: Add rtd layout template."
2018-01-24 14:37:17 -08:00
Greg Price
edfa3eabfd docs: Use orphan to directly exclude pages from toctree.
This is what the Sphinx docs recommend when you actually don't want
the page to be included in navigation:
  http://www.sphinx-doc.org/en/stable/markup/toctree.html
And now that we have `eval_rst`, we're able to take advantage of it!

One difference between doing this and the old way of making "hidden"
toctree entries is that with the latter, the "previous" and "next"
links at the bottom of each page would thread through the hidden
entries; which gets kind of confusing when they don't appear in the nav.
2018-01-24 14:37:17 -08:00
Greg Price
a61e032a3b docs/contributing/mypy: Small wording fixes. 2018-01-24 14:37:17 -08:00
Greg Price
5a2b001c18 docs: Fix a bit of confusion over past vs. present.
The careful testing with dozens of realms was a discrete thing
that happened, not a general state that the tool was in;
certainly not the last state it was known to be in, as the rest
of the sentence explains how it hasn't been so carefully tested
since then.  So "as of" doesn't fit.
2018-01-24 14:37:17 -08:00
Greg Price
da626c176f docs: ssl-certificates: 2017 is no longer the present.
Tweak this wording so it stays true and time-appropriate indefinitely.
2018-01-24 14:37:17 -08:00
Greg Price
4bdecb7150 create_realm: Small refactor to check key just once. 2018-01-24 14:34:30 -08:00
Greg Price
6da9ecef88 settings: Set a flag when email isn't configured, so we can warn. 2018-01-24 14:34:30 -08:00
Greg Price
08bbd7e61d settings: Slightly simplify EMAIL_BACKEND logic.
DEVELOPMENT is defined as just `not PRODUCTION`, but this code made
it look like things might be more complicated than that.
2018-01-24 14:34:30 -08:00
Greg Price
0ba3fc3c2f install: Slightly tighten up CLI parsing.
This causes us to give an error if you pass the installer any
positional arguments, e.g. with `--`.  There's no reason you'd want
to do this, but I accidentally did it by passing an extra `--` to
the `test-install/install` wrapper and spent a few minutes on
confused debugging.
2018-01-24 14:34:30 -08:00
Brock Whittaker
d06fd9c357 dark-mode: Make settings page code blocks compatible.
This makes the code blocks compatible by changing the background to be darker and the text color to be base (white).
2018-01-24 14:17:33 -08:00
Brock Whittaker
189832deed dark-mode: Make "error" alerts compatible.
This makes them compatible by making the backgrounds darker and the text base color.
2018-01-24 14:17:33 -08:00
Brock Whittaker
ca6ea11a98 dark-mode: Make "success" alerts compatible with dark mode. 2018-01-24 14:17:33 -08:00
Brock Whittaker
2d18bade15 dark-mode: Make settings "tip" boxes more compatible.
This makes them compatible by making the background dark and the text base color.
2018-01-24 14:17:33 -08:00
Brock Whittaker
0bf02e531c compose: Change "reply" button to be normal coloring.
This changes the button color to look normal, rather than being a blue/purple.
2018-01-24 14:17:33 -08:00
Brock Whittaker
7b78c3e7fd message-feed: Change message edit buttons to new style.
This changes the button styles for the message editing confirmation/cancel to the new button class ".button", rather than ".btn".
2018-01-24 14:17:33 -08:00
Brock Whittaker
f18307a812 informational-overlays: Fix <hr> to be dark mode responsive.
This changes the <hr> to be translucent rather than light grey so it responds nicely to the dark mode theme.
2018-01-24 14:17:33 -08:00
Tim Abbott
9ed2a94b8c nagios: Add configuration designed for full-stack servers.
This doesn't yet pass all Nagios checks correctly, and still has a few
flaws:
* The ideal setup code for the `nagios` user in the database isn't included.
* Some of the other details are a bit off; we need to split some host roles.

But it's better than nothing, and we can iterate from here.
2018-01-24 14:16:03 -08:00
Tim Abbott
886d1028d9 check-templates: Remove obsolete exclude for api.html.
That file not longer exists.
2018-01-24 11:08:54 -08:00
Greg Price
341279a117 travis/production: Update expected HTTP output.
This changed with the recent consolidation of how we get a
self-signed cert in test installs.
2018-01-24 10:58:44 -08:00
Eeshan Garg
e8fe4a65af webhooks/gitlab: Filter out hidden comments from issue descriptions.
Hidden comments of the form `<!-- comment -->` were previously
rendered as is when a new Issue was created. Now, we strip those
out completely!
2018-01-24 10:48:55 -08:00
Greg Price
0f836f51a5 generate-self-signed-cert: Fix a mostly-harmless bug.
Thanks to the magic of `set -x`, I noticed this:
```
+ cat
++ ssl-cert
/tmp/src/zulip-server/scripts/setup/generate-self-signed-cert: line 49: ssl-cert: command not found
+ apt-get install -y openssl
[...]
```

In other words, we were trying to run `ssl-cert` -- the name of a
Debian package I meant to refer to in a comment inside the templated
temporary config file for `openssl req` -- as if it were a command.
It wasn't, hence the error.

Because `set -e` has loopholes like a sieve, this didn't cause the
script to exit, just produced this funny output and presumably caused
the config file's comment to be missing a word.  In principle, it
could do something surprising if for some reason there were a command
named `ssl-cert` on PATH.

Fix it.
2018-01-23 18:08:52 -08:00
Greg Price
6aa7a1b8d2 install docs: Document streamlined self-signed-cert flow.
This is easy now, so make it known to admins who are looking for a
fast path for a test install.

Also totally cut the painfully complicated steps for generating a
self-signed cert by hand.  Anyone who actually wants that can find a
hundred explanations on the Web, or can look at our script if they
want to specifically mirror how we do it (which is mercifully much
simpler than this.)
2018-01-23 18:08:52 -08:00
Greg Price
f26b34405e install --self-signed-cert: Generate our own, rather than use system's.
This gives us just one way of adopting a self-signed cert, rather than
one script which would generate a new one and an option to another
which would symlink to the system's snakeoil cert.  Now those two
codepaths converge, and do the same thing.

The small advantage of generating our own over the alternative is that
it lets us set the name in the cert to EXTERNAL_HOST, rather than the
system's hostname as embedded in the system snakeoil certs.  Not a big
deal, but might make things go slightly smoother if some browsers are
lenient (in a way that they probably shouldn't be.)
2018-01-23 18:08:52 -08:00
Greg Price
d76c2d77f4 install: Tighten an SSL-cert help message.
The option's name now explains for itself some of what we'd
had in prose.
2018-01-23 18:08:52 -08:00
Greg Price
841a5f3152 install: Say --self-signed-cert instead of --snakeoil-cert.
Less evocative, but requires less explanation to document because
it's a well-known term on the Internet.
2018-01-23 18:08:52 -08:00
Greg Price
c27f36a82a install: Rename generate-self-signed-cert.
This script generates one certificate.
2018-01-23 18:08:52 -08:00
Greg Price
d258e48f3d install: Replace our generate-self-signed-certs script.
Take the core of the logic from how Debian generates the system's
/etc/ssl/certs/ssl-cert-snakeoil.pem ; that gives me more confidence
in the various config choices, and it also demonstrates a much cleaner
way to use the `openssl` tool.  Also replace the outer shell logic for
CLI and logging with a cleaner version.
2018-01-23 18:08:52 -08:00
Jerry Zhang
db0fe676db linter: Remove extra space in message_list_view.js. 2018-01-23 15:14:13 -08:00
Brock Whittaker
97acdb7252 ui_util: Move place_caret_at_end to ui_util module.
This makes it publicly accessible across the codebase.
2018-01-23 15:00:11 -08:00
Greg Price
f4d5ade9d8 docs: Exclude Sphinx config file from mypy checking.
It runs in kind of a peculiar environment -- in particular with the
`tags` identifier injected into the namespace -- and it contains
very little code more complex than `foo = "bar"`, so there's not
much to check anyway.
2018-01-23 14:28:56 -08:00
Aditya Bansal
0ec50d8cc8 reminders: Hide message menu reminder's option behind features_flag. 2018-01-24 03:33:40 +05:30
Aditya Bansal
dd0e6c8025 reminders: Fix issue with log file permissions in production. 2018-01-24 03:33:40 +05:30
Greg Price
a727f22a4f lint: Suppress complaint about tags in Sphinx config. 2018-01-23 13:56:21 -08:00
Greg Price
c2b77c5719 lint pyflakes: Pull out our error-suppression patterns as data.
This makes the list much cleaner to understand and edit.
2018-01-23 13:56:21 -08:00
Tim Abbott
8566eebfbb account-settings: Fix missing close-quote in template.
This was introduced in 2ca0fb4128.
2018-01-23 12:34:11 -08:00
Tim Abbott
56395f40d2 static: Restore bundling KaTeX and zxcvbn via django-pipeline.
Since we need KaTeX to be available for zerver/lib/tex.py and
static/third/katex/cli.js to be able to shell out to it.  However, for
some reason, the KaTeX we bundle using Webpack doesn't seem to be
importable by Node (and it's also kinda a pain to find its filename
from `cli.js`).

So, we work around this by just using the legacy system for KaTeX.

Something similar is needed for zxcvbn.js, in order to support the
settings_account.js use case (basically deferred loading of this
file); that requires JS code to have access to the correct path for
zxcvbn.
2018-01-23 12:30:28 -08:00
Tim Abbott
852af0e3c5 Revert "katex: Update the require path to point to the new one."
This implementation never worked, for two reasons:

(1) The logic for getting the path to the katex package had invalid
syntax in the version of Node we use.

(2) The KaTeX package bundled by webpack doesn't seem to be importable
from Node at all.
2018-01-23 12:30:28 -08:00
YJDave
15dd94035c org settings: Handle NEW_USER_BOT not being set.
If NEW_USER_BOT is not configured in organization, then disable setting
for selecting stream for new user notification.
2018-01-23 15:23:25 -05:00
YJDave
2ca0fb4128 user setting: Move password change flow in UI into modal.
Thanks to @brokwhittaker for his significant chagnes in
password modal design.
2018-01-23 14:40:47 -05:00
Brock Whittaker
849d63dd1c settings: Change error for "no data" to something more friendly. 2018-01-23 14:38:59 -05:00
Brock Whittaker
ffe3a6c127 settings: Remove password confirmation in modal.
This removes the requirement to confirm your new password.
It isn't necessary and can be fixed easily with an email
reset if messed up.
2018-01-23 14:38:59 -05:00
YJDave
2b133ee99c settings: When overlay modal opens, remove previous alert messages. 2018-01-23 14:38:59 -05:00
YJDave
e7cae000cf styles: Remove all dead code of m-10 style class from settings.
Remove dead style class m-10 and add m-t-10 class in settings templates.
2018-01-23 14:26:40 -05:00
YJDave
8a1fb5bae5 org settings: Change add emoji permission to be dropdown. 2018-01-23 14:26:40 -05:00
YJDave
74f3189fa5 settings: Add styles for dropdown titles. 2018-01-23 14:26:40 -05:00
YJDave
676d543d86 org settings: Change create stream permission to be dropdown.
Organization permission setting allow-user-to-create-stream is
change to dropdown, from checkbox.
2018-01-23 14:26:40 -05:00
Greg Price
bd9340b4db docs: Warn on development version of install instructions. 2018-01-23 10:57:50 -08:00
Greg Price
bffc11f824 docs: Add an unreleased tag.
This allows us to conditionally include a note just for unreleased
versions of the docs (i.e., "latest") and omit it when released.
2018-01-23 10:57:50 -08:00
Greg Price
d4a86c840d docs: Enable embedding fragments of ReST in our Markdown.
This allows us to selectively use some of the powerful features of
ReST which Python projects with high-quality documentation (like
Python core, and Django) rely on.
2018-01-23 10:57:50 -08:00
Greg Price
2bf5d0074c docs: Update ETA for Let's Encrypt wildcard support.
It's now January 2018, so we can delete this caveat, right?
Not quite yet -- the original post we link to now has an
update saying 2018-02-27.  Let's make it less specific,
in case the date changes again.
2018-01-23 10:57:50 -08:00
Greg Price
cdd35816fe docs: Link back to install step in SSL doc. 2018-01-23 10:57:50 -08:00
Greg Price
8fd98133d8 docs: Tweak discussion of SSL certs in prod requirements. 2018-01-23 10:57:50 -08:00
Greg Price
0cf0c51cad docs: Revise description of main install step.
Bulleted information instead of prose, huzzah!  Also I think we need
to explain the options a bit right here, or at least link to where
they're documented somewhere.  (If the list gets much longer, we'll
want to shift toward the latter.)

Also reorganize existing information a bit, and clean up a couple
of nits.
2018-01-23 10:57:50 -08:00
Greg Price
bcc1456f55 docs: Tighten sub-headings in SSL certs doc.
What I really want is to give these sections nice stable slugs
to put on the anchors and use as the URL fragment, independent of
any wording tweaks on the text headings.  But I don't think we
have that feature with Markdown and our current docs infrastructure.

At least for Certbot, the brevity helps make this heading clearer
than the previous one.
2018-01-23 10:57:50 -08:00
Greg Price
93b957eaae docs: Revise explanation of manual SSL cert install.
Change a bit of prose to bullets.  Also lead with the "If you ..."
that helps readers skim past this section.
2018-01-23 10:57:50 -08:00
Tim Abbott
21d8ff14b4 docs: Update documentation to recommend certbot. 2018-01-23 10:57:50 -08:00
Tim Abbott
2365b13b68 puppet: Move postgres Nagios plugin to main postgres-common.
This plugins package is required in order to use Nagios checks to
verify the Zulip postgres database, and thus belongs in the default
package set.
2018-01-23 10:31:48 -08:00
Dennis Ludl
895a675f4c decorators: Fix email check in access_user_by_api_key case insensitive.
In Zulip, email addresses should always be treated as
case-insensitive; this code path incorrectly assumed the email input
by the user had the correct case.

Discussed in:

https://chat.zulip.org/#narrow/stream/issues/subject/Mobile.20Apps.3A.20Sometimes.20don't.20load.20data/near/461062

Commit message tweaked by tabbott.
2018-01-23 10:04:03 -08:00
Patrick Grave
a2ed76c383 mypy: Use Python 3 syntax for typing in beanstalk/tests.py 2018-01-23 08:49:42 -08:00
Patrick Grave
f2b322c32d mypy: Use Python 3 syntax for typing in upload.py 2018-01-23 08:49:42 -08:00
Patrick Grave
008e250668 mypy: Use Python 3 syntax for typing in test_runner.py 2018-01-23 08:49:42 -08:00
Abijith10
7ed76eeb23 mypy: Use Python 3 type syntax in zerver/webhooks/zendesk/view.py. 2018-01-23 08:37:56 -08:00
Abijith10
c4420ba0c6 mypy: Use Python 3 type syntax in zerver/webhooks/librato/view.py. 2018-01-23 08:37:56 -08:00
Abijith10
8a0cd1a966 mypy: Use Python 3 type syntax in zerver/webhooks/github_webhook/view.py. 2018-01-23 08:37:56 -08:00
Abijith10
d30c2463c2 mypy: Use Python 3 type syntax in zerver/webhooks/deskdotcom/view.py. 2018-01-23 08:37:56 -08:00
Abijith10
c6804f5c8d mypy: Use Python 3 type syntax in zerver/webhooks/delighted/view.py. 2018-01-23 08:37:56 -08:00
Abijith10
39fe64132d mypy: Use Python 3 type syntax in zerver/webhooks/codeship/view.py. 2018-01-23 08:37:56 -08:00
Abijith10
ead63c475b mypy: Use Python 3 type syntax in zerver/models.py. 2018-01-23 08:37:56 -08:00
rht
6b4f392ee9 Slack importer: Make it transparent to user which parts aren't mapped 1-to-1. 2018-01-23 10:36:14 -05:00
Rhea Parekh
11b549e566 slack importer: Add regex for mail links.
`<mailto:foo@foo.com>` is changed to `mailto:foo@foo.com`.
2018-01-23 10:01:15 -05:00
Rhea Parekh
df1bb5fd27 slack importer: Fix link regex and add test case. 2018-01-23 10:01:15 -05:00
Rhea Parekh
5b1e9f8181 slack importer: correct the implementation of unzipping slack data file.
Slack zip file unzips in the same folder.
2018-01-23 10:01:15 -05:00
Rhea Parekh
845a8d63bf slack importer: Prevent id clashes for import in an active db.
Previously we had a problem of id clashes while importing converted
slack data into an existing zulip instance with realms which are actively
populating the database.

This counts the total objects to be imported and does a db transaction
to increase the SEQUENCE number for that table by that number,
and hence allocates a range of ids for the to be converted slack data
objects.
2018-01-23 10:01:15 -05:00
Weronika Grzybowska
7ac7100a1d messages: Make checking for status message consistent with backend.
Adds a check for newline that was present on backend, but missing in the
frontend markdown implementation. Updating messages uses is_me_message flag
received from server instead of its own partial test. Similarly, rendering
previews uses markdown code.

Fixes #6493.
2018-01-23 09:26:41 -05:00
Robert Hönig
4cc8c74aaa frontend: Internally refer to bots by ID.
This is done by using a bot's ID instead of email in
the handler methods for bot_data.bots and bot_data.services,
and updating all code paths involved.
2018-01-23 07:29:00 -05:00
Robert Hönig
bd6fa385a5 frontend: Add outgoing webhook config entries to the "edit bot" menu.
This allows users to edit an outgoing webhook's endpoint URL
and interface type after it has been created.

Fixes #7411.
2018-01-23 07:29:00 -05:00
Robert Hönig
9a15c4e3ff Add bot services to page_params.
This is the first step for allowing users
to edit a bot's service entries, name the
outgoing webhook configuration entries. The
chosen data structures allow for a future
with multiple services per bot; right now,
only one service per bot is supported.
2018-01-23 07:29:00 -05:00
Robert Hönig
06fb868482 Send an event to bot owners when a bot is created. 2018-01-23 07:29:00 -05:00
Rishi Gupta
069ab33615 docs: Add gsoc-ideas.md. 2018-01-23 01:27:21 -08:00
Vishnu Ks
036dc53d20 messages: Rename last_visible_message_id to first_visible_message_id. 2018-01-22 19:53:44 -08:00
Greg Price
ff29fe07be provision: Install virtualenv on xenial too.
As the commit message on 680381c9d which added this for stretch says,
we need this dependency when on xenial as well.  Add it there.
2018-01-22 19:36:52 -08:00
Vishnu Ks
b762b839d4 stripe: Make newly added card default source. 2018-01-22 19:31:17 -08:00
Greg Price
2a59b2d2ac install: Work around a bug in the (our) Debian package for camo.
Before this fix, the installer has an extremely annoying bug where
when run inside a container with `lxc-attach`, when the installer
finishes, the `lxc-attach` just hangs and doesn't respond even to
C-c or C-z.  The only way to get the terminal back is to root around
from some other terminal to find the PID and kill it; then run
something like `stty sane` to fix the messed-up terminal settings
left behind.

After bisecting pieces of the install script to locate which step
was causing the issue, it comes down to the `service camo restart`.
The comment here indicates that we knew about an annoying bug here
years ago, and just swept it under the rug by skipping this step
when in Travis. >_<

The issue can be reproduced by running simply `service camo restart`
under `lxc-attach` instead of the installer; or `service camo start`,
following a `service camo stop`.  If `lxc-attach` is used to get an
interactive shell, these commands appear to work fine; but then when
that shell exits, the same hang appears.  So, when we start camo
we're evidently leaving some kind of mess that entangles the daemon
with our shell.

Looking at the camo initscript where it starts the daemon, there's
not much code, and one flag jumps out as suspicious:

  start-stop-daemon --start --quiet --pidfile $PIDFILE -bm \
    --exec $DAEMON --no-close -c nobody --test > /dev/null 2>&1 \
    || return 1
  start-stop-daemon --start --quiet --pidfile $PIDFILE -bm \
    --no-close -c nobody --exec $DAEMON -- \
    $DAEMON_ARGS >> /var/log/camo/camo.log 2>&1 \
    || return 2

What does `--no-close` do?

 -C, --no-close
     Do not close any file descriptor when forcing the daemon
     into  the  background  (since version 1.16.5).  Used for
     debugging purposes to see  the  process  output,  or  to
     redirect  file  descriptors  to  log the process output.

And in fact, looking in /proc/PID/fd while a hang is happening finds
that fd 0 on the camo daemon process, aka stdin, is connected to our
terminal.

So, stop that by denying the initscript our stdin in the first place.
This fixes the problem.

The Debian maintainer turns out to be "Zulip Debian Packaging Team",
at debian@zulip.com; so this package and its bugs are basically ours.
2018-01-22 18:55:46 -08:00
Greg Price
6e7ae9a239 test-install: Run installer under eatmydata.
This is a tool that throws away `fsync` calls and other requests for
the system to sync files to disk.  It may make the install faster; for
example, if it has to install a number of system packages, `dpkg` is
known to make a lot of `fsync` calls which slow things down
significantly.  Conversely, if there's a power failure in the middle
of running a test install, we really don't mind if the test install's
data becomes corrupt.
2018-01-22 18:55:46 -08:00
Greg Price
eb25928674 test-install: Allow the installer to move the install tree aside.
When the install script is successful, one of the final things it
wants to do is to move the tree that Zulip was installed from into the
deployments directory.  It can't do that, at least not in a naive way
with `mv`, if the tree is actually a mount point.  So, stick the tree
inside some other directory that we create just for the purpose of
being the mount point and containing the install tree.
2018-01-22 18:55:46 -08:00
Greg Price
33a0a00705 production test suite: Use installer's own --snakeoil-cert. 2018-01-22 18:55:46 -08:00
Greg Price
b0a9117e80 test-install: Pre-install a few more dependencies in base image. 2018-01-22 18:55:46 -08:00
Greg Price
0e3ab4d437 test-install: Share the pip cache across installs.
This saves several minutes off the install time.  Sadly pip still
clones Git repos for dependencies that point to them, but for many
others (not all? not sure) it just gets a wheel from the cache.
2018-01-22 18:55:46 -08:00
Greg Price
69ba6ad6d7 test-install: Let installer handle the snakeoil cert. 2018-01-22 18:55:46 -08:00
Greg Price
cef8549ec6 install: Add --snakeoil-cert option.
This provides a major simplification for non-production installs,
including our own testing (it's already in both the test-install
harness script and the "production" test suite) as well as potential
admins evaluating Zulip.

Ultimately this should probably be the default behavior, with perhaps
something shown to admins on the web as a reminder and link to help on
installing a better certificate.  For now, pending working through
that, just get the behavior in and leave it opt-in.
2018-01-22 18:55:46 -08:00
Greg Price
ac88f8ae1b setup-certbot: Stop automatically "agreeing" to the LE TOS.
It's not appropriate for our script to pass the `--agree-tos` flag
without any evidence of the user actually having any knowledge of,
let alone intent to agree to, any such ToS.  Stop doing that.
Fortunately this script hasn't been part of any release, so it's
likely that no users have gone down this path.
2018-01-22 18:55:46 -08:00
Greg Price
7b47cca67e test-install: Pre-install two more dependencies in base image. 2018-01-22 18:55:46 -08:00
Greg Price
525b136f10 install: Install curl.
The third-party `install-yarn.sh` script uses `curl`, and we invoke it
in `install-node`.  So we need to install it as a dependency.

We've mostly gotten away with this because it's common for `curl` to
already be installed; but it isn't always.
2018-01-22 18:55:46 -08:00
Greg Price
07969a2b0c test-install: Share the tarball directory between host and container.
This greatly simplifies iterating on changes to the installer and
associated code: just edit in the shared directory (or edit in your
worktree and rsync to the directory), and rerun.

With this change, the form with a directory is now really the main
way to run the script; the form accepting a tarball is really just
a convenience feature, unpacking the tarball and then proceeding with
that directory.
2018-01-22 18:55:46 -08:00
Greg Price
d7e2190b85 test-install: Pass options through to the installer.
This will facilitate testing interesting installer features
using its own CLI.

On my laptop, with a recent base image (updated a few days ago with
`prepare-base`), it takes just 7 or 8 seconds to get to the installer
running, as timed by passing `--help` so that the installer promptly
exits.
2018-01-22 18:55:45 -08:00
Greg Price
de7abd8f78 test-install: Upgrade CLI parsing, with getopt.
This will let us add more options without the CLI collapsing under
its own weight.
2018-01-22 18:55:45 -08:00
Cynthia Lin
7d8cd37035 modals: Dynamically replace keyboard shortcuts for Mac OS.
Fixes #3577.
2018-01-22 19:41:17 -05:00
Cynthia Lin
d449fcb309 user docs: Dynamically replace keyboard shortcuts for Mac OS. 2018-01-22 19:41:17 -05:00
YJDave
2691c27126 stream settings: Hide create-stream-btn if user not allowed. 2018-01-22 18:26:36 -05:00
YJDave
01510c1e8f all streams: Show lock-icon for subscriber count, if user can't access.
Previoulsy, we display "0 subscribers" if user can't access stream's
subscribers. Replace subscriber count with lock icon in case of
unsubscribed private stream, in "All stream" list.
2018-01-22 18:26:36 -05:00
YJDave
81599cf906 stream settings: Display warning if user can not access subscribers.
Display warning, saying "You can not access private stream subscribers,
in which you aren't subscribed", if user can not access subscribers;
instead of showing zero subscriber to stream.
2018-01-22 18:26:36 -05:00
YJDave
8f65de1970 stream settings: Always show stream type, regardless of subscribed or not. 2018-01-22 18:26:36 -05:00
YJDave
c22285c154 stream settings: Allow org admin to update settings of unsub-stream.
As per backend validations.
2018-01-22 18:26:36 -05:00
Eeshan Garg
3189388258 api docs: Show Python and JavaScript examples first.
It makes sense to make our Python and JS API examples more visible
than our curl examples, since Python is what most people will tend
to use.

Also, from a design perspective, an API documentation page that
starts off with a shiny Python example with syntax highlighting
looked much better than having a bland curl example be the first
thing readers see.
2018-01-22 18:10:29 -05:00
Eeshan Garg
96362e8e60 api docs: Move code examples farther up. 2018-01-22 18:10:29 -05:00
Eeshan Garg
668ac28b85 api/sidebar.md: Move "REST API" to the bottom. 2018-01-22 18:10:29 -05:00
Eeshan Garg
00d3f19c0a integrations/email: Render settings.EMAIL_GATEWAY_EXAMPLE correctly. 2018-01-22 18:05:20 -05:00
Balaji2198
41685105db api/update-message: Make it render correctly in Github. 2018-01-22 15:35:49 -05:00
Balaji2198
992b416802 api/delete-queue: Add Python syntax highlighting. 2018-01-22 15:35:49 -05:00
rht
953478a189 katex: Update the require path to point to the new one.
This fixes #7620.
2018-01-20 08:09:17 -05:00
Aditya Bansal
efbddce34d settings_user_groups.js: Add 100% node test coverage. 2018-01-20 08:01:06 -05:00
Aditya Bansal
40f161ca63 settings_user_groups.js: Remove unnecessary call to get a person. 2018-01-20 08:01:06 -05:00
Greg Price
bf5f1b5f20 install: Start on an LXC-based dev/test environment for the installer.
In order to do development on the installer itself in a sane way,
we need a reasonably fast and automatic way to get a fresh environment
to try to run it in.

This calls for some form of virtualization.  Choices include

 * A public cloud, like EC2 or Digital Ocean.  These could work, if we
   wrote some suitable scripts against their APIs, to manage
   appropriate base images (as AMIs or snapshots respectively) and to
   start fresh instances/droplets from a base image.  There'd be some
   latency on starting a new VM, and this would also require the user
   to have an account on the relevant cloud with API access to create
   images and VMs.

 * A local whole-machine VM system (hypervisor) like VirtualBox or
   VMware, perhaps managing the configuration through Vagrant.  These
   hypervisors can be unstable and painfully slow.  They're often the
   only way to get development work done on a Mac or Windows machine,
   which is why we use them there for the normal Zulip development
   environment; but I don't really want to find out how their
   instability scales when constantly spawning fresh VMs from an image.

 * Containers.  The new hotness, the name on everyone's lips, is Docker.
   But Docker is not designed for virtualizing a traditional Unix server,
   complete with its own init system and a fleet of processes with a
   shared filesystem -- in other words, the platform Zulip's installer
   and deployment system are for.  Docker brings its own quite
   different model of deployment, and someday we may port Zulip from
   the traditional Unix server to the Docker-style deployment model,
   but for testing our traditional-Unix-server deployment we need a
   (virtualized) traditional Unix server.

 * Containers, with LXC.  LXC provides containers that function as
   traditional Unix servers; because of the magic of containers, the
   overhead is quite low, and LXC offers handy snapshotting features
   so that we can quickly start up a fresh environment from a base
   image.  Running LXC does require a Linux base system.  For
   contributors whose local development machine isn't already Linux,
   the same solutions are available as for our normal development
   environment: the base system for running LXC could be e.g. a
   Vagrant-managed VirtualBox VM, or a machine in a public cloud.

This commit adds a first version of such a thing, using LXC to manage
a base image plus a fresh container for each test run.  The test
containers function as VMs: once installed, all the Zulip services run
normally in them and can be managed in the normal production ways.

This initial version has a shortage of usage messages or docs, and
likely has some sharp edges.  It also requires familiarity with the
basics of LXC commands in order to make good use of the resulting
containers: `lxc-ls -f`, `lxc-attach`, `lxc-stop`, and `lxc-start`,
in particular.
2018-01-19 17:27:04 -08:00
ihsavru
a5be1fb109 lightbox: Fix responsiveness issues with image description.
Fixes #7789
2018-01-19 17:12:38 -08:00
akashnimare
37c792aee5 apps: Update desktop app to latest release. 2018-01-20 00:46:31 +05:30
YJDave
8905744bb1 stream settings: Add period at the end of error messages. 2018-01-19 13:05:43 -05:00
Aditya Bansal
1324d2e3c0 reminders: Make shortcuts to setup reminder in message feed work. 2018-01-19 11:33:11 -05:00
Aditya Bansal
7d8d7f7f9b reminders: Add alert message for set reminder success or failure. 2018-01-19 11:33:11 -05:00
Aditya Bansal
0f71a7ecca reminders: Add UI for setting up reminders for messages in the feed. 2018-01-19 11:33:11 -05:00
Aditya Bansal
732321818d scheduledmessage: Adjust schedule_message to accept callbacks. 2018-01-19 11:33:11 -05:00
Aditya Bansal
76f6f7cb47 datetimepicker: Add flatpickr lib as dependancy. 2018-01-19 11:33:11 -05:00
Aditya Bansal
9efc1b08a1 reminders: Add slash command to set reminders from reminder bot. 2018-01-19 11:33:11 -05:00
Aditya Bansal
f272ea9087 scheduledmessages: Start using/expecting delivery_type as a param. 2018-01-19 11:33:11 -05:00
Aditya Bansal
dcce8e7219 scheduledmessages: Add delivery_type field to the table. 2018-01-19 11:33:11 -05:00
Aditya Bansal
c770bdaa3a reminder_bot: Add infra for adding reminder bot to every realm. 2018-01-19 11:33:11 -05:00
Aditya Bansal
5a794f9871 compose.js: Add schedule_message() to handle scheduling of messages.
In this we add code to support '/remind' command for causing
messages to be scheduled.
2018-01-19 11:33:11 -05:00
Aditya Bansal
b71ed33e64 compose: Extract the 'Sending...' from template to be added with Js.
In this we change the way 'Sending...' is displayed. Instead of
hardcoding it into the template we make change the paradigm so
that we can have a flexible message about what's happening
rather than just always saying 'Sending...'. For eg. this will
help in the upcoming feature of Scheduled Messages by having this
message say 'Scheduling...'.
2018-01-19 11:33:11 -05:00
Aditya Bansal
f46d098558 schedulemessages: Add handle_deferred_message() to handle requests.
This is responsible for:
1.) Handling all the incoming requests at the
messages endpoint which have defer param set. This is similar to
send_message_backend apart from the fact that instead of really
sending a message it schedules one to be sent later on.
2.) Does some preliminary checks such as validating timestamp for
scheduling a message, prevent scheduling a message in past, ensure
correct format of message to be scheduled.
3.) Extracts time of scheduled delivery from message.
4.) Add tests for the newly introduced function.
5.) timezone: Add get_timezone() to obtain tz object from string.
This helps in obtaining a timezone (tz) object from a timezone
specified as a string. This string needs to be a pytz lib defined
timezone string which we use to specify local timezones of the
users.
2018-01-19 11:33:11 -05:00
Brock Whittaker
6b03e25382 help: Add "Add a link preview" documentation.
This is a server setting so I created the section "Server settings" in the help sidebar for this to go under, and rewrote the copy and retook the images that were originally done by @Privisus due to some issues.
2018-01-19 06:15:30 -05:00
rht
ee06da9350 bugdown: Linkify Bitcoin URI. 2018-01-19 06:07:43 -05:00
Umair Khan
ea8f1efb63 tests: Re-raise exception if not import error. 2018-01-19 06:02:05 -05:00
Umair Khan
8f316183e0 tests: Make import error tracebacks terse.
This will also disable exception chaining; we do not need it here.
2018-01-19 06:02:05 -05:00
Greg Price
9565a5375f version: Belatedly bump PROVISION_VERSION.
This should have been done in 167a71292 yesterday, which added a
library to requirements; oops.
2018-01-18 17:46:37 -08:00
Greg Price
e68f426286 docs/production: Revise doc on authentication methods.
Hopefully this version makes it somewhat clearer how the different
methods relate to each other, how to choose between them, what
`ZulipRemoteUserBackend` is for, and how the latter works.
2018-01-18 17:45:03 -08:00
Tarun Kumar
9b7b600772 user docs: Fix screenshot in TeX documentation.
Changes the screenshot to use $$ instead of $.
2018-01-18 16:42:15 -08:00
Vishnu Ks
7dbb4cdae2 uploads: Remove ExceededQuotaError class.
We are no longer using it.
2018-01-18 15:38:08 -08:00
Steve Howell
a5e55cee9b bot docs: Clean up "Testing a bot's output".
The main cleanup here is to move the examples out of the bulleted
list, which was getting rendered in an ugly/confusing way.

I also removed some redundant text, fixed some typos, and changed
the wording a bit.
2018-01-18 16:09:24 -05:00
Sampriti Panda
6c32379985 compose: Fix browser extensions interfering with compose box.
Make sure that clicks outside <body> triggered by extensions
don't close the compose box.
2018-01-18 15:53:06 -05:00
Tim Abbott
b04bb1a973 locale: Update translation files.
This includes adding the new Turkish language.
2018-01-18 09:13:05 -08:00
Tim Abbott
2c16c76551 beeminder: Fix buggy coding tag at top of file. 2018-01-18 09:07:06 -08:00
Umair Khan
a994dba583 tests: Give more descriptive import error.
This code takes care of the environment running Python 3.4 when
test label is passed directly to the test-backend command:
./tools/test-backend test_alert_words
2018-01-18 07:13:26 -05:00
Umair Khan
0eda941822 tests: Verify imports in test modules. 2018-01-18 07:13:26 -05:00
Umair Khan
7248a3366b tests: Change print_error_message to check_import_error. 2018-01-18 07:13:26 -05:00
Umair Khan
f3c86c9e58 tests: Remove old import testing code.
We will add the modified version of this code in the next commit.
2018-01-18 07:13:26 -05:00
Umair Khan
c26cdee95d get_test_names: Update to accept ParallelTestSuite arg. 2018-01-18 07:13:26 -05:00
Alena Volkova
aa58e1fcda tests: Make import failure error messages more consistent. 2018-01-18 07:13:26 -05:00
Alena Volkova
13b1334fe4 tests: Refactor error handling of import failures. 2018-01-18 07:13:26 -05:00
Greg Price
1ef2d9d637 billing: Simplify logging of Stripe errors.
Several changes:
* De-duplicate code for different error types.
* No need to list lots of error subtypes where we aren't treating
  them differently; StripeError is the base class of them all.
* Unexpected, non-Stripe-related, exceptions we can handle in the normal
  way.  Just make them show up in the billing-specific log too.
* The Stripe client library already logs type, code, param, and message
  before raising an error, so we don't need to repeat those; just add the
  HTTP status code (because it's not there already and sure why not),
  and the Python exception type the client library chose to raise
  in case that makes things a bit easier to interpret.
2018-01-17 18:10:17 -08:00
Greg Price
858b9d7bc1 billing: Log important requests to Stripe. 2018-01-17 18:10:17 -08:00
Greg Price
3d423a3c7b logging: Fix corrupted default format for our logfiles.
This was changed by accident when the syntax was rearranged,
in 3f4bf2d22 "zerver/lib: Use python 3 syntax for typing"
back in November.
2018-01-17 18:10:17 -08:00
Greg Price
e8ceea7f0f billing: Send logs to a dedicated file.
This will help make them easy to read through.  Include messages to
the logger name `stripe`, which Stripe's client library logs to.
2018-01-17 18:10:17 -08:00
Greg Price
3aa5529b96 billing: Better error message for dev on lacking Stripe credentials.
Normal server admins will never run this code, and zulipchat.com will
have this information configured before users see it, so this message
is really just for development.
2018-01-17 16:44:04 -08:00
Greg Price
455b77225f requirements: Note one requirement as needed only for zilencer.
Otherwise it's potentially puzzling why this is there, for an admin
looking at a normal install without zilencer.
2018-01-17 16:44:04 -08:00
Greg Price
2b6e526ea2 zilencer: Make /billing appear without i18n prefix.
This copies what we do in `zproject/urls.py` for pages in the
main Django app.
2018-01-17 16:44:04 -08:00
Vishnu Ks
0bca0286a1 billing: Integrate Stripe, using Stripe Checkout.
Stripe Checkout means using JS code provided by Stripe to handle
almost all of the UI, which is great for us.

There are more features we should add to this page and changes we
should make, but this gives us an MVP.

[greg: expanded commit message; fixed import ordering and some types.]
2018-01-17 16:43:54 -08:00
Vishnu Ks
a978336765 billing: Create model for customers paying with Stripe.
[greg: reduced migration dependencies, revised commit message.]
2018-01-17 16:15:14 -08:00
Vishnu Ks
167a712922 requirements: Include stripe in common.in. 2018-01-17 16:12:32 -08:00
Shubham Dhama
797fa62fde test auth.py: Add tests for json_fetch_api_key function. 2018-01-17 15:15:51 -05:00
rht
6142a70dc7 docs: Update architecture-overview to point to Python 3.x. 2018-01-17 13:04:11 -05:00
infinitelooped
252a485621 integrations: Add documentation for Groove. 2018-01-17 13:00:11 -05:00
Privisus
e5fc49e23a integrations: Add documentation for Raygun. 2018-01-17 12:53:22 -05:00
Privisus
c758636c1e integrations: Add webhook code, API endpoint, and tests for Raygun. 2018-01-17 12:53:22 -05:00
Rhea Parekh
7153d20205 slack importer: append Message id from the db. 2018-01-17 11:46:27 -05:00
Rhea Parekh
58f1f0e13e slack importer: append Recipient id from the db.
Recipient id should be updated from the database,
otherwise there will be foreign key clashes.
2018-01-17 11:46:27 -05:00
Rhea Parekh
138aba3d89 slack importer: Add unit tests for slack message conversions. 2018-01-17 09:38:53 -05:00
Rhea Parekh
c86411d9a2 slack importer: Move message conversions to a new module. 2018-01-17 09:38:53 -05:00
Rhea Parekh
c1d336f5d1 slack importer: Refactor checking for availability of realm subdomain. 2018-01-17 09:38:53 -05:00
Eeshan Garg
a0526206f9 api/delete-queue: Add JavaScript example. 2018-01-17 09:27:35 -05:00
Eeshan Garg
af1290fde7 api/get-events-from-queue: Recommend using zuliprc.
Recommend using a zuliprc file instead of hardcoding the API
credentials in a config object.
2018-01-17 09:27:35 -05:00
Eeshan Garg
8ed0a0950e api/register-queue: Recommend using zuliprc.
Recommend using a zuliprc file instead of hardcoding the API
credentials in a config object.
2018-01-17 09:27:35 -05:00
Eeshan Garg
df00e6a45f api/create-user: Add JavaScript example. 2018-01-17 09:27:35 -05:00
Eeshan Garg
0e778e152d api/get-profile: Add JavaScript example. 2018-01-17 09:27:35 -05:00
Eeshan Garg
dd88cfac16 api/get-all-users: Recommend using zuliprc.
Recommend using a zuliprc file instead of hardcoding the API
credentials in a config object.
2018-01-17 09:27:35 -05:00
Eeshan Garg
e18b9ae1c1 api/remove-subscriptions: Add JavaScript example. 2018-01-17 09:27:35 -05:00
Eeshan Garg
6d92c88997 api/add-subscriptions: Add JavaScript example. 2018-01-17 09:27:35 -05:00
Eeshan Garg
4d8c20b773 api/get-subscribed-streams: Recommend using zuliprc.
Recommend using a zuliprc file instead of hardcoding the API
credentials in a config object.
2018-01-17 09:27:35 -05:00
Eeshan Garg
b32bb7d5f4 api/get-stream-id: Add JavaScript example. 2018-01-17 09:27:35 -05:00
Eeshan Garg
370d2c6bab api/get-all-streams: Recommend using zuliprc.
Recommend using a zuliprc file instead of hardcoding the API
credentials in a config object.
2018-01-17 09:27:35 -05:00
Eeshan Garg
e781a57ca2 api/private-message: Recommend using zuliprc.
Recommend using a zuliprc file instead of hardcoding the API
credentials in a config object.
2018-01-17 09:27:35 -05:00
Eeshan Garg
e36d61f216 api/update-message: Add JavaScript example. 2018-01-17 09:27:35 -05:00
Eeshan Garg
ba98451928 api/stream-message: Recommend using zuliprc.
Recommend using a zuliprc file instead of hardcoding the API
credentials in a config object.
2018-01-17 09:27:35 -05:00
Eeshan Garg
360885fb12 api/render-message: Add JavaScript example. 2018-01-17 09:27:35 -05:00
Ricky
a90e99dd3e webhooks: Add Beeminder webhook. 2018-01-17 09:24:12 -05:00
fredfishgames
4cb9edecda integrations: Add documentation for Opbeat. 2018-01-17 09:17:19 -05:00
fredfishgames
4e2b99a98b integrations: Add webhook code, API endpoint, and tests for Opbeat. 2018-01-17 09:17:19 -05:00
Shreyansh Dwivedi
b0fb7aa6b2 bugdown: Add preview for vimeo videos.
This also amends a commit from Brock Whittaker <brock@zulipchat.com>
that merges two separate functions for YouTube videos and Vimeo videos
into a generic video recall function.

Fixes #7550.
2018-01-17 09:11:43 -05:00
Cynthia Lin
9fe284b442 dark-mode: Fix background color of table headers. 2018-01-17 03:29:07 -05:00
Cynthia Lin
be21f831a0 settings: Normalize white boxes in settings. 2018-01-17 03:29:07 -05:00
Cynthia Lin
e1764446c1 user settings: Change alert words styling to match other settings forms.
Fixes #8065.
2018-01-17 03:29:07 -05:00
Eeshan Garg
457c5a7735 webhooks/gci: Support 'outoftime' event.
This commit adds support for the 'outoftime' event. Such an event
is triggered when the task deadline for a particular task has
passed.
2018-01-16 15:57:35 -08:00
Cynthia Lin
a028097266 dark-mode: Change Stream list chevrons colors to have more contrast.
Fixes #7794.
2018-01-16 17:18:50 -05:00
Cynthia Lin
56f341ffb5 dark-mode: Combine similar CSS selectors together. 2018-01-16 17:18:50 -05:00
Steve Howell
8530ed0b5e org settings: Make button-clicking code more clear.
On the "Organization settings" page, we had two Save buttons
for admins that had identical markup.  This was confusing for
people reading the code.  Now the two buttons have different
markup and individual, targeted click handlers (albeit still
calling the same function to do most of the work).

The context of this fix is that I was debugging a
Casper flake where our Casper tests were essentially clicking
on the same button twice.  Depending on the timing,
the second button click could cause a "No changes saved!"
behavior that confused the Casper test.  It is unclear whether
Casper was clicking both buttons here (in which case this fix
is necessary) or the same button twice (in which case this fix
just removes a nasty red herring for debugging).

The code still has the flaw that both buttons basically submit
the same data to the server, despite the appearance on the page
that there are two forms.  The best fix for that is probably
just to move the Language/Notifications stuff to another
panel.  I wanted to avoid touching this code altogether, but
the minor modifications here were necessary to improve the
Capser testing situation.
2018-01-16 13:25:19 -05:00
Steve Howell
93d5a33f2a casper tests: Show the server output inline.
Showing the server output transparently in casper tests
will save developers headaches chasing down flakes.  It's
particularly important to see server output intermingled
with the Casper output.
2018-01-16 13:25:19 -05:00
Steve Howell
fa0ac8b6b5 casper tests: Always show console output from the app.
We now always show JS console output when running Casper tests.
The app is not spammy for the "happy path", so there's no real
reason to quiet it down, and it's never been well documented
how to turn on the option, so we've subjected developers to
needless head scratching in the past.
2018-01-16 13:25:19 -05:00
Steve Howell
3cb6871f90 Improve messaging in test_server_running().
We now make it a bit easier to see that you are waiting for
the server, as well as indicating when the server is up.
2018-01-16 13:25:19 -05:00
Steve Howell
5336c03da9 casper tests: Use helper functions for message editing test.
We use these functions to be consistent with the style of the rest
of the code:

    * common.then_click
    * submit_checked
    * submit_unchecked
2018-01-16 13:25:19 -05:00
Steve Howell
7fe59d2dcd casper: Add heading output to message editing test.
It's always been difficult to find code in this file, particularly
when you're matching it up to test failures.
2018-01-16 13:25:19 -05:00
Steve Howell
e7546db0b0 casper: Remove dead code related to message editing.
All the code removed here is pretty old and caused annoying
flakes.  We don't realistically have anybody who can fix
the code.
2018-01-16 13:25:19 -05:00
Rohitt Vashishtha
cc8942e0dc /team: Fetch zulip-js repository data. 2018-01-16 12:23:19 -05:00
Reid Barton
b01b4498cc Fix a typo in prod_settings_template.py. 2018-01-16 08:47:18 -08:00
Viraat Chandra
64034241a0 webhooks: Create Intercom integration and docs. 2018-01-16 08:51:17 -05:00
Xavier Cooney
8c5e74afe9 test_messages.py: Remove unecessary imports. 2018-01-16 08:16:43 -05:00
Xavier Cooney
b0f501ff6c test_helpers.py: Remove unecessary imports. 2018-01-16 08:16:43 -05:00
Xavier Cooney
0c48f5bf09 test_classes.py: Remove unecssary imports. 2018-01-16 08:16:43 -05:00
XavierCooney
35dc203d58 queue_processors.py: Remove unecessary imports. 2018-01-16 08:16:43 -05:00
Robert Hönig
93f47fa700 outgoing webhooks: Rename "Base URL" to "Endpoint URL".
Based on user feedback. "Endpoint URL" gives a clearer
idea of the field's purpose.
2018-01-16 08:11:51 -05:00
Sivagiri Visakan
aeeb9d07a8 integrations: Handle errors in Groove payloads. 2018-01-16 07:31:50 -05:00
Angelika Serwa
374025e10b settings UI: Fix settings sidebar.
Fixes broken settings page on continuous use of tab key.
Sets settings sidebar visibility to hidden when not visible.
Fixes: #7982.
2018-01-12 07:31:53 -05:00
Eeshan Garg
a14b52ef1d api docs: Document the DELETE /users/me/subscriptions endpoint.
Note that there is currently no JavaScript method in zulip-js
to call this endpoint.
2018-01-12 07:30:38 -05:00
Eeshan Garg
1b3b907694 delete-queue.md: Specify queue_id as a required argument.
Specifying it as an optional one was a mistake.
2018-01-12 07:30:38 -05:00
Eeshan Garg
8c723e8c27 api docs: Document the POST /api/v1/users endpoint.
Note that there is no JavaScript equivalent for requesting this
endpoint in zulip-js yet.
2018-01-12 07:30:38 -05:00
Xavier Cooney
6dbc7c5656 org-settings: Fix pointers near disabled checkboxes.
Fixes #7768
2018-01-12 07:26:38 -05:00
Brock Whittaker
842afd1821 dark-mode: Make alert words compatible.
The alert word highlighting is too light to work with the font
when it is white, so this changes it to have a translucent background
so that the color adjusts to be more visible on a darker background.

This is originally taken from #7844 and is a modification of the
solution in #7847.

The reason this approach is better for the codebase is now there is
only one color to change for alert words which reduces the likelihood
that someone in the future will change the color of one theme's
alert words and not the other.

Fixes: #7844.
2018-01-11 17:24:41 -08:00
Kiy4h
68d86b62fa integrations: Add webhook payloads for rollbar. 2018-01-11 06:32:37 -05:00
Robert Hönig
3accf7b935 embedded bots UI: Fix wrong _.each argument order. 2018-01-11 06:30:54 -05:00
Xavier Cooney
e417a99830 webhooks/gitlab: Support topic parameter to specify a topic.
Fixes #7743.
2018-01-11 06:29:55 -05:00
Aditya Bansal
ec1297c1e8 schedulemessages: Add delivery system for scheduled message. 2018-01-10 09:18:02 -05:00
Aditya Bansal
c64766e55e scheduledmessages: Add funcs to verify and schedule messages.
We add two functions:

1.) check_schedule_message(): This function is responsible for
doing the essential initial checkes to verify the validity of
the message. These checkes include things like if user is
allowed to send messages to some stream or not or if the user is
a super_user. All this is basically done by further calling
check_message() with appropriate parameters. This is on the same
lines as is check_send_message().

2.) do_schedule_messages(): This function is responsible for
creating ScheduleMessage table rows for a list of messages that
are to be scheduled. This basically accumulates the ScheduleMessage
objects in a list and then bulk creates the rows.
2018-01-10 09:18:02 -05:00
Aditya Bansal
6c36cf3c82 scheduledmessages: Add model for the ScheduledMessage table. 2018-01-10 09:18:02 -05:00
Aditya Bansal
26bbdc0875 settings_user_groups.js: Add node tests to increase test coverage. 2018-01-10 06:56:52 -05:00
Andy Perez
c209069fcd bugdown: Improve image inlining logic.
Fix #7537
2018-01-09 16:43:22 -05:00
Andy Perez
25b32a5ed7 markdown: Fix backend rendering regex.
An image link such as [example](http://www.example.com/example.png)
is supposed to be inlined by the backend.  The regex
backend_only_markdown_re in markdown.js does not recognize this link
as an image link, causing issues when adding fixtures to
zerver/fixtures/markdown_test_cases.json .
2018-01-09 16:43:22 -05:00
Greg Price
1a83b32da5 circleci: Skip checking links in documentation for now.
This is fairly often -- though not always! -- failing, with a nasty
failure mode where it takes like 6 minutes to time out.  See
discussion on #7748 (search for "bad link").

Actually, after seeing it happen just now when running
test-documentation on my laptop, on some other link, it occurs to me
that I've seen this before -- it's fairly common in Travis, too.  It's
just that it doesn't actually cause the build to fail :-/, and on
Travis we haven't been paying as close attention to slow builds as we
are on Circle right now.
2018-01-09 10:53:13 -08:00
Greg Price
d66f081af8 test-documentation: Send messages to stderr, not stdout.
Generally stderr is the conventional place for this sort of running
commentary, and it's better set up for it: by default stdout may have
a buffer inside the process so that things written to it don't reach
the outside until later, while stderr is always by default unbuffered,
so messages are printed immediately.

Here, until the previous commit, because our color-reset sequence was
being printed without a following newline (with `echo -n`), it was
getting buffered; and then error messages from `scrapy` to stderr were
being erroneously painted with the color intended for the message
"Testing links in documentation...".
2018-01-09 10:15:49 -08:00
Greg Price
618beb7110 test-documentation: Factor out the terminal goo for coloring messages. 2018-01-09 10:15:08 -08:00
Greg Price
f1f5b25969 test-documentation: Fix whitespace for readability. 2018-01-09 10:08:12 -08:00
Robert Hönig
d1d8365a6b embedded bots: Add config data UI.
This adds UI fields in the bot settings for specifying
configuration values like API keys for a bot. The names
and placeholder values for each bot's config fields are
fetched from the bot's <bot>.conf template file in the
zulip_bots package. This also adds giphy and followup
as embedded bots.
2018-01-09 11:50:54 -05:00
infinitelooped
ffa7637215 integrations: Add webhook code, API endpoint, and tests for Groove. 2018-01-09 09:32:52 -05:00
rht
763a96228f left sidebar: Remove plus icon from the stream bar. 2018-01-09 09:05:23 -05:00
Steve Howell
b403897ef9 Fix broken doc links for Python Markdown library. 2018-01-09 08:33:36 -05:00
Vishnu Ks
ad7c8237b9 circleci: Run frontend tests in circleci. 2018-01-08 19:38:23 -08:00
Greg Price
a0ea206379 circleci: cut two TODO comments better tracked elsewhere
These are part of the checklist in #7748.
2018-01-08 19:38:23 -08:00
Greg Price
9a4cd54a25 zilencer: Add a simple management command to create a RemoteZulipServer.
This saves us from having to go into a `manage.py shell` to do this,
and adds a bit more structure like the usage message.
2018-01-08 17:46:46 -08:00
YJDave
2d52131554 user settings: Fix live updates in email change setting.
To toggle email change display, replace display = None
to disabled = true.
Email field shouldn't be removed from settings, it should only
disabled if email changes are disabled in realm.
2018-01-08 14:35:03 -05:00
YJDave
b523fd52f8 user setting: Disable email field if, user not allowed to change email. 2018-01-08 14:35:03 -05:00
YJDave
28ca52b493 user setting: Enhance email change modal.
* Disable spellcheck in email field.
* Decrease width of email change modal.
* Autofocus email field in email change modal.
2018-01-08 14:35:03 -05:00
YJDave
88b2498a8a user setting: Change wording of strings in email change modal.
Change email field title to "New email" and close button
title to "Cancel".
2018-01-08 14:35:03 -05:00
YJDave
0a92dfd120 user setting: Set email change warning icon inline to email field. 2018-01-08 14:35:03 -05:00
Alena Volkova
9d1063d362 urls: Move the json/fetch_api_key endpoint to be an API-style route. 2018-01-08 13:15:52 -05:00
Alena Volkova
7c22045158 test_decorators: Replace the json/fetch_api_key endpoint in tests.
This endpoint is about to become an API-style route and have the legacy
decorator removed from its view. Other endpoints will be used in tests
instead of it.
2018-01-08 13:15:52 -05:00
Rhea Parekh
b583f1f0ff slack importer: Add regex for markdown mapping.
* For strikethrough formatting: Slack's '~strike~' to Zulip's '~~strike~~'.
    * For bold formatting: Slack's '*bold*' to Zulip's '**bold**'.
    * For italic formatting: Slack's '_italic_' to Zulip's '*italic*'.
    * For mentioning formatting: Slack's <@slack_id|short_name> to Zulip's @**full_name**.
    * Checking links.
2018-01-08 08:05:50 -05:00
Rhea Parekh
dd51f348e5 Slack importer: Update documentation. 2018-01-08 08:05:50 -05:00
Rhea Parekh
a6e0bcd5f6 Slack importer: Map messages and usermessages. 2018-01-08 08:05:50 -05:00
Rhea Parekh
24a86a524b slack importer: Quiet the unzip command. 2018-01-08 08:05:50 -05:00
Rhea Parekh
4019a456d1 slack importer: Rename messages file.
Rename messages file from '/message-000001.json' to
'/messages-000001.json'
2018-01-08 08:05:50 -05:00
Rhea Parekh
400c968b0e slack importer: Remove unnecessary comment. 2018-01-08 08:05:50 -05:00
Rhea Parekh
c875428a83 slack importer: Extract get_user_full_name() helper. 2018-01-08 08:05:50 -05:00
Robert Hönig
3420ed1fcc validator.py: Cover missing lines in check_dict(). 2018-01-07 15:23:17 -05:00
Eeshan Garg
a01f8c088a api docs: Document the POST /api/v1/users/me/subscriptions endpoint.
There is a JavaScript equivalent for this endpoint but the npm
package has not yet been released.
2018-01-07 15:19:51 -05:00
Eeshan Garg
ae59b08316 api docs: Document the GET /api/v1/users/me endpoint.
Note that there is no JavaScript equivalent for requesting this
endpoint in zulip-js yet.
2018-01-07 15:19:51 -05:00
Eeshan Garg
045aacbc67 api docs: Document the PATCH /api/v1/messages/<msg_id> endpoint.
Note that there is no JavaScript equivalent for requesting this
endpoint in zulip-js yet.
2018-01-07 15:19:51 -05:00
Eeshan Garg
6f01b042a1 api docs: Document the DELETE /api/v1/events endpoint.
Note that there is no JavaScript equivalent for requesting this
endpoint in zulip-js yet.
2018-01-07 15:19:51 -05:00
Cynthia Lin
da06832837 right-sidebar: Make Search people input collapsible with search icon.
Fixes #4816
2018-01-07 15:05:03 -05:00
Cynthia Lin
7c1a803927 left-sidebar: Fix styling of Streams header to not use links. 2018-01-07 15:05:03 -05:00
Robert Hönig
c745d1901c bot_config.py: Add function for loading config file templates.
load_bot_config_template(bot) parses the <bot>.conf
template file, which can be found in the zulip_bots
package for each bot. It then returns the INI content
of that file as a dict.
2018-01-07 20:05:52 +01:00
Robert Hönig
ed7208fd6e Make EmbeddedBotHandler.get_config_info comply with ExternalBotHandler. 2018-01-07 20:05:52 +01:00
Robert Hönig
9cc059f4aa bot_config.py: Raise exception when getting config data from bot without config entries. 2018-01-07 20:05:52 +01:00
Robert Hönig
83d0c7be31 embedded bots: Run bot.initialize() if bot has this function. 2018-01-07 20:05:52 +01:00
Robert Hönig
dcd62f92fb validator.py: Extend functionality of check_dict().
With this commit, check_dict() can be used to verify
that all keys and/or values of a dict are of a certain
type.
2018-01-07 20:04:52 +01:00
Robert Hönig
82db9a211e bot settings: Set converter as default in embedded bot list.
The previous value 'xkcd' is not yet an embedded bot.
2018-01-07 18:52:04 +01:00
Robert Hönig
e28943cd9a zjquery: Allow attribute selector '[]'. 2018-01-07 18:49:16 +01:00
Robert Hönig
a7b35f24b9 zjquery: Add support for trigger() with string as argument. 2018-01-07 18:47:55 +01:00
Balaji2198
d6ae9341d3 refactor: Remove obsolete .user_offline.
This is an obsolete css class in right-sidebar.css.
2018-01-07 10:04:35 -05:00
Balaji2198
9e814e1b2d refactor: Remove obsolete .ps-scrollbar-y.
This is an obsolete css class in left-sidebar.css.
2018-01-07 10:04:35 -05:00
Balaji2198
f520a28bc7 refactor: Remove obsolete .ps-scrollbar-y-rail.
This is an obsolete css class in left-sidebar.css.
2018-01-07 10:04:35 -05:00
Balaji2198
bebbdce5dc refactor: Remove obsolete .hidden-filter.
This is an obsolete css class in left-sidebar.css.
2018-01-07 10:04:35 -05:00
Eeshan Garg
30795c864d python-zulip-api: Upgrade to release 0.4.0. 2018-01-07 09:52:13 -05:00
Vishnu Ks
ec207e5697 slack importer: Use standalone database for running tests. 2018-01-07 09:50:27 -05:00
Vishnu Ks
5cadc6365a slack importer: Extract data into directory of zip file.
Currently the zip file is extracted to the root of
zulip directory no matter where the the zip file.
The extracted data is not useful after running the command
which pollutes the zulip directory. It make more sense to
extract it to the same directory of zip file especially
when the zip file gets downloaded to /temp like in the tests.
2018-01-07 09:50:27 -05:00
Robert Hönig
29a343cb44 Rename BotUserConfigData to BotConfigData.
This is in compliance with the naming of
BotStorageData.
2018-01-06 14:13:18 -05:00
Cynthia Lin
c82e73e0c9 org settings: Improve design of User groups page. 2018-01-06 11:50:52 -05:00
Cynthia Lin
a937750b1a node tests: Add 100% test coverage for user_groups.js. 2018-01-06 11:50:52 -05:00
Cynthia Lin
5b70bb80b1 org settings: Add typeahead to user group member inputs.
Fixes #165.
2018-01-06 11:50:52 -05:00
Cynthia Lin
58d37702a4 org settings: Add functionality for updating data of user groups. 2018-01-06 11:50:52 -05:00
Cynthia Lin
48f7e8c0d0 org settings: Add functionality for saving state of edited user groups. 2018-01-06 11:50:52 -05:00
Cynthia Lin
d6a937aa2a org settings: Add functionality for adding/removing users from groups. 2018-01-06 11:50:52 -05:00
Cynthia Lin
a8c20876b9 org settings: Add user group save functionality for editing groups. 2018-01-06 11:50:52 -05:00
Cynthia Lin
7da0c126e4 org settings: Add user group deletion functionality. 2018-01-06 11:50:52 -05:00
Cynthia Lin
168e7bb2d6 org settings: Add user group creation functionality. 2018-01-06 11:50:52 -05:00
Cynthia Lin
8c8cd5fbf1 org settings: Render user group data dynamically. 2018-01-06 11:50:52 -05:00
Cynthia Lin
83706e1bcd org settings: Add User groups content and design. 2018-01-06 11:50:52 -05:00
Cynthia Lin
7790e2b23c org settings: Add framework for User groups page. 2018-01-06 11:50:52 -05:00
Alena Volkova
5bbc46762f tests: Improve error handling of import failures.
Fixes #6776.
2018-01-05 12:03:37 -05:00
Umair Khan
7145e6c97b travis: Enable test-queue-worker-reload.
Fixes #1341
2018-01-05 08:24:57 -05:00
Umair Khan
6259390f40 test-queue-worker-reload: Add wait to avoid race condition.
The autoreload code of Django works by looping over the files associated
with all the loaded modules. This loop is run after every 1 second. If
the file is found for the first time by the loop, it is assumed that the
file is new and is not modified between the time it is loaded and is
checked by the loop. This assumption is the source of a race condition.

We can either implement a more sensitive version of the loop or we can
just allow enough time to the Django loop to touch every file at least
once.

For the time being, we are going with the second option.
2018-01-05 08:24:57 -05:00
Umair Khan
e68adab75d test-queue-worker-reload: Poll for 60 seconds. 2018-01-05 08:24:57 -05:00
Umair Khan
21eabf4a60 travis: Fix test-queue-worker-reload.
Previously, there were following problems with the implmentation:
* Same file handle was being used to read and write. We used to do
  `seek(0)` and then `read()`. This had a chance to overwrite
  file data. Now we use different file handles to read and write data.
* We were using text streams. Text streams cannot be used with
  `bufferring=0`. Now we use binary streams without buffering so that
  data is available for reading without any delay.

This commit also updates the key(s) that we search in the logfile.
Previously, launch of all queues was announced in the log, now we only
anounce the number of threads that were launched.

This commit also makes sure that we always exit after gracefull shutting
down the development server.
2018-01-05 08:24:57 -05:00
Steve Howell
2da8e0d521 casper tests: Fix bug related to iago's credentials.
Before this change, we were pulling iago's credentials from
the wrong database, which usually was a non-issue (dev and test
are populated the same way), but which would break things if
you modified iago's credentials in dev.

Now the credentials properly come from the test database.
2018-01-05 07:53:47 -05:00
YJDave
d80d5a2443 stream settings: Restore original stream name in UI on error.
Update stream-name-editable span in UI if it throws error
changing stream name.
2018-01-04 16:52:54 -05:00
YJDave
de13dd41c2 stream narrow: Set message if narrows to never-subscribed private stream.
If user narrows to never-subscribed private stream, display
nonsubbed_private_nonexistent_stream_narrow_message.
2018-01-04 16:52:54 -05:00
YJDave
6a94b33eb0 stream membership: Display add-subscribers option only if user can add.
Display add-subscribers-to-stream option only if stream is
public or user is subscribed to private stream.
2018-01-04 16:52:54 -05:00
YJDave
31cfd16f85 stream settings: Update subscription-btn display instant.
If user unsubscribe from private stream, then immediately remove
subscription option from settings.
2018-01-04 16:52:54 -05:00
YJDave
7ccaf2dc48 stream settings: Hide subscribe/unsubscribe as needed.
For public stream, always show subscription option.
For private stream, if user is subscribed display unsubscribe option.
If user is not subscribe, do not display subscription option.
2018-01-04 16:52:24 -05:00
YJDave
690e82e624 stream settings: Display edit icon only if user is allowed to edit.
Only show edit option for stream name and description if user is admin and
either stream is public or stream is private and admin is subscribed to
private stream.
As per backend restrictions for editing stream name/description.
2018-01-04 16:47:31 -05:00
YJDave
335bed15ee org setting: Remove title strings from settings.
Fixes #7882
2018-01-04 16:41:05 -05:00
YJDave
2aad083f1f create stream: Disable announce stream label, not only checkbox.
If stream is private, disable announce stream label with checkbox.
2018-01-04 16:37:09 -05:00
YJDave
a870bb3cae create stream: Remove disabling announce stream, if all users checked.
Remove disabling announce stream option in stream creation,
if all users are checked to add into stream.
2018-01-04 16:37:09 -05:00
YJDave
ae25f07c69 create stream: Show notification stream name for announcement.
Display stream name in which new stream notification will be announced.
2018-01-04 16:37:09 -05:00
YJDave
bb250f47a6 settings: Apply 'settings-info-icon' style to informational tooltip icons. 2018-01-04 16:37:09 -05:00
YJDave
2124f4c8d9 settings: Add style for settings informational icons. 2018-01-04 16:37:09 -05:00
YJDave
19eef98305 stream setting: Change email address popover placement to right. 2018-01-04 16:25:28 -05:00
YJDave
8c7d4bb5ad stream setting: Fix bug in email address popover.
Email address popover was not showing, because add popover
jquery function was executed before DOM elements get load.
2018-01-04 16:25:28 -05:00
YJDave
f83a694fb6 stream subscription: Clean up error handling. 2018-01-04 16:23:57 -05:00
Privisus
4f700ddcbf integrations: Add webhook payloads for Raygun. 2018-01-04 11:44:39 -05:00
Steve Howell
11af2a6d0f minor: Fix typo for muting message.
The word "in" was missing.
2018-01-04 11:38:31 -05:00
YJDave
ce43daa236 stream settings: Fix all dead code related to #subscriptions-status.
Remove all references of #subscriptions-status and add error handling
of stream settings endpoints.

Fixes #4647
2018-01-04 11:35:37 -05:00
Eeshan Garg
479bc41ca5 api docs: Remove old and outdated endpoint docs. 2018-01-04 10:17:29 -05:00
Eeshan Garg
1fd71287d6 api docs: Document the GET /api/v1/events endpoint. 2018-01-04 10:17:29 -05:00
Eeshan Garg
d235a6c0c4 api docs: Remove superfluous sys imports in Python examples.
These are remnants from old code examples that I forgot to
remove.
2018-01-04 10:17:29 -05:00
Eeshan Garg
c616d7869b api docs: Recommend using zuliprc file for configuration.
In our code examples, we now recommend using a zuliprc file
instead of passing in the config info directly.
2018-01-04 10:17:29 -05:00
Cynthia Lin
b530ee145f click_handlers: Include expanded mobile sidebars as popovers.
This prevents the sidebars from automatically closing when users
click inside the popover area. Fixes #7896.
2018-01-04 09:12:07 -05:00
Vishnu Ks
e6d3f8895f messages: Create function to calculate first visible message id. 2018-01-04 08:52:40 -05:00
Vishnu Ks
f2a7d44c29 models: Add message_visibility_limit attribute to Realm. 2018-01-04 08:52:40 -05:00
MadElf1337
7c113d185f integrations: Add webhook payloads for Facebook. 2018-01-03 14:47:50 -05:00
Brock Whittaker
d026ad4678 settings_display: Change two "!" to one.
There is an extra exclamation mark in the ui response for changing
the emojiset, which has been removed.
2018-01-03 13:29:49 -05:00
Steve Howell
a49fd44612 css linter: Fix error reporting.
Three changes:
    * Change wording of error message.
    * Flush standard error.
    * Use unified diff.
2018-01-03 13:26:55 -05:00
Eeshan Garg
f620525373 api docs: Document the POST /api/v1/register endpoint. 2018-01-03 12:23:30 -05:00
Cynthia Lin
9e060b46d5 portico: Raise z-index of exit button in navigation sidebar.
Fixes #7971.
2018-01-03 11:25:22 -05:00
Alena Volkova
45f0c76c44 settings: Limit the creation of generic bots.
This commit adds a setting to limit creation of generic bots
to admins for realms that want that restriction.  (Generic
bots, apart from being considered spammy on some realms,
have less locked down permissions than webhook bots).

Fixes #7066.
2018-01-02 18:12:22 -05:00
Marco Burstein
6f8792729d manage.py: Move the maximum digits calculation to outside of a loop. 2018-01-02 17:21:28 -05:00
Marco Burstein
ff5a73e027 manage.py: Make it easy to create lots of streams with populate_db.
Fix #7968.
2018-01-02 16:48:03 -05:00
Eeshan Garg
18c3bec667 webhooks/gci: Support "unassign" event type.
This commit adds support for the "unassign" event type, the
payloads for which are generated when a mentor unassigns a student
from a task.
2018-01-02 16:42:00 -05:00
Eeshan Garg
2c7f4d2187 webhooks/gci: Support "extend" event type.
This commit adds support for events of type "extend", the payloads
for which are generated when a mentor extends the deadline for a
task.
2018-01-02 16:42:00 -05:00
Steve Howell
ec2015ee8c Extract settings_display.report_emojiset_change().
This mostly moves code from server_events_dispatch, but
it also de-duplicates the logic in emoji_success(), and
it does early-return for the "text" case to keep the
function a bit flatter.
2018-01-02 15:13:50 -05:00
Aastha Gupta
daf86eb664 settings: Add "text" option to emoji_set model.
We no longer have a special UI setting and model
field ("emoji_alt_code") for saying users want text-only
emojis.  We now instead make "text" be a fifth choice
for "emojiset".

Fixes #7406
2018-01-02 14:55:01 -05:00
YJDave
5ff84e97b5 markdown: Add markdown shortcuts.
Markdown shorcuts:
ctrl/cmd+b ->insert bold text
ctrl/cmd+i ->insert italic text
ctrl/cmd+l ->insert link

Fixes #5978
2018-01-02 13:48:50 -05:00
Vishnu Ks
277d463d23 messages: Add option to limit users message history. 2018-01-02 13:45:01 -05:00
MadElf1337
e7f1a9ee34 inetgrations: Add webhook payloads for Honeybadger. 2018-01-02 11:45:33 -05:00
YJDave
fa44d2ea69 settings: Remove autoscroll_forever setting.
Fixes #6845
2018-01-02 10:35:49 -05:00
Umair Khan
c2248a81dc Enable test-run-dev. 2018-01-01 09:42:11 -05:00
Umair Khan
9bbce65274 test-run-dev: Redirect stderr to STDOUT.
This redirects the STDERR of run-dev.py command to STDOUT. This is
how you are supposed to redirect according to the docs.
2018-01-01 09:42:11 -05:00
Umair Khan
4c5d361990 test-run-dev: Remove close_and_get_content.
After the new implementation of start_server, this function is not
needed anymore.
2018-01-01 09:42:11 -05:00
Umair Khan
45b004818b test-run-dev: Fix start_server implementation.
Previously, there were following problems with the implmentation:
 * Same file handle was being used to read and write. We used to do
   `seek(0)` and then `read()`. This had a chance to overwrite file
   data. Now we use different file handles to read and write data.
 * We were using text streams. Text streams cannot be used with
   `bufferring=0`. Now we use binary streams without buffering so that
   data is available for reading without any delay.
2018-01-01 09:42:11 -05:00
Umair Khan
cd849bc3f1 test-run-dev: Disable Nagios check.
We have moved API to a separate repo. Nagios related code still assumes
that the api folder exists in the Zulip repo.
2018-01-01 09:42:11 -05:00
XavierCooney
5409a98039 docs: Fix typo in multiple-organizations.md. 2017-12-31 09:11:30 -05:00
Jerry Zhang
535e6bd218 user docs: Add user guide for configure authentication methods.
Fixes #3357.
2017-12-31 08:09:47 -05:00
Cynthia Lin
c31e148ea8 user docs: Add links back to homepage to the bottom of the sidebars. 2017-12-31 08:08:25 -05:00
Cynthia Lin
20a745390b user docs: Allow redirection of external URLs in documentation sidebars.
Fixes #7916.
2017-12-31 08:08:25 -05:00
Utkarsh Patil
50be484964 onboarding: Fix error-password overlap bug
Apply appropriate spacing between password field and error message.

Fixes: #7796.
2017-12-30 11:05:39 -05:00
Eeshan Garg
80405747ce test_docs: Test new API docs (templates/zerver/api/*). 2017-12-30 11:03:23 -05:00
Eeshan Garg
b73c60a135 api docs: Document the GET /api/v1/users endpoint. 2017-12-30 11:03:23 -05:00
Eeshan Garg
b31bdf23ca api docs: Document the POST /api/v1/messages/render endpoint.
Note that currently, there is no way to interface with this
endpoint using zulip-js.
2017-12-30 11:03:23 -05:00
Eeshan Garg
0458faf2f9 api docs: Document the GET /users/me/subscriptions endpoint. 2017-12-30 11:03:23 -05:00
Eeshan Garg
cf8a8c8811 api docs: Document the GET /api/v1/get_stream_id endpoint.
This commit documents the /api/v1/get_stream_id endpoint.

Note that there is currently no way to interface with this
endpoint with zulip-js.
2017-12-30 11:03:23 -05:00
Cynthia Lin
781e8b442f general UI: Add a description for the message view source icon. 2017-12-30 11:00:44 -05:00
Cynthia Lin
e71970ca46 general UI: Add a description for the message edit icon.
Fixes #7745.
2017-12-30 11:00:44 -05:00
rht
185fd99816 mypy: Use Python 3 type syntax in several files. 2017-12-30 07:34:51 -05:00
rht
1324d9f000 mypy: Use Python 3 type syntax in zerver/views. 2017-12-30 07:34:05 -05:00
rht
2e8adbde12 mypy: Use Python 3 type syntax in zerver/lib/actions.py. 2017-12-30 07:33:07 -05:00
Eeshan Garg
e769a7eed2 api docs: Document the get-streams endpoint.
This commit documents the get-streams endpoint, which can be
by making a GET request to /api/v1/streams.

Note that in the code examples, JavaScript is missing an example
for how to pass in the `include_` query parameters. That is
because zulip-js's client.streams.retrieve function doesn't take
any arguments and zulip-js does not export any function equivalent
to client.call_endpoint in python-zulip-api/zulip.
2017-12-29 17:03:36 -05:00
Eeshan Garg
3003d3d927 api examples: Change required JS module from zulip to zulip-js.
The JS module we ask our users to install in the installation
instructions is zulip-js, not zulip. These examples would fail
with the latter. This commit updates the examples to use the
name zulip-js.
2017-12-29 17:03:36 -05:00
Eeshan Garg
89f622937d api docs: Generate Arguments table from JSON.
This commit does the following:
* Move the Arguments table data from stream-message.md and
  private-message.md to a JSON file.
* Add a Markdown extension that allows one to include and render
  a table from a JSON file like so:
    {generate_arguments_table|arguments.json|private-stream.md}
* Use Bootstrap's .table class to format the table instead of
  relying on custom CSS.
2017-12-29 17:03:36 -05:00
Eeshan Garg
229cdfce90 markdown: Add a macro for invalid API key JSON response.
The JSON response for when an invalid API key is used to initiate
an API call seems to be identical in every case, so this macro
can be reused all the time.
2017-12-29 17:03:36 -05:00
Eeshan Garg
3a90a6be5e markdown: Add macro for successful send message JSON response.
The JSON response for when an API call to send a message is
successful is the same for both private and stream messages, so
these macros may be used again.
2017-12-29 17:03:36 -05:00
Eeshan Garg
b093a861e0 api/private-message: Document arguments and examples responses.
This commit adds the following:

* A table specifying the arguments that are required for this API
  call.
* Examples of JSON responses.

This will help us in obsoleting api_endpoints.html.
2017-12-29 17:03:36 -05:00
Eeshan Garg
cdcaf1374e api/stream-message: Document arguments and examples responses.
This commit adds the following:

* A table specifying the arguments that are required for this API
  call.
* Examples of JSON responses.

This will help us in obsoleting api_endpoints.html.
2017-12-29 17:03:36 -05:00
Eeshan Garg
94bc9d52d1 api docs: Split usage.md into two separate docs.
This commit splits usage.md into two separate docs,
stream-message.md and private-message.md. The arguments and return
values for sending a stream message are somewhat different from
those of sending a private message, so it made sense to split the
two up for clarity.
2017-12-29 17:03:36 -05:00
YJDave
29905ad5d6 create stream: Before sending notificaion, check if NOTIFICATION_BOT exists.
There might be case that NOTIFICATION_BOT is none, so before sending stream
announce notification, check first if settings.NOTIFICATION_BOT is not none.
2017-12-29 08:59:55 -05:00
akashnimare
db7943478e api: Align code blocks properly in /api page.
Fixes #7395.
2017-12-29 08:45:37 -05:00
MadElf1337
39fc26deff integrations: Add webhook payloads for Runscope. 2017-12-29 07:27:20 -05:00
Steve Howell
4a27f4199d Try to avoid codecov spam.
I am increasing the threshold even more for when
codecov complains.  Since the tool reports so many
false negatives, we should probably change our philosophy
on code coverage so that this tool only reports
catastrophic commits (like .e.g. a commit that prevents
running a whole test suite) and let our more specific
tools continue to catch things like regressions of files
from 100% coverage.
2017-12-29 07:23:26 -05:00
akashnimare
ef51a39552 markdown: Update regex for strikethrough.
This uses the correct regex for strikethrough. Also, added
a test to make sure that strikethrough works when it contains
link with whitespace.

Fixes #7596.
2017-12-28 15:59:04 -05:00
YJDave
dd406e87e9 settings: Check if xhr response text include ':' or not.
We join extra text message for notification and xhr response text by ':'.
Before joining, check if xhr response text already include ':', to
prevent notification with more than one ':'.
2017-12-28 15:54:57 -05:00
YJDave
c06028159e org setting: Clean code of realm domain modal.
Remove extra lines for reporting alert messages on modal
and add predefined ui_report functions instead.
2017-12-28 15:54:57 -05:00
MadElf1337
de62e11c23 integrations: Add webhook payloads for StatusPage.io. 2017-12-28 15:53:06 -05:00
cPhost
470e57db49 node tests: Enforce 100% coverage for stream_data.js. 2017-12-28 09:39:45 -05:00
cPhost
154436140b node tests: Cover stream_data.delete_sub. 2017-12-28 09:39:45 -05:00
Steve Howell
80477da481 quick fix: Stop tracebacks with missedmessage_hook.
A `None` value is not properly handled in this function, which
indicates some lack of testing or a recent regression we don't
understand.  We were getting lots of tracebacks from this line
of code on our test server:

    mentioned = 'mentioned' in flags and 'read' not in flags
2017-12-28 08:10:56 -05:00
Rishi Gupta
ad9f0dea36 documentation: Explain major and minor provision_version. 2017-12-28 08:04:16 -05:00
Kiy4h
2e35b7fd60 mypy: Use Python 3 type syntax in zerver/webhooks/taiga/view.py. 2017-12-28 07:26:44 -05:00
Kiy4h
93cc19e3f8 mypy: Use Python 3 type syntax in zerver/webhooks/helloworld/view.py. 2017-12-28 07:26:44 -05:00
Kiy4h
3b7fbc1a1d mypy: Use Python 3 type syntax in zerver/webhooks/gosquared/view.py. 2017-12-28 07:26:44 -05:00
Kiy4h
6fa51be822 mypy: Use Python 3 type syntax in zerver/views/push_notifications.py. 2017-12-28 07:26:44 -05:00
Kiy4h
64413e3b91 mypy: Use Python 3 type syntax in zerver/views/email_mirror.py. 2017-12-28 07:26:44 -05:00
Kiy4h
238cd2b132 mypy: Use Python 3 type syntax in zerver/views/alert_words.py. 2017-12-28 07:26:44 -05:00
Kiy4h
78e71faefe mypy: Use Python 3 type syntax in zerver/lib/test_fixtures.py. 2017-12-28 07:26:44 -05:00
Steve Howell
aae69702fe casper: Try to fix clicking flakes for message editing.
The new `common.then_click` should prevent some races and remove
some duplicate code.
2017-12-27 18:33:32 -05:00
Steve Howell
9391f7aa98 quick fix: Turn off git lint for Travis builds.
We may be having problems with git lint, so this is a quick
fix to hopefully get builds working again.
2017-12-27 18:20:18 -05:00
Balaji2198
de27142e16 stream settings: Fix link to docs about public/private streams. 2017-12-27 15:04:34 -08:00
Steve Howell
6d59dbca8d casper: Add more flake protection for message editing.
(This is a continuation of the prior commit's technique.)
2017-12-27 17:25:14 -05:00
Steve Howell
27f7bdf8b1 casper: Attempt to fix flakes with message edit settings.
This introduces the helpers submit_checked() and submit_unchecked()
to wait to submit forms till casper sees the checkbox being clicked.
2017-12-27 17:12:52 -05:00
Cynthia Lin
5df9011ae5 user docs: Apply highlights to documentation indexes. 2017-12-27 15:15:05 -05:00
Cynthia Lin
fa92a35f17 user docs: Highlight currently selected user docs article.
Fixes #7053.
2017-12-27 15:15:05 -05:00
Cynthia Lin
1dcd311ce8 user docs: Fix miscolored hamburger icon on mobile view. 2017-12-27 15:15:05 -05:00
Rhea Parekh
ed4054d110 Import script: Check and add system bots after every import.
This checks for the existing system bots and adds them if they
aren't included in the import.
2017-12-27 07:52:45 -05:00
Rhea Parekh
01fa8416b1 Slack importer: Updating the documentation to the new method.
The already existing import-users-and-channels-from-slack.md file is
updated here to follow the new method.
2017-12-27 07:50:53 -05:00
Rhea Parekh
6b32519a71 Slack importer: Add Travis tests. 2017-12-27 07:50:53 -05:00
Rhea Parekh
62aec0688f Slack importer: Add slack to zulip data conversion script as a manage.py command. 2017-12-27 07:50:53 -05:00
Rhea Parekh
cd332a7f59 Slack importer: Append ids to the existing ids in the database.
For import with the condition `--import-into-nonempty`, the ids
of the mapped data will be appended to the existing ids in the
database.
2017-12-27 07:50:53 -05:00
Rhea Parekh
5b37c5562b Slack importer: Add the slack to zulip data conversion files. 2017-12-27 07:50:53 -05:00
Rhea Parekh
3d4ee3b862 zerver/tests/test_email_mirror: Sweep force_str. 2017-12-26 09:09:31 -05:00
Rhea Parekh
25e5969add zerver/lib/mobile_auth_otp: Sweep force_str. 2017-12-26 09:09:31 -05:00
Rhea Parekh
cc872ad976 zerver/lib/upload.py: Sweep force_bytes from ensure_medium_avatar_image. 2017-12-26 09:09:31 -05:00
Rhea Parekh
092472f42d tests: Add test coverage for uploading avatars to S3UploadBackend.
Add test coverage for the function upload_avatar_image and
ensure_medium_avatar_image in S3UploadBackend.
2017-12-26 09:09:31 -05:00
Rhea Parekh
bebd8df728 zerver/webhooks/github/view: Sweep force_str. 2017-12-26 09:09:31 -05:00
Rhea Parekh
99cb001345 zerver/webhooks/beanstalk/view.py: Sweep force_bytes and force_str. 2017-12-26 09:09:31 -05:00
Rhea Parekh
b792a90842 Remove unused imports in the codebase. 2017-12-26 09:09:31 -05:00
Rhea Parekh
6e374d30e1 tools/lib/provision: Clean the code to directly read files in binary mode. 2017-12-26 09:09:31 -05:00
Steve Howell
5dfd7f030a refactor: Clean up add_subscription_marker().
This change has a few cleanups:

    * We early-return on last_msg_container === undefined
      to make the function flatter.
    * We avoid comparing two boolean values for equality,
      which can be a landmine if one of the values is
      `undefined`, which is falsy but not actually `false`.
    * We extract some local variables for readability.
    * We make the conditions for subscribe/unsubscribe
      more explicit.
2017-12-26 09:01:21 -05:00
Steve Howell
f6c41a54b9 Avoid overwriting message.unread for message edits.
This fixes a bug where this used to happen:

    * Alice has not read a message
    * Bob edits the message
    * Alice immediately reads the message
    * Bob's edit arrives to Alice and sets her
      message status back to unread

Essentially, the root cause of the bug is that we update
message.unread for edits, possibly from stale data, even
though Alice has more current info about reading the message.

This is the final fix to that scenario.  There were some
aggravating factors that widened the race window which were
fixed in earlier commits.

Fixes #6248
2017-12-26 09:01:21 -05:00
Steve Howell
58ec5f9695 Use throttle, not debounce, to "read" messages.
We were queuing up individual messages to be flagged as
read on the server before this change, and we used debounce
to avoid sending individual POSTs, but this created delays
that were ripe for race conditions.

Now we batch them in the caller and use throttle instead.
This now prevents us from slamming the server with lots of
individual requests, without as many opportunities for races.

(Note that we still have some possibility of race conditions,
but they should be rare now, and other commits will address
some of the other contributors to read/unread glitches.)
2017-12-26 09:01:21 -05:00
Steve Howell
204949396c refactor: Delete deprecated message.flags attribute.
Once we convert message.flags to more specific boolean attributes
like message.mentioned and message.alerted, we should get rid of
the `flags` attribute, as it will only confuse debugging.
2017-12-26 09:01:21 -05:00
Steve Howell
0a3d769911 local echo: Bypass message.flags array.
We no longer set message.flags in the local echo path.

In the markdown parsing step, we just set message.mentioned
directly.

And then we change `insert_new_messages` to no longer
convert flags to booleans, and move that code to only
happen for incoming server message events.
2017-12-26 09:01:21 -05:00
Steve Howell
4d8d17d134 refactor: Upstream calls to set_message_booleans.
We want to call `set_message_booleans` as soon as we
get data from the server, to avoid confusion about whether
`flags` is the authoritative field.

This commit has callers to `add_message_metadata` call
`set_message_booleans`.

This also sets us up to **not** call `set_message_booleans`
in the local echo codepath, where we can just have the
markdown processor set booleans natively.
2017-12-26 09:01:21 -05:00
Steve Howell
e96b3ffc5a refactor: Remove flags parm in set_message_booleans.
In all cases the value of `flags` we were passing in was
actually `message.flags` (although it was slightly obscured in
one place), so now we just pass in `message`.

(We also move a tiny bit of defensive code to set `flags`
into `set_message_booleans`.)
2017-12-26 09:01:21 -05:00
Steve Howell
7165bb1eea minor: Remove duplicate function names in unread.js.
We no longer use the verbose style of naming functions
that are exported.
2017-12-26 09:01:21 -05:00
Steve Howell
199650d5c7 refactor: Stop using flags array for unread counts.
In the JS code, we now use `message.unread` universally as
the indicator of whether a message is unread, rather than
the `message.flags` array that gets passed down to us
from the server.

In particular, we use the unread flag for filtering when
you search.

A lot of this commit is just removing logic to add/remove
"read" from `message.flags` and updating tests.

We also explicitly set `message.unread` to `false` inside of
`unread.mark_as_read()` and no longer have `unread.set_flag()`.

(Some of the callers to `unread.set_flag` were also calling
`unread.mark_as_read`, which was updating the `message`
object, so now we just have `unread.mark_as_read` update
the `message` object.  And then unread_ops.mark_all_as_read()
was already calling unread.declare_bankruptcy().)
2017-12-26 09:01:21 -05:00
Steve Howell
a1b221730b refactor: Add unread.get_unread_message{_ids}().
This adds two similar functions to simplify
our batch processing of unread messages.

    unread.get_unread_messages
    unread.get_unread_message_ids

They are used to simplify two functions that loop
over messages.  Before this change, the functions
would short circuit the loop to ignore messages
that were already read; now they just use the
helpers before the loop.
2017-12-26 09:01:21 -05:00
Steve Howell
a8cd7655d3 refactor: Inline batched_updater into send_read.
The only remaining caller for batched_updater was send_read,
so this commit inlines it and removes code paths that are
no longer relevant.
2017-12-26 09:01:21 -05:00
Steve Howell
7a362861d0 frontend: Simplify saving collapsed/uncollapsed flags.
We now make direct calls to `send_flags_update` for
seting collapsed/uncollapsed, rather than going through
the `batched_updaters` mechanism.

Also the methods in `message_flags` to set
collapsed/uncollapsed now take a single message.
2017-12-26 09:01:21 -05:00
Steve Howell
d52552dcc3 Simplify/unify starring messages from the frontend.
We now do all of the main logic for starring/unstarring
a message in `message_flags.toggle_starred`:

    * mark the message as read (just in case)
    * update the UI (i.e. the green star in the message)
    * update the server

The calling code in both the click handler and the hotkey
handler remains simple--they just handle minor details like
finding the message and clearing popovers.

For updating the server, we now call the new
`send_flag_update` helper.

And we continue to delegate some of the logic to
`ui.update_starred`, but we remove some code there that's
now pushed up to `message_flags.toggle_starred`.

This change should be mostly transparent to users, but it
does remove some inconsistent behaviors between the click
handler and the hotkey handler.  Before this change, the
click handler was more aggressive about updating the UI
and marking the message as read.  For people using the "*"
key to star/unstar, they probably would only have noticed
different behavior on a slow connection or in an edge
case scenario where only half of the message was onscreen.

More importantly, by simplifying how we talk to the server,
this eliminated up to a one-second lag due to the debounce
logic in the batch_updater code.  The complicated debounce
logic is only really needed for batch-updating "read"
messages, and it was overkill and sluggish for starring
messages.

Last but not least, we add defensive code for the local
echo case.  (Users have to wait till the message gets acked
to star it.)
2017-12-26 09:01:21 -05:00
Steve Howell
d5d11ff181 Disable message menu for locally echoed messages.
Wait until the server acks a message before we enable
the message popover menu.  This prevents a whole class
of bugs related to re-drawing the message and changing
the message id, and it also makes room for a little
spinner in the future.

Users with decent internet connections will generally
get server responses before they can click on the
chevron or hit esc/i, anyway.
2017-12-26 09:01:21 -05:00
Steve Howell
94da59ff81 local echo: Don't show collapse/uncollapse items.
Trying to collapse a locally echoed message is a rare
thing to do, and it was buggy before this due to races
between the server acking the original message and the
user flipping the collapsed flag.

We now calculate `should_display_collapse` and
`should_display_uncollapse` in the JS code and simplify
the template by eliminating all the inline if/else
logic.

(Note that we are about to disable the message menu
altogether for locally echoed messages, so this change
is partly future-proofing for when we put the menu
back for more innocuous commands.)
2017-12-26 09:01:21 -05:00
derAnfaenger
f84a49cee6 bot settings: Fetch embedded bots list from page_params. 2017-12-26 08:50:00 -05:00
Abhijeet Kaur
28b0ebd739 Embedded bots: Add UI for adding embedded bots.
Adds type "embedded bot" to bot creation menu. Lets
users select a bot to run from a list of bots.
Currently, this list is hard-coded into the backend.
2017-12-26 08:50:00 -05:00
derAnfaenger
94c8e8b8e7 embedded bots: Strip @-mention from message.
This is in order to comply with the most recent
code in the `zulip_bots` package.
2017-12-26 08:50:00 -05:00
Xavier Cooney
f66f04f83a mypy: Use Python 3 type syntax in 'bitbucket/tests.py'. 2017-12-26 08:34:38 -05:00
Xavier Cooney
63142385ca mypy: Use Python 3 type syntax in 'send_password_reset_email.py'. 2017-12-26 08:34:38 -05:00
Xavier Cooney
34aee15d63 mypy: Use Python 3 type syntax in 'gitlab/view.py'. 2017-12-26 08:34:38 -05:00
Xavier Cooney
36b58ff6fc mypy: Use Python 3 type syntax in 'views/users.py'. 2017-12-26 08:34:38 -05:00
Xavier Cooney
78042d7f18 mypy: Use Python 3 type syntax in 'webhooks/gogs/tests.py'. 2017-12-26 08:34:38 -05:00
nyan-salmon
51be0e5e76 mypy: Use Python 3 type syntax in zerver/webhooks/solano/view.py. 2017-12-26 08:34:06 -05:00
nyan-salmon
0fd0332a2c mypy: Use Python 3 type syntax in zerver/views/custom_profile_fields.py. 2017-12-26 08:34:06 -05:00
nyan-salmon
613856c33b mypy: Use Python 3 type syntax in zerver/lib/send_email.py. 2017-12-26 08:34:06 -05:00
nyan-salmon
4f4d689f86 mypy: Use Python 3 type syntax in zerver/webhooks/splunk/view.py. 2017-12-26 08:34:06 -05:00
nyan-salmon
6c5f66c561 mypy: Use Python 3 type syntax in zerver/webhooks/slack/view.py. 2017-12-26 08:34:06 -05:00
Viraat Chandra
de3eb89d5c mypy: Use Python 3 syntax for typing in zerver/lib/request.py. 2017-12-26 08:31:43 -05:00
Viraat Chandra
bbf24ec68e mypy: Use Python 3 syntax for typing in zerver/lib/webhooks/git.py. 2017-12-26 08:31:43 -05:00
Viraat Chandra
553711e671 mypy: Use Python 3 syntax for typing in zerver/tests/test_home.py. 2017-12-26 08:31:43 -05:00
Viraat Chandra
0494902e6d mypy: Use Python 3 syntax for typing in zerver/views/auth.py. 2017-12-26 08:31:43 -05:00
Viraat Chandra
65337603b6 mypy: Use Python 3 syntax for typing in zilencer/views.py. 2017-12-26 08:31:43 -05:00
fredfishgames
55801d2feb mypy: Use Python 3 type syntax in zerver/tornado/event_queue.py. 2017-12-26 08:31:09 -05:00
fredfishgames
ccc3d69f61 mypy: Use Python 3 type syntax in zerver/webhooks/bitbucket2/tests.py. 2017-12-26 08:31:09 -05:00
greysome
6bcc01bfee mypy: Use Python 3 type syntax in zerver/webhooks/bitbucket/view.py 2017-12-26 08:30:33 -05:00
greysome
f2f9efd1a7 mypy: Use Python 3 type syntax in zerver/lib/integrations.py 2017-12-26 08:30:33 -05:00
greysome
fb7ee942c4 mypy: Use Python 3 type syntax in zerver/lib/export.py 2017-12-26 08:30:33 -05:00
greysome
da9c808db4 mypy: Use Python 3 type syntax in zerver/webhooks/transifex/view.py 2017-12-26 08:30:33 -05:00
greysome
64ce353d4b mypy: Use Python 3 type syntax in zerver/webhooks/circleci/view.py 2017-12-26 08:30:33 -05:00
greysome
bbe2d91d31 mypy: Use Python 3 type syntax in zerver/forms.py 2017-12-26 08:30:33 -05:00
Xavier Cooney
06b462ba19 mypy: Use Python 3 type syntax in tests/test_auth_backends.py. 2017-12-26 08:29:30 -05:00
Xavier Cooney
61704dc20b mypy: Use Python 3 type syntax in views/pointer.py. 2017-12-26 08:29:30 -05:00
Xavier Cooney
5b2819645e mypy: Use Python 3 type syntax in decorator.py. 2017-12-26 08:29:30 -05:00
cPhost
0966f4737b node tests: Cover stream_data.get_newbie_stream. 2017-12-23 07:32:18 -05:00
Rishi Gupta
e62d9742aa emails: Fix notify_new_login emails have unserializable context.
Regression introduced in e0f30d0 (PR #7569).
2017-12-22 16:34:18 -05:00
Vishnu Ks
c2847669b1 reactions: Implement local echo functionality.
Fixes #4291
2017-12-22 15:15:29 -05:00
Steve Howell
c33102f692 Fix mypy error in AdminNotifyHandler.emit(). 2017-12-22 15:02:18 -05:00
Greg Price
ac6f3373b6 errors tests: Deduplicate and isolate the magical part.
This makes the tests look a lot more boring and straightforward, in
addition to being a bit shorter.
2017-12-22 11:52:13 -05:00
Greg Price
de5c944980 errors tests: De-indent a bunch of code.
This diff is nothing but dedentation -- it's empty under
`git diff -b`.  These with-statements are only needed for
a pretty narrow scope of code, so make that clear in the
source.
2017-12-22 11:52:13 -05:00
Greg Price
ca5c991994 errors: Simplify manual testing of error emails.
There are two different things you need to patch in order to get error
emails (at `/emails`) in dev.  Flip one of them in dev all the time,
and make the comment on the other a bit more explicit.
2017-12-22 11:52:13 -05:00
Greg Price
a34c01780f errors: Compute deployment metadata on the right deployment.
When I added this "Deployed code" feature to the error reporting,
I apparently hadn't worked out enough of how this code works to
realize that `notify_server_error` may be in a different process,
at a different time and potentially even on a different machine
from the actual error being reported.

Given that architecture, all the data about the error must be computed
in `AdminNotifyHandler`, before sending the report through the queue,
or else it risks being wrong.  The job of `notify_server_error` and
friends is only to format the data and send it off.  So, move the
implementation of this feature in order to do that.

(@showell added some "nocoverage" directives here for code that
is hard to test (exceptions being thrown, deployment files not
existing) and that was originally part of a file that didn't
require 100% coverage)
2017-12-22 11:52:13 -05:00
Greg Price
eea1ceb0db errors: Show what logger and source code the message comes from. 2017-12-22 11:52:13 -05:00
Greg Price
77e47900dd errors: Stop showing a long list of Nones when there's no request.
This had contributed to making the emails look broken and of uncertain
accuracy.
2017-12-22 11:52:13 -05:00
Greg Price
68fa29c3ec errors: Make Zulip and email paths more parallel.
This helps prevent them from diverging and getting different sets of
features and fixes.  As a bonus, the email path gets a nice tweak that
the Zulip path has had for years, since f7f2ec0ac, which makes the
emails clearer and less broken-looking when logging a message with no
stack trace.
2017-12-22 11:52:13 -05:00
Greg Price
8c0fd5beaf errors: Clean up the logic slightly.
This deduplicates a little bit of logic, and also has us always put
things into `report` the same way.

Empirically an exception in this codepath is very rare, so we won't
complicate the code by trying to salvage a lot of partial information
if it happens -- just log the traceback, and try to get a minimal
notification sent of the bare fact this happened.
2017-12-22 11:52:13 -05:00
Greg Price
b15231dfc2 logging: Rename AdminZulipHandler to AdminNotifyHandler.
This name hasn't been right since f7f2ec0ac back in 2013; this handler
sends the log record to a queue, whose consumer will not only maybe
send a Zulip message but definitely send an email.  I found this
pretty confusing when I first worked on this logging code and was
looking for how exception emails got sent; so now that I see exactly
what's actually happening here, fix it.
2017-12-22 11:52:13 -05:00
neiljp (Neil Pilgrim)
73a834990b mypy: Swap order of user initialization in ZulipPasswordResetForm.save.
When running with `--strict-optional`, this helps mypy see what's
going on here.

[Fix changed by greg.]
2017-12-23 01:22:22 +09:00
neiljp (Neil Pilgrim)
7c819f4d90 mypy: Account for Optional variables in addressee.py. 2017-12-23 01:22:22 +09:00
neiljp (Neil Pilgrim)
57e7ec94a0 mypy: Adjust 2 emoji.py functions to allow for strict-optional. 2017-12-23 01:22:22 +09:00
neiljp (Neil Pilgrim)
451af39561 mypy: Correct get*notifications_stream to return Optional[Stream]. 2017-12-23 01:22:22 +09:00
neiljp (Neil Pilgrim)
d01dcbd018 mypy: Amend tos_version parameter of create_user_profile to be Optional.
tos_version is marked as Optional[Text] in UserProfile & is Optional
in other places within zerver/lib/create_user.py
2017-12-23 01:22:22 +09:00
Aastha Gupta
560425929e compose: Notify when drafts are saved.
Fixes #7539
2017-12-22 10:51:55 -05:00
Aastha Gupta
78e8d18ef3 integrations: Rename HUBOT_INTEGRATIONS_LEGACY.
It is now simply called HUBOT_INTEGRATIONS.

Fixes #7402
2017-12-22 10:38:47 -05:00
Angelika Serwa
2f575cca72 Add Dropbox webhook integration.
This is just a basic Dropbox webhook integration. It just
notifies a user when something has changed, it does not
specify what changed. Doing so would require storing data,
as Dropbox API was created mainly for file managers, not
integrations like this.
Closes #5672
2017-12-22 10:36:21 -05:00
Marco Burstein
096088969d compose: Re-open the compose editor after restoring a draft.
Fix #5951.
2017-12-22 08:57:39 -05:00
Marco Burstein
6fc50fa21a mypy: Use Python 3 type syntax in zerver/webhooks/sentry/view.py. 2017-12-22 08:17:00 -05:00
Marco Burstein
34001081c2 mypy: Use Python 3 type syntax in zerver/webhooks/yo/view.py. 2017-12-22 08:17:00 -05:00
Marco Burstein
678b43494b mypy: Use Python 3 type syntax in zerver/webhooks/airbrake/view.py. 2017-12-22 08:17:00 -05:00
Marco Burstein
9327048f6f mypy: Use Python 3 type syntax in zerver/lib/events.py. 2017-12-22 08:17:00 -05:00
Marco Burstein
2acf3cf1d4 mypy: Use Python 3 type syntax in zerver/webhooks/mention/view.py. 2017-12-22 08:17:00 -05:00
Marco Burstein
017476cdfb mypy: Use Python 3 type syntax in zerver/lib/create_user.py. 2017-12-22 08:17:00 -05:00
Marco Burstein
e7f0139f69 mypy: Use Python 3 type syntax in zerver/webhooks/travis/view.py. 2017-12-22 08:17:00 -05:00
Tommy Ip
9ea7b05cfe bugdown: Rewrite markdown link to relative link conditionally. 2017-12-22 08:10:42 -05:00
Tommy Ip
efe2d497f4 bugdown: Avoid matching uri with regex. 2017-12-22 08:10:42 -05:00
Tommy Ip
9ce797d68c bugdown: Extract rewrite_if_relative_link function. 2017-12-22 08:10:42 -05:00
Steve Howell
8bb230f3d5 Increase code coverage threshold to 0.07.
We are getting lots of coverage failures in builds recently
that seem to be red herrings, and this is just a quick fix.
2017-12-21 17:14:22 -05:00
Umair Khan
898acc4278 missed-message-worker: Send email through email_senders.
We have shifted to a generic queue to send all the emails. This queue
can retry in case of network issues; this makes sure that the emails are
always sent.
2017-12-20 19:36:27 -08:00
Umair Khan
e0f30d02f2 email-worker: Send login email through queue.
Fixes #7460
2017-12-20 19:36:27 -08:00
Umair Khan
68513952fb email-worker: Create EmailSendingWorker.
This commit just copies all the code from MissedMessageSendingWorker
class to a new EmailSendingWorker class. All the logic to send an email
through a queue was already there. This commit only makes the logic
generic. It does so by creating a special purpose queue called
'email_senders' to send any type of email. To make
MissedMessageSendingWorker still work we derive it from
EmailSendingWorker. All the tests that were testing
MissedMessageSendingWorker now run against EmailSendingWorker.
2017-12-20 19:36:27 -08:00
Vishnu Ks
f743eeb1eb circleci: Set up locale en_US.UTF-8.
See comment for motivation and what's known.

[greg: Added comment, summarizing Vishnu's results from testing.]
2017-12-20 19:18:29 -08:00
Jeremy Zhou
48163db479 docs: Update Windows installation instructions in setup-vagrant.md.
Vagrant 1.8.6 is only compatible with VirtualBox <= 5.1, so I made a
note to use version < 5.2.
2017-12-20 19:16:25 -08:00
Vishnu Ks
16d8244c0a tests: Eliminate 'Sending invitation' output spam in test_signup.
Fixes #7563
2017-12-20 18:50:01 -08:00
neiljp (Neil Pilgrim)
25d5a2ee1c requirements: Upgrade mypy to 0.560.
Fixes #7835.
2017-12-20 18:09:36 -08:00
Greg Price
d4f0c4dffc docs: Restore Docker links, updated.
Previous versions of these links were removed earlier today because
Docker upstream had broken them.

To see what the links had been intended to point to, I used the
Wayback Machine (web.archive.org/web), the super-handy project of the
Internet Archive.  These are the current equivalents.
2017-12-20 11:16:50 -08:00
Steve Howell
70681628ca docs: Remove broken Docker links. 2017-12-20 09:24:43 -05:00
Brock Whittaker
8ea39d2609 input-pill: Wrap "values" in IIFE.
The function should execute initially and return a function, not
be a function that when executed returns another function. This
fixes an existing bug.
2017-12-20 08:53:27 -05:00
Brock Whittaker
511f2f3db4 input-pill: Add "onPillRemove" callback.
This will now allow a callback to be triggered when a pill is
removed from the set.
2017-12-20 08:53:27 -05:00
Rishi Gupta
c2a41c268f models: Update Realm.get_admin_users to not use select_related().
None of the uses of this function in the codebase follow any of the foreign
keys of UserProfile.
2017-12-20 08:51:58 -05:00
Marco Burstein
e9d7161418 compose: Warn users when posting to the #announce stream.
Currently, users are warned when mentioning @all and @everyone, but not
when posting on the #announce stream. Confirm with users that they want
to send their message on #announce if over 60 people are going to be
notified.

Fixes #6928.
2017-12-20 07:36:50 -05:00
snlkapil
1589c597d2 settings: Show local time instead of UTC in invitations tab. 2017-12-20 07:08:46 -05:00
Rishi Gupta
27a8ef86e4 actions: Add realm deactivation and reactivation to RealmAuditLog. 2017-12-19 17:46:36 -08:00
Rishi Gupta
cce8d0d721 invite: Update text of success message.
We should move to a design that doesn't require so many success messages,
since each one carries translation risk (e.g. what if the translation is too
long/overflows, or is not a clear translation, etc.). But doing a quick fix
until then.
2017-12-19 17:46:36 -08:00
Rishi Gupta
4261307e27 emails: Clear ScheduledEmail emails on realm deactivation.
This only affects the invitation reminder emails; clear_scheduled_emails was
already clearing the other two types.
2017-12-19 17:46:36 -08:00
Rishi Gupta
869b4d41ef models: Add ScheduledEmail.realm.
The two extra queries in the test are due to the assert in
send_future_email.
2017-12-19 17:46:36 -08:00
Rishi Gupta
cc08becb2c portico: Update FAQ on /plans. 2017-12-19 15:36:13 -08:00
Rishi Gupta
87e164043f portico: Rename plans at /plans. 2017-12-19 15:36:13 -08:00
ViRu-ThE-ViRuS
c8aadaa408 integrations: Add webhook payloads for Intercom. 2017-12-19 16:50:06 -05:00
Greg Price
eb650306eb circleci: Disable gitlint for now.
We get the following error (edited slightly):

  Dec 19 06:13:27 commit_messages| An error occurred while executing
    '/usr/bin/git rev-list --max-count=-1 upstream/master..HEAD':
  fatal: ambiguous argument 'upstream/master..HEAD':
    unknown revision or path not in the working tree.
  Use '--' to separate paths from revisions, like this:
  'git <command> [<revision>...] -- [<file>...]'

We'll need to adjust the remotes to make `upstream` mean what we expect.
2017-12-18 22:21:49 -08:00
Greg Price
e5c6c446b5 travis + circleci: Start postgresql during provision.
Otherwise, in CircleCI it isn't running when we need it later.
Travis must special-case starting it automatically.
2017-12-18 22:05:27 -08:00
Greg Price
c83c118c6c circleci: Crudely clone a bit of is_travis logic.
This isn't really the right way to do this -- commit
  dcd80e665 "travis/setup-backend: Remove the '--travis' flag"
took us in the wrong direction by introducing more magic, deeper in
the stack.

But it's the same way we do it for Travis.  For now, just copy that.

[Thanks to hackerkid for cleaning up my original crude hack.]
2017-12-18 22:04:39 -08:00
Greg Price
e8bf7d23bf provision: Remove transitional Python 2->3 logic in setup_venvs.
At this point if we were accidentally using `/srv/zulip-venv` for
anything, we'd have run into it by now.  So just drop the bit of
historical logic that we had to ensure that.
2017-12-18 21:59:51 -08:00
Greg Price
3ba0d5659f travis: Don't create nagios state.
As the comment says, we don't seem to use this.  And the Travis builds
work fine without it.
2017-12-18 21:43:07 -08:00
Greg Price
9ce080ebb1 circleci: Remove Circle-created gitconfig file.
[Investigation by hackerkid.]
2017-12-18 21:42:00 -08:00
Greg Price
e34852acf6 package.json: Move difflib to devDependencies.
We introduced this a couple of commits ago (in #7782) for use in the
tests only.  Putting it here avoids pulling in a new dependency in
production which we don't use there.
2017-12-18 19:09:03 -08:00
Eeshan Garg
8936d03f3a webhooks/gitlab: Support Merge Request Hook approved event type.
Such payloads are generated when a GitLab repository has merge
request approvals enabled and a project member approves a merge
request. Approving is not the same as merging.
2017-12-18 19:12:54 -05:00
Andy Perez
44e6d9b54b testing: Add nice diffs to markdown python tests. 2017-12-18 19:03:38 -05:00
Andy Perez
fc2298ec54 node tests: Add nice diffs to js markdown tests.
Fix #3915
2017-12-18 19:03:38 -05:00
Andy Perez
695affd44e node tests: Compare markdown using semantic equivalence.
Fix #4367
2017-12-18 19:03:38 -05:00
Greg Price
776af2e248 push notifs: Simplify content-truncation code slightly.
This should be a pure refactor.
2017-12-18 15:32:56 -08:00
Greg Price
014900c2e5 push notifs: Include same stream and sender info on GCM as on APNs.
This takes the information added to APNs payloads by #7080, and adds
to our GCM payloads the parts that it didn't already have.
2017-12-18 15:32:56 -08:00
Greg Price
e077d6fc74 push notifs: Factor out common payload fields for APNs and GCM.
This should be a pure refactor, producing exactly the same payloads.
2017-12-18 15:32:56 -08:00
Eeshan Garg
21008a49b9 webhooks/gci: Support approve-pending-pc event type.
This event is generated when a mentor approves a task but
GCI is still waiting on a student's parental consent.
2017-12-18 10:00:20 -08:00
Callum Fraser
a61a7f3965 mypy: Use Python 3 type syntax in zerver/webhooks/pingdom/view.py. 2017-12-18 11:32:52 -05:00
Callum Fraser
4508264f25 mypy: Use Python 3 type syntax in zerver/webhooks/opsgenie/view.py. 2017-12-18 11:32:52 -05:00
Callum Fraser
52f0c4472e mypy: Use Python 3 type syntax in zerver/webhooks/ifttt/view.py. 2017-12-18 11:32:52 -05:00
Callum Fraser
23b29212a3 mypy: Use Python 3 type syntax in zerver/webhooks/greenhouse/view.py. 2017-12-18 11:32:52 -05:00
Callum Fraser
403ea486e4 mypy: Use Python 3 type syntax in zerver/webhooks/gogs/view.py. 2017-12-18 11:32:52 -05:00
Callum Fraser
33e1879295 mypy: Use Python 3 type syntax in zerver/webhooks/beanstalk/view.py. 2017-12-18 11:32:52 -05:00
Callum Fraser
c55685063f mypy: Use Python 3 type syntax in zerver/webhooks/appfollow/view.py. 2017-12-18 11:32:52 -05:00
Callum Fraser
b0c5eb5482 mypy: Use Python 3 type syntax in zerver/views/typing.py. 2017-12-18 11:32:52 -05:00
Callum Fraser
0438da5c16 mypy: Use Python 3 type syntax in zerver/lib/avatar.py. 2017-12-18 11:32:52 -05:00
Utkarsh Patil
c2441e4455 user settings: Clean settings.css and fix bug
Clean up settings.css and fix js bug in attachments_ui.js
2017-12-18 10:12:33 -05:00
Utkarsh Patil
c9596e12be user settings: fix uploaded files UI
Fix UI and date uploaded
2017-12-18 10:12:33 -05:00
Utkarsh Patil
b3d7a87552 user settings: Change file size display format
Display 1MB for 1000KB and display atleast 2 sig digits from 'KB' onwards
2017-12-18 10:12:33 -05:00
Utkarsh Patil
25f742839d user settings: change 'Date uploaded' display format
Display 'Today' or 'Yesterday' and the date for days beyond those
2017-12-18 10:12:33 -05:00
Utkarsh Patil
0b710e41c9 user settings: fix 'Uploaded files' UI
Align table header and its corresponding table data
2017-12-18 10:12:33 -05:00
civilnewsnetwork
0ce8b69fd6 Renamed 'Register' to 'Sign up' including translations 2017-12-18 10:02:15 -05:00
cPhost
3dc315a0a1 node tests: Add 100% coverage for narrow_state.js. 2017-12-18 09:57:43 -05:00
Tommy Ip
16e03b644d linter: Update commit title regex to match uppercase for the first letter. 2017-12-18 09:36:47 -05:00
Tommy Ip
7243a91e47 linter: Re-enable gitlint. 2017-12-18 09:36:47 -05:00
Alena Volkova
3cfb2d57b2 tests: Refactor the method for encoding credentials. 2017-12-18 09:24:09 -05:00
Alena Volkova
39915d9835 tests: Replace all get_auth usages with auth methods and delete it. 2017-12-18 09:24:09 -05:00
Alena Volkova
90aa6c627e tests: Replace api_auth usages with auth methods in zerver/webhooks. 2017-12-18 09:24:09 -05:00
Alena Volkova
26eb23afc7 tests: Replace api_auth usages with auth methods in zerver/tests. 2017-12-18 09:24:09 -05:00
Alena Volkova
4a303d1778 tests: Add auth methods that will replace passing credentials. 2017-12-18 09:24:09 -05:00
cPhost
7f4e57ddff node tests: Cover stream_data.initialize_from_page_params. 2017-12-18 09:19:05 -05:00
neiljp (Neil Pilgrim)
2fc0272a5d Editing (minor): Add .pyi to .editorconfig. 2017-12-18 07:35:58 -05:00
itstakenalr
90c71f3ca6 docs: Update request-remote.md.
Change (zulip-venv) to (zulip-py3-venv)
2017-12-16 01:10:26 -08:00
Shreyansh Dwivedi
5b49259722 compose box:Add a reply button. Fixes #5578 2017-12-15 14:23:24 -05:00
Rishi Gupta
5a235bcfc5 portico: Make minor updates to for/mystery-hunt. 2017-12-15 09:39:24 -08:00
Sivagiri
3792bd2d69 integrations: Add webhook payloads for Groove. 2017-12-14 18:54:22 -05:00
Brock Whittaker
bfda5bbf2b streams: Make stream settings inputs responsive to narrow screens.
This makes the inputs and buttons responsive to narrow screens by
gracefully resizing and falling in place.

Fixes: #7712.
2017-12-14 17:47:54 -05:00
Xavier Cooney
bb54aab7c0 Change sidebar headings in API docs to not have pointer cursor.
Previosly, a pointer cursor would display when hovering over some of the
headings in the API docs, however nothing would happen when clicked.

Fixes #7702.
2017-12-14 07:51:48 -05:00
Andy Perez
f0190333b8 bugdown: Remove whitespace strip from inline code.
Fixes #4507
2017-12-14 07:48:10 -05:00
YJDave
99e62f80b9 portico: Enhanced password warning 2017-12-14 07:16:56 -05:00
Steve Howell
7b8cc396b5 bot docs: Simplify docs on writing bot tests.
These changes catch up to some recent improvements in the
test system, plus I eliminate some unnecessary sections.
2017-12-14 07:07:18 -05:00
Umair Khan
07961611b2 test_create_update_and_remove_default_stream_group: Fix flake. 2017-12-14 05:35:54 -05:00
Umair Khan
b98c5c6d45 test_multi_user_subscription: Fix flake. 2017-12-14 05:35:54 -05:00
YJDave
e4bf3d6907 api: Fix typo in interactive bots doc. 2017-12-14 00:53:23 -08:00
Brock Whittaker
a05631d8c6 night-mode: Add experimental text.
This adds "(experimental)" after the night mode text in the
checkbox line so that people know it is not a fully stable
feature.
2017-12-13 17:27:49 -08:00
pradeepgangwar
445ece4a3c Fix 'v' hotkey image searching behavior.
Fixes #7621
2017-12-13 15:14:18 -06:00
Vishnu Ks
bc37317914 invites: Differentiate users invited as admin by showing bolt icon. 2017-12-13 15:12:21 -06:00
Utkarsh Patil
10149b75cc stats: Add per-graph loading indicator
This commit ensures that size of each graph is the same before and
after the data is loaded. It also adds a loading indicator to each
graph until the data is loaded.

Fixes https://github.com/zulip/zulip/issues/6490
2017-12-13 14:44:28 -06:00
Aastha Gupta
1df3e04cd7 bot settings: Clear typeahead when renaming a bot
Fixes #7534
When bot is renamed, the old name persists in mention typehead.
This commit clears the typeahead, whenever bot details are modified.
2017-12-13 14:39:53 -06:00
Brock Whittaker
20f3b0f599 popovers: Apply email overflow changes to ".message-info-popover".
This applies the same overflow changes to “.message-info-popover” by
imposing a max width on the popover (so it doesn’t increase in width
when it gets larger) and adding the tooltip on hover.
2017-12-13 14:20:18 -06:00
cPhost
97c3d5fce3 user profiles: add tooltip for too long email. 2017-12-13 14:20:18 -06:00
Balaji2198
c54c40eecd refactor: Remove obsolete .sidebar-nav. 2017-12-13 14:17:41 -06:00
Balaji2198
e9ae14c968 refactor: Remove obsolete .position-relative. 2017-12-13 14:17:41 -06:00
Balaji2198
7b91668ef4 refactor: Remove obsolete .messagebox-bottom-colorblock. 2017-12-13 14:17:41 -06:00
Balaji2198
b9c784bd7f refactor: Remove obsolete .messagebox-bottom.
This is an obsolete css class in zulip.css.
2017-12-13 14:17:41 -06:00
Balaji2198
6f7574ce19 refactor: Remove obsolete .message-right.
This is an obsolote css class in zulip.css.
2017-12-13 14:17:41 -06:00
Balaji2198
50517c16d6 refactor: Remove obsolete .message-pane.
This is an obsolete css class in zulip.css.
2017-12-13 14:17:41 -06:00
Balaji2198
38d778501c refactor: Remove obsolete .edit-profile.
This is an obsolete css class in zulip.css.
2017-12-13 14:17:41 -06:00
YJDave
ffe3776b5f create stream: Show current user on top of "People to add" list
Fixes #7475
2017-12-13 14:16:07 -06:00
civilnewsnetwork
76511449f1 Added darken to perfect-scrollbar on scroll 2017-12-13 14:14:59 -06:00
Greg Price
137c0e65bb tools: Revert to Python 2 typing syntax for now.
This reverts commit 66261f1cc.  See parent commit for reason; here,
provision worked but `tools/run-dev.py` would give errors.

We need to figure out a test that reproduces these issues, then make a
version of these changes that keeps that test working, before we
re-merge them.
2017-12-13 10:38:15 -08:00
Greg Price
17a6632c43 zerver/views: Revert to Python 2 typing syntax for now (storage, streams).
This reverts commit 620b2cd6e.

Contributors setting up a new development environment were getting
errors like this:
```
++ dirname tools/do-destroy-rebuild-database
[...]
+ ./manage.py purge_queue --all
Traceback (most recent call last):
[...]
  File "/home/zulipdev/zulip/zproject/legacy_urls.py", line 3, in <module>
    import zerver.views.streams
  File "/home/zulipdev/zulip/zerver/views/streams.py", line 187, in <module>
    method_kwarg_pairs: List[FuncKwargPair]) -> HttpResponse:
  File "/usr/lib/python3.5/typing.py", line 1025, in __getitem__
    tvars = _type_vars(params)
[...]
  File "/usr/lib/python3.5/typing.py", line 277, in _get_type_vars
    for t in types:
TypeError: 'ellipsis' object is not iterable
```

The issue appears to be that we're using the `typing` module from the
3.5 stdlib, rather than the `typing=3.6.2` in our requirements files,
and that doesn't understand the `Callable[..., HttpResponse]` that
appears in the definition of `FuncKwargPair`.

Revert for now to get provision working again; at least one person
reports that reverting this sufficed.  We'll need to do more testing
before putting this change back in.
2017-12-13 10:20:11 -08:00
Greg Price
73a5c39264 docs: Fix link in roadmap.
Caught by tools/test-documentation .
2017-12-12 20:50:36 -08:00
Greg Price
d5fd2a1d72 tools: Fix run-dev.py, which had an if False: on a needed import. 2017-12-12 20:50:00 -08:00
Greg Price
ca09c1e0fd templates: Revert change to Python 3 typing syntax in examples.
This reverts commit 5a1869901.  I reviewed this change and decided not
to merge it yet, but then I did anyway <_< >_>, along with some others
in the same PR.
2017-12-12 17:45:43 -08:00
rht
66261f1cc3 tools: Use Python 3 syntax for typing in many files. 2017-12-12 17:42:57 -08:00
rht
5a1869901d templates: Use Python 3 syntax for typing. 2017-12-12 17:42:54 -08:00
rht
92d62f62e1 zilencer/management: Use Python 3 syntax for typing. 2017-12-12 17:41:12 -08:00
rht
620b2cd6e2 zerver/views: Use Python 3 syntax for typing (storage, streams). 2017-12-12 17:40:50 -08:00
Greg Price
cd5e44491c logging: Drop confusing use of propagate in test_settings.
This line was added in e8ab7cd1a as a desperate measure to get the
`set_loglevel` helper to successfully suppress the `zulip.send_email`
logs.

In fact, the reason that just setting `level` there wasn't doing the
job had nothing to do with `propagate`, which doesn't interact with
`level`.  (See the long block comment in `zproject/settings.py`,
searching for "Python logging module", for my attempt at concisely
explaining these semantics.)  Rather, our setting for `level` was
getting clobbered by the use of `create_logger`; and setting
`propagate` to False worked by completely suppressing all logs to
`zulip.send_email` and descendants from reaching the normal handlers,
regardless of the log messages' levels.

Now that the `create_logger` issue is fixed (see a few commits before
this one), drop that.
2017-12-12 17:17:08 -08:00
Greg Price
b830b446f1 logging: Reduce create_logger to new log_to_file.
The name `create_logger` suggests something much bigger than what this
function actually does -- the logger doesn't any more or less exist
after the function is called than before.  Its one real function is to
send logs to a specific file.

So, pull out that logic to an appropriately-named function just for
it.  We already use `logging.getLogger` in a number of places to
simply get a logger by name, and the old `create_logger` callsites can
do the same.
2017-12-12 17:17:08 -08:00
Greg Price
1c810baaef logging: Stop calling basicConfig in create_logger.
From the docs:

> This function does nothing if the root logger already has handlers
> configured for it.

Which we do if we've started up Django and configured settings, and in
particular allowed Django to process `settings.LOGGING`.

So, cut it out -- all it can do is confuse people about how logging
works.

If we ever actually used the `log_format` parameter, this would be
doubly confused, because only the first call would have any effect.
2017-12-12 17:17:08 -08:00
Greg Price
b6491fd52a logging: Eliminate log_level from create_logger.
Because calls to `create_logger` generally run after settings are
configured, these would override what we have in `settings.LOGGING` --
which in particular defeated any attempt to set log levels in
`test_settings.py`.  Move all of these settings to the same place in
`settings.py`, so they can be overridden in a uniform way.
2017-12-12 17:17:08 -08:00
Greg Price
ebcf0b4876 logging: Stop having create_logger force loglevels to INFO.
This is already the loglevel we set on the root logger, so this has no
effect -- except in tests, where `test_settings.py` attempts to set
some of these same loggers to higher loglevels.  Because the
`create_logger` call generally runs after we've configured settings,
it clobbers that effect.

The code in `test_settings.py` that tries to suppress logs only works
because it also sets `propagate=False`, which has nothing to do with
loglevels but does cause logs at this logger (and descendants) to be
dropped completely unless we've configured handlers for this logger
(or one of its relevant descendants.)
2017-12-12 17:17:07 -08:00
Weronika Grzybowska
b54f78968f markdown: Add automatic numbering of ordered lists.
Adds a markdown preprocessor that finds ordered lists where all items
use the same number and change them to be in normal increasing order,
starting with that number.

Fixes #5159.
2017-12-12 18:35:38 -06:00
Greg Price
20b2c11830 activity: Show the time the data is from.
I've wanted this when looking at a tab from the day before.
Also provides the date and time in UTC, which is handy for
interpreting some of the data.

Pretty sure this is not the world's cleanest way to do this in the
front-end code.  It'll do for now.
2017-12-12 15:30:03 -08:00
Greg Price
bdea0960de activity: Supply a missing field.
In prod this has no effect, but in dev we render a warning here,
which makes the table not look right.  Fix it.
2017-12-12 15:30:03 -08:00
Greg Price
1e1f381270 activity: Explain highlighting of young realms. 2017-12-12 15:30:03 -08:00
Greg Price
e6cdc55ab5 activity: Use real ≥ signs, not ">=".
Not only does this look better, but in the parallel case of ≤
(coming soon) it prevents a naive parser, like in our linter,
from getting confused by seeing a "<" character.
2017-12-12 15:30:03 -08:00
Greg Price
d36b1cd2d7 activity: Correct description of message-history figures.
This explains why the first number was usually the smallest!
2017-12-12 15:30:03 -08:00
Nikhil Kumar Mishra
799bf58463 bot docs: Change zulip-bot-output to zulip-terminal.
Fixes #7734 .
2017-12-12 16:43:23 -06:00
Greg Price
4e0146782b travis: Try returning to the just-deprecated base image for now.
We're getting a couple of different spurious failures.  Until
we fix them, stop breaking.

See https://blog.travis-ci.com/2017-12-12-new-trusty-images-q4-launch .
2017-12-12 14:40:22 -08:00
Steve Howell
0975bebacc quick fix: Fix migrations to be linear.
I merged a "good" but stale build, and the migrations
were out of order.  This fixes them.
2017-12-12 11:31:07 -06:00
Rhea Parekh
acebd3a5e9 migrations: Replace special chars in stream & user names with space.
Also handle potential duplicate stream names created.
Fixes #6534
2017-12-12 10:04:31 -06:00
Rhea Parekh
d30fb5a341 UserProfile: Disallow markdown character in the user profile name. 2017-12-12 10:04:31 -06:00
Rhea Parekh
dd1b14378b Streams: Disallow certain markdown characters in stream names. 2017-12-12 10:04:31 -06:00
Rhea Parekh
8ed7f73199 IRC mirror: No longer require IRC stream names to start with #. 2017-12-12 10:04:31 -06:00
ryan
08b39672c2 invitations: remove reformatting on error
This removes email input reformatting when invites are not sent.

Fixes #7581.
2017-12-12 09:58:34 -06:00
Utkarsh Patil
1093d88fa0 hotkey.js: Navigate using page up / page down
Using page up / page down, go to the top / bottom of compose textarea

Fixes https://github.com/zulip/zulip/issues/7097
2017-12-12 09:55:50 -06:00
Cynthia Lin
240511c2d7 dark-mode: Compact common background-color declarations. 2017-12-12 09:11:34 -06:00
Cynthia Lin
86f87bcb3f dark-mode: Change hex color codes to HSL. 2017-12-12 09:11:34 -06:00
Cynthia Lin
45d0b2bb47 dark-mode: Fix background colors of modals and sidebars in mobile view.
Fixes #7623.
2017-12-12 09:11:34 -06:00
Greg Price
10fc40a3f1 dev_settings: Remove accidentally-pushed OAuth app IDs.
These aren't of much use without the corresponding secrets (despite us
calling one of them a "key", both are public IDs), which are in my
personal dev-secrets.conf.  So, remove them.

I had this commit applied in order to test what became 90944983f...
and then I accidentally included it in what I pushed, as 0fa9a489d.
Oops.
2017-12-11 21:06:35 -08:00
Greg Price
8a432c5134 APNs: Update comment on versions of our APNs payload format. 2017-12-11 20:55:20 -08:00
kunall17
98943a8333 Include data of stream/private sender details in apns push notifications 2017-12-11 20:51:09 -08:00
Rishi Gupta
b7779667fc models: Set UserProfile.MIN_NAME_LENGTH to two.
Chinese names are often two characters.
2017-12-11 20:35:12 -08:00
Xavier Cooney
ebc7c72d99 mypy: Use Python 3 type syntax in wordpress/view.py 2017-12-11 20:33:00 -08:00
Xavier Cooney
2db270be4b mypy: Use Python 3 type syntax in crashlytics/view.py 2017-12-11 20:33:00 -08:00
Xavier Cooney
1fa5233923 mypy: Use Python 3 type syntax in gitlab/tests.py 2017-12-11 20:33:00 -08:00
Xavier Cooney
cc427911fa mypy: Use Python 3 type syntax in stripe/view.py 2017-12-11 20:33:00 -08:00
Xavier Cooney
7887857c81 mypy: Use Python 3 type syntax in user_settings.py 2017-12-11 20:33:00 -08:00
picapi_
85ae723c9f mypy: Use Python 3 type syntax in zerver/lib/soft_deactivation.py. 2017-12-11 20:30:19 -08:00
picapi_
2adeaab6ab mypy: Use Python 3 type syntax in zerver/views/invite.py. 2017-12-11 20:30:19 -08:00
picapi_
f07d39353a mypy: Use Python 3 type syntax in zerver/webhooks/basecamp/view.py. 2017-12-11 20:27:55 -08:00
picapi_
d038e7ea6b mypy: Use Python 3 type syntax in zerver/webhooks/bitbucket2/view.py. 2017-12-11 20:27:55 -08:00
picapi_
20c2e53de4 mypy: Use Python 3 type syntax in zerver/webhooks/jira/view.py. 2017-12-11 20:27:55 -08:00
picapi_
15fb392dd1 mypy: Use Python 3 type syntax in zerver/webhooks/papertrail/view.py. 2017-12-11 20:27:55 -08:00
picapi_
3fb9803398 mypy: Use Python 3 type syntax in zerver/webhooks/teamcity/view.py. 2017-12-11 20:27:55 -08:00
Greg Price
0fa9a489d5 wip test oauth 2017-12-11 20:03:52 -08:00
Vishnu Ks
90944983f5 signup: Redirect to /register instead of sending mail when user has no account.
When a user with no account tries to login using GitHub/Google auth
they are given an option to register.  If the user chooses to
register, a mail is sent for verification and the user has to continue
registration as if they signed up using email.  This is confusing and
a bit annoying, so instead of sending email I have changed the
procedure to just redirect to /register where they can start
registration over and proceed normally.

An ideal implementation for this would be to just allow users to
continue registration without email or going back to register.

[greg: tweaked to keep existing user-facing text]
2017-12-11 20:03:52 -08:00
Greg Price
e9a7173119 actions: Cut some redundant types in docstrings.
We have a better way of writing types now!

Also move a comment that should have been a docstring,
to being a docstring.
2017-12-11 19:29:11 -08:00
Shreyansh Dwivedi
47fcb27e39 invitations: Remove custom_body.
Fixes #7672
2017-12-11 19:23:54 -08:00
Callum Fraser
00178d114b mypy: Use Python 3 type syntax in zerver/views/streams.py.
[greg: small formatting tweaks]
2017-12-11 18:43:24 -08:00
Callum Fraser
aa9567ce37 mypy: Use Python 3 type syntax in zerver/middleware.py. 2017-12-11 18:43:24 -08:00
Rishi Gupta
d9ce33dcf0 registration: Clarify realm_creation conditionals in accounts_register.
No change in behavior.
2017-12-11 18:36:14 -08:00
Rishi Gupta
e545a681fc registration: Use standard pattern for returning link_does_not_exist.
Eventually this check for the realm will be done in get_object_from_key
itself. Rewriting this to fit the pattern in get_object_from_key.

No change to behavior.
2017-12-11 18:36:14 -08:00
Rishi Gupta
dbe3576706 registration: Enforce realm is None only if realm_creation.
Commit d4ee3023 and its parent have the history behind this code.

Since d4ee3023^, all new PreregistrationUser objects, except those for
realm creation, have a non-None `realm`.  Since d4ee3023, any legacy
PreregistrationUsers, with a `realm` of None despite not being for
realm creation, are treated as expired.  Now, we ignore them
completely, and remove any that exist from the database.

The user-visible effect is to change the error message for
registration (or invitation) links created before d4ee3023^ to be
"link does not exist", rather than "link expired".

This change will at most affect users upgrading straight from 1.7 or
earlier to 1.8 (rather than from 1.7.1), but I think that's not much
of a concern (such installations are probably long-running
installations, without many live registration or invitation links).

[greg: tweaked commit message]
2017-12-11 18:36:14 -08:00
Cynthia Lin
9682ad4ca9 left sidebar: Add margin to bottom of Streams list.
The last stream name gets covered by a Chrome link hover tooltip, so an extra 20px gets added to the bottom.

Fixes #7654.
2017-12-11 17:33:46 -08:00
Greg Price
ac7d086085 sidebar: Revert to narrowing to whole stream.
This reverts commit eb2bdb706 "sidebar: Narrow to latest topic if
not in stream."  On a trial deploy, many users were surprised and
preferred the old behavior.
2017-12-11 16:35:12 -08:00
Greg Price
d15fcc18cc sidebars: Revert change to more muted colors.
This reverts commit aebf63c28 "sidebars: Change to more muted
hover/active colors."

In addition to the effects described in its commit message, this
commit gave the unread counts in the left sidebar a much lighter
background, making them harder to see.  I'm not quite sure which part
of this change caused that effect how; reverting for now and we
can sort out a new version of the change.
2017-12-11 15:36:59 -08:00
Brock Whittaker
2252d7e5f6 Revert "dark-mode: Add "T" hotkey for dark mode theme."
This reverts commit ce62abce73.

Fixes #7678.
2017-12-11 15:59:02 -06:00
Cynthia Lin
db55fd8e48 Revert "Make dark theme toggle only run in dev mode."
This reverts commit 59870b2203.
2017-12-11 15:59:02 -06:00
Ivche1337
1d202e30d8 integrations: Add webhook payloads for Opbeat. 2017-12-11 15:40:49 -06:00
Rishi Gupta
b8976ae4bd integrations: Improve wording in create-bot-construct-url.md. 2017-12-11 15:39:26 -06:00
Rishi Gupta
4eb3202b13 integrations: Remove weather example from zapier doc.
I don't think it made the page more readable, and doubled the length.
2017-12-11 15:39:26 -06:00
Symt
3706ec7479 linter: Add good/bad lines for CSS and HTML. 2017-12-11 15:37:22 -06:00
Rishi Gupta
48afc55b1b settings: Reword notifications settings strings.
Audible notifications is a confusing term, especially since it could
plausibly mean audible notifications on your phone.

Mobile push notifications is also not great, since most people don't know
what push notifications are.

I removed "receive" from stream settings strings since I think it isn't
necessary, and so that the strings (and translations) would be the same as
what's on the settings pages.
2017-12-11 09:17:31 -08:00
Rishi Gupta
7ae9c2935e org settings: Change wording of restrict to domains setting. 2017-12-11 09:17:31 -08:00
Akash Nimare
54affeac02 desktop: Update desktop app to v1.7.0.
Update desktop app to latest stable release.
2017-12-11 11:14:38 -06:00
Jerry Zhang
14d1902386 node tests: Cover exports.create_sub_from_server_data. 2017-12-11 11:13:55 -06:00
Rishi Gupta
f323d59ec0 org settings: Remove double negative from open realm setting.
The current wording is tricky to wrap one's head around.
2017-12-10 23:15:00 -08:00
Rishi Gupta
7cc8992d1e message feed: Update wording for narrow to non-existent stream. 2017-12-10 22:53:11 -08:00
Shreyansh Dwivedi
4a262713e6 Better errror message for narrow to a nonexistent stream. Fixes #6862 2017-12-10 06:00:14 -08:00
cPhost
63e8248933 node tests: Cover stream_data.canonicalized_name. 2017-12-10 04:20:29 -08:00
cPhost
0b9e678d4d node test: Cover stream_data.render_stream_description. 2017-12-10 04:20:29 -08:00
cPhost
d2a2d0b362 node tests: Cover stream_data.get_subscriber_count. 2017-12-10 04:19:33 -08:00
Steve Howell
36ade63d84 compose: Fix bug in undo operation
This fixes compose.test_video_link_compose_clicked to just
use a stub for compose_ui.insert_syntax_and_focus.

It also adds direct tests for compose_ui.insert_syntax_and_focus.

Fixes #6362
2017-12-10 04:10:18 -08:00
Arseny Chekanov
e5c05f128a mypy: Use Python 3 type syntax in zerver/views/realm_filters.py. 2017-12-09 16:50:12 -08:00
Arseny Chekanov
c2c023f0cf mypy: Use Python 3 type syntax in zerver/tornado/websocket_client.py. 2017-12-09 16:50:12 -08:00
Arseny Chekanov
1f34300006 mypy: Use Python 3 type syntax in zerver/webhooks/trello/tests.py. 2017-12-09 16:50:12 -08:00
Steve Howell
738c73f08e lint: Prevent self: Any annotations.
We should omit these for mypy.  For most class definitions,
mypy doesn't need `Any`, and it provides no real useful info.

For clever monkeypatches, you should provide a more specific
type than `Any`.
2017-12-08 19:00:18 -08:00
Steve Howell
ac48772907 mypy: Improve typing for ManifestStaticFilesStorage monkeypatch. 2017-12-08 19:00:18 -08:00
Steve Howell
f83a73c763 mypy: Use more specific type for _replacement_destroy_test_db. 2017-12-08 19:00:18 -08:00
Steve Howell
78041a5846 mypy: Use more specific type for instrument_url wrapper. 2017-12-08 19:00:18 -08:00
Xavier Cooney
aa37b50d1e mypy: User Python 3 syntax for typing in realm.py. 2017-12-08 18:34:26 -08:00
Xavier Cooney
a6465e8e35 mypy: Use Python 3 syntax in zapier/view.py. 2017-12-08 18:34:26 -08:00
Xavier Cooney
1262d14d39 mypy: Use Python 3 syntax in gci/view.py. 2017-12-08 18:34:26 -08:00
Xavier Cooney
38e65570ae mypy: Use Python 3 syntax for typing in heroku/view.py. 2017-12-08 18:34:26 -08:00
Xavier Cooney
a831acd97f mypy: Use Python 3 type syntax in bugdown/__init__.py. 2017-12-08 18:34:26 -08:00
Xavier Cooney
63e793a8d1 mypy: Use Python 3 syntax for typing in views/tutorial.py. 2017-12-08 18:34:26 -08:00
Cynthia Lin
9bf0c96e9f modals: Make settings page selectors more specific.
The `#settings_page .right.show` selector was breaking the Emoji style inputs in Display settings on mobile responsive view.

Fixes #7624.
2017-12-08 18:22:30 -08:00
Cynthia Lin
799e4adf42 compose: Align Press Enter to send checkbox with label.
Fixes #7604.
2017-12-08 18:21:32 -08:00
Rohitt Vashishtha
eb2bdb706a sidebar: Narrow to latest topic if not in stream.
We now narrow to the latest topic in stream if we are narrowing from
outside the stream, and show all topics grouped together (previous
default) if we are already narrowed to the stream.

Fixes #7555.
2017-12-08 05:53:49 -08:00
Rohitt Vashishtha
6d9273819c tests: Cover new composebox typeahead terminal symbols. 2017-12-08 01:00:38 -08:00
AlloulDorian
39dc41f40b user docs: Add doc for video calls. 2017-12-07 16:57:50 -08:00
cPhost
c6985e2eee eslint: add --cache flag for faster linting 2017-12-07 15:14:51 -08:00
Brock Whittaker
59b0776c53 left-sidebar: Lighten global filter icons.
This lightens them to a half-opaque base text color so they stand out
less than they currently do.
2017-12-07 15:10:07 -08:00
Brock Whittaker
aebf63c288 sidebars: Change to more muted hover/active colors.
The active streams and users should be more muted grey tones than the
greens and blues that they currently are.
2017-12-07 15:10:07 -08:00
Brock Whittaker
60e018e972 sidebars: Add 1px of vertical margin to all <li>.
This makes the list slightly less dense (9%) and ensures that the
borders of hovered items and active items don’t touch each other.
2017-12-07 15:10:07 -08:00
Brock Whittaker
953ee778f3 sidebars: Remove link underlines on hover.
This removes the underlines on the stream names and user names when
hovered over for a cleaner look. This is acceptable due to the fact
that hover is signified already by a light grey background.
2017-12-07 15:10:07 -08:00
cPhost
7504d01066 node tests: Cover stream_data.remove_default_stream. 2017-12-07 15:05:44 -08:00
Jerry Zhang
48ebec3a29 node tests: Cover exports.get_default_status. 2017-12-07 15:02:12 -08:00
Jerry Zhang
e134fd610e node tests: Cover exports.is_for_stream_id. 2017-12-07 14:58:27 -08:00
Jerry Zhang
806e9bb742 node tests: Cover exports.remove_subscriber. 2017-12-07 14:57:15 -08:00
Jerry Zhang
b874693242 node tests: Cover exports.user_is_subscribed. 2017-12-07 14:57:15 -08:00
Vishnu Ks
a30152cb94 models: Use is_cross_realm_bot_email whenever possible.
Fixes #7557
2017-12-07 14:55:06 -08:00
Vishnu Ks
ff43443ac7 models: Create is_cross_realm_bot_email function. 2017-12-07 14:55:06 -08:00
Cynthia Lin
c90faca875 portico: Modify docs sidebar to a light shade of green. 2017-12-07 14:40:17 -08:00
Cynthia Lin
b7fb86b9ea user docs: Modify sidebar and index page styling. 2017-12-07 14:40:17 -08:00
Cynthia Lin
eddf3a722a components: Change cursor to pointer for checkbox labels.
Lets users know that they can toggle the checkbox by clicking the corresponding label.
2017-12-07 14:37:23 -08:00
Cynthia Lin
5f480495f8 invitations: Make stream labels click targets.
Label tags can't be nested in each other.

Fixes #7582.
2017-12-07 14:37:23 -08:00
Vishnu Ks
6e85122724 integrations: Fix broken ifttt link. 2017-12-07 10:28:53 -08:00
Rohitt Vashishtha
9c2a28b6df invitations: Fix lint errors in test_queue_workers. 2017-12-06 22:15:25 -08:00
Rishi Gupta
6787fbd547 invitations: Change rate limiting to use invites_sent::day.
[greg: small tweaks]
2017-12-06 20:35:50 -08:00
Rishi Gupta
fbd8dde1f8 invitations: Add LoggingCountStat to keep track of sent invitations. 2017-12-06 20:35:50 -08:00
Rishi Gupta
100167fcf8 invitations: Change error messages for resend/revoke views.
We don't have a concept of invitation ID on the frontend (or backend).
2017-12-06 20:35:50 -08:00
Rishi Gupta
cb5eb47470 invitations: Move resend/revoke error handling out of actions.py. 2017-12-06 20:35:50 -08:00
Rishi Gupta
968aae167b invitations: Remove get_prereg_user_by_email.
The original logic is buggy now that emails can belong to (and be
invited to) multiple realms.

The new logic in the `invites` queue worker also avoids the bug where
when the PreregistrationUser was gone by the time the queue worker got
to the invite (e.g., because it'd been revoked), we threw an exception.

[greg: fix upgrade-compatibility logic; add test; explain
revoked-invite race above]
2017-12-06 20:35:50 -08:00
Greg Price
cab5c418f1 invitations: Add tests for queue worker. 2017-12-06 20:30:42 -08:00
Rishi Gupta
8baadc6b15 invitations: Add check for invite limit to resend invite pathway. 2017-12-06 20:30:42 -08:00
Greg Price
b3482429f1 invitations: Adjust a few blank lines for clarity and compactness. 2017-12-06 20:30:42 -08:00
Rishi Gupta
cb527fd3c6 invitations: Move spammer check from do_invite_users into its own function. 2017-12-06 20:30:42 -08:00
Rishi Gupta
e48bc9136a invites: Change resend invitation pathway to use existing code.
This code changes frequently enough that errors are bound to creep in.  The
main change is that this sends the original invitation email instead of the
reminder email, but I think that's fine.
2017-12-06 20:30:42 -08:00
Rishi Gupta
e8b33f2c78 settings_invites: Change wording on resend button. 2017-12-06 20:30:42 -08:00
Brock Whittaker
349dad7a84 typeaheads: Change active <li> to have white text again.
This was accidentally changed due to an inheritance problem of
`.typeahead.dropdown-menu a` overriding the default bootstrap
selector `.dropdown-menu .active > a` with its color styling
preferences.
2017-12-06 16:48:08 -08:00
Brock Whittaker
2776787dc3 compose-alert: Remove unneeded style.
This removes the width attribute that actually makes the notification
about a pixel too long, because removing this with a block element will
automatically make it 100% auto fit.
2017-12-06 16:48:08 -08:00
Brock Whittaker
0ed9da9a11 compose: Make compose alerts dark-mode compatible.
This makes all the alerts in the compose box compatible with dark mode
by choosing different colors and fixing borders to be properly
pronounced, along with removing text shadows that make text unreadable.
2017-12-06 16:48:08 -08:00
Brock Whittaker
9a3a9be926 compose: Restyle #out-of-view-notification alert.
This restyles the notification to be slightly lighter green and have
styles that are more compatible with dark mode, along with removing
dead styles.
2017-12-06 16:48:08 -08:00
Brock Whittaker
83d9844fcd compose: Center "x" vertically and horizontally on cross-stream warning.
On the warning that occurs when you are cross posting to a different
stream, move the “x” to be vertically centered and horizontally aligned
with the”x” on other warnings in the compose box.
2017-12-06 16:48:08 -08:00
Brock Whittaker
0e4eef6ef0 dark-mode: Make bankruptcy modal dark-mode compatible.
This makes the bankruptcy modal compatible with dark mode by adding the
`.modal-bg` class to switch it to dark mode, and by setting a darker
background and border color to the modal header.
2017-12-06 16:48:08 -08:00
Brock Whittaker
a3dac75383 bankruptcy: Change to new default button styles.
This changes the bankruptcy modal to use the new default button style.
2017-12-06 16:48:08 -08:00
Brock Whittaker
a5da6265eb dark-mode: Make all states of navbar <li> dark mode compatible.
This fixes and adds to the logic in commit `525e8e3`. That commit
would only have the stream be the correct color if it was active,
but really it should be dark text by default regardless of whether
it is the active tab bar list item.
2017-12-06 16:48:08 -08:00
Jerry Zhang
4fd3492e73 node tests: Cover exports.get_user_group_from_id. 2017-12-06 06:34:31 -08:00
picapi_
5febd177cf mypy: Use Python 3 type syntax in zerver/webhooks/newrelic/view.py. 2017-12-05 16:32:18 -08:00
picapi_
d55d680758 mypy: Use Python 3 type syntax in zerver/webhooks/homeassistant/view.py. 2017-12-05 16:32:18 -08:00
picapi_
c2ef7e7ce5 mypy: Use Python 3 type syntax in zerver/webhooks/freshdesk/view.py. 2017-12-05 16:32:18 -08:00
picapi_
21e629f351 mypy: Use Python 3 type syntax in zerver/lib/test_classes.py. 2017-12-05 16:32:18 -08:00
picapi_
96fa399ce0 mypy: Use Python 3 type syntax in tools/lister.py. 2017-12-05 16:32:18 -08:00
cPhost
bbdf9f0306 node tests: Cover stream_data.notifications_in_home_view 2017-12-05 16:30:36 -08:00
cPhost
cd9c066c0b node tests: Cover stream_data.name_in_home_view 2017-12-05 16:30:36 -08:00
cPhost
5f50786129 node tests: Cover exports.operators. 2017-12-03 14:01:19 -08:00
cPhost
8b7e355949 node tests: Cover single_collect. 2017-12-03 14:01:19 -08:00
cPhost
8d0ccd29fe narrow_state: Make set_compose_defaults return opts. 2017-12-03 14:01:19 -08:00
Jerry Zhang
164fe28c5b node tests: Cover exports.receives_audible_notifications. 2017-12-03 13:54:41 -08:00
Jerry Zhang
f0d8ce009c node tests: Cover exports.receives_desktop_notifications. 2017-12-03 13:54:41 -08:00
picapi_
67773a4b84 mypy: Use Python 3 type syntax in zerver/webhooks/semaphore/view.py. 2017-12-03 13:48:18 -08:00
picapi_
e2c14724d9 mypy: Use Python 3 type syntax in zerver/views/messages.py. 2017-12-03 13:48:18 -08:00
Greg Price
ff435439af circle-docker: Describe how to build the image.
These commands are super boring standard Docker commands,
so this probably isn't helpful for anyone who is familiar
with building Docker images... but I had to consult docs
to work out the right commands again today, so they'd help me.
2017-12-01 17:16:51 -08:00
Greg Price
535fd9bb5c circle-docker: Silence some spam output. 2017-12-01 17:16:51 -08:00
Greg Price
ea589e8283 circle: Bump base image version.
This new base image just comes from me doing a fresh `docker build`
and uploading the result.  That gives it fresher versions of our
APT dependencies than the image I built a couple of months ago,
speeding up provision by giving it less to install.
2017-12-01 17:16:51 -08:00
Greg Price
58db3c13cb circle: Bump cache version.
This will store a fresh version of the cached trees to the
new ...-base2 keys, and then the *next* build will use those
instead of the ...-base1 keys.
2017-12-01 16:11:25 -08:00
Greg Price
fda349fd33 circle-docker: Fix getting a sudo prompt.
Provision was failing at tools/setup/postgres-init-dev-db
with this in the log:

    Sep 20 02:27:01 + sudo -i -u postgres psql ''
    [sudo] password for circleci:

The issue is that the old version of this line (from Circle upstream)
only lets the `circleci` user sudo to root -- not to other users, or
not directly anyway -- because sudoers syntax is complicated.  Fix it,
after studying `man sudoers`.
2017-12-01 15:21:28 -08:00
Greg Price
a1265e09ba circle-docker: Add all the standard APT deps we provision.
This is only an optimization -- if this list is missing anything,
we'll get to it in `provision` in the actual build.  That's important,
because we want an existing image to work fine for testing new
versions of our codebase, including changes that may install more
packages in `provision`.

What this does accomplish is keeping provision's `apt-get install`
fast, by leaving it very little work to do.

The list comes from looking at the APT output during provision in an
actual run without this step, and leaving out two packages which
aren't available at this stage, because we get them from PPAs:
postgresql-9.3-pgroonga and postgresql-9.3-tsearch-extras.
2017-12-01 15:21:28 -08:00
Greg Price
ab57756d61 circle-docker: Prune redundant packages from install list for clarity. 2017-12-01 15:21:28 -08:00
Greg Price
642fb8537e circle-docker: Use -scm variant of base image to save a bit of work. 2017-12-01 15:21:28 -08:00
Greg Price
8050ad6c3b circle-docker: Simplify a bit for clarity and efficiency.
Install `jq` with APT -- that's a lot simpler to read than this
explicit download.

And coalesce several commands, following Docker upstream's
recommendation and avoiding unnecessary overhead.
2017-12-01 15:21:28 -08:00
Greg Price
b9990941d6 circle: Draft a config for running our builds in CircleCI.
From just my experience attempting this change, I've been impressed
with the very fast turnaround in CircleCI for a change -- from `git
push` to the build starting is usually just a couple of seconds.

It also looks like we get much clearer control over the caching
system, and the setup of the environment via a Docker image of our
choice, which can help avoid most of the several minutes Travis takes
to set up our environment before it actually starts running the tests
themselves.

Plus it supports fine-grained parallelism, e.g. by test file:
https://circleci.com/docs/2.0/parallelism-faster-jobs/

So we can probably get much faster builds by making this switch.
Because the environment is much more transparent and even under
our control, I'm also hopeful for more reliable builds.
2017-12-01 15:19:57 -08:00
Greg Price
7094f78302 circle: First, near-upstream cut at a Dockerfile.
This is nearly the same as Circle's version, linked in the comment.
I've
* changed the FROM line to get Ubuntu,
* added a couple of distro packages to compensate, and
* revised the comments.
2017-12-01 14:47:55 -08:00
Rishi Gupta
f6071e0d90 compose typeahead: Add newline and other terminal_symbols. 2017-12-01 07:17:30 -08:00
Umair Khan
dd97c7e659 nfs: Allow read and write in NFS share.
Reference: https://linux.die.net/man/5/exports
2017-12-01 07:15:32 -08:00
Rishi Gupta
dd57939f50 plans: Make minor wording changes. 2017-12-01 07:14:19 -08:00
Rishi Gupta
8b1c3c00e8 plans: Make the feature thead separator narrower. 2017-12-01 07:14:19 -08:00
Rishi Gupta
58a20b3e96 plans: Change the positioning of the commercial hosting price. 2017-12-01 07:14:19 -08:00
Rishi Gupta
3ef5296ea9 plans: Swap the order of the two blocks within .pricing-container. 2017-12-01 07:14:19 -08:00
Rhea Parekh
460e9b4634 Scripts: Add script for resetting postgres sequences for imports. 2017-12-01 06:38:08 -08:00
Greg Price
ef2f27980a activity: Explain "active sites", and which sites show up in table. 2017-11-30 20:43:46 -08:00
Greg Price
34ee019b20 activity: Consistently define "user" as non-deactivated, non-bot. 2017-11-30 20:43:46 -08:00
Greg Price
0ebfc2fb5c activity: Highlight recently-created realms. 2017-11-30 20:43:46 -08:00
Greg Price
8de34c93dd activity: Show each realm's creation date.
I'd rather have something rich and fancy like a sparkline of
activity... but this is a lot quicker to implement.
2017-11-30 20:43:46 -08:00
Greg Price
2c9b698cb6 activity: Replace "at-risk users" with WAU.
Substantively, this makes the table more readable by grouping users
into expanding sets by level of activity: active in last day, active
in last week, have an account at all.  The class "active in last week",
as opposed to "active in last week but not in last day", makes more
natural comparisons both between realms and for one realm through time,
and it's less sensitive to the details of our definitions.

This also makes the terminology more standard.  We already made that
change in the display, in the previous commit; as we go through the
logic here, we adjust the terminology in the code too.
2017-11-30 20:43:46 -08:00
Greg Price
c5a32185ea activity: Explain what the numbers mean.
This doesn't yet change any of the numbers -- purely adds explanation
and replaces a confusing term or two.
2017-11-30 20:43:46 -08:00
Alena Volkova
3be8e95d13 settings: Send bot types from the backend instead of hardcoding them. 2017-11-30 15:28:53 -08:00
Tim Abbott
2310794451 bots: Don't allow embedded bots bot type in production.
This is important for making it easy for us to merge code related to
UI for embedded bots now, without enabling them in the production UI.
2017-11-30 15:28:53 -08:00
Rishi Gupta
eebef9e9de portico: Update /for/mystery-hunt. 2017-11-30 15:01:33 -08:00
Tim Abbott
e9b3ac3f34 travis: Remove now-unnecssary items from apt-mark hold lists.
This seems to have been causing the travis production suite to fail.
It's a direct consequence of removing travis' giant library of apt
sources.list files; now that those are gone, there aren't copies of
all these extra packages available anyway.
2017-11-30 14:56:36 -08:00
Brock Whittaker
2a7ea5ca53 dark-mode: Change star color to be lighter.
This changes the star color to be lighter and visually softer to be
easier to spot in the page.
2017-11-30 14:40:28 -08:00
Brock Whittaker
5735f8251b dark-mode: Make typeaheads dark mode compatible.
This makes the typeaheads dark-mode compatible by changing to the
background to be dark and the text to inherit from the body text
(rather than bootstrap’s default of #333).
2017-11-30 14:40:28 -08:00
Brock Whittaker
9d255ac7de dark-mode: Respect ".no-style" attr on buttons.
This respects the ".no-style" declaration on buttons and sets
the background back to transparent in dark mode (from a slightly
darkened background).
2017-11-30 14:40:28 -08:00
Brock Whittaker
6d5835773e Informational-overlays: Change "Search Operators" red to better red.
The color of red it was was pretty terrible, so this changes it to a
better shade that also just happens to look good with dark mode.
2017-11-30 14:40:28 -08:00
Brock Whittaker
525e8e36d7 dark-mode: Fix tab list stream to not inherit color.
The streams can be light and if it inherits the white text color they
will not be readable. It should default to dark text with the exception
of when the tab is is `.dark-background`, in which case then it should
revert to inheriting the white color.
2017-11-30 14:40:28 -08:00
Brock Whittaker
03c15fd9dc dark-mode: Change edit notice medium grey to translucent.
This changes the font color from a medium grey to the base font color
plus an opacity of half.
2017-11-30 14:40:28 -08:00
Brock Whittaker
675cb8599d message-feed: Increase font weight of "(EDITED)".
This increases the font weight from 300 to 400 to increase visibility
of the edit notice in messages.
2017-11-30 14:40:27 -08:00
Brock Whittaker
a48568ebbe message-edit-history: Update to new button default style.
This updates an old button to the new button style.
2017-11-30 14:40:27 -08:00
Brock Whittaker
180dee5c5e message-feed: Remove unnecessary text shadow on date row.
This removes an unnecessary text shadow from the message feed date rows
that doesn’t show on white backgrounds and looks unreadable on dark
ones.
2017-11-30 14:40:27 -08:00
Brock Whittaker
f6bbc1f274 dark-mode: Change date row from medium grey to translucent.
This changes the color from a medium grey to a translucent that
inherits the base text color.
2017-11-30 14:40:27 -08:00
Brock Whittaker
4f81bdd0a6 message-edit-history: Make dark mode compatible.
This makes the edit history overlay dark mode compatible by changing
the background to the dark blue along with changing the highlight
colors to work with white text and dark backgrounds.
2017-11-30 14:40:27 -08:00
Brock Whittaker
625c163ba0 dark-mode: Convert medium grey to translucent base color.
This changes the message time from a medium grey to something that is
translucent base color instead.
2017-11-30 14:40:27 -08:00
Brock Whittaker
b2194e860b message-feed: Reduce animation time for date.
This reduces the animation time for the message date to about half.
2017-11-30 14:40:27 -08:00
Brock Whittaker
80b68c3e2b message-edit-history: Increase font weight of author.
This increases the font weight of the author to be a normal font weight
rather than a thin one since it’s already too faint to see on many
monitors.
2017-11-30 14:40:27 -08:00
Brock Whittaker
7883897165 muted-topics: Enable dark mode for mute notifications.
This enables dark mode by changing the background to a dark color
in the stream/topic mute notifications.
2017-11-30 14:40:27 -08:00
Brock Whittaker
afce6b18bf muting: Change muting overlay to use standard buttons.
This changes the overlay “Unmute” button to use the default `.button`
style.
2017-11-30 14:40:27 -08:00
Brock Whittaker
bc11b0f1e8 Revert "dark-mode: Remove unnecessary CSS and fix dark mode bugs."
This reverts commit 64381b6e38.

It turns out we actually needed this for inline code blocks to work.
2017-11-30 14:40:19 -08:00
Brock Whittaker
30475ba4c4 Sidebars: Add border radius to hovered <li>.
This adds a border radius the the <li> to make the selections and
hover areas look a bit more polished and clean.
2017-11-30 14:34:31 -08:00
Tim Abbott
e50f036a99 travis: Remove all travis sources.list files early.
This fixes most of the current Travis CI failures, and should help
prevent future ones from cropping up, since we're just deleting Travis
CI's giant library of apt sources up front.

The production build is still failing, since apparently some of the
packages we were doing `apt-mark hold` on no longer exist.
2017-11-30 14:19:47 -08:00
Rohitt Vashishtha
10618157a2 typeahead: Refactor typeahead tests to include cursor position. 2017-11-30 13:23:46 -08:00
synicalsyntax
6e353a0550 hotkeys: Clear compose box warnings with escape key.
Fixes #7531.
2017-11-30 11:55:50 -08:00
cPhost
6e5dab6a1e node tests: Cover set_compose_defaults. 2017-11-30 06:25:36 -08:00
Brock Whittaker
e0236646bf night-mode: Add custom CSS through JS.
This adds custom CSS through JavaScript for things that do not
scope well and will override other inherited styles.

This should ONLY be used for problematic CSS that has no obvious
or easy CSS-only solution.

(Specifically, we need this for the "default link" styling, which is
hard to override because we don't want to start winning ties due to
specificity that we would not have won in the light theme).
2017-11-29 23:06:11 -08:00
Tim Abbott
6d887dc6ee test-backend: Require 100% test coverage on confirmation code. 2017-11-29 22:20:06 -08:00
Rishi Gupta
7d1c88f0fb invitations: Limit realms to 100 invites per day.
To guard against using zulip invites as a vector for spam. Stopgap measure
until we figure out something better.
2017-11-29 22:18:05 -08:00
Rishi Gupta
8dc0adbed8 confirmation: Add Confirmation.realm. 2017-11-29 22:18:05 -08:00
Rishi Gupta
93abac7952 confirmation: Fix mypy annotation in create_confirmation_link. 2017-11-29 22:18:05 -08:00
Rishi Gupta
7c9694077e confirmation: Move check_prereg_key_and_redirect to registration.py. 2017-11-29 22:18:05 -08:00
Tim Abbott
6e8f4ffc77 test_signup: Expand tests for invalid confirmation links.
We'll need the expanded test coverage when we move
check_prereg_key_and_redirect to zerver/views/registration.py to avoid
test failures, and these are also tests we should really have anyway.
2017-11-29 22:18:05 -08:00
Rishi Gupta
3675d97870 confirmation: Refactor views.confirm to be clearer.
Also gives more appropriate error messages for expired user_registration and
invitation links.
2017-11-29 22:03:09 -08:00
Rishi Gupta
331a9bee6b confirmation: Add Confirmation.REALM_CREATION.
Does not change any behavior. Groundwork for adding a realm field to
Confirmation.
2017-11-29 22:03:09 -08:00
Rishi Gupta
0f5c0ea92b confirmation: Add comment explaining RealmCreationKey. 2017-11-29 22:03:09 -08:00
Rishi Gupta
dc244bd27e confirmation: Fix time enforcement in check_key_is_valid.
The previous code gave the user an extra day past
REALM_CREATION_LINK_VALIDITY_DAYS. Also rewrote it to match the parallel
logic in get_object_from_key.
2017-11-29 22:03:09 -08:00
Greg Price
4926228071 rabbitmq: Do a better job of retrying failed connections.
Empirically, the retry in `_on_connection_closed` didn't actually work
-- if a reconnect failed, that was it, and the exception handler
didn't get run.  A traceback would get logged, but all its frames were
in Tornado or Pika, not our own code; presumably something magic and
async was happening to the exception.

Moreover, though we would make one attempt to reconnect if we had a
connection that got closed, we didn't have any form of retry if the
original attempt at connecting failed in the first place.

Happily, upstream offers a perfectly reasonable bit of API that avoids
both of these problems: the on-open-error callback.  So use that.
2017-11-29 16:56:29 -08:00
Greg Price
7ac2b58584 rabbitmq: Reorder a bit to group our reconnect logic together. 2017-11-29 16:56:29 -08:00
Greg Price
c32b16715d tornado: Use spiffy new call_later rather than add_timeout.
This method was new in Tornado 4.0.  It saves us from having to get
the time ourselves and do the arithmetic -- which not only makes the
code a bit shorter, but also easier to get right.  Tornado docs (see
http://www.tornadoweb.org/en/stable/ioloop.html) say we should have
been getting the time from `ioloop.time()` rather than hardcoding
`time.time()`, because the loop could e.g. be running on the
`time.monotonic()` clock.
2017-11-29 16:56:29 -08:00
Greg Price
73886f57d2 zerver/lib/queue: Clean up import order. 2017-11-29 16:56:29 -08:00
Greg Price
3c4e4c14c9 rabbitmq: Add on-close callback atomically in creating the connection.
Adding it afterward is inherently racy, and upstream's API is quite
reasonable for avoiding that -- just like we can pass an on-open
callback up front, we can do the same with the on-close callback.

This is a more thorough version of 4adf2d5c2 from back in 2013-04.
2017-11-29 16:56:29 -08:00
Greg Price
e88c2a7ee4 rabbitmq: Cut redundant stop_ioloop_on_close parameter.
The default value of this parameter is already False upstream.
(It was already False in pika version 0.9.6, which we were
supposedly using when we introduced this in 4baeaaa52; not sure
what the story was there.)
2017-11-29 16:56:29 -08:00
Brock Whittaker
e7ec21b4cf dark-mode: Add pigments support for dark mode.
This adds support for dark mode pygments that are good syntax
highlighting colors to be seen on a dark background.
2017-11-29 16:44:43 -08:00
Brock Whittaker
a7c2258e12 dark-mode: Change drafts container to be dark.
This changes the drafts container to be dark.
2017-11-29 16:44:43 -08:00
Brock Whittaker
387bdd34c7 dark-mode: Change top-of-messages colors for dark mode.
Make it a white background with the “Z” in the same dark grey/blue
color as the background.
2017-11-29 16:44:43 -08:00
Brock Whittaker
d883f3308c dark-mode: Refactor top-of-messages logo to have CSS styles.
This changes the fill and stroke styles to be in CSS rather than
inlined in the SVG, making it easier to change and override elsewhere.
2017-11-29 16:44:43 -08:00
Brock Whittaker
a2729c52d0 dark-mode: Fix incorrect hover colors on .stream_label.
The headers on some dark stream labels would turn dark and and on some
light turn light. This makes sure that does not happen.
2017-11-29 16:44:43 -08:00
Brock Whittaker
6d8d5f7e95 invite-users: Change buttons to new style.
Some of the buttons in the footer are still the `.btn` class, so these
have been converted to the `.button` class.
2017-11-29 16:44:43 -08:00
Brock Whittaker
618455c7aa dark-mode: Fix invite overlay to have a dark background and borders.
This changes the modal background to be dark and changes the header
border to be darker instead of lighter like the subs and settings ones
are.
2017-11-29 16:44:43 -08:00
Brock Whittaker
836bfd8f45 dark-mode: Refactor gear-menu icon to be translucent.
This makes the gear-menu icon translucent rather than medium grey and
black (which isn't even our base text color) to be half opaque (approx)
and base text color.
2017-11-29 16:44:43 -08:00
Brock Whittaker
e37838c926 dark-mode: Refactor compose icons to be translucent.
This makes the compose icons translucent rather than medium grey
and black (which isn't even our base text color) to be half opaque
(approx) and base text color.
2017-11-29 16:44:43 -08:00
Brock Whittaker
edffa56c51 dark-mode: Style alerts to be darker red.
This styles the alerts to be a darker red that blends more with the
blue dark mode theme.
2017-11-29 16:44:43 -08:00
Brock Whittaker
89b38ff87d dark-mode: Change all links to be brighter blue on hover.
This changes the links to become more emphasized by being brighter
rather than darker since they’re on a dark background.
2017-11-29 16:44:43 -08:00
Brock Whittaker
76f6051a1e dark-mode: Change popover arrows to all be dark.
This changes the position-based arrows on popovers to all be dark
rather than light grey.
2017-11-29 16:44:43 -08:00
Brock Whittaker
ad9c71b4b1 dark-mode: Change emoji reaction overlay to be dark mode compatible.
This changes it to be compatible with the dark-mode which involves one
change to light mode of changing a grey to a translucent white in
reactions.css.
2017-11-29 16:44:42 -08:00
Brock Whittaker
1716d69c35 dark-mode: Fix @-mention colors.
This fixes mention colors for dark mode.
2017-11-29 16:44:42 -08:00
Tim Abbott
377cad7dc2 css: Deduplicate user-group-mention CSS.
These CSS rules were identical before, anyway.
2017-11-29 16:43:46 -08:00
Brock Whittaker
e62ba13887 dark-mode: Change background-image and background-color to background.
There isn’t any reason for either of these mention code paths to be
using specified background types, so convert them all to background so
inheritance is more simple.
2017-11-29 16:42:07 -08:00
Brock Whittaker
1e03c15758 settings_display: Change dev check to correct attribute.
For setting the night mode, it checks to see if you’re in development
by checking `page_params.development`, but the actual attribute is
`page_params.development_environment`.
2017-11-29 16:40:18 -08:00
Brock Whittaker
64381b6e38 dark-mode: Remove unnecessary CSS and fix dark mode bugs. 2017-11-29 16:40:18 -08:00
Tim Abbott
be832387c5 user_groups: Fix reporting of empty user groups.
Previously, we weren't doing a proper left join in
user_groups_in_realm_serialized, resulting in empty user groups being
excluded from the query.  We want to leave decisions about excluding
empty user groups to the UI layer, so we include these here.
2017-11-29 16:13:55 -08:00
Rohitt Vashishtha
621d5dc9df typeahead: Show typeahead only if cursor is before space or punctiation.
This solves the issue with typeahead appearing in the middle of an
already-completed typeahead word.

Example: Earlier, '@ran|dom' would also trigger the typeahead and show
'random', but selecting it would turn it into '@**random** dom'.

We still have a problem to solve of preventing typeahead from
appearing on a space in the middle of an already-completed typeahead
word, but that is its own independent bug.
2017-11-29 14:53:14 -08:00
Greg Price
fe979af822 purge_queue: Allow purging Tornado-consumed queues.
These are the exceptions to the rule that our queues correspond to
queue-processor workers.

Purging `notify_tornado` in particular is a useful workaround right
now for some error spew in the dev environment.
2017-11-29 14:44:53 -08:00
Tim Abbott
b2cb443d24 subs: Fix clearing unread counts when leaving private streams.
Because we use access_stream_by_id here, and that checks for an active
subscription to interact with a private stream, this didn't work.

The correct fix to add an option to active_stream_by_id to accept an
argument indicating whether we need an active subscription; for this
use case, we definitely do not.
2017-11-29 14:40:08 -08:00
Vishnu Ks
5279ac4601 droplets: Update snapshot id. 2017-11-29 14:24:08 -08:00
Greg Price
c2cd76b69e docs: Note need to log out and in again on push notifs setup.
This often surprises people, so mention it up front.

(Also it'd probably be good to add some code to make this step
unnecessary.)
2017-11-29 13:32:02 -08:00
Brock Whittaker
176e4a293b lightbox: Allow for clicking top and bottom to close overlay.
The top and bottom sections of the lightbox overlay do not close the
lightbox when clicked. Now, this triggers the close_overlay path when a
valid non-actionable background element is clicked.

Fixes: #7500.
2017-11-29 11:26:58 -08:00
Tim Abbott
f9347962f6 settings: Only include two-factor apps if two-factor auth is enabled. 2017-11-29 11:09:16 -08:00
Vishnu Ks
954c363a2f dev_settings: Convert hostname to lower case when setting external host. 2017-11-29 10:02:55 -08:00
Cynthia Lin
3d6340ef31 subs: Add padding to Announce stream tooltip content.
Fixes #7474.
2017-11-29 09:51:35 -08:00
Sivagiri
4871b48bf2 node tests: Add tests for stream() and topic() in narrow_state. 2017-11-29 09:39:43 -08:00
Umair Khan
4a0c372de4 get_user_group_from_name: Remove existence check.
Using user_group_name_dict.get() will return `undefined`.
`blueslip.error` statement caused an exception notification to the
admins.

Tweaked by tabbott to add a test for a nonexistent group.
2017-11-29 09:36:04 -08:00
YJDave
967ef04c1e docs: Fix typos in event-system document.
Tweaked by tabbott to fix these typos properly.
2017-11-29 09:31:16 -08:00
Eeshan Garg
61089a9349 python-zulip-api: Upgrade to package release 0.3.9. 2017-11-28 22:16:43 -08:00
Greg Price
5b73c54a74 docs: Push all extraneous level-1 headings inward.
This prevents internal headings like "Basic Example" from appearing in
the left nav at the same level as all the various subsystems.
2017-11-28 21:45:11 -08:00
Greg Price
dc8cb0b436 docs/git/pull-requests: Give headings more hierarchy.
This prevents the sub-heading "Update a pull request" from appearing
as a separate item in the nav.
2017-11-28 21:44:23 -08:00
Greg Price
c7a9f2f4eb docs: Give docs on docs a clearer heading for navigation.
The old name sounds like it's going to be an index or table
of contents for reading the documentation.
2017-11-28 21:35:28 -08:00
Tim Abbott
6bc1a682de notifications: Separate push and email notifications checks.
This is an early step in a larger refactor to properly decouple the
email and push notification code paths.
2017-11-28 17:51:18 -08:00
Sarah
ba70b542d3 notification settings: Add stream email notifications setting.
Adds a field to UserProfile for enabling emails about stream
messages and a field to Subscriptions about email
notification preferences.
2017-11-28 17:51:18 -08:00
Eeshan Garg
bae1ecf1c5 tools/setup: Delete static/generated/bots before repopulating.
tools/setup/generate_zulip_bots_static_files now starts off by
deleting static/generated/bots/ (if it hasn't been removed already)
so that outdated static files from older versions of the zulip_bots
package don't supress errors in the main repo that would otherwise
break.

For more info, see #7542

Fixes: #7542.
2017-11-28 17:17:54 -08:00
rht
ee546a33a3 zerver/lib: Use python 3 syntax for typing.
Edited by tabbott to improve various line-wrapping decisions.
2017-11-28 17:15:14 -08:00
rht
229a8b38c0 zerver/lib: Use Python 3 syntax for typing for several files.
This adds a number of annotations that had been missed in previous
passes.
2017-11-28 17:02:24 -08:00
rht
115f7e6055 zerver/tornado: Use Python 3 syntax for typing (part 2). 2017-11-28 17:02:24 -08:00
Tim Abbott
5dedb488e6 roadmap: Rewrite roadmap to no longer point to milestones. 2017-11-28 16:56:23 -08:00
rht
a1cc720860 zerver: Use Python 3 syntax for typing.
Tweaked by tabbott to fix some minor whitespace errors.
2017-11-28 16:49:36 -08:00
Greg Price
0ec2a9d259 auth: Try switching to register even if user exists on another realm.
For example, this means that if a user already has an account on one
realm and they try to make an account on another by hitting "Sign in
with Google" (rather than following the little "Register" link to a
"Sign up with Google" button instead), they'll get to make an account
instead of getting an error.

Until very recently, if the user existed on another realm, any attempt
to register with that email address had to fail in the end, so this
logic gave the user a useful error message early.  We introduced it in
c23aaa178 "GitHub: Show error on login page for wrong subdomain"
back in 2016-10 for that purpose.  No longer!  We now support reusing
an email on multiple realms, so we let the user proceed instead.

This function's interface is kind of confusing, but I believe when its
callers use it properly, `invalid_subdomain` should only ever be true
when `user_profile` is None -- in which case the revised
`invalid_subdomain` condition in this commit can never actually fire,
and the `invalid_subdomain` parameter no longer has any effect.  (At
least some unit tests call this function improperly in that respect.)
I've kept this commit to a minimal change, but it would be a good
followup to go through the call sites, verify that, eliminate the use
of `invalid_subdomain`, then remove it from the function entirely.
2017-11-28 16:38:41 -08:00
Vishnu Ks
d329636079 tests: Add test for user signup with already-used email.
[Test simplified a bit by greg.]
2017-11-28 16:23:10 -08:00
Greg Price
50e451cd7b populate_db: Create an email-reusing Cordelia in the "lear" realm. 2017-11-28 16:23:10 -08:00
Tim Abbott
586e18b237 auth: Allow accounts with the same email in different realms.
[Modified by greg to (1) keep `USERNAME_FIELD = 'email'`,
(2) silence the corresponding system check, and (3) ban
reusing a system bot's email address, just like we do in
realm creation.]
2017-11-28 16:23:10 -08:00
Tim Abbott
e6f460f511 auth: Replace user_email_is_unique validator.
As we migrate to allow reuse of the same email with multiple realms,
we need to replace the old "no email reuse" validators.  Because
stealing the email for a system bot would be problematic, we still ban
doing so.

This commit only affects the realm creation logic, not registering an
account in an existing realm.
2017-11-28 16:23:10 -08:00
Greg Price
d6cfa56bc1 test_signup: Test that cloning a system bot's email is not allowed.
Just now this is largely redundant with `test_signup_already_active`;
but very soon when we allow reusing an email across realms, the logic
will diverge.
2017-11-28 16:23:10 -08:00
Greg Price
a753f49e6a populate_db: Add a "lear" realm for testing cross-realm email sharing.
We don't yet actually allow sharing emails across realms, but we
will soon.  This lets us start testing some pieces of those changes.
2017-11-28 16:23:10 -08:00
Greg Price
5f38b374b6 register: Activate existing mirror dummy only if on same realm.
The one thing this bit of logic is used for is to decide whether
there's an existing user which is a mirror dummy that we should
activate.  This change causes us to ignore such an existing user if
it's on some other realm, and go straight into `do_create_user`.
2017-11-28 16:23:10 -08:00
Greg Price
eb8b05b2b5 test_email_mirror: Remove a brittle bit of logic.
This code appears to exist to cover a few extra lines in
zerver/lib/digest.py.  But it's rather brittle, tucked as it is into
the middle of a different test's loop, and with the upcoming
introduction of the `lear` realm in testing, this test code itself
loses coverage.

For now, rather than fix this test code up just delete it; we don't
have 100% coverage on `zerver/lib/digest.py`, while we do on this test
file, so that avoids breaking coverage in CI.  As a followup, we
should add back some logic like this but in a more robust way,
probably as its own separate test method.
2017-11-28 16:23:10 -08:00
Greg Price
453585abb1 test_messages: Clean up some error spew by updating a test.
This test would produce a bunch of log messages with tracebacks,
complaining that `welcome-bot@zulip.com` tried to send cross-realm PMs
and can't.  The issue is that the test overrides
`settings.CROSS_REALM_BOT_EMAILS`, and hasn't kept up with additions
to the normal value for that setting.  Update it so that welcome-bot
is permitted as usual.
2017-11-28 16:23:10 -08:00
Greg Price
f632692188 lint: Fix use of re.match in judging long lines.
The `re.match` function in the Python stdlib is a trap for the unwary,
with surprising and asymmetrical semantics; we should probably add a
lint rule to ban it entirely.  The docstring says:

> Try to apply the pattern at the start of the string, [...]

In other words, it effectively adds a `^` at the start (or `\A`, where
the distinction matters.)  It's bad enough that this differs from what
grep, sed, perl, less, and every other tool I can think of do when
looking for matches to a regex; on top of that, it treats the
beginning of the string differently from the end, for no obvious
reason.  The function that does what the rest of the world understands
by "match against this regex" is `re.search`.

In this case, it's unlikely that anyone intended for comments with
URLs, or `api_url` references, to miss out on their respective
exceptions to the long-line rule if they happen to start after the
first column.  So fix those rules by just switching to `re.search`
with the same pattern.

I think Markdown URL references may have to start at the beginning of
the line, so I've left a `^` there to preserve -- but now make
explicit -- the `re.match` behavior.
2017-11-28 16:23:10 -08:00
Greg Price
b6cc21b438 debug: Add facility to dump tracemalloc snapshots.
Originally this used signals, namely SIGRTMIN.  But in prod, the
signal handler never fired; I debugged fruitlessly for a while, and
suspect uwsgi was foiling it in a mysterious way (which is kind of
the only way uwsgi does anything.)

So, we listen on a socket.  Bit more code, and a bit trickier to
invoke, but it works.

This was developed for the investigation of memory-bloating on
chat.zulip.org that led to a331b4f64 "Optimize query_all_subs_by_stream()".

For usage instructions, see docstring.
2017-11-28 15:52:07 -08:00
derAnfaenger
6dd639454e integrations: Add topic parameter for Appfollow.
Tweaked by tabbott to document the integration.
2017-11-28 15:49:19 -08:00
Rishi Gupta
191f8f1b39 left sidebar: Change Home to All messages.
We made this change because users often unnecessarily click "Home"
first in their use of Zulip, because it seems appealing.  While "All
messages" isn't quite precise (it doesn't include muted streams), it
does describe relatively simply the interleaved view that this
represents.

This commit leaves everything as "home" in the code, and only changes
user-visible strings and docs. Changing the code will be a big project;
there are hundreds of relevant occurrences in variable names, etc.

Further, we'll probably want to convert those various variable names
in different ways.

Tweaked by tabbott to extend the commit message and update a few comments.
2017-11-28 15:42:58 -08:00
Umair Khan
1acdfef13c two_factor: Disable prefix in OurAuthenticationForm.
In two factor authentication every step adds a unique prefix to the fields,
due to this the name of the form fields differs from the HTML fields. If
we do not do this we will have to change the name in the HTML, which
will cause the change in tests.
2017-11-28 15:27:44 -08:00
Umair Khan
274bba82b9 two_factor: Add configuration and URLs.
This adds django-two-factor to the project, but held behind
settings.TWO_FACTOR_AUTHENTICATION_ENABLED, so that this has no effect
by default.
2017-11-28 15:21:40 -08:00
Tim Abbott
4f5a5a8547 auth: Extract add_dev_login_context.
This simple refactor cleans up the code for the dev_auth_enabled code
path to be a bit less deeply in the login_page() logic.
2017-11-28 15:17:33 -08:00
Tim Abbott
b42ce65090 requirements: Add dependencies for two-factor auth.
We're not yet ready to add 2FA to Zulip yet, but we've determined we'd
like to work from these libraries.

I'm not bothering to bump PROVISION_VERSION for this, since we're
likely to do something else that bumps it soon, and we're not merging
anything that uses these new libraries.
2017-11-28 15:13:38 -08:00
Tim Abbott
d5bb45db60 webhooks/gci: Fix missing mypy annotation. 2017-11-28 14:08:44 -08:00
Sampriti Panda
bea653fabc webhooks/gci: Improve message formatting.
* Use Student Name instead of Task Name in subject.
* Use Task Instance URL instead of Task Definition URL (and workaround
  for a bug in the API).
2017-11-28 13:53:42 -08:00
Tommy Ip
2d7536bf05 Document the add_mentor.py tool. 2017-11-28 13:26:59 -08:00
Tommy Ip
ba1a32ca74 Create script to add and remove mentor's ssh key from DO droplets. 2017-11-28 13:26:59 -08:00
Tommy Ip
6e22847548 refactor: new message content -> compose textarea. 2017-11-28 12:53:40 -08:00
Cynthia Lin
e92a8ac8ee subs: Properly focus on Stream name box while creating a new stream.
Fixes #7473.
2017-11-28 10:07:11 -08:00
Garvit
b9826e9067 Add filters for toMarkdown to paste data to compose-box.
This fixes bugs with pasting headings and italic styling.

Fixes #7485.
2017-11-28 09:56:48 -08:00
Tim Abbott
cb8f2cf484 git cheat sheet: Be a bit less agressively anti-git-pull.
Now that we configure pull.rebase, it's less necessary.
2017-11-28 09:15:13 -08:00
Rohitt Vashishtha
c073af0ddc git-docs: Highlight Zulip's git scripts in overview. 2017-11-28 09:07:25 -08:00
Rohitt Vashishtha
106cc71c19 docs: Add external documentation for markdown subsystem.
Tweaked by tabbott to move the content earlier in the doc.
2017-11-28 09:07:17 -08:00
Rohitt Vashishtha
a2d1ebc091 git-docs: Refine git-cheat-sheet with more examples. 2017-11-28 09:02:50 -08:00
Vishnu Ks
87a412a992 droplets: Fix broken link for requesting droplets. 2017-11-28 08:53:52 -08:00
Vishnu Ks
73ee9a4ad8 droplets: Update info on recreating the droplets. 2017-11-28 08:53:52 -08:00
Vishnu Ks
c37193568f droplets: Update baseimage snapshot id.
The new snapshot has python-zulip-env as well
as VIM and mosh installed.
2017-11-28 08:53:52 -08:00
Tommy Ip
29e9d16ac7 refactor: s/upload-bar/compose-upload-bar. 2017-11-27 21:35:14 -08:00
Tommy Ip
6a694418b2 refactor: s/error-msg/compose-error-msg. 2017-11-27 21:35:14 -08:00
Tommy Ip
b9c2f479d3 refactor: s/send-status-close/compose-send-status-close. 2017-11-27 21:35:14 -08:00
Tommy Ip
c0c58f9761 refactor: s/send-status/compose-send-status. 2017-11-27 21:35:14 -08:00
Tommy Ip
19b518c801 refactor: Extract tests for upload mechanics.
This temporarily removes the tests for clear_out_file_list since
fixing that test proved to be difficult.
2017-11-27 21:34:55 -08:00
Tommy Ip
ddaff4cd2a refactor: Extract upload mechanics to new JS module.
Tweaked by tabbott to move changes from the next commit that are
required for this to pass tests into this commit.

Note that this exports a few items that were not previously exported.
2017-11-27 21:31:51 -08:00
Tim Abbott
0445322625 compose: Export the major upload-related methods.
This is a preparatory commit to moving these to their own module.
2017-11-27 21:31:24 -08:00
Tim Abbott
df58f0f7ae compose: Export some upload-related variables. 2017-11-27 21:31:23 -08:00
Robert Hönig
1e66bd1c02 tests: Add newlines to test_service_bot_system.test_internal_endpoint(). 2017-11-27 21:05:34 -08:00
derAnfaenger
c8a5ae753c embedded bots: Consistently use 'storage' instead of 'state.' 2017-11-27 21:05:34 -08:00
Tim Abbott
9645c8b31f integrations: Remove disabled googlesearch integration.
This was moved to another part of the python-zulip-api codebase
because it was unfinished.
2017-11-27 20:50:37 -08:00
Eeshan Garg
c45517f544 python-zulip-api: Upgrade to PyPI package release 0.3.8.
There's one migration required by this release:

* queue_processors: Stop passing state_handler to handle_message.

  state_handler is now a property of bot_handler and thus, does
  not need to be passed to bot_handler.handle_message().

  The commit responsible is:
  2a74ad11c5
2017-11-27 20:31:37 -08:00
rht
e538f4dd44 zerver/views: Use Python 3 syntax for typing.
Edited by tabbott to remove state.py and streams.py, because of
problems with the original PR's changes, and wrap some long lines.
2017-11-27 17:10:39 -08:00
rht
92888a0cde zproject: Use Python 3 syntax for typing. 2017-11-27 17:01:18 -08:00
Rishi Gupta
83149a953a copy paste: Turn off toMarkdown in production.
At least until some of the TODOs at the bottom of
node_tests/copy_and_paste.js are done.
2017-11-27 16:44:16 -08:00
Rishi Gupta
3fcfcd2a55 copy paste: Add toMarkdown test for 1. text. 2017-11-27 16:44:16 -08:00
Tim Abbott
bd8196c3a5 lint: Fix too-long line in auth.py. 2017-11-27 15:28:46 -08:00
Rohitt Vashishtha
8082780853 typeahead: Update @mention to not autocomplete "@ " (@space).
Tweaked by tabbott to also cover "@** ".

Fixes #7533.
2017-11-27 15:15:56 -08:00
Vishnu Ks
d4ee3023b2 registration: Require an explicit realm on PreregistrationUser.
This completes the last commit's work to fix CVE-2017-0910, applying
to any invite links already created before the fix was deployed.  With
this change, all new-user registrations must match an explicit realm
in the PreregistrationUser row, except when creating a new realm.

[greg: rewrote commit message]
2017-11-27 14:59:34 -08:00
Vishnu Ks
985768b2fd registration: Check realm against PreregistrationUser realm.
We would allow a user with a valid invitation for one realm to use it
on a different realm instead.  On a server with multiple realms, an
authorized user of one realm could use this (by sending invites to
other email addresses they control) to create accounts on other
realms. (CVE-2017-0910)

With this commit, when sending an invitation, we record the inviting
user's realm on the PreregistrationUser row; and when registering a
user, we check that the PregistrationUser realm matches the realm the
user is trying to register on.  This resolves CVE-2017-0910 for
newly-sent invitations; the next commit completes the fix.

[greg: rewrote commit message]
2017-11-27 14:58:26 -08:00
Tim Abbott
8b935f4e99 settings: Add setting for SYSTEM_BOT_REALM.
This fixes some subtle JavaScript exceptions we've been getting in
zulipchat.com, caused by the system bot realm there not being "zulip"
interacting with get_cross_realm_users.
2017-11-27 14:46:07 -08:00
Tim Abbott
25fd4c5508 bulk_get_users: Edit the cache keys to make them more unique.
While at this point I was to rewrite this function, this at least
plugs the issues for now.
2017-11-27 14:41:31 -08:00
Tim Abbott
339b67f7af get_cross_realm_dicts: Harden against caching bug in last commit.
This should help protect us from future issues with the way that
`bulk_get_users` does caching.

It's likely that we'll want to further restructure `bulk_get_users` to
not have this base_query code path altogether (since it's kinda
buggy), but I'm going to defer that for a time when we have another
user.
2017-11-27 14:35:50 -08:00
Tim Abbott
646ba5b9e5 bulk_get_users: Fix issues with users in multiple realms.
The previous implementation had a subtle caching bug: because it was
sharing its cache with the `get_user_profile_by_email` cache, if a
user happened to have an email in that cache, we'd return it, even
though that user didn't match `base_query`.

This causes `get_cross_realm_users` to no longer have a problematic
caching bug.
2017-11-27 14:34:45 -08:00
Tim Abbott
f423dc4930 check_send_receive_time: Fix parsing bug.
This was a regression introduced with the argparse migration.
2017-11-27 14:01:30 -08:00
Rohitt Vashishtha
6734b00c0b markdown: Hide URL if message is only an image.
Hides URL if the message content == image url so that sending gifs or
images feels less cluttered. Uses the url_to_a() function to generate
the expected url string for matching.

Fixes #7324.
2017-11-27 13:30:18 -08:00
Rohitt Vashishtha
3550467899 markdown: Insert text in link-only inline image preview tests.
Appends "Test: " text to some tests to make changes to the image preview
rendering. In the future, if the message is only a link to an image,
the link will be hidden.
2017-11-27 13:30:18 -08:00
Steve Howell
025b8c19ae Simplify code to warn about private stream links.
This change does a few things:

    * I use "early return" to make the code a bit flatter
      and easier to comment.

    * I added more comments.

    * I removed some unneeded passing of `invite_only` into
      the template.
2017-11-27 10:41:10 -08:00
Steve Howell
e74118e730 tests: Improve templates.compose_private_stream_alert() test.
I assert that the stream_name gets properly placed into the HTML.
2017-11-27 10:41:10 -08:00
Umair Khan
8f190e0746 user-groups: Update marked.js to do proper local echo for mentions.
We implement markdown in the JS as well to improve the
usability.  Comes complete withunit tests.

Fixes #7381.
2017-11-27 09:16:09 -08:00
Umair Khan
90994bccac user-groups: Recognize single asterisk for group mentions.
The character combination of @* now begins a group mention, so
this test is no longer valid.
2017-11-27 09:16:09 -08:00
Umair Khan
c78846a274 markdown.js: Add error function to blueslip.
If we do not add this, we get an exception before we reach the
assertion.
2017-11-27 09:08:30 -08:00
Umair Khan
9d0eea8dd1 user-groups: Add is_member_of. 2017-11-27 09:08:30 -08:00
Rhea Parekh
1d826ae201 composebox: Warn when linked to private streams.
Fix issue #6860
2017-11-27 07:41:59 -08:00
Rohitt Vashishtha
be56a99734 popover: Populate compose_box with popover user's email.
Replaces use of compose.respond_to_message with compose.start, manually
populating the email field with the popovered user's email.

Fixes #7526.
2017-11-26 22:59:37 -08:00
Tim Abbott
649b7b8b9f internal_send_message: Enforce being passed cross-realm bots.
We include ERROR_BOT in this set, even though it's not technically
cross-realm (it just lives in the admin realm).

This code path does not correctly handle emails that correspond to
multiple accounts (because `get_system_bot` does not).  Since it's
intended to only be used by system bots, we add an appropriate
assertion to ensure it is only used for system bots.
2017-11-26 17:14:23 -08:00
Tim Abbott
ae8e203717 actions: Merge internal_prep_message into internal_send_message.
We also document the fact that only system bots are supported here.
2017-11-26 17:14:23 -08:00
Tim Abbott
6952dcbdac embedded bots: Stop using internal_send_message for non-system-bots.
This was causing problems, because internal_send_message assumes that
there is a unique user (across all realms) with the given email
address (which is sorta required to support cross-realm bot messages
the way it does).

With this change, it now, in practice, only sends cross-realm bot
messages.
2017-11-26 17:14:23 -08:00
Tim Abbott
27582782fa embedded bots: Flip around ordering of rate-limiting check. 2017-11-26 17:14:23 -08:00
Tim Abbott
5306a9634d email_mirror: Rewrite to not use internal_send_message.
This was causing problems with the fact that `get_system_bot` now only
works for actual system bot users.
2017-11-26 17:14:23 -08:00
Eeshan Garg
5b8f38f4e3 webhooks/bitbucket2: Ignore push events with no changes.
We now ignore payloads where payload['push']['changes'] is empty,
because an empty push doesn't really convey any useful information.

I couldn't find a way to replicate the action that would generate
such a payload, so I took one of our existing payloads and editted
out payload['push']['changes'] myself, so this payload is not
authentic.
2017-11-26 17:03:07 -08:00
Tim Abbott
2210f627a5 signup: Switch active mirror-dummy users to an AssertionError.
Previously, this was a ValidationError, but that doesn't really make
sense, since this condition reflects an actual bug in the code.

Because this happened to be our only test coverage the ValidationError
catch on line 84 of registration.py, we add nocoverage there for now.
2017-11-26 16:13:45 -08:00
Vishnu Ks
b9bc1c2b33 Eliminate get_user_profile_by_email from test_classes. 2017-11-26 15:47:56 -08:00
Tim Abbott
d1ff4293a5 backends: Remove assumption that only one user can have a given email.
I probably should have just done this in the original implementation;
there's only a small downside in the form of an extra database query
when trying to authenticate a user who doesn't exist.
2017-11-26 15:42:48 -08:00
Vishnu Ks
610eb557b8 backend: Make password reset form support multi realm membership. 2017-11-26 15:35:25 -08:00
Vishnu Ks
9f225360dc register: Make /register redirect to find accounts in root domain without realm.
If there is no realm in the root domain don't show
registration form. Instead just redirect to find
accounts page.
2017-11-26 15:32:17 -08:00
Vishnu Ks
bab0b913ee test_signup: Extract logic for realm-creation test to a function. 2017-11-26 15:29:16 -08:00
Vishnu Ks
1b5753d021 test_signup: Fix assertIsNone check for realm in RealmCreationTest. 2017-11-26 15:27:33 -08:00
Tim Abbott
c3c978e55d docs: Document the new queue_json_publish model in our unit tests. 2017-11-26 11:49:42 -08:00
Tim Abbott
9fcdb6c83a notifications: Use call_consume_in_tests for email sending.
This adds a bit of test coverage with really no downside.
2017-11-26 11:46:07 -08:00
Robert Hönig
0e0a8a2b14 queue processor tests: Call consume by default.
This significantly improves the API for queue_json_publish to not be
overly focused on what the behavior of this function should be in our
unit tests.
2017-11-26 11:45:34 -08:00
Shubham Dhama
5e23bfa779 typeahead: show typeahead for syntax of the from @**... or #**...
Fixes: #7494.
2017-11-26 11:18:47 -08:00
Rohitt Vashishtha
cd83b94f3d git-docs: Make links to Zulip's git-tools at relevant places.
Tweaked by tabbott to fix a few issues with the text found while
looking at this.
2017-11-26 11:14:16 -08:00
Rohitt Vashishtha
a9e915007a git-dogs: Move working-copies to docs/git. 2017-11-26 09:15:50 -08:00
Rohitt Vashishtha
e2c1cf6832 git-docs: Move fixing-commits to docs/git. 2017-11-26 09:15:50 -08:00
Rohitt Vashishtha
e811675831 git-docs: Merge two cheat-sheets and move to docs/git. 2017-11-26 09:15:50 -08:00
Rohitt Vashishtha
ae0732e4f2 git-docs: Fix typos and make minor edits to working-copies. 2017-11-26 09:15:50 -08:00
Balaji2198
585cd36a2e setting: Align elements properly in invite users.
Adds a margin-top to `Check all` and `Uncheck all` elements.

Fixes #7488.
2017-11-26 09:13:33 -08:00
Eeshan Garg
15bf0ebc61 css: Fix overflowing long URLs in Markdown macros.
Long URLs in Markdown macros overflow their containers without this
property. This reverts 0dc91a9148.  We
will likely need to fix the original Windows bug that
0dc91a9148 has resolved another way.
2017-11-25 17:02:38 -08:00
Eeshan Garg
23162a1433 github_webhook: Use indented Markdown macros. 2017-11-25 17:01:11 -08:00
Eeshan Garg
1dca7cc367 webhooks/beanstalk: Use indented Markdown macros. 2017-11-25 17:01:11 -08:00
Eeshan Garg
8b43e07fc5 webhooks/codebase: Use indented Markdown macros. 2017-11-25 17:01:11 -08:00
Eeshan Garg
880fd5497a markdown: Add indented versions of multi-line Markdown macros.
This is part of our efforts to change our integrations/webhooks
docs to follow the same sort of numbered-list format as our /help
docs. In order to indicate that paragraphs separated by newlines
are part of the same numbered-list point, every paragraph must be
indented 4 spaces.
2017-11-25 17:01:11 -08:00
Tim Abbott
6968b540c8 mypy: Remove type: ignores that are unnecessary with new mypy.
Mostly these can be removed because the broken LXML stubs were removed
from typeshed in https://github.com/python/typeshed/issues/525.
2017-11-25 10:06:28 -08:00
Rhea Parekh
84847b811b requirements: Upgrade mypy to 0.550.
We have to add a few type: ignores due to mypy 0.550 having some bugs
in the new imaplib stubs in typeshed.

Fixes #7387.
2017-11-25 10:06:27 -08:00
Tim Abbott
d639e31641 lint: Fix check-templates handling of team.html.
This prevents some unnecessary error messages when running the linter
on a single file.
2017-11-25 09:43:01 -08:00
Tim Abbott
13a1b44aa8 settings: Fix missing target=_blank on realm emoji images.
This resulted in problems with the desktop app, where clicking these
links would leave the user in a situation where they needed the "back"
button in order to get back to the webapp.

Fixes zulip/zulip-electron#342.
2017-11-25 09:43:01 -08:00
Rohitt Vashishtha
146aed3cc3 gitignore: Ignore package-lock.json generated by npm.
See https://chat.zulip.org/#narrow/stream/code.20review/subject/pull.20request for discussion.
2017-11-24 10:25:28 -08:00
Joshua Pan
9e8ae68dfb vagrant: Add NFS backend for file synchronization for OSX.
This is intended to fix serious issues with frequent guest crashes on
OSX High Sierra with Virtualbox and the default file synchronization.

Note from Tim: We've tried this idea before, and it worked for Mac,
but caused problems for non-Mac users of our Vagrant setup that
resulted in it being reverted in
1432e9afb0.

Hopefully the new conditional will handle things correctly in both Mac
and Linux.
2017-11-24 10:16:07 -08:00
Robert Hönig
0dc91a9148 css: Fix code blocks overflowing for integration names. 2017-11-24 09:26:08 -08:00
Cynthia Lin
b607d26f0a lightbox: Fix image metadata not displaying at full width when possible. 2017-11-24 09:21:31 -08:00
Vaibhav Sagar
711f7bca3b upload: Fix typo in animated GIF error message.
s/must be have/must have the/.
2017-11-24 09:08:38 -08:00
Tim Abbott
6f53d65e56 docs: Update a few broken links to the Git guide. 2017-11-23 16:24:00 -08:00
Harshit Bansal
fa3602b61f docs: Split 'git-guide.md`.
This should make our Git documentation more readable and less
intimidating.
2017-11-23 16:04:18 -08:00
akashnimare
271c3c1101 portico: Fix portico dropdown bug.
This fixes a responsiveness bug where the portico dropdown was not
showing up properly in a mobile view.
2017-11-23 15:56:50 -08:00
Sumana Harihareswara
7821acde6b /team: Fix typo. 2017-11-23 15:18:26 -08:00
Tim Abbott
1152246993 Revert "reactions: Change from grey to translucent."
This reverts commit 30f45ac061.

This commit caused problems with the compose box emoji picker
overflowing its bounds in Firefox at 90% zoom.
2017-11-23 14:55:00 -08:00
Tim Abbott
0f8ee343de node: Fix copy_and_paste test output.
I'm confused how this was passing when I tested previously.
2017-11-23 14:18:28 -08:00
Tim Abbott
cc8c8ab21c node: Fix style in copy-paste test.
This bug got merged due to a problem with Travis CI.
2017-11-23 13:06:17 -08:00
Tim Abbott
4d4532a27e copy_and_paste: Add a simple extensible test suite.
This commit is mostly about adding the test suite; some of the results
are things we'd like to change.
2017-11-23 12:59:01 -08:00
Andy Perez
e7f1825617 bugdown: Update KaTeX to version 0.8.3 from 0.7.1.
Fixes #7480.
2017-11-23 12:43:34 -08:00
Tim Abbott
15cf87f424 clean-npm-cache: Fix path to yarn in Travis CI.
Apparently, this was checking the wrong path in Travis CI, and thus
never actually running (meaning we'd accumulate every `node_modules`
directory ever in the Travis caches, which in turn resulted in very
slow builds).
2017-11-23 12:01:20 -08:00
Tim Abbott
15501c8b07 lint: Clean up json_rules logic for tab-based whitespace.
This both improves the comment to be more readable, and also uses the
new and improved exclude feature to limit the exclusion to just the
webhook fixtures (where it's needed).

Also fixes a mypy error.
2017-11-23 12:01:20 -08:00
Tim Abbott
fb88eaa2d8 lint: Fix logic for exclude to handle directory trees.
The previous exclude rules only allowed excluding a directory (and
things in subdirectories would silently still be linted).  Anyone
using this would expect it to exclude a directory tree, so we make it
do that.
2017-11-23 12:01:20 -08:00
Vishnu Ks
def573cde3 remotedev: Add option to recreate droplets. 2017-11-23 11:09:30 -08:00
Tim Abbott
938892db8f lint: Ban tab-based whitespace in our our text fixtures.
We don't want to do this for the webhook fixtures since those come
from third-party code, but it makes sense to do this for hand-edited
code.
2017-11-23 10:47:09 -08:00
Umair Khan
f70b36a5a9 12-toggle-message-editing: Add wait before flaky test. 2017-11-23 10:43:42 -08:00
Greg Price
49f4c33a57 docs: Update release checklist with thoughts from 1.7.1. 2017-11-22 18:11:20 -08:00
Greg Price
50ea5ff4b1 version: Update mentions of latest release to reflect 1.7.1. 2017-11-22 18:11:20 -08:00
Greg Price
fbbd5b0eee changelog: Document 1.7.1 release. 2017-11-22 18:11:20 -08:00
Greg Price
47abd9c522 i18n: Update translations (including complete Korean!) 2017-11-22 18:11:20 -08:00
Greg Price
64c608a51a install: Clarify how we set locale during install, and why.
This updates commit 11ab545f3 "install: Set the locale ..."
to be somewhat cleaner, and to explain more in the commit message.

In some environments, either pip itself fails or some packages fail to
install, and setting the locale to en_US.UTF-8 resolves the issue.

We heard reports of this kind of behavior with at least two different
sets of symptoms, with 1.7.0 or its release candidates:
  https://chat.zulip.org/#narrow/stream/general/subject/Trusty.201.2E7.20Upgrade/near/302214
  https://chat.zulip.org/#narrow/stream/production.20help/subject/1.2E6.20to.201.2E7/near/306250

In all reported cases, commit 11ab545f3 or equivalent fixed the issue.

Setting LC_CTYPE is redundant when also setting LC_ALL, because LC_ALL
overrides all `LC_*` environment variables; so skip that.  Also move
the line in `install` to a more appropriate spot, and adjust the
comments.
2017-11-22 18:11:20 -08:00
Steve Howell
59870b2203 Make dark theme toggle only run in dev mode. 2017-11-22 16:13:09 -08:00
akashnimare
a37e993907 portico: Remove unnecessary background from realm-icon.
This PR removes unnecessary white background from realm-icon.
Also, I have given padding and border-radius to make it look good.

This also fixes a bug where realm-name didn't show up because of the
white font color.
2017-11-22 15:00:22 -08:00
Tommy Ip
f425f9ad3d navbar: Fix transparency issue. 2017-11-22 13:02:13 -08:00
Vishnu Ks
b9fc4a4306 docs: Mention the error when phantomjs is not installed. 2017-11-22 12:42:02 -08:00
rht
138c486548 zilencer: Use python 3 syntax for typing. 2017-11-22 12:29:03 -08:00
Andy Perez
0449dc8b8a bugdown: Fix handling of nested fenced math blocks.
Change any fence delimiters (backticks and tildes) to be
interpreted literally inside of math fenced_code blocks.

Fixes #5190.
2017-11-22 12:19:43 -08:00
rht
01885cdedc analytics: Use Python 3 syntax for typing (final). 2017-11-22 12:16:59 -08:00
rht
6c286b5eb6 analytics: Use Python 3 syntax for typing (part 2). 2017-11-22 12:16:58 -08:00
Tim Abbott
a4e9da22e0 coverage: Update pattern for __str__ for new typing syntax.
The new Python 3 typing syntax means the def lines for __str__ can
look a bit different.
2017-11-22 12:16:58 -08:00
Tommy Ip
db240de555 /team: Make the contributor list more fair.
Don't display contributors with less commits than the 100th server
contributor (the Github API limits the output of users to 100).
2017-11-22 11:33:24 -08:00
Tommy Ip
e44b8809b2 /team: Render contributors list in tabs client side. 2017-11-22 11:33:24 -08:00
Tommy Ip
019c06a087 /team: Populate authors.json with updated file structure. 2017-11-22 11:33:24 -08:00
Tommy Ip
09d103091d /team: Use list instead of dict for contributors data. 2017-11-22 11:33:24 -08:00
Tommy Ip
771abf4179 /team: Fetch contributors data from all major repos.
Also wait 2 seconds before trying again.
2017-11-22 11:33:24 -08:00
David Rosa Tamsen
84384196f2 docs: Exclude files from TOC warnings and navigation sidebar.
Sphinx was displaying "WARNING: document isn't included in any toctree"
for files we just don't want in the TOC. We can hide them from the index,
but the rtd theme defaults to display hidden index entries in the nav bar.

This commit excludes these files from such warnings, and patches layout.html
so that hidden index entries stay hidden from the navigation sidebar.

This commit also moves password-strength.md under docs/production and
adds it as a hidden entry in production/index.rst.

Fixes #7417.
2017-11-22 10:59:14 -08:00
David Rosa Tamsen
11b8b8f483 docs: Add rtd layout template.
The readthedocs theme overrides a few settings in their layout template.
We might want to change some settings back to their default values.

This commit copies the original readthedocs layout file from
https://github.com/rtfd/sphinx_rtd_theme/blob/master/sphinx_rtd_theme/layout.html
to _templates/layout.html, and excludes it from lint and template checks.

Addresses #7417.
2017-11-22 10:59:14 -08:00
Tim Abbott
9074b9f2fa docs: Do a few more tweaks to the webhook walkthrough formatting. 2017-11-22 10:29:07 -08:00
derAnfaenger
a1d255471c docs: Fix formatting of integration-docs-guide.md 2017-11-22 10:29:07 -08:00
derAnfaenger
43484ad494 markdown processor: Exclude some files from macro substitution.
This fixes unintended macro substitution for files explaining
the macro system.
2017-11-22 10:29:07 -08:00
Harshit Bansal
2e7d0cb4cb digests: Fix new stream links.
Fixes: #7479.
2017-11-22 10:07:36 -08:00
Cynthia Lin
e071d27b6b lightbox: Fix text overflow of translated user interface.
Fixes #7469.
2017-11-22 09:56:30 -08:00
Tim Abbott
8f6b39a1c0 mypy: Fix annotations for json_encoder_for_html. 2017-11-22 01:32:46 -08:00
rht
3ec90f8b33 zerver/tests: Use python 3 syntax for typing (final). 2017-11-21 22:01:19 -08:00
rht
0260ba82ca zerver/tests: Use python 3 syntax for typing (part 4). 2017-11-21 22:01:19 -08:00
rht
3bf9cd0656 zerver/tests: Use python 3 syntax for typing (part 3). 2017-11-21 22:01:19 -08:00
rht
e3daa09b05 zerver/tests: Use python 3 syntax for typing. 2017-11-21 22:01:19 -08:00
Tim Abbott
f1850b99cf test-backend: Don't use monkey-patching to set formatter class.
The previous approach threw a mypy error, and was also bad code
anyway.
2017-11-21 21:55:48 -08:00
Tim Abbott
33865a3535 lint: Add exclude rules for URLs in code comments. 2017-11-21 21:53:48 -08:00
rht
e169bb0954 zerver: Remove simplejson dependency.
Modified by tabbott to put the third-party code in a new file.

Fixes #6970.
2017-11-21 21:51:48 -08:00
Tim Abbott
b4e67fac36 bot_lib: Fix storage bug introduced by rebase error. 2017-11-21 21:37:54 -08:00
rht
e55898850a Replace optparse with argparse in remaining tools.
Tweaked by tabbott to fix various bugs with the usage output.
2017-11-21 21:34:38 -08:00
rht
585b71bc00 email-mirror-postfix: Replace optparse with argparse. 2017-11-21 21:34:38 -08:00
rht
54fb88f331 scripts: Replace optparse with argparse. 2017-11-21 21:23:41 -08:00
rht
5f6dbe6226 fixtures: replace optparse example with argparse. 2017-11-21 21:23:41 -08:00
derAnfaenger
e526d0c144 embedded bots: Add views to access state. 2017-11-21 21:10:39 -08:00
derAnfaenger
d2af8d4cbd embedded bots: Support multi-entry state modification. 2017-11-21 21:10:39 -08:00
derAnfaenger
cbadd3d430 embedded bots: Simplify StateError exception messages. 2017-11-21 21:10:12 -08:00
Tim Abbott
141cf21b86 bulk_create: Fix buggy logic for generating recipients_by_email.
This buggy logic from e1686f427c had
broken do-destroy-rebuild-test-database.

Now that we're not just trying to add the Recipient objects for every
user on the system here to profiles_by_id, we also shouldn't be
processing every Recipeint object on the system.  The fix is simple:
because of the patch we got merged into Django upstream,
recipients_to_create actually has the object IDs added to the
Recipient objects passed into Recipient.objects.bulk_create.

This was missed in manual testing, since it only broke `populate_db
--test-suite`.
2017-11-21 21:07:32 -08:00
rht
3f4bf2d22f zerver/lib: Use python 3 syntax for typing.
Extracted from a larger commit by tabbott because these changes will
not create significant merge conflicts.
2017-11-21 20:56:40 -08:00
rht
561ba33f69 zerver/lib: Use python 3 syntax for typing.
Split by tabbott from a larger commit; this covers a batch of files
with no open PRs touching them.
2017-11-21 20:45:52 -08:00
Eeshan Garg
73d0f1db81 lib/integrations: Remove Integration.doc_context.
An Integration object doesn't need access to the context dict used
to render its doc.md, since the context dict is just passed directly to
render_markdown_path.
2017-11-21 20:39:30 -08:00
Eeshan Garg
600ee90a38 integrations: Add add_context_for_single_integration function.
Previously, when rendering a single integration, we tacked on the
following information to the context dict that was redundant:

* An OrderedDict containing all of the Integration objects for
  all integrations.
* An OrderedDict containing all of the integration categories.

The context dict for rendering a particular integration doc would
contain 4 OrderedDicts, 2 for categories, 2 for Integration objects
because of how many times add_integrations_context had been called.

This was very wasteful, since an Integration object doesn't need
to access any other Integration object (or itself for that matter)
to render its documentation. This commit adds a function that
allows us to only pass in the context values that are necessary.
2017-11-21 20:39:30 -08:00
Tim Abbott
e1686f427c bulk_create: Remove assumption that UserProfiles are globally unique.
This isn't used in production, but that could change in the future,
and the fix to make this limited to a single realm is pretty simple.
2017-11-21 20:23:06 -08:00
Tim Abbott
aa2a4632c5 tests: Lock down 100% test coverage on zerver/forms.py.
With the recent work on OurAuthenticationForm, this now has complete coverage.
2017-11-21 20:14:12 -08:00
Tim Abbott
f6e57fd514 forms: Remove unnecessary OurAuthenticationForm logic.
This is checked for in the caller of OurAuthenticationForm, which
meant this code was never run.  But it is worth having an assertion
here to catch any possible regressions.
2017-11-21 20:14:12 -08:00
Tim Abbott
719d6c49df forms: Stop using get_user_profile_by_email in OurAuthenticationForm.
Structurally, the main change here is replacing the `clean_username`
function, which would get called when one accessed
self.cleaned_data['username'] with code in the main `clean` function.

This is important because only in `clean` do we have access to the
`realm` object.

Since I recently added full test coverage on this form, we know each
of the major cases have a test; the error messages are unchanged.
2017-11-21 20:14:12 -08:00
Tim Abbott
36bc037cc2 auth: Convert SocialAuthMixin to use new helper.
This is a pure refactor at this point.
2017-11-21 20:14:12 -08:00
Tim Abbott
22b7de0ccd auth: Move check for social backend earlier.
This better fits the flow that we use in other auth backends.
2017-11-21 20:14:12 -08:00
Tim Abbott
665fc594db auth: Set valid_attestation more unconditionally in social auth. 2017-11-21 20:14:12 -08:00
Tim Abbott
ade5b4ea69 auth: Convert SocialAuthMixin to accept a realm object. 2017-11-21 20:14:12 -08:00
Tim Abbott
0377288f68 auth: Fix GitHub test for invalid user account. 2017-11-21 20:14:12 -08:00
Tim Abbott
251a537e0d auth: Set the subdomain in more GitHub auth tests.
This should have been set in basically all of these tests to set them
up properly, and this issue will matter after upcoming changes.
2017-11-21 20:14:12 -08:00
Tim Abbott
732dd1b6a3 auth: Improve logic for invalid GitHub emails.
This deletes the old mock-covered test for this, which was mostly
useless.  We have a much less messy test, which we extend to provide
the same test coverage the old one did.

While the result was the same before, this makes it more obvious.
2017-11-21 20:14:12 -08:00
Vishnu Ks
766511e519 actions: Mark all messages as read when user unsubscribes from stream.
This fixes a bug where, when a user is unsubscribed from a stream,
they might have unread messages on that stream leak.  While it might
seem to be a minor problem, it can cause significant problems for
computing the `unread_msgs` data structures, since it means we need to
add an extra filter for whether the user is still subscribed, either
in the backend or in the UI.

Fixes #7095.
2017-11-21 20:09:17 -08:00
Garvit
52069998eb compose: Preserve links when pasting html.
This uses the to-markdown.js library to do all the hard work of
parsing HTML and turning it into markdown and not e.g. uploaded files.

Tweaked by tabbott to better scope when it activates to just include
pastes of HTML content.

Fixes #5853.
2017-11-21 19:52:47 -08:00
Tim Abbott
9fa58a3c16 compose_ui: Automatically resize textarea after adding new syntax.
This fixes existing problems as well as an upcoming problem that
copy-and-pasting in markdown should usually expand the compose text
area.
2017-11-21 19:52:47 -08:00
Rishi Gupta
d400b10282 docs: Reword GSoC section of contributing.md. 2017-11-21 19:32:27 -08:00
Tim Abbott
1c9a28d0d8 ldap: Use simpler ordering for handling successful auth.
common_get_active_user returns None if it finds any problems.
2017-11-21 19:08:45 -08:00
Tim Abbott
e0b56c72de ldap: Simplify logic for user creation.
self._realm can't be None here with the new logic in authenticate().
2017-11-21 19:08:45 -08:00
Tim Abbott
e91051b1cd ldap: Remove some unnecessary indentation.
We created this redundant pair of conditionals in a preceding commit,
in order to match the indentation of an `except` block so as to slice
the diffs extra finely as we're refactoring auth code.
2017-11-21 19:06:19 -08:00
Tim Abbott
c4c8879cf7 ldap: Fix the error message for deactivated users. 2017-11-21 18:35:05 -08:00
Tim Abbott
97f1c2a72a ldap: Use new helper for checking realm status.
We intentionally don't fix the indentation that now feels ridiculous
below in order to make it easier to see what's actually changing in
this commit.
2017-11-21 18:35:04 -08:00
Tim Abbott
104a8de148 ldap: Shrink unnecessary scope of missing user block.
This is a pure refactor, and will help simplify the change in the next
commit.
2017-11-21 18:30:51 -08:00
Tim Abbott
e100935527 auth: Move LDAP check for whether backend is enabled earlier.
The previous logic felt fairly convoluted.
2017-11-21 18:30:51 -08:00
Tim Abbott
195a78ad11 auth: Convert EmailAuthBackend to use new helper.
This lets us delete some duplicate code, since common_get_active_user
handles an account in the wrong subdomain for us.

Also lets us delete the now-unused common_get_active_user_by_email.
2017-11-21 18:30:51 -08:00
Tim Abbott
8c21619be8 auth: Move checks for password_auth_enabled earlier.
This way, we don't attempt to evaluate whether the user's account is
active (etc.) until after we've checked the backend is enabled.  This
won't change the result of actual auth, but feels more readable.
2017-11-21 18:30:29 -08:00
Tim Abbott
3bfb19b5f3 Convert EmailAuthBackend and LDAPAuthBackend to accept a realm. 2017-11-21 18:23:50 -08:00
Tim Abbott
53224a16a9 EmailAuthBackend: Convert a return to assert for a now-impossible case. 2017-11-21 18:23:50 -08:00
Tim Abbott
1b95b098dd auth: Clarify comments explaining the GoogleMobileOauth2Backend. 2017-11-21 18:23:50 -08:00
Tim Abbott
23d791ca1b auth: Convert GoogleMobileOauth2Backend to use new helper.
That logic was now just duplicate code.
2017-11-21 18:23:49 -08:00
Tim Abbott
caddef9279 auth: Invert conditionals in GoogleMobileOAuth2Backend.
This will help make the flow more readable.
2017-11-21 18:23:49 -08:00
Tim Abbott
fee2e36800 auth: Set valid_attestation for Google auth backend always.
This is a behavior change, though we don't check the value in the
caller regardless.  It just seems more logical for us to correctly
report to the caller whether the Google auth itself was valid
unconditionally.
2017-11-21 18:23:49 -08:00
Tim Abbott
3c15f442fe auth: Check for GoogleMobileOauth2Backend being enabled earlier. 2017-11-21 18:23:49 -08:00
Tim Abbott
a7d51127fb auth: Convert GoogleMobileOAuth2Backend to accept a realm object. 2017-11-21 18:23:49 -08:00
Tim Abbott
37acfb4e90 auth: Convert DevAuthBackend to use new helper. 2017-11-21 18:23:49 -08:00
Tim Abbott
fa8eab303a auth: Check for DevAuthBackend being enabled earlier. 2017-11-21 18:23:49 -08:00
Tim Abbott
07bc31f818 auth: Convert DevAuthBackend to accept a realm object. 2017-11-21 18:23:49 -08:00
Tim Abbott
4968631d1b auth: Convert DevAuthBackend to use a unique argument pattern.
This helps ensure that we won't accidentally activate this backend on
other code paths.
2017-11-21 18:23:49 -08:00
Tim Abbott
f2d3258a56 auth: Rewrite RemoteUserBackend to use new helper. 2017-11-21 18:23:49 -08:00
Tim Abbott
73df431b88 auth: Check for RemoteUserBackend being enabled earlier.
This is possible now that we have a realm object before fetching the
UserProfile object.
2017-11-21 18:23:49 -08:00
Tim Abbott
d63e9f240c auth: Remove unnecessary remote_user=None code path.
This code path was only required because we had remote_user set as a
positional argument here, and thus we'd be running this auth backend's
code when actually using another auth backend (due to how Django auth
backends are selected based on argument signature).
2017-11-21 18:23:49 -08:00
Tim Abbott
387c9109ec auth: Convert RemoteUserBackend to accept a realm object. 2017-11-21 18:23:49 -08:00
Tim Abbott
fb6abe1b1e auth: Rewrite DummyAuthBackend to not block email reuse.
This require some care to ensure we still provide the same nice error
messages for the case of a user who has an account, just not with this
organization.

Also, we fix the fact that the docstring was (and I think always has
been) at best confusing and perhaps even inaccurate.
2017-11-21 18:23:26 -08:00
Tim Abbott
f17974ab32 DummyAuthBackend: Require being passed a realm object.
We should now always know the realm in our auth code paths.
2017-11-21 18:22:37 -08:00
Tim Abbott
236c4b5d96 contributing: Improve discussion of internships. 2017-11-21 18:19:46 -08:00
Tim Abbott
4832d34821 docs: Add a bit of discussion of GSoC. 2017-11-21 17:54:15 -08:00
Vishnu Ks
34689370cd settings: Create UI and backend for setting signups stream. 2017-11-21 17:39:51 -08:00
Vishnu Ks
3d2c9c6098 models: Replace core team with Realm.INITIAL_PRIVATE_STREAM_NAME. 2017-11-21 17:39:51 -08:00
Vishnu Ks
a0275a6257 actions: Send new user messages to signup_notifications_stream. 2017-11-21 17:39:50 -08:00
Rishi Gupta
42652713c8 onboarding: Refactor away setup_initial_private_stream.
It is a confusing name, now that the stream creation part has been taken
away.
2017-11-21 17:39:50 -08:00
Vishnu Ks
3d17897563 onboarding: Move signup notifications stream creation to do_create_realm. 2017-11-21 17:39:50 -08:00
Vishnu Ks
08aca174fe models: Add signup_notifications_stream attribute to Realm. 2017-11-21 17:39:50 -08:00
Tim Abbott
089ff8a0ae backends: Convert authenticate methods to modern type annotations. 2017-11-21 11:47:26 -08:00
Tim Abbott
708872f361 populate_db: Use call_consume_in_tests when generating test data.
We'd rather this work be just executed immediately, rather than
queued, since queued events can confuse the queue workers if the
database is dropped and recreated repeatedly.
2017-11-21 09:43:54 -08:00
Tim Abbott
84b9147fe3 gitignore: Add static/generated/icons. 2017-11-21 09:27:04 -08:00
Rohitt Vashishtha
5221ea5db5 settings: Make CSS selector more specific in table rows in org settings.
Fixes #7374. Since we use `table-layout: fixed`, the width of the first
row are applied to all the remaining rows, thus wrapping all the columns
to 20% width. This is fixed by making the selector specific to only
user_rows and not the editable data row.
2017-11-21 09:12:55 -08:00
derAnfaenger
41a2032d71 docs: Add 'requirements.txt' to bot structure outline. 2017-11-21 09:08:48 -08:00
Steve Howell
4a6c3eeb98 Use realistic filepaths in zuliprc docs and hints.
The first part of this change is to have the "Your bots"
tooltip not lie about creating `.zuliprc`, because it
doesn't put a dot in front of the file.

And then the more significant change here is to make
the "Running a bot" documentation use realistic filepaths,
both in terms of where the download typically puts the file,
and where you want to move it to.
2017-11-21 07:32:24 -08:00
Cynthia Lin
aa50fae4ba portico: Add anchor link support to API and user docs.
Fixes #7432.
2017-11-20 17:23:19 -08:00
akashnimare
9d973129ab user docs: Update compose box screenshots. 2017-11-20 17:14:01 -08:00
akashnimare
b97bb3a69d frontend: Move checkbox to the left of label text
Generally, the checkbox should come 'before' the label text.
2017-11-20 17:14:01 -08:00
rht
bff736868e Generate custom-icon-webfont on each provision or update-prod-static.
Fixes #7354.
2017-11-20 16:36:49 -08:00
David Rosa Tamsen
327bb05733 docs: Make index page easy to find.
This commit adds an Index link to bottom of nav bar.

Fixes #7416.
2017-11-20 16:33:04 -08:00
Tim Abbott
73e4d647c7 casper: Add a few more explicit waits to message editing tests.
This is a second attempt at fixing a casper test flake we've been
having recently.
2017-11-20 16:18:34 -08:00
Tim Abbott
c7f47f5477 casper: Use casper.then() more consistently in editing tests.
Hopefully, this will fix the test flake problems we've been having
with this test since upgrading Casper.
2017-11-20 16:04:26 -08:00
Greg Price
0b543bfc0e docs: Rewrite certbot discussion, to enjoy the new automation.
This doesn't touch the main path through the install docs; that will
see a broader rewrite soon as we make outbound email optional for a
nascent server, make the hostname and admin email into mandatory
installer flags, and then radically simplify the instructions by
removing mandatory editing of `settings.py` and folding most of what's
left into the installer.
2017-11-20 15:52:07 -08:00
Greg Price
de2a2d0dfa docs: Send people to install instructions for latest release.
Pointing these at the latest release, rather than the latest version
in master, allows us to make changes to the installer and document
them properly in master, without making the instructions confusingly
wrong for people who just go to the website or the GitHub repo page
and follow instructions to install.
2017-11-20 15:52:07 -08:00
Harshit Bansal
5111aeac41 tools: Rewrite test-locked-requirements to be more performant.
This commit modifies `test-locked-requirements` to use some caching
so that we don't need to use the `update-locked-requirements` tool
everytime for checking the validity of locked requirements as it is
slow.

Fixes: #6969.
2017-11-20 15:35:47 -08:00
Harshit Bansal
40fe6239c5 build_emoji: Migrate to python3. 2017-11-20 15:30:58 -08:00
Harshit Bansal
df4d10a3df custom_check.py: Fix the comment for ignoring long lines.
Change `#ignorelongline` to `# ignorelongline` as comments must a
have whitespace after `#`.
2017-11-20 15:29:47 -08:00
Tim Abbott
29408d24ff emoji: Rework reactions validation to have a single function.
This feels more readable to me, and also identified a couple cases
where we were missing test coverage.
2017-11-20 15:27:21 -08:00
Tim Abbott
2d4c7b771a reactions: Move legacy endpoint code further down in file.
This helps ensure that new contributors working on the reactions code
read the stuff we use now first.
2017-11-20 15:27:21 -08:00
Tim Abbott
80a2a36dd1 reactions: Rename legacy reactions for greater clarity. 2017-11-20 15:27:21 -08:00
Harshit Bansal
87b523f3ef emoji.py: Refactor emoji data consistency checking functions.
Inorder to provide more explicit error messages I have merged the
`emoji_code_is_valid()` and `emoji_name_is_valid()` functions into
`check_emoji_code_consistency()` and `check_emoji_name_consistency()`
respectively.
2017-11-20 15:27:21 -08:00
Harshit Bansal
9a4d5fe1f8 test_reactions.py: Extract EmojiBaseReaction test class. 2017-11-20 15:27:20 -08:00
Harshit Bansal
8a4fc9970f reactions.js: Migrate webapp to use the new reactions API.
Fixes: #6909.
2017-11-20 15:27:20 -08:00
Tim Abbott
6981ac3d2f requirements: Add back explicit typing dependencies.
These are needed to make the output the same on Trusty and Xenial.
2017-11-20 13:47:16 -08:00
Rishi Gupta
27babcf92b portico: Update error message for deactivated user.
The installation admin is not the right person to get support requests from
deactivated users, regardless of the situation.

Also updates the wording to be a bit more concise.
2017-11-20 13:40:51 -08:00
Rishi Gupta
f202645bbd portico: Rename community forum to community chat. 2017-11-20 13:40:51 -08:00
Rishi Gupta
ef6e383e57 portico: Add block on video calls to features.html. 2017-11-20 13:40:51 -08:00
Harshit Bansal
e75f0c1ee4 requirements: Rename requirements files.
This commit renames various source requirements files like `dev.txt`,
`mypy.txt` etc to `dev.in`, `mypy.in` etc and various locked requirements
files like `dev_lock.txt`, `mypy_lock.txt` etc to `dev.txt`, `mypy.txt`
etc. This will help in emphasizing to the user that *.in are actually
input to `update-locked-requirements` tool which should be run after
updating any of these.
2017-11-21 02:38:26 +05:30
Harshit Bansal
95b3f2e745 requirements: Add mypy.txt and docs.txt to locked requirements framework. 2017-11-21 02:38:26 +05:30
Tim Abbott
e81b64d511 docs: Move remotedev docs to docs/development/ and fix links.
Thanks to SivagiriVisakan for pointing out the issues here; I ended up
redoing this since the doc really belongs in that directory.
2017-11-20 11:13:59 -08:00
Tim Abbott
1d06869743 provision: Bump PROVISION_VERSION for recent email changes.
It might be a good idea to make the `tools/inline-email-css` caching
better so we don't need to do this.
2017-11-20 10:57:44 -08:00
Tim Abbott
25ddba99f6 lint: Ban general use of user_profile.save().
This often can cause minor caching problems.

Obviously, it'd be better if we had access to the AST and thus could
do this rule for UserProfile objects in general.
2017-11-20 10:57:08 -08:00
Vishnu Ks
432c9d3449 email_log: Reset the value of email after email change process.
This commit actually needs only user_profile.save() line
but it's more readable with both the lines.
2017-11-20 10:45:16 -08:00
Tim Abbott
0667a62244 password reset: Simplify password reset form logic.
Now that we're generating the URL inside the Python code, we can clean
up the context logic.
2017-11-20 10:40:33 -08:00
Vishnu Ks
9c50819dd6 email: Add reset button to password reset email. 2017-11-20 10:35:03 -08:00
Tim Abbott
c8edbae21c password reset: Fix error message for invalid realm.
This is a lot cleaner than the previous model.

Basically rewritten by Vishnu Ks to actually work :).
2017-11-20 10:34:55 -08:00
Tim Abbott
10fbafa13e PasswordResetTest: Clean up mocking of logging.info. 2017-11-20 10:32:40 -08:00
Umair Khan
95ba3e7cbb password_reset: Send email unconditionally.
This was basically rewritten by tabbott, because the code is a lot
cleaner after just rewriting the ZulipPasswordResetForm code to no
longer copy the model of the original Django version.

Fixes #4733.
2017-11-20 10:32:40 -08:00
Balaji2198
489feaf139 docs: Add a few more articles to subsystems TOC.
These are subsystems documentation, which was accidentally not listed
in the TOC.
2017-11-20 10:22:06 -08:00
Balaji2198
d6fb70e8dc docs: Move users.md to subsystems/ and give it a title.
Edited by tabbott to improve the users.md title and update the TOC in
this commit.
2017-11-20 10:21:53 -08:00
Balaji2198
1f43252903 docs: Update TOC in production to include SSL and email.
This adds a few missing entries to the TOC, which hadn't made sense
back when Zulip's ReadTheDocs didn't have the new collapsing feature.

Tweaked by tabbott to also give the SSL certificates doc an
appropriate title for its new role.
2017-11-20 10:21:02 -08:00
Balaji2198
c3ac9894a5 docs: Move migration-renumbering.md to subsystems/.
It belongs in that part of the documentation.  We also update the
links in docs/subsystems/schema-migrations.md.
2017-11-20 10:20:31 -08:00
Balaji2198
a5e605d73c docs: Delete brief-install-vagrant-dev.md
This was the old version of our installation docs, and hasn't been
used or updated in about a year.
2017-11-20 10:20:15 -08:00
Tommy Ip
02be1a11cc docs: Document Firefox's screenshot feature. 2017-11-20 10:01:13 -08:00
Tommy Ip
3a397b2f2d /team: Left align BDFL name and role in non-mobile UI. 2017-11-20 09:44:17 +00:00
Eeshan Garg
02a32e246e webhooks/gitlab: Support test payloads without an "action" attribute.
Payloads that don't have a payload['object_attributes']['action']
attribute are generated when GitLab sends a test payload to verify
if the webhook was set up successfully. In this case, we should
send a message notifying that the webhook was configured
successfully.
2017-11-19 20:56:10 -08:00
Eeshan Garg
9138d3b8d7 integrations: Move integration-specific context to integration_doc.
Instead of populating the context dict with integration-specific
information in render_markdown_path, we now do that in
zerver.views.integrations.integration_doc instead.

Fixes #7401.

Tweaked by tabbott to use cast to handle the typing issues here.
2017-11-19 20:48:46 -08:00
Rishi Gupta
fca765d0f9 portico: Update text on /team. 2017-11-19 20:38:08 -08:00
Tim Abbott
46ba76e245 Fix broken link to GitHub CONTRIBUTING guide. 2017-11-19 20:31:27 -08:00
Shubham Dhama
8b152fc109 email: Fix identification of chrome as safari on ios
The user agent(UA) string for chrome on ios contains "crios" instead of "chrome".
Added the missing test for corresponding case.
Fixes: #7441.
2017-11-19 17:07:33 -08:00
Rishi Gupta
f6bf11f5e6 portico: Add for/mystery-hunt. 2017-11-19 17:04:17 -08:00
rht
33b1a541d7 zerver/lib: Use python 3 syntax for typing.
With tweaks by tabbott to fix line spacing.
2017-11-18 16:09:04 -08:00
rht
4a07214725 zerver/tests: Use python 3 syntax for typing. 2017-11-18 15:41:16 -08:00
rht
6c28c7e879 zerver/tests: Use python 3 syntax for typing. 2017-11-18 15:35:57 -08:00
Greg Price
13aa23eb40 provision: Run clean-unused-caches.
This prevents the caches in /srv from growing to fill up the disk --
e.g., on my laptop after 6 months of regular development the venv cache
was 12G and the NPM cache 5G, making them by far the largest disk hogs
on the machine.

It costs about 0.4s, apart from any time spent actually removing
things.  This is a little annoyingly slow to be adding to every
provision, and seems like it could be optimized, but I think already
worth it as is.
2017-11-18 15:04:08 -08:00
David Rosa Tamsen
a6510c4626 docs: Remove integration docs from tutorials/index.
Merged PR 7414 moved integration docs to /api, so
this commit updates tutorials/index.rst accordingly.
2017-11-17 18:44:54 -08:00
Tim Abbott
18369cb5ad JWT: Fetch the subdomain earlier in the auth code path. 2017-11-17 17:33:28 -08:00
Tim Abbott
462b7a1b3c tests: Expand test coverage of OurAuthenticationForm.
This adds tests for a new more cases.  Some were already covered
elsewhere in the codebase, but it feels best for LoginTest to fully
cover OurAuthenticationForm.
2017-11-17 17:31:38 -08:00
Tim Abbott
81adc92db6 actions: Use get_system_bot for fetching WELCOME_BOT. 2017-11-17 17:25:56 -08:00
Tim Abbott
cd95c09fca forms: Use an AssertionError for unexpected DNS errors. 2017-11-17 17:25:56 -08:00
Tim Abbott
94d188fd7d docs: Fix broken anchor links after API docs migration. 2017-11-17 15:56:05 -08:00
Tim Abbott
1ed50ee858 tests: Pass a realm option to login for non-zulip realms.
This better matches the model of how having multiple realms should
work: you need to specify which realm you're logging into.
2017-11-17 15:32:42 -08:00
Tim Abbott
1e334f41ed test_subs: Fix nondeterministic failures in default stream tests.
Here we sort the streams before comparing them.
2017-11-17 15:32:42 -08:00
Greg Price
a194f17c2a gitignore: Ignore several artifacts of a prod deployment.
This allows `git status` to normally be clean in a prod deployment,
so that `git describe --dirty` carries some signal.
2017-11-17 14:32:34 -08:00
Greg Price
79a5ddc68f gitignore: Fix format for excluding .cache/.
Comments in gitignore files must be on their own line.
2017-11-17 14:26:40 -08:00
Greg Price
bd5905da5d error_notify: Use git describe --always.
This way, even if the repo lacks any tags, we still
at least get the commit ID.
2017-11-17 14:19:20 -08:00
Tim Abbott
a0cfe45150 analytics: Wrap some longer lines. 2017-11-17 13:19:48 -08:00
rht
d1689b5884 analytics: Use python 3 syntax for typing. 2017-11-17 13:16:49 -08:00
Tim Abbott
b2637c8400 docs: Fix broken link due to integration guide migration. 2017-11-17 12:25:33 -08:00
derAnfaenger
73915a9631 docs: Move integration docs to /api. 2017-11-17 11:58:54 -08:00
Umair Khan
06b57e8512 style: Merge css of social login/register buttons. 2017-11-17 11:44:13 -08:00
Umair Khan
1e3aa55f4f github: Override get_authenticated_user.
Now we have moved the `do_auth` function to `SocialAuthMixin`. Instead
of overriding `do_auth`, derived class is now expected to override
`get_authenticated_user`.

`do_auth` now contains code which is expected by all backends.
2017-11-17 11:44:13 -08:00
Andy Perez
83f563aeff bugdown: Properly parse empty blockquotes.
The character ">" now only starts a blockquote if the resulting
blockquote would be non-empty.  Thus, by itself, ">" is now
interpreted literally by bugdown, fixing #687.  The message
with contents consisting of ">>>" is now parsed as a doubly
(not triply) nested blockquote with contents ">".  Properly
formed blockquotes have identical behavior as before, but now
bugdown can no longer produce empty blockquotes as output.

Fixes #2886, #687.
2017-11-17 11:41:44 -08:00
Andy Perez
bdaf3275f7 message feed: Fix display height of empty messages.
Ideally, empty messages are never created.  However, sometimes even
non empty messages can act as if empty, such as one consisting only
of an opening and closing blockquote tag.  This sets the
.message_content to have a minimum height equal to the line height.
This is overridden with zero (the default) in the case of collapse.
2017-11-17 11:40:22 -08:00
David Rosa Tamsen
4906bc8e4a docs: Prevent readthedocs from overriding collapse_navigation setting.
Expand bullets "[+]" show up on locals instance, but they
do not show up online on readthedocs. The expand icon is valuable
to indicate that each section has more content.

The problem is readthedocs appends code to conf.py that overrides the
html_theme_options prior to a build. This commit prevents this from
happening so that collapse_navigation remains set to False.

In response to merged PR 7326.
2017-11-17 11:28:37 -08:00
Tim Abbott
57c78da915 test-documentation: Build docs in parallel.
We already do this by default in tools/build-docs, but since we
migrated test-documentation to not run that directly (to disable
collapsing), we need to add the recent parallelism fix here too.

It saves about 5-10s when running this test suite for me, which is
good, but definitely leaves me feeling like there could be more
improvement.
2017-11-17 11:06:56 -08:00
Tommy Ip
f1eb9ff403 gitignore: Add .cache/. 2017-11-17 11:03:08 -08:00
Tim Abbott
026410dd1b api: Fix a typo in an anchor tag URL. 2017-11-17 11:03:08 -08:00
Tim Abbott
484ded60ce docs: Fix unintentional whitespace in ReadTheDocs homepage. 2017-11-17 11:03:08 -08:00
Mohd Ali Rizwi
2b858ab47b api: Fix code blocks in headings.
These didn't look good, and were unnecessary.

Fixes part of #7395.

Commit message tweaked by tabbott.
2017-11-17 11:03:08 -08:00
Brock Whittaker
2b6587c6bf overlays: Move overlays earlier in index.html.
It appears as though the ordering of the overlays in the DOM is
overriding their z-index in Safari on mobile. This moves them up to
the top of the template ahead of the header so that the header will no
longer display above the overlays in positioning.

Fixes: #7248.
2017-11-17 11:03:08 -08:00
Tim Abbott
1b28ddd8a7 requirements: Update to new pyoembed release.
This should mean we no longer need to maintain a fork.
2017-11-17 11:03:08 -08:00
Brock Whittaker
4fb7292dd4 message-feed: Add dark mode support for inline code. 2017-11-17 10:30:24 -08:00
Brock Whittaker
874598b291 left-sidebar: Change icons to be translucent.
This changes the icons to be translucent rather than grey and also
makes them get darker on hover rather than lighter (which didn’t really
make sense) on the normal theme.
2017-11-17 10:30:24 -08:00
Brock Whittaker
5081294c5b streams: Remove unnecessary font color declaration, change to translucent.
This changes a declaration from grey to translucent and another to
remove an unnecessary color declaration.
2017-11-17 10:30:23 -08:00
Brock Whittaker
015cd65e8f message-feed: Change borders from grey to translucent.
This changes the borders from grey to translucent and bins them to the
nearest tenth of opacity.
2017-11-17 10:30:23 -08:00
Brock Whittaker
7d2607c919 settings: Change borders from grey to translucent.
This also changes the .settings-section table borders to be darker
which keeps it inline with the rest of the styling.
2017-11-17 10:30:23 -08:00
Brock Whittaker
30f45ac061 reactions: Change from grey to translucent.
This keeps the look the same on a white background but works better on
color backgrounds, as it shares a similar saturation.
2017-11-17 10:30:23 -08:00
Brock Whittaker
d13e556923 reactions: Remove unecessary color declaration. 2017-11-17 10:30:23 -08:00
Brock Whittaker
e14e61c22e compose: Change borders from gray to translucent.
This works better on color backgrounds while staying the same on white.
The compose input borders are also darkened slightly.
2017-11-17 10:30:23 -08:00
Brock Whittaker
83f329b41a components: Change checkboxes from grey to translucent.
This works better with color background and looks the same on white.
2017-11-17 10:30:23 -08:00
Brock Whittaker
aeed2e6863 dark-mode: Remove unnecessary CSS and fix dark mode bugs. 2017-11-17 10:30:18 -08:00
Brock Whittaker
151e5b0e51 app: Remove column-middle background color.
The declaration making the background color white seems to be
unnecessary.
2017-11-17 08:44:04 -08:00
Brock Whittaker
f5f217570c message-feed: Change private message blue to be translucent.
This looks the same on white, different on dark blue.
2017-11-17 08:44:04 -08:00
Brock Whittaker
2d9a570ceb drafts: Remove unnecessary white background on messages.
This removes the white background behind the messages that isn’t useful
since they are already on a white background.
2017-11-17 08:44:04 -08:00
Brock Whittaker
53616cc714 gear-menu: Inherit body color.
Instead of overriding the default link color with grey, just inherit
the body color.
2017-11-17 08:44:04 -08:00
Brock Whittaker
a77b41dce4 navbar: Remove background attribute on search bar.
This removes the background color declaration on the search bar so it
can inherit the standard input background color.

navbar: Let search bar inherit from base color.
2017-11-17 08:44:04 -08:00
Brock Whittaker
3df96a27cc message-feed: Make stream labels inherit color.
Instead of overriding the default link color with grey, just inherit
the base color.
2017-11-17 08:44:04 -08:00
Brock Whittaker
ff39aa0eb5 message-feed: Remove white backgrounds on messages.
They aren’t necessary either I don’t believe.
2017-11-17 08:44:04 -08:00
Brock Whittaker
cd3ea16785 navbar: Remove white background.
It’s never been necessary afaik.
2017-11-17 08:44:04 -08:00
Brock Whittaker
e0e7c0091b compose: Change from grey to translucent black. 2017-11-17 08:44:04 -08:00
Brock Whittaker
3c4900205c streams: Fix width bug with stream creation form footer.
The footer was a few pixels short and would create a gap in the bottom
right hand corner of the streams overlay when the stream creation flow
is open.
2017-11-17 08:44:04 -08:00
Brock Whittaker
1514ea9be6 streams: Inherit base color rather than redefining text color.
This also removes an unecessary font-weight declaration that
was immediately being overridden.
2017-11-17 08:44:04 -08:00
Brock Whittaker
efb7206756 settings: Change grey colors to translucent black. 2017-11-17 08:44:04 -08:00
Brock Whittaker
e806300b51 settings: Use .modal-bg class to control background color.
This lets the `.modal-bg` class dictate background color instead of
manually setting it for all modals.
2017-11-17 08:44:04 -08:00
Brock Whittaker
537c1c211b right-sidebar: Remove base color definition.
The right-sidebar should just inherit the color of the body, not invent
a new lighter shade of grey.
2017-11-17 08:44:04 -08:00
Brock Whittaker
3ebccda703 left-sidebar: Make <ul> links inherit body color.
The links were overridden with a dark grey to not display normal link
color but should really just inherit the body color.
2017-11-17 08:44:04 -08:00
Brock Whittaker
9852861f8a compose: Change white background to be on #compose.
This changes the white background placement to be on #compose rather
than .compose-content.
2017-11-17 08:44:04 -08:00
Brock Whittaker
ca46a2152b popovers: Restyle border-bottom below avatar in user popovers.
This styles the border-bottom to be an opacity based solution to
work the same with the normal mode and better with dark mode.
2017-11-17 08:44:04 -08:00
derAnfaenger
6049cd27b1 migrations: Fix conflict. 2017-11-17 08:24:56 -08:00
derAnfaenger
395f1e9270 embedded bots: Add database config storage.
Storage limititations are only set on the value of
a config entry, since this is the only user-accessible
part of the schema. Keys are statically set by each
embedded bot.
2017-11-16 23:06:38 -08:00
Sarah
35e60d5e14 new-feature-tutorial: Add references to Django.
With some tweaks by tabbott to update links for our recent
documentation migration.

Fixes #670.
2017-11-16 22:57:31 -08:00
Aditya Bansal
dd037df2c4 thumbor: Add dependencies and virtualenv setup script.
In this commit we add new dependencies needed for running thumbor.
Also we add the script for creating the virtual environment ready
for thumbor.
Note: Thumbor will use python2 and thus have different virtualenv
dedicated to it.
Credits to @TigorC and @joshland as well for there work on this.
2017-11-16 22:38:29 -08:00
Aditya Bansal
66060c703c update-locked-requirements: Add py2 option to compile requirements.
In this commit we add a new option which could be used to specify
python version. When 'py2' is specified, future/futures are not
removed from the requirements lock file generated.
2017-11-16 22:34:14 -08:00
Aditya Bansal
79576797b0 thumbor: Auto generate thumbor_key and add it to zulip settings. 2017-11-16 22:34:14 -08:00
Tim Abbott
fa0fb9e299 casper: Switch to use a newer casper off master.
Newer casper should fix some problems we've had with contenteditable.
2017-11-16 22:20:38 -08:00
Tim Abbott
7b5ae1ee38 node: Update yarn.lock. 2017-11-16 22:20:38 -08:00
Tim Abbott
41a0fd97c4 build-release-tarball: Improve help/error output. 2017-11-16 22:19:58 -08:00
Tim Abbott
780d83efab build-release-tarball: Add support for --help. 2017-11-16 22:19:58 -08:00
Tim Abbott
8dc82f97c7 python: Wrap long def lines in test files.
We don't have our linter checking test files due to ultra-long strings
that are often present in test output that we verify.  But it's worth
at least cleaning out all the ultra-long def lines.
2017-11-16 22:00:53 -08:00
rht
4f5b1c0a5a zerver/tests: Use python 3 syntax for typing in most files. 2017-11-16 21:52:01 -08:00
Tim Abbott
569cb1d2fb docs: Move readme-symlink symlink to be just called readme.
This name was always a little confusing.
2017-11-16 21:43:25 -08:00
Vishnu Ks
068912ca7d tests: Add test for default stream group signup flow. 2017-11-16 21:17:31 -08:00
Vishnu Ks
cc553125a1 tests: Move check_user_subscribed_only_to_streams to test_classes ZulipTestCase. 2017-11-16 21:17:31 -08:00
Vishnu Ks
1b9b142d51 test_signup: Store return value of sorted.
Sorted does not sort in-place.
2017-11-16 21:17:31 -08:00
Rishi Gupta
8b7d78a7d5 portico: Add link to chat-zulip-org.html to footer. 2017-11-16 21:15:24 -08:00
Rishi Gupta
f0807353ae settings: Remove ABOUT_LINK_DISABLED.
Was introduced in 0f4bbc8, I think because the /team page was unfinished at
the time.
2017-11-16 21:15:24 -08:00
Harshit Bansal
d9c2f613e3 api: Add new endpoint for reactions.
This endpoint will allow us to add/delete emoji reactions whose emoji
got renamed during various emoji infra changes. This was also a
required change for realm emoji migration.

This commit was tweaked significantly by tabbott for greater clarity
(with no changes to the actual logic).
2017-11-16 20:52:15 -08:00
Vishnu Ks
40fca20c51 droplets: Run git clean -f after creating droplet. 2017-11-16 19:47:42 -08:00
Vishnu Ks
75601f660d droplets: Always rebase instead of merge during git pull. 2017-11-16 19:47:42 -08:00
Greg Price
3828305305 error_notify: Try git describe too.
Tested for graceful degradation both with `git` not existing and the
`.git` directory not existing.
2017-11-16 19:15:12 -08:00
Greg Price
41ecdd8d83 error_notify: Add some idea of the deployed code version.
Tested in dev with the help of our handy /emails/ display.
2017-11-16 19:15:12 -08:00
Greg Price
4b5c52fc99 queue: Prevent an AttributeError rather than swallowing it.
When the RabbitMQ server disappears, we log errors like these:

```
Traceback (most recent call last):
  File "./zerver/lib/queue.py", line 114, in json_publish
    self.publish(queue_name, ujson.dumps(body))
  File "./zerver/lib/queue.py", line 108, in publish
    self.ensure_queue(queue_name, do_publish)
  File "./zerver/lib/queue.py", line 88, in ensure_queue
    if not self.connection.is_open:
AttributeError: 'NoneType' object has no attribute 'is_open'

During handling of the above exception, another exception occurred:
[... traceback of connection failure inside the retried self.publish()]
```

That's a type error -- a programming error, not an exceptional
condition from outside the program.  Fix the programming error.

Also move the retry out of the `except:` block, so that if it also
fails we don't get the exceptions stacked on each other.  This is a
new feature of Python 3 which is sometimes indispensable for
debugging, and which surfaced this nit in the logs (on Python 2 we'd
never see the AttributeError part), but in some cases it can cause a
lot of spew if care isn't taken.
2017-11-16 18:33:14 -08:00
Brock Whittaker
16d06c6a78 portico-header: Remove border between image and realm name.
This removes the border between the realm image and the realm name in
the portico header that is shown when logged in.
2017-11-16 16:03:24 -08:00
Greg Price
0cc8d243e4 build-release-tarball: Fold away the confusing variable TMP_CHECKOUT.
Even where this is actually used for a temporary checkout, it obscures
the relationship between this and $TMPDIR -- and some of our logic
depends on that.  In other places, it isn't actually even a checkout.
In all cases, the expanded version is clearer.
2017-11-16 15:54:34 -08:00
Greg Price
3d1211edcf build-release-tarball: Cut a recently-obsoleted comment.
We no longer use .gitattributes for this purpose (since bfaf0fb3b),
so this comment isn't true anymore.
2017-11-16 15:54:34 -08:00
Greg Price
18f9e18324 build-release-tarball: Drop likely-bitrotted macOS support.
This script, and tools/update-prod-static which it relies on,
have kept getting more complex since this conditional was added
in 2013, and the places we rely on GNU features have probably
multiplied beyond `mktemp -d`.  It's unlikely this works on
macOS with BSD tools now, and it'd be hard to maintain that way
if it did; drop the pretense.
2017-11-16 15:54:34 -08:00
Greg Price
5a2f3fe9c2 build-release-tarball: Reorder a bit for clarity.
This puts our fiddling with the update-prod-static logfiles
immediately after we run update-prod-static.
2017-11-16 15:54:34 -08:00
Greg Price
93fbffebd7 build-release-tarball: Cut a redundant cleanup step.
There's no need to remove this file here -- the whole tree will be
removed a few commands later, and the `tar` command we do first, to
supplement our tarball with various generated files, is quite
selective and wouldn't look at this file anyway.
2017-11-16 15:54:34 -08:00
Greg Price
09a38ec5dc build-release-tarball: Cut a long-stranded comment.
This comment only made sense for about one week, in 2013;
the setting it points at was removed in e6ca5d265.
2017-11-16 15:54:34 -08:00
Greg Price
8d405da96c build-release-tarball: Use set +x consistently. 2017-11-16 15:54:34 -08:00
Greg Price
92e322a9d1 build-release-tarball: Add --authors-not-required.
This makes it not real annoying to run this in a development loop.
2017-11-16 15:54:34 -08:00
Eeshan Garg
ae6d30b60e requirements: Upgrade to fakeldap 0.6.1.
Tweaked by tabbott to remove the unnecessary GitHub indirection.
2017-11-16 15:23:44 -08:00
Sampriti Panda
a696141a25 search: Add more extensive logging for Unicode errors in highlight_string.
Tweaked by tabbott to provide finer-grained logging.
2017-11-16 15:08:16 -08:00
Mohd Ali Rizwi
66d658d7f1 docs: Use git clone -c to set git pull to rebase by default.
This updates the developer documentation to recommend `git clone -c`
to set the git pull mode to be rebase by default in the repository
configuration.

The hope is that this will help minimize how often new contributors
end up accidentally messing up their PRs by using `git pull`.

Tweaked by tabbott to fix broken links and optimize the language.

Fixes: #7022.
2017-11-16 14:35:02 -08:00
KiranS
92caa4abab docs: Add more troubleshooting cases to Vagrant guide. 2017-11-16 14:12:38 -08:00
Rishi Gupta
1a360ecd20 portico: Add code of conduct features to for/open-source.md.
We got asked about this from a potential user, and they seemed fairly
excited and confused by it. In particular, it wasn't obvious that
deactivating a user was the feature they were looking for.
2017-11-16 14:05:49 -08:00
Rishi Gupta
549401ede4 docs: Update emoji.md to explain new naming scheme. 2017-11-16 14:05:49 -08:00
Tim Abbott
e1f8d24166 lint: Fix tools tests.
These were broken when Travis wasn't running properly.
2017-11-16 13:59:40 -08:00
derAnfaenger
6a72fcff9c docs: Fix outdated bots guide link. 2017-11-16 13:58:07 -08:00
Tim Abbott
2563f93d46 test-help-documentation: Pass use_db=True.
With the new portico work we've done, the help documentation does
sorta depend on the database if you're logged in.  So it's best to
just require it for these tests.
2017-11-16 13:44:53 -08:00
Tim Abbott
cb4acf2aa4 docs: Lint rst files for trailing whitespace. 2017-11-16 13:20:50 -08:00
Tim Abbott
d9da8f859d lint: Check for absolute/relative link style in developer docs.
This should help avoid a pretty wide range of link bugs we've had in
the past.
2017-11-16 12:44:16 -08:00
Tim Abbott
bf77ad3a6e docs: Clean a few files of too-long lines.
We also document why the rest of them are still on the list.
2017-11-16 11:49:00 -08:00
Greg Price
011114397b docs: Fix some Markdown links missing a close-paren.
These were just introduced today.
2017-11-16 11:43:19 -08:00
Tim Abbott
6973f1d1ef docs: Fix unnecessary absolute links in docs/. 2017-11-16 11:39:59 -08:00
Tim Abbott
7c24e04223 lint: Fix long lines in README.md. 2017-11-16 11:38:13 -08:00
Rhea Parekh
8c4651d716 zerver/lib/actions.py: Fix translation bugs.
Fixes #7396.
2017-11-16 11:05:49 -08:00
Tim Abbott
638eb7a8e4 docs: Update links to ReadTheDocs to always use https.
This is better security practice.

We also add a lint rule to enforce this for the future.
2017-11-16 10:59:24 -08:00
Tim Abbott
054952a44a docs: Update links from codebase to point to ReadTheDocs. 2017-11-16 10:53:49 -08:00
Tim Abbott
07c2b205a4 docs: Update absolute links to point to new URLs.
This should get test-documentation and test-help-documentation passing
again after we moved everything around in the last commit.

There are a lot more absolute links (generally in code comments) to
update, but they are lower-priority and can be done in a follow-up
pass.
2017-11-16 10:08:22 -08:00
David Rosa Tamsen
7072fa5b37 docs: Reorganize developer docs to improve navigation.
This commit helps reduce clutter on the navigation sidebar.
Creates new directories and moves relevant files into them.
Modifies index.rst, symlinks, and image paths accordingly.

This commit also enables expandable/collapsible navigation items,
renames files in docs/development and docs/production,
modifies /tools/test-documentation so that it overrides a theme setting,
Also updates links to other docs, file paths in the codebase that point
to developer documents, and files that should be excluded from lint tests.

Note that this commit does not update direct links to
zulip.readthedocs.io in the codebase; those will be resolved in an
upcoming follow-up commit (it'll be easier to verify all the links
once this is merged and ReadTheDocs is updated).

Fixes #5265.
2017-11-16 09:45:08 -08:00
Harshit Bansal
3b95a6d2d9 bugdown: Fix a bug in the updation logic of markdown engines.
While fixing an issue related to email gateway messages not getting
rendered properly, I unknowingly introduced a bug in the markdown
engine updation code. This commit fixes it. The issue was that for
a realm having email gateway setup, updation of realm filters would
lead to the updation of only one of the markdown engines not both.
2017-11-15 22:47:11 -08:00
Harshit Bansal
b849c5e551 bugdown: Remove an unnecessary check in do_convert(). 2017-11-15 22:47:11 -08:00
Harshit Bansal
5e5bb02e39 bugdown: Remove make_realm_filters().
This commit removes `make_realm_filters()` and merges its functionality
in `make_md_engine()` and `maybe_update_markdown_engines()`.
2017-11-15 22:47:11 -08:00
Harshit Bansal
f9f9e92443 bugdown: Correct the descriptions of Bugdown config. 2017-11-15 22:47:11 -08:00
Harshit Bansal
e615a2ab4f bugdown: Simplify the "opts" parameter of make_md_engine(). 2017-11-15 22:47:11 -08:00
Harshit Bansal
e3f2f67d0e bugdown: Rename maybe_update_realm_filters().
This commit renames `maybe_update_realm_filters()` to
`maybe_update_markdown_engines()` which sounds closer
to the semantics.
2017-11-15 22:47:11 -08:00
Tim Abbott
64230b3bd5 populate_db: Remove the 'simple' realm.
The 'simple' realm was super broken and confusing for new users.  We
should replace this with having an easy way to make a new realm in
development, done properly.

Fixes #6116.
2017-11-15 22:42:05 -08:00
Umair Khan
98be0cc502 user-groups: Send delete user group event.
Fixes #7380
2017-11-15 22:35:43 -08:00
Umair Khan
cc76f7deac user-groups: Create check_delete_user_group. 2017-11-15 22:35:43 -08:00
Umair Khan
79f4a7627f user-groups: Send remove members event. 2017-11-15 22:35:23 -08:00
Umair Khan
cec3f19366 user-groups: Send add members event. 2017-11-15 22:35:23 -08:00
Umair Khan
eb48fab495 user-groups: Send description update event. 2017-11-15 22:35:23 -08:00
Umair Khan
5571122120 user-groups: Send name update event. 2017-11-15 22:35:23 -08:00
Umair Khan
912505317a user-groups: Send create group event. 2017-11-15 22:35:23 -08:00
Umair Khan
31efe951b7 user-groups: Fix function argument bug; pass group.
In remove_members_from_group_backend, we are passing user group to
remove_members_from_user_group. In remove_members_from_user_group,
expect user_group_id.
2017-11-15 22:35:23 -08:00
Umair Khan
66179ea295 bulk_add_members_to_user_group: Pass user group.
Previously we passed user group id. If we pass user group, send event is
easier.
2017-11-15 22:35:23 -08:00
Umair Khan
5ef3974e80 user_groups_in_realm_serialized: Sort groups. 2017-11-15 22:35:23 -08:00
Greg Price
a56fca81f1 setup-certbot: Require hostname and email.
The script already won't work without them; so if the user gets the
invocation wrong, give a halfway-reasonable error rather than just
crash into the ground.
2017-11-15 21:50:41 -08:00
Greg Price
df8548aaf1 setup-certbot: Fix the usage message, and add the recently-added options. 2017-11-15 21:50:41 -08:00
Greg Price
8f387ba4d4 setup-certbot: Add option to choose verification method.
This allows the installer to continue using this script for the
`standalone` method, while the no-argument form now uses the same
`webroot` method as the renewal cron job, suitable for running
by hand to adopt Certbot after initial install.
2017-11-15 21:50:41 -08:00
Greg Price
7c887a6741 setup-certbot: Use set -x.
When there's a failure, this can make it much less confusing
to figure out.
2017-11-15 21:50:41 -08:00
Greg Price
9adaf3417a install: Enforce a constraint on the options, and expand usage message. 2017-11-15 21:50:41 -08:00
Greg Price
84f956f5f1 certbot: Use --deploy-hook to get the cert actually served.
Certbot replaces the cert files under /etc/letsencrypt/live/,
which our nginx config refers to symlinks to; but it doesn't
tell nginx there's been an update, so nginx keeps serving the
old cert.

This is fine as long as nginx is restarted, or just told to
reload its config, at some point before the cert actually
expires about 30 days later.  Which is probably the common
case, but of course we should make it just work.  So, if we
actually renew a cert, tell nginx to reload its config now.
2017-11-15 21:50:41 -08:00
Greg Price
ae901309fc certbot: Control auto-renew with a zulip.conf setting.
This causes the cron job to run only when a Zulip-managed certbot
install is actually set up.

Inside `install`, zulip.conf doesn't yet exist when we run
setup-certbot, so we write the setting later.  But we also give
setup-certbot the ability to write the setting itself, so that we
can recommend it in instructions for adopting certbot in an
existing Zulip installation.
2017-11-15 21:50:41 -08:00
Greg Price
dd32348fca setup-certbot: Eliminate obnoxious wget spew. 2017-11-15 21:50:41 -08:00
Greg Price
3f1f70fae2 setup-certbot: Treat potential existing certs with kid gloves.
This helps make this script suitable to run on existing installations,
by mitigating any worry about clobbering existing certs with links to
the new ones, in case the admin changes their mind or was using the
certs for something else too.
2017-11-15 21:50:41 -08:00
Greg Price
dacf65b301 certbot: Move verification webroot under /var/lib/zulip .
If we were making an old-fashioned webroot where hand-written static
HTML files went, somewhere under `/srv` would be most appropriate.
Here, this webroot is really more of an implementation detail of the
certbot set up by the Zulip installer/packaging, containing transient
state.  So someplace under `/var` is appropriate, and specifically
under `/var/lib/zulip` in order to properly namespace it.

For background on `/var/www` and friends, see the top couple of answers
on
  https://unix.stackexchange.com/questions/47436/why-web-server-var-www
2017-11-15 21:50:41 -08:00
Tim Abbott
2afc3b9e50 certbot: Move path to /usr/local/sbin.
[greg: fixed typo bug]
2017-11-15 21:50:41 -08:00
rht
97ec56276c certbot: Add certbot renew cron job to puppet.
Tweaked by tabbott to use the proper command.
2017-11-15 21:50:41 -08:00
Tim Abbott
f02e5b90f6 cross_realm: Use bulk_get_users to fix handling of missing users.
This fixes a regression in ae5ba7f4fd,
where Zulip would 500 if the newly added system bots didn't exist on
the server.

This also fixes a moderate size performance problem where we'd fetch 5
users from memcached or the database in a loop.
2017-11-15 21:24:51 -08:00
Tim Abbott
c7a975e4df users: Move check_change_full_name to actions.py.
This avoids an import loop in the next commit, and better matches our
usual code structure.
2017-11-15 17:39:09 -08:00
Tim Abbott
774380dcb8 capitalization: Allow enabled/disabled to be lower-case. 2017-11-15 17:39:09 -08:00
Tim Abbott
03b4a0240c user_settings: Fix mypy annotations.
While we're at it, convert this to use the Python 3 style, which isn't
prone to this sort of bug.
2017-11-15 17:38:19 -08:00
Tommy Ip
acdc4c9d27 /team: Improve the responsiveness of the team profiles.
Fixes #7349
2017-11-15 17:08:08 -08:00
Tommy Ip
94a14f9796 /team: Add padding to content. 2017-11-15 17:08:08 -08:00
Tommy Ip
0bd09398d8 /team: Use CSS grid for contributors table. 2017-11-15 17:08:08 -08:00
Tommy Ip
0a445031a9 /team: Remove responsive columns hack.
Since we are restyling the contributors table to the new fancy CSS
grid layout we no longer need this hack.
2017-11-15 17:08:08 -08:00
Vishnu Ks
6f955fbf34 actions: Replace stream.add with stream.append in process_new_human_user.
stream is a list not a set. It used to be set
and was changed to stream before getting merged.
2017-11-15 17:06:43 -08:00
Vishnu Ks
f99fd20f8f management: Add option to set description of default stream groups. 2017-11-15 17:06:43 -08:00
Aastha Gupta
c84f1686b7 emoji: Display emoji in messages as text as well as reactions.
Fixes #6795.
2017-11-15 16:59:11 -08:00
Brock Whittaker
b76578ca13 Add an experimental dark mode stylesheet.
Note from tabbott: While this initial version is experimental and
definitely incomplete, we expect to have a solid version done over the
next few weeks (after more refactoring).  We're merging this now to
make it easy to test both versions when refactoring our CSS.

Fixes #267.
2017-11-15 16:45:34 -08:00
Brock Whittaker
ce62abce73 dark-mode: Add "T" hotkey for dark mode theme. 2017-11-15 16:45:34 -08:00
Brock Whittaker
f9f0f356be settings: Add backend storage and interface for night mode.
This allows the night mode setting to be stored in the backend.
2017-11-15 16:36:06 -08:00
Tim Abbott
2b43a0302a python: Sort imports in smaller apps. 2017-11-15 15:55:49 -08:00
Tim Abbott
dc8dd2333c tornado: Sort imports in files with no merge conflicts. 2017-11-15 15:53:11 -08:00
Tim Abbott
10ab9410c9 python: Sort imports in easy files in zerver/. 2017-11-15 15:50:28 -08:00
Tim Abbott
a996f843d1 python: Sort imports in zerver/templatetags. 2017-11-15 15:49:39 -08:00
Tim Abbott
38e97089fc python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
Tim Abbott
f04d6ed19e python: Sort imports in management commands. 2017-11-15 15:43:47 -08:00
Tim Abbott
73a668e7ae python: Sort imports in webhooks. 2017-11-15 15:43:10 -08:00
Rishi Gupta
c377db7d04 docs: Update intro text to index.rst. 2017-11-15 14:32:25 -08:00
Tim Abbott
6a5b965a90 integrations: Rename HUBOT_LOZENGES to HUBOT_INTEGRATIONS. 2017-11-15 14:04:19 -08:00
Aastha Gupta
3b53c692a4 integrations: Add integrations/doc/assembla.
Significantly modified by tabbott and rishig to be more maintainable.

Fixes #4542.
2017-11-15 14:04:19 -08:00
Tim Abbott
85844107fd integrations: Remove code for legacy Hubot lozenges.
We no longer display the only model anyway.
2017-11-15 14:04:19 -08:00
Brock Whittaker
2c000c0f1d settings: Increase specificity of sidebar <li> selector.
This was interfering with <li> elements outside of the settings page.
2017-11-15 13:42:44 -08:00
Rishi Gupta
f7d23ee38b docs: Make minor updates to CONTRIBUTING.md and README.md. 2017-11-15 11:16:28 -08:00
Brock Whittaker
744c4af958 left-sidebar: Remove topics help code.
This removes code associated with the dead topic help feature that is
below “more topics”.
2017-11-15 11:01:33 -08:00
rht
e54b9730fc Reduce python files line length limit to 110.
License: Apache-2.0
Signed-off-by: rht <rhtbot@protonmail.com>
2017-11-15 10:58:03 -08:00
rht
bafba95eb7 Text-wrap the remaining long lines exceeding 110. 2017-11-15 10:58:03 -08:00
rht
09af29b051 zerver/lib: Text-wrap long lines exceeding 110. 2017-11-15 10:58:03 -08:00
rht
d3914a5017 confirmation: Text-wrap long lines exceeding 110. 2017-11-15 10:58:03 -08:00
Tim Abbott
5aa6751e7a lint: Fix long lines in newly added features. 2017-11-15 10:58:03 -08:00
Steve Howell
dbcc76b996 Fix MissedMessageWorker.
This fixes a regression in 25c669df52.

We were draining the queue in both the superclass and the subclass,
so by the time the subclass started processing events, there were
no events to process.  Now the subclass properly uses the events
passed in from the superclass.
2017-11-15 10:26:28 -08:00
Eeshan Garg
e85d0747d4 tools/test-help-documentation: Verify api/ docs. 2017-11-15 10:12:59 -08:00
Tim Abbott
9dd5d6e999 api: Fix broken links detected by new tests. 2017-11-15 10:12:59 -08:00
Florian Jüngermann
b31917be1d frontend: Remove redundant stream separator in the left sidebar.
In the case of no 'normal' streams (only pinned and dormant ones) there are two separators
between the groups of streams. My commit removes one.
2017-11-15 10:06:25 -08:00
derAnfaenger
5ef09bfcd4 docs: Move bot docs to /api.
With a few fixes for rendering bugs.  The rest will be in a follow-up
issue.
2017-11-15 09:58:29 -08:00
derAnfaenger
da67c610b2 docs: Fix typo in plans.html 2017-11-15 09:49:01 -08:00
Vishnu Ks
8a46ddf9d7 dev_settings: Add localhost:9991 as realm host for zulip realm.
[greg: Tweaked explanatory comment.]
2017-11-14 18:34:17 -08:00
Rishi Gupta
2d73d3d1d4 docs: Move license declaration from README.md to LICENSE. 2017-11-14 16:04:23 -08:00
Rishi Gupta
c019c1ba70 docs: Update chat-zulip-org.md. 2017-11-14 16:04:23 -08:00
Rishi Gupta
df8e156e50 docs: Reorder sections in chat-zulip-org.md. 2017-11-14 16:04:23 -08:00
Rishi Gupta
87b470ff40 docs: Remove information on office hours and sprints.
Also removes references to meeting agendas that haven't been updated in
months.
2017-11-14 16:04:23 -08:00
Rishi Gupta
ee2ea3750c docs: Split a CONTRIBUTING.md out of README.md.
Also contains a number of updates, additions, and deletions; this is
essentially a rewrite of the github landing page experience.
2017-11-14 16:04:23 -08:00
Rishi Gupta
7e9273bc31 docs: Stop recommending the dev environment in prod.md.
The dev environment has none of the onboarding that chat.zulip.org and the
prod install have.
2017-11-14 16:04:23 -08:00
Steve Howell
ae5ba7f4fd Add a couple cross-realm bots.
These are new:

    new-user-bot
    emailgateway

Our cross-realm bots are hard coded to have email addresses
in the `zulip.com` domain, and they're not part of ordinary
realms.

These have always been cross-realm, but new enforcement in the
frontend code of all messages having been sent by a known user means
that it's important to add these properly.
2017-11-14 16:02:19 -08:00
Greg Price
415da352df prod install: Cut premature suggestion to configure auth backends.
The warning here means that the admin can't really act on this yet if
they want to disable email auth, which is likely among admins that
want to make any changes here.  And for admins who don't, this is an
extra thing to read and make a decision about before they can get a
server running.  See #6985.

Conversely, we already discuss auth backends right at the top of the
`prod-customize` doc, which is linked under "Next steps" at the end of
these instructions.

The warning about EmailAuthBackend is important; but we can move it to
the config file right next to the setting, and then it's available
right when it's actionable, which is if the admin is actually thinking
about changing the setting.
2017-11-14 15:57:39 -08:00
Tim Abbott
f756f55145 docs: Rename docs/README.html to docs/documentation.html.
Since it's now the top-level documentation for our documentation
system in general, not just docs/, it deserves a more normal name.
2017-11-14 15:52:58 -08:00
Vishnu Ks
36f29764cb emails: Add option to forward mails send in dev env to external email.
Fixes #7085.
2017-11-14 15:27:29 -08:00
Tim Abbott
ac763d6eed tools: Remove obsolete build-deb tool.
This hasn't been used in ages, and isn't useful with the current
codebase.
2017-11-14 15:22:26 -08:00
Vishnu Ks
d2555e8769 api: Add support to change name of default stream groups. 2017-11-14 14:41:42 -08:00
Vishnu Ks
2af249dd5d api: Add description attribute to default stream group. 2017-11-14 14:41:42 -08:00
Vishnu Ks
f45ba7de93 api: Pass group id instead of name to default stream group api. 2017-11-14 14:41:42 -08:00
Tommy Ip
9565ea4513 python: Add settings for isort.
Commit msg tweaked by rht. Based on
https://github.com/zulip/zulip/pull/3318.

Content tweaked by tabbott.
2017-11-14 12:31:14 -08:00
Tim Abbott
d2d1459a6a requirements: Add isort development dependency. 2017-11-14 12:10:48 -08:00
Eeshan Garg
4755ecae8a docs/dev-env: Recommend setting up lxc network config on Debian.
LXC on Debian does not ship with a default network config for
containers, so we now recommend setting up the lxc network config
manually.

Tweaked by tabbott to make these details much harder to miss.
2017-11-14 11:19:33 -08:00
Cynthia Lin
d5a3691561 media: Display stream list filter at full width. 2017-11-14 11:12:13 -08:00
Cynthia Lin
940ca17c46 hotkeys: Expand collapsed sidebars when sidebar searches are initiated.
Fixes #7351.
2017-11-14 11:12:13 -08:00
Cynthia Lin
7d2672cfcd popovers: Include expanded mobile sidebars as active popovers. 2017-11-14 11:12:13 -08:00
Tim Abbott
a047584d0b docs: Use parallelism when building docs.
This makes things significantly faster on a multiprocess machine.
2017-11-14 10:41:38 -08:00
rht
cceba2023c Use makedirs directly instead of wrapping it in mkdirs. 2017-11-14 09:47:09 -08:00
rht
72ce1c6501 Use a more concise mkdir -p when the situation permits. 2017-11-14 09:47:09 -08:00
Tim Abbott
a86968cd44 landing_nav: Fix missing login_link_disabled check.
This caused login links to incorrectly appear on the zulipchat.com
homepage.
2017-11-13 17:07:17 -08:00
Steve Howell
99ecb51c5f minor: Add whitespace after commas in CSS. 2017-11-13 12:43:43 -08:00
Steve Howell
f35b7b4c77 css: Convert colors to hsl() format.
This changes most of the app-related CSS files, but leaves
things like landing pages and bootstrap alone.
2017-11-13 12:43:43 -08:00
Steve Howell
ba51078418 Simplify CSS linter and clean up CSS.
The CSS linter was pretty hard to reason about.  It was
pretty flexible about certain things, but then it would
prevent seemingly innocuous code from getting checked in.

This commit overhauls the pretty-printer to be more composable,
where every object in the AST knows how to render itself.  It
also cleans up a little bit of the pre_fluff/post_fluff logic
in the parser itself, so comments are more likely to be "attached"
to the AST node that make sense.

The linter is actually a bit more finicky about newlines, but
this is mostly a good thing, as most of the variations before
this commit were pretty arbitrary.
2017-11-13 12:43:43 -08:00
Umair Khan
7e2b452f6a user-groups: Add composebox_typeahead tests. 2017-11-13 11:43:16 -08:00
Umair Khan
597a6e6c74 user-groups: Add user groups in typeahead code. 2017-11-13 11:42:17 -08:00
Umair Khan
0e21cbc5d9 user-groups: Create static/js/user_groups.js. 2017-11-13 13:08:15 +05:00
Umair Khan
ad8f5650a3 user-groups: Generate test data of user groups. 2017-11-13 13:08:15 +05:00
Vishnu Ks
50eb3be0c2 droplets: Remove ip_address default value from create_dns_record.
I forgot to remove the default value 172.31.1.4 from
ip_address which was used only for testing purpose.
2017-11-11 17:05:14 -08:00
Brock Whittaker
7b4124b7b4 portico-header: Add background to avatar images.
This adds a white background color to avatar images that may
have a transparent background.
2017-11-10 19:25:42 -08:00
derAnfaenger
25bf15a3c9 bots: Use non-generic exception for state key removal. 2017-11-10 18:56:26 -08:00
derAnfaenger
8fccf36246 bots: Wrap StateError exceptions around BotUserData exceptions. 2017-11-10 18:56:26 -08:00
derAnfaenger
d707e3bc1d bots: Add USER_STATE_SIZE_LIMIT setting. 2017-11-10 18:56:26 -08:00
derAnfaenger
545c73c79e bots: Rename StateHandlerError to StateError. 2017-11-10 18:54:54 -08:00
derAnfaenger
71372610e3 bots: Validate state size limit directly in set_bot_state(). 2017-11-10 18:54:39 -08:00
derAnfaenger
6c543d1280 bots: Make StateHandler test more accurate. 2017-11-10 18:45:52 -08:00
Tim Abbott
9921971bfb markdown_test_cases: Fix annoying whitespace issue.
This unfortunately breaks the node tests.
2017-11-10 18:37:19 -08:00
Tim Abbott
54aa87fba3 api: Migrate to using the new version of the API site. 2017-11-10 17:56:22 -08:00
Tim Abbott
01a8dd04d3 docs: Update our changelog. 2017-11-10 17:40:50 -08:00
Tim Abbott
3a77e20d28 markdown: Fix now-buggy test case. 2017-11-10 17:07:32 -08:00
Brock Whittaker
ca2f93db31 settings: Restyle "emoji style" section.
This restyles and rewords some of the emoji style section to look
better and fit it more with the current style guide.

Tweaked by tabbott to modify the historical migration rather than
adding a new one.  This is OK because the emojiset choices text change
doesn't touch the database; it's just a Django Python code thing.

Also removed translation tags, since we don't need them for a set of
brand names.
2017-11-10 17:04:27 -08:00
Harshit Bansal
439bc2920a settings: Change the control for selecting emojiset to radio group.
Fixes: #7260.
2017-11-10 16:59:03 -08:00
Andy Perez
4d51a6cfac bugdown: Fix $$ whitespace handling.
The intended use of $$ is for inline expressions, not for multiline
ones; ```math is an acceptable alternative for the latter.  Hence,
the $$-syntax for inline TeX no longer permits newlines within it.

This was also necessary for the next change to be sensible; namely
allowing for spaces around both $$ when crafting inline TeX instead of
forcing everything to be crammed together, e.g. $$x=7$$.  In order to
avoid uninentionally creating inline expressions, the opening and
closing $$'s of an inline expression must now both exactly consist of
two dollar signs, no more and no less.

Fixes: #6488.
2017-11-10 16:54:27 -08:00
Rishi Gupta
b88ba90b30 docs: Make minor updates to chat-zulip-org.md. 2017-11-10 16:44:42 -08:00
Rishi Gupta
d1f0d2bdc1 docs: Update the pitch at the top of README.md. 2017-11-10 16:42:19 -08:00
Tim Abbott
a23378a304 check_short_string: Verify string before checking length.
While the previous implementation was correct, this should give better
error messages.
2017-11-10 16:37:43 -08:00
neiljp (Neil Pilgrim)
72eba6a0ce mypy: Adjust validator.py to use object rather than Any. 2017-11-10 16:37:29 -08:00
neiljp (Neil Pilgrim)
331a3c3447 mypy: Migrate validator.py typing to python3 syntax. 2017-11-10 16:32:25 -08:00
rht
8e87eb4084 zerver/lib/bugdown: Text-wrap long lines exceeding 110. 2017-11-10 16:29:32 -08:00
rht
a93b7c40a7 zerver: Text-wrap long lines exceeding 110. 2017-11-10 16:29:32 -08:00
rht
23a481c5d2 zerver/lib/actions.py: Text-wrap long lines exceeding 110. 2017-11-10 16:27:22 -08:00
rht
f397e15128 tools: Text-wrap long lines exceeding 110. 2017-11-10 16:24:09 -08:00
rht
7a96b8c7ad tools/lib: Text-wrap long lines exceeding 110. 2017-11-10 16:24:09 -08:00
rht
53e37aa511 scripts: Text-wrap long lines exceeding 110. 2017-11-10 16:22:26 -08:00
rht
51c1a6dfc9 analytics: Text-wrap long lines exceeding 110.
License: Apache-2.0
Signed-off-by: rht <rhtbot@protonmail.com>
2017-11-10 16:22:00 -08:00
Vishnu Ks
07e6a4fb2d droplets: Add wildcard A records to support realm subdomains. 2017-11-10 16:13:53 -08:00
Vishnu Ks
4a102b248a droplets: Set EXTERNAL_HOST to username.zulipdev.org:9991. 2017-11-10 16:13:53 -08:00
Vishnu Ks
f44b60a150 Implement API for default stream groups. 2017-11-10 16:05:36 -08:00
rht
5ff690d486 zulip-export: Convert to using argparse from optparse. 2017-11-10 15:54:02 -08:00
rht
f689813f38 test-js-with-node: Port from optparse to argparse. 2017-11-10 15:52:43 -08:00
Eeshan Garg
9c2cab50ca test_docs: Verify that all of our integrations/ docs are rendered.
Fixes #7360.
2017-11-10 20:11:55 -03:30
Brock Whittaker
5ae4b8d3f3 input-pill: Add clean up functions.
This adds functions to remove pills and reset the state.
2017-11-10 14:14:03 -08:00
Brock Whittaker
70a14d8b44 bootstrap: Patch bootstrap.js to support contenteditable.
If the lookup input is contenteditable, it should be searching for text
rather than input.
2017-11-10 14:14:03 -08:00
Brock Whittaker
1bb45dd946 hotkey: Prevent hotkey interactions with pills.
This prevents hotkeys from firing when any of the pills or pill
input sections are focused.
2017-11-10 14:14:03 -08:00
Brock Whittaker
00d11fb0af input-pill: Add styling.
This adds some styling for the default case of the input pills and some
custom styling.
2017-11-10 14:14:03 -08:00
Brock Whittaker
74d91bff22 input-pill: Add onpillcreate method. 2017-11-10 14:14:03 -08:00
Brock Whittaker
5a0bba2afc input-pill: Add validation callback for pills.
This adds a validator that when calling `reject` will reject a pill
from being added.
2017-11-10 14:14:03 -08:00
Brock Whittaker
5d0aae283f input-pill: Add key/value caching.
Some of the calls in our codebase will call for the `.keys()` method a
lot, so this caches the results and returns them rather than mapping
the array if it knows the state to be the same as before.
2017-11-10 14:14:03 -08:00
Brock Whittaker
93141cbe39 input-pill: Have all clicks directly on container focus input.
If a user clicks on the pill container and not directly on a pill
or on an "x" inside of a pill, it should be presumed they are
trying to input new text. This effectively makes the whole non-pill
section an input bar.
2017-11-10 14:14:03 -08:00
Brock Whittaker
7b00736fa2 input-pill: Add "input_pill" class and documentation. 2017-11-10 14:14:03 -08:00
Brock Whittaker
d27882325c hotkeys: Refactor text selectors to be array.
This makes it easier in the future to see diffs and to add/remove text
selectors for hotkey prevention.
2017-11-10 14:14:03 -08:00
derAnfaenger
032fad2cf1 queue_processors: Add error coverage for MessageSenderWorker. 2017-11-10 13:23:53 -08:00
derAnfaenger
d9571698f2 queue_processors: Add coverage for get_active_worker_queues(). 2017-11-10 13:23:53 -08:00
derAnfaenger
d3bee4fcc5 queue_processors: Exclude various lines from coverage.
The os.mkdir call is straightforward and doesn't testing.
Workers relying on LoopQueueProcessingWorker are tested
with its consume method that exists solely for this purpose.
2017-11-10 13:23:53 -08:00
derAnfaenger
7777a81dbf queue_processors: Add full coverage for SlowQuery. 2017-11-10 13:23:53 -08:00
Cynthia Lin
1bcc07f7dd popovers: Add bot icon to user profile popovers for bots.
Fixes #7176.
2017-11-10 11:18:43 -08:00
Cynthia Lin
a3e5f2a887 message view: Use new custom bot icon in messages. 2017-11-10 11:18:43 -08:00
Cynthia Lin
0b800b0a7d icons: Create framework for custom icons and add new bot icon. 2017-11-10 11:18:42 -08:00
Steve Howell
b6ebead827 tests: Add test_raw_unread_stream(). 2017-11-10 10:50:57 -08:00
Steve Howell
23f7615adb tests: Add test_raw_unread_huddle(). 2017-11-10 10:50:57 -08:00
Steve Howell
db8c69ff03 tests: Add test_raw_unread_personal(). 2017-11-10 10:50:57 -08:00
Steve Howell
5a99fa4990 tests: Extract GetUnreadMsgsTest.mute_(stream,topic) helpers.
This also introduces the GetUnreadMsgsTest class, and it fixes
the topic_name field that was accidentally hard coded in mute_topic.
2017-11-10 10:50:57 -08:00
Steve Howell
f54146b6d8 mypy: Add RawUnreadMessagesResult type. 2017-11-10 10:50:57 -08:00
Steve Howell
c799ec0ca6 minor: Inline get_unread_message_ids_per_recipient().
This method was only used in one test.
2017-11-10 10:50:57 -08:00
Harshit Bansal
e062b244b4 requirements: Remove unused diff-match-patch package.
This package was used for generating diffs for message edits. But
we have now switched to `lxml` for producing diffs so this is no
longer required.
2017-11-10 10:19:32 -08:00
Tommy Ip
8480deb754 integration docs: Fix broken desk.com markdown. 2017-11-10 17:33:42 +00:00
Tommy Ip
325ca0df62 integration docs: Fix broken Stripe markdown.
More information: https://chat.zulip.org/#narrow/stream/issues/topic/.237336
2017-11-10 17:19:52 +00:00
Umair Khan
4c6a376fd5 user-groups: Add groups to page_params. 2017-11-09 17:35:46 -08:00
Umair Khan
ef545b9180 user-groups: Add css for user-group-mention class. 2017-11-09 17:35:46 -08:00
Umair Khan
b1603d289c user-groups: Add update members API endpoint.
Significantly modified by tabbott to fix some bugs.
2017-11-09 17:35:37 -08:00
Umair Khan
a1b894a786 user-groups: Add delete API endpoint.
Significantly modified by tabbott to fix some bugs.
2017-11-09 17:35:30 -08:00
Umair Khan
eeaf0f1742 user-groups: Add edit API endpoint.
Significantly modified by tabbott to fix some bugs.
2017-11-09 17:35:22 -08:00
Umair Khan
1bbe84af49 user-groups: Add create API endpoint.
Significantly modified by tabbott for better security structure.
2017-11-09 17:26:14 -08:00
Umair Khan
39ca38837e user-groups: Add description to groups. 2017-11-09 16:35:52 -08:00
Umair Khan
18aecb82d7 user-groups: Get members from membership. 2017-11-09 16:18:40 -08:00
derAnfaenger
7798aae6ca queue processors: Add full coverage for DigestWorker. 2017-11-09 16:01:24 -08:00
derAnfaenger
dac44dda92 Cover users without activity record in email queue digest tests. 2017-11-09 16:01:24 -08:00
derAnfaenger
970e8c5df2 queue processors: Add full coverage for FetchLinksEmbedData. 2017-11-09 16:01:24 -08:00
Tommy Ip
bcd575d8de bugdown: Rewrite links to local server to be relative links.
Fixes #7247
2017-11-09 15:59:31 -08:00
Tim Abbott
982bd9c38d Fix push notifications for soft-deactivated users.
Previously, these push notification events were being generated, but
then ignored in handle_push_notification because there was no
user_message object.
2017-11-09 15:52:29 -08:00
Tim Abbott
c99d20db63 push_notifications: Shrink scope of try/except block.
There's no reason this needed to indent the entire function.
2017-11-09 15:30:21 -08:00
derAnfaenger
3ac09b3e9b queue processors: Add coverage for SlowQueryWorker. 2017-11-09 15:20:40 -08:00
Tim Abbott
25c669df52 queue_processors: Extract LoopQueueProcessingWorker class.
This should help make it easier to add tests coverage for these queue
processors, since they now use a system more similar to the other
queue processors.
2017-11-09 15:20:40 -08:00
Tim Abbott
64b4d83038 push_notifications: Improve debugging of lookup problems.
We're having this error being thrown often, and don't know why.
2017-11-09 15:20:24 -08:00
Tommy Ip
7477fbb14e docs: Remove dangling </p> tag.
Fixes #7336
2017-11-09 14:39:40 -08:00
Garvit
8084f2dc55 Add: Profile picture popover on clicking mentions in chats.
Fixes #6380
2017-11-09 12:21:16 -08:00
Steve Howell
9b723c7a32 Use encode() in zerver/lib/logging_util.py. 2017-11-09 10:43:20 -08:00
Steve Howell
3158ed01bf Remove force_str() in upload.py. 2017-11-09 10:43:20 -08:00
Steve Howell
531a3ee9de refactor: Fix parse.quote(force_str(s)) calls in bugdown. 2017-11-09 10:43:20 -08:00
Steve Howell
8eaeba8615 refactor: Remove dict_with_str_keys().
This function is no longer needed in python3, as it was decoding
keys that already came for a JSON-decoded string.
2017-11-09 10:43:20 -08:00
Steve Howell
b0bb09cdb8 Remove force_text() in get_signed_upload_url(). 2017-11-09 10:43:20 -08:00
Steve Howell
7da6beac99 Remove force_text() in upload.get_file_info(). 2017-11-09 10:43:20 -08:00
Steve Howell
a9f42e6266 Remove force_text() from sanitize_name(). 2017-11-09 10:43:20 -08:00
Steve Howell
17cfead19a Remove force_text() in twitter_text(). 2017-11-09 10:43:20 -08:00
Steve Howell
585829f665 Remove force_text() in list_of_tlds(). 2017-11-09 10:43:19 -08:00
Steve Howell
da2744812f Don't use force_bytes() in decorator.py.
In python3 base64.b64decode() can take an ASCII string, and any
legit data will be ASCII.  If you pass in non-ASCII data, the
function will properly throw a ValueError (verified in python3 shell).

	>>> s = '안녕하세요'
	>>> import base64
	>>> base64.b64decode(s)
	Traceback (most recent call last):
	  File "/srv/zulip-py3-venv/lib/python3.4/base64.py", line 37, in _bytes_from_decode_data
		return s.encode('ascii')
	UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)

	During handling of the above exception, another exception occurred:

	Traceback (most recent call last):
	  File "<stdin>", line 1, in <module>
	  File "/srv/zulip-py3-venv/lib/python3.4/base64.py", line 83, in b64decode
		s = _bytes_from_decode_data(s)
	  File "/srv/zulip-py3-venv/lib/python3.4/base64.py", line 39, in _bytes_from_decode_data
		raise ValueError('string argument should contain only ASCII characters')
	ValueError: string argument should contain only ASCII characters
2017-11-09 10:43:19 -08:00
Steve Howell
63024b3a6f Use encode() in zerver/lib/message.py. 2017-11-09 10:38:58 -08:00
Steve Howell
d42478bfea Use encode() in zerver/lib/response.py. 2017-11-09 10:38:58 -08:00
Steve Howell
64dc9e65cf Use encode() in zerver/lib/tex.py. 2017-11-09 10:38:58 -08:00
Steve Howell
7821cb3d51 Avoid unneeded force_text() in make_safe_digest(). 2017-11-09 10:38:41 -08:00
Steve Howell
17200bfbc9 tests: Simplify test_classes.fixture_data().
We eliminate the unnecessary force_text() helper and clean up
the formatting a bit.
2017-11-09 10:32:14 -08:00
Steve Howell
5d3ecf8f31 Remove force_str() in log_event(). 2017-11-09 10:32:14 -08:00
Steve Howell
c38996ddde Remove unused force_text import. 2017-11-09 10:32:14 -08:00
Steve Howell
786e90d774 Removed unused imports of force_bytes. 2017-11-09 10:32:14 -08:00
Steve Howell
a77cdaa527 Remove force_text() in get_url_data(). 2017-11-09 10:32:14 -08:00
Steve Howell
66b42e0a42 Remove unused import in app_filters.py. 2017-11-09 10:32:14 -08:00
Steve Howell
50e3285a0d tests: Remove force_text() in test_messages.py. 2017-11-09 10:27:30 -08:00
YJDave
de67bf81fd org settings: Allow users to delete their message.
Fixes #7049.
2017-11-09 10:20:34 -08:00
rht
88a828dd0c Remove six.moves.urllib usage. 2017-11-09 10:00:00 -08:00
rht
5ee40bf718 Remove usage of six.moves.binary_type. 2017-11-09 10:00:00 -08:00
rht
5937141264 Remove usage of six.moves.string_types. 2017-11-09 10:00:00 -08:00
rht
bb46bea44d Remove usage of six.moves.text_type. 2017-11-09 10:00:00 -08:00
Harshit Bansal
65838bb825 email_gateway: Disable code block processor for email gateway.
Generally emails are not written with markdown in mind and hence
sometimes render in strange ways. This commit fixes a particular
issue that was causing whitespace before paragraphs to be treated
as code block due to which email content was being rendered in a
box that scrolls in right direction a lot.

Fixes: #7045.
2017-11-09 09:56:35 -08:00
Steve Howell
d7254a0556 Append space as needed in compose_ui.smart_insert(). 2017-11-09 09:49:20 -08:00
Steve Howell
f935afa241 Prepend space as needed in compose_ui.smart_insert(). 2017-11-09 09:49:20 -08:00
Steve Howell
1b1858aa64 node tests: Test compose_ui.smart_insert(). 2017-11-09 09:49:20 -08:00
Steve Howell
12dc567a89 Move insert_syntax_and_focus() to compose_ui.js.
This change also removes a couple lines of test code that
weren't really testing anything.
2017-11-09 09:49:20 -08:00
derAnfaenger
19bc55aa45 Fix various typos.
The typos and their corrections were found with the
aid of https://github.com/lucasdemarchi/codespell.
2017-11-09 16:26:38 +01:00
Brock Whittaker
4817ba44a4 tab-switcher: Switch tabs with left/right arrows.
This now allows all tab switcher components to be used with left
and right arrows, given that a tab is already in focus, which is
the default behavior unless overridden (like on the streams
overlay).
2017-11-08 18:13:57 -08:00
Brock Whittaker
5b86b65818 message-feed: Do not autoscroll new messages if popovers open.
Do not attempt to autoscroll down to view new messages if popovers are
open. This prevents the issue where someone can be viewing a profile or
reacting to a message and not be able to due to a new message coming in.

Fixes: #7319.
2017-11-08 13:37:00 -08:00
Tim Abbott
0386c674cb api: Fill out the sidebar with sections.
Most of these should be migrated from ReadTheDocs to this new site.
2017-11-08 13:15:41 -08:00
Tim Abbott
a8c735e1d2 /api/: Fix some headings. 2017-11-08 13:08:23 -08:00
Brock Whittaker
d2e55fa5c8 /api/ & /help/: Change index to <h1>.
The Index should be presented as an <h1> section and to the far left.
2017-11-08 13:01:33 -08:00
Brock Whittaker
228b0c4290 /help/: Add a slide class for sidebars that should have slide mechanism.
This adds a slide class that specifies that the JS actions for sliding
up and down sections is the desired behavior, along with a bit of CSS
to help display correctly in the case of not being a sliding section.
2017-11-08 13:01:33 -08:00
Brock Whittaker
670f20248a /api/: Fix incorrect sidebar styling.
This rule is only applied to the API page which makes it inconsistent
with the /help/ page.
2017-11-08 13:01:33 -08:00
rht
04f4f7166c zerver/tests: Use python 3 syntax for typing.
This patch was extracted by tabbott for just the files with no open
PRs modifying them.
2017-11-08 12:50:27 -08:00
neiljp (Neil Pilgrim)
fec59b29cd Tools/mypy: Enforce typed generics in tools/run-mypy.
This adds the "--disallow-any=generics" option to run-mypy, which no
longer permits:
- inheriting from "list"; use "List[sometype]" (or a TypeVar)
- generic types with no following square brackets specifying the type
  (even if initially 'Any')

Any (and '...' for Callable) is a lot easier to search for than an
absence of square brackets, and should improve overall typing quality.
2017-11-08 12:40:40 -08:00
neiljp (Neil Pilgrim)
790cd5e7c8 mypy: Specify generic type parameters in cachify decorator.
Use of the decorator in event_queue.py suggests concrete return type,
for application of copy() function.
2017-11-08 12:40:40 -08:00
Tim Abbott
94554c65da certbot: Modify nginx configuration to support automated renewal. 2017-11-08 12:32:26 -08:00
Tim Abbott
38dc43fdf8 certbot: Use --standalone mode during installer.
This should help avoid problems, since we don't need to install
`nginx` before using this mode.
2017-11-08 12:32:26 -08:00
Tim Abbott
62bb465896 puppet: Modify lb0 nginx configuration. 2017-11-08 12:32:26 -08:00
Brock Whittaker
dfb3597eb2 left-sidebar: Remove leading whitespace underline on global filters.
This removes the leading whitespace that was approximately the width of
a space character that would get underlined when hovering over any one
of the global filters.
2017-11-08 12:29:40 -08:00
Steve Howell
c3b89845c9 node tests: Use zrequire in typing_status.js. 2017-11-08 12:24:17 -08:00
Steve Howell
0fc20bf943 node tests: Use zrequire in typing_data.js. 2017-11-08 12:24:17 -08:00
Steve Howell
c32f69bef6 node tests: Use zrequire in topic_data.js. 2017-11-08 12:24:17 -08:00
Steve Howell
1dc5218ef5 node tests: Use zrequire in rtl.js. 2017-11-08 12:24:17 -08:00
Steve Howell
f65d3316e0 node tests: Use zrequire in recent_senders.js. 2017-11-08 12:24:17 -08:00
Steve Howell
34bddd26d8 node tests: Use zrequire in pm_conversations.js. 2017-11-08 12:24:17 -08:00
Steve Howell
99695da799 node tests: Use zrequire in people.js. 2017-11-08 12:24:17 -08:00
Steve Howell
6304aea4bc node tests: Use zrequire in hotkey.js. 2017-11-08 12:24:17 -08:00
Steve Howell
bf0ed5915c node tests: Use zrequire in common.js. 2017-11-08 12:24:17 -08:00
Steve Howell
adb02b37ce node tests: Use zrequire in colorspace.js. 2017-11-08 12:24:17 -08:00
Steve Howell
e0fa317be1 node_tests: Remove unneeded var statements.
Variables like Dict/_/assert are already globally defined.
2017-11-08 12:24:17 -08:00
Steve Howell
bef176f5f6 node tests: Use zrequire in channel.js. 2017-11-08 12:24:17 -08:00
Steve Howell
7a68add9a4 Remove unneeded requires in activity.js. 2017-11-08 12:24:17 -08:00
Steve Howell
cdc1bf3d5e node test: Remove add_dependencies(). 2017-11-08 12:24:17 -08:00
Steve Howell
a1c5b0928e node tests: Use zrequire in util.js. 2017-11-08 12:24:17 -08:00
Steve Howell
8cdd08a02a node tests: Use zrequire in user_events.js. 2017-11-08 12:24:17 -08:00
Steve Howell
9b9ff5cce3 node tests: Use zrequire in unread.js. 2017-11-08 12:24:17 -08:00
Steve Howell
c233bb53fd node tests: Use zrequire in typeahead_helper.js. 2017-11-08 12:24:17 -08:00
Steve Howell
c38081b528 node tests: Use zrequire in topic_generator.js. 2017-11-08 12:24:17 -08:00
Steve Howell
de341e88c5 node tests: Use zrequire in timerender.js. 2017-11-08 12:24:17 -08:00
Steve Howell
83c9b1134e node tests: Use zrequire in templates.js. 2017-11-08 12:24:17 -08:00
Steve Howell
4ef8df15c9 node tests: Use zrequire in subs.js. 2017-11-08 12:24:17 -08:00
Steve Howell
b3bfca9c2e node tests: Use zrequire in stream_sort.js. 2017-11-08 12:24:17 -08:00
Steve Howell
c12d46284f node tests: Use zrequire in stream_events.js. 2017-11-08 12:24:17 -08:00
Steve Howell
2c1a855cae node tests: Use zrequire in settings_org.js. 2017-11-08 12:24:17 -08:00
Steve Howell
9489c5d0a8 node tests: Use zrequire in settings_bots.js. 2017-11-08 12:24:17 -08:00
Steve Howell
f720aad260 node tests: Use zrequire in server_events.js. 2017-11-08 12:24:17 -08:00
Steve Howell
19ca4bff82 node tests: Use zrequire in search_suggestion.js. 2017-11-08 12:24:17 -08:00
Steve Howell
5db2f3e087 node tests: Use zrequire in reactions.js. 2017-11-08 12:24:17 -08:00
Steve Howell
23313f2ddf node tests: Use zrequire in presence.js. 2017-11-08 12:24:17 -08:00
Steve Howell
14631b8748 node tests: Use zrequire in password.js. 2017-11-08 12:24:17 -08:00
Steve Howell
65dc6a0975 node tests: Use zrequire in narrow_state.js. 2017-11-08 12:24:17 -08:00
Steve Howell
2fac1fe6c9 node tests: Use zrequire in muting.js. 2017-11-08 12:24:17 -08:00
Steve Howell
8f0b396140 node tests: Use zrequire in message_store.js. 2017-11-08 12:24:17 -08:00
Steve Howell
180f910764 node tests: Use zrequire in message_list_view.js. 2017-11-08 12:24:17 -08:00
Steve Howell
98c4ee3175 node tests: Use zrequire in message_list.js. 2017-11-08 12:24:17 -08:00
Steve Howell
84f547004c node tests: Use zrequire in message_edit.js. 2017-11-08 12:24:17 -08:00
Steve Howell
ba79558257 node tests: Use zrequire in markdown.js. 2017-11-08 12:24:17 -08:00
Steve Howell
914cf175c0 node tests: Use zrequire in i18n.js. 2017-11-08 12:24:17 -08:00
Steve Howell
1ba0315aad node tests: Use zrequire in hashchange.js. 2017-11-08 12:24:17 -08:00
Steve Howell
b2775506a4 node tests: Use zrequire in filter.js. 2017-11-08 12:24:17 -08:00
Steve Howell
ad59600062 node tests: Use zrequire in emoji_picker.js. 2017-11-08 12:24:17 -08:00
Steve Howell
c307356d33 node tests: Use zrequire in emoji.js. 2017-11-08 12:24:17 -08:00
Steve Howell
f6f227d089 node tests: Use zrequire in drafts.js. 2017-11-08 12:24:17 -08:00
Steve Howell
15e21f0cd1 node tests: Use zrequire in dispatch.js. 2017-11-08 12:24:17 -08:00
Steve Howell
2ea4a20bc5 node tests: Use zrequire in composebox_typeahead.js. 2017-11-08 12:24:17 -08:00
Steve Howell
3aa2c22370 node tests: Use zrequire in compose_fade.js. 2017-11-08 12:24:17 -08:00
Steve Howell
a7a6f68c98 node tests: Use zrequire in compose_actions.js. 2017-11-08 12:24:17 -08:00
Steve Howell
4d814c03d4 node tests: Use zrequire in compose.js. 2017-11-08 12:24:17 -08:00
Steve Howell
e63dd59065 node tests: Use zrequire in bot_data.js. 2017-11-08 12:24:17 -08:00
Steve Howell
640b0d5653 node tests: Use zrequire in alert_words.js. 2017-11-08 12:24:17 -08:00
Steve Howell
b0665815d2 Use stub_i18n in templates.js. 2017-11-08 12:24:17 -08:00
Steve Howell
eff9f617ef node tests: Use stubbed i18n in message_list.js. 2017-11-08 12:24:17 -08:00
derAnfaenger
c9d438d149 linter: Add example lines for several python rules. 2017-11-08 11:18:37 -08:00
derAnfaenger
dbc1f83d3a linter: Make string formatting custom rule more complete. 2017-11-08 11:16:18 -08:00
derAnfaenger
816c4a4e79 mypy: Fix typo in type statement. 2017-11-08 11:16:18 -08:00
derAnfaenger
88794ea361 linter: Fix tests ignoring rules with include_only. 2017-11-08 11:16:18 -08:00
Tim Abbott
5703b38ffb api: Move usage instructions to their own page. 2017-11-08 10:29:24 -08:00
Tim Abbott
c869ed2c3b api-docs: Extract installation instructions to their own section. 2017-11-08 10:01:48 -08:00
Tim Abbott
67d85caf34 api-docs: Clean up reference to bin/ in the tarball. 2017-11-08 09:44:55 -08:00
Tim Abbott
ac63be7a0c api-docs: Fix space in zulip-send instructions. 2017-11-08 09:43:41 -08:00
Eeshan Garg
7c113f0447 api-docs: Render api_url in /api docs.
In templates/zerver/api/main.html, since the current context isn't
passed to render_markdown_path when rendering an article,
render_markdown_path doesn't have the context to render values such
as api_url. This commit makes sure that it does by passing a dict
called api_uri_context to render_markdown_path when rendering an
article.
2017-11-08 01:29:49 -03:30
Eeshan Garg
6d48601f40 api-docs: Use proper indentation for code blocks. 2017-11-08 01:13:19 -03:30
Steve Howell
4108797218 Eliminate the parse_usermessage_flags interface.
This commit puts the guts of parse_usermessage_flags into
UserMessage.flags_list_for_flags, since it was slightly faster
than the old implementation and produced the same results.
(Both algorithms were super fast, actually.)

And then all callers use the model method now.
2017-11-07 17:48:27 -08:00
Steve Howell
ae0b27a7ed Extract messages_for_ids. 2017-11-07 17:48:27 -08:00
Steve Howell
70f2cd2860 De-duplicate is_search logic in get_messages_backend().
The logic to set search_fields was essentially the same for both
sides of the include_history conditional.

Now we have just one code block that sets search_fields, and we
can quickly short-circuit the loop when is_search is False.
2017-11-07 17:48:27 -08:00
Steve Howell
c62588c359 minor: Use dict comprehension in get_messages_backend(). 2017-11-07 17:48:27 -08:00
Steve Howell
47c63217cc tests: Add test_include_history().
Before this test, we weren't really testing the logic to
get flags from UserMessage.
2017-11-07 17:48:27 -08:00
Tim Abbott
a8a159c5d2 mypy: Fix variable reuse in streams.py. 2017-11-07 17:48:27 -08:00
Tim Abbott
7e13d74529 tornado: Fix hardcoding of URI scheme in sockjs_url. 2017-11-07 17:24:10 -08:00
rht
04eaec64f0 zerver/webhooks: Text-wrap long lines exceeding 110. 2017-11-07 17:24:09 -08:00
rht
296835351d zerver/views: Text-wrap long lines exceeding 110.
Tweaked by tabbott to fix various minor issues.
2017-11-07 17:24:09 -08:00
rht
22e1456c4d zerver/tornado: Text-wrap long lines exceeding 110. 2017-11-07 17:24:08 -08:00
rht
548c96ad86 zilencer: Text-wrap long lines exceeding 110. 2017-11-07 17:24:06 -08:00
Tim Abbott
900cd13865 docs: Link to postgres documentation for SSL modes.
For some historical reason we'd had the Postgres documentation on
valid SSL modes copied into the Zulip settings.py template file.  This
fixes that historical artifact.
2017-11-07 16:55:32 -08:00
David Rosa Tamsen
dd10d30d1e docs: Add setting to conf.py to disable sticky_navigation
The left navigation bar defaults to "sticking" to the screen as you
scroll.  This commit adds the sticky_navigation setting to conf.py to
disable the default behavior.

This addresses part of #5265.
2017-11-07 16:48:15 -08:00
Steve Howell
c2860ce214 Set client_gravatar=True in the webapp.
The webapp knows how to compute gravatar URLs, so there is no need
for the server to send us gravatar URLs.
2017-11-07 16:38:14 -08:00
Steve Howell
8616a4ebc5 Use client_gratavar=True for users on in page_params.
This change affects realm_users and realm_non_active_users.

Note that we still send full avatar urls in realm_user/add
events, so apply_events has to do something mildly hacky to
turn the avatar_url to None in that case.

Fixing the event is probably not worth the trouble, as single
urls are not bandwidth hogs; we only need this optimization
for bulk data.
2017-11-07 16:38:14 -08:00
Steve Howell
a076581426 Use client_gravatar=True for avatar URLs in page_params.
This change affects these values:

    * page_params.avatar_url
    * page_params.avatar_url_medium

It requires passing the client_gravatar flag through this
codepath:

    * home_real
    * do_events_register
    * fetch_initial_state_data
    * avatar_url
2017-11-07 16:38:14 -08:00
rht
8242c15b48 zerver/lib: Remove unused imports (F401). 2017-11-07 16:37:13 -08:00
rht
17a19993f1 analytics/tests: Remove unused imports (F401). 2017-11-07 16:37:11 -08:00
rht
fa09076ec9 analytics/management: Remove unused imports (F401). 2017-11-07 16:37:09 -08:00
rht
b557b02f2f analytics/lib: Remove unused imports (F401). 2017-11-07 16:37:07 -08:00
rht
c4f09156ff corporate: Remove unused imports (F401). 2017-11-07 16:37:04 -08:00
rht
047eca1629 zproject: Remove unused imports (F401). 2017-11-07 16:37:03 -08:00
rht
995b300840 zilencer: Remove unused imports (F401). 2017-11-07 16:37:01 -08:00
rht
3c083a99dc confirmation: Remove unused imports (F401). 2017-11-07 16:36:59 -08:00
rht
926f0a7b45 zerver/tornado: Remove unused imports (F401). 2017-11-07 16:36:57 -08:00
rht
d6aa7f7738 zerver/management: Remove unused imports (F401). 2017-11-07 16:36:54 -08:00
Brock Whittaker
54ac11f2e1 left-sidebar: Fixup line height issues with unread counts.
This centers the text along with the unread counts vertically within
the <li> in the left sidebar.
2017-11-07 16:28:34 -08:00
Rishi Gupta
15b3a8e4ff email change: Use confirmation object user to determine changeability.
Seems like the more logical check. Also, the previous code makes it feel
like there is a potential vulnerability where one could get an email change
object in a realm where email changes are disabled, and then open that link
while logged in to a different realm.

While we're at it, remove the unnecessary check that the user is
logged in when clicking the confirmation link; that creates
unnecessary trouble for users who use multiple browsers.
2017-11-07 16:26:27 -08:00
Rishi Gupta
4fc8aa2b53 email change: Refactor confirmation path for readability.
Removes an assert, which at this point is there just for readability, since
the second argument to
get_object_from_key(confirmation_key, Confirmation.EMAIL_CHANGE)
ensures that the returned object is of the correct type.
2017-11-07 16:02:49 -08:00
Rishi Gupta
6fbb7e8046 email change: Remove confirmation_key.lower() from confirm_email_change.
Not sure why it is here, and it adds confusion.
2017-11-07 16:02:49 -08:00
Rishi Gupta
1823d46236 unsubscribe: Use a custom confirmation error page.
Reverts a bit of 6e02ce8.
2017-11-07 16:02:49 -08:00
sagar-kalra
c2f1f54190 help: Fix indentation of code blocks in desktop install guide.
Apparently, one can fix these by indenting 4 spaces beyond what would
have been sufficient to stay inside the bulleted lists.

Fixes #7075.
2017-11-07 15:48:34 -08:00
Angelika Serwa
9930cb43cd stream_settings: Add loading spinner when creating a new stream.
Add a spinner for when a stream is being created to show that
an operation is being performed, while also disallowing users to
modify the form in the meanwhile.

Commit modified by Brock Whittaker <brock@zulipchat.com>.

Fixes: #5268.
2017-11-07 12:26:47 -08:00
Tim Abbott
17f3cbbb90 Revert "static: Optimize SVG images."
This apparently messed up the size of the bot icon on some browsers.

This reverts commit 7a6e0dda41.
2017-11-07 12:15:22 -08:00
Tim Abbott
417f92c8e1 markdown: Remove now-obsolete bugdown_matches_marked.
Fixes #7099.
2017-11-07 12:01:57 -08:00
Rhea Parekh
34667e7b64 markdown_test_cases: Clean bugdown_matches_marked from the tex cases. 2017-11-07 11:55:25 -08:00
neiljp (Neil Pilgrim)
4194dcfff1 mypy: set SubSuiteList to inherit from typed List.
Modified by tabbott to add the `type: ignore`, which is basically
required by the monkey-patching we're doing here.
2017-11-07 11:39:21 -08:00
neiljp (Neil Pilgrim)
9655c4f122 mypy: Amend type of bad_stream_content within test_bad_narrow_stream_content. 2017-11-07 11:26:46 -08:00
neiljp (Neil Pilgrim)
8a0d4e6bff mypy: Improve typing of test_narrow.py:exercise_bad_narrow_operand.
- Add explicit Any type parameter to Sequence
- Specify compatible List type parameters for addition in function body.
2017-11-07 11:26:46 -08:00
neiljp (Neil Pilgrim)
1dcc981af8 mypy: Add explicit Any type parameters for embedded data Dicts. 2017-11-07 11:26:46 -08:00
neiljp (Neil Pilgrim)
d038bf89ac mypy: Adjust pivotal/view.py function parameter type based on body. 2017-11-07 11:26:46 -08:00
neiljp (Neil Pilgrim)
6a1786dc1b mypy: Clarify return type of _check_messages_before_archiving. 2017-11-07 11:26:46 -08:00
neiljp (Neil Pilgrim)
88424bed0b mypy: Clarify types in add_missing_messages in soft_deactivation.py. 2017-11-07 11:26:46 -08:00
YJDave
3c63367caf delete: Fix bug in appearance of popover in mobile-screen. 2017-11-07 11:20:25 -08:00
Cynthia Lin
576be51bc9 message feed: Change sub button styling to new style. 2017-11-07 11:10:52 -08:00
Brock Whittaker
95f34b2a90 left-sidebar: Increase line-height to not cut off text bottom.
This increases the line height so it does not cut off the bottom of the
stream text in characters like “g”.
2017-11-07 10:57:00 -08:00
Brock Whittaker
c5eaf303cc left-sidebar: Allow for more space for unread counts.
This leaves enough space for up to 100,000 unread message counts, which
perhaps above we should change to say something like “102K”.
2017-11-07 10:57:00 -08:00
rht
fa7016644e refactor: Remove six.moves.https_cookies import. 2017-11-07 10:51:44 -08:00
rht
01eb22abd9 refactor: Remove all the remaining six.moves import. 2017-11-07 10:51:44 -08:00
rht
9c7d5812ce refactor: Remove six.moves.urllib.parse import. 2017-11-07 10:51:44 -08:00
rht
ccf2792c1c refactor: Remove six.moves.configparser import. 2017-11-07 10:51:44 -08:00
rht
de319b4558 refactor: Remove six.moves.StringIO import. 2017-11-07 10:51:44 -08:00
rht
6b12fe24b6 refactor: Remove six.moves.input import. 2017-11-07 10:51:44 -08:00
rht
14671fc7b9 refactor: Remove six.moves.zip_longest import. 2017-11-07 10:51:44 -08:00
rht
6cce0e346e refactor: Remove six.moves.filter import. 2017-11-07 10:51:44 -08:00
rht
80a8d4f9f3 refactor: Remove six.moves.map import. 2017-11-07 10:46:42 -08:00
rht
549a26860f refactor: Remove six.moves.range import. 2017-11-07 10:46:42 -08:00
rht
ec5120e807 refactor: Remove six.moves.zip import. 2017-11-07 10:46:42 -08:00
rht
19bd335cbb Change urllib import to be Python 3-specific. 2017-11-07 10:46:42 -08:00
Steve Howell
8450f0ec69 Register client_gravar=True for the webapp. 2017-11-07 10:42:18 -08:00
Steve Howell
2bbfda041a Support client_gravatar field for event registration.
This commit allows clients to register client_gravatar=True, and
then we recognize that flag for message events.  If the flag is
True, we will not calculate gravatar URLs and let the clients do
it themselves.  (Clients can calculate gravatar URLs based on
emails with just a little bit of code.)
2017-11-07 10:42:17 -08:00
Steve Howell
f105c480b3 Calculate gravatar hashes on the webapp client.
This change prepares us to have the server send avatar_url
of None when somebody wants a gravatar avatar (as opposed
to a user-uploaded one).

Subsequent commits will change behavior on both the server
and client to have this happen.  So this commit has no-op
code for now, but it will soon use the fallback-to-gravatar
logic.
2017-11-07 10:36:02 -08:00
Steve Howell
3462127ddb Improve test_client_info_for_normal_users().
We now test both possible values of apply_markdown.
2017-11-07 10:36:02 -08:00
Steve Howell
01777623a7 Improve test_get_events_narrow().
We now test message events with both possible value of
apply_markdown (False and True).
2017-11-07 10:36:02 -08:00
Steve Howell
88e1e284bb Restructure send-message code for gravatars.
This refactoring doesn't change behavior, but it sets us up
to more easily handle a register setting for `client_gravatar`,
which will allow clients to tell us they're going to compute
their own gravatar URLs.

The `client_gravatar` flag already exists in our code, but it
is only used for Django views (users/messages) but not for
Zulip events.

The main change is to move the call to `set_sender_avatar` into
`finalize_payload`, which adds the boolean `client_gravatar`
parameter to that function.  And then we update various callers
to supply that flag.

One small performance benefit of this change is that we now
lazily compute the client message payloads in
`event_queue.process_message_event` now, so this will improve
performance if all interested clients have the same value of
`apply_markdown`.  But the change here is really preparing us
for the additional boolean parameter, which will cause us to
have four variations of the payload.
2017-11-07 10:36:02 -08:00
Steve Howell
2a6c6518fc refactor: Don't shadow message_dict in process_message_event(). 2017-11-07 10:36:02 -08:00
Steve Howell
5be13fb066 Add cachify decorator. 2017-11-07 10:36:02 -08:00
Steve Howell
7e4702c9c1 Avoid double-escaping HTML for settings notifications.
The i18n.t function already escapes HTML, so we should avoid
calling jQuery's text() method, which double escapes the HTML.

The symptom reported here was that if you changed your
timezone to something like like America/Mexico_City, you'd
see `&#x2F;` instead of `/`.

Most callers to the `ui_report` functions clearly call `i18n.t`
on the messages with code like this:

    ui_report.success(i18n.t("No changes to save!"), status);

There are some exceptions:

    blueslip.js: has really long hard coded messages
    reload.js: mostly says "Reloading...", which perhaps we should
               translate
    settings_account.js: uses helper functions
    settings_lab.js: uses local variable
    settings_org.js: i18n happens in property_types
    ui.js: uses generic_embed_error (unaffected by this change)

Fixes #7280
2017-11-07 09:52:20 -08:00
Steve Howell
567da076ad i18n: Translate strings in settings_account.js. 2017-11-07 09:52:20 -08:00
Steve Howell
2b6fee3c53 i18n: Translate deactivation errors in the webapp. 2017-11-07 09:52:20 -08:00
Steve Howell
aa61db9301 Change warn -> error in people.report_late_add().
This commit is easy to revert if we want to tone down errors
to warnings for the short term, while our codepath still does
proper handling for adding users when they come in messages.
2017-11-07 09:51:10 -08:00
Steve Howell
02a011d627 Add people.report_late_add().
We want to know when users are added after page load, as it can
be a symptom of stray messages leaking in or live-update problems,
etc.

Fixes #7120
2017-11-07 09:51:10 -08:00
Steve Howell
aebfdaa8ed refactor: Use early-return in extract_people_from_message(). 2017-11-07 09:51:10 -08:00
Steve Howell
294a1fb8f8 refactor: Extract people.maybe_incr_recipient_count().
This logic used to be in extract_people_from_message(), but
we are deprecating extract_people_from_message(), whereas
the maybe_incr_recipient_count() function has logic that we
want to keep.
2017-11-07 09:51:10 -08:00
Steve Howell
c291c74e45 minor: Make comment more accurate in popover error condition. 2017-11-07 09:51:10 -08:00
Steve Howell
5271241b24 Read page_params.realm_non_active_users() at page load.
This change is the first step in making it so that we load
non-active users at page load time in the webapp.

Before this change, we would reactively handle deactivated
users when we saw them as senders in messages.  Subsequent
changes will make it a warning if we see unknown senders
in messages.
2017-11-07 09:51:10 -08:00
Steve Howell
b492f3569a tests: Extract node_tests/people_errors.js.
This is mostly a pure extraction, but we needed to duplicate
a bit of setup from people.js, and I added an assertion
for warning about "No user_id provided".
2017-11-07 09:51:10 -08:00
Steve Howell
48b18e4a38 Only show active realm users in compose typeahead.
There's no reason to include deactivated users in compose
typeahead, since we won't let the compose happen.

This also removes cross-realm bots from the typeahead, which
is mostly driven by not having a convenient function to include
them, but also it's rare that it makes sense to talk to a cross-realm
bot unless replying to it.
2017-11-07 09:51:10 -08:00
derAnfaenger
a61a127ca5 integrations: Update twitter bot commands.
This removes redundant arguments for specifying
the zulip server address (it's already contained
in the zuliprc).
2017-11-07 09:44:24 -08:00
derAnfaenger
c8e87a322d queue processors: Exclude TestWorker from coverage. 2017-11-07 09:38:58 -08:00
derAnfaenger
0709033858 bugdown: Fetch complete data for tweet.
This makes an extended instead of a normal query,
resulting in the full text of a tweet being fetched
instead of just a truncated version.
2017-11-07 09:13:39 -08:00
Vishnu Ks
c5ff020246 droplets: Garbage collect A records before creating droplet. 2017-11-06 12:20:39 -08:00
Rishi Gupta
dec4b9ed93 remote dev: Add code and instructions for creating digital ocean droplets.
Mostly copied from the zulip/zulip-gci repository, but with some changes to
wordings and code cleanup for linters.
2017-11-06 12:20:39 -08:00
Rishi Gupta
b31af80c5f requirements: Update comments output by update-locked-requirements.
I just ran tools/update-locked-requirements and commited the changes.
2017-11-06 12:20:39 -08:00
rht
e3eebf3be0 Remove inheritance from object. 2017-11-06 08:53:48 -08:00
rht
8990b1046d zerver: Remove inheritance from object. 2017-11-06 08:53:48 -08:00
rht
2ceb0b45b3 zerver/tornado: Remove inheritance from object. 2017-11-06 08:53:48 -08:00
rht
c7fa1d4146 zerver/tests: Remove inheritance from object. 2017-11-06 08:53:48 -08:00
rht
864e16f30d zerver/migrations: Remove inheritance from object. 2017-11-06 08:53:48 -08:00
rht
e311842a1b zerver/lib: Remove inheritance from object. 2017-11-06 08:53:48 -08:00
rht
0e71b243ce zilencer: Remove inheritance from object. 2017-11-06 08:53:48 -08:00
rht
e33c8d91e0 zproject: Remove inheritance from object. 2017-11-06 08:53:48 -08:00
rht
5cfffb0e51 analytics: Remove inheritance from object. 2017-11-06 08:53:48 -08:00
Cynthia Lin
7a6e0dda41 static: Optimize SVG images. 2017-11-04 20:57:19 -07:00
Cynthia Lin
d94a84e77f static: Remove unused images. 2017-11-04 20:57:19 -07:00
neiljp (Neil Pilgrim)
42f5eea61f mypy: Improve typing of request.pyi (REQ).
This expands request.pyi to type-check the arguments passed into REQ.

Tweaked by tabbott to fix the report.py annotations.
2017-11-04 20:26:03 -07:00
rht
dd1920c811 confirmation: Use python 3 syntax for typing. 2017-11-04 19:59:41 -07:00
rht
ada9979f51 docs: Use python 3 syntax for typing. 2017-11-04 19:58:05 -07:00
rht
26b6b893e6 zproject: Use python 3 syntax for typing. 2017-11-04 19:58:03 -07:00
rht
77f32a1e0c frontend_tests: Use python 3 syntax for typing. 2017-11-04 19:57:55 -07:00
neiljp (Neil Pilgrim)
0d31cb568c mypy: Broaden some types from Dict to Any based on context. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
055dff9038 mypy: Clarify parameter types in test_decorators.py. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
6e6b1ce0d5 mypy: Explicitly inherit test_[sequence|mapping] test classes from generic types. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
3fd720d8f4 mypy: Broadly specify lambda type parameters in test_events.py. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
aae8a03415 mypy: Explicitly specify Dict[str, Any] as DummyForm base type. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
2a2870eec8 mypy: Fully specify type of Callable parameter to process_instrumented_calls. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
b0e9fd7fa0 mypy: Specify type of decorator correctly in test_logging_handlers.py. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
f3b5b9db78 mypy: Specify Callable parameters in FakeClient functions in WorkerTest. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
6f490394c3 mypy: Set explicit Any-like parameters for StatsMock functions. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
692e2150c6 mypy: Explicitly specify List[Any] in test_classes.py. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
792a580efb mypy: Specify Callable type parameters in test_helpers.py. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
952f034136 mypy: Set explicit Any-like parameters for handle_callback_exception in runtornado.py. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
186181c2a0 mypy: Specify type parameters in convert_term in narrow_parameter. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
da97de3370 mypy: Use Dict[Any,Any] for update_realm parameter. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
720df640e7 mypy: Set freshdesk TicketDict to inherit from typed Dict. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
6c995db231 mypy: Use Iterator[Any] as return type of queryset_iterator. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
1197ff9655 mypy: Explicitly return Set[Any] for empty set in backends.py. 2017-11-04 19:47:45 -07:00
neiljp (Neil Pilgrim)
54cbb808e6 mypy: Add explicit Any parameters to get_user_events return type. 2017-11-04 19:47:44 -07:00
neiljp (Neil Pilgrim)
fed757452c mypy: Clarify type of lookup_dict in aggregate_message_dict. 2017-11-04 19:47:44 -07:00
neiljp (Neil Pilgrim)
b693f32c0b mypy: Add Dict parameters for dropbox_image return type.
Also a note re using TypedDict in future, as the Dict looks constrained.
2017-11-04 19:47:44 -07:00
neiljp (Neil Pilgrim)
737408f741 mypy: Add explicit flexible type parameters for Callable in run-dev.py. 2017-11-04 19:47:44 -07:00
neiljp (Neil Pilgrim)
9f90a3174b mypy: Add explicit Any as Dict parameters in check_line_coverage in test-js-with-node. 2017-11-04 19:47:44 -07:00
neiljp (Neil Pilgrim)
221be326a9 mypy: Set type parameters for IO to Any in scripts/lib/node_cache.py. 2017-11-04 19:47:44 -07:00
neiljp (Neil Pilgrim)
abc0d5e79b mypy: Add type parameter for Set in check_help_documentation.py. 2017-11-04 19:47:44 -07:00
neiljp (Neil Pilgrim)
a5d1fdf0d6 mypy: Add type parameter for IO in test-queue-worker-reload. 2017-11-04 19:47:44 -07:00
neiljp (Neil Pilgrim)
458ab3020d mypy: Add explicit Any for generic types in type_debug.py. 2017-11-04 19:47:44 -07:00
Tim Abbott
ff2f55e8ba docs: Add some basic coverage of our mypy Python 3 situation. 2017-11-04 19:46:32 -07:00
Tim Abbott
671c3dea66 mypy: Fix type annotation style in webhook walkthrough. 2017-11-04 19:44:12 -07:00
rht
969cc506d2 zerver/webhooks: Use python 3 syntax for typing.
Tweaked by tabbott to fix various line-wrapping issues.
2017-11-04 19:40:32 -07:00
Greg Price
68b0a419ec decorator: Cut a bunch of dead imports of two view decorators.
Saw these when grepping for these two decorators; they're actually
more numerous than the surviving use sites are.  Cut out the noise.
2017-11-04 19:27:00 -07:00
Greg Price
6b9d294873 auth: Set user_activity query nicely for several auth views.
This gets used when we call `process_client`, which we generally do at
some kind of login; and in particular, we do in the shared auth
codepath `login_or_register_remote_user`.  Add a decorator to make it
easy, and use it on the various views that wind up there.

In particular, this ensures that the `query` is some reasonable
constant corresponding to the view, as intended.  When not set, we
fall back in `update_user_activity` on the URL path, but in particular
for `log_into_subdomain` that can now contain a bunch of
request-specific data, which makes it (a) not aggregate properly, and
(b) not even fit in the `CHARACTER VARYING(50)` database field we've
allotted it.
2017-11-04 19:27:00 -07:00
Greg Price
b2d35872ed decorator: Set the user_activity query in another case.
Now that this is a little less mysterious-looking to do,
let's do it in this spot too.
2017-11-04 19:27:00 -07:00
Greg Price
1a540241a9 require_server_admin: Cut a redundant bit of request-mutation.
The only place this attribute is used is in `update_user_activity`,
called only in `process_client`, which won't happen if we end up
returning a redirect just below.  If we don't, we go and call
`add_logging_data` just after, which takes care of this already.
2017-11-04 19:27:00 -07:00
Greg Price
b871aa9622 user_activity: Allow passing the query more directly.
This won't work for all call paths without deeper refactoring,
but for at least some paths we can make this more direct -- function
arguments, rather than mutating a request attribute -- so it's easier
to see how the data is flowing.
2017-11-04 19:27:00 -07:00
Tim Abbott
732a5bae84 analytics: Fix checks for pointer update route. 2017-11-04 19:27:00 -07:00
neiljp (Neil Pilgrim)
dac67ebe67 mypy: Remove un-necessary comment re mypy issue #3145.
RuleList is required at global scope now, for later functions.
2017-11-04 19:22:06 -07:00
neiljp (Neil Pilgrim)
7d6d8fc848 mypy: Improve type annotation of run_parallel in zerver/lib/parallel.py. 2017-11-04 16:18:27 -07:00
neiljp (Neil Pilgrim)
05ef052ef5 mypy: Improve typing in custom_check_file() in custom_check.py. 2017-11-04 16:18:27 -07:00
neiljp (Neil Pilgrim)
d63733077f mypy: Return AdminZulipHandler in test_logging_handlers.py.
Switching from __class__.__name__ to isinstance() allows mypy to
confirm the list comprehension type, and so the return type.
2017-11-04 16:18:27 -07:00
neiljp (Neil Pilgrim)
be856bad46 mypy: Reduce use of Any in zerver/lib/url_preview/ return types. 2017-11-04 16:18:27 -07:00
Rhea Parekh
b972b083d9 markdown_test_cases: Clean cases where bugdown_matches_marked is false.
Fixes #7099.
2017-11-04 10:44:35 -07:00
Cynthia Lin
f63585bd6d hotkeys: Ensure navigation hotkeys do not work while overlay is open.
Fixes #7123.
2017-11-03 15:38:10 -07:00
Cynthia Lin
e7de4f5d74 hotkeys: Modify draft toggle behavior. 2017-11-03 15:38:10 -07:00
rht
fef7d6ba09 zerver/lib: Remove u prefix from strings.
License: Apache-2.0
Signed-off-by: rht <rhtbot@protonmail.com>
2017-11-03 15:34:37 -07:00
Rishi Gupta
5d04e29ac2 confirmation: Add comment for registration.confirmation_key.
I remember being really confused by this function in the past, and I finally
figured it out. It should be removed, and the dev_url added by
00-realm-creation should call a function that just gets the confirmation_key
from outbox like all of the backend tests, but until then this comment
should help.
2017-11-03 15:33:16 -07:00
Rishi Gupta
6e02ce8344 unsubscribe: Use get_object_from_key for confirmation.
This is the only one of the confirmation pathways that wasn't using this
idiom, I think.
2017-11-03 15:33:16 -07:00
Rishi Gupta
fdbe36644e confirmation: Add confirmation_type to get_object_from_key.
This change:

* Prevents weird potential attacks like taking a valid confirmation link
  (say an unsubscribe link), and putting it into the URL of a multiuse
  invite link. I don't know of any such attacks one could do right now, but
  reasoning about it is complicated.

* Makes the code easier to read, and in the case of confirmation/views.py,
  exposes something that needed refactoring anyway (USER_REGISTRATION and
  INVITATION should have different endpoints, and both of those endpoints
  should be in zerver/views/registration, not this file).
2017-11-03 15:33:16 -07:00
akashnimare
608a594256 docs: Update desktop app version to stable 2017-11-03 15:08:57 -07:00
Tim Abbott
957e1c2ec6 mypy: Fix buggy import setup for embedded bot tests. 2017-11-03 14:38:43 -07:00
Tim Abbott
c3db9513f2 tornado: Delete fake_message_sender.
This test helper method duplicated a bunch of logic in
`zerver/worker/queue_processors.py` in a specialized fashion for the
tests.  Now that we're using `call_consume_in_tests` in this code
path, we don't need it.
2017-11-03 14:11:23 -07:00
Tim Abbott
eade4d0052 tornado: Use call_consume_in_tests for message_sender queue.
This increases test coverage of queue_processors.py significantly,
with no real cost, achieving valuable progress torwards #6542.
2017-11-03 14:09:48 -07:00
derAnfaenger
f382875d5a embedded bots: Add full test coverage for queue processor. 2017-11-03 13:57:24 -07:00
derAnfaenger
3985cae689 outgoing webhook bots: Add message flow tests.
This adds coverage for the outgoing_webhooks
queue worker.
2017-11-03 13:55:16 -07:00
derAnfaenger
84328320eb outgoing webhook tests: Simplify response mock.
Before this commit, ResponseMock() was initialized
with a data attribute, which isn't used in the tests
and does not occur in the outgoing webhook code.
2017-11-03 13:53:39 -07:00
Greg Price
909631b5a9 docs/oauth: Update for Google UI changes, and for zulipdev.com.
The control panel on the Google side doesn't seem to match the
instructions we have; it looks pretty 2017 to me, so I imagine
it's had a redesign since the instructions were written.

Also, in dev, EXTERNAL_HOST is now a port on zulipdev.com, not on
localhost.

Update these instructions for those developments, and edit lightly.
In dev, recommend setting in `dev_settings` instead of in
`prod_settings_template`; that feels to me a little more reflective of
the actual intent, and the effect should be equivalent.
2017-11-03 13:38:59 -07:00
Greg Price
eafb82ab2e docs: Move docs on testing OAuth to their own page.
In some minutes of searching yesterday afternoon on the docs site,
I couldn't find docs on how to set up our OAuth integrations for
the dev environment -- even though I was pretty sure they should
be there somewhere, because I'd just been told that.  Wasn't until
I considered the problem fresh today, and grepped the docs source
instead, that I found them.

So, move them to a separate page so they're in the nav.
2017-11-03 13:38:59 -07:00
Greg Price
119bc14182 alias domains: Add a v1 of this feature.
The main limitation of this version is that it's controlled entirely
from settings, with nothing in the database and no web UI or even
management command to control it.  That makes it a bit more of a
burden for the server admins than it'd ideally be, but that's fine
for now.

Relatedly, the web flow for realm creation still requires choosing a
subdomain even if the realm is destined to live at an alias domain.

Specific to the dev environment, there is an annoying quirk: the
special dev login flow doesn't work on a REALM_HOSTS realm.  Also,
in this version the `add_new_realm` and `add_new_user` management
commands, which are intended for use in development environments only,
don't support this feature.

In manual testing, I've confirmed that a REALM_HOSTS realm works for
signup and login, with email/password, Google SSO, or GitHub SSO.
Most of that was in dev; I used zulipstaging.com to also test
 * logging in with email and password;
 * logging in with Google SSO... far enough to correctly determine
   that my email address is associated with some other realm.
2017-11-03 13:38:59 -07:00
Greg Price
b33d981d7b settings: Simplify setting ALLOWED_HOSTS, by handling EXTERNAL_HOST.
This means one fewer thing the admin typically needs to read, absorb,
and make a decision about at install time.

The one way this change could hypothetically cause trouble is if the
admin wants to keep subdomains of EXTERNAL_HOST out of ALLOWED_HOSTS.
But while the subdomains often won't exist as domain names, it's hard
to imagine the situation in which they would exist but be under
someone else's control, or be doing something other than serving
Zulip realms.
2017-11-03 13:38:59 -07:00
Greg Price
31302c3670 integrations/redmine: Clean up a bit of grammar in the docs.
It's kind of awkward that this takes the scheme-relative URL -- either
the full URL, or maybe just the host, would make more sense.  But on a
bit of study of the plugin's source, I can't convince myself that it
won't break if given the full URL with the scheme.  (See a code
comment thread in #7116.)  So leave the substance as is, pending the
plugin itself getting some cleanup, but do fix the sentence's English
grammar since we're looking at it.
2017-11-03 13:38:59 -07:00
Greg Price
e9a4596ea9 integrations/hubot: Fix URL in example config.
tabbott checked the source and confirmed my suspicion
(in eb55a3a1b) that this should be a full URL, not scheme-relative.
2017-11-03 13:38:59 -07:00
Steve Howell
9767029211 Allow generic bots to be mentioned.
The original PR to allow generic bots to be mentioned had
some merge issues that we detected about a week after the
fact.  This commit restores the logic from the original PR.

The reason we didn't detect this bug earlier is that the
merge issues didn't break any existing behavior.  Instead,
they made it so that only UserMessage rows got written for
bots, but no events were being set.  The part of the commit
that got lost is restored here, so now events get sent as
well.

Thanks to @derAnfaenger for reporting this and being patient
as we tracked it down.

Fixes #7140
2017-11-03 07:45:18 -07:00
derAnfaenger
2155b255d6 service bot tests: Remove bot stream subscription.
Since service bots react to all @-mentions, the
stream subscription was redundant.
2017-11-02 14:44:11 -07:00
Eeshan Garg
aaaed74c3d webhooks: Import REQ, has_request_variables from zerver.lib.request.
We now import REQ and has_request_variables from zerver.lib.request,
which is where these methods are defined.

Fixes #7195.
2017-11-02 14:40:55 -07:00
Eeshan Garg
20f3e9b779 webhooks/gci: Support 'needswork' event_type.
This commit adds support for payloads that are generated when a
mentor submits a task for more work.
2017-11-02 16:46:11 -02:30
Eeshan Garg
9969a3a40b webhooks/gci: Replace 'type' -> 'event_type', 'uuid' -> 'id'. 2017-11-02 16:39:48 -02:30
rht
839b427ea5 zerver/management: Remove u prefix from strings.
License: Apache-2.0
Signed-off-by: rht <rhtbot@protonmail.com>
2017-11-02 11:01:47 -07:00
rht
dc37e3f72c zerver/migrations: Remove u prefix from strings. 2017-11-02 11:01:47 -07:00
rht
38acddee99 zproject: Remove u prefix from strings. 2017-11-02 11:01:47 -07:00
rht
be2a720a04 refactor: Replace %r with %s in string representations of classes. 2017-11-02 11:01:47 -07:00
rht
dcc831f767 refactor: Replace all __unicode__ method with __str__.
Close #6627.
2017-11-02 11:01:47 -07:00
rht
e51d98cd96 refactor: Remove usage of ModelReprMixin. 2017-11-02 11:01:47 -07:00
Brock Whittaker
4af9e11115 left-sidebar: Add overflow ellipsis on long stream names.
On stream names that don’t quite fit, we’ll add overflow ellipsis to
them. It appears we already did this on mobile in a sub-optimal way so
we can remove that media query with preference to the new, better
styling.
2017-11-01 13:27:42 -07:00
Brock Whittaker
c9af964357 list_render: Add sorting reversal.
This allows a user to reverse the sort order by clicking again on an
active tab, which changes from ascending to descending order.

Fixes: #7254.
2017-11-01 13:26:40 -07:00
Brock Whittaker
26dd785b2b list_render: Use correct arrow for ascending.
Ascending files (as it currently is by default) should use an upwards
arrow.
2017-11-01 13:26:40 -07:00
Brock Whittaker
fd19743098 settings: Fix scrolling on settings page in narrow height windows.
This allows a user to scroll all the way down on the sidebar and the
main panel in the settings page on narrow height windows by removing
the min-height specification and making the “Log out” line in the
sidebar become statically positioned at shorter heights.

Fixes: #7251.
2017-11-01 13:25:27 -07:00
Steve Howell
85f605a978 Fix bug with EmailLogBackend.send_messages.
The `logging.info` call was not properly using string interpolation.
2017-11-01 10:05:13 -07:00
Cynthia Lin
ad374ad3c5 css: Fix improper indentation to fix Travis test failure. 2017-10-31 18:58:59 -07:00
Cynthia Lin
6a4e7ad12e user settings: Enhance Uploaded files sorting.
Fixes #7149
2017-10-31 18:33:41 -07:00
Cynthia Lin
5d9327a25b user settings: Improve Uploaded Files design.
* Prevent long file names from corrupting table display.

* Add sticky table header.

Fixes #7189.
2017-10-31 18:33:41 -07:00
Tim Abbott
3ed707c225 docs: Add more detail on the apt upgrade process and postgres. 2017-10-31 18:11:54 -07:00
Tim Abbott
1432e9afb0 Revert "vagrant: Switch Virtualbox to use NFS for syncing files."
This reverts commit 4d7f1e7c88.

Apparently, Vagrant's parsing seems to result in this demanding a
network connection.  Further investigation is needed.
2017-10-31 17:49:53 -07:00
Harshit Bansal
44bff43c86 actions.py: Rename do_remove_reaction() to do_remove_reaction_legacy(). 2017-10-31 15:42:35 -07:00
Harshit Bansal
233595b2f7 actions.py: Rename do_add_reaction() to do_add_reaction_legacy(). 2017-10-31 15:42:35 -07:00
Umair Khan
636046aec9 user-groups: Add basic backend for UserGroup model.
This adds the data model and bugdown support for the new UserGroup
mention feature.

Before it'll be fully operational, we'll still need:
* A backend API for making these.
* A UI for interacting with that API.
* Typeahead on the frontend.
* CSS to make them look pretty and see who's in them.
2017-10-31 15:16:14 -07:00
Umair Khan
5914afc018 cleanup: Use a single loop in do_send_messages. 2017-10-31 12:56:14 -07:00
Steve Howell
9689168bf6 Simplify highlight_string logic.
This change avoids some complicated byte arithmetic by
extracting some local variables and being more explicit
about using bytes vs. using strings.
2017-10-31 12:45:58 -07:00
Tim Abbott
6df65abd50 team: Tweak some text. 2017-10-31 12:44:05 -07:00
Tim Abbott
d27002ba21 landing-page: Replace /about with /team and /history in links. 2017-10-31 12:44:05 -07:00
Brock Whittaker
425738fa24 landing-page: Extract /team/ from /about/.
This extracts and creates a /team/ page using the existing
'team.html' template and applying the why-page styling to it.
2017-10-31 11:37:42 -07:00
Tim Abbott
4d7f1e7c88 vagrant: Switch Virtualbox to use NFS for syncing files.
This seems to help with frequent virtualbox guest crashes that we've
been having on Macs recently.

Thanks to Umair Khan for figuring this out.
2017-10-31 11:11:34 -07:00
Sampriti Panda
d6df408a0e search: Add tests for multiple unicode search operands. 2017-10-31 10:53:16 -07:00
sandeepsajan0
04a79800b9 models: Fix typo in comment. 2017-10-31 10:46:38 -07:00
Tim Abbott
5e3ba1f20f mypy: Fix an unnecessary duplicate type declaration. 2017-10-31 10:46:02 -07:00
Sampriti Panda
ee61e1be2c search: Fix misaligned highlights due to unicode characters.
tsearch_extras returns search offsets in bytes but our highlight
function treated them as character offsets.  Added a check to subtract
extra bytes if the tsearch search backend is being used.

Fixes #4084.
Fixes #7021.
2017-10-31 09:06:46 -07:00
Tim Abbott
8f9463bd72 test_bugdown: Check for unknown keys in markdown_test_cases.json.
This should help protect us from typos.
2017-10-31 08:58:42 -07:00
Rhea Parekh
6f029d487e tests: Change test_content to text_content in markdown_test_cases.
docs: Fix error in markdown documentation.
2017-10-31 08:51:49 -07:00
Shubham Dhama
aab0eeb5cc popovers: Hide opened popover on navigating back.
Hides popover if it remains open and an overlay such as the settings
UI is opened via the browser back button.

Fixes: #7230.
2017-10-31 08:47:00 -07:00
neiljp (Neil Pilgrim)
5ec855967d mypy: Constrain return types to match in test_runner.py. 2017-10-31 00:03:35 -07:00
neiljp (Neil Pilgrim)
966d5f3760 mypy: Specify Callable parameter/return type for run decorator in tools/diagnose. 2017-10-31 00:03:35 -07:00
neiljp (Neil Pilgrim)
7d8de37299 mypy: Specify librato Callable type. 2017-10-31 00:03:35 -07:00
neiljp (Neil Pilgrim)
7288451329 mypy: Slightly clarify Callable parameter to WebsocketClient.__init__. 2017-10-31 00:03:35 -07:00
neiljp (Neil Pilgrim)
452802bf75 mypy: Add Callable parameters/returns to AsyncDjangoHandler in handlers.py, 2017-10-31 00:03:35 -07:00
neiljp (Neil Pilgrim)
5357c2e352 mypy: Reduce use of Any in UserPresence static methods.
Use str here since now using python3.
2017-10-31 00:03:35 -07:00
neiljp (Neil Pilgrim)
7f5b69bca8 mypy: Clarify Callable parameters & return type for get_timing. 2017-10-31 00:02:17 -07:00
neiljp (Neil Pilgrim)
304e411944 mypy: Remove unused FuncT TypeVar in cache.py. 2017-10-31 00:02:17 -07:00
Harshit Bansal
48662a79a5 clean-venv-cache: Fix an exception with unusual deployment dirs. 2017-10-31 00:01:09 -07:00
Tim Abbott
9bf81b7fa9 api: Fix /api/endpoints/ javascript for now.
This was apparently completely broken for some time, and got a bit
worse with my recent changes (enough to fail a test).

Since the plan for this page likely involves dissecting and
eliminating it, I think it makes sense to just fix it hackishly and
move on.
2017-10-30 23:58:12 -07:00
Harshit Bansal
8c9ea94878 scripts: Fix an issue in purge-old-deployments script.
We were not including the real path of the symlinks due to which we
were incorrectly deleting deployments pointed by last/current/next.
2017-10-30 23:09:51 -07:00
Tim Abbott
493529d981 compose: Fix node test failure from video link integration.
It's pretty annoying that we're seeing this several hours after the
original code was merged.
2017-10-30 23:06:04 -07:00
Tim Abbott
3104d3ea3e api: Fix rendering of code blocks after clicking sidebar links.
We need to call `render_code_sections` to show the code block for the
current language whenever switching which code block we're looking at.
2017-10-30 22:53:41 -07:00
Tim Abbott
f01f596138 help: Merge api.js and help.js bundles to fix code blocks.
In addition to decreasing the excessive number of bundles we had, this
will set us up to fix rendering of code blocks when clicking the
sidebar links in the /api-new site.
2017-10-30 22:53:17 -07:00
Brock Whittaker
e86e259cb1 /api/: Add Markdown-based /api-new documentation.
This commit allows for the /api-new/ page to rendered similarly to our
/help pages.  It's based on the old content for /api, but we're not
replacing the old content yet, to give a bit of time to restructure
things reasonably.

Tweaked by eeshangarg and tabbott.
2017-10-30 22:32:43 -07:00
Aditya Bansal
31ea495842 test_uploads: Extract 'use_s3_backend' to test helpers. 2017-10-30 21:56:31 -07:00
Aditya Bansal
269cd3b8bf tests: Remove work around for non-writeable name property of StringIO. 2017-10-30 21:56:31 -07:00
Greg Price
26edde21f7 alias domains: Tweak a test helper that assumes hosts are subdomains.
Because this is for tests, a heuristic like this that's right in most
situations is actually fine; we can override it in the few cases where
a test might set up a situation where it fails.

So just make it clear for the next reader that that's what's going on,
and also adjust the helper's interface slightly so that its callers
do have that flexibility.
2017-10-30 18:29:29 -07:00
Greg Price
22e5110789 subdomains: Dedupe out the last copy of Realm.host_for_subdomain.
This makes the affected code somewhat easier to read, and paves the
way for changing this logic to add support for alias domains.
2017-10-30 18:29:29 -07:00
Greg Price
eb55a3a1ba template context: Give better names to the URLs for the API.
The "subdomain" label is redundant, to the extent it's even
accurate -- this is really just the URL we want to display,
which may or may not involve a subdomain.  Similarly "external".

The former `external_api_path_subdomain` was never a path -- it's a
host, followed by a path, which together form a scheme-relative URL.
I'm not quite convinced that value is actually the right thing in
2 of the 3 places we use it, but fixing that can start by giving an
accurate name to the thing we have.
2017-10-30 18:29:29 -07:00
Greg Price
271a9f0da7 settings: Eliminate disused variable EXTERNAL_API_URI.
This was part of the logic to handle EXTERNAL_API_PATH varying.
But also it was already no longer used -- it was only ever passed
into template contexts, as `external_api_uri`, and it'd been
overtaken there by `external_api_uri_subdomain`.

So, update our dev docs to reflect that, and eliminate the variable.
2017-10-30 18:29:29 -07:00
Greg Price
aeb69dfd61 template context: Eliminate now-constant variable api_site_required. 2017-10-30 18:29:29 -07:00
Greg Price
bf1395b3ec template context: Eliminate the disused variable external_api_path.
This is not only now redundant, but actually already has no uses.
2017-10-30 18:29:29 -07:00
Greg Price
7366a4ca7a settings: Eliminate the disused EXTERNAL_API_PATH.
This setting isn't documented at all, and I believe nobody has used it
since the end of api.zulip.com in 2016.  So we get to complete the
cleanup of this logic.
2017-10-30 18:29:29 -07:00
Jack Zhang
fef828a037 compose: Add video link button, powered by Jitsi. 2017-10-30 17:13:47 -07:00
Tim Abbott
bb80c0cc24 compose_state: Extract insert_syntax_and_focus.
This moves the existing emoji picker code to a new library.
2017-10-30 17:12:56 -07:00
Tim Abbott
d1a5e0c7a5 compose: Move formatting help further left in icon row.
It make sense for attachments to be a bit further to the right,
especially as we add more widgets over there.
2017-10-30 16:41:01 -07:00
Tim Abbott
72774de6e3 compose: Wrap more message control button icon lines.
These lines were super long and obscured the code.
2017-10-30 16:40:43 -07:00
Steve Howell
1ac2360d2e mypy: Fix QuerySet -> QuerySet[Subscription]. 2017-10-30 16:33:51 -07:00
Steve Howell
faba34dae4 Simplify bulk_remove_subscriptions().
We extract get_bulk_stream_subscriber_info() from this
function to remove some of the complexity.  Also, in that
new function we avoid a hop to the database by querying
on stream ids instead of recipient ids.  The query that
gets changed here does require a join to the recipient
table (to get the stream id), so it's a little bit of a
tradeoff.
2017-10-30 16:33:50 -07:00
Steve Howell
48d13257b6 Make our_realm explicit in bulk_remove_subscriptions.
There's an implicit assumption in bulk_remove_subscriptions
that all users belong to the same realm.  We use the realm
for things like comparing occupied streams before and
after our main operation of deactivating streams.

Before this change, we just used the user_profile variable
that leaked from some prior loop to look up the realm, which
was super brittle.

Now we're a bit more explicit.
2017-10-30 16:29:43 -07:00
rht
c4fcff7178 refactor: Replace super(.*self) with Python 3-specific super().
We change all the instances except for the `test_helpers.py`
TimeTrackingCursor monkey-patching, which actually needs to specify
the base class.
2017-10-30 14:30:25 -07:00
Harshit Bansal
d140451fb4 html_diff: Migrate from Text to str. 2017-10-30 14:10:35 -07:00
Harshit Bansal
c863bb83a0 html_diff: Migrate to use lxml.
We were using Google's diff-match-patch library to diff HTML. The
problem with that approach is that it is a text differ, not an HTML
differ and so it ends up messing up the HTML tags. `lxml` is a safer
option.

Fixes: #7219.
2017-10-30 14:10:35 -07:00
Tim Abbott
c160c06f9c bot_storage: Fix missing test coverage.
Apparently, we didn't have coverage on setting a second value for a
key.
2017-10-30 14:10:35 -07:00
derAnfaenger
692db3f62b embedded bots: Move StateHandler query logic to separate file. 2017-10-30 13:37:56 -07:00
Tim Abbott
acb0b6ee43 process_fts_updates: Fix pgroonga search in development.
For some reason, we have the USING_PGROONGA setting on in development
right now.  I'm going to disable that in another commit to match what
we're doing in production, but we'll still want that setting to work
in development.

The problem here was that process_fts_updates only attempted to read
the USING_PGROONGA setting from a /etc/zulip/zulip.conf source, and
thus would just not be updating the index in development.
2017-10-30 11:44:04 -07:00
Felix Yan
aea33fc738 Fix a comment typo in zerver/middleware.py. 2017-10-30 10:36:35 -07:00
Steve Howell
2d0daffbc0 tests: Verify query counts for stream deactivation. 2017-10-29 18:36:35 -07:00
Steve Howell
08ad26f913 refactor: Extract get_stream_subscriptions_for_users(). 2017-10-29 18:36:35 -07:00
Steve Howell
b3192d17ab refactor: Extract get_stream_subscriptions_for_user(). 2017-10-29 18:36:35 -07:00
Steve Howell
a2747517a3 Extract StreamTopicTarget.get_active_subscriptions().
Note that this code leads to a slightly different query, because
we join to one row in the small Recipient table to match
stream_id to recipient.type_id.
2017-10-29 18:36:35 -07:00
Steve Howell
8e0b417bd9 Extract get_active_subscriptions_for_stream_ids(). 2017-10-29 18:36:35 -07:00
Steve Howell
126e14d1de Add zerver/lib/stream_subscription.py.
The first method we extract to this library is
get_active_subscriptions_for_stream_id().

We also move num_subscribers_for_stream_id() to here, which
is slightly annoying (having the method on Stream was nice)
but avoids some circular dependency issues.
2017-10-29 18:36:35 -07:00
Steve Howell
138568f4f4 refactor: Extract get_stream_recipients(). 2017-10-29 18:36:35 -07:00
Steve Howell
f64c780d5c Extract get_huddle_user_ids(). 2017-10-29 18:36:35 -07:00
Brock Whittaker
8c9579eb86 webpack.assets.json: Add a custom JS bundle for /api.
Note that we also need the JS bundle for /help because that
includes the JS code for our sidebar dropdowns.
2017-10-29 18:18:32 -07:00
Brock Whittaker
6933d51c0f views/integrations: Change non-generic HelpView to MarkdownDirectoryView.
The HelpView class will render a directory as markdown with an index HTML
page. This however can also be used for other generics and applied to
the API pages as well, so change the class to a generic class and
specify the path templates and names.

Tweaked by tabbott and Eeshan Garg.
2017-10-29 18:15:36 -07:00
Brock Whittaker
4cb3cdb5b0 markdown: Add the "extra" Markdown extension to app_filters.
This allows for Markdown contained inside of block
HTML elements as long as they have the attribute markdown=“1”.
2017-10-29 17:40:25 -07:00
neiljp (Neil Pilgrim)
63335fd8c5 mypy: Correct return_success_on_head_request typing.
Also switch to python3 type annotations.
2017-10-29 17:10:13 -07:00
neiljp (Neil Pilgrim)
0781237b1f mypy: Improve typing to profile.py & remove FuncT from decorator.py.
FuncT was unused in decorator.py, and only imported into profile.py.
The @profiled decorator is now more strongly typed on return-type.
Annotations were converted to python3 format.
2017-10-29 17:10:13 -07:00
neiljp (Neil Pilgrim)
1cc0a3cc67 mypy: Improve constraint on return types in statsd_increment decorator. 2017-10-29 17:10:13 -07:00
Harshit Bansal
1871d6fe1f minor: Remove unnecessary path juggling in get_recent_deployments(). 2017-10-29 14:38:20 -07:00
Tim Abbott
669517c450 docs: Clarify 1.6-and-below instructions for upgrade-zulip-from-git. 2017-10-29 12:41:32 -07:00
Tim Abbott
11ab545f3b install: Set the locale so our dependencies can install.
Many pip packages don't install properly without a US locale.
2017-10-29 11:49:08 -07:00
Steve Howell
f5fcbe453b Use get_stream_recipient() in test_narrow.mute_stream(). 2017-10-28 17:57:39 -07:00
Steve Howell
8302689789 Extract Message.is_stream_message().
This sets us up to denormalize on to Message some notion of
whether a message is for a stream (without having to hit the
Recipient table).
2017-10-28 17:57:39 -07:00
Steve Howell
8b012c6210 Extract get_personal_recipient(). 2017-10-28 17:57:39 -07:00
Steve Howell
64211512f8 Avoid mutation in get_recipient_from_user_ids.
We shouldn't mutate parameters in a `get_foo` function.
2017-10-28 17:57:39 -07:00
Steve Howell
370ffe389c Extract get_huddle_recipient().
This extraction moves all the huddle logic into models.py, which
hopefully can reduce friction for things like re-organizing our
caches (there are two cache entries for every huddle) and/or
just putting huddle_id on Message directly.
2017-10-28 17:57:39 -07:00
Steve Howell
a28841e8aa Extract get_stream_recipient().
Do you call get_recipient(Recipient.STREAM, stream_id) or
get_recipient(stream_id, Recipient.STREAM)?  I could never
remember, and it was not very type safe, since both parameters
are integers.
2017-10-28 17:57:39 -07:00
Rishi Gupta
b7a9068724 mobile: Update docs and portico URLs to point to new Android app. 2017-10-28 15:27:29 -07:00
Harshit Bansal
5020ba4a20 emoji: Allow users to change emoji set.
This feature was merged in PR #4383 but was disabled due to some
remaining emoji infra changes.

Fixes: #209.
2017-10-28 10:38:33 -07:00
Harshit Bansal
56f26c2d6f zproject/settings.py: Correct emoji sprite CSS files. 2017-10-28 10:38:33 -07:00
Harshit Bansal
4c077a77ed notifications: Instead of regex use lxml for fixing emojis. 2017-10-28 10:38:33 -07:00
Harshit Bansal
1067cfd92a node_modules: Add npm packages for the supported emojisets.
This commit adds emoji datasource packages for the rest of the emojiset
packages which we will use for serving images in notifications.
2017-10-28 10:38:32 -07:00
Steve Howell
d132c30c24 Remove active parameter from do_create_user().
Almost all callers to do_create_user were trying to
create active users, except for one test.  The
active=False codepath was kind of broken (things
like sending welcome messages had sort of undefined
behavior there), so instead of trying to maintain it,
we just update the one test (`test_people`) to flip the
`is_active` flag manually.

Fixes #7197
2017-10-28 10:32:01 -07:00
Steve Howell
d6c47573b2 Eliminate ZulipTestCase.send_message().
Now all tests use these three messages instead:

    send_stream_message
    send_personal_message
    send_huddle_message
2017-10-28 10:20:59 -07:00
Steve Howell
c978464d16 tests: Fix send_message calls in test_user.py. 2017-10-28 10:20:59 -07:00
Steve Howell
610d9b4abc tests: Fix send_message calls in test_unread.py. 2017-10-28 10:20:59 -07:00
Steve Howell
a20bba04ca tests: Fix send_message calls in test_tutorial.py. 2017-10-28 10:20:59 -07:00
Steve Howell
bb42004464 tests: Fix send_message calls in test_subs.py. 2017-10-28 10:20:59 -07:00
Steve Howell
fba754224c tests: Fix send_message calls in test_soft_deactivation.py. 2017-10-28 10:20:59 -07:00
Steve Howell
6475b25a00 tests: Fix send_message calls in test_signup.py. 2017-10-28 10:20:59 -07:00
Steve Howell
f264bbc7ca tests: Fix send_message calls in test_service_bot_system.py. 2017-10-28 10:20:59 -07:00
Steve Howell
8276442ee6 tests: Fix send_message calls in test_retention.py. 2017-10-28 10:20:59 -07:00
Steve Howell
1f077f7177 tests: Fix send_message calls in test_reactions.py. 2017-10-28 10:20:59 -07:00
Steve Howell
74943b4120 tests: Fix send_message calls in test_notifications.py. 2017-10-28 10:20:59 -07:00
Steve Howell
26e51c016d tests: Fix send_message calls in test_narrow.py. 2017-10-28 10:20:59 -07:00
Steve Howell
5c00bbc1a9 tests: Fix send_message in test_message_edit_notifications.py. 2017-10-28 10:20:59 -07:00
Steve Howell
cf1a4540ef tests: Fix send_message calls in test_link_embed.py. 2017-10-28 10:20:59 -07:00
Steve Howell
fd9d919fc6 tests: Fix send_message calls in test_home.py. 2017-10-28 10:20:59 -07:00
Steve Howell
1c38130626 tests: Fix send_message calls in test_export.py. 2017-10-28 10:20:59 -07:00
Steve Howell
3e319837ef tests: Fix send_message calls in test_events.py.
We mostly introduce these functions (as part of a big
code sweep):

    send_stream_message
    send_personal_message
    send_huddle_message

In two cases, where we want to specifically manipulate
queue ids, we now call check_send_message directly.  (The
above three functions deliberately don't support kwargs
to ensure simple code and better type safety.)
2017-10-28 10:20:59 -07:00
Steve Howell
25379a3b19 Fix send_message calls in test_embedded_bot_system.py. 2017-10-28 10:20:59 -07:00
Steve Howell
4372bfb4a5 tests: Fix send_message calls in test_bugdown.py. 2017-10-28 10:20:59 -07:00
Steve Howell
7cf5be2266 tests: Fix send_message calls in test_alert_words.py. 2017-10-28 10:20:59 -07:00
Steve Howell
53ad6270b4 tests: Fix send_message calls in test_event_queue.py. 2017-10-28 10:20:59 -07:00
Steve Howell
9c90c40c08 tests: Fix send_message calls in test_upload.py. 2017-10-28 10:20:59 -07:00
Tim Abbott
f2e3e779eb mypy: Properly annotate generic_bulk_cached_fetch.
Along with fixing some minor bugs, this requires extracting out the
default functions so that we can do type: ignores on them properly.

While we're at it, we switch to the Python 3 syntax.
2017-10-28 10:07:15 -07:00
Tim Abbott
73c27e1277 cache: Fix type aliasing of cached_objects.
Previously, it was converted from a CompressedItemT to an ItemT
without changing the variable name.
2017-10-28 10:01:44 -07:00
Tim Abbott
94c1da7025 cache: Move generic_bulk_cached_fetch typevars up a bit. 2017-10-28 10:00:43 -07:00
Tim Abbott
5b5dffebe7 get_messages_backend: Tweak how search fields are added.
This is a no-op, but makes mypy happier, since previously it wanted to
know the type of the {} we were passing to `.update()`.
2017-10-28 09:58:51 -07:00
Tim Abbott
6c242379f4 bugdown: Remove unused caching imports. 2017-10-28 09:02:36 -07:00
neiljp (Neil Pilgrim)
232bcd98b3 mypy: Improve return type of internal_notify_view decorator. 2017-10-28 08:57:49 -07:00
neiljp (Neil Pilgrim)
5c3af83229 mypy: Improve return type of api_key_only_webhook_view decorator. 2017-10-28 08:57:49 -07:00
neiljp (Neil Pilgrim)
c063ba72a2 mypy: Improve typing of cache_with_key and cache decorators.
Fixes #1348.
2017-10-28 08:57:49 -07:00
Tim Abbott
2e69d4d420 mypy: Fix type for per_request_display_recipient_cache. 2017-10-28 08:57:49 -07:00
Tim Abbott
fa55d7ed33 retry_event: Remove requirement of failed_tries being already there.
This fixes a bug where retries in the signups queue threw an exception.
2017-10-27 18:15:53 -07:00
rht
8b6b4e043f install: Add option to get certs via certbot.
While this doesn't quite complete our plans for certbot support (it's
not documented, etc.), this is a great stride forward.
2017-10-27 17:19:34 -07:00
Catherine Kleimeier
fe2adeeee1 hotkeys: Fix ESC removing message feed focus in Firefox.
We correct a bug on Firefox where using the ESC key to close an edit
box that was opened by the left arrow key caused the message feed to
lose focus, making it difficult to navigate the message feed by
keyboard afterwards.

We fix this bug by changing the function that handles the ESC key
during an edit to pass the correct object to the message_edit.end
function.

Fixes #7072.
2017-10-27 17:11:12 -07:00
Tim Abbott
0d1194811f mypy: Remove ignores for a few typeshed bugs fixed upstream. 2017-10-27 17:09:00 -07:00
Tim Abbott
bfa148ab39 requirements: Update mypy to latest version.
This involves fixing the mypy annotations in one file
2017-10-27 17:05:52 -07:00
Vishnu Ks
e102c42e0f requirements: Upgrade moto to 1.1.24. 2017-10-27 16:56:15 -07:00
Vishnu Ks
43dd26cf08 requirements: Upgrade Twisted to 17.9.0. 2017-10-27 16:56:15 -07:00
Vishnu Ks
ea58830673 requirements: Upgrade Sphinx to 1.6.5. 2017-10-27 16:56:15 -07:00
Vishnu Ks
cd90e1a3ad requirements: Upgrade six to 1.11.0. 2017-10-27 16:56:15 -07:00
Vishnu Ks
f5f94bddda requirements: Upgrade setuptools to 36.6.0. 2017-10-27 16:56:15 -07:00
Vishnu Ks
5c51d19194 requirements: Upgrade pyasn1 and pyasn1-modules. 2017-10-27 16:56:15 -07:00
Vishnu Ks
c04cde6e96 requirements: Upgrade psycopg2 to 2.7.3.2. 2017-10-27 16:56:15 -07:00
Vishnu Ks
0291214e0b requirements: Upgrade pip-tools to 1.10.1. 2017-10-27 16:56:15 -07:00
Vishnu Ks
e1aabfceca requirements: Upgrade Pillow to 4.3.0. 2017-10-27 16:56:15 -07:00
Vishnu Ks
7fc2e1ad0e requirements: Upgrade oauthlib to 2.0.6. 2017-10-27 16:56:15 -07:00
Vishnu Ks
c535816dea requirements: Upgrade lxml to 4.1.0. 2017-10-27 16:56:15 -07:00
Vishnu Ks
308212c80b requirements: Upgrade ipython to 6.2.1. 2017-10-27 16:56:15 -07:00
Vishnu Ks
db0cd705d7 requirements: Upgrade html2text to 2017.10.4. 2017-10-27 16:56:15 -07:00
Vishnu Ks
e96611ad1d requirements: Upgrade google-api-python-client to 1.6.4. 2017-10-27 16:56:15 -07:00
Vishnu Ks
cd064475a7 requirements: Upgrade django-auth-ldap to 1.2.16. 2017-10-27 16:56:15 -07:00
Vishnu Ks
0140a347dc requirements: Upgrade django to 1.11.6. 2017-10-27 16:56:15 -07:00
Vishnu Ks
00331ad84e requirements: Upgrade cryptography to 2.1.2. 2017-10-27 16:56:15 -07:00
Vishnu Ks
92f482a142 requirements: Upgrade cffi to 1.11.2. 2017-10-27 16:56:15 -07:00
Vishnu Ks
af4185e1fe requirements: Add simplejson.
simplejson is still used in home.py
2017-10-27 16:56:15 -07:00
Tim Abbott
3abe92fc39 requirements: Update version of pyombed to fork with bs4 bug fixed.
This fixes an annoying warning message that was printed in our tests.
2017-10-27 16:55:27 -07:00
Tim Abbott
095a3ecbdd requirements: Fix missing simplejson dependency. 2017-10-27 16:54:01 -07:00
Tim Abbott
090563fb25 test_tornado: Fix IOLoop exceptions output spam.
We weren't quite following the proper protocol for Tornado tests.
2017-10-27 16:28:33 -07:00
Tim Abbott
f790e667b3 test_tornado: Fix repeated autoreload configuration in tests.
Apparently, our previous efforts to disable AUTORELOAD in the tests
were incorrect.
2017-10-27 16:19:03 -07:00
Tim Abbott
aacafd7a4d test_tornado: Fix incorrect tearDown method for IOLoops.
We appear to have 2 bugs of this form, so this just cuts half of the
exception/warning log output, but it's a start.
2017-10-27 16:13:42 -07:00
Tim Abbott
49d7d49038 test_narrow: Fix sqlalchemy warning spam. 2017-10-27 16:06:03 -07:00
Tim Abbott
d80d15c08d GoogleSubdomainLoginTest: Suppress unnecessary logging output.
This helps make our test output nice and clean.
2017-10-27 16:06:03 -07:00
Tim Abbott
e5df05fd35 tests: Suppress logging spam in email mirror tests. 2017-10-27 16:06:03 -07:00
Tim Abbott
a1fa7a3c83 JWT: Filter out logging.warning output in tests. 2017-10-27 16:06:03 -07:00
Tim Abbott
fca6df09b0 test_home: Mark a couple tests as explicitly slow. 2017-10-27 16:05:55 -07:00
Tim Abbott
28b25a66c2 test_events: Mark several slower tests as explicitly slow. 2017-10-27 15:46:59 -07:00
Tim Abbott
ef9679667f test_docs: Fix unnecessary info-level logging in tests. 2017-10-27 15:44:45 -07:00
Tim Abbott
e19312b394 Fix zerver.lib.digest log being printed in tests. 2017-10-27 15:44:15 -07:00
Tim Abbott
073c81bbe8 slow_tests: Increase limit for TOO slow notices. 2017-10-27 15:38:17 -07:00
Tim Abbott
e8ab7cd1a9 logging: Fix zulip.send_email log being printed in tests.
Our set_loglevel tool didn't set propagate to False, so just using it
directly wouldn't work unless the logger is explcitly declared in
zproject/settings.py, which this one isn't.
2017-10-27 15:34:36 -07:00
Tim Abbott
80a9253f89 attachments: Remove unnecessary use of REQ.
It didn't do anything, because that third argument is actually a
positional argument coming from the URL parsing logic.
2017-10-27 15:18:44 -07:00
Tim Abbott
5467296f60 decorators: Use human_users_only more aggressively. 2017-10-27 15:16:13 -07:00
Tim Abbott
1cd017288d views: Fix imports of REQ/has_request_variables from the wrong place.
These were never in zerver/decorator.py, and so it makes sense to
import them zerver/lib/request.py, mostly for ease of finding things.
2017-10-27 15:07:31 -07:00
Brock Whittaker
25251e0216 /about/: Create a team partial.
This creates a template for the /team/ page that is currently just
embedded inside the /about/ page.  This includes the titles for core
team members with their pictures.
2017-10-27 14:50:48 -07:00
Greg Price
6d403ff255 tests: Simplify set_http_host to dedupe its logic.
This will make it easier to change this logic.
2017-10-27 14:42:24 -07:00
Greg Price
e4b4f67b44 subdomains: Tighten search for EXTERNAL_HOST in get_subdomain.
If a Zulip install at example.org got a request at an HTTP `Host`
like foo.example.org.evil.com (or even foo.example.orgevil.com),
we would accept it as subdomain foo.  This isn't likely to happen
in practice because it shouldn't pass ALLOWED_HOSTS, and it's not
obvious to me that anything untoward could be done with it even
if ALLOWED_HOSTS were set wide open, but if nothing else it
multiplies the cases in analyzing this logic.

The reason we had a loose match like this, I assume, is to allow
the user to come from arbitrary ports -- especially in development.
So tighten the pattern to allow just that, and add some tests for
that behavior and a comment explaining why this complication is
needed.
2017-10-27 14:42:24 -07:00
Greg Price
1b19af2612 subdomains: Write some tests for get_subdomain.
This logic is a bit subtle, and we're about to make changes to it.
So let's have some tests.
2017-10-27 14:42:24 -07:00
Greg Price
d9cb606804 oauth: Find a better name for redirect_to_main_site.
This name was way too broad for the rather specific logic
in the actual function.
2017-10-27 14:42:24 -07:00
Greg Price
ad551427ed auth: Factor out some uses of EXTERNAL_HOST with ROOT_DOMAIN_URI.
Apart from being less verbose, this makes it more manifest (on e.g. grep)
that we aren't using EXTERNAL_HOST here to construct subdomains.
2017-10-27 14:42:24 -07:00
Greg Price
318682fd52 auth: Use URL rather than cookie to pass signed data cross-domain.
The cookie mechanism only works when passing the login token to a
subdomain.  URLs work across domains, which is why they're the
standard transport for SSO on the web.  Switch to URLs.

Tweaked by tabbott to add a test for an expired token.
2017-10-27 14:42:04 -07:00
Greg Price
6efcce9374 oauth login: Refactor tests to dedupe a bit of recurring logic.
This makes the tests a little cleaner in itself, and also prepares
them to adjust with less churn when we change how
redirect_and_log_into_subdomain passes the signed token.
2017-10-27 14:28:38 -07:00
Greg Price
fad3d56810 views: Move some login code from registration to auth.
Most of these have more to do with authentication in general than with
registering a new account.  `create_preregistration_user` could go
either way; we move it to `auth` so we can make the imports go only in
one direction.
2017-10-27 14:28:38 -07:00
Henrik Pettersson
09cd47c6ad Add UI for viewing and cancelling open Zulip invitations.
Lets administrators view a list of open(unconfirmed) invitations and
resend or revoke a chosen invitation.

There are a few changes that we can expect for the future:

  * It is currently possible to invite an email that you have already
    invited, it might make sense to change this behavior.

  * Resend currently sends an invite reminder instead of resending the
    original invite, this is because 'custom_body' was not stored when
    the first invite was sent.

Tweaked in various minor ways, primarily in the backend, by tabbott,
mostly for style consistency with the rest of the codebase.

Fixes: #1180.
2017-10-27 13:07:43 -07:00
Tim Abbott
b831df8f7f Vagrantfile: Do "set +x" a bit before the end.
This helps avoid the confusing situation we'd had where the very last
line of the Vagrant output would be something in red.
2017-10-27 11:59:33 -07:00
Tim Abbott
a9d1042718 Vagrantfile: Fix some incorrect indentation in shell script. 2017-10-27 11:58:25 -07:00
Tim Abbott
8d00111a27 vagrant: Skip the shell virtualenv warning on provision. 2017-10-27 11:44:47 -07:00
Tim Abbott
237e3cdca1 registration: Clarify comment on do_activate_user code path. 2017-10-27 11:22:19 -07:00
Vishnu Ks
8c68a167fe backend: Allow Administrators to invite new users as admins.
Tweaked by tabbott to have the field before the invitation is
completed be called invite_as_admins, not invited_as_admins, for
readability.

Fixes #6834.
2017-10-27 11:19:38 -07:00
Steve Howell
4b78f69a87 tests: Introduce send_huddle_message().
The tighter interface here makes for shorter lines (or
fewer multi-line calls) and it leads to stricter type
checking.
2017-10-27 11:00:23 -07:00
Steve Howell
9707767b21 tests: Introduce send_personal_message().
The tighter interface prevents the need to specify
Recipient.PERSONAL (which can often be inaccurate in the
huddle case, anyway), and it prevents tests from confusingly
specifying a "subject" field for PMs.
2017-10-27 11:00:23 -07:00
Steve Howell
25a6fbd05d tests: Introduce send_stream_message().
Having send_stream_message() avoids the need to supply
Recipient.STREAM as a parameter, and it also uses the more
modern name of `topic_name` for topics.  Under the hood, it
avoids some annoying steps for re-formatting the recipients,
since we just have a single stream name.
2017-10-27 11:00:23 -07:00
Steve Howell
9576d25f92 Use check_send_stream_message in test_not_too_many_queries.
When possible, we want to use direct APIs for sending
stream messages.

This changes the codepath slightly, by not using
forwarded_user_profile, but it doesn't impact the number
of queries, and it's a simple check.

We also remove a couple "subject" references here.
2017-10-27 11:00:23 -07:00
Steve Howell
abf16a96d1 Rename subject -> topic_name in assert_stream_message(). 2017-10-27 11:00:23 -07:00
Steve Howell
c4404ed078 tests: Change some test topic names to not use "subject". 2017-10-27 11:00:23 -07:00
Steve Howell
65b6676844 minor: Remove unused import (internal_send_message). 2017-10-27 10:48:11 -07:00
Steve Howell
655f37a34b Rename subject_name in send_message_backend(). 2017-10-27 10:48:11 -07:00
Steve Howell
e5c5d10375 Rename subject vars in do_update_message(). 2017-10-27 10:48:11 -07:00
Steve Howell
fbe5f93141 Rename subject -> topic_name in internal_send_message. 2017-10-27 10:48:11 -07:00
Steve Howell
973ee97612 Rename subject -> topic_name in internal_prep_message(). 2017-10-27 10:48:11 -07:00
Steve Howell
f04550d143 Rename subject -> topic_name as var in check_message().
There were two variables, subject and subject_name, that
really had no clear distinction, so now they're just
topic_name.
2017-10-27 10:48:11 -07:00
Steve Howell
70b05998b1 Rename subject_name -> topic_name in check_send_message(). 2017-10-27 10:48:11 -07:00
derAnfaenger
45c21b79e1 settings ui: Restrict file type for image file pickers.
Previously, we would allow users to pick any file, even if we didn't
support that file type.
2017-10-27 10:21:36 -07:00
derAnfaenger
64025d2ce7 integrations: Add Errbot documentation.
Fixes zulip/python-zulip-api#49.
2017-10-27 09:22:51 -07:00
Tim Abbott
84790f8e21 gitattributes: Set .jpeg files as binary. 2017-10-26 22:25:39 -07:00
Tim Abbott
cab39dc6eb get_service_bot_events: Add some future-proofing.
The comment is the most important part here, but the new code
structure should help, too.
2017-10-26 22:16:47 -07:00
Tim Abbott
b897c763f8 get_recipient_info: Simplify active_user_ids construction. 2017-10-26 22:16:47 -07:00
Steve Howell
a70ede6c75 Allow "default" bots to see mentions on all streams.
This change allows normal bots to get UserMessage rows when
they are mentioned on a stream, even if they are not actually
subscribed to the stream.

Fixes #7140.
2017-10-26 22:16:47 -07:00
Steve Howell
53dbcbe2a4 refactor: Handle service bot mentions earlier in the code.
We now find all (possibly) relevant service bots for a message
in the call to get_recipient_info.  This allows us to eliminate
some code that would patch them after we rendered.

The get_service_bot_events() function will ignore any service
bots that weren't actually mentioned in the message (due to
backticks) or part of the active user ids.
2017-10-26 22:16:47 -07:00
Steve Howell
87b48f722d Add MentionData.get_user_ids().
This prepares us to take advantage of the user_ids
in subsequent commits related to `do_send_messages()`.
2017-10-26 22:16:47 -07:00
Steve Howell
8ac26dfb9b refactor: Introduce bugdown.MentionData class.
We now have a MentionData class that encapsulates
the users who are possibly mentioned in a message.

Not that the rendering code may not keep all the mentions,
since things like backticks will suppress the mention.

We populate this now in do_send_messages, so that we can use
the info earlier in the message-sending process.  This info
now gets passed down the call stack as an optional parameter.

Note that bugdown.convert() still populates the data when its
callers decline to pass in a MentionData object.

This is mostly a preparatory commit, as we don't take advantage
of the data yet in do_send_messages.
2017-10-26 22:16:47 -07:00
rht
45e8ce559d zerver/views: Use python 3 syntax for typing. 2017-10-26 21:58:22 -07:00
rht
1047733486 zerver/tornado: Use python 3 syntax for typing. 2017-10-26 21:58:22 -07:00
rht
e296841447 tools/documentation_crawler: Use python 3 syntax for typing. 2017-10-26 21:58:22 -07:00
Cynthia Lin
2aefeb723e /about/: Remove link hover underline from contributor usernames. 2017-10-26 20:35:08 -07:00
Tim Abbott
8e2cdedf9a lint: Fix lines in Python codebase longer than 120 characters. 2017-10-26 17:47:30 -07:00
Tim Abbott
b936e8c24b lint: Fix lines in Python codebase longer than 125 characters. 2017-10-26 17:36:54 -07:00
Tim Abbott
be619fe881 lint: Wrap many very long lines in the Python codebase.
This decreases the maximum line length in our Python codebase to 130.
2017-10-26 17:31:58 -07:00
Brock Whittaker
c771873439 informational-overlays: Make tab-switcher full-size.
The tab-switcher did not satisfy the full space of the header and
seemed to be a bit visually broken. This fixes it and makes it 100%
width.
2017-10-26 16:52:37 -07:00
Steve Howell
635675fe48 Reduce queries needed for sending messages.
In do_send_messages, we only produce one dictionary for
the event queues, instead of different flavors for text
vs. html.  This prevents two unnecessary queries to the
database.

It also means we only put one dictionary on the "message"
event queue instead of two, albeit a wider one that has
some values that won't be sent to the actual clients.

This wider dictionary from MessageDict.wide_dict is also
used for the `feedback_messages` queue and service bot
queues.  Since the extra fields are possibly useful down
the road, and they'll just be ignored for now, we don't
bother to remove them.  Also, those queue processors won't
have access to `content_type`, which they shouldn't need.

Fixes #6947
2017-10-26 16:35:28 -07:00
Steve Howell
9b6a4d0b16 refactor: Extract MessageDict.finalize_payload(). 2017-10-26 16:35:28 -07:00
Steve Howell
df93a99b50 Cache only one row per message.
Before this change, we populated two cache entries for each
message that we sent.  The entries were largely redundant,
with the only difference being whether we sent the content
as raw markdown or as the rendered HTML.

This commit makes it so we only have one cache entry per
message, and it includes both content and rendered_content.

One legacy source on confusion here is that `content`
changes meaning when you're on the front end.  Here is the
situation going forward:

    database:
        content = raw
        rendered_contented = rendered

    cache entry:
        content = raw
        rendered_contented = rendered

    payload for the frontend:
        content = raw (for apply_markdown=False)
        content = rendered (for apply_markdown=True)
2017-10-26 16:35:28 -07:00
Steve Howell
0cef7c9fd5 Refactor: Extract get_client_info_for_message_event().
This removes some clutter from process_message_event, and it
makes process_message_event() a bit easier to test.
2017-10-26 16:35:28 -07:00
Steve Howell
a50671165a tests: Add test_content_types(). 2017-10-26 15:47:44 -07:00
rht
c2a5b5f160 zerver/migrations: Use python 3 syntax for typing. 2017-10-26 15:24:56 -07:00
rht
a311678190 zerver/management: Use python 3 syntax for typing. 2017-10-26 15:24:56 -07:00
Brock Whittaker
6500611ecd /plans/: Change FAQ section answers to <p>.
By changing the sections to paragraphs, the underlines come back
for the links.
2017-10-26 15:15:22 -07:00
Brock Whittaker
798133a403 landing-pages: Remove :hover underlines in unecessary places.
All links by default had an underline on hover, including when
<a> tags were wrapping <div> and <img> tags, which made for a small
underline near them on hover. This better focusses the underline
behavior to just paragraphs and lists.
2017-10-26 15:15:22 -07:00
Tim Abbott
1a283434a8 docs: Clean up links for writing integration docs.
There's no need to have an empty redirect section at the bottom of
this page.
2017-10-26 15:14:11 -07:00
derAnfaenger
ec17460c68 docs: Update preferred integration logo format to svg. 2017-10-26 15:06:07 -07:00
Brock Whittaker
a2a0e9b1c0 landing-page: Detect meta key to prevent page transitions.
This detects the meta key being pressed to open a page in a new
tab and therefore will prevent the page animation from fading out
the body content, in case the user wants to go back to that page
again.
2017-10-26 15:05:34 -07:00
derAnfaenger
1792dcbd09 tests: Call real consume method of queue processors.
This switches to more real tests for a first batch of
queue_json_publish() calls that don't cause trouble when
used with call_consume_tests=True.
2017-10-26 14:58:03 -07:00
derAnfaenger
18e5bcbbb1 tests: Enable call_consume_in_tests for email mirror queue. 2017-10-26 14:53:27 -07:00
derAnfaenger
17949adf11 embedded bots: Add StateHandler remove() function. 2017-10-26 14:49:50 -07:00
Brock Whittaker
3d7fb4888b portico-header: Add down chevron to indicate dropdown.
This adds a down chevron to the pill org realm section to indicate
clicking it will drop it down.
2017-10-26 13:56:53 -07:00
Brock Whittaker
53d739f9aa portico-header: Add pill with org/realm name.
This adds a pill element that includes the org/realm name that you
are currently signed into.
2017-10-26 13:56:53 -07:00
Steve Howell
df03e30d68 popovers: Fix is-active checks for popovers.
We were incorrectly reporting active bots as non-active in
popovers, and we had no test coverage for cross-realm bots.

We also rename the function to is_active_user_for_popover,
since the old name, realm_user_is_active_human_or_bot, suggested
the wrong semantics for cross-realm bots.

Last but not least, we only do a blueslip warning if a user id
is not found.  When lookups fail, we are pretty confident that
the user is not active, so an error is overkill.  We can change
that as part of issue #7120.

Fixes #7153
2017-10-26 13:56:32 -07:00
Tim Abbott
3e16b02f30 docs: Update release checklist following 1.7.0 release. 2017-10-26 13:53:21 -07:00
Vishnu Ks
25cb6af32c mangement: Create command for creating default stream groups. 2017-10-26 11:38:48 -07:00
Tim Abbott
b8658c6901 default stream groups: Use cleaner system for error handling.
Wherever possible, we always want to move checking for error
conditions to the views code, so that we don't need to worry about
handling failures with (in this case) a user that's half-created
because a DefaultStreamGroup doesn't exist.
2017-10-26 11:38:27 -07:00
Vishnu Ks
eecdc5bb61 registration: Add option to choose default stream groups.
This effectively implements the feature of default stream groups,
except for a UI, nice styling, etc.

Note that we're careful to not have this do anything in an
organization that doesn't have any default stream groups.
2017-10-26 11:34:06 -07:00
Vishnu Ks
4f00170735 models: Create DefaultStreamGroup. 2017-10-26 11:11:51 -07:00
Brock Whittaker
ae9d686d26 features: Make more responsive.
This fixes some responsiveness issues with the features page where the
text for headers would go off the screen on mobile and narrower devices.
2017-10-26 11:01:20 -07:00
Brock Whittaker
e20dd2f1fc features: Add constraints to message-feed image.
This adds two constraints to the image:

1. The `max-width` can not be more than 500px (which prevents it
from being to vertically tall.
2. The `display` is set to `none` below 1024px because the image is
too small at that point to be legible.
2017-10-26 11:01:20 -07:00
Sumana Harihareswara
559f69667f docs: Fix spelling in template. 2017-10-26 10:47:18 -07:00
Greg Price
66ebe9720f subdomains: Refactor get_subdomain a bit.
The helper _extract_subdomain doesn't have a super meaningful
interface, and this is its one callsite.  So just inline it.
2017-10-26 10:29:17 -07:00
Greg Price
cc32634439 subdomains: Simplify is_subdomain_root_or_alias.
This logic is equivalent, though it takes a couple of readings
to convince oneself of that.  This version should then be
easier to reason about.
2017-10-26 10:29:17 -07:00
Greg Price
69e44a68fc subdomains: Refactor Realm.get_bot_domain to rely on Realm.host.
This has exactly the same behavior so long as self.subdomain contains
no colon character, ':'; and of course we don't allow those in
subdomains, because they aren't allowed by DNS.
2017-10-26 10:29:17 -07:00
Greg Price
f676635653 subdomains: Refactor Realm.uri as a trivial wrapper for Realm.host. 2017-10-26 10:29:17 -07:00
Greg Price
30cc2994de social auth: Replace a bit of explicit model-querying with get_realm. 2017-10-26 10:29:17 -07:00
Greg Price
093bae4bc5 subdomains: Fix some implicit uses of "" for the root subdomain.
These are just instances that jumped out at me while working on the
subdomains code, mostly while grepping for get_subdomain call sites.
I haven't attempted a comprehensive search, and there are likely
still others left.
2017-10-26 10:29:17 -07:00
Greg Price
27adbe8d79 subdomains: Clean up a use of various falsy values for the root domain.
This isn't a complete cleanup of the logic at this spot, but
at least the messy part that remains is now explicit.
2017-10-26 10:29:17 -07:00
Greg Price
4a6e867046 lint: Disable a buggy pep8 rule on line breaks and operators.
I'd much rather see something like

    if (thing_is_permissible(user, thing)
            or (user_possesses_hammer(user)
                and glass_break_requested(thing))):

than

    if (thing_is_permissible(user, thing) or
            (user_possesses_hammer(user) and
                glass_break_requested(thing))):

because the former makes the overall logic much easier to scan.
Similarly for a formula full of arithmetic rather than Boolean
operators.  And the actual PEP 8 agrees (though until 2016 it
unfortunately had the opposite advice.)

The upstream linter still applies the backward rule, so disable that.
2017-10-26 10:29:17 -07:00
Greg Price
be309bc8b1 subdomains: Complete the refactor to user_matches_subdomain.
Now that the old `check_subdomain` has no callers except in
implementing the new, improved interface `user_matches_subdomain`,
inline it into that.  Also simplify the Boolean logic a bit.
2017-10-26 10:29:17 -07:00
Greg Price
c9457d4af0 subdomains: Refactor check_subdomain to a clearer interface.
Now that every call site of check_subdomain produces its second
argument in exactly the same way, push that shared bit of logic
into a new wrapper for check_subdomain.

Also give that new function a name that says more specifically what
it's checking -- which I think is easier to articulate for this
interface than for that of check_subdomain.
2017-10-26 10:29:17 -07:00
Greg Price
7c467a8f01 subdomains: Fix one backward call site of check_subdomain.
This should be a pure refactor: the only asymmetry in the behavior
of `check_subdomain` between its two arguments is if one of them
is None, and in this case we have a non-nullable model field on
one side and the return value from `get_subdomain` on the other.

With these swapped, this call site now matches all other
`check_subdomain` call sites in having the second argument come as
the subdomain of some user's realm.
2017-10-26 10:29:17 -07:00
Greg Price
7bec0a29c4 subdomains: Simplify out check_subdomain from an uncommon use.
This also replaces an implicit use of "" for
Realm.SUBDOMAIN_FOR_ROOT_DOMAIN.
2017-10-26 10:29:17 -07:00
Greg Price
f10e66eff2 subdomains: Simplify a funny call site of get_subdomain.
The type of get_subdomain's parameter is non-Optional, and
in fact if passed an argument of None it would promptly
blow up.  So this `getattr` can't be serving any purpose.
2017-10-26 10:29:17 -07:00
Steve Howell
f8f4d9cb63 people.js: Rename realm_get -> get_active_user_for_email.
We rename this function to be more clear, and we also remove
a stray function name for `realm_get` that was for the wrong
exported function.
2017-10-26 09:52:42 -07:00
Steve Howell
2699a6aac9 refactor: Extract people.is_valid_email_for_compose().
It's easier to unit test logic inside of people.js than compose.js.

We allow users to compose emails to any of our cross-realm bots.
Someday we may tighten up which cross-realm bots are valid targets,
since it's not necessarily the case that those bots do anything
useful when you send them messages.
2017-10-26 09:45:08 -07:00
Steve Howell
8cf5e05827 Rename realm_people_dict -> active_user_dict.
This dictionary includes bots, so the reference to
"people" in the name `realm_people_dict` was misleading.

We omit `realm` for brevity sake--it's usually the case
that folks implementing new features can safely ignore
cross-realm bots, and it's on our roadmap to move those
bots into the realm.
2017-10-26 09:26:28 -07:00
Steve Howell
646bd356a3 Rename get_realm_human_user_ids -> get_active_user_ids.
The function name `get_realm_human_user_ids` was a lie--it
includes active bots as well.

The only user of this function is `activity.js`, which wasn't
impacted by the misleading name, because we eventually filter
out bots in the `info_for` function.

It's possible that we actually want to include bots in the right
sidebar, since they can be difficult to discover in other parts
of the UI.  Or, if we want to keep the right sidebar as all
human users, we may eventually want to make the logic to exclude
bots happen higher in the stack (but for real, this time).
2017-10-26 09:17:43 -07:00
Brock Whittaker
03805fdca4 landing-page: Remove incorrect gray text.
This changes some text that would display gray when on a blue body
text page; we considered changing the opacity instead, but probably we
should just delete this..
2017-10-25 16:49:42 -07:00
Brock Whittaker
f885ec82db landing-page: Make <ul> formatting consistent.
This changes the <ul> styling so that when not nested in a <p>
tag it'll have the standard font-weight (400) and be the same
color as the body text (blue/gray).
2017-10-25 16:36:31 -07:00
Henrik Pettersson
2f52da7baa test_signup: extract InviteUserBase class
This is a refactor done in preparation for #1180
2017-10-25 16:32:04 -07:00
derAnfaenger
8680541912 embedded bots: Add message flow tests. 2017-10-25 16:13:37 -07:00
Abhijeet Kaur
a88178afaf Embedded bots: Add support for creating embedded bots via the API.
Adds support to add "Embedded bot" Service objects. This service
handles every embedded bot.

Extracted from "Embedded bots: Add support to add embedded bots from
UI" by Robert Honig.

Tweaked by tabbott to be disabled by default.
2017-10-25 16:13:29 -07:00
derAnfaenger
ce4ba9c178 bot services: Use call_consume_in_tests. 2017-10-25 15:56:12 -07:00
derAnfaenger
0473692abd embedded bots: Properly reply to PMs and streams
This fixes an exception occurring when engaging an embedded
bot in a PM, makes it respond as itself instead of the sender,
and makes it respond to the PM conversation it is engaded in.
2017-10-25 15:56:12 -07:00
derAnfaenger
d0c0b148b3 bot services: Rename add_outgoing_webhook_service to add_service. 2017-10-25 15:46:07 -07:00
derAnfaenger
e041abd300 tests: Add create_test_bot() helper function. 2017-10-25 15:46:07 -07:00
Tim Abbott
1a0f075136 lint: Fix indentation in portico header HTML. 2017-10-25 15:44:11 -07:00
derAnfaenger
3cf88d8c09 embedded bots: Add virtual_fs bot.
This will be our main bot for testing the StateHandler code.
2017-10-25 15:39:28 -07:00
derAnfaenger
0d0c8fee7e embedded bots: Migrate StateHandler API to use get and put.
This moves away from handling a StateHandler object like a dict
and gives it the methods get, put, and contains.
2017-10-25 15:39:28 -07:00
derAnfaenger
34e3eb8c67 embedded bots: Rename state and state_handler to storage. 2017-10-25 15:39:28 -07:00
derAnfaenger
cd600b8677 embedded bots: Add StateHandler marshaling functions. 2017-10-25 15:39:28 -07:00
derAnfaenger
51f1281ee9 docs: Specify the updated bot StateHandler API. 2017-10-25 15:37:28 -07:00
derAnfaenger
81a6b0d72c docs: Update deprecated code in writing bots guide. 2017-10-25 15:29:08 -07:00
Brock Whittaker
fd779c1ba6 compose: Remove PM recipient box outline.
This removes the old blue styled outline around the PM recipient
box that was part of the older bootstrap styling in favor of the
dark outline on :focus that had been implemented for the rest of
the recipient boxes recently.
2017-10-25 15:15:58 -07:00
darshanime
a14ec17473 dev_login: Don't redirect to realm if it doesn't exist.
Fixes #7132.
2017-10-25 15:13:20 -07:00
Brock Whittaker
a9a9333b2a portico: Show whether the user is logged in.
This creates a dropdown in place of the normal register/login links
you get when logged out, with an option to go to the app or log out if
that appears you click on the avatar.

A bit more work is needed to make this look really good, but it's a
great start.
2017-10-25 14:59:24 -07:00
Brock Whittaker
d5bb4a2265 portico: Add common class between two portico headers. 2017-10-25 14:47:54 -07:00
Brock Whittaker
ec43a6e718 portico: Add "porticocustomhead" block to base.html.
This adds a custom header to the base.html strictly for portico assets
that should not be overridden.
2017-10-25 14:47:54 -07:00
Vishnu Ks
9314a7ac8b backends: Move EmailLogBackEnd to email_backends. 2017-10-25 14:35:12 -07:00
Vishnu Ks
1d94119d31 actions: Call send_initial_pms from process_new_human_user. 2017-10-25 14:14:59 -07:00
rht
49ad5c78e6 js: Update minor versions of several node dependencies. 2017-10-25 14:09:28 -07:00
Steve Howell
14d2d4e506 Fix bug in flush_user_profile().
Every time we updated a UserProfile object, we were calling
delete_display_recipient_cache(), which churns the cache and
does an extra database hop to find subscriptions.  This was
due to saying `updated_fields` instead of `update_fields`.

This made us prone to cache churn for fields like UserProfile.pointer
that are fairly volatile.

Now we use the helper function changed().  To prevent the
opposite problem, we use all the fields that could invalidate
the cache.
2017-10-25 11:30:56 -07:00
Steve Howell
c8875693c8 Extract changed() helper in flush_user_profile().
The verbose style of `changed` is partly to appease mypy.
2017-10-25 11:29:09 -07:00
Steve Howell
70c053d86f Call get_realm_stream() in access_stream_by_name(). 2017-10-25 11:29:09 -07:00
Steve Howell
1bfc162d64 refactor: Rename get_stream_backend to get_realm_stream.
The name `get_stream_backend` sounded like it was off limits,
but there is no reason not to call this function directly.
2017-10-25 11:29:05 -07:00
Steve Howell
2387fa70af tests: Make test_people() more robust.
This test had a little bug, where we weren't actually
verifying `realm_bots` before, because we weren't using
`field` to look it up.

This commit fixes that bug and adds additional checks,
particularly for the recently added `realm_non_active_users'.
2017-10-25 11:18:30 -07:00
Steve Howell
305fe6106b Add realm_non_active_users data to initial payload.
We now add `realm_non_active_users` to the result of
`do_events_register` (and thus `page_params`).  It has
the same structure as `realm_users`, but it's for
non-active users.  Clients need data on non-active users
when they process old messages that were sent by those
users when they were active.  Clients can currently get
most of the data they need in the message events, but it
makes for ugly client code.

Fixes #4322
2017-10-25 11:18:30 -07:00
Steve Howell
b94c062368 Make the realm user cache include non-active users.
This is a prepatory commit that adds non-active users to
the realm user cache.  It mostly involves name changes and
removing an `is_active` filter from the relevant DB query.

The only consumer of this cache is `get_raw_user_data`, which
now filters on `is_active` in a dictionary comprehension (but
this will get moved around a bit in a subsequent commit).
2017-10-25 11:18:30 -07:00
Steve Howell
769c741c7c refactor: Simplify event updates for realm_users.
We make a few things cleaner for populating `realm_users`
in `do_event_register` and `apply_events`:

    * We have a `raw_users` intermediate dictionary that
      makes event updates O(1) and cleaner to read.

    * We extract an `is_me` section for all updates that
      apply to the current user.

    * For `update` events, we do a more surgical copying
      of fields from the event into our dict.  This
      prevents us from mutating fields in the event,
      which was sketchy (at least in test mode).  In
      particular, this allowed us to remove some ugly
      `del` code related to avatars.

    * We introduce local vars `was_admin` and `now_admin`.

The cleanup had two test implications:

    * We no longer need to normalize `realm_users`, since
      `apply_events` now sees `raw_users` instead.  Since
      `raw_users` is a dict, there is no need to normalize
      it, unlike lists with possibly random order.

    * We updated the schema for avatar updates to include
      the two fields that we used to hackily delete from
      an event.
2017-10-25 11:18:30 -07:00
Shekh Ataul
d239f77966 refactor: Replace mkdir_p functions with Python 3 builtin.
This didn't exist in Python 2, but it does in Python 3, so we get to
reap the rewards of dropping Python 2 support.

Fixes #7082.
2017-10-25 11:06:11 -07:00
Eeshan Garg
bd814eea2b webhooks/taiga: Support relateduserstory events.
This commit adds support for the following:

1. When a user story is added to an epic.
2. When a user story is removed from an epic.
2017-10-25 10:59:58 -07:00
Aditya Bansal
0ddad98c98 features.html: Cleanup to use 4 space and consistant indentation. 2017-10-25 10:58:57 -07:00
Aditya Bansal
3fb0f7c092 home.html: Cleanup to use 4 space indentation.
Tweaked by tabbott to also make the translation tags make more sense.
2017-10-25 10:58:49 -07:00
Tim Abbott
a03f322028 version: Bump version following 1.7 release. 2017-10-25 10:37:51 -07:00
1791 changed files with 105524 additions and 52931 deletions

143
.circleci/config.yml Normal file
View File

@@ -0,0 +1,143 @@
# See CircleCI upstream's docs on this config format:
# https://circleci.com/docs/2.0/language-python/
#
version: 2
jobs:
"trusty-python-3.4":
docker:
# This is built from tools/circleci/images/trusty/Dockerfile .
- image: gregprice/circleci:trusty-python-4.test
working_directory: ~/zulip
steps:
- checkout
- run:
name: create cache directories
command: |
dirs=(/srv/zulip-{npm,venv}-cache)
sudo mkdir -p "${dirs[@]}"
sudo chown -R circleci "${dirs[@]}"
- restore_cache:
keys:
- v1-npm-base.trusty.1
- restore_cache:
keys:
- v1-venv-base.trusty.1
- run:
name: install dependencies
command: |
# Install moreutils so we can use `ts` and `mispipe` in the following.
sudo apt-get install -y moreutils
# CircleCI sets the following in Git config at clone time:
# url.ssh://git@github.com.insteadOf https://github.com
# This breaks the Git clones in the NVM `install.sh` we run
# in `install-node`.
# TODO: figure out why that breaks, and whether we want it.
# (Is it an optimization?)
rm -f /home/circleci/.gitconfig
# This is the main setup job for the test suite
mispipe "tools/travis/setup-backend" ts
# Cleaning caches is mostly unnecessary in Circle, because
# most builds don't get to write to the cache.
# mispipe "scripts/lib/clean-unused-caches --verbose --threshold 0" ts
- save_cache:
paths:
- /srv/zulip-npm-cache
key: v1-npm-base.trusty.1
- save_cache:
paths:
- /srv/zulip-venv-cache
key: v1-venv-base.trusty.1
# TODO: in Travis we also cache ~/zulip-emoji-cache, ~/node, ~/misc
# The moment of truth! Run the tests.
- run:
name: run backend tests
command: |
. /srv/zulip-py3-venv/bin/activate
mispipe ./tools/travis/backend ts
- run:
name: run frontend tests
command: |
. /srv/zulip-py3-venv/bin/activate
mispipe ./tools/travis/frontend ts
- run:
name: upload coverage report
command: |
. /srv/zulip-py3-venv/bin/activate
pip install codecov && codecov \
|| echo "Error in uploading coverage reports to codecov.io."
# - store_artifacts: # TODO
# path: var/casper/
# # also /tmp/zulip-test-event-log/
# destination: test-reports
"xenial-python-3.5":
docker:
# This is built from tools/circleci/images/xenial/Dockerfile .
- image: gregprice/circleci:xenial-python-3.test
working_directory: ~/zulip
steps:
- checkout
- run:
name: create cache directories
command: |
dirs=(/srv/zulip-{npm,venv}-cache)
sudo mkdir -p "${dirs[@]}"
sudo chown -R circleci "${dirs[@]}"
- restore_cache:
keys:
- v1-npm-base.xenial.1
- restore_cache:
keys:
- v1-venv-base.xenial.1
- run:
name: install dependencies
command: |
sudo apt-get install -y moreutils
rm -f /home/circleci/.gitconfig
mispipe "tools/travis/setup-backend" ts
- save_cache:
paths:
- /srv/zulip-npm-cache
key: v1-npm-base.xenial.1
- save_cache:
paths:
- /srv/zulip-venv-cache
key: v1-venv-base.xenial.1
- run:
name: run backend tests
command: |
. /srv/zulip-py3-venv/bin/activate
mispipe ./tools/travis/backend ts
- run:
name: upload coverage report
command: |
. /srv/zulip-py3-venv/bin/activate
pip install codecov && codecov \
|| echo "Error in uploading coverage reports to codecov.io."
workflows:
version: 2
build:
jobs:
- "trusty-python-3.4"
- "xenial-python-3.5"

View File

@@ -5,6 +5,6 @@ coverage:
project:
default:
target: auto
threshold: 0.03
threshold: 0.50
base: auto
patch: off

View File

@@ -6,7 +6,7 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.{sh,py,js,json,yml,xml,css,md,markdown,handlebars,html}]
[*.{sh,py,pyi,js,json,yml,xml,css,md,markdown,handlebars,html}]
indent_style = space
indent_size = 4

View File

@@ -18,6 +18,7 @@
"Dropbox": false,
"SockJS": false,
"marked": false,
"md5": false,
"moment": false,
"i18n": false,
"DynamicText": false,
@@ -31,13 +32,21 @@
"popovers": false,
"server_events": false,
"server_events_dispatch": false,
"message_scroll": false,
"info_overlay": false,
"ui": false,
"ui_report": false,
"night_mode": false,
"ui_util": false,
"lightbox": false,
"input_pill": false,
"user_pill": false,
"compose_pm_pill": false,
"stream_color": false,
"people": false,
"user_groups": false,
"navigate": false,
"toMarkdown": false,
"settings_account": false,
"settings_display": false,
"settings_notifications": false,
@@ -47,9 +56,13 @@
"settings_sections": false,
"settings_emoji": false,
"settings_org": false,
"settings_ui": false,
"settings_users": false,
"settings_streams": false,
"settings_filters": false,
"settings_invites": false,
"settings_user_groups": false,
"settings_profile_fields": false,
"settings": false,
"resize": false,
"loading": false,
@@ -58,6 +71,7 @@
"typing_data": false,
"typing_status": false,
"sent_messages": false,
"transmit": false,
"compose": false,
"compose_actions": false,
"compose_state": false,
@@ -79,8 +93,10 @@
"gear_menu": false,
"hashchange": false,
"hash_util": false,
"FetchStatus": false,
"message_list": false,
"Filter": false,
"flatpickr": false,
"pointer": false,
"util": false,
"MessageListView": false,
@@ -145,6 +161,7 @@
"recent_senders": false,
"unread_ui": false,
"unread_ops": false,
"upload": false,
"user_events": false,
"Plotly": false,
"emoji_codes": false,
@@ -155,8 +172,12 @@
"hotspots": false,
"compose_ui": false,
"common": false,
"desktop_notifications_panel": false
"panels": false,
"PerfectScrollbar": false
},
"plugins": [
"eslint-plugin-empty-returns"
],
"rules": {
"array-callback-return": "error",
"array-bracket-spacing": "error",
@@ -176,6 +197,7 @@
"complexity": [ 0, 4 ],
"curly": 2,
"dot-notation": [ "error", { "allowKeywords": true } ],
"empty-returns/main": "error",
"eol-last": [ "error", "always" ],
"eqeqeq": 2,
"func-style": [ "off", "expression" ],

2
.gitattributes vendored
View File

@@ -1,6 +1,7 @@
* text=auto eol=lf
*.gif binary
*.jpg binary
*.jpeg binary
*.eot binary
*.woff binary
*.woff2 binary
@@ -9,3 +10,4 @@
*.png binary
*.otf binary
*.tif binary
yarn.lock binary

14
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,14 @@
<!-- What's this PR for? (Just a link to an issue is fine.) -->
**Testing Plan:** <!-- How have you tested? -->
**GIFs or Screenshots:** <!-- If a UI change. See:
https://zulip.readthedocs.io/en/latest/tutorials/screenshot-and-gif-software.html
-->
<!-- Also be sure to make clear, coherent commits:
https://zulip.readthedocs.io/en/latest/contributing/version-control.html
-->

17
.gitignore vendored
View File

@@ -12,19 +12,26 @@
# * Subdirectories with several internal things to ignore get their own
# `.gitignore` files.
#
# * Comments must be on their own line. (Otherwise they don't work.)
#
# See `git help ignore` for details on the format.
## Config files for the dev environment
/zproject/dev-secrets.conf
/tools/conf.ini
/tools/custom_provision
/tools/droplets/conf.ini
## Byproducts of setting up and using the dev environment
*.pyc
package-lock.json
/.vagrant
/var
# Dockerfiles generated for CircleCI
/tools/circleci/images
# Static build
*.mo
npm-debug.log
@@ -37,6 +44,11 @@ npm-debug.log
# Test / analysis tools
.coverage
## Files (or really symlinks) created in a prod deployment
/zproject/prod_settings.py
/zulip-current-venv
/zulip-py3-venv
## Files left by various editors and local environments
# (Ideally these should be in everyone's respective personal gitignore files.)
*~
@@ -51,6 +63,11 @@ zulip.kdev4
*.sublime-workspace
.vscode/
*.DS_Store
# .cache/ is generated by VSCode's test runner
.cache/
.eslintcache
## Miscellaneous
# (Ideally this section is empty.)
zthumbor/thumbor_local_settings.py
.transifexrc

View File

@@ -1,10 +1,10 @@
[general]
ignore=title-trailing-punctuation, body-min-length, body-is-missing
ignore=title-trailing-punctuation, body-min-length, body-is-missing, title-imperative-mood
extra-path=tools/lib/gitlint-rules.py
[title-match-regex]
regex=^.+\.$
[title-match-regex-allow-exception]
regex=^(.+:\ )?[A-Z].+\.$
[title-max-length]
line-length=76

8
.isort.cfg Normal file
View File

@@ -0,0 +1,8 @@
[settings]
line_length = 79
multi_line_output = 2
balanced_wrapping = true
known_third_party = django, ujson, sqlalchemy
known_first_party = zerver, zproject, version, confirmation, zilencer, analytics, frontend_tests, scripts, corporate
sections = FUTURE, STDLIB, THIRDPARTY, FIRSTPARTY, LOCALFOLDER
lines_after_imports = 1

View File

@@ -1,9 +1,11 @@
# See https://zulip.readthedocs.io/en/latest/travis.html for
# See https://zulip.readthedocs.io/en/latest/testing/travis.html for
# high-level documentation on our Travis CI setup.
dist: trusty
group: deprecated-2017Q4
install:
# Disable broken riak sources.list in Travis base image 2017-10-18
- rm -vf "/etc/apt/sources.list.d/*riak*"
# Disable sometimes-broken sources.list in Travis base images
- sudo rm -vf /etc/apt/sources.list.d/*
- sudo apt-get update
# Disable Travis CI's built-in NVM installation
- mispipe "mv ~/.nvm ~/.travis-nvm-disabled" ts
@@ -33,6 +35,7 @@ cache:
- $HOME/zulip-npm-cache
- $HOME/zulip-emoji-cache
- $HOME/node
- $HOME/misc
env:
global:
- BOTO_CONFIG=/tmp/nowhere
@@ -45,14 +48,9 @@ matrix:
# that doesn't seem to be documented, but it's what we see empirically.
# We only get 4 jobs running at a time, so we try to make the first few
# the most likely to break.
- python: "3.4"
env: TEST_SUITE=frontend
- python: "3.4"
env: TEST_SUITE=backend
- python: "3.4"
env: TEST_SUITE=production
- python: "3.5"
env: TEST_SUITE=backend
# Other suites moved to CircleCI -- see .circleci/.
sudo: required
addons:
artifacts:
@@ -67,9 +65,3 @@ addons:
- moreutils
after_success:
- codecov
notifications:
webhooks:
urls:
- https://zulip.org/zulipbot/travis
on_success: always
on_failure: always

View File

@@ -13,3 +13,21 @@ source_file = static/locale/en/translations.json
source_lang = en
type = KEYVALUEJSON
file_filter = static/locale/<lang>/translations.json
[zulip.messages]
source_file = static/locale/en/mobile.json
source_lang = en
type = KEYVALUEJSON
file_filter = static/locale/<lang>/mobile.json
[zulip-test.djangopo]
source_file = static/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO
file_filter = static/locale/<lang>/LC_MESSAGES/django.po
[zulip-test.translationsjson]
source_file = static/locale/en/translations.json
source_lang = en
type = KEYVALUEJSON
file_filter = static/locale/<lang>/translations.json

333
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,333 @@
# Contributing to Zulip
Welcome to the Zulip community!
## Community
The
[Zulip community server](https://zulip.readthedocs.io/en/latest/contributing/chat-zulip-org.html)
is the primary communication forum for the Zulip community. It is a good
place to start whether you have a question, are a new contributor, are a new
user, or anything else. Make sure to read the
[community norms](https://zulip.readthedocs.io/en/latest/contributing/chat-zulip-org.html#community-norms)
before posting. The Zulip community is also governed by a
[code of conduct](https://zulip.readthedocs.io/en/latest/code-of-conduct.html).
You can subscribe to zulip-devel@googlegroups.com for a lower traffic (~1
email/month) way to hear about things like mentorship opportunities with Google
Code-in, in-person sprints at conferences, and other opportunities to
contribute.
## Ways to contribute
To make a code or documentation contribution, read our
[step-by-step guide](#your-first-codebase-contribution) to getting
started with the Zulip codebase. A small sample of the type of work that
needs doing:
* Bug squashing and feature development on our Python/Django
[backend](https://github.com/zulip/zulip), web
[frontend](https://github.com/zulip/zulip), React Native
[mobile app](https://github.com/zulip/zulip-mobile), or Electron
[desktop app](https://github.com/zulip/zulip-electron).
* Building out our
[Python API and bots](https://github.com/zulip/python-zulip-api) framework.
* [Writing an integration](https://zulipchat.com/api/integration-guide).
* Improving our [user](https://zulipchat.com/help/) or
[developer](https://zulip.readthedocs.io/en/latest/) documentation.
* [Reviewing code](https://zulip.readthedocs.io/en/latest/contributing/code-reviewing.html)
and manually testing pull requests.
**Non-code contributions**: Some of the most valuable ways to contribute
don't require touching the codebase at all. We list a few of them below:
* [Reporting issues](#reporting-issues), including both feature requests and
bug reports.
* [Giving feedback](#user-feedback) if you are evaluating or using Zulip.
* [Translating](https://zulip.readthedocs.io/en/latest/translating/translating.html)
Zulip.
* [Outreach](#zulip-outreach): Star us on GitHub, upvote us
on product comparison sites, or write for [the Zulip blog](http://blog.zulip.org/).
## Your first (codebase) contribution
This section has a step by step guide to starting as a Zulip codebase
contributor. It's long, but don't worry about doing all the steps perfectly;
no one gets it right the first time, and there are a lot of people available
to help.
* First, make an account on the
[Zulip community server](https://zulip.readthedocs.io/en/latest/contributing/chat-zulip-org.html),
paying special attention to the community norms. If you'd like, introduce
yourself in
[#new members](https://chat.zulip.org/#narrow/stream/new.20members), using
your name as the topic. Bonus: tell us about your first impressions of
Zulip, and anything that felt confusing/broken as you started using the
product.
* Read [What makes a great Zulip contributor](#what-makes-a-great-zulip-contributor).
* [Install the development environment](https://zulip.readthedocs.io/en/latest/development/overview.html),
getting help in
[#development help](https://chat.zulip.org/#narrow/stream/development.20help)
if you run into any troubles.
* Read the
[Zulip guide to Git](https://zulip.readthedocs.io/en/latest/git/index.html)
and do the Git tutorial (coming soon) if you are unfamiliar with Git,
getting help in
[#git help](https://chat.zulip.org/#narrow/stream/git.20help) if you run
into any troubles.
* Sign the
[Dropbox Contributor License Agreement](https://opensource.dropbox.com/cla/).
### Picking an issue
Now, you're ready to pick your first issue! There are hundreds of open issues
in the main codebase alone. This section will help you find an issue to work
on.
* If you're interested in
[mobile](https://github.com/zulip/zulip-mobile/issues?q=is%3Aopen+is%3Aissue),
[desktop](https://github.com/zulip/zulip-electron/issues?q=is%3Aopen+is%3Aissue),
or
[bots](https://github.com/zulip/python-zulip-api/issues?q=is%3Aopen+is%3Aissue)
development, check the respective links for open issues, or post in
[#mobile](https://chat.zulip.org/#narrow/stream/mobile),
[#electron](https://chat.zulip.org/#narrow/stream/electron), or
[#bots](https://chat.zulip.org/#narrow/stream/bots).
* For the main server and web repository, start by looking through issues
with the label
[good first issue](https://github.com/zulip/zulip/issues?q=is%3Aopen+is%3Aissue+label%3A"good+first+issue").
These are smaller projects particularly suitable for a first contribution.
* We also partition all of our issues in the main repo into areas like
admin, compose, emoji, hotkeys, i18n, onboarding, search, etc. Look
through our [list of labels](https://github.com/zulip/zulip/labels), and
click on some of the `area:` labels to see all the issues related to your
areas of interest.
* If the lists of issues are overwhelming, post in
[#new members](https://chat.zulip.org/#narrow/stream/new.20members) with a
bit about your background and interests, and we'll help you out. The most
important thing to say is whether you're looking for a backend (Python),
frontend (JavaScript), mobile (React Native), desktop (Electron),
documentation (English) or visual design (JavaScript + CSS) issue, and a
bit about your programming experience and available time.
We also welcome suggestions of features that you feel would be valuable or
changes that you feel would make Zulip a better open source project. If you
have a new feature you'd like to add, we recommend you start by posting in
[#new members](https://chat.zulip.org/#narrow/stream/new.20members) with the
feature idea and the problem that you're hoping to solve.
Other notes:
* For a first pull request, it's better to aim for a smaller contribution
than a bigger one. Many first contributions have fewer than 10 lines of
changes (not counting changes to tests).
* The full list of issues looking for a contributor can be found with the
[help wanted](https://github.com/zulip/zulip/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)
label.
* For most new contributors, there's a lot to learn while making your first
pull request. It's OK if it takes you a while; that's normal! You'll be
able to work a lot faster as you build experience.
### Working on an issue
To work on an issue, claim it by adding a comment with `@zulipbot claim` to
the issue thread. [Zulipbot](https://github.com/zulip/zulipbot) is a GitHub
workflow bot; it will assign you to the issue and label the issue as "in
progress". Some additional notes:
* You're encouraged to ask questions on how to best implement or debug your
changes -- the Zulip maintainers are excited to answer questions to help
you stay unblocked and working efficiently. You can ask questions on
chat.zulip.org, or on the GitHub issue or pull request.
* We encourage early pull requests for work in progress. Prefix the title of
work in progress pull requests with `[WIP]`, and remove the prefix when
you think it might be mergeable and want it to be reviewed.
* After updating a PR, add a comment to the GitHub thread mentioning that it
is ready for another review. GitHub only notifies maintainers of the
changes when you post a comment, so if you don't, your PR will likely be
neglected by accident!
### And beyond
A great place to look for a second issue is to look for issues with the same
`area:` label as the last issue you resolved. You'll be able to reuse the
work you did learning how that part of the codebase works. Also, the path to
becoming a core developer often involves taking ownership of one of these area
labels.
## What makes a great Zulip contributor?
Zulip runs a lot of [internship programs](#internship-programs), so we have
a lot of experience with new contributors. In our experience, these are the
best predictors of success:
* Posting good questions. This generally means explaining your current
understanding, saying what you've done or tried so far, and including
tracebacks or other error messages if appropriate.
* Learning and practicing
[Git commit discipline](https://zulip.readthedocs.io/en/latest/contributing/version-control.html#commit-discipline).
* Submitting carefully tested code. This generally means checking your work
through a combination of automated tests and manually clicking around the
UI trying to find bugs in your work. See
[things to look for](https://zulip.readthedocs.io/en/latest/contributing/code-reviewing.html#things-to-look-for)
for additional ideas.
* Posting
[screenshots or GIFs](https://zulip.readthedocs.io/en/latest/tutorials/screenshot-and-gif-software.html)
for frontend changes.
* Being responsive to feedback on pull requests. This means incorporating or
responding to all suggested changes, and leaving a note if you won't be
able to address things within a few days.
* Being helpful and friendly on chat.zulip.org.
These are also the main criteria we use to select interns for all of our
internship programs.
## Reporting issues
If you find an easily reproducible bug and/or are experienced in reporting
bugs, feel free to just open an issue on the relevant project on GitHub.
If you have a feature request or are not yet sure what the underlying bug
is, the best place to post issues is
[#issues](https://chat.zulip.org/#narrow/stream/issues) (or
[#mobile](https://chat.zulip.org/#narrow/stream/mobile) or
[#electron](https://chat.zulip.org/#narrow/stream/electron)) on the
[Zulip community server](https://zulip.readthedocs.io/en/latest/contributing/chat-zulip-org.html).
This allows us to interactively figure out what is going on, let you know if
a similar issue has already been opened, and collect any other information
we need. Choose a 2-4 word topic that describes the issue, explain the issue
and how to reproduce it if known, your browser/OS if relevant, and a
[screenshot or screenGIF](https://zulip.readthedocs.io/en/latest/tutorials/screenshot-and-gif-software.html)
if appropriate.
**Reporting security issues**. Please do not report security issues
publicly, including on public streams on chat.zulip.org. You can email
zulip-security@googlegroups.com. We create a CVE for every security issue.
## User feedback
Nearly every feature we develop starts with a user request. If you are part
of a group that is either using or considering using Zulip, we would love to
hear about your experience with the product. If you're not sure what to
write, here are some questions we're always very curious to know the answer
to:
* Evaluation: What is the process by which your organization chose or will
choose a group chat product?
* Pros and cons: What are the pros and cons of Zulip for your organization,
and the pros and cons of other products you are evaluating?
* Features: What are the features that are most important for your
organization? In the best case scenario, what would your chat solution do
for you?
* Onboarding: If you remember it, what was your impression during your first
few minutes of using Zulip? What did you notice, and how did you feel? Was
there anything that stood out to you as confusing, or broken, or great?
* Organization: What does your organization do? How big is the organization?
A link to your organization's website?
## Internship programs
Zulip runs internship programs with
[Outreachy](https://www.outreachy.org/),
[Google Summer of Code (GSoC)](https://developers.google.com/open-source/gsoc/)
[1], and the
[MIT Externship program](https://alum.mit.edu/students/NetworkwithAlumni/ExternshipProgram),
and has in the past taken summer interns from Harvard, MIT, and
Stanford.
While each third-party program has its own rules and requirements, the
Zulip community's approaches all of these programs with these ideas in
mind:
* We try to make the application process as valuable for the applicant as
possible. Expect high quality code reviews, a supportive community, and
publicly viewable patches you can link to from your resume, regardless of
whether you are selected.
* To apply, you'll have to submit at least one pull request to a Zulip
repository. Most students accepted to one of our programs have
several merged pull requests (including at least one larger PR) by
the time of the application deadline.
* The main criteria we use is quality of your best contributions, and
the bullets listed at
[What makes a great Zulip contributor](#what-makes-a-great-zulip-contributor).
Because we focus on evaluating your best work, it doesn't hurt your
application to makes mistakes in your first few PRs as long as your
work improves.
Zulip also participates in
[Google Code-In](https://developers.google.com/open-source/gci/). Our
selection criteria for Finalists and Grand Prize Winners is the same as our
selection criteria for interns above.
Most of our interns end up sticking around the project long-term, and many
quickly become core team members. We hope you apply!
### Google Summer of Code
GSoC is by far the largest of our internship programs (we had 14 GSoC
students in summer 2017). While we don't control how many slots
Google allocates to Zulip, we hope to mentor a similar number of
students in 2018.
If you're reading this well before the application deadline and want
to make your application strong, we recommend getting involved in the
community and fixing issues in Zulip now. Having good contributions
and building a reputation for doing good work is best way to have a
strong application. About half of Zulip's GSoC students for Summer
2017 had made significant contributions to the project by February
2017, and about half had not. Our
[GSoC project ideas page][gsoc-guide] has lots more details on how
Zulip does GSoC, as well as project ideas (though the project idea
list is maintained only during the GSoC application period, so if
you're looking at some other time of year, the project list is likely
out-of-date).
We also have in some past years run a Zulip Summer of Code (ZSoC)
program for students who we didn't have enough slots to accept for
GSoC but were able to find funding for. Student expectations are the
same as with GSoC, and it has no separate application process; your
GSoC application is your ZSoC application. If we'd like to select you
for ZSoC, we'll contact you when the GSoC results are announced.
[gsoc-guide]: https://zulip.readthedocs.io/en/latest/overview/gsoc-ideas.html
[gsoc-faq]: https://developers.google.com/open-source/gsoc/faq
[1] Formally, [GSoC isn't an internship][gsoc-faq], but it is similar
enough that we're treating it as such for the purposes of this
documentation.
## Zulip Outreach
**Upvoting Zulip**. Upvotes and reviews make a big difference in the public
perception of projects like Zulip. We've collected a few sites below
where we know Zulip has been discussed. Doing everything in the following
list typically takes about 15 minutes.
* Star us on GitHub. There are four main repositories:
[server/web](https://github.com/zulip/zulip),
[mobile](https://github.com/zulip/zulip-mobile),
[desktop](https://github.com/zulip/zulip-electron), and
[Python API](https://github.com/zulip/python-zulip-api).
* [Follow us](https://twitter.com/zulip) on Twitter.
For both of the following, you'll need to make an account on the site if you
don't already have one.
* [Like Zulip](https://alternativeto.net/software/zulip-chat-server/) on
AlternativeTo. We recommend upvoting a couple of other products you like
as well, both to give back to their community, and since single-upvote
accounts are generally given less weight. You can also
[upvote Zulip](https://alternativeto.net/software/slack/) on their page
for Slack.
* [Add Zulip to your stack](https://stackshare.io/zulip) on StackShare, star
it, and upvote the reasons why people like Zulip that you find most
compelling. Again, we recommend adding a few other products that you like
as well.
We have a doc with more detailed instructions and a few other sites, if you
have been using Zulip for a while and want to contribute more.
**Blog posts**. Writing a blog post about your experiences with Zulip, or
about a technical aspect of Zulip can be a great way to spread the word
about Zulip.
We also occasionally [publish](http://blog.zulip.org/) longer form
articles related to Zulip. Our posts typically get tens of thousands
of views, and we always have good ideas for blog posts that we can
outline but don't have time to write. If you are an experienced writer
or copyeditor, send us a portfolio; we'd love to talk!

46
LICENSE
View File

@@ -1,3 +1,24 @@
Copyright 2011-2017 Dropbox, Inc., Kandra Labs, Inc., and contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
The software includes some works released by third parties under other
free and open source licenses. Those works are redistributed under the
license terms under which the works were received. For more details,
see the ``docs/THIRDPARTY`` file included with this distribution.
--------------------------------------------------------------------------------
Apache License
Version 2.0, January 2004
@@ -175,28 +196,3 @@
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

348
README.md
View File

@@ -1,301 +1,83 @@
**[Zulip overview](#zulip-overview)** |
**[Community](#community)** |
**[Installing for dev](#installing-the-zulip-development-environment)** |
**[Installing for production](#running-zulip-in-production)** |
**[Ways to contribute](#ways-to-contribute)** |
**[How to get involved](#how-to-get-involved-with-contributing-to-zulip)** |
**[License](#license)**
# Zulip overview
Zulip is a powerful, open source group chat application. Written in
Python and using the Django framework, Zulip supports both private
messaging and group chats via conversation streams.
Zulip is a powerful, open source group chat application that combines the
immediacy of real-time chat with the productivity benefits of threaded
conversations. Zulip is used by open source projects, Fortune 500 companies,
large standards bodies, and others who need a real-time chat system that
allows users to easily process hundreds or thousands of messages a day. With
over 300 contributors merging over 500 commits a month, Zulip is also the
largest and fastest growing open source group chat project.
Zulip also supports fast search, drag-and-drop file uploads, image
previews, group private messages, audible notifications,
missed-message emails, desktop apps, and much more.
Further information on the Zulip project and its features can be found
at <https://www.zulip.org>.
[![Build Status](https://travis-ci.org/zulip/zulip.svg?branch=master)](https://travis-ci.org/zulip/zulip)
[![CircleCI Build Status](https://circleci.com/gh/zulip/zulip.svg?style=svg)](https://circleci.com/gh/zulip/zulip)
[![Travis Build Status](https://travis-ci.org/zulip/zulip.svg?branch=master)](https://travis-ci.org/zulip/zulip)
[![Coverage Status](https://img.shields.io/codecov/c/github/zulip/zulip.svg)](https://codecov.io/gh/zulip/zulip)
[![Mypy coverage](https://img.shields.io/badge/mypy-100%25-green.svg)](http://blog.zulip.org/2016/10/13/static-types-in-python-oh-mypy/)
[![docs](https://readthedocs.org/projects/zulip/badge/?version=latest)](http://zulip.readthedocs.io/en/latest/)
[![Mypy coverage](https://img.shields.io/badge/mypy-100%25-green.svg)][mypy-coverage]
[![docs](https://readthedocs.org/projects/zulip/badge/?version=latest)](https://zulip.readthedocs.io/en/latest/)
[![Zulip chat](https://img.shields.io/badge/zulip-join_chat-brightgreen.svg)](https://chat.zulip.org)
[![Twitter](https://img.shields.io/badge/twitter-@zulip-blue.svg?style=flat)](http://twitter.com/zulip)
[![Twitter](https://img.shields.io/badge/twitter-@zulip-blue.svg?style=flat)](https://twitter.com/zulip)
## Community
[mypy-coverage]: https://blog.zulip.org/2016/10/13/static-types-in-python-oh-mypy/
There are several places online where folks discuss Zulip.
## Getting started
* The primary place is the
[Zulip development community Zulip server][czo-doc] at
chat.zulip.org.
Click on the appropriate link below. If nothing seems to apply,
join us on the
[Zulip community server](https://zulip.readthedocs.io/en/latest/contributing/chat-zulip-org.html)
and tell us what's up!
* For Google Summer of Code students and applicants, we have
[a mailing list](https://groups.google.com/forum/#!forum/zulip-gsoc)
for help, questions, and announcements. But it's often simpler to
[visit chat.zulip.org][czo-doc] instead.
You might be interested in:
* We have a [public development discussion mailing list][zulip-devel],
zulip-devel, which is currently pretty low traffic because most
discussions happen in our public Zulip instance. We use it to
announce Zulip developer community gatherings and ask for feedback on
major technical or design decisions. It has several hundred
subscribers, so you can use it to ask questions about features or
possible bugs, but please don't use it ask for generic help getting
started as a contributor (e.g. because you want to do Google Summer of
Code). The rest of this page covers how to get involved in the Zulip
project in detail.
* **Contributing code**. Check out our
[guide for new contributors](https://zulip.readthedocs.io/en/latest/overview/contributing.html)
to get started. Zulip prides itself on maintaining a clean and
well-tested codebase, and a stock of hundreds of
[beginner-friendly issues][beginner-friendly].
* Zulip also has a [blog](https://blog.zulip.org/) and
[twitter account](https://twitter.com/zulip).
* **Contributing non-code**.
[Report an issue](https://zulip.readthedocs.io/en/latest/overview/contributing.html#reporting-issue),
[translate](https://zulip.readthedocs.io/en/latest/translating/translating.html) Zulip
into your language,
[write](https://zulip.readthedocs.io/en/latest/overview/contributing.html#zulip-outreach)
for the Zulip blog, or
[give us feedback](https://zulip.readthedocs.io/en/latest/overview/contributing.html#user-feedback). We
would love to hear from you, even if you're just trying the product out.
* Last but not least, we use [GitHub](https://github.com/zulip/zulip)
to track Zulip-related issues (and store our code, of course).
Anybody with a GitHub account should be able to create Issues there
pertaining to bugs or enhancement requests. We also use Pull Requests
as our primary mechanism to receive code contributions.
* **Supporting Zulip**. Advocate for your organization to use Zulip, write a
review in the mobile app stores, or
[upvote Zulip](https://zulip.readthedocs.io/en/latest/overview/contributing.html#zulip-outreach) on
product comparison sites.
The Zulip community has a [Code of Conduct][code-of-conduct].
* **Checking Zulip out**. The best way to see Zulip in action is to drop by
the
[Zulip community server](https://zulip.readthedocs.io/en/latest/contributing/chat-zulip-org.html). We
also recommend reading Zulip for
[open source](https://zulipchat.com/for/open-source/), Zulip for
[companies](https://zulipchat.com/for/companies/), or Zulip for
[working groups and part time communities](https://zulipchat.com/for/working-groups-and-communities/).
[zulip-devel]: https://groups.google.com/forum/#!forum/zulip-devel
* **Running a Zulip server**. Setting up a server takes just a couple of
minutes. Zulip runs on Ubuntu 16.04 Xenial and Ubuntu 14.04 Trusty. The
installation process is
[documented here](https://zulip.readthedocs.io/en/1.7.1/prod.html).
Commercial support is available; see <https://zulipchat.com/plans> for
details.
## Installing the Zulip Development environment
* **Using Zulip without setting up a server**. <https://zulipchat.com> offers
free and commercial hosting.
The Zulip development environment is the recommended option for folks
interested in trying out Zulip, since it is very easy to install.
This is documented in [the developer installation guide][dev-install].
* **Applying for a Zulip internship**. Zulip runs internship programs with
[Outreachy](https://www.outreachy.org/),
[Google Summer of Code](https://developers.google.com/open-source/gsoc/),
and the
[MIT Externship program](https://alum.mit.edu/students/NetworkwithAlumni/ExternshipProgram). Zulip
also participates in
[Google Code-In](https://developers.google.com/open-source/gci/). More
information is available
[here](https://zulip.readthedocs.io/en/latest/overview/contributing.html#internship-programs).
## Running Zulip in production
You may also be interested in reading our [blog](http://blog.zulip.org/) or
following us on [twitter](https://twitter.com/zulip).
Zulip is distributed under the
[Apache 2.0](https://github.com/zulip/zulip/blob/master/LICENSE) license.
Zulip in production supports Ubuntu 16.04 Xenial and Ubuntu 14.04
Trusty. We're happy to support work to enable Zulip to run on
additional platforms. The installation process is
[documented here](https://zulip.readthedocs.io/en/latest/prod.html).
## Ways to contribute
Zulip welcomes all forms of contributions! This page documents the
Zulip development process.
* **Pull requests**. Before a pull request can be merged, you need to
sign the [Dropbox Contributor License Agreement][cla]. Also,
please skim our [commit message style guidelines][doc-commit-style].
We encourage early pull requests for work in progress. Prefix the title
of your pull request with `[WIP]` and reference it when asking for
community feedback. When you are ready for final review, remove
the `[WIP]`.
* **Testing**. The Zulip automated tests all run automatically when
you submit a pull request, but you can also run them all in your
development environment following the instructions in the [testing
docs][doc-test]. You can also try out [our new desktop
client][electron], which is in alpha; we'd appreciate testing and
[feedback](https://github.com/zulip/zulip-electron/issues/new).
* **Developer Documentation**. Zulip has a growing collection of
developer documentation on [Read The Docs][doc]. Recommended reading
for new contributors includes the [directory structure][doc-dirstruct]
and [new feature tutorial][doc-newfeat]. You can also improve
[Zulip.org][z-org].
* **Mailing lists and bug tracker**. Zulip has a [development
discussion mailing list](#community) and uses [GitHub issues
][gh-issues]. There are also lists for the [Android][email-android]
and [iOS][email-ios] apps. Feel free to send any questions or
suggestions of areas where you'd love to see more documentation to the
relevant list! Check out our [bug report guidelines][bug-report]
before submitting. Please report any security issues you discover to
zulip-security@googlegroups.com.
* **App codebases**. This repository is for the Zulip server and web
app (including most integrations). The
[beta React Native mobile app][mobile], [Java Android app][Android]
(see [our mobile strategy][mobile-strategy]),
[new Electron desktop app][electron], and
[legacy Qt-based desktop app][desktop] are all separate repositories.
* **Glue code**. We maintain a [Hubot adapter][hubot-adapter] and several
integrations ([Phabricator][phab], [Jenkins][], [Puppet][], [Redmine][],
and [Trello][]), plus [node.js API bindings][node], an [isomorphic
JavaScript library][zulip-js], and a [full-text search PostgreSQL
extension][tsearch], as separate repos.
* **Translations**. Zulip is in the process of being translated into
10+ languages, and we love contributions to our translations. See our
[translating documentation][transifex] if you're interested in
contributing!
* **Code Reviews**. Zulip is all about community and helping each
other out. Check out [#code review][code-review] on
[chat.zulip.org][czo-doc] to help review PRs and give comments on
other people's work. Everyone is welcome to participate, even those
new to Zulip! Even just checking out the code, manually testing it,
and posting on whether or not it worked is valuable.
[cla]: https://opensource.dropbox.com/cla/
[code-of-conduct]: https://zulip.readthedocs.io/en/latest/code-of-conduct.html
[dev-install]: https://zulip.readthedocs.io/en/latest/dev-overview.html
[doc]: https://zulip.readthedocs.io/
[doc-commit-style]: http://zulip.readthedocs.io/en/latest/version-control.html#commit-messages
[doc-dirstruct]: http://zulip.readthedocs.io/en/latest/directory-structure.html
[doc-newfeat]: http://zulip.readthedocs.io/en/latest/new-feature-tutorial.html
[doc-test]: http://zulip.readthedocs.io/en/latest/testing.html
[electron]: https://github.com/zulip/zulip-electron
[gh-issues]: https://github.com/zulip/zulip/issues
[desktop]: https://github.com/zulip/zulip-desktop
[android]: https://github.com/zulip/zulip-android
[mobile]: https://github.com/zulip/zulip-mobile
[mobile-strategy]: https://github.com/zulip/zulip-android/blob/master/android-strategy.md
[email-android]: https://groups.google.com/forum/#!forum/zulip-android
[email-ios]: https://groups.google.com/forum/#!forum/zulip-ios
[hubot-adapter]: https://github.com/zulip/hubot-zulip
[jenkins]: https://github.com/zulip/zulip-jenkins-plugin
[node]: https://github.com/zulip/zulip-node
[zulip-js]: https://github.com/zulip/zulip-js
[phab]: https://github.com/zulip/phabricator-to-zulip
[puppet]: https://github.com/matthewbarr/puppet-zulip
[redmine]: https://github.com/zulip/zulip-redmine-plugin
[trello]: https://github.com/zulip/trello-to-zulip
[tsearch]: https://github.com/zulip/tsearch_extras
[transifex]: https://zulip.readthedocs.io/en/latest/translating.html#testing-translations
[z-org]: https://github.com/zulip/zulip.github.io
[code-review]: https://chat.zulip.org/#narrow/stream/code.20review
[bug-report]: http://zulip.readthedocs.io/en/latest/bug-reports.html
## Google Summer of Code
We participated in
[GSoC](https://developers.google.com/open-source/gsoc/) in 2016 (with
[great results](https://blog.zulip.org/2016/10/13/static-types-in-python-oh-mypy/))
and [are participating](https://github.com/zulip/zulip.github.io/blob/master/gsoc-ideas.md)
in 2017 as well.
## How to get involved with contributing to Zulip
First, subscribe to the Zulip [development discussion mailing
list](#community).
The Zulip project uses a system of labels in our [issue
tracker][gh-issues] to make it easy to find a project if you don't
have your own project idea in mind or want to get some experience with
working on Zulip before embarking on a larger project you have in
mind:
* [Integrations](https://github.com/zulip/zulip/labels/area%3A%20integrations).
Integrate Zulip with another piece of software and contribute it
back to the community! Writing an integration can be a great first
contribution. There's detailed documentation on how to write
integrations in [the Zulip integration writing
guide](https://zulip.readthedocs.io/en/latest/integration-guide.html).
* [Good first issue](https://github.com/zulip/zulip/labels/good%20first%20issue):
Smaller projects that might be a great first contribution.
* [Documentation](https://github.com/zulip/zulip/labels/area%3A%20documentation):
The Zulip project loves contributions of new documentation.
* [Help Wanted](https://github.com/zulip/zulip/labels/help%20wanted):
A broader list of projects that nobody is currently working on.
* [Platform support](https://github.com/zulip/zulip/labels/Platform%20support):
These are open issues about making it possible to install Zulip on a
wider range of platforms.
* [Bugs](https://github.com/zulip/zulip/labels/bug): Open bugs.
* [Feature requests](https://github.com/zulip/zulip/labels/enhancement):
Browsing this list can be a great way to find feature ideas to
implement that other Zulip users are excited about.
* [2016 roadmap milestone](http://zulip.readthedocs.io/en/latest/roadmap.html):
The projects that are
[priorities for the Zulip project](https://zulip.readthedocs.io/en/latest/roadmap.html).
These are great projects if you're looking to make an impact.
Another way to find issues in Zulip is to take advantage of our
`area:<foo>` convention in separating out issues. We partition all of
our issues into areas like admin, compose, emoji, hotkeys, i18n,
onboarding, search, etc. Look through our
[list of labels](https://github.com/zulip/zulip/labels), and click on
some of the `area:` labels to see all the tickets related to your
areas of interest.
If you're excited about helping with an open issue, make sure to claim
the issue by commenting the following in the comment section:
"**@zulipbot** claim". **@zulipbot** will assign you to the issue and
label the issue as **in progress**. For more details, check out
[**@zulipbot**](https://github.com/zulip/zulipbot).
You're encouraged to ask questions on how to best implement or debug
your changes -- the Zulip maintainers are excited to answer questions
to help you stay unblocked and working efficiently. It's great to ask
questions in comments on GitHub issues and pull requests, or
[on chat.zulip.org][czo-doc]. We'll direct longer discussions to
Zulip chat, but please post a summary of what you learned from the
chat, or link to the conversation, in a comment on the GitHub issue.
We also welcome suggestions of features that you feel would be
valuable or changes that you feel would make Zulip a better open
source project, and are happy to support you in adding new features or
other user experience improvements to Zulip.
If you have a new feature you'd like to add, we recommend you start by
opening a GitHub issue about the feature idea explaining the problem
that you're hoping to solve and that you're excited to work on it. A
Zulip maintainer will usually reply within a day with feedback on the
idea, notes on any important issues or concerns, and and often tips on
how to implement or test it. Please feel free to ping the thread if
you don't hear a response from the maintainers -- we try to be very
responsive so this usually means we missed your message.
For significant changes to the visual design, user experience, data
model, or architecture, we highly recommend posting a mockup,
screenshot, or description of what you have in mind to the
[#design](https://chat.zulip.org/#narrow/stream/design) stream on
[chat.zulip.org][czo-doc] to get broad feedback before you spend too
much time on implementation details.
Finally, before implementing a larger feature, we highly recommend
looking at the
[new feature tutorial](http://zulip.readthedocs.io/en/latest/new-feature-tutorial.html)
and [coding style guidelines](http://zulip.readthedocs.io/en/latest/code-style.html)
on ReadTheDocs.
Feedback on how to make this development process more efficient, fun,
and friendly to new contributors is very welcome! Just send an email
to the [zulip-devel](#community) list with your thoughts.
When you feel like you have completed your work on an issue, post your
PR to the
[#code review](https://chat.zulip.org/#narrow/stream/code.20review)
stream on [chat.zulip.org][czo-doc]. This is our lightweight process
that gives other developers the opportunity to give you comments and
suggestions on your work.
## License
Copyright 2011-2017 Dropbox, Inc., Kandra Labs, Inc., and contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
The software includes some works released by third parties under other
free and open source licenses. Those works are redistributed under the
license terms under which the works were received. For more details,
see the ``docs/THIRDPARTY`` file included with this distribution.
[czo-doc]: https://zulip.readthedocs.io/en/latest/chat-zulip-org.html
[beginner-friendly]: https://github.com/zulip/zulip/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22

103
Vagrantfile vendored
View File

@@ -10,7 +10,7 @@ end
if Vagrant::VERSION == "1.8.7" then
path = `which curl`
if path.include?('/opt/vagrant/embedded/bin/curl') then
puts "In Vagrant 1.8.7, curl is broken. Please use Vagrant 1.8.6 "\
puts "In Vagrant 1.8.7, curl is broken. Please use Vagrant 2.0.2 "\
"or run 'sudo rm -f /opt/vagrant/embedded/bin/curl' to fix the "\
"issue before provisioning. See "\
"https://github.com/mitchellh/vagrant/issues/7997 "\
@@ -19,6 +19,53 @@ if Vagrant::VERSION == "1.8.7" then
end
end
# Workaround: the lxc-config in vagrant-lxc is incompatible with changes in
# LXC 2.1.0, found in Ubuntu 17.10 artful. LXC 2.1.1 (in 18.04 LTS bionic)
# ignores the old config key, so this will only be needed for artful.
#
# vagrant-lxc upstream has an attempted fix:
# https://github.com/fgrehm/vagrant-lxc/issues/445
# but it didn't work in our testing. This is a temporary issue, so we just
# hack in a fix: we patch the skeleton `lxc-config` file right in the
# distribution of the vagrant-lxc "box" we use. If the user doesn't yet
# have the box (e.g. on first setup), Vagrant would download it but too
# late for us to patch it like this; so we prompt them to explicitly add it
# first and then rerun.
if ['up', 'provision'].include? ARGV[0]
if command? "lxc-ls"
LXC_VERSION = `lxc-ls --version`.strip unless defined? LXC_VERSION
if LXC_VERSION == "2.1.0"
lxc_config_file = ENV['HOME'] + "/.vagrant.d/boxes/fgrehm-VAGRANTSLASH-trusty64-lxc/1.2.0/lxc/lxc-config"
if File.file?(lxc_config_file)
lines = File.readlines(lxc_config_file)
deprecated_line = "lxc.pivotdir = lxc_putold\n"
if lines[1] == deprecated_line
lines[1] = "# #{deprecated_line}"
File.open(lxc_config_file, 'w') do |f|
f.puts(lines)
end
end
else
puts 'You are running LXC 2.1.0, and fgrehm/trusty64-lxc box is incompatible '\
"with it by default. First add the box by doing:\n"\
" vagrant box add https://vagrantcloud.com/fgrehm/trusty64-lxc\n"\
'Once this command succeeds, do "vagrant up" again.'
exit
end
end
end
end
# Workaround: Vagrant removed the atlas.hashicorp.com to
# vagrantcloud.com redirect in February 2018. The value of
# DEFAULT_SERVER_URL in Vagrant versions less than 1.9.3 is
# atlas.hashicorp.com, which means that removal broke the fetching and
# updating of boxes (since the old URL doesn't work). See
# https://github.com/hashicorp/vagrant/issues/9442
if Vagrant::DEFAULT_SERVER_URL == "atlas.hashicorp.com"
Vagrant::DEFAULT_SERVER_URL.replace('https://vagrantcloud.com')
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# For LXC. VirtualBox hosts use a different box, described below.
@@ -30,7 +77,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
host_ip_addr = "127.0.0.1"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/srv/zulip"
if (/darwin/ =~ RUBY_PLATFORM) != nil
config.vm.synced_folder ".", "/srv/zulip", type: "nfs",
linux__nfs_options: ['rw']
config.vm.network "private_network", type: "dhcp"
else
config.vm.synced_folder ".", "/srv/zulip"
end
vagrant_config_file = ENV['HOME'] + "/.zulip-vagrant-config"
if File.file?(vagrant_config_file)
@@ -100,10 +153,29 @@ $provision_script = <<SCRIPT
set -x
set -e
set -o pipefail
# Code should go here, rather than tools/provision, only if it is
# something that we don't want to happen when running provision in a
# development environment not using Vagrant.
# Set the MOTD on the system to have Zulip instructions
sudo rm -f /etc/update-motd.d/*
sudo bash -c 'cat << EndOfMessage > /etc/motd
Welcome to the Zulip development environment! Popular commands:
* tools/provision - Update the development environment
* tools/run-dev.py - Run the development server
* tools/lint - Run the linter (quick and catches many problmes)
* tools/test-* - Run tests (use --help to learn about options)
Read https://zulip.readthedocs.io/en/latest/testing.html to learn
how to run individual test suites so that you can get a fast debug cycle.
EndOfMessage'
# If the host is running SELinux remount the /sys/fs/selinux directory as read only,
# needed for apt-get to work.
if [ -d "/sys/fs/selinux" ]; then
sudo mount -o remount,ro /sys/fs/selinux
sudo mount -o remount,ro /sys/fs/selinux
fi
# Set default locale, this prevents errors if the user has another locale set.
@@ -111,14 +183,35 @@ if ! grep -q 'LC_ALL=en_US.UTF-8' /etc/default/locale; then
echo "LC_ALL=en_US.UTF-8" | sudo tee -a /etc/default/locale
fi
# Set an environment variable, so that we won't print the virtualenv
# shell warning (it'll be wrong, since the shell is dying anyway)
export SKIP_VENV_SHELL_WARNING=1
# End `set -x`, so that the end of provision doesn't look like an error
# message after a successful run.
set +x
# Check if the zulip directory is writable
if [ ! -w /srv/zulip ]; then
echo "The vagrant user is unable to write to the zulip directory."
echo "To fix this, run the following commands on the host machine:"
# sudo is required since our uid is not 1000
echo ' vagrant halt -f'
echo ' rm -rf /PATH/TO/ZULIP/CLONE/.vagrant'
echo ' sudo chown -R 1000:$(whoami) /PATH/TO/ZULIP/CLONE'
echo "Replace /PATH/TO/ZULIP/CLONE with the path to where zulip code is cloned."
echo "You can resume setting up your vagrant environment by running:"
echo " vagrant up"
exit 1
fi
# Provision the development environment
ln -nsf /srv/zulip ~/zulip
/srv/zulip/tools/provision
# Run any custom provision hooks the user has configured
if [ -f /srv/zulip/tools/custom_provision ]; then
chmod +x /srv/zulip/tools/custom_provision
/srv/zulip/tools/custom_provision
chmod +x /srv/zulip/tools/custom_provision
/srv/zulip/tools/custom_provision
fi
SCRIPT

View File

@@ -1,38 +1,40 @@
import time
from collections import OrderedDict, defaultdict
from datetime import datetime, timedelta
import logging
from typing import Any, Callable, Dict, List, \
Optional, Text, Tuple, Type, Union
from django.conf import settings
from django.db import connection, models
from django.db.models import F
from analytics.models import InstallationCount, RealmCount, \
UserCount, StreamCount, BaseCount, FillState, Anomaly, installation_epoch, \
last_successful_fill
from zerver.models import Realm, UserProfile, Message, Stream, \
UserActivityInterval, RealmAuditLog, models
from zerver.lib.timestamp import floor_to_day, floor_to_hour, ceiling_to_day, \
ceiling_to_hour, verify_UTC
from typing import Any, Callable, Dict, List, Optional, Text, Tuple, Type, Union
from collections import defaultdict, OrderedDict
from datetime import timedelta, datetime
from zerver.lib.logging_util import create_logger
import time
from analytics.models import Anomaly, BaseCount, \
FillState, InstallationCount, RealmCount, StreamCount, \
UserCount, installation_epoch, last_successful_fill
from zerver.lib.logging_util import log_to_file
from zerver.lib.timestamp import ceiling_to_day, \
ceiling_to_hour, floor_to_hour, verify_UTC
from zerver.models import Message, Realm, RealmAuditLog, \
Stream, UserActivityInterval, UserProfile, models
## Logging setup ##
logger = create_logger('zulip.management', settings.ANALYTICS_LOG_PATH, 'INFO')
logger = logging.getLogger('zulip.management')
log_to_file(logger, settings.ANALYTICS_LOG_PATH)
# You can't subtract timedelta.max from a datetime, so use this instead
TIMEDELTA_MAX = timedelta(days=365*1000)
## Class definitions ##
class CountStat(object):
class CountStat:
HOUR = 'hour'
DAY = 'day'
FREQUENCIES = frozenset([HOUR, DAY])
def __init__(self, property, data_collector, frequency, interval=None):
# type: (str, DataCollector, str, Optional[timedelta]) -> None
def __init__(self, property: str, data_collector: 'DataCollector', frequency: str,
interval: Optional[timedelta]=None) -> None:
self.property = property
self.data_collector = data_collector
# might have to do something different for bitfields
@@ -46,31 +48,28 @@ class CountStat(object):
else: # frequency == CountStat.DAY
self.interval = timedelta(days=1)
def __unicode__(self):
# type: () -> Text
return u"<CountStat: %s>" % (self.property,)
def __str__(self) -> Text:
return "<CountStat: %s>" % (self.property,)
class LoggingCountStat(CountStat):
def __init__(self, property, output_table, frequency):
# type: (str, Type[BaseCount], str) -> None
def __init__(self, property: str, output_table: Type[BaseCount], frequency: str) -> None:
CountStat.__init__(self, property, DataCollector(output_table, None), frequency)
class DependentCountStat(CountStat):
def __init__(self, property, data_collector, frequency, interval=None, dependencies=[]):
# type: (str, DataCollector, str, Optional[timedelta], List[str]) -> None
def __init__(self, property: str, data_collector: 'DataCollector', frequency: str,
interval: Optional[timedelta]=None, dependencies: List[str]=[]) -> None:
CountStat.__init__(self, property, data_collector, frequency, interval=interval)
self.dependencies = dependencies
class DataCollector(object):
def __init__(self, output_table, pull_function):
# type: (Type[BaseCount], Optional[Callable[[str, datetime, datetime], int]]) -> None
class DataCollector:
def __init__(self, output_table: Type[BaseCount],
pull_function: Optional[Callable[[str, datetime, datetime], int]]) -> None:
self.output_table = output_table
self.pull_function = pull_function
## CountStat-level operations ##
def process_count_stat(stat, fill_to_time):
# type: (CountStat, datetime) -> None
def process_count_stat(stat: CountStat, fill_to_time: datetime) -> None:
if stat.frequency == CountStat.HOUR:
time_increment = timedelta(hours=1)
elif stat.frequency == CountStat.DAY:
@@ -120,16 +119,14 @@ def process_count_stat(stat, fill_to_time):
currently_filled = currently_filled + time_increment
logger.info("DONE %s (%dms)" % (stat.property, (end-start)*1000))
def do_update_fill_state(fill_state, end_time, state):
# type: (FillState, datetime, int) -> None
def do_update_fill_state(fill_state: FillState, end_time: datetime, state: int) -> None:
fill_state.end_time = end_time
fill_state.state = state
fill_state.save()
# We assume end_time is valid (e.g. is on a day or hour boundary as appropriate)
# and is timezone aware. It is the caller's responsibility to enforce this!
def do_fill_count_stat_at_hour(stat, end_time):
# type: (CountStat, datetime) -> None
def do_fill_count_stat_at_hour(stat: CountStat, end_time: datetime) -> None:
start_time = end_time - stat.interval
if not isinstance(stat, LoggingCountStat):
timer = time.time()
@@ -139,8 +136,7 @@ def do_fill_count_stat_at_hour(stat, end_time):
(stat.property, (time.time()-timer)*1000, rows_added))
do_aggregate_to_summary_table(stat, end_time)
def do_delete_counts_at_hour(stat, end_time):
# type: (CountStat, datetime) -> None
def do_delete_counts_at_hour(stat: CountStat, end_time: datetime) -> None:
if isinstance(stat, LoggingCountStat):
InstallationCount.objects.filter(property=stat.property, end_time=end_time).delete()
if stat.data_collector.output_table in [UserCount, StreamCount]:
@@ -151,8 +147,7 @@ def do_delete_counts_at_hour(stat, end_time):
RealmCount.objects.filter(property=stat.property, end_time=end_time).delete()
InstallationCount.objects.filter(property=stat.property, end_time=end_time).delete()
def do_aggregate_to_summary_table(stat, end_time):
# type: (CountStat, datetime) -> None
def do_aggregate_to_summary_table(stat: CountStat, end_time: datetime) -> None:
cursor = connection.cursor()
# Aggregate into RealmCount
@@ -177,7 +172,8 @@ def do_aggregate_to_summary_table(stat, end_time):
start = time.time()
cursor.execute(realmcount_query, {'end_time': end_time})
end = time.time()
logger.info("%s RealmCount aggregation (%dms/%sr)" % (stat.property, (end-start)*1000, cursor.rowcount))
logger.info("%s RealmCount aggregation (%dms/%sr)" % (
stat.property, (end - start) * 1000, cursor.rowcount))
# Aggregate into InstallationCount
installationcount_query = """
@@ -194,14 +190,16 @@ def do_aggregate_to_summary_table(stat, end_time):
start = time.time()
cursor.execute(installationcount_query, {'end_time': end_time})
end = time.time()
logger.info("%s InstallationCount aggregation (%dms/%sr)" % (stat.property, (end-start)*1000, cursor.rowcount))
logger.info("%s InstallationCount aggregation (%dms/%sr)" % (
stat.property, (end - start) * 1000, cursor.rowcount))
cursor.close()
## Utility functions called from outside counts.py ##
# called from zerver/lib/actions.py; should not throw any errors
def do_increment_logging_stat(zerver_object, stat, subgroup, event_time, increment=1):
# type: (Union[Realm, UserProfile, Stream], CountStat, Optional[Union[str, int, bool]], datetime, int) -> None
def do_increment_logging_stat(zerver_object: Union[Realm, UserProfile, Stream], stat: CountStat,
subgroup: Optional[Union[str, int, bool]], event_time: datetime,
increment: int=1) -> None:
table = stat.data_collector.output_table
if table == RealmCount:
id_args = {'realm': zerver_object}
@@ -222,8 +220,7 @@ def do_increment_logging_stat(zerver_object, stat, subgroup, event_time, increme
row.value = F('value') + increment
row.save(update_fields=['value'])
def do_drop_all_analytics_tables():
# type: () -> None
def do_drop_all_analytics_tables() -> None:
UserCount.objects.all().delete()
StreamCount.objects.all().delete()
RealmCount.objects.all().delete()
@@ -231,8 +228,7 @@ def do_drop_all_analytics_tables():
FillState.objects.all().delete()
Anomaly.objects.all().delete()
def do_drop_single_stat(property):
# type: (str) -> None
def do_drop_single_stat(property: str) -> None:
UserCount.objects.filter(property=property).delete()
StreamCount.objects.filter(property=property).delete()
RealmCount.objects.filter(property=property).delete()
@@ -241,8 +237,8 @@ def do_drop_single_stat(property):
## DataCollector-level operations ##
def do_pull_by_sql_query(property, start_time, end_time, query, group_by):
# type: (str, datetime, datetime, str, Optional[Tuple[models.Model, str]]) -> int
def do_pull_by_sql_query(property: str, start_time: datetime, end_time: datetime, query: str,
group_by: Optional[Tuple[models.Model, str]]) -> int:
if group_by is None:
subgroup = 'NULL'
group_by_clause = ''
@@ -262,15 +258,13 @@ def do_pull_by_sql_query(property, start_time, end_time, query, group_by):
cursor.close()
return rowcount
def sql_data_collector(output_table, query, group_by):
# type: (Type[BaseCount], str, Optional[Tuple[models.Model, str]]) -> DataCollector
def pull_function(property, start_time, end_time):
# type: (str, datetime, datetime) -> int
def sql_data_collector(output_table: Type[BaseCount], query: str,
group_by: Optional[Tuple[models.Model, str]]) -> DataCollector:
def pull_function(property: str, start_time: datetime, end_time: datetime) -> int:
return do_pull_by_sql_query(property, start_time, end_time, query, group_by)
return DataCollector(output_table, pull_function)
def do_pull_minutes_active(property, start_time, end_time):
# type: (str, datetime, datetime) -> int
def do_pull_minutes_active(property: str, start_time: datetime, end_time: datetime) -> int:
user_activity_intervals = UserActivityInterval.objects.filter(
end__gt=start_time, start__lt=end_time
).select_related(
@@ -294,7 +288,8 @@ count_message_by_user_query = """
INSERT INTO analytics_usercount
(user_id, realm_id, value, property, subgroup, end_time)
SELECT
zerver_userprofile.id, zerver_userprofile.realm_id, count(*), '%(property)s', %(subgroup)s, %%(time_end)s
zerver_userprofile.id, zerver_userprofile.realm_id, count(*),
'%(property)s', %(subgroup)s, %%(time_end)s
FROM zerver_userprofile
JOIN zerver_message
ON
@@ -336,7 +331,9 @@ count_message_type_by_user_query = """
LEFT JOIN zerver_stream
ON
zerver_recipient.type_id = zerver_stream.id
GROUP BY zerver_userprofile.realm_id, zerver_userprofile.id, zerver_recipient.type, zerver_stream.invite_only
GROUP BY
zerver_userprofile.realm_id, zerver_userprofile.id,
zerver_recipient.type, zerver_stream.invite_only
) AS subquery
GROUP BY realm_id, id, message_type
"""
@@ -521,6 +518,11 @@ count_stats_ = [
CountStat.DAY, interval=timedelta(days=15)-UserActivityInterval.MIN_INTERVAL_LENGTH),
CountStat('minutes_active::day', DataCollector(UserCount, do_pull_minutes_active), CountStat.DAY),
# Rate limiting stats
# Used to limit the number of invitation emails sent by a realm
LoggingCountStat('invites_sent::day', RealmCount, CountStat.DAY),
# Dependent stats
# Must come after their dependencies.

View File

@@ -1,19 +1,14 @@
from zerver.models import Realm, UserProfile, Stream, Message
from analytics.models import InstallationCount, RealmCount, UserCount, StreamCount
from analytics.lib.counts import CountStat
from analytics.lib.time_utils import time_range
from datetime import datetime
from math import sqrt
from random import gauss, random, seed
from typing import List
from six.moves import zip
from analytics.lib.counts import CountStat
def generate_time_series_data(days=100, business_hours_base=10, non_business_hours_base=10,
growth=1, autocorrelation=0, spikiness=1, holiday_rate=0,
frequency=CountStat.DAY, partial_sum=False, random_seed=26):
# type: (int, float, float, float, float, float, float, str, bool, int) -> List[int]
def generate_time_series_data(days: int=100, business_hours_base: float=10,
non_business_hours_base: float=10, growth: float=1,
autocorrelation: float=0, spikiness: float=1,
holiday_rate: float=0, frequency: str=CountStat.DAY,
partial_sum: bool=False, random_seed: int=26) -> List[int]:
"""
Generate semi-realistic looking time series data for testing analytics graphs.

View File

@@ -1,16 +1,15 @@
from zerver.lib.timestamp import floor_to_hour, floor_to_day, \
timestamp_to_datetime, verify_UTC
from analytics.lib.counts import CountStat
from datetime import datetime, timedelta
from typing import List, Optional
from analytics.lib.counts import CountStat
from zerver.lib.timestamp import floor_to_day, floor_to_hour, verify_UTC
# If min_length is None, returns end_times from ceiling(start) to floor(end), inclusive.
# If min_length is greater than 0, pads the list to the left.
# So informally, time_range(Sep 20, Sep 22, day, None) returns [Sep 20, Sep 21, Sep 22],
# and time_range(Sep 20, Sep 22, day, 5) returns [Sep 18, Sep 19, Sep 20, Sep 21, Sep 22]
def time_range(start, end, frequency, min_length):
# type: (datetime, datetime, str, Optional[int]) -> List[datetime]
def time_range(start: datetime, end: datetime, frequency: str,
min_length: Optional[int]) -> List[datetime]:
verify_UTC(start)
verify_UTC(end)
if frequency == CountStat.HOUR:

View File

@@ -1,14 +1,14 @@
import datetime
import logging
import time
from typing import Any, Dict
from django.core.management.base import BaseCommand, CommandParser
from zerver.models import Recipient, Message
from zerver.lib.timestamp import timestamp_to_datetime
import datetime
import time
import logging
def compute_stats(log_level):
# type: (int) -> None
from zerver.lib.timestamp import timestamp_to_datetime
from zerver.models import Message, Recipient
def compute_stats(log_level: int) -> None:
logger = logging.getLogger()
logger.setLevel(log_level)
@@ -71,12 +71,10 @@ def compute_stats(log_level):
class Command(BaseCommand):
help = "Compute statistics on MIT Zephyr usage."
def add_arguments(self, parser):
# type: (CommandParser) -> None
def add_arguments(self, parser: CommandParser) -> None:
parser.add_argument('--verbose', default=False, action='store_true')
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
def handle(self, *args: Any, **options: Any) -> None:
level = logging.INFO
if options["verbose"]:
level = logging.DEBUG

View File

@@ -1,14 +1,13 @@
import datetime
from typing import Any, Dict
from zerver.lib.statistics import seconds_usage_between
from django.core.management.base import BaseCommand, CommandParser
from zerver.models import UserProfile
import datetime
from django.utils.timezone import utc
def analyze_activity(options):
# type: (Dict[str, Any]) -> None
from zerver.lib.statistics import seconds_usage_between
from zerver.models import UserProfile
def analyze_activity(options: Dict[str, Any]) -> None:
day_start = datetime.datetime.strptime(options["date"], "%Y-%m-%d").replace(tzinfo=utc)
day_end = day_start + datetime.timedelta(days=options["duration"])
@@ -47,13 +46,11 @@ Usage: ./manage.py analyze_user_activity [--realm=zulip] [--date=2013-09-10] [--
By default, if no date is selected 2013-09-10 is used. If no realm is provided, information
is shown for all realms"""
def add_arguments(self, parser):
# type: (CommandParser) -> None
def add_arguments(self, parser: CommandParser) -> None:
parser.add_argument('--realm', action='store')
parser.add_argument('--date', action='store', default="2013-09-06")
parser.add_argument('--duration', action='store', default=1, type=int,
help="How many days to show usage information for")
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
def handle(self, *args: Any, **options: Any) -> None:
analyze_activity(options)

View File

@@ -0,0 +1,85 @@
from argparse import ArgumentParser
from datetime import timedelta
from django.core.management.base import BaseCommand
from django.utils.timezone import now as timezone_now
from analytics.models import InstallationCount, installation_epoch, \
last_successful_fill
from analytics.lib.counts import COUNT_STATS, CountStat
from zerver.lib.timestamp import floor_to_hour, floor_to_day, verify_UTC, \
TimezoneNotUTCException
from zerver.models import Realm
import os
import subprocess
import sys
import time
from typing import Any, Dict
states = {
0: "OK",
1: "WARNING",
2: "CRITICAL",
3: "UNKNOWN"
}
class Command(BaseCommand):
help = """Checks FillState table.
Run as a cron job that runs every hour."""
def handle(self, *args: Any, **options: Any) -> None:
fill_state = self.get_fill_state()
status = fill_state['status']
message = fill_state['message']
state_file_path = "/var/lib/nagios_state/check-analytics-state"
state_file_tmp = state_file_path + "-tmp"
with open(state_file_tmp, "w") as f:
f.write("%s|%s|%s|%s\n" % (
int(time.time()), status, states[status], message))
subprocess.check_call(["mv", state_file_tmp, state_file_path])
def get_fill_state(self) -> Dict[str, Any]:
if not Realm.objects.exists():
return {'status': 0, 'message': 'No realms exist, so not checking FillState.'}
warning_unfilled_properties = []
critical_unfilled_properties = []
for property, stat in COUNT_STATS.items():
last_fill = last_successful_fill(property)
if last_fill is None:
last_fill = installation_epoch()
try:
verify_UTC(last_fill)
except TimezoneNotUTCException:
return {'status': 2, 'message': 'FillState not in UTC for %s' % (property,)}
if stat.frequency == CountStat.DAY:
floor_function = floor_to_day
warning_threshold = timedelta(hours=26)
critical_threshold = timedelta(hours=50)
else: # CountStat.HOUR
floor_function = floor_to_hour
warning_threshold = timedelta(minutes=90)
critical_threshold = timedelta(minutes=150)
if floor_function(last_fill) != last_fill:
return {'status': 2, 'message': 'FillState not on %s boundary for %s' %
(stat.frequency, property)}
time_to_last_fill = timezone_now() - last_fill
if time_to_last_fill > critical_threshold:
critical_unfilled_properties.append(property)
elif time_to_last_fill > warning_threshold:
warning_unfilled_properties.append(property)
if len(critical_unfilled_properties) == 0 and len(warning_unfilled_properties) == 0:
return {'status': 0, 'message': 'FillState looks fine.'}
if len(critical_unfilled_properties) == 0:
return {'status': 1, 'message': 'Missed filling %s once.' %
(', '.join(warning_unfilled_properties),)}
return {'status': 2, 'message': 'Missed filling %s once. Missed filling %s at least twice.' %
(', '.join(warning_unfilled_properties), ', '.join(critical_unfilled_properties))}

View File

@@ -1,24 +1,20 @@
import sys
from argparse import ArgumentParser
from django.db import connection
from typing import Any
from django.core.management.base import BaseCommand
from analytics.lib.counts import do_drop_all_analytics_tables
from typing import Any
class Command(BaseCommand):
help = """Clear analytics tables."""
def add_arguments(self, parser):
# type: (ArgumentParser) -> None
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument('--force',
action='store_true',
help="Clear analytics tables.")
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
def handle(self, *args: Any, **options: Any) -> None:
if options['force']:
do_drop_all_analytics_tables()
else:

View File

@@ -1,18 +1,15 @@
import sys
from argparse import ArgumentParser
from django.db import connection
from typing import Any
from django.core.management.base import BaseCommand
from analytics.lib.counts import do_drop_single_stat, COUNT_STATS
from typing import Any
from analytics.lib.counts import COUNT_STATS, do_drop_single_stat
class Command(BaseCommand):
help = """Clear analytics tables."""
def add_arguments(self, parser):
# type: (ArgumentParser) -> None
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument('--force',
action='store_true',
help="Actually do it.")
@@ -20,8 +17,7 @@ class Command(BaseCommand):
type=str,
help="The property of the stat to be cleared.")
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
def handle(self, *args: Any, **options: Any) -> None:
property = options['property']
if property not in COUNT_STATS:
print("Invalid property: %s" % (property,))

View File

@@ -1,14 +1,13 @@
import datetime
from argparse import ArgumentParser
from typing import Any
from argparse import ArgumentParser
from django.db.models import Count, QuerySet
from django.utils.timezone import now as timezone_now
from zerver.lib.management import ZulipBaseCommand
from zerver.models import UserActivity
import datetime
class Command(ZulipBaseCommand):
help = """Report rough client activity globally, for a realm, or for a user
@@ -18,18 +17,16 @@ Usage examples:
./manage.py client_activity --target realm --realm zulip
./manage.py client_activity --target user --user hamlet@zulip.com --realm zulip"""
def add_arguments(self, parser):
# type: (ArgumentParser) -> None
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument('--target', dest='target', required=True, type=str,
help="'server' will calculate client activity of the entire server. "
"'realm' will calculate client activity of realm. "
"'user' will calculate client activity of the user.")
parser.add_argument('--user', dest='user', type=str,
help="The email adress of the user you want to calculate activity.")
help="The email address of the user you want to calculate activity.")
self.add_realm_args(parser)
def compute_activity(self, user_activity_objects):
# type: (QuerySet) -> None
def compute_activity(self, user_activity_objects: QuerySet) -> None:
# Report data from the past week.
#
# This is a rough report of client activity because we inconsistently
@@ -59,8 +56,7 @@ Usage examples:
print("%25s %15d" % (count[1], count[0]))
print("Total:", total)
def handle(self, *args, **options):
# type: (*Any, **str) -> None
def handle(self, *args: Any, **options: str) -> None:
realm = self.get_realm(options)
if options["user"] is None:
if options["target"] == "server" and realm is None:

View File

@@ -1,22 +1,18 @@
from argparse import ArgumentParser
from datetime import datetime, timedelta
from typing import Any, Dict, List, Mapping, Optional, Text, Type, Union
from django.core.management.base import BaseCommand
from django.utils.timezone import now as timezone_now
from analytics.lib.counts import COUNT_STATS, CountStat, do_drop_all_analytics_tables
from analytics.lib.counts import COUNT_STATS, \
CountStat, do_drop_all_analytics_tables
from analytics.lib.fixtures import generate_time_series_data
from analytics.lib.time_utils import time_range
from analytics.models import BaseCount, InstallationCount, RealmCount, \
UserCount, StreamCount, FillState
from analytics.models import BaseCount, FillState, RealmCount, UserCount, StreamCount
from zerver.lib.timestamp import floor_to_day
from zerver.models import Realm, UserProfile, Stream, Message, Client, \
RealmAuditLog
from datetime import datetime, timedelta
from six.moves import zip
from typing import Any, Dict, List, Optional, Text, Type, Union, Mapping
RealmAuditLog, Recipient
class Command(BaseCommand):
help = """Populates analytics tables with randomly generated data."""
@@ -24,8 +20,11 @@ class Command(BaseCommand):
DAYS_OF_DATA = 100
random_seed = 26
def create_user(self, email, full_name, is_staff, date_joined, realm):
# type: (Text, Text, Text, bool, datetime, Realm) -> UserProfile
def create_user(self, email: Text,
full_name: Text,
is_staff: bool,
date_joined: datetime,
realm: Realm) -> UserProfile:
user = UserProfile.objects.create(
email=email, full_name=full_name, is_staff=is_staff,
realm=realm, short_name=full_name, pointer=-1, last_pointer_updater='none',
@@ -35,10 +34,10 @@ class Command(BaseCommand):
event_time=user.date_joined)
return user
def generate_fixture_data(self, stat, business_hours_base, non_business_hours_base,
growth, autocorrelation, spikiness, holiday_rate=0,
partial_sum=False):
# type: (CountStat, float, float, float, float, float, float, bool) -> List[int]
def generate_fixture_data(self, stat: CountStat, business_hours_base: float,
non_business_hours_base: float, growth: float,
autocorrelation: float, spikiness: float,
holiday_rate: float=0, partial_sum: bool=False) -> List[int]:
self.random_seed += 1
return generate_time_series_data(
days=self.DAYS_OF_DATA, business_hours_base=business_hours_base,
@@ -46,8 +45,7 @@ class Command(BaseCommand):
autocorrelation=autocorrelation, spikiness=spikiness, holiday_rate=holiday_rate,
frequency=stat.frequency, partial_sum=partial_sum, random_seed=self.random_seed)
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
def handle(self, *args: Any, **options: Any) -> None:
do_drop_all_analytics_tables()
# I believe this also deletes any objects with this realm as a foreign key
Realm.objects.filter(string_id='analytics').delete()
@@ -57,15 +55,22 @@ class Command(BaseCommand):
realm = Realm.objects.create(
string_id='analytics', name='Analytics', date_created=installation_time)
shylock = self.create_user('shylock@analytics.ds', 'Shylock', True, installation_time, realm)
stream = Stream.objects.create(
name='all', realm=realm, date_created=installation_time)
Recipient.objects.create(type_id=stream.id, type=Recipient.STREAM)
def insert_fixture_data(stat, fixture_data, table):
# type: (CountStat, Mapping[Optional[str], List[int]], Type[BaseCount]) -> None
def insert_fixture_data(stat: CountStat,
fixture_data: Mapping[Optional[str], List[int]],
table: Type[BaseCount]) -> None:
end_times = time_range(last_end_time, last_end_time, stat.frequency,
len(list(fixture_data.values())[0]))
if table == RealmCount:
id_args = {'realm': realm}
if table == UserCount:
id_args = {'realm': realm, 'user': shylock}
if table == StreamCount:
id_args = {'stream': stream, 'realm': realm}
for subgroup, values in fixture_data.items():
table.objects.bulk_create([
table(property=stat.property, subgroup=subgroup, end_time=end_time,
@@ -134,4 +139,12 @@ class Command(BaseCommand):
FillState.objects.create(property=stat.property, end_time=last_end_time,
state=FillState.DONE)
# TODO: messages_sent_to_stream:is_bot
stat = COUNT_STATS['messages_in_stream:is_bot:day']
realm_data = {'false': self.generate_fixture_data(stat, 30, 5, 6, .6, 4),
'true': self.generate_fixture_data(stat, 20, 2, 3, .2, 3)}
insert_fixture_data(stat, realm_data, RealmCount)
stream_data = {'false': self.generate_fixture_data(stat, 10, 7, 5, .6, 4),
'true': self.generate_fixture_data(stat, 5, 3, 2, .4, 2)} # type: Mapping[Optional[str], List[int]]
insert_fixture_data(stat, stream_data, StreamCount)
FillState.objects.create(property=stat.property, end_time=last_end_time,
state=FillState.DONE)

View File

@@ -1,15 +1,14 @@
import datetime
from argparse import ArgumentParser
from typing import Any, List
from argparse import ArgumentParser
import datetime
import pytz
from django.core.management.base import BaseCommand
from django.db.models import Count
from django.utils.timezone import now as timezone_now
from zerver.models import UserProfile, Realm, Stream, Message, Recipient, UserActivity, \
Subscription, UserMessage, get_realm
from zerver.models import Message, Realm, Recipient, Stream, \
Subscription, UserActivity, UserMessage, UserProfile, get_realm
MOBILE_CLIENT_LIST = ["Android", "ios"]
HUMAN_CLIENT_LIST = MOBILE_CLIENT_LIST + ["website"]
@@ -19,13 +18,11 @@ human_messages = Message.objects.filter(sending_client__name__in=HUMAN_CLIENT_LI
class Command(BaseCommand):
help = "Generate statistics on realm activity."
def add_arguments(self, parser):
# type: (ArgumentParser) -> None
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument('realms', metavar='<realm>', type=str, nargs='*',
help="realm to generate statistics for")
def active_users(self, realm):
# type: (Realm) -> List[UserProfile]
def active_users(self, realm: Realm) -> List[UserProfile]:
# Has been active (on the website, for now) in the last 7 days.
activity_cutoff = timezone_now() - datetime.timedelta(days=7)
return [activity.user_profile for activity in (
@@ -35,53 +32,44 @@ class Command(BaseCommand):
query="/json/users/me/pointer",
client__name="website"))]
def messages_sent_by(self, user, days_ago):
# type: (UserProfile, int) -> int
def messages_sent_by(self, user: UserProfile, days_ago: int) -> int:
sent_time_cutoff = timezone_now() - datetime.timedelta(days=days_ago)
return human_messages.filter(sender=user, pub_date__gt=sent_time_cutoff).count()
def total_messages(self, realm, days_ago):
# type: (Realm, int) -> int
def total_messages(self, realm: Realm, days_ago: int) -> int:
sent_time_cutoff = timezone_now() - datetime.timedelta(days=days_ago)
return Message.objects.filter(sender__realm=realm, pub_date__gt=sent_time_cutoff).count()
def human_messages(self, realm, days_ago):
# type: (Realm, int) -> int
def human_messages(self, realm: Realm, days_ago: int) -> int:
sent_time_cutoff = timezone_now() - datetime.timedelta(days=days_ago)
return human_messages.filter(sender__realm=realm, pub_date__gt=sent_time_cutoff).count()
def api_messages(self, realm, days_ago):
# type: (Realm, int) -> int
def api_messages(self, realm: Realm, days_ago: int) -> int:
return (self.total_messages(realm, days_ago) - self.human_messages(realm, days_ago))
def stream_messages(self, realm, days_ago):
# type: (Realm, int) -> int
def stream_messages(self, realm: Realm, days_ago: int) -> int:
sent_time_cutoff = timezone_now() - datetime.timedelta(days=days_ago)
return human_messages.filter(sender__realm=realm, pub_date__gt=sent_time_cutoff,
recipient__type=Recipient.STREAM).count()
def private_messages(self, realm, days_ago):
# type: (Realm, int) -> int
def private_messages(self, realm: Realm, days_ago: int) -> int:
sent_time_cutoff = timezone_now() - datetime.timedelta(days=days_ago)
return human_messages.filter(sender__realm=realm, pub_date__gt=sent_time_cutoff).exclude(
recipient__type=Recipient.STREAM).exclude(recipient__type=Recipient.HUDDLE).count()
def group_private_messages(self, realm, days_ago):
# type: (Realm, int) -> int
def group_private_messages(self, realm: Realm, days_ago: int) -> int:
sent_time_cutoff = timezone_now() - datetime.timedelta(days=days_ago)
return human_messages.filter(sender__realm=realm, pub_date__gt=sent_time_cutoff).exclude(
recipient__type=Recipient.STREAM).exclude(recipient__type=Recipient.PERSONAL).count()
def report_percentage(self, numerator, denominator, text):
# type: (float, float, str) -> None
def report_percentage(self, numerator: float, denominator: float, text: str) -> None:
if not denominator:
fraction = 0.0
else:
fraction = numerator / float(denominator)
print("%.2f%% of" % (fraction * 100,), text)
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
def handle(self, *args: Any, **options: Any) -> None:
if options['realms']:
try:
realms = [get_realm(string_id) for string_id in options['realms']]

View File

@@ -1,20 +1,20 @@
from argparse import ArgumentParser
from typing import Any
from argparse import ArgumentParser
from django.core.management.base import BaseCommand
from django.db.models import Q
from zerver.models import Realm, Stream, Message, Subscription, Recipient, get_realm
from zerver.models import Message, Realm, \
Recipient, Stream, Subscription, get_realm
class Command(BaseCommand):
help = "Generate statistics on the streams for a realm."
def add_arguments(self, parser):
# type: (ArgumentParser) -> None
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument('realms', metavar='<realm>', type=str, nargs='*',
help="realm to generate statistics for")
def handle(self, *args, **options):
# type: (*Any, **str) -> None
def handle(self, *args: Any, **options: str) -> None:
if options['realms']:
try:
realms = [get_realm(string_id) for string_id in options['realms']]
@@ -36,7 +36,8 @@ class Command(BaseCommand):
continue
print("%25s" % (stream.name,), end=' ')
recipient = Recipient.objects.filter(type=Recipient.STREAM, type_id=stream.id)
print("%10d" % (len(Subscription.objects.filter(recipient=recipient, active=True)),), end=' ')
print("%10d" % (len(Subscription.objects.filter(recipient=recipient,
active=True)),), end=' ')
num_messages = len(Message.objects.filter(recipient=recipient))
print("%12d" % (num_messages,))
print("%d invite-only streams" % (invite_only_count,))

View File

@@ -1,34 +1,29 @@
import os
import sys
from scripts.lib.zulip_tools import ENDC, WARNING
from argparse import ArgumentParser
from datetime import timedelta
import time
from argparse import ArgumentParser
from typing import Any, Dict
from django.conf import settings
from django.core.management.base import BaseCommand
from django.utils.dateparse import parse_datetime
from django.utils.timezone import now as timezone_now
from django.utils.timezone import utc as timezone_utc
from django.utils.dateparse import parse_datetime
from django.conf import settings
from analytics.models import RealmCount, UserCount
from analytics.lib.counts import COUNT_STATS, logger, process_count_stat
from scripts.lib.zulip_tools import ENDC, WARNING
from zerver.lib.timestamp import floor_to_hour
from zerver.models import UserProfile, Message, Realm
from typing import Any, Dict
from zerver.models import Realm
class Command(BaseCommand):
help = """Fills Analytics tables.
Run as a cron job that runs every hour."""
def add_arguments(self, parser):
# type: (ArgumentParser) -> None
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument('--time', '-t',
type=str,
help='Update stat tables from current state to --time. Defaults to the current time.',
help='Update stat tables from current state to'
'--time. Defaults to the current time.',
default=timezone_now().isoformat())
parser.add_argument('--utc',
action='store_true',
@@ -42,8 +37,7 @@ class Command(BaseCommand):
help="Print timing information to stdout.",
default=False)
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
def handle(self, *args: Any, **options: Any) -> None:
try:
os.mkdir(settings.ANALYTICS_LOCK_DIR)
except OSError:
@@ -55,8 +49,7 @@ class Command(BaseCommand):
finally:
os.rmdir(settings.ANALYTICS_LOCK_DIR)
def run_update_analytics_counts(self, options):
# type: (Dict[str, Any]) -> None
def run_update_analytics_counts(self, options: Dict[str, Any]) -> None:
# installation_epoch relies on there being at least one realm; we
# shouldn't run the analytics code if that condition isn't satisfied
if not Realm.objects.exists():

View File

@@ -1,29 +1,25 @@
from argparse import ArgumentParser
import datetime
import pytz
from argparse import ArgumentParser
from typing import Any
from django.core.management.base import BaseCommand
from django.utils.timezone import now as timezone_now
from zerver.models import UserProfile, Realm, Stream, Message, get_realm
from zerver.models import Message, Realm, Stream, UserProfile, get_realm
class Command(BaseCommand):
help = "Generate statistics on user activity."
def add_arguments(self, parser):
# type: (ArgumentParser) -> None
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument('realms', metavar='<realm>', type=str, nargs='*',
help="realm to generate statistics for")
def messages_sent_by(self, user, week):
# type: (UserProfile, int) -> int
def messages_sent_by(self, user: UserProfile, week: int) -> int:
start = timezone_now() - datetime.timedelta(days=(week + 1)*7)
end = timezone_now() - datetime.timedelta(days=week*7)
return Message.objects.filter(sender=user, pub_date__gt=start, pub_date__lte=end).count()
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
def handle(self, *args: Any, **options: Any) -> None:
if options['realms']:
try:
realms = [get_realm(string_id) for string_id in options['realms']]

View File

@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from django.db import models, migrations
import django.db.models.deletion
from django.conf import settings
import zerver.lib.str_utils
from django.db import migrations, models
import zerver.lib.str_utils
class Migration(migrations.Migration):

View File

@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [

View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from django.db import migrations, models
import zerver.lib.str_utils
import zerver.lib.str_utils
class Migration(migrations.Migration):

View File

@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [

View File

@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [

View File

@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [

View File

@@ -3,7 +3,6 @@
from django.conf import settings
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [

View File

@@ -2,7 +2,6 @@
# Generated by Django 1.10.5 on 2017-02-01 22:28
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [

View File

@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
from django.db import migrations
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
from django.db import migrations
def delete_messages_sent_to_stream_stat(apps, schema_editor):
# type: (StateApps, DatabaseSchemaEditor) -> None
def delete_messages_sent_to_stream_stat(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
UserCount = apps.get_model('analytics', 'UserCount')
StreamCount = apps.get_model('analytics', 'StreamCount')
RealmCount = apps.get_model('analytics', 'RealmCount')

View File

@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
from django.db import migrations
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
from django.db import migrations
def clear_message_sent_by_message_type_values(apps, schema_editor):
# type: (StateApps, DatabaseSchemaEditor) -> None
def clear_message_sent_by_message_type_values(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
UserCount = apps.get_model('analytics', 'UserCount')
StreamCount = apps.get_model('analytics', 'StreamCount')
RealmCount = apps.get_model('analytics', 'RealmCount')

View File

@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
from django.db import migrations
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
from django.db import migrations
def clear_analytics_tables(apps, schema_editor):
# type: (StateApps, DatabaseSchemaEditor) -> None
def clear_analytics_tables(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
UserCount = apps.get_model('analytics', 'UserCount')
StreamCount = apps.get_model('analytics', 'StreamCount')
RealmCount = apps.get_model('analytics', 'RealmCount')

View File

@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2018-01-29 08:14
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('analytics', '0011_clear_analytics_tables'),
]
operations = [
migrations.AlterField(
model_name='installationcount',
name='anomaly',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='analytics.Anomaly'),
),
migrations.AlterField(
model_name='realmcount',
name='anomaly',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='analytics.Anomaly'),
),
migrations.AlterField(
model_name='streamcount',
name='anomaly',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='analytics.Anomaly'),
),
migrations.AlterField(
model_name='usercount',
name='anomaly',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='analytics.Anomaly'),
),
]

View File

@@ -1,14 +1,12 @@
import datetime
from typing import Any, Dict, Optional, Text, Tuple, Union
from django.db import models
from zerver.models import Realm, UserProfile, Stream, Recipient
from zerver.lib.str_utils import ModelReprMixin
from zerver.lib.timestamp import floor_to_day
from zerver.models import Realm, Recipient, Stream, UserProfile
import datetime
from typing import Optional, Tuple, Union, Dict, Any, Text
class FillState(ModelReprMixin, models.Model):
class FillState(models.Model):
property = models.CharField(max_length=40, unique=True) # type: Text
end_time = models.DateTimeField() # type: datetime.datetime
@@ -19,19 +17,16 @@ class FillState(ModelReprMixin, models.Model):
last_modified = models.DateTimeField(auto_now=True) # type: datetime.datetime
def __unicode__(self):
# type: () -> Text
return u"<FillState: %s %s %s>" % (self.property, self.end_time, self.state)
def __str__(self) -> Text:
return "<FillState: %s %s %s>" % (self.property, self.end_time, self.state)
# The earliest/starting end_time in FillState
# We assume there is at least one realm
def installation_epoch():
# type: () -> datetime.datetime
def installation_epoch() -> datetime.datetime:
earliest_realm_creation = Realm.objects.aggregate(models.Min('date_created'))['date_created__min']
return floor_to_day(earliest_realm_creation)
def last_successful_fill(property):
# type: (str) -> Optional[datetime.datetime]
def last_successful_fill(property: str) -> Optional[datetime.datetime]:
fillstate = FillState.objects.filter(property=property).first()
if fillstate is None:
return None
@@ -40,14 +35,13 @@ def last_successful_fill(property):
return fillstate.end_time - datetime.timedelta(hours=1)
# would only ever make entries here by hand
class Anomaly(ModelReprMixin, models.Model):
class Anomaly(models.Model):
info = models.CharField(max_length=1000) # type: Text
def __unicode__(self):
# type: () -> Text
return u"<Anomaly: %s... %s>" % (self.info, self.id)
def __str__(self) -> Text:
return "<Anomaly: %s... %s>" % (self.info, self.id)
class BaseCount(ModelReprMixin, models.Model):
class BaseCount(models.Model):
# Note: When inheriting from BaseCount, you may want to rearrange
# the order of the columns in the migration to make sure they
# match how you'd like the table to be arranged.
@@ -55,55 +49,52 @@ class BaseCount(ModelReprMixin, models.Model):
subgroup = models.CharField(max_length=16, null=True) # type: Optional[Text]
end_time = models.DateTimeField() # type: datetime.datetime
value = models.BigIntegerField() # type: int
anomaly = models.ForeignKey(Anomaly, null=True) # type: Optional[Anomaly]
anomaly = models.ForeignKey(Anomaly, on_delete=models.SET_NULL, null=True) # type: Optional[Anomaly]
class Meta(object):
class Meta:
abstract = True
class InstallationCount(BaseCount):
class Meta(object):
class Meta:
unique_together = ("property", "subgroup", "end_time")
def __unicode__(self):
# type: () -> Text
return u"<InstallationCount: %s %s %s>" % (self.property, self.subgroup, self.value)
def __str__(self) -> Text:
return "<InstallationCount: %s %s %s>" % (self.property, self.subgroup, self.value)
class RealmCount(BaseCount):
realm = models.ForeignKey(Realm)
realm = models.ForeignKey(Realm, on_delete=models.CASCADE)
class Meta(object):
class Meta:
unique_together = ("realm", "property", "subgroup", "end_time")
index_together = ["property", "end_time"]
def __unicode__(self):
# type: () -> Text
return u"<RealmCount: %s %s %s %s>" % (self.realm, self.property, self.subgroup, self.value)
def __str__(self) -> Text:
return "<RealmCount: %s %s %s %s>" % (self.realm, self.property, self.subgroup, self.value)
class UserCount(BaseCount):
user = models.ForeignKey(UserProfile)
realm = models.ForeignKey(Realm)
user = models.ForeignKey(UserProfile, on_delete=models.CASCADE)
realm = models.ForeignKey(Realm, on_delete=models.CASCADE)
class Meta(object):
class Meta:
unique_together = ("user", "property", "subgroup", "end_time")
# This index dramatically improves the performance of
# aggregating from users to realms
index_together = ["property", "realm", "end_time"]
def __unicode__(self):
# type: () -> Text
return u"<UserCount: %s %s %s %s>" % (self.user, self.property, self.subgroup, self.value)
def __str__(self) -> Text:
return "<UserCount: %s %s %s %s>" % (self.user, self.property, self.subgroup, self.value)
class StreamCount(BaseCount):
stream = models.ForeignKey(Stream)
realm = models.ForeignKey(Realm)
stream = models.ForeignKey(Stream, on_delete=models.CASCADE)
realm = models.ForeignKey(Realm, on_delete=models.CASCADE)
class Meta(object):
class Meta:
unique_together = ("stream", "property", "subgroup", "end_time")
# This index dramatically improves the performance of
# aggregating from streams to realms
index_together = ["property", "realm", "end_time"]
def __unicode__(self):
# type: () -> Text
return u"<StreamCount: %s %s %s %s %s>" % (self.stream, self.property, self.subgroup, self.value, self.id)
def __str__(self) -> Text:
return "<StreamCount: %s %s %s %s %s>" % (
self.stream, self.property, self.subgroup, self.value, self.id)

View File

@@ -1,4 +1,8 @@
from datetime import datetime, timedelta
from typing import Any, Dict, List, Optional, Text, Tuple, Type, Union
import ujson
from django.apps import apps
from django.db import models
from django.db.models import Sum
@@ -6,23 +10,22 @@ from django.test import TestCase
from django.utils.timezone import now as timezone_now
from django.utils.timezone import utc as timezone_utc
from analytics.lib.counts import CountStat, COUNT_STATS, process_count_stat, \
do_fill_count_stat_at_hour, do_increment_logging_stat, DataCollector, \
sql_data_collector, LoggingCountStat, do_aggregate_to_summary_table, \
do_drop_all_analytics_tables, do_drop_single_stat, DependentCountStat
from analytics.models import BaseCount, InstallationCount, RealmCount, \
UserCount, StreamCount, FillState, Anomaly, installation_epoch, \
last_successful_fill
from zerver.lib.actions import do_create_user, do_deactivate_user, \
do_activate_user, do_reactivate_user, update_user_activity_interval
from zerver.lib.timestamp import floor_to_day, TimezoneNotUTCException
from zerver.models import Realm, UserProfile, Message, Stream, Recipient, \
Huddle, Client, UserActivityInterval, RealmAuditLog, get_client, get_user
from datetime import datetime, timedelta
import ujson
from typing import Any, Dict, List, Optional, Text, Tuple, Type, Union
from analytics.lib.counts import COUNT_STATS, CountStat, DataCollector, \
DependentCountStat, LoggingCountStat, do_aggregate_to_summary_table, \
do_drop_all_analytics_tables, do_drop_single_stat, \
do_fill_count_stat_at_hour, do_increment_logging_stat, \
process_count_stat, sql_data_collector
from analytics.models import Anomaly, BaseCount, \
FillState, InstallationCount, RealmCount, StreamCount, \
UserCount, installation_epoch, last_successful_fill
from zerver.lib.actions import do_activate_user, do_create_user, \
do_deactivate_user, do_reactivate_user, update_user_activity_interval, \
do_invite_users, do_revoke_user_invite, do_resend_user_invite_email, \
InvitationError
from zerver.lib.timestamp import TimezoneNotUTCException, floor_to_day
from zerver.models import Client, Huddle, Message, Realm, \
RealmAuditLog, Recipient, Stream, UserActivityInterval, \
UserProfile, get_client, get_user, PreregistrationUser
class AnalyticsTestCase(TestCase):
MINUTE = timedelta(seconds = 60)
@@ -31,8 +34,7 @@ class AnalyticsTestCase(TestCase):
TIME_ZERO = datetime(1988, 3, 14).replace(tzinfo=timezone_utc)
TIME_LAST_HOUR = TIME_ZERO - HOUR
def setUp(self):
# type: () -> None
def setUp(self) -> None:
self.default_realm = Realm.objects.create(
string_id='realmtest', name='Realm Test', date_created=self.TIME_ZERO - 2*self.DAY)
# used to generate unique names in self.create_*
@@ -41,8 +43,7 @@ class AnalyticsTestCase(TestCase):
self.current_property = None # type: Optional[str]
# Lightweight creation of users, streams, and messages
def create_user(self, **kwargs):
# type: (**Any) -> UserProfile
def create_user(self, **kwargs: Any) -> UserProfile:
self.name_counter += 1
defaults = {
'email': 'user%s@domain.tld' % (self.name_counter,),
@@ -57,8 +58,7 @@ class AnalyticsTestCase(TestCase):
kwargs[key] = kwargs.get(key, value)
return UserProfile.objects.create(**kwargs)
def create_stream_with_recipient(self, **kwargs):
# type: (**Any) -> Tuple[Stream, Recipient]
def create_stream_with_recipient(self, **kwargs: Any) -> Tuple[Stream, Recipient]:
self.name_counter += 1
defaults = {'name': 'stream name %s' % (self.name_counter,),
'realm': self.default_realm,
@@ -69,8 +69,7 @@ class AnalyticsTestCase(TestCase):
recipient = Recipient.objects.create(type_id=stream.id, type=Recipient.STREAM)
return stream, recipient
def create_huddle_with_recipient(self, **kwargs):
# type: (**Any) -> Tuple[Huddle, Recipient]
def create_huddle_with_recipient(self, **kwargs: Any) -> Tuple[Huddle, Recipient]:
self.name_counter += 1
defaults = {'huddle_hash': 'hash%s' % (self.name_counter,)}
for key, value in defaults.items():
@@ -79,8 +78,7 @@ class AnalyticsTestCase(TestCase):
recipient = Recipient.objects.create(type_id=huddle.id, type=Recipient.HUDDLE)
return huddle, recipient
def create_message(self, sender, recipient, **kwargs):
# type: (UserProfile, Recipient, **Any) -> Message
def create_message(self, sender: UserProfile, recipient: Recipient, **kwargs: Any) -> Message:
defaults = {
'sender': sender,
'recipient': recipient,
@@ -93,9 +91,9 @@ class AnalyticsTestCase(TestCase):
return Message.objects.create(**kwargs)
# kwargs should only ever be a UserProfile or Stream.
def assertCountEquals(self, table, value, property=None, subgroup=None,
end_time=TIME_ZERO, realm=None, **kwargs):
# type: (Type[BaseCount], int, Optional[Text], Optional[Text], datetime, Optional[Realm], **models.Model) -> None
def assertCountEquals(self, table: Type[BaseCount], value: int, property: Optional[Text]=None,
subgroup: Optional[Text]=None, end_time: datetime=TIME_ZERO,
realm: Optional[Realm]=None, **kwargs: models.Model) -> None:
if property is None:
property = self.current_property
queryset = table.objects.filter(property=property, end_time=end_time).filter(**kwargs)
@@ -107,8 +105,8 @@ class AnalyticsTestCase(TestCase):
queryset = queryset.filter(subgroup=subgroup)
self.assertEqual(queryset.values_list('value', flat=True)[0], value)
def assertTableState(self, table, arg_keys, arg_values):
# type: (Type[BaseCount], List[str], List[List[Union[int, str, bool, datetime, Realm, UserProfile, Stream]]]) -> None
def assertTableState(self, table: Type[BaseCount], arg_keys: List[str],
arg_values: List[List[object]]) -> None:
"""Assert that the state of a *Count table is what it should be.
Example usage:
@@ -153,20 +151,18 @@ class AnalyticsTestCase(TestCase):
self.assertEqual(table.objects.count(), len(arg_values))
class TestProcessCountStat(AnalyticsTestCase):
def make_dummy_count_stat(self, property):
# type: (str) -> CountStat
def make_dummy_count_stat(self, property: str) -> CountStat:
query = """INSERT INTO analytics_realmcount (realm_id, value, property, end_time)
VALUES (%s, 1, '%s', %%%%(time_end)s)""" % (self.default_realm.id, property)
return CountStat(property, sql_data_collector(RealmCount, query, None), CountStat.HOUR)
def assertFillStateEquals(self, stat, end_time, state=FillState.DONE):
# type: (CountStat, datetime, int) -> None
def assertFillStateEquals(self, stat: CountStat, end_time: datetime,
state: int=FillState.DONE) -> None:
fill_state = FillState.objects.filter(property=stat.property).first()
self.assertEqual(fill_state.end_time, end_time)
self.assertEqual(fill_state.state, state)
def test_process_stat(self):
# type: () -> None
def test_process_stat(self) -> None:
# process new stat
current_time = installation_epoch() + self.HOUR
stat = self.make_dummy_count_stat('test stat')
@@ -192,8 +188,7 @@ class TestProcessCountStat(AnalyticsTestCase):
self.assertFillStateEquals(stat, current_time)
self.assertEqual(InstallationCount.objects.filter(property=stat.property).count(), 2)
def test_bad_fill_to_time(self):
# type: () -> None
def test_bad_fill_to_time(self) -> None:
stat = self.make_dummy_count_stat('test stat')
with self.assertRaises(ValueError):
process_count_stat(stat, installation_epoch() + 65*self.MINUTE)
@@ -203,8 +198,7 @@ class TestProcessCountStat(AnalyticsTestCase):
# This tests the LoggingCountStat branch of the code in do_delete_counts_at_hour.
# It is important that do_delete_counts_at_hour not delete any of the collected
# logging data!
def test_process_logging_stat(self):
# type: () -> None
def test_process_logging_stat(self) -> None:
end_time = self.TIME_ZERO
user_stat = LoggingCountStat('user stat', UserCount, CountStat.DAY)
@@ -226,9 +220,13 @@ class TestProcessCountStat(AnalyticsTestCase):
self.assertTableState(UserCount, ['property', 'value'], [[user_stat.property, 5]])
self.assertTableState(StreamCount, ['property', 'value'], [[stream_stat.property, 5]])
self.assertTableState(RealmCount, ['property', 'value'],
[[user_stat.property, 5], [stream_stat.property, 5], [realm_stat.property, 5]])
[[user_stat.property, 5],
[stream_stat.property, 5],
[realm_stat.property, 5]])
self.assertTableState(InstallationCount, ['property', 'value'],
[[user_stat.property, 5], [stream_stat.property, 5], [realm_stat.property, 5]])
[[user_stat.property, 5],
[stream_stat.property, 5],
[realm_stat.property, 5]])
# Change the logged data and mark FillState as dirty
UserCount.objects.update(value=6)
@@ -242,17 +240,21 @@ class TestProcessCountStat(AnalyticsTestCase):
self.assertTableState(UserCount, ['property', 'value'], [[user_stat.property, 6]])
self.assertTableState(StreamCount, ['property', 'value'], [[stream_stat.property, 6]])
self.assertTableState(RealmCount, ['property', 'value'],
[[user_stat.property, 6], [stream_stat.property, 6], [realm_stat.property, 6]])
[[user_stat.property, 6],
[stream_stat.property, 6],
[realm_stat.property, 6]])
self.assertTableState(InstallationCount, ['property', 'value'],
[[user_stat.property, 6], [stream_stat.property, 6], [realm_stat.property, 6]])
[[user_stat.property, 6],
[stream_stat.property, 6],
[realm_stat.property, 6]])
def test_process_dependent_stat(self):
# type: () -> None
def test_process_dependent_stat(self) -> None:
stat1 = self.make_dummy_count_stat('stat1')
stat2 = self.make_dummy_count_stat('stat2')
query = """INSERT INTO analytics_realmcount (realm_id, value, property, end_time)
VALUES (%s, 1, '%s', %%%%(time_end)s)""" % (self.default_realm.id, 'stat3')
stat3 = DependentCountStat('stat3', sql_data_collector(RealmCount, query, None), CountStat.HOUR,
stat3 = DependentCountStat('stat3', sql_data_collector(RealmCount, query, None),
CountStat.HOUR,
dependencies=['stat1', 'stat2'])
hour = [installation_epoch() + i*self.HOUR for i in range(5)]
@@ -285,7 +287,8 @@ class TestProcessCountStat(AnalyticsTestCase):
# test daily dependent stat with hourly dependencies
query = """INSERT INTO analytics_realmcount (realm_id, value, property, end_time)
VALUES (%s, 1, '%s', %%%%(time_end)s)""" % (self.default_realm.id, 'stat4')
stat4 = DependentCountStat('stat4', sql_data_collector(RealmCount, query, None), CountStat.DAY,
stat4 = DependentCountStat('stat4', sql_data_collector(RealmCount, query, None),
CountStat.DAY,
dependencies=['stat1', 'stat2'])
hour24 = installation_epoch() + 24*self.HOUR
hour25 = installation_epoch() + 25*self.HOUR
@@ -296,9 +299,8 @@ class TestProcessCountStat(AnalyticsTestCase):
self.assertFillStateEquals(stat4, hour24)
class TestCountStats(AnalyticsTestCase):
def setUp(self):
# type: () -> None
super(TestCountStats, self).setUp()
def setUp(self) -> None:
super().setUp()
# This tests two things for each of the queries/CountStats: Handling
# more than 1 realm, and the time bounds (time_start and time_end in
# the queries).
@@ -326,8 +328,7 @@ class TestCountStats(AnalyticsTestCase):
# This huddle should not show up anywhere
self.create_huddle_with_recipient()
def test_active_users_by_is_bot(self):
# type: () -> None
def test_active_users_by_is_bot(self) -> None:
stat = COUNT_STATS['active_users:is_bot:day']
self.current_property = stat.property
@@ -345,19 +346,21 @@ class TestCountStats(AnalyticsTestCase):
[[2, 'true'], [1, 'false'],
[3, 'false', self.second_realm],
[1, 'false', self.no_message_realm]])
self.assertTableState(InstallationCount, ['value', 'subgroup'], [[2, 'true'], [5, 'false']])
self.assertTableState(InstallationCount,
['value', 'subgroup'],
[[2, 'true'], [5, 'false']])
self.assertTableState(UserCount, [], [])
self.assertTableState(StreamCount, [], [])
def test_messages_sent_by_is_bot(self):
# type: () -> None
def test_messages_sent_by_is_bot(self) -> None:
stat = COUNT_STATS['messages_sent:is_bot:hour']
self.current_property = stat.property
bot = self.create_user(is_bot=True)
human1 = self.create_user()
human2 = self.create_user()
recipient_human1 = Recipient.objects.create(type_id=human1.id, type=Recipient.PERSONAL)
recipient_human1 = Recipient.objects.create(type_id=human1.id,
type=Recipient.PERSONAL)
recipient_stream = self.create_stream_with_recipient()[1]
recipient_huddle = self.create_huddle_with_recipient()[1]
@@ -378,8 +381,7 @@ class TestCountStats(AnalyticsTestCase):
self.assertTableState(InstallationCount, ['value', 'subgroup'], [[3, 'false'], [3, 'true']])
self.assertTableState(StreamCount, [], [])
def test_messages_sent_by_message_type(self):
# type: () -> None
def test_messages_sent_by_message_type(self) -> None:
stat = COUNT_STATS['messages_sent:message_type:day']
self.current_property = stat.property
@@ -441,8 +443,7 @@ class TestCountStats(AnalyticsTestCase):
[2, 'huddle_message']])
self.assertTableState(StreamCount, [], [])
def test_messages_sent_to_recipients_with_same_id(self):
# type: () -> None
def test_messages_sent_to_recipients_with_same_id(self) -> None:
stat = COUNT_STATS['messages_sent:message_type:day']
self.current_property = stat.property
@@ -461,8 +462,7 @@ class TestCountStats(AnalyticsTestCase):
self.assertCountEquals(UserCount, 1, subgroup='huddle_message')
self.assertCountEquals(UserCount, 1, subgroup='public_stream')
def test_messages_sent_by_client(self):
# type: () -> None
def test_messages_sent_by_client(self) -> None:
stat = COUNT_STATS['messages_sent:client:day']
self.current_property = stat.property
@@ -497,8 +497,7 @@ class TestCountStats(AnalyticsTestCase):
[[4, website_client_id], [3, client2_id]])
self.assertTableState(StreamCount, [], [])
def test_messages_sent_to_stream_by_is_bot(self):
# type: () -> None
def test_messages_sent_to_stream_by_is_bot(self) -> None:
stat = COUNT_STATS['messages_in_stream:is_bot:day']
self.current_property = stat.property
@@ -535,14 +534,13 @@ class TestCountStats(AnalyticsTestCase):
self.assertTableState(InstallationCount, ['value', 'subgroup'], [[5, 'false'], [2, 'true']])
self.assertTableState(UserCount, [], [])
def create_interval(self, user, start_offset, end_offset):
# type: (UserProfile, timedelta, timedelta) -> None
def create_interval(self, user: UserProfile, start_offset: timedelta,
end_offset: timedelta) -> None:
UserActivityInterval.objects.create(
user_profile=user, start=self.TIME_ZERO-start_offset,
end=self.TIME_ZERO-end_offset)
def test_15day_actives(self):
# type: () -> None
def test_15day_actives(self) -> None:
stat = COUNT_STATS['15day_actives::day']
self.current_property = stat.property
@@ -585,8 +583,7 @@ class TestCountStats(AnalyticsTestCase):
self.assertTableState(InstallationCount, ['value'], [[6]])
self.assertTableState(StreamCount, [], [])
def test_minutes_active(self):
# type: () -> None
def test_minutes_active(self) -> None:
stat = COUNT_STATS['minutes_active::day']
self.current_property = stat.property
@@ -634,16 +631,14 @@ class TestDoAggregateToSummaryTable(AnalyticsTestCase):
# feature important for keeping the size of the analytics tables small,
# which is that if there is no relevant data in the table being
# aggregated, the aggregation table doesn't get a row with value 0.
def test_no_aggregated_zeros(self):
# type: () -> None
def test_no_aggregated_zeros(self) -> None:
stat = LoggingCountStat('test stat', UserCount, CountStat.HOUR)
do_aggregate_to_summary_table(stat, self.TIME_ZERO)
self.assertFalse(RealmCount.objects.exists())
self.assertFalse(InstallationCount.objects.exists())
class TestDoIncrementLoggingStat(AnalyticsTestCase):
def test_table_and_id_args(self):
# type: () -> None
def test_table_and_id_args(self) -> None:
# For realms, streams, and users, tests that the new rows are going to
# the appropriate *Count table, and that using a different zerver_object
# results in a new row being created
@@ -668,8 +663,7 @@ class TestDoIncrementLoggingStat(AnalyticsTestCase):
do_increment_logging_stat(stream2, stat, None, self.TIME_ZERO)
self.assertTableState(StreamCount, ['stream'], [[stream1], [stream2]])
def test_frequency(self):
# type: () -> None
def test_frequency(self) -> None:
times = [self.TIME_ZERO - self.MINUTE*i for i in [0, 1, 61, 24*60+1]]
stat = LoggingCountStat('day test', RealmCount, CountStat.DAY)
@@ -686,8 +680,7 @@ class TestDoIncrementLoggingStat(AnalyticsTestCase):
[1, 'hour test', self.TIME_LAST_HOUR],
[1, 'hour test', self.TIME_ZERO - self.DAY]])
def test_get_or_create(self):
# type: () -> None
def test_get_or_create(self) -> None:
stat = LoggingCountStat('test', RealmCount, CountStat.HOUR)
# All these should trigger the create part of get_or_create.
# property is tested in test_frequency, and id_args are tested in test_id_args,
@@ -705,8 +698,7 @@ class TestDoIncrementLoggingStat(AnalyticsTestCase):
[[2, 'subgroup1', self.TIME_ZERO], [1, 'subgroup2', self.TIME_ZERO],
[1, 'subgroup1', self.TIME_LAST_HOUR]])
def test_increment(self):
# type: () -> None
def test_increment(self) -> None:
stat = LoggingCountStat('test', RealmCount, CountStat.DAY)
self.current_property = 'test'
do_increment_logging_stat(self.default_realm, stat, None, self.TIME_ZERO, increment=-1)
@@ -717,8 +709,7 @@ class TestDoIncrementLoggingStat(AnalyticsTestCase):
self.assertTableState(RealmCount, ['value'], [[3]])
class TestLoggingCountStats(AnalyticsTestCase):
def test_aggregation(self):
# type: () -> None
def test_aggregation(self) -> None:
stat = LoggingCountStat('realm test', RealmCount, CountStat.DAY)
do_increment_logging_stat(self.default_realm, stat, None, self.TIME_ZERO)
process_count_stat(stat, self.TIME_ZERO)
@@ -740,8 +731,7 @@ class TestLoggingCountStats(AnalyticsTestCase):
self.assertTableState(UserCount, ['property', 'value'], [['user test', 1]])
self.assertTableState(StreamCount, ['property', 'value'], [['stream test', 1]])
def test_active_users_log_by_is_bot(self):
# type: () -> None
def test_active_users_log_by_is_bot(self) -> None:
property = 'active_users_log:is_bot:day'
user = do_create_user('email', 'password', self.default_realm, 'full_name', 'short_name')
self.assertEqual(1, RealmCount.objects.filter(property=property, subgroup=False)
@@ -759,9 +749,47 @@ class TestLoggingCountStats(AnalyticsTestCase):
self.assertEqual(1, RealmCount.objects.filter(property=property, subgroup=False)
.aggregate(Sum('value'))['value__sum'])
def test_invites_sent(self) -> None:
property = 'invites_sent::day'
def assertInviteCountEquals(count: int) -> None:
self.assertEqual(count, RealmCount.objects.filter(property=property, subgroup=None)
.aggregate(Sum('value'))['value__sum'])
user = self.create_user(email='first@domain.tld')
stream, _ = self.create_stream_with_recipient()
do_invite_users(user, ['user1@domain.tld', 'user2@domain.tld'], [stream])
assertInviteCountEquals(2)
# We currently send emails when re-inviting users that haven't
# turned into accounts, so count them towards the total
do_invite_users(user, ['user1@domain.tld', 'user2@domain.tld'], [stream])
assertInviteCountEquals(4)
# Test mix of good and malformed invite emails
try:
do_invite_users(user, ['user3@domain.tld', 'malformed'], [stream])
except InvitationError:
pass
assertInviteCountEquals(4)
# Test inviting existing users
try:
do_invite_users(user, ['first@domain.tld', 'user4@domain.tld'], [stream])
except InvitationError:
pass
assertInviteCountEquals(5)
# Revoking invite should not give you credit
do_revoke_user_invite(PreregistrationUser.objects.filter(realm=user.realm).first())
assertInviteCountEquals(5)
# Resending invite should cost you
do_resend_user_invite_email(PreregistrationUser.objects.first())
assertInviteCountEquals(6)
class TestDeleteStats(AnalyticsTestCase):
def test_do_drop_all_analytics_tables(self):
# type: () -> None
def test_do_drop_all_analytics_tables(self) -> None:
user = self.create_user()
stream = self.create_stream_with_recipient()[0]
count_args = {'property': 'test', 'end_time': self.TIME_ZERO, 'value': 10}
@@ -781,8 +809,7 @@ class TestDeleteStats(AnalyticsTestCase):
for table in list(analytics.models.values()):
self.assertFalse(table.objects.exists())
def test_do_drop_single_stat(self):
# type: () -> None
def test_do_drop_single_stat(self) -> None:
user = self.create_user()
stream = self.create_stream_with_recipient()[0]
count_args_to_delete = {'property': 'to_delete', 'end_time': self.TIME_ZERO, 'value': 10}
@@ -810,15 +837,14 @@ class TestDeleteStats(AnalyticsTestCase):
self.assertTrue(table.objects.filter(property='to_save').exists())
class TestActiveUsersAudit(AnalyticsTestCase):
def setUp(self):
# type: () -> None
super(TestActiveUsersAudit, self).setUp()
def setUp(self) -> None:
super().setUp()
self.user = self.create_user()
self.stat = COUNT_STATS['active_users_audit:is_bot:day']
self.current_property = self.stat.property
def add_event(self, event_type, days_offset, user=None):
# type: (str, float, Optional[UserProfile]) -> None
def add_event(self, event_type: str, days_offset: float,
user: Optional[UserProfile]=None) -> None:
hours_offset = int(24*days_offset)
if user is None:
user = self.user
@@ -826,29 +852,25 @@ class TestActiveUsersAudit(AnalyticsTestCase):
realm=user.realm, modified_user=user, event_type=event_type,
event_time=self.TIME_ZERO - hours_offset*self.HOUR)
def test_user_deactivated_in_future(self):
# type: () -> None
def test_user_deactivated_in_future(self) -> None:
self.add_event('user_created', 1)
self.add_event('user_deactivated', 0)
do_fill_count_stat_at_hour(self.stat, self.TIME_ZERO)
self.assertTableState(UserCount, ['subgroup'], [['false']])
def test_user_reactivated_in_future(self):
# type: () -> None
def test_user_reactivated_in_future(self) -> None:
self.add_event('user_deactivated', 1)
self.add_event('user_reactivated', 0)
do_fill_count_stat_at_hour(self.stat, self.TIME_ZERO)
self.assertTableState(UserCount, [], [])
def test_user_active_then_deactivated_same_day(self):
# type: () -> None
def test_user_active_then_deactivated_same_day(self) -> None:
self.add_event('user_created', 1)
self.add_event('user_deactivated', .5)
do_fill_count_stat_at_hour(self.stat, self.TIME_ZERO)
self.assertTableState(UserCount, [], [])
def test_user_unactive_then_activated_same_day(self):
# type: () -> None
def test_user_unactive_then_activated_same_day(self) -> None:
self.add_event('user_deactivated', 1)
self.add_event('user_reactivated', .5)
do_fill_count_stat_at_hour(self.stat, self.TIME_ZERO)
@@ -856,23 +878,20 @@ class TestActiveUsersAudit(AnalyticsTestCase):
# Arguably these next two tests are duplicates of the _in_future tests, but are
# a guard against future refactorings where they may no longer be duplicates
def test_user_active_then_deactivated_with_day_gap(self):
# type: () -> None
def test_user_active_then_deactivated_with_day_gap(self) -> None:
self.add_event('user_created', 2)
self.add_event('user_deactivated', 1)
process_count_stat(self.stat, self.TIME_ZERO)
self.assertTableState(UserCount, ['subgroup', 'end_time'],
[['false', self.TIME_ZERO - self.DAY]])
def test_user_deactivated_then_reactivated_with_day_gap(self):
# type: () -> None
def test_user_deactivated_then_reactivated_with_day_gap(self) -> None:
self.add_event('user_deactivated', 2)
self.add_event('user_reactivated', 1)
process_count_stat(self.stat, self.TIME_ZERO)
self.assertTableState(UserCount, ['subgroup'], [['false']])
def test_event_types(self):
# type: () -> None
def test_event_types(self) -> None:
self.add_event('user_created', 4)
self.add_event('user_deactivated', 3)
self.add_event('user_activated', 2)
@@ -884,8 +903,7 @@ class TestActiveUsersAudit(AnalyticsTestCase):
# Also tests that aggregation to RealmCount and InstallationCount is
# being done, and that we're storing the user correctly in UserCount
def test_multiple_users_realms_and_bots(self):
# type: () -> None
def test_multiple_users_realms_and_bots(self) -> None:
user1 = self.create_user()
user2 = self.create_user()
second_realm = Realm.objects.create(string_id='moo', name='moo')
@@ -909,8 +927,7 @@ class TestActiveUsersAudit(AnalyticsTestCase):
# do_fill_count_stat_at_hour. E.g. if one changes self.stat.frequency to
# CountStat.HOUR from CountStat.DAY, this will fail, while many of the
# tests above will not.
def test_update_from_two_days_ago(self):
# type: () -> None
def test_update_from_two_days_ago(self) -> None:
self.add_event('user_created', 2)
process_count_stat(self.stat, self.TIME_ZERO)
self.assertTableState(UserCount, ['subgroup', 'end_time'],
@@ -919,31 +936,27 @@ class TestActiveUsersAudit(AnalyticsTestCase):
# User with no relevant activity could happen e.g. for a system bot that
# doesn't go through do_create_user. Mainly just want to make sure that
# that situation doesn't throw an error.
def test_empty_realm_or_user_with_no_relevant_activity(self):
# type: () -> None
def test_empty_realm_or_user_with_no_relevant_activity(self) -> None:
self.add_event('unrelated', 1)
self.create_user() # also test a user with no RealmAuditLog entries
Realm.objects.create(string_id='moo', name='moo')
do_fill_count_stat_at_hour(self.stat, self.TIME_ZERO)
self.assertTableState(UserCount, [], [])
def test_max_audit_entry_is_unrelated(self):
# type: () -> None
def test_max_audit_entry_is_unrelated(self) -> None:
self.add_event('user_created', 1)
self.add_event('unrelated', .5)
do_fill_count_stat_at_hour(self.stat, self.TIME_ZERO)
self.assertTableState(UserCount, ['subgroup'], [['false']])
# Simultaneous related audit entries should not be allowed, and so not testing for that.
def test_simultaneous_unrelated_audit_entry(self):
# type: () -> None
def test_simultaneous_unrelated_audit_entry(self) -> None:
self.add_event('user_created', 1)
self.add_event('unrelated', 1)
do_fill_count_stat_at_hour(self.stat, self.TIME_ZERO)
self.assertTableState(UserCount, ['subgroup'], [['false']])
def test_simultaneous_max_audit_entries_of_different_users(self):
# type: () -> None
def test_simultaneous_max_audit_entries_of_different_users(self) -> None:
user1 = self.create_user()
user2 = self.create_user()
user3 = self.create_user()
@@ -955,8 +968,7 @@ class TestActiveUsersAudit(AnalyticsTestCase):
self.assertTableState(UserCount, ['user', 'subgroup'],
[[user1, 'false'], [user2, 'false']])
def test_end_to_end_with_actions_dot_py(self):
# type: () -> None
def test_end_to_end_with_actions_dot_py(self) -> None:
user1 = do_create_user('email1', 'password', self.default_realm, 'full_name', 'short_name')
user2 = do_create_user('email2', 'password', self.default_realm, 'full_name', 'short_name')
user3 = do_create_user('email3', 'password', self.default_realm, 'full_name', 'short_name')
@@ -973,30 +985,26 @@ class TestActiveUsersAudit(AnalyticsTestCase):
self.assertFalse(UserCount.objects.filter(user=user2).exists())
class TestRealmActiveHumans(AnalyticsTestCase):
def setUp(self):
# type: () -> None
super(TestRealmActiveHumans, self).setUp()
def setUp(self) -> None:
super().setUp()
self.stat = COUNT_STATS['realm_active_humans::day']
self.current_property = self.stat.property
def mark_audit_active(self, user, end_time=None):
# type: (UserProfile, Optional[datetime]) -> None
def mark_audit_active(self, user: UserProfile, end_time: Optional[datetime]=None) -> None:
if end_time is None:
end_time = self.TIME_ZERO
UserCount.objects.create(
user=user, realm=user.realm, property='active_users_audit:is_bot:day',
subgroup=ujson.dumps(user.is_bot), end_time=end_time, value=1)
def mark_15day_active(self, user, end_time=None):
# type: (UserProfile, Optional[datetime]) -> None
def mark_15day_active(self, user: UserProfile, end_time: Optional[datetime]=None) -> None:
if end_time is None:
end_time = self.TIME_ZERO
UserCount.objects.create(
user=user, realm=user.realm, property='15day_actives::day',
end_time=end_time, value=1)
def test_basic_boolean_logic(self):
# type: () -> None
def test_basic_boolean_logic(self) -> None:
user = self.create_user()
self.mark_audit_active(user, end_time=self.TIME_ZERO - self.DAY)
self.mark_15day_active(user, end_time=self.TIME_ZERO)
@@ -1007,16 +1015,14 @@ class TestRealmActiveHumans(AnalyticsTestCase):
do_fill_count_stat_at_hour(self.stat, self.TIME_ZERO + i*self.DAY)
self.assertTableState(RealmCount, ['value', 'end_time'], [[1, self.TIME_ZERO + self.DAY]])
def test_bots_not_counted(self):
# type: () -> None
def test_bots_not_counted(self) -> None:
bot = self.create_user(is_bot=True)
self.mark_audit_active(bot)
self.mark_15day_active(bot)
do_fill_count_stat_at_hour(self.stat, self.TIME_ZERO)
self.assertTableState(RealmCount, [], [])
def test_multiple_users_realms_and_times(self):
# type: () -> None
def test_multiple_users_realms_and_times(self) -> None:
user1 = self.create_user()
user2 = self.create_user()
second_realm = Realm.objects.create(string_id='second', name='second')
@@ -1056,8 +1062,7 @@ class TestRealmActiveHumans(AnalyticsTestCase):
[1, self.default_realm, self.TIME_ZERO - self.DAY],
[2, second_realm, self.TIME_ZERO - self.DAY]])
def test_end_to_end(self):
# type: () -> None
def test_end_to_end(self) -> None:
user1 = do_create_user('email1', 'password', self.default_realm, 'full_name', 'short_name')
user2 = do_create_user('email2', 'password', self.default_realm, 'full_name', 'short_name')
do_create_user('email3', 'password', self.default_realm, 'full_name', 'short_name')

View File

@@ -1,12 +1,10 @@
from zerver.lib.test_classes import ZulipTestCase
from analytics.lib.counts import CountStat
from analytics.lib.fixtures import generate_time_series_data
from zerver.lib.test_classes import ZulipTestCase
# A very light test suite; the code being tested is not run in production.
class TestFixtures(ZulipTestCase):
def test_deterministic_settings(self):
# type: () -> None
def test_deterministic_settings(self) -> None:
# test basic business_hour / non_business_hour calculation
# test we get an array of the right length with frequency=CountStat.DAY
data = generate_time_series_data(

View File

@@ -1,25 +1,22 @@
from django.utils.timezone import get_fixed_timezone, utc
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.timestamp import ceiling_to_hour, ceiling_to_day, \
datetime_to_timestamp
from zerver.models import Realm, UserProfile, Client, get_realm
from analytics.lib.counts import CountStat, COUNT_STATS
from analytics.lib.time_utils import time_range
from analytics.models import RealmCount, UserCount, BaseCount, \
FillState, last_successful_fill
from analytics.views import stats, get_chart_data, sort_by_totals, \
sort_client_labels, rewrite_client_arrays
from datetime import datetime, timedelta
import mock
import ujson
from typing import Dict, List, Optional
from typing import List, Dict, Optional
import mock
from django.utils.timezone import utc
from analytics.lib.counts import COUNT_STATS, CountStat
from analytics.lib.time_utils import time_range
from analytics.models import FillState, \
RealmCount, UserCount, last_successful_fill
from analytics.views import get_chart_data, rewrite_client_arrays, \
sort_by_totals, sort_client_labels, stats
from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.timestamp import ceiling_to_day, \
ceiling_to_hour, datetime_to_timestamp
from zerver.models import Client, get_realm
class TestStatsEndpoint(ZulipTestCase):
def test_stats(self):
# type: () -> None
def test_stats(self) -> None:
self.user = self.example_user('hamlet')
self.login(self.user.email)
result = self.client_get('/stats')
@@ -28,8 +25,7 @@ class TestStatsEndpoint(ZulipTestCase):
self.assert_in_response("Zulip analytics for", result)
class TestGetChartData(ZulipTestCase):
def setUp(self):
# type: () -> None
def setUp(self) -> None:
self.realm = get_realm('zulip')
self.user = self.example_user('hamlet')
self.login(self.user.email)
@@ -38,12 +34,11 @@ class TestGetChartData(ZulipTestCase):
self.end_times_day = [ceiling_to_day(self.realm.date_created) + timedelta(days=i)
for i in range(4)]
def data(self, i):
# type: (int) -> List[int]
def data(self, i: int) -> List[int]:
return [0, 0, i, 0]
def insert_data(self, stat, realm_subgroups, user_subgroups):
# type: (CountStat, List[Optional[str]], List[str]) -> None
def insert_data(self, stat: CountStat, realm_subgroups: List[Optional[str]],
user_subgroups: List[str]) -> None:
if stat.frequency == CountStat.HOUR:
insert_time = self.end_times_hour[2]
fill_time = self.end_times_hour[-1]
@@ -61,8 +56,7 @@ class TestGetChartData(ZulipTestCase):
for i, subgroup in enumerate(user_subgroups)])
FillState.objects.create(property=stat.property, end_time=fill_time, state=FillState.DONE)
def test_number_of_humans(self):
# type: () -> None
def test_number_of_humans(self) -> None:
stat = COUNT_STATS['realm_active_humans::day']
self.insert_data(stat, [None], [])
result = self.client_get('/json/analytics/chart_data',
@@ -78,8 +72,7 @@ class TestGetChartData(ZulipTestCase):
'result': 'success',
})
def test_messages_sent_over_time(self):
# type: () -> None
def test_messages_sent_over_time(self) -> None:
stat = COUNT_STATS['messages_sent:is_bot:hour']
self.insert_data(stat, ['true', 'false'], ['false'])
result = self.client_get('/json/analytics/chart_data',
@@ -96,8 +89,7 @@ class TestGetChartData(ZulipTestCase):
'result': 'success',
})
def test_messages_sent_by_message_type(self):
# type: () -> None
def test_messages_sent_by_message_type(self) -> None:
stat = COUNT_STATS['messages_sent:message_type:day']
self.insert_data(stat, ['public_stream', 'private_message'],
['public_stream', 'private_stream'])
@@ -117,8 +109,7 @@ class TestGetChartData(ZulipTestCase):
'result': 'success',
})
def test_messages_sent_by_client(self):
# type: () -> None
def test_messages_sent_by_client(self) -> None:
stat = COUNT_STATS['messages_sent:client:day']
client1 = Client.objects.create(name='client 1')
client2 = Client.objects.create(name='client 2')
@@ -141,10 +132,10 @@ class TestGetChartData(ZulipTestCase):
'result': 'success',
})
def test_include_empty_subgroups(self):
# type: () -> None
def test_include_empty_subgroups(self) -> None:
FillState.objects.create(
property='realm_active_humans::day', end_time=self.end_times_day[0], state=FillState.DONE)
property='realm_active_humans::day', end_time=self.end_times_day[0],
state=FillState.DONE)
result = self.client_get('/json/analytics/chart_data',
{'chart_name': 'number_of_humans'})
self.assert_json_success(result)
@@ -153,7 +144,8 @@ class TestGetChartData(ZulipTestCase):
self.assertFalse('user' in data)
FillState.objects.create(
property='messages_sent:is_bot:hour', end_time=self.end_times_hour[0], state=FillState.DONE)
property='messages_sent:is_bot:hour', end_time=self.end_times_hour[0],
state=FillState.DONE)
result = self.client_get('/json/analytics/chart_data',
{'chart_name': 'messages_sent_over_time'})
self.assert_json_success(result)
@@ -162,18 +154,22 @@ class TestGetChartData(ZulipTestCase):
self.assertEqual(data['user'], {'human': [0], 'bot': [0]})
FillState.objects.create(
property='messages_sent:message_type:day', end_time=self.end_times_day[0], state=FillState.DONE)
property='messages_sent:message_type:day', end_time=self.end_times_day[0],
state=FillState.DONE)
result = self.client_get('/json/analytics/chart_data',
{'chart_name': 'messages_sent_by_message_type'})
self.assert_json_success(result)
data = result.json()
self.assertEqual(data['realm'], {
'Public streams': [0], 'Private streams': [0], 'Private messages': [0], 'Group private messages': [0]})
'Public streams': [0], 'Private streams': [0],
'Private messages': [0], 'Group private messages': [0]})
self.assertEqual(data['user'], {
'Public streams': [0], 'Private streams': [0], 'Private messages': [0], 'Group private messages': [0]})
'Public streams': [0], 'Private streams': [0],
'Private messages': [0], 'Group private messages': [0]})
FillState.objects.create(
property='messages_sent:client:day', end_time=self.end_times_day[0], state=FillState.DONE)
property='messages_sent:client:day', end_time=self.end_times_day[0],
state=FillState.DONE)
result = self.client_get('/json/analytics/chart_data',
{'chart_name': 'messages_sent_by_client'})
self.assert_json_success(result)
@@ -181,8 +177,7 @@ class TestGetChartData(ZulipTestCase):
self.assertEqual(data['realm'], {})
self.assertEqual(data['user'], {})
def test_start_and_end(self):
# type: () -> None
def test_start_and_end(self) -> None:
stat = COUNT_STATS['realm_active_humans::day']
self.insert_data(stat, [None], [])
end_time_timestamps = [datetime_to_timestamp(dt) for dt in self.end_times_day]
@@ -204,8 +199,7 @@ class TestGetChartData(ZulipTestCase):
'end': end_time_timestamps[1]})
self.assert_json_error_contains(result, 'Start time is later than')
def test_min_length(self):
# type: () -> None
def test_min_length(self) -> None:
stat = COUNT_STATS['realm_active_humans::day']
self.insert_data(stat, [None], [])
# test min_length is too short to change anything
@@ -226,14 +220,12 @@ class TestGetChartData(ZulipTestCase):
self.assertEqual(data['end_times'], [datetime_to_timestamp(dt) for dt in end_times])
self.assertEqual(data['realm'], {'human': [0]+self.data(100)})
def test_non_existent_chart(self):
# type: () -> None
def test_non_existent_chart(self) -> None:
result = self.client_get('/json/analytics/chart_data',
{'chart_name': 'does_not_exist'})
self.assert_json_error_contains(result, 'Unknown chart name')
def test_analytics_not_running(self):
# type: () -> None
def test_analytics_not_running(self) -> None:
# try to get data for a valid chart, but before we've put anything in the database
# (e.g. before update_analytics_counts has been run)
with mock.patch('logging.warning'):
@@ -244,8 +236,7 @@ class TestGetChartData(ZulipTestCase):
class TestGetChartDataHelpers(ZulipTestCase):
# last_successful_fill is in analytics/models.py, but get_chart_data is
# the only function that uses it at the moment
def test_last_successful_fill(self):
# type: () -> None
def test_last_successful_fill(self) -> None:
self.assertIsNone(last_successful_fill('non-existant'))
a_time = datetime(2016, 3, 14, 19).replace(tzinfo=utc)
one_hour_before = datetime(2016, 3, 14, 18).replace(tzinfo=utc)
@@ -256,21 +247,18 @@ class TestGetChartDataHelpers(ZulipTestCase):
fillstate.save()
self.assertEqual(last_successful_fill('property'), one_hour_before)
def test_sort_by_totals(self):
# type: () -> None
def test_sort_by_totals(self) -> None:
empty = [] # type: List[int]
value_arrays = {'c': [0, 1], 'a': [9], 'b': [1, 1, 1], 'd': empty}
self.assertEqual(sort_by_totals(value_arrays), ['a', 'b', 'c', 'd'])
def test_sort_client_labels(self):
# type: () -> None
def test_sort_client_labels(self) -> None:
data = {'realm': {'a': [16], 'c': [15], 'b': [14], 'e': [13], 'd': [12], 'h': [11]},
'user': {'a': [6], 'b': [5], 'd': [4], 'e': [3], 'f': [2], 'g': [1]}}
self.assertEqual(sort_client_labels(data), ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'])
class TestTimeRange(ZulipTestCase):
def test_time_range(self):
# type: () -> None
def test_time_range(self) -> None:
HOUR = timedelta(hours=1)
DAY = timedelta(days=1)
@@ -296,8 +284,7 @@ class TestTimeRange(ZulipTestCase):
[floor_day-2*DAY, floor_day-DAY, floor_day, floor_day+DAY])
class TestMapArrays(ZulipTestCase):
def test_map_arrays(self):
# type: () -> None
def test_map_arrays(self) -> None:
a = {'desktop app 1.0': [1, 2, 3],
'desktop app 2.0': [10, 12, 13],
'desktop app 3.0': [21, 22, 23],

View File

@@ -1,7 +1,7 @@
from django.conf.urls import url, include
from zerver.lib.rest import rest_dispatch
from django.conf.urls import include, url
import analytics.views
from zerver.lib.rest import rest_dispatch
i18n_urlpatterns = [
# Server admin (user_profile.is_staff) visible stats pages

View File

@@ -1,56 +1,52 @@
from django.conf import settings
from django.core import urlresolvers
from django.db import connection
from django.db.models import Sum
from django.db.models.query import QuerySet
from django.http import HttpResponseNotFound, HttpRequest, HttpResponse
from django.template import RequestContext, loader
from django.utils.timezone import now as timezone_now
from django.utils.translation import ugettext as _
from django.shortcuts import render
from jinja2 import Markup as mark_safe
from analytics.lib.counts import CountStat, process_count_stat, COUNT_STATS
from analytics.lib.time_utils import time_range
from analytics.models import BaseCount, InstallationCount, RealmCount, \
UserCount, StreamCount, last_successful_fill
from zerver.decorator import has_request_variables, REQ, require_server_admin, \
zulip_login_required, to_non_negative_int, to_utc_datetime
from zerver.lib.request import JsonableError
from zerver.lib.response import json_success
from zerver.lib.timestamp import ceiling_to_hour, ceiling_to_day, \
timestamp_to_datetime, convert_to_UTC
from zerver.models import Realm, UserProfile, UserActivity, \
UserActivityInterval, Client
from collections import defaultdict
from datetime import datetime, timedelta
import itertools
import json
import logging
import pytz
import re
import time
from collections import defaultdict
from datetime import datetime, timedelta
from typing import Any, Callable, Dict, List, \
Optional, Set, Text, Tuple, Type, Union
from six.moves import filter, map, range, zip
from typing import Any, Callable, Dict, List, Optional, Set, Text, \
Tuple, Type, Union
import pytz
from django.conf import settings
from django.urls import reverse
from django.db import connection
from django.db.models import Sum
from django.db.models.query import QuerySet
from django.http import HttpRequest, HttpResponse, HttpResponseNotFound
from django.shortcuts import render
from django.template import RequestContext, loader
from django.utils.timezone import now as timezone_now, utc as timezone_utc
from django.utils.translation import ugettext as _
from jinja2 import Markup as mark_safe
from analytics.lib.counts import COUNT_STATS, CountStat, process_count_stat
from analytics.lib.time_utils import time_range
from analytics.models import BaseCount, InstallationCount, \
RealmCount, StreamCount, UserCount, last_successful_fill
from zerver.decorator import require_server_admin, \
to_non_negative_int, to_utc_datetime, zulip_login_required
from zerver.lib.exceptions import JsonableError
from zerver.lib.request import REQ, has_request_variables
from zerver.lib.response import json_success
from zerver.lib.timestamp import ceiling_to_day, \
ceiling_to_hour, convert_to_UTC, timestamp_to_datetime
from zerver.models import Client, get_realm, Realm, \
UserActivity, UserActivityInterval, UserProfile
@zulip_login_required
def stats(request):
# type: (HttpRequest) -> HttpResponse
def stats(request: HttpRequest) -> HttpResponse:
return render(request,
'analytics/stats.html',
context=dict(realm_name = request.user.realm.name))
@has_request_variables
def get_chart_data(request, user_profile, chart_name=REQ(),
min_length=REQ(converter=to_non_negative_int, default=None),
start=REQ(converter=to_utc_datetime, default=None),
end=REQ(converter=to_utc_datetime, default=None)):
# type: (HttpRequest, UserProfile, Text, Optional[int], Optional[datetime], Optional[datetime]) -> HttpResponse
def get_chart_data(request: HttpRequest, user_profile: UserProfile, chart_name: Text=REQ(),
min_length: Optional[int]=REQ(converter=to_non_negative_int, default=None),
start: Optional[datetime]=REQ(converter=to_utc_datetime, default=None),
end: Optional[datetime]=REQ(converter=to_utc_datetime, default=None)) -> HttpResponse:
if chart_name == 'number_of_humans':
stat = COUNT_STATS['realm_active_humans::day']
tables = [RealmCount]
@@ -119,8 +115,7 @@ def get_chart_data(request, user_profile, chart_name=REQ(),
data['display_order'] = None
return json_success(data=data)
def sort_by_totals(value_arrays):
# type: (Dict[str, List[int]]) -> List[str]
def sort_by_totals(value_arrays: Dict[str, List[int]]) -> List[str]:
totals = [(sum(values), label) for label, values in value_arrays.items()]
totals.sort(reverse=True)
return [label for total, label in totals]
@@ -131,8 +126,7 @@ def sort_by_totals(value_arrays):
# understanding the realm's traffic and the user's traffic. This function
# tries to rank the clients so that taking the first N elements of the
# sorted list has a reasonable chance of doing so.
def sort_client_labels(data):
# type: (Dict[str, Dict[str, List[int]]]) -> List[str]
def sort_client_labels(data: Dict[str, Dict[str, List[int]]]) -> List[str]:
realm_order = sort_by_totals(data['realm'])
user_order = sort_by_totals(data['user'])
label_sort_values = {} # type: Dict[str, float]
@@ -143,8 +137,7 @@ def sort_client_labels(data):
return [label for label, sort_value in sorted(label_sort_values.items(),
key=lambda x: x[1])]
def table_filtered_to_id(table, key_id):
# type: (Type[BaseCount], int) -> QuerySet
def table_filtered_to_id(table: Type[BaseCount], key_id: int) -> QuerySet:
if table == RealmCount:
return RealmCount.objects.filter(realm_id=key_id)
elif table == UserCount:
@@ -156,8 +149,7 @@ def table_filtered_to_id(table, key_id):
else:
raise AssertionError("Unknown table: %s" % (table,))
def client_label_map(name):
# type: (str) -> str
def client_label_map(name: str) -> str:
if name == "website":
return "Website"
if name.startswith("desktop app"):
@@ -176,8 +168,7 @@ def client_label_map(name):
return name[len("Zulip"):-len("Webhook")] + " webhook"
return name
def rewrite_client_arrays(value_arrays):
# type: (Dict[str, List[int]]) -> Dict[str, List[int]]
def rewrite_client_arrays(value_arrays: Dict[str, List[int]]) -> Dict[str, List[int]]:
mapped_arrays = {} # type: Dict[str, List[int]]
for label, array in value_arrays.items():
mapped_label = client_label_map(label)
@@ -188,8 +179,12 @@ def rewrite_client_arrays(value_arrays):
mapped_arrays[mapped_label] = [value_arrays[label][i] for i in range(0, len(array))]
return mapped_arrays
def get_time_series_by_subgroup(stat, table, key_id, end_times, subgroup_to_label, include_empty_subgroups):
# type: (CountStat, Type[BaseCount], int, List[datetime], Dict[Optional[str], str], bool) -> Dict[str, List[int]]
def get_time_series_by_subgroup(stat: CountStat,
table: Type[BaseCount],
key_id: int,
end_times: List[datetime],
subgroup_to_label: Dict[Optional[str], str],
include_empty_subgroups: bool) -> Dict[str, List[int]]:
queryset = table_filtered_to_id(table, key_id).filter(property=stat.property) \
.values_list('subgroup', 'end_time', 'value')
value_dicts = defaultdict(lambda: defaultdict(int)) # type: Dict[Optional[str], Dict[datetime, int]]
@@ -210,12 +205,10 @@ def get_time_series_by_subgroup(stat, table, key_id, end_times, subgroup_to_labe
eastern_tz = pytz.timezone('US/Eastern')
def make_table(title, cols, rows, has_row_class=False):
# type: (str, List[str], List[Any], bool) -> str
def make_table(title: str, cols: List[str], rows: List[Any], has_row_class: bool=False) -> str:
if not has_row_class:
def fix_row(row):
# type: (Any) -> Dict[str, Any]
def fix_row(row: Any) -> Dict[str, Any]:
return dict(cells=row, row_class=None)
rows = list(map(fix_row, rows))
@@ -228,8 +221,7 @@ def make_table(title, cols, rows, has_row_class=False):
return content
def dictfetchall(cursor):
# type: (connection.cursor) -> List[Dict[str, Any]]
def dictfetchall(cursor: connection.cursor) -> List[Dict[str, Any]]:
"Returns all rows from a cursor as a dict"
desc = cursor.description
return [
@@ -238,8 +230,7 @@ def dictfetchall(cursor):
]
def get_realm_day_counts():
# type: () -> Dict[str, Dict[str, str]]
def get_realm_day_counts() -> Dict[str, Dict[str, str]]:
query = '''
select
r.string_id,
@@ -274,12 +265,13 @@ def get_realm_day_counts():
result = {}
for string_id in counts:
raw_cnts = [counts[string_id].get(age, 0) for age in range(8)]
min_cnt = min(raw_cnts)
max_cnt = max(raw_cnts)
min_cnt = min(raw_cnts[1:])
max_cnt = max(raw_cnts[1:])
def format_count(cnt):
# type: (int) -> str
if cnt == min_cnt:
def format_count(cnt: int, style: Optional[str]=None) -> str:
if style is not None:
good_bad = style
elif cnt == min_cnt:
good_bad = 'bad'
elif cnt == max_cnt:
good_bad = 'good'
@@ -288,18 +280,21 @@ def get_realm_day_counts():
return '<td class="number %s">%s</td>' % (good_bad, cnt)
cnts = ''.join(map(format_count, raw_cnts))
cnts = (format_count(raw_cnts[0], 'neutral')
+ ''.join(map(format_count, raw_cnts[1:])))
result[string_id] = dict(cnts=cnts)
return result
def realm_summary_table(realm_minutes):
# type: (Dict[str, float]) -> str
def realm_summary_table(realm_minutes: Dict[str, float]) -> str:
now = timezone_now()
query = '''
SELECT
realm.string_id,
coalesce(user_counts.active_user_count, 0) active_user_count,
coalesce(at_risk_counts.at_risk_count, 0) at_risk_count,
realm.date_created,
coalesce(user_counts.dau_count, 0) dau_count,
coalesce(wau_counts.wau_count, 0) wau_count,
(
SELECT
count(*)
@@ -321,22 +316,24 @@ def realm_summary_table(realm_minutes):
(
SELECT
up.realm_id realm_id,
count(distinct(ua.user_profile_id)) active_user_count
count(distinct(ua.user_profile_id)) dau_count
FROM zerver_useractivity ua
JOIN zerver_userprofile up
ON up.id = ua.user_profile_id
WHERE
up.is_active
AND (not up.is_bot)
AND
query in (
'/json/send_message',
'send_message_backend',
'/api/v1/send_message',
'/json/update_pointer',
'/json/users/me/pointer'
'/json/users/me/pointer',
'update_pointer_backend'
)
AND
last_visit > now() - interval '1 day'
AND
not is_bot
GROUP BY realm_id
) user_counts
ON user_counts.realm_id = realm.id
@@ -344,7 +341,7 @@ def realm_summary_table(realm_minutes):
(
SELECT
realm_id,
count(*) at_risk_count
count(*) wau_count
FROM (
SELECT
realm.id as realm_id,
@@ -362,35 +359,37 @@ def realm_summary_table(realm_minutes):
'send_message_backend',
'/api/v1/send_message',
'/json/update_pointer',
'/json/users/me/pointer'
'/json/users/me/pointer',
'update_pointer_backend'
)
GROUP by realm.id, up.email
HAVING max(last_visit) between
now() - interval '7 day' and
now() - interval '1 day'
) as at_risk_users
HAVING max(last_visit) > now() - interval '7 day'
) as wau_users
GROUP BY realm_id
) at_risk_counts
ON at_risk_counts.realm_id = realm.id
) wau_counts
ON wau_counts.realm_id = realm.id
WHERE EXISTS (
SELECT *
FROM zerver_useractivity ua
JOIN zerver_userprofile up
ON up.id = ua.user_profile_id
WHERE
up.realm_id = realm.id
AND up.is_active
AND (not up.is_bot)
AND
query in (
'/json/send_message',
'/api/v1/send_message',
'send_message_backend',
'/json/update_pointer',
'/json/users/me/pointer'
'/json/users/me/pointer',
'update_pointer_backend'
)
AND
up.realm_id = realm.id
AND
last_visit > now() - interval '2 week'
)
ORDER BY active_user_count DESC, string_id ASC
ORDER BY dau_count DESC, string_id ASC
'''
cursor = connection.cursor()
@@ -398,6 +397,21 @@ def realm_summary_table(realm_minutes):
rows = dictfetchall(cursor)
cursor.close()
# Fetch all the realm administrator users
realm_admins = defaultdict(list) # type: Dict[str, List[str]]
for up in UserProfile.objects.select_related("realm").filter(
is_realm_admin=True,
is_active=True
):
realm_admins[up.realm.string_id].append(up.email)
for row in rows:
row['date_created_day'] = row['date_created'].strftime('%Y-%m-%d')
row['age_days'] = int((now - row['date_created']).total_seconds()
/ 86400)
row['is_new'] = row['age_days'] < 12 * 7
row['realm_admin_email'] = ', '.join(realm_admins[row['string_id']])
# get messages sent per day
counts = get_realm_day_counts()
for row in rows:
@@ -415,7 +429,7 @@ def realm_summary_table(realm_minutes):
total_hours += hours
row['hours'] = str(int(hours))
try:
row['hours_per_user'] = '%.1f' % (hours / row['active_user_count'],)
row['hours_per_user'] = '%.1f' % (hours / row['dau_count'],)
except Exception:
pass
@@ -424,41 +438,42 @@ def realm_summary_table(realm_minutes):
row['string_id'] = realm_activity_link(row['string_id'])
# Count active sites
def meets_goal(row):
# type: (Dict[str, int]) -> bool
return row['active_user_count'] >= 5
def meets_goal(row: Dict[str, int]) -> bool:
return row['dau_count'] >= 5
num_active_sites = len(list(filter(meets_goal, rows)))
# create totals
total_active_user_count = 0
total_dau_count = 0
total_user_profile_count = 0
total_bot_count = 0
total_at_risk_count = 0
total_wau_count = 0
for row in rows:
total_active_user_count += int(row['active_user_count'])
total_dau_count += int(row['dau_count'])
total_user_profile_count += int(row['user_profile_count'])
total_bot_count += int(row['bot_count'])
total_at_risk_count += int(row['at_risk_count'])
total_wau_count += int(row['wau_count'])
rows.append(dict(
string_id='Total',
active_user_count=total_active_user_count,
date_created_day='',
realm_admin_email='',
dau_count=total_dau_count,
user_profile_count=total_user_profile_count,
bot_count=total_bot_count,
hours=int(total_hours),
at_risk_count=total_at_risk_count,
wau_count=total_wau_count,
))
content = loader.render_to_string(
'analytics/realm_summary_table.html',
dict(rows=rows, num_active_sites=num_active_sites)
dict(rows=rows, num_active_sites=num_active_sites,
now=now.strftime('%Y-%m-%dT%H:%M:%SZ'))
)
return content
def user_activity_intervals():
# type: () -> Tuple[mark_safe, Dict[str, float]]
def user_activity_intervals() -> Tuple[mark_safe, Dict[str, float]]:
day_end = timestamp_to_datetime(time.time())
day_start = day_end - timedelta(hours=24)
@@ -508,8 +523,7 @@ def user_activity_intervals():
content = mark_safe('<pre>' + output + '</pre>')
return content, realm_minutes
def sent_messages_report(realm):
# type: (str) -> str
def sent_messages_report(realm: str) -> str:
title = 'Recently sent messages for ' + realm
cols = [
@@ -576,18 +590,16 @@ def sent_messages_report(realm):
return make_table(title, cols, rows)
def ad_hoc_queries():
# type: () -> List[Dict[str, str]]
def get_page(query, cols, title):
# type: (str, List[str], str) -> Dict[str, str]
def ad_hoc_queries() -> List[Dict[str, str]]:
def get_page(query: str, cols: List[str], title: str) -> Dict[str, str]:
cursor = connection.cursor()
cursor.execute(query)
rows = cursor.fetchall()
rows = list(map(list, rows))
cursor.close()
def fix_rows(i, fixup_func):
# type: (int, Union[Callable[[Realm], mark_safe], Callable[[datetime], str]]) -> None
def fix_rows(i: int,
fixup_func: Union[Callable[[Realm], mark_safe], Callable[[datetime], str]]) -> None:
for row in rows:
row[i] = fixup_func(row[i])
@@ -749,8 +761,7 @@ def ad_hoc_queries():
@require_server_admin
@has_request_variables
def get_activity(request):
# type: (HttpRequest) -> HttpResponse
def get_activity(request: HttpRequest) -> HttpResponse:
duration_content, realm_minutes = user_activity_intervals() # type: Tuple[mark_safe, Dict[str, float]]
counts_content = realm_summary_table(realm_minutes) # type: str
data = [
@@ -768,8 +779,7 @@ def get_activity(request):
context=dict(data=data, title=title, is_home=True),
)
def get_user_activity_records_for_realm(realm, is_bot):
# type: (str, bool) -> QuerySet
def get_user_activity_records_for_realm(realm: str, is_bot: bool) -> QuerySet:
fields = [
'user_profile__full_name',
'user_profile__email',
@@ -788,8 +798,7 @@ def get_user_activity_records_for_realm(realm, is_bot):
records = records.select_related('user_profile', 'client').only(*fields)
return records
def get_user_activity_records_for_email(email):
# type: (str) -> List[QuerySet]
def get_user_activity_records_for_email(email: str) -> List[QuerySet]:
fields = [
'user_profile__full_name',
'query',
@@ -805,8 +814,7 @@ def get_user_activity_records_for_email(email):
records = records.select_related('user_profile', 'client').only(*fields)
return records
def raw_user_activity_table(records):
# type: (List[QuerySet]) -> str
def raw_user_activity_table(records: List[QuerySet]) -> str:
cols = [
'query',
'client',
@@ -814,8 +822,7 @@ def raw_user_activity_table(records):
'last_visit'
]
def row(record):
# type: (QuerySet) -> List[Any]
def row(record: QuerySet) -> List[Any]:
return [
record.query,
record.client.name,
@@ -827,8 +834,7 @@ def raw_user_activity_table(records):
title = 'Raw Data'
return make_table(title, cols, rows)
def get_user_activity_summary(records):
# type: (List[QuerySet]) -> Dict[str, Dict[str, Any]]
def get_user_activity_summary(records: List[QuerySet]) -> Dict[str, Dict[str, Any]]:
#: `Any` used above should be `Union(int, datetime)`.
#: However current version of `Union` does not work inside other function.
#: We could use something like:
@@ -836,8 +842,7 @@ def get_user_activity_summary(records):
#: but that would require this long `Union` to carry on throughout inner functions.
summary = {} # type: Dict[str, Dict[str, Any]]
def update(action, record):
# type: (str, QuerySet) -> None
def update(action: str, record: QuerySet) -> None:
if action not in summary:
summary[action] = dict(
count=record.count,
@@ -871,35 +876,32 @@ def get_user_activity_summary(records):
update('website', record)
if ('send_message' in query) or re.search('/api/.*/external/.*', query):
update('send', record)
if query in ['/json/update_pointer', '/json/users/me/pointer', '/api/v1/update_pointer']:
if query in ['/json/update_pointer', '/json/users/me/pointer', '/api/v1/update_pointer',
'update_pointer_backend']:
update('pointer', record)
update(client, record)
return summary
def format_date_for_activity_reports(date):
# type: (Optional[datetime]) -> str
def format_date_for_activity_reports(date: Optional[datetime]) -> str:
if date:
return date.astimezone(eastern_tz).strftime('%Y-%m-%d %H:%M')
else:
return ''
def user_activity_link(email):
# type: (str) -> mark_safe
def user_activity_link(email: str) -> mark_safe:
url_name = 'analytics.views.get_user_activity'
url = urlresolvers.reverse(url_name, kwargs=dict(email=email))
url = reverse(url_name, kwargs=dict(email=email))
email_link = '<a href="%s">%s</a>' % (url, email)
return mark_safe(email_link)
def realm_activity_link(realm_str):
# type: (str) -> mark_safe
def realm_activity_link(realm_str: str) -> mark_safe:
url_name = 'analytics.views.get_realm_activity'
url = urlresolvers.reverse(url_name, kwargs=dict(realm_str=realm_str))
url = reverse(url_name, kwargs=dict(realm_str=realm_str))
realm_link = '<a href="%s">%s</a>' % (url, realm_str)
return mark_safe(realm_link)
def realm_client_table(user_summaries):
# type: (Dict[str, Dict[str, Dict[str, Any]]]) -> str
def realm_client_table(user_summaries: Dict[str, Dict[str, Dict[str, Any]]]) -> str:
exclude_keys = [
'internal',
'name',
@@ -943,8 +945,7 @@ def realm_client_table(user_summaries):
return make_table(title, cols, rows)
def user_activity_summary_table(user_summary):
# type: (Dict[str, Dict[str, Any]]) -> str
def user_activity_summary_table(user_summary: Dict[str, Dict[str, Any]]) -> str:
rows = []
for k, v in user_summary.items():
if k == 'name':
@@ -970,33 +971,29 @@ def user_activity_summary_table(user_summary):
title = 'User Activity'
return make_table(title, cols, rows)
def realm_user_summary_table(all_records, admin_emails):
# type: (List[QuerySet], Set[Text]) -> Tuple[Dict[str, Dict[str, Any]], str]
def realm_user_summary_table(all_records: List[QuerySet],
admin_emails: Set[Text]) -> Tuple[Dict[str, Dict[str, Any]], str]:
user_records = {}
def by_email(record):
# type: (QuerySet) -> str
def by_email(record: QuerySet) -> str:
return record.user_profile.email
for email, records in itertools.groupby(all_records, by_email):
user_records[email] = get_user_activity_summary(list(records))
def get_last_visit(user_summary, k):
# type: (Dict[str, Dict[str, datetime]], str) -> Optional[datetime]
def get_last_visit(user_summary: Dict[str, Dict[str, datetime]], k: str) -> Optional[datetime]:
if k in user_summary:
return user_summary[k]['last_visit']
else:
return None
def get_count(user_summary, k):
# type: (Dict[str, Dict[str, str]], str) -> str
def get_count(user_summary: Dict[str, Dict[str, str]], k: str) -> str:
if k in user_summary:
return user_summary[k]['count']
else:
return ''
def is_recent(val):
# type: (Optional[datetime]) -> bool
def is_recent(val: Optional[datetime]) -> bool:
age = timezone_now() - val
return age.total_seconds() < 5 * 60
@@ -1018,8 +1015,7 @@ def realm_user_summary_table(all_records, admin_emails):
row = dict(cells=cells, row_class=row_class)
rows.append(row)
def by_used_time(row):
# type: (Dict[str, Any]) -> str
def by_used_time(row: Dict[str, Any]) -> str:
return row['cells'][3]
rows = sorted(rows, key=by_used_time, reverse=True)
@@ -1042,8 +1038,7 @@ def realm_user_summary_table(all_records, admin_emails):
return user_records, content
@require_server_admin
def get_realm_activity(request, realm_str):
# type: (HttpRequest, str) -> HttpResponse
def get_realm_activity(request: HttpRequest, realm_str: str) -> HttpResponse:
data = [] # type: List[Tuple[str, str]]
all_user_records = {} # type: Dict[str, Any]
@@ -1078,8 +1073,7 @@ def get_realm_activity(request, realm_str):
)
@require_server_admin
def get_user_activity(request, email):
# type: (HttpRequest, str) -> HttpResponse
def get_user_activity(request: HttpRequest, email: str) -> HttpResponse:
records = get_user_activity_records_for_email(email)
data = [] # type: List[Tuple[str, str]]

View File

@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-11-30 00:13
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('zerver', '0124_stream_enable_notifications'),
('confirmation', '0004_remove_confirmationmanager'),
]
operations = [
migrations.AddField(
model_name='confirmation',
name='realm',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='zerver.Realm'),
),
]

View File

@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2018-01-29 18:39
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('confirmation', '0005_confirmation_realm'),
]
operations = [
migrations.AddField(
model_name='realmcreationkey',
name='presume_email_valid',
field=models.BooleanField(default=False),
),
]

View File

@@ -7,9 +7,9 @@ __revision__ = '$Id: models.py 28 2009-10-22 15:03:02Z jarek.zgoda $'
import datetime
from django.db import models
from django.core.urlresolvers import reverse
from django.db.models import CASCADE
from django.urls import reverse
from django.conf import settings
from django.contrib.sites.models import Site
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.fields import GenericForeignKey
from django.http import HttpRequest, HttpResponse
@@ -18,7 +18,8 @@ from django.utils.timezone import now as timezone_now
from zerver.lib.send_email import send_email
from zerver.lib.utils import generate_random_token
from zerver.models import PreregistrationUser, EmailChangeStatus, MultiuseInvite
from zerver.models import PreregistrationUser, EmailChangeStatus, MultiuseInvite, \
UserProfile, Realm
from random import SystemRandom
import string
from typing import Any, Dict, Optional, Text, Union
@@ -28,32 +29,31 @@ class ConfirmationKeyException(Exception):
EXPIRED = 2
DOES_NOT_EXIST = 3
def __init__(self, error_type):
# type: (int) -> None
super(ConfirmationKeyException, self).__init__()
def __init__(self, error_type: int) -> None:
super().__init__()
self.error_type = error_type
def render_confirmation_key_error(request, exception):
# type: (HttpRequest, ConfirmationKeyException) -> HttpResponse
def render_confirmation_key_error(request: HttpRequest, exception: ConfirmationKeyException) -> HttpResponse:
if exception.error_type == ConfirmationKeyException.WRONG_LENGTH:
return render(request, 'confirmation/link_malformed.html')
if exception.error_type == ConfirmationKeyException.EXPIRED:
return render(request, 'confirmation/link_expired.html')
return render(request, 'confirmation/link_does_not_exist.html')
def generate_key():
# type: () -> str
def generate_key() -> str:
generator = SystemRandom()
# 24 characters * 5 bits of entropy/character = 120 bits of entropy
return ''.join(generator.choice(string.ascii_lowercase + string.digits) for _ in range(24))
def get_object_from_key(confirmation_key):
# type: (str) -> Union[MultiuseInvite, PreregistrationUser, EmailChangeStatus]
ConfirmationObjT = Union[MultiuseInvite, PreregistrationUser, EmailChangeStatus]
def get_object_from_key(confirmation_key: str,
confirmation_type: int) -> ConfirmationObjT:
# Confirmation keys used to be 40 characters
if len(confirmation_key) not in (24, 40):
raise ConfirmationKeyException(ConfirmationKeyException.WRONG_LENGTH)
try:
confirmation = Confirmation.objects.get(confirmation_key=confirmation_key)
confirmation = Confirmation.objects.get(confirmation_key=confirmation_key,
type=confirmation_type)
except Confirmation.DoesNotExist:
raise ConfirmationKeyException(ConfirmationKeyException.DOES_NOT_EXIST)
@@ -67,15 +67,17 @@ def get_object_from_key(confirmation_key):
obj.save(update_fields=['status'])
return obj
def create_confirmation_link(obj, host, confirmation_type, url_args=None):
# type: (Union[ContentType, int], str, int, Optional[Dict[str, str]]) -> str
def create_confirmation_link(obj: ContentType, host: str,
confirmation_type: int,
url_args: Optional[Dict[str, str]]=None) -> str:
key = generate_key()
Confirmation.objects.create(content_object=obj, date_sent=timezone_now(), confirmation_key=key,
type=confirmation_type)
realm=obj.realm, type=confirmation_type)
return confirmation_url(key, host, confirmation_type, url_args)
def confirmation_url(confirmation_key, host, confirmation_type, url_args=None):
# type: (str, str, int, Optional[Dict[str, str]]) -> str
def confirmation_url(confirmation_key: str, host: str,
confirmation_type: int,
url_args: Optional[Dict[str, str]]=None) -> str:
if url_args is None:
url_args = {}
url_args['confirmation_key'] = confirmation_key
@@ -83,11 +85,12 @@ def confirmation_url(confirmation_key, host, confirmation_type, url_args=None):
reverse(_properties[confirmation_type].url_name, kwargs=url_args))
class Confirmation(models.Model):
content_type = models.ForeignKey(ContentType)
content_type = models.ForeignKey(ContentType, on_delete=CASCADE)
object_id = models.PositiveIntegerField() # type: int
content_object = GenericForeignKey('content_type', 'object_id')
date_sent = models.DateTimeField() # type: datetime.datetime
confirmation_key = models.CharField(max_length=40) # type: str
realm = models.ForeignKey(Realm, null=True, on_delete=CASCADE) # type: Optional[Realm]
# The following list is the set of valid types
USER_REGISTRATION = 1
@@ -96,51 +99,69 @@ class Confirmation(models.Model):
UNSUBSCRIBE = 4
SERVER_REGISTRATION = 5
MULTIUSE_INVITE = 6
REALM_CREATION = 7
type = models.PositiveSmallIntegerField() # type: int
def __unicode__(self):
# type: () -> Text
def __str__(self) -> Text:
return '<Confirmation: %s>' % (self.content_object,)
class ConfirmationType(object):
def __init__(self, url_name, validity_in_days=settings.CONFIRMATION_LINK_DEFAULT_VALIDITY_DAYS):
# type: (str, int) -> None
class ConfirmationType:
def __init__(self, url_name: str,
validity_in_days: int=settings.CONFIRMATION_LINK_DEFAULT_VALIDITY_DAYS) -> None:
self.url_name = url_name
self.validity_in_days = validity_in_days
_properties = {
Confirmation.USER_REGISTRATION: ConfirmationType('confirmation.views.confirm'),
Confirmation.INVITATION: ConfirmationType('confirmation.views.confirm',
Confirmation.USER_REGISTRATION: ConfirmationType('check_prereg_key_and_redirect'),
Confirmation.INVITATION: ConfirmationType('check_prereg_key_and_redirect',
validity_in_days=settings.INVITATION_LINK_VALIDITY_DAYS),
Confirmation.EMAIL_CHANGE: ConfirmationType('zerver.views.user_settings.confirm_email_change'),
Confirmation.UNSUBSCRIBE: ConfirmationType('zerver.views.unsubscribe.email_unsubscribe',
validity_in_days=1000000), # should never expire
Confirmation.MULTIUSE_INVITE: ConfirmationType('zerver.views.registration.accounts_home_from_multiuse_invite',
validity_in_days=settings.INVITATION_LINK_VALIDITY_DAYS)
Confirmation.MULTIUSE_INVITE: ConfirmationType(
'zerver.views.registration.accounts_home_from_multiuse_invite',
validity_in_days=settings.INVITATION_LINK_VALIDITY_DAYS),
Confirmation.REALM_CREATION: ConfirmationType('check_prereg_key_and_redirect'),
}
# Conirmation pathways for which there is no content_object that we need to
# keep track of.
# Functions related to links generated by the generate_realm_creation_link.py
# management command.
# Note that being validated here will just allow the user to access the create_realm
# form, where they will enter their email and go through the regular
# Confirmation.REALM_CREATION pathway.
# Arguably RealmCreationKey should just be another ConfirmationObjT and we should
# add another Confirmation.type for this; it's this way for historical reasons.
def check_key_is_valid(creation_key):
# type: (Text) -> bool
if not RealmCreationKey.objects.filter(creation_key=creation_key).exists():
return False
days_sofar = (timezone_now() - RealmCreationKey.objects.get(creation_key=creation_key).date_created).days
# Realm creation link expires after settings.REALM_CREATION_LINK_VALIDITY_DAYS
if days_sofar <= settings.REALM_CREATION_LINK_VALIDITY_DAYS:
return True
return False
def validate_key(creation_key: Optional[str]) -> Optional['RealmCreationKey']:
"""Get the record for this key, raising InvalidCreationKey if non-None but invalid."""
if creation_key is None:
return None
try:
key_record = RealmCreationKey.objects.get(creation_key=creation_key)
except RealmCreationKey.DoesNotExist:
raise RealmCreationKey.Invalid()
time_elapsed = timezone_now() - key_record.date_created
if time_elapsed.total_seconds() > settings.REALM_CREATION_LINK_VALIDITY_DAYS * 24 * 3600:
raise RealmCreationKey.Invalid()
return key_record
def generate_realm_creation_url():
# type: () -> Text
def generate_realm_creation_url(by_admin: bool=False) -> Text:
key = generate_key()
RealmCreationKey.objects.create(creation_key=key, date_created=timezone_now())
return u'%s%s%s' % (settings.EXTERNAL_URI_SCHEME,
settings.EXTERNAL_HOST,
reverse('zerver.views.create_realm',
kwargs={'creation_key': key}))
RealmCreationKey.objects.create(creation_key=key,
date_created=timezone_now(),
presume_email_valid=by_admin)
return '%s%s%s' % (settings.EXTERNAL_URI_SCHEME,
settings.EXTERNAL_HOST,
reverse('zerver.views.create_realm',
kwargs={'creation_key': key}))
class RealmCreationKey(models.Model):
creation_key = models.CharField('activation key', max_length=40)
date_created = models.DateTimeField('created', default=timezone_now)
# True just if we should presume the email address the user enters
# is theirs, and skip sending mail to it to confirm that.
presume_email_valid = models.BooleanField(default=False) # type: bool
class Invalid(Exception):
pass

View File

@@ -1,31 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright: (c) 2008, Jarek Zgoda <jarek.zgoda@gmail.com>
__revision__ = '$Id: views.py 21 2008-12-05 09:21:03Z jarek.zgoda $'
from django.shortcuts import render
from django.template import RequestContext
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from confirmation.models import Confirmation, get_object_from_key, ConfirmationKeyException, \
render_confirmation_key_error
from zerver.models import PreregistrationUser
from typing import Any, Dict
# This is currently only used for confirming PreregistrationUser.
# Do not add other confirmation paths here.
def confirm(request, confirmation_key):
# type: (HttpRequest, str) -> HttpResponse
try:
get_object_from_key(confirmation_key)
except ConfirmationKeyException as exception:
return render_confirmation_key_error(request, exception)
return render(request, 'confirmation/confirm_preregistrationuser.html',
context={
'key': confirmation_key,
'full_name': request.GET.get("full_name", None)})

View File

@@ -1,5 +1,5 @@
from django.conf.urls import url
from django.views.generic import TemplateView, RedirectView
from django.views.generic import TemplateView
i18n_urlpatterns = [
# Zephyr/MIT

View File

@@ -2,7 +2,7 @@
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXOPTS = -j8
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build

View File

@@ -37,7 +37,7 @@ Copyright: 2011, Krzysztof Wilczynski
2011, Puppet Labs Inc
License: Apache-2.0
File: puppet/zulip_internal/files/mediawiki/Auth_remoteuser.php
File: puppet/zulip_ops/files/mediawiki/Auth_remoteuser.php
Copyright: 2006 Otheus Shelling
2007 Rusty Burchfield
2009 James Kinsman
@@ -59,15 +59,24 @@ Files: puppet/zulip/files/nagios_plugins/zulip_nagios_server/check_website_respo
Copyright: 2011 Chris Freeman
License: GPL-2.0
Files: puppet/zulip_internal/files/trac/cgi-bin/
Files: puppet/zulip_ops/files/trac/cgi-bin/
Copyright: 2003-2009 Edgewall Software
2003-2004 Jonas Borgström <jonas@edgewall.com>
License: BSD-3-Clause
Files: puppet/zulip_internal/files/zulip-ec2-configure-interfaces
Files: puppet/zulip_ops/files/zulip-ec2-configure-interfaces
Copyright: 2013-2017, Dropbox, Inc., Kandra Labs, Inc., and contributors
License: Expat
Files: scripts/setup/generate-self-signed-cert
Copyright: 2003-2006 Thom May
2006 Fabio M. Di Nitto
2006 Adam Conrad
2006-2008 Tollef Fog Heen
2008-2015 Stefan Fritsch
2018 Kandra Labs, Inc., and contributors
License: BSD-3-Clause
Files: static/audio/zulip.*
Copyright: 2011 Vidsyn
License: CC-0-1.0
@@ -182,6 +191,10 @@ Files: zerver/lib/decorator.py zerver/management/commands/runtornado.py scripts/
Copyright: Django Software Foundation and individual contributors
License: BSD-3-Clause
Files: zerver/lib/json_encoder_for_html.py zerver/tests/test_json_encoder_for_html.py
Copyright: 2006 Bob Ippolito
License: MIT or Academic Free License v. 2.1
License: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -1,119 +0,0 @@
# Vagrant environment setup (in brief)
Start by cloning this repository: `git clone https://github.com/zulip/zulip.git`
This is the recommended approach for all platforms and will install
the Zulip development environment inside a VM or container and works
on any platform that supports Vagrant.
The best performing way to run the Zulip development environment is
using an LXC container on a Linux host, but we support other platforms
such as Mac via Virtualbox (but everything will be 2-3x slower).
* If your host is Ubuntu 15.04 or newer, you can install and configure
the LXC Vagrant provider directly using apt:
```
sudo apt-get install vagrant lxc lxc-templates cgroup-lite redir
vagrant plugin install vagrant-lxc
```
You may want to [configure sudo to be passwordless when using Vagrant LXC][avoiding-sudo].
* If your host is Ubuntu 14.04, you will need to [download a newer
version of Vagrant][vagrant-dl], and then do the following:
```
sudo apt-get install lxc lxc-templates cgroup-lite redir
sudo dpkg -i vagrant*.deb # in directory where you downloaded vagrant
vagrant plugin install vagrant-lxc
```
You may want to [configure sudo to be passwordless when using Vagrant LXC][avoiding-sudo].
* For other Linux hosts with a kernel above 3.12, [follow the Vagrant
LXC installation instructions][vagrant-lxc] to get Vagrant with LXC
for your platform.
* If your host is macOS or older Linux, [download Vagrant][vagrant-dl]
and [VirtualBox][vbox-dl]. Or, instead of Virtualbox you can use
[VMWare Fusion][vmware-fusion-dl] with the [VMWare vagrant
provider][vagrant-vmware-fusion-dl] for a nonfree option with better
performance.
* On Windows: You can use Vagrant and Virtualbox/VMWare on Windows
with Cygwin, similar to the Mac setup. Be sure to create your git
clone using `git clone https://github.com/zulip/zulip.git -c
core.autocrlf=false` to avoid Windows line endings being added to
files (this causes weird errors).
[vagrant-dl]: https://www.vagrantup.com/downloads.html
[vagrant-lxc]: https://github.com/fgrehm/vagrant-lxc
[vbox-dl]: https://www.virtualbox.org/wiki/Downloads
[vmware-fusion-dl]: http://www.vmware.com/products/fusion.html
[vagrant-vmware-fusion-dl]: https://www.vagrantup.com/vmware/
[avoiding-sudo]: https://github.com/fgrehm/vagrant-lxc#avoiding-sudo-passwords
Once that's done, simply change to your zulip directory and run
`vagrant up` in your terminal to install the development server. This
will take a long time on the first run because Vagrant needs to
download the Ubuntu Trusty base image, but later you can run `vagrant
destroy` and then `vagrant up` again to rebuild the environment and it
will be much faster.
Once that finishes, you can run the development server as follows:
```
vagrant ssh
# Now inside the container
/srv/zulip/tools/run-dev.py
```
To get shell access to the virtual machine running the server to run
lint, management commands, etc., use `vagrant ssh`.
At this point you should [read about using the development
environment][using-dev].
[using-dev]: using-dev-environment.html
### Specifying a proxy
If you need to use a proxy server to access the Internet, you will
need to specify the proxy settings before running `Vagrant up`.
First, install the Vagrant plugin `vagrant-proxyconf`:
```
vagrant plugin install vagrant-proxyconf.
```
Then create `~/.zulip-vagrant-config` and add the following lines to
it (with the appropriate values in it for your proxy):
```
HTTP_PROXY http://proxy_host:port
HTTPS_PROXY http://proxy_host:port
NO_PROXY localhost,127.0.0.1,.example.com
```
Now run `vagrant up` in your terminal to install the development
server. If you ran `vagrant up` before and failed, you'll need to run
`vagrant destroy` first to clean up the failed installation.
You can also change the port on the host machine that Vagrant uses by
adding to your `~/.zulip-vagrant-config` file. E.g. if you set:
```
HOST_PORT 9971
```
(and halt and restart the Vagrant guest), then you would visit
http://localhost:9971/ to connect to your development server.
If you'd like to be able to connect to your development environment from other
machines than the VM host, you can manually set the host IP address in the
'~/.zulip-vagrant-config' file as well. For example, if you set:
```
HOST_IP_ADDR 0.0.0.0
```
(and restart the Vagrant guest), your host IP would be 0.0.0.0, a special value
for the IP address that means any IP address can connect to your development server.

View File

@@ -15,8 +15,8 @@
import sys
import os
import shlex
if False:
from typing import Any, Dict, List, Optional
from typing import Any, Dict, List, Optional
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -43,18 +43,23 @@ templates_path = ['_templates']
master_doc = 'index'
# General information about the project.
project = u'Zulip'
copyright = u'2015-2017, The Zulip Team'
author = u'The Zulip Team'
project = 'Zulip'
copyright = '2015-2017, The Zulip Team'
author = 'The Zulip Team'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.7'
version = '1.7+git'
# The full version, including alpha/beta/rc tags.
release = '1.7.0'
release = '1.7.1+git'
# This allows us to insert a warning that appears only on an unreleased
# version, e.g. to say that something is likely to have changed.
if release.endswith('+git'):
tags.add('unreleased')
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -113,11 +118,18 @@ if not on_rtd:
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
else:
html_theme = 'sphinx_rtd_theme'
html_style = None
html_theme_options = {'collapse_navigation': False}
using_rtd_theme = True
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#html_theme_options = {}
html_theme_options = {
'collapse_navigation': False,
}
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
@@ -206,12 +218,6 @@ html_static_path = ['_static']
# Output file base name for HTML help builder.
htmlhelp_basename = 'zulip-contributor-docsdoc'
def setup(app):
# type: (Any) -> None
# overrides for wide tables in RTD theme
app.add_stylesheet('theme_overrides.css') # path relative to _static
# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
@@ -232,8 +238,8 @@ latex_elements = {
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'zulip-contributor-docs.tex', u'Zulip Documentation',
u'The Zulip Team', 'manual'),
(master_doc, 'zulip-contributor-docs.tex', 'Zulip Documentation',
'The Zulip Team', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
@@ -262,7 +268,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'zulip-contributor-docs', u'Zulip Documentation',
(master_doc, 'zulip-contributor-docs', 'Zulip Documentation',
[author], 1)
]
@@ -276,7 +282,7 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'zulip-contributor-docs', u'Zulip Documentation',
(master_doc, 'zulip-contributor-docs', 'Zulip Documentation',
author, 'zulip-contributor-docs', 'Documentation for contributing to Zulip.',
'Miscellaneous'),
]
@@ -294,6 +300,7 @@ texinfo_documents = [
#texinfo_no_detailmenu = False
from recommonmark.parser import CommonMarkParser
from recommonmark.transform import AutoStructify
source_parsers = {
'.md': CommonMarkParser,
@@ -302,3 +309,24 @@ source_parsers = {
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
source_suffix = ['.rst', '.md']
def setup(app: Any) -> None:
app.add_config_value('recommonmark_config', {
'enable_eval_rst': True,
# Turn off recommonmark features we aren't using.
'enable_auto_doc_ref': False,
'auto_toc_tree_section': None,
'enable_auto_toc_tree': False,
'enable_math': False,
'enable_inline_math': False,
'url_resolver': lambda x: x,
}, True)
# Enable `eval_rst`, and any other features enabled in recommonmark_config.
# Docs: http://recommonmark.readthedocs.io/en/latest/auto_structify.html
# (But NB those docs are for master, not latest release.)
app.add_transform(AutoStructify)
# overrides for wide tables in RTD theme
app.add_stylesheet('theme_overrides.css') # path relative to _static

View File

@@ -1,32 +1,20 @@
# The chat.zulip.org community
[chat.zulip.org](https://chat.zulip.org/) is the primary communication
forum for the Zulip community. It is a Zulip server that you can
connect to from any modern web browser.
[https://chat.zulip.org](https://chat.zulip.org/) is the primary communication
forum for the Zulip community.
You can go through the simple signup process at that link, and then
you will soon be talking to core Zulip developers and other users. To
get help in real time, you will have the best luck finding core
developers roughly between 17:00 UTC and 2:00 UTC or during [office
hours and sprints](#office-hours-and-sprints), but the sun never
sleeps on the Zulip community. Most questions get a reply within
developers roughly between 17:00 UTC and 6:00 UTC, but the sun never
sets on the Zulip community. Most questions get a reply within
minutes to a few hours, depending on the time of day.
## This is a bleeding edge development server
## Community norms
The chat.zulip.org server is frequently deployed off of `master` from
the Zulip Git repository, so please point out anything you notice that
seems wrong! We catch many bugs that escape code review this way.
The chat.zulip.org server is a development and testing server, not a
production service, so don't use it for anything mission-critical,
secret/embarrassing, etc.
## Community conventions
* Send any test messages to
* Send test messages to
[#test here](https://chat.zulip.org/#narrow/stream/test.20here) or
as a PM to yourself to avoid disrupting others.
as a PM to yourself to avoid disturbing others.
* When asking for help, provide the details needed for others to help
you. E.g. include the full traceback in a code block (not a
screenshot), a link to the code or a WIP PR you're having trouble
@@ -40,8 +28,11 @@ secret/embarrassing, etc.
Mentioning other users is great for timely questions or making sure
someone who is not online sees your message.
* Converse informally; there's no need to use titles like "Sir" or "Madam".
* Use gender-neutral language.
* Follow the [community code of conduct](code-of-conduct.html).
* Use
[gender-neutral language](https://en.wikipedia.org/wiki/Gender-neutral_language).
For example, avoid using a pronoun like her or his in sentences like
"Every developer should clean [their] keyboard at least once a week."
* Follow the community [code of conduct](../code-of-conduct.html).
* Participate! Zulip is a friendly and welcoming community, and we
love meeting new people, hearing about what brought them to Zulip,
and getting their feedback. If you're not sure where to start,
@@ -61,6 +52,16 @@ To make the best use of your time, we highly recommend that you
unsubscribe from streams that you aren't interested in, and mute
streams that are only of occasional interest.
## This is a bleeding edge development server
The chat.zulip.org server is frequently deployed off of `master` from
the Zulip Git repository, so please point out anything you notice that
seems wrong! We catch many bugs that escape code review this way.
The chat.zulip.org server is a development and testing server, not a
production service, so don't use it for anything mission-critical,
secret/embarrassing, etc.
## Streams
There are a few streams worth highlighting that are relevant for
@@ -72,7 +73,7 @@ everyone, even non-developers:
* [#feedback](https://chat.zulip.org/#narrow/stream/feedback) is for
posting feedback on Zulip.
* [#design](https://chat.zulip.org/#narrow/stream/design) is where we
discuss the UI design and collect feedback on potential design
discuss UI and feature design and collect feedback on potential design
changes. We love feedback, so don't hesitate to speak up!
* [#user community](https://chat.zulip.org/#narrow/stream/user.20community) is
for Zulip users to discuss their experiences using and adopting Zulip.
@@ -123,45 +124,16 @@ meetings, and they're a great time to stop by and introduce yourself
if you'd like to get involved (though really, any time is, so).
Here are the regular meetings that exist today along with their usual
times (actual times are listed in the linked agenda documents):
times:
* Mobile team on
[#mobile](https://chat.zulip.org/#narrow/stream/mobile), generally
Wednesdays at 10AM Pacific time. [Agendas][mobile-agendas].
Wednesdays at 10AM Pacific time.
* Backend/infrastructure team on
[#backend](https://chat.zulip.org/#narrow/stream/backend), generally
Fridays at 10AM Pacific time. [Agendas][infra-agendas].
Fridays at 10AM Pacific time.
* Bots and integrations team on
[#integrations](https://chat.zulip.org/#narrow/stream/integrations),
generally Fridays at 9AM Pacific time. [Agendas][bots-agendas].
[mobile-agendas]: https://paper.dropbox.com/doc/Zulip-mobile-agendas-nVdb9I7SDiom9hY8Zw8Ge
[infra-agendas]: https://paper.dropbox.com/doc/Zulip-infrastructure-team-agendas-kGyCvF2u2kLcZ1Hzyd9iD
[bots-agendas]: https://paper.dropbox.com/doc/Zulip-bots-and-integrations-agendas-3MR8NAL3fg4tIEpfb5jyx
### Office hours and sprints
We also do project-wide ad-hoc "office hours" and remote sprints
irregularly, about once a month.
Anyone can schedule one: announce it in
[#announce](https://chat.zulip.org/#narrow/stream/announce) and on
[the zulip-devel mailing list](https://groups.google.com/forum/#!forum/zulip-devel)
a few days ahead of time, and ideally, tell
[Sumana](https://chat.zulip.org/#narrow/sender/18-sh) so she can put
it on [the public Zulip meetings calendar][meetings-calendar].
*Office hours* are simply times for us to informally discuss current
global project priorities, find out what questions people have, and so
on. We set them up so people know there'll be more people around at a
particular time to chat. You don't need to RSVP and you don't need to
show up on time or stop conversations when the "hour" stops. They
start in [#general](https://chat.zulip.org/#narrow/stream/general) and
conversations move into other streams and topics as they come up.
*Sprints* are times when Zulip developers get together in chat, and
sometimes in person, to work on related issues at the same time.
[meetings-calendar]: https://calendar.google.com/calendar/embed?src=ktiduof4eoh47lmgcl2qunnc0o@group.calendar.google.com
generally Fridays at 9AM Pacific time.

View File

@@ -103,7 +103,7 @@ this?". Good choices include
change being made. Tests that exclude whole classes of potential
bugs are preferred when possible (e.g., the common test suite
`test_bugdown.py` between the Zulip server's [frontend and backend
Markdown processors](markdown.html), or the `GetEventsTest` test for
Markdown processors](../subsystems/markdown.html), or the `GetEventsTest` test for
buggy race condition handling).
* *Translation.* Make sure that the strings are marked for
@@ -192,11 +192,11 @@ We also strongly recommend reviewers to go through the following resources.
* [Code Review - A consolidation of advice and stuff from the
sinternet](https://gist.github.com/porterjamesj/002fb27dd70df003646df46f15e898de)
article by James J. Porter
* [Zulip Code of Conduct](https://zulip.readthedocs.io/en/latest/code-of-conduct.html)
* [Zulip Code of Conduct](../code-of-conduct.html)
[code-style]: code-style.html
[commit-messages]: version-control.html#commit-messages
[test-writing]: testing.html
[mypy]: mypy.html
[git tool]: git-guide.html#fetch-a-pull-request-and-rebase
[translation]: translating.html
[code-style]: ../contributing/code-style.html
[commit-messages]: ../contributing/version-control.html#commit-messages
[test-writing]: ../testing/testing.html
[mypy]: ../contributing/mypy.html
[git tool]: ../git/zulip-tools.html#fetch-a-pull-request-and-rebase
[translation]: ../translating/translating.html

View File

@@ -163,7 +163,7 @@ Don't use it:
### Translation tags
Remember to
[tag all user-facing strings for translation](translating.html), whether
[tag all user-facing strings for translation](../translating/translating.html), whether
they are in HTML templates or JavaScript editing the HTML (e.g. error
messages).
@@ -217,7 +217,7 @@ code a lot uglier, in which case it's fine to go up to 120 or so.
When calling a function with an anonymous function as an argument, use
this style:
$.get('foo', function (data) {
my_function('foo', function (data) {
var x = ...;
// ...
});
@@ -292,5 +292,5 @@ All significant new features should come with tests. See testing.
### Third party code
See [our docs on dependencies](dependencies.html) for discussion of
See [our docs on dependencies](../subsystems/dependencies.html) for discussion of
rules about integrating third-party projects.

View File

@@ -0,0 +1,17 @@
#######################
Code Contribution Guide
#######################
.. toctree::
:maxdepth: 3
version-control
code-style
mypy
code-reviewing
chat-zulip-org
zulipbot-usage
accessibility
bug-reports
../code-of-conduct
summer-with-zulip

View File

@@ -2,25 +2,30 @@
[mypy](http://mypy-lang.org/) is a compile-time static type checker
for Python, allowing optional, gradual typing of Python code. Zulip
is using mypy's Python 2 compatible syntax for type annotations, which
means that type annotations are written inside comments that start
with `# type: `. Here's a brief example of the mypy syntax we're
was fully annotated with mypy's Python 2 syntax in 2016, before our
migration to Python 3 in late 2017.
As a result, Zulip is in the process of migrating from using mypy's
Python 2 compatible syntax for type annotations (in which type
annotations are written inside comments that start with `# type: `) to
the Python 3 syntax. Here's a brief example of the mypy syntax we're
using in Zulip:
```
user_dict = {} # type: Dict[str, UserProfile]
def get_user(email, realm):
# type: (str, Realm) -> UserProfile
def get_user(email: str, realm: Realm) -> UserProfile:
... # Actual code of the function here
```
You can learn more about it at:
* [The mypy cheat
sheet](https://github.com/python/mypy/blob/master/docs/source/cheat_sheet.rst)
is the best resource for quickly understanding how to write the PEP
484 type annotations used by mypy correctly.
* The
[mypy cheat sheet for Python 3](http://mypy.readthedocs.io/en/latest/cheat_sheet_py3.html)
(and its
[python 2 version](https://github.com/python/mypy/blob/master/docs/source/cheat_sheet.rst))
are the best resources for quickly understanding how to write the
PEP 484 type annotations used by mypy correctly.
* The [Python 2 type annotation syntax spec in PEP
484](https://www.python.org/dev/peps/pep-0484/#suggested-syntax-for-python-2-7-and-straddling-code)

View File

@@ -0,0 +1,285 @@
# How to have an amazing summer with Zulip
The purpose of this doc is to provide advice to GSoC/ZSoC mentors and students
on how to make the summer as successful as possible. It's mandatory reading, in
addition to [Google's
materials](https://developers.google.com/open-source/gsoc/resources/manual).
- Don't focus too much on doing precisely what's in the project proposal or
following precisely that schedule. The goals are for students to learn and to
advance Zulip, not to do in July what we guessed would be the right plan in
March with limited information.
- We probably will want to create a Dropbox Paper document for each student to
keep track of the current version of their project plan, but make sure to
keep GitHub up to date with what issues you're working on.
- Claim issues using zulipbot only when you actually start work on them. And
if someone else fixes an issue you were planning to fix, don't worry about
it! It's great for Zulip that the project was finished, and there's plenty
of issues to work on :D. You can help review their work to build
your expertise in the subsystem you're working on.
- Look for, claim, and fix bugs to help keep Zulip polished. Bugs and polish
are usually more important to users than new features.
- Help test new features! It's fun, and one of the most valuable
ways one can contribute to any software project is finding bugs in
it before they reach a lot of users :).
- Participate and be helpful in the community! Helping a new Zulip server
administrator debug their installation problem or playing with the mobile
app until you can get something to break are great ways to contribute.
- Mentors and students should stay in close contact, both with each other and
the rest of the Zulip community. We recommend the following:
- Daily checkins on #checkins on chat.zulip.org; ideally at some time of day
you can both be online, but when not possible, async is better than nothing!
- We prefer checkins in public streams, since it makes easier for
other contributors to keep track of what everyone else is
working on and share ideas (and helps organization leadership
keep track of progress). Though, of course, feel free to have
much more involved/detailed discussions privately as well.
- If a mentor will be traveling or otherwise offline, mentors should make
sure another mentor is paying attention in the meantime.
- Video calls are great! Mentors should do 1-2 video calls with their students
calls per week, depending on length, schedules, and what's happening.
- Make sure to talk about not just the current project, but also meta-issues
like your development process, where things are getting stuck, skills you
need help learning, and time-saving tricks.
- If you need feedback from the community / decisions made, ask in the
appropriate public stream on [chat.zulip.org](http://chat.zulip.org). Often
someone can provide important context that you need to succeed in your
project.
- Communicate clearly, especially in public places! You'll get much more
useful feedback to a well-written Zulip message or GitHub issue comment than
one that is unclear.
- Be sure to mention any concerns you have with your own work!
- Talk with your mentor about the status of your various projects and where
they're stuck.
- And when you update your PR having addressed a set of review feedback, be
clear about which issues you've resolved (and how!) and
especially any that you haven't yet (this helps code reviewers
use their time well).
- Post screenshots and/or brief videos of UI changes; a picture can be worth
1000 words, especially for verifying whether a design change is
working as intended.
- Use #design and similar forums to get feedback on issues where we need
community consensus on what something should look like or how it
should work.
- Bring up problems early, whether technical or otherwise. If you
find you're stressed about something, mention it your mentor
immediately, so they can help you solve the problem. If you're
stressed about something involving your mentor, bring it up with
an organization admin.
- Join Zulip's GitHub teams that relate to your projects and/or interests, so
that you see new issues and PRs coming in that are relevant to your work.
You can browse the area teams here:
https://github.com/orgs/zulip/teams (You need to be a member of
the Zulip organization to see them; ask Tim for an invite if needed).
- Everyone's goal is to avoid students ending up blocked and feeling stuck.
There are lots of things that students can do (and mentors can help them to)
to avoid this:
- Get really good at using `git rebase -i` to produce a really clean
commit history that's fast to review. We occasionally do workshops
on how to do relatively complex rebases.
- Work on multiple parallelizable projects (or parts of projects) at a time.
This can help avoid being stuck while waiting for something to be reviewed.
- It can help to plan a bit in advance; if your next project requires some
UX decisions to be made with the community, start the conversation a few
days before you need an answer. Or do some preparatory refactoring that
will make the feature easier to complete and can be merged without making
all the decisions.
- Think about how to test your changes.
- Among your various projects, prioritize as follows:
- (1) Fixing regressions you introduced with recently merged work (and other
bugs you notice).
- (2) Responding to code review feedback and fixing your in-flight branches
over starting new work. Unmerged PRs develop painful merge conflicts
pretty quickly, so you'll do much less total work per feature if you're
responsive and try to make it easy for maintainers to merge your commits.
- (3) Do any relevant follow-ups to larger projects you've completed, to
make sure that you've left things better than how you found them.
- (4) Starting on the next project.
- Figure out a QA/testing process that works for you, and be sure to explain
in your PRs how you've tested your changes. Most of the time, in a large
open source project, is spent looking for and fixing regressions, and it
saves everyone time when bugs can be fixed before the code is reviewed, or
barring that, before it's merged.
- Plan (and if when planning fails, rebase) your branches until they are easy
to merge partially (i.e. merging just the first commit will not make Zulip
worse or break the tests). Ideally, when reviewing a branch of yours, the
maintainer should be able to merge the first few commits and leave comments
on the rest. This is by far the most efficient way to do collaborative
development, since one is constantly making progress, we keep branches
small, and developers don't end up reviewing the easily merged parts of a PR
repeatedly.
- Look at Steve Howell's closed PRs to get a feel for how to do this well
for even complex changes.
- Or Eklavya Sharma's (from GSoC 2016) to see a fellow GSoC student doing
this well. (`git log -p` `--``author=Eklavya` is a fast way to skim).
- Team up with other developers close to or in your time zone who are working
on similar areas to trade timely initial code reviews. 75% of the feedback
that the expert maintainers give is bugs/UI problems from clicking around,
lack of tests, or code clarity issues that anyone else in the project should
be able to point out. Doing this well can save a lot of round-trips.
- Help with code review! Reviewing others' changes is one of the best ways to
learn to be a better developer, since you'll both see how others solve
problems and also practice the art of catching bugs in unfamiliar code.
- It's best to start with areas where you know the surrounding code
and expertise, but don't be afraid to open up the code in your
development environment and read it rather than trying to
understand everything from the context GitHub will give you. Even
Tim reads surrounding code much of the time when reviewing things,
and so should you :).
- It's OK to review something that's already been reviewed or just post a
comment on one thing you noticed in a quick look!
- Even posting a comment that you tried a PR and it worked in your development
environment is valuable; you'll save the next reviewer a bit of time
verifying that.
- If you're confused by some code, usually that's because the code is
confusing, not because you're not smart enough. So speak up when you notice
this! Very frequently, this is a sign that we need to write more
docs/comments or (better, if possible!) to make the code more
self-explanatory.
- Plan your approach to larger projects. Usually, when tackling something big,
there's a few phases you want to go through:
- Studying the subsystem, reading its docs, etc., to get a feel for how things
work. Often a good approach is to fix some small bugs in the area to warm
your knowledge up.
- Figure out how you'll test your work feature, both manually and via
automated tests. For some projects, can save a lot of hours by doing a bit
of pre-work on test infrastructure or `populate_db` initial data
to make it easy for both you and code reviewers to get the state
necessary to test a feature.
- Make a plan for how to create a series of small (<100LOC) commits that are
each safely mergable and move you towards your goal. Often this ends up
happening through first doing a hacky attempt to hooking together the
feature, with reading and print statements as part of the effort, to
identify any refactoring needed or tests you want to write to help make sure
your changes won't break anything important as you work. Work out a fast and
consistent test procedure for how to make sure the feature is working as
planned.
- Do the prerequisite test/refactoring/etc. work, and get those changes
merged.
- Build a mergeable version of the feature on top of those refactorings.
Whenever possible, find chunks of complexity that you can separate from the
rest of the project.
- Spend time every week thinking about what could make contributing to Zulip
easier for both yourself and the next generation of Zulip developers. And then
make those ideas reality!
- Have fun! Spending your summer coding on open source is an amazing life
opportunity, and we hope you'll have a blast. With some luck and hard work,
your contributions to the open source world this summer will be something you
can be proud of for the rest of your life.
## What makes a successful summer
Success for the student means a few things, in order of importance:
- Mastery of the skills needed to be a self-sufficient and effective open source
developer. Ideally, by the end of the summer, most of the student's PRs should
go through only a couple rounds of code review before being merged, both in
Zulip and in any future open source projects they choose to join.
Our most successful students end up as the maintainer for one or
more areas within Zulip.
- The student has become a valued member of the Zulip community, and has made
the Zulip community a better place through their efforts. Reviewing PRs,
helping others debug, providing feedback, and finding bugs are all essential
ways to contribute beyond the code in your own project.
- Zulip becoming significantly better in the areas the student focused on. The
area should feel more polished, and have several new major features the
student has implemented. That section of code should be more readable,
better-tested, and have clearer documentation.
## Extra notes for mentors
- You're personally accountable for your student having a successful summer. If
you get swamped and find you don't have enough time, tell the org admins so
that we can make sure someone is covering for you. Yes, it sucks when you
can't do what you signed up for, but even worse is to not tell anyone and thus
prevent the project from finding a replacement.
- Mentors are expected to provide on the mentors stream a **brief report
weekly** on (1) how your students' projects are going, (2) what (if anything)
you're worried about, and (3) what new things you'd like to try this week to
help your student. A great time to do this is after a weekly scheduled call
with your student, while your recollection of the state is fresh.
- Timely feedback is more important than complete feedback, so get a fast
feedback cadence going with your student. It's amazing how useful just 5
minutes of feedback can be. Pay attention to the relative timezones; if you
plan it, you can get several round trips in per day even with big timezone
differences like USA + India.
- What exactly you focus on in your mentorship will vary from week to week and
depend somewhat on what the student needs. It might be any combination of
these things:
- Helping the student plan, chunk, and prioritize their work.
- Manually testing UI changes and helping find bugs.
- Doing code review of your student's work
- Providing early feedback on visual and technical design questions.
- Helping the student figure out how to test their changes.
- Helping the student break their PRs into reviewing chunks.
- Making sure busy maintainers like Tim Abbott provide any necessary feedback
so that the student's project doesn't get stuck.
- Helping with the technical design of projects and making sure they're aware
of useful and relevant reference materials.
- Pair programming with the student to help make sure you share useful tricks.
- Emotional support when things feel like they aren't going well.

View File

@@ -94,7 +94,7 @@ label "travis updates"`, and **@zulipbot** will let you know the build status
### Contributing
If you wish to help develop and contribute to **@zulipbot**, check out the
[zulip/zulipbot](https:/github.com/zulip/zulipbot) repository on GitHub and read
[zulip/zulipbot](https://github.com/zulip/zulipbot) repository on GitHub and read
the project's [contributing
guidelines](https://github.com/zulip/zulipbot/blob/master/CONTRIBUTING.md) for
guidelines](https://github.com/zulip/zulipbot/blob/master/.github/CONTRIBUTING.md) for
more information.

View File

@@ -0,0 +1,12 @@
#######################
Development Environment
#######################
.. toctree::
:maxdepth: 3
Development environment installation <overview>
Recommended setup (Vagrant) <setup-vagrant>
Advanced Setup (non-Vagrant) <setup-advanced>
Using the development environment <using>
Developing remotely <remote>

View File

@@ -82,14 +82,14 @@ And if you've setup the Zulip development environment on a remote
machine, take a look at our tips for
[developing remotely][dev-remote].
[dev-remote]: dev-remote.html
[install-direct]: dev-setup-non-vagrant.html#installing-directly-on-ubuntu
[install-docker]: dev-setup-non-vagrant.html#using-docker-experimental
[install-generic]: dev-setup-non-vagrant.html#installing-manually-on-linux
[install-vagrant]: dev-env-first-time-contributors.html
[dev-remote]: remote.html
[install-direct]: ../development/setup-advanced.html#installing-directly-on-ubuntu
[install-docker]: ../development/setup-advanced.html#using-docker-experimental
[install-generic]: ../development/setup-advanced.html#installing-manually-on-linux
[install-vagrant]: ../development/setup-vagrant.html
[self-install-remote]: #installing-remotely
[self-slow-internet]: #slow-internet-connections
[configure-proxy]: dev-env-first-time-contributors.html#specifying-a-proxy
[using-dev-env]: using-dev-environment.html
[testing]: testing.html
[travis-ci]: git-guide.html#step-3-configure-travis-ci-continuous-integration
[configure-proxy]: ../development/setup-vagrant.html#specifying-a-proxy
[using-dev-env]: using.html
[testing]: ../testing/testing.html
[travis-ci]: ../git/cloning.html#step-3-configure-travis-ci-continuous-integration

View File

@@ -41,10 +41,19 @@ the remote virtual machine, we recommend installing
[Vagrant][install-vagrant] method so you can easily uninstall if you
need to.
The main difference from the standard instructions is that for a
remote development environment, you'll need to run `export
EXTERNAL_HOST=<REMOTE_IP>:9991` in a shell before running `run-dev.py`
(and see also the `--interface=''` option documented below). If your
server has a static IP address, we recommend putting this command in
`~/.bashrc`, so you don't need to remember to run it every time. This
allows you to access Zulip running in your development environment
using a browser on another host.
## Running the development server
Once you have set up the development environment, you can start up the
development instance of Zulip with the following command in the directory where
development server with the following command in the directory where
you cloned Zulip:
```
@@ -56,7 +65,12 @@ navigate to `http://<REMOTE_IP>:9991` and you should see something like
this screenshot of the Zulip development environment:
![Image of Zulip development
environment](images/zulip-dev.png)
environment](../images/zulip-dev.png)
The `--interface=''` command makes the Zulip development environment
accessible from any IP address (in contrast with the more secure
default of only being accessible from localhost, which is great for
developing on your laptop).
You can [port
forward](https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding) using
@@ -87,7 +101,7 @@ don't have a favorite, here are some suggestions:
* [spacemacs](https://github.com/syl20bnr/spacemacs)
* [sublime](https://www.sublimetext.com/)
Next, follow our [Git and GitHub Guide](git-guide.html) to clone and configure
Next, follow our [Git and GitHub Guide](../git/index.html) to clone and configure
your fork of zulip on your local computer.
Once you have cloned your code locally, you can get to work.
@@ -172,13 +186,13 @@ Next, read the following to learn more about developing for Zulip:
* [Using the Development Environment][rtd-using-dev-env]
* [Testing][rtd-testing]
[install-direct]: dev-setup-non-vagrant.html#installing-directly-on-ubuntu
[install-generic]: dev-setup-non-vagrant.html#installing-manually-on-linux
[install-vagrant]: dev-env-first-time-contributors.html
[rtd-git-guide]: git-guide.html
[rtd-using-dev-env]: using-dev-environment.html
[rtd-testing]: testing.html
[install-direct]: ../development/setup-advanced.html#installing-directly-on-ubuntu
[install-generic]: ../development/setup-advanced.html#installing-manually-on-linux
[install-vagrant]: ../development/setup-vagrant.html
[rtd-git-guide]: ../git/index.html
[rtd-using-dev-env]: using.html
[rtd-testing]: ../testing/testing.html
[git-bash]: https://git-for-windows.github.io/
[codeanywhere]: https://codeanywhere.com/
[img-ca-settings]: images/codeanywhere-settings.png
[img-ca-workspace]: images/codeanywhere-workspace.png
[img-ca-settings]: ../images/codeanywhere-settings.png
[img-ca-workspace]: ../images/codeanywhere-workspace.png

View File

@@ -0,0 +1,83 @@
```eval_rst
:orphan:
```
# How to request a remote Zulip development instance
Under specific circumstances, typically during sprints, hackathons, and
Google Code-in, Zulip can provide you with a virtual machine with the
development environment already set up.
The machines (droplets) are being generously provided by
[Digital Ocean](https://www.digitalocean.com/). Thank you Digital Ocean!
## Step 1: Join GitHub and create SSH Keys
To contribute to Zulip and to use a remote Zulip developer instance, you'll
need a GitHub account. If you don't already have one, sign up
[here][github-join].
You'll also need to [create SSH keys and add them to your GitHub
account][github-help-add-ssh-key].
## Step 2: Create a fork of zulip/zulip
Zulip uses a **forked-repo** and **[rebase][gitbook-rebase]-oriented
workflow**. This means that all contributors create a fork of the [Zulip
repository][github-zulip-zulip] they want to contribute to and then submit pull
requests to the upstream repository to have their contributions reviewed and
accepted.
When we create your Zulip dev instance, we'll connect it to your fork of Zulip,
so that needs to exist before you make your request.
While you're logged in to GitHub, navigate to [zulip/zulip][github-zulip-zulip]
and click the **Fork** button. (See [GitHub's help article][github-help-fork]
for further details).
## Step 3: Make request via chat.zulip.org
Now that you have a GitHub account, have added your SSH keys, and forked
zulip/zulip, you are ready to request your Zulip developer instance.
If you haven't already, create an account on https://chat.zulip.org/.
Next, join the [development
help](https://chat.zulip.org/#narrow/stream/development.20help) stream. Create a
new **stream message** with your GitHub username as the **topic** and request
your remote dev instance. **Please make sure you have completed steps 1 and 2
before doing so**. A core developer should reply letting you know they're
working on creating it as soon as they are available to help.
Once requested, it will only take a few minutes to create your instance. You
will be contacted when it is complete and available.
## Next steps
Once your remote dev instance is ready:
- Connect to your server by running
`ssh zulipdev@<username>.zulipdev.org` on the command line
(Terminal for macOS and Linux, Bash for Git on Windows).
- There is no password; your account is configured to use your SSH keys.
- Once you log in, you should see `(zulip-py3-venv) ~$`.
- To start the dev server, `cd zulip` and then run `./tools/run-dev.py`.
- While the dev server is running, you can see the Zulip server in your browser
at http://username.zulipdev.org:9991.
Once you've confirmed you can connect to your remote server, take a look at:
* [developing remotely](../development/remote.html) for tips on using the remote dev
instance, and
* our [Git & GitHub Guide](../git/index.html) to learn how to use Git with Zulip.
Next, read the following to learn more about developing for Zulip:
* [Using the Development Environment](../development/using.html)
* [Testing](../testing/testing.html)
[github-join]: https://github.com/join
[github-help-add-ssh-key]: https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/
[github-zulip-zulip]: https://github.com/zulip/zulip/
[github-help-fork]: https://help.github.com/articles/fork-a-repo/
[gitbook-rebase]: https://git-scm.com/book/en/v2/Git-Branching-Rebasing

View File

@@ -1,15 +1,21 @@
# Zulip development environment setup without Vagrant
# Advanced Setup (non-Vagrant)
Contents:
* [Installing directly on Ubuntu](#installing-directly-on-ubuntu)
* [Installing manually on Linux](#installing-manually-on-linux)
* [Installing directly on cloud9](#installing-on-cloud9)
* [Using Docker (experimental)](#using-docker-experimental)
## Installing directly on Ubuntu
Start by cloning this repository: `git clone
https://github.com/zulip/zulip.git`
Start by [cloning your fork of the Zulip repository][zulip-rtd-git-cloning]
and [connecting the Zulip upstream repository][zulip-rtd-git-connect]:
```
git clone --config pull.rebase https://github.com/YOURUSERNAME/zulip.git
git remote add -f upstream https://github.com/zulip/zulip.git
```
If you'd like to install a Zulip development environment on a computer
that's already running Ubuntu 16.04 Xenial or Ubuntu 14.04 Trusty, you
@@ -28,7 +34,7 @@ development environment).
Once you've done the above setup, you can pick up the [documentation
on using the Zulip development
environment](dev-env-first-time-contributors.html#step-4-developing),
environment](../development/setup-vagrant.html#step-4-developing),
ignoring the parts about `vagrant` (since you're not using it).
## Installing manually on Linux
@@ -61,8 +67,13 @@ Install the following non-Python dependencies:
#### Using the official Ubuntu repositories, PGroonga PPA and `tsearch-extras` deb package:
Start by cloning this repository: `git clone
https://github.com/zulip/zulip.git`
Start by [cloning your fork of the Zulip repository][zulip-rtd-git-cloning]
and [connecting the Zulip upstream repository][zulip-rtd-git-connect]:
```
git clone --config pull.rebase https://github.com/YOURUSERNAME/zulip.git
git remote add -f upstream https://github.com/zulip/zulip.git
```
```
sudo apt-get install closure-compiler libfreetype6-dev libffi-dev \
@@ -78,6 +89,8 @@ sudo apt-get update
sudo apt-get install postgresql-9.3-pgroonga
# On 16.04
sudo apt-get install postgresql-9.5-pgroonga
# On 17.04 or 17.10
sudo apt-get install postgresql-9.6-pgroonga
# If using Debian, follow the instructions here: http://pgroonga.github.io/install/debian.html
@@ -107,7 +120,7 @@ sudo dpkg -i postgresql-9.4-tsearch-extras_0.1_amd64.deb
# If on 16.04 or stretch
wget https://launchpad.net/~tabbott/+archive/ubuntu/zulip/+files/postgresql-9.5-tsearch-extras_0.2_amd64.deb
sudo dpkg -i postgresql-9.5-tsearch-extras_0.2_amd64.deb
sudo dpkg -i postgresql-9.5-tsearch-extras_0.3_amd64.deb
```
Alternatively, you can always build the package from [tsearch-extras
@@ -119,8 +132,13 @@ Now continue with the [All Systems](#all-systems) instructions below.
[zulip-ppa]: https://launchpad.net/~tabbott/+archive/ubuntu/zulip/+packages
Start by cloning this repository: `git clone
https://github.com/zulip/zulip.git`
Start by [cloning your fork of the Zulip repository][zulip-rtd-git-cloning]
and [connecting the Zulip upstream repository][zulip-rtd-git-connect]:
```
git clone --config pull.rebase https://github.com/YOURUSERNAME/zulip.git
git remote add -f upstream https://github.com/zulip/zulip.git
```
```
sudo add-apt-repository ppa:tabbott/zulip
@@ -139,8 +157,13 @@ Now continue with the [All Systems](#all-systems) instructions below.
These instructions are experimental and may have bugs; patches
welcome!
Start by cloning this repository: `git clone
https://github.com/zulip/zulip.git`
Start by [cloning your fork of the Zulip repository][zulip-rtd-git-cloning]
and [connecting the Zulip upstream repository][zulip-rtd-git-connect]:
```
git clone --config pull.rebase https://github.com/YOURUSERNAME/zulip.git
git remote add -f upstream https://github.com/zulip/zulip.git
```
```
sudo dnf install libffi-devel memcached rabbitmq-server \
@@ -156,8 +179,13 @@ Now continue with the [Common to Fedora/CentOS](#common-to-fedora-centos-instruc
These instructions are experimental and may have bugs; patches
welcome!
Start by cloning this repository: `git clone
https://github.com/zulip/zulip.git`
Start by [cloning your fork of the Zulip repository][zulip-rtd-git-cloning]
and [connecting the Zulip upstream repository][zulip-rtd-git-connect]:
```
git clone --config pull.rebase https://github.com/YOURUSERNAME/zulip.git
git remote add -f upstream https://github.com/zulip/zulip.git
```
```
# Add user zulip to the system (not necessary if you configured zulip
@@ -190,7 +218,7 @@ sudo yum install libffi-devel memcached rabbitmq-server openldap-devel \
sudo yum groupinstall "Development Tools"
# clone Zulip's git repo and cd into it
cd && git clone https://github.com/zulip/zulip && cd zulip/
cd && git clone --config pull.rebase https://github.com/zulip/zulip && cd zulip/
## NEEDS TESTING: The next few DB setup items may not be required at all.
# Initialize the postgres db
@@ -214,8 +242,13 @@ Now continue with the [Common to Fedora/CentOS](#common-to-fedora-centos-instruc
These instructions are experimental and may have bugs; patches
welcome!
Start by cloning this repository: `git clone
https://github.com/zulip/zulip.git`
Start by [cloning your fork of the Zulip repository][zulip-rtd-git-cloning]
and [connecting the Zulip upstream repository][zulip-rtd-git-connect]:
```
git clone --config pull.rebase https://github.com/YOURUSERNAME/zulip.git
git remote add -f upstream https://github.com/zulip/zulip.git
```
```
doas pkg_add sudo bash gcc postgresql-server redis rabbitmq \
@@ -248,8 +281,13 @@ Finally continue with the [All Systems](#all-systems) instructions below.
### Common to Fedora/CentOS instructions
Start by cloning this repository: `git clone
https://github.com/zulip/zulip.git`
Start by [cloning your fork of the Zulip repository][zulip-rtd-git-cloning]
and [connecting the Zulip upstream repository][zulip-rtd-git-connect]:
```
git clone --config pull.rebase https://github.com/YOURUSERNAME/zulip.git
git remote add -f upstream https://github.com/zulip/zulip.git
```
```
# Build and install postgres tsearch-extras module
@@ -311,7 +349,7 @@ sudo virtualenv /srv/zulip-py3-venv -p python3 # Create a python3 virtualenv
sudo chown -R `whoami`:`whoami` /srv/zulip-py3-venv
source /srv/zulip-py3-venv/bin/activate # Activate python3 virtualenv
pip install --upgrade pip # upgrade pip itself because older versions have known issues
pip install --no-deps -r requirements/dev_lock.txt # install python packages required for development
pip install --no-deps -r requirements/dev.txt # install python packages required for development
```
Now run these commands:
@@ -323,6 +361,7 @@ sudo mkdir /srv/zulip-emoji-cache
sudo chown -R `whoami`:`whoami` /srv/zulip-emoji-cache
./tools/setup/emoji/build_emoji
./tools/inline-email-css
./tools/generate-custom-icon-webfont
./tools/setup/build_pygments_data
./tools/setup/generate_zulip_bots_static_files
./scripts/setup/generate_secrets.py --development
@@ -365,10 +404,63 @@ proxy in the environment as follows:
yarn config set https-proxy http://proxy_host:port
```
## Installing on cloud9
AWS Cloud9 is a cloud-based integrated development environment (IDE)
that lets you write, run, and debug your code with just a browser. It
includes a code editor, debugger, and terminal.
This section documents how to setup the Zulip development environment
in a cloud9 workspace. If you don't have an existing cloud9 account,
you can sign up [here](https://aws.amazon.com/cloud9/).
* Create a Workspace, and select the blank template.
* Resize the workspace to be 1GB of memory and 4GB of disk
space. (This is under free limit for both the old Cloud9 and the AWS
Free Tier).
* Clone the zulip repo: `git clone --config pull.rebase
https://github.com/<your-username>/zulip.git`
* Restart rabbitmq-server since its broken on cloud9: `sudo service
rabbitmq-server restart`.
* And run provision `cd zulip && ./tools/provision`, once this is done.
* Activate the zulip virtual environment by `source
/srv/zulip-py3-venv/bin/activate` or by opening a new terminal.
#### Install zulip-cloud9
There's an NPM package, `zulip-cloud9`, that provides a wrapper around
the Zulip development server for use in the Cloud9 environment.
Note: `npm i -g zulip-cloud9` does not work in zulip's virtual
environment. Although by default, any packages installed in workspace
folder (i.e. the top level folder) are added to `$PATH`.
```bash
cd .. # switch to workspace folder if you are in zulip directory
npm i zulip-cloud9
zulip-dev start # to start the development server
```
If you get error of the form `bash: cannot find command zulip-dev`,
you need to start a new terminal.
Your development server would be running at
`https://<workspace-name>-<username>.c9users.io` on port 8080. You
dont need to add `:8080` to your url, since the cloud9 proxy should
automatically forward the connection. You might want to visit
[zulip-cloud9 repo](https://github.com/cPhost/zulip-cloud9) and it's
[wiki](https://github.com/cPhost/zulip-cloud9/wiki) for more info on
how to use zulip-cloud9 package.
## Using Docker (experimental)
Start by cloning this repository: `git clone
https://github.com/zulip/zulip.git`
Start by [cloning your fork of the Zulip repository][zulip-rtd-git-cloning]
and [connecting the Zulip upstream repository][zulip-rtd-git-connect]:
```
git clone --config pull.rebase https://github.com/YOURUSERNAME/zulip.git
git remote add -f upstream https://github.com/zulip/zulip.git
```
The docker instructions for development are experimental, so they may
have bugs. If you try them and run into any issues, please report
@@ -379,8 +471,8 @@ First, you need to install Docker in your development machine
following the [instructions][docker-install]. Some other interesting
links for somebody new in Docker are:
* [Get Started](https://docs.docker.com/engine/installation/linux/)
* [Understand the architecture](https://docs.docker.com/engine/understanding-docker/)
* [Get Started](https://docs.docker.com/get-started/)
* [Understand the architecture](https://docs.docker.com/engine/docker-overview/)
* [Docker run reference](https://docs.docker.com/engine/reference/run/)
* [Dockerfile reference](https://docs.docker.com/engine/reference/builder/)
@@ -411,7 +503,7 @@ docker run -itv $(pwd):/srv/zulip -p 9991:9991 user/zulipdev:v2 \
```
You'll want to
[read the guide for Zulip development](dev-env-first-time-contributors.html#step-4-developing)
[read the guide for Zulip development](../development/setup-vagrant.html#step-4-developing)
to understand how to use the Zulip development. Note that
`start-dockers` automatically runs `tools/run-dev.py` inside the
container; you can then visit http://localhost:9991 to connect to your
@@ -463,3 +555,6 @@ the results in your browser.
Currently, the Docker workflow is substantially less convenient than
the Vagrant workflow and less documented; please contribute to this
guide and the Docker tooling if you are using Docker to develop Zulip!
[zulip-rtd-git-cloning]: ../git/cloning.html#step-1b-clone-to-your-machine
[zulip-rtd-git-connect]: ../git/cloning.html#step-1c-connect-your-fork-to-zulip-upstream

View File

@@ -24,7 +24,7 @@ environment,** check
[Troubleshooting and Common Errors](#troubleshooting-and-common-errors). If
that doesn't help, please visit
[#provision help](https://chat.zulip.org/#narrow/stream/provision.20help)
in the [Zulip development community server](chat-zulip-org.html) for
in the [Zulip development community server](../contributing/chat-zulip-org.html) for
real-time help, send a note to the
[Zulip-devel Google group](https://groups.google.com/forum/#!forum/zulip-devel)
or [file an issue](https://github.com/zulip/zulip/issues).
@@ -46,9 +46,9 @@ proxy](#specifying-a-proxy) if you need a proxy to access the internet.)
- **All**: 2GB available RAM, Active broadband internet connection, [GitHub account][set-up-git].
- **macOS**: macOS (10.11 El Capitan or 10.12 Sierra recommended),
Git, VirtualBox (version [5.1.8][vbox-dl-macos]
recommended -- we find it's more stable than more recent versions),
- **macOS**: macOS (10.11 El Capitan or newer recommended), Git,
VirtualBox (version [5.2.6][vbox-dl-macos] recommended -- we find
it's more stable than more recent versions),
[Vagrant][vagrant-dl-macos].
- **Ubuntu**: 14.04 64-bit or 16.04 64-bit, Git, [Vagrant][vagrant-dl-deb], lxc.
- or **Debian**: 9.0 "stretch" 64-bit
@@ -82,8 +82,12 @@ Jump to:
#### macOS
1. Install [Vagrant][vagrant-dl-macos] (1.8.4-1.8.6, do not use 1.8.7).
2. Install [VirtualBox][vbox-dl-macos] (5.1.8).
0. If you are running MacOS High Sierra, make sure you are not running
a version with a
[buggy NFS implementation](#importerror-no-module-named-on-macos-during-vagrant-provisioning).
Versions 10.13.2 and above have the bug fixed.
1. Install [Vagrant][vagrant-dl-macos] (2.0.2).
2. Install [VirtualBox][vbox-dl-macos] (5.2.6).
(For a non-free option, but better performance, you can also use [VMWare
Fusion][vmware-fusion-dl] with the [VMWare Fusion Vagrant
@@ -100,7 +104,7 @@ after which you can jump to [Step 2: Get Zulip Code](#step-2-get-zulip-code):
```
sudo apt-get -y purge vagrant && \
wget https://releases.hashicorp.com/vagrant/1.8.6/vagrant_1.8.6_x86_64.deb && \
wget https://releases.hashicorp.com/vagrant/2.0.2/vagrant_2.0.2_x86_64.deb && \
sudo dpkg -i vagrant*.deb && \
sudo apt-get -y install build-essential git ruby lxc lxc-templates cgroup-lite redir && \
vagrant plugin install vagrant-lxc && \
@@ -122,11 +126,11 @@ christie@ubuntu-desktop:~
$ sudo apt-get purge vagrant
```
Now download and install the .deb package for [Vagrant 1.8.6][vagrant-dl-deb]:
Now download and install the .deb package for [Vagrant 2.0.2][vagrant-dl-deb]:
```
christie@ubuntu-desktop:~
$ wget https://releases.hashicorp.com/vagrant/1.8.6/vagrant_1.8.6_x86_64.deb
$ wget https://releases.hashicorp.com/vagrant/2.0.2/vagrant_2.0.2_x86_64.deb
christie@ubuntu-desktop:~
$ sudo dpkg -i vagrant*.deb
@@ -170,35 +174,36 @@ Now you are ready for [Step 2: Get Zulip Code.](#step-2-get-zulip-code)
#### Debian
The setup for Debian 9.0 "stretch" is just like [for Ubuntu 16.04](#ubuntu),
with one difference.
The setup for Debian 9.0 "stretch" is very similar to that
[for Ubuntu 16.04 above](#ubuntu). Follow those instructions,
except with the following differences:
If you're in a hurry, you can copy and paste the following into your terminal
after which you can jump to [Step 2: Get Zulip Code](#step-2-get-zulip-code):
**Apt package list**. In "2. Install remaining dependencies", the
command to install the dependencies is a bit shorter:
```
sudo apt-get -y purge vagrant && \
wget https://releases.hashicorp.com/vagrant/1.8.6/vagrant_1.8.6_x86_64.deb && \
sudo dpkg -i vagrant*.deb && \
sudo apt-get -y install build-essential git ruby lxc redir && \
vagrant plugin install vagrant-lxc && \
vagrant lxc sudoers
christie@ubuntu-desktop:~
$ sudo apt-get install build-essential git ruby lxc redir
```
For a step-by-step explanation, follow the [Ubuntu instructions above](#ubuntu),
with the following difference: in "2. Install remaining dependencies", the
command is
**Set up LXC networking**. After completing "2. Install remaining
dependencies", you will have to set up networking for LXC containers,
because Debian's packaging for LXC does not ship any default
network setup for them. You can do this by
[following the steps][lxc-networking-quickstart] outlined in
[Debian's LXC docs](https://wiki.debian.org/LXC#network_setup).
```
sudo apt-get install build-essential git ruby lxc redir
```
[lxc-networking-quickstart]: https://wiki.debian.org/LXC#Minimal_changes_to_set_up_networking_for_LXC_for_Debian_.2BIBw-stretch.2BIB0_.28testing.29
Then return to the next step in the Ubuntu instructions above. After
finishing those steps, you will be ready for
[Step 2: Get Zulip Code](#step-2-get-zulip-code).
#### Windows 10
1. Install [Git for Windows][git-bash], which installs *Git BASH*.
2. Install [VirtualBox][vbox-dl] (version >= 5.1.6).
3. Install [Vagrant][vagrant-dl-win] (version 1.8.4-1.8.6, do not use 1.8.7).
2. Install [VirtualBox][vbox-dl] (version == 5.2.6).
3. Install [Vagrant][vagrant-dl-win] (version 2.0.2, do not use 1.8.7).
(Note: While *Git BASH* is recommended, you may also use [Cygwin][cygwin-dl].
If you do, make sure to **install default required packages** along with
@@ -270,9 +275,13 @@ Now you are ready for [Step 2: Get Zulip Code.](#step-2-get-zulip-code)
do this.
2. Open Terminal (macOS/Ubuntu) or Git BASH (Windows; must
**run as an Administrator**).
3. In Terminal/Git BASH, clone your fork:
3. In Terminal/Git BASH,
[clone your fork of the Zulip repository](../git/cloning.html#step-1b-clone-to-your-machine)
and [connect the Zulip upstream repository](../git/cloning.html#step-1c-connect-your-fork-to-zulip-upstream):
```
git clone git@github.com:YOURUSERNAME/zulip.git
git clone --config pull.rebase git@github.com:YOURUSERNAME/zulip.git
git remote add -f upstream https://github.com/zulip/zulip.git
```
This will create a 'zulip' directory and download the Zulip code into it.
@@ -282,7 +291,7 @@ something like:
```
christie@win10 ~
$ git clone git@github.com:YOURUSERNAME/zulip.git
$ git clone --config pull.rebase git@github.com:YOURUSERNAME/zulip.git
Cloning into 'zulip'...
remote: Counting objects: 73571, done.
remote: Compressing objects: 100% (2/2), done.
@@ -321,7 +330,7 @@ does the following:
downloads all required dependencies, sets up the python environment for
the Zulip development server, and initializes a default test
database. We call this process "provisioning", and it is documented
in some detail in our [dependencies documentation](dependencies.html).
in some detail in our [dependencies documentation](../subsystems/dependencies.html).
You will need an active internet connection during the entire
process. (See [Specifying a proxy](#specifying-a-proxy) if you need a
@@ -333,7 +342,7 @@ documented in the
[Troubleshooting and Common Errors](#troubleshooting-and-common-errors)
section. If that doesn't help, please visit
[#provision help](https://chat.zulip.org/#narrow/stream/provision.20help)
in the [Zulip development community server](chat-zulip-org.html) for
in the [Zulip development community server](../contributing/chat-zulip-org.html) for
real-time help.
On Windows, you will see `The system cannot find the path specified.` message
@@ -427,7 +436,7 @@ navigating to <http://localhost:9991/> in the browser on your main machine.
You should see something like this:
![Image of Zulip development environment](images/zulip-dev.png)
![Image of Zulip development environment](../images/zulip-dev.png)
The Zulip server will continue to run and send output to the terminal window.
When you navigate to Zulip in your browser, check your terminal and you
@@ -470,7 +479,7 @@ It's good to have the terminal running `run-dev.py` up as you work since error
messages including tracebacks along with every backend request will be printed
there.
See [Logging](logging.html) for further details on the run-dev.py console
See [Logging](../subsystems/logging.html) for further details on the run-dev.py console
output.
#### Committing and pushing changes with git
@@ -499,7 +508,7 @@ After provisioning, you'll want to
If you run into any trouble, the
[#provision help](https://chat.zulip.org/#narrow/stream/provision.20help)
in the [Zulip development community server](chat-zulip-org.html) for
in the [Zulip development community server](../contributing/chat-zulip-org.html) for
is a great place to ask for help.
#### Rebuilding the development environment
@@ -595,7 +604,7 @@ If these solutions aren't working for you or you encounter an issue not
documented below, there are a few ways to get further help:
* Ask in [#provision help](https://chat.zulip.org/#narrow/stream/provision.20help)
in the [Zulip development community server](chat-zulip-org.html),
in the [Zulip development community server](../contributing/chat-zulip-org.html),
* send a note to the [Zulip-devel Google
group](https://groups.google.com/forum/#!forum/zulip-devel), or
* [File an issue](https://github.com/zulip/zulip/issues).
@@ -653,8 +662,8 @@ macOS.
On **macOS** this error is most likely to occur with Vagrant version 1.8.7 and
is a [known issue](https://github.com/mitchellh/vagrant/issues/7997).
The solution is to downgrade Vagrant to version 1.8.6 ([available
here](https://releases.hashicorp.com/vagrant/1.8.6/)), or to use your system's
The solution is to downgrade Vagrant to version 2.0.2 ([available
here](https://releases.hashicorp.com/vagrant/2.0.2/)), or to use your system's
version of `curl` instead of the one that ships with Vagrant:
```
@@ -713,6 +722,33 @@ This is equivalent of running a halt followed by an up (aka rebooting
the guest). After this, you can do `vagrant provision` and `vagrant
ssh`.
#### ssl read error
If you receive the following error while running `vagrant up`:
```
SSL read: error:00000000:lib(0):func(0):reason(0), errno 104
```
It means that either your network connection is unstable and/or very
slow. To resolve it, run `vagrant up` until it works (possibly on a
better network connection).
#### Unmet dependencies error
When running `vagrant up` or `provision`, if you see the following error:
```
==> default: E:unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
```
It means that your local apt repository has been corrupted, which can
usually be resolved by executing the command:
```
apt-get -f install
```
#### ssh connection closed by remote host
On running `vagrant ssh`, if you see the following error:
@@ -878,7 +914,7 @@ Likely causes are:
1. Networking issues
2. Insufficient RAM. Check whether you've allotted at least two
gigabytes of RAM, which is the minimum Zulip
[requires](dev-env-first-time-contributors.html#requirements). If
[requires](../development/setup-vagrant.html#requirements). If
not, go to your VM settings and increase the RAM, then restart
the VM.
@@ -956,10 +992,58 @@ christie@xenial:~
$ sudo patch --directory /usr/lib/ruby/vendor_ruby/vagrant < vagrant-plugin.patch
patching file bundler.rb
```
#### VT-X unavailability error
Users who are unable to do "vagrant up" due to a VT-X unavailability error need to disable "Hyper-V" to get it to work.
#### Permissions errors when running the test suite in LXC
See ["Possible testing issues"](testing.html#possible-testing-issues).
See ["Possible testing issues"](../testing/testing.html#possible-testing-issues).
#### ImportError: No module named '...' on MacOS during Vagrant provisioning
If you see following error (or similar) when you try to provision
Vagrant environment by `vagrant provision` (or during first run
`vagrant up`):
```
default: ImportError: No module named 'zerver.lib.emoji'
default: Error running a subcommand of ./lib/provision.py: tools/do-destroy-rebuild-database
default: Actual error output for the subcommand is just above this.
default: Traceback (most recent call last):
default: File "./lib/provision.py", line 413, in <module>
default: sys.exit(main(options))
default: File "./lib/provision.py", line 349, in main
default: run(["tools/do-destroy-rebuild-database"])
default: File "/srv/zulip/scripts/lib/zulip_tools.py", line 163, in run
default: subprocess.check_call(args, **kwargs)
default: File "/usr/lib/python3.4/subprocess.py", line 561, in check_call
default: raise CalledProcessError(retcode, cmd)
default: subprocess.CalledProcessError: Command '['tools/do-destroy-rebuild-database']' returned non-zero exit status 1
default:
default: Provisioning failed!
default: * Look at the traceback(s) above to find more about the errors.
default: * Resolve the errors or get help on chat.
default: * If you can fix this yourself, you can re-run tools/provision at any time.
default: * Logs are here: zulip/var/log/provision.log
default:
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
```
This error is caused by a bug in the MacOS NFS file syncing
implementation (Zulip uses Vagrant's NFS feature for syncing files on
MacOS). In early versions of MacOS High Sierra, files present in the
directory on the host machine would appear to not be present in the
Vagrant guest (e.g. in the exception above, `zerver/lib/emoji.py` is
missing). This bug is fixed in MacOS High Sierra 10.13.2 and above,
so the fix is to upgrade to a version of MacOS with a working NFS
implementation.
You can read more about this
[here](https://github.com/hashicorp/vagrant/issues/8788).
### Specifying a proxy
@@ -1012,22 +1096,22 @@ for the IP address that means any IP address can connect to your development ser
[cygwin-dl]: http://cygwin.com/
[vagrant-dl]: https://www.vagrantup.com/downloads.html
[vagrant-dl-win]: https://releases.hashicorp.com/vagrant/1.8.6/vagrant_1.8.6.msi
[vagrant-dl-macos]: https://releases.hashicorp.com/vagrant/1.8.6/vagrant_1.8.6.dmg
[vagrant-dl-deb]: https://releases.hashicorp.com/vagrant/1.8.6/vagrant_1.8.6_x86_64.deb
[vagrant-dl-win]: https://releases.hashicorp.com/vagrant/2.0.2/vagrant_2.0.2_x86_64.msi
[vagrant-dl-macos]: https://releases.hashicorp.com/vagrant/2.0.2/vagrant_2.0.2_x86_64.dmg
[vagrant-dl-deb]: https://releases.hashicorp.com/vagrant/2.0.2/vagrant_2.0.2_x86_64.deb
[vagrant-lxc]: https://github.com/fgrehm/vagrant-lxc
[vbox-dl]: https://www.virtualbox.org/wiki/Downloads
[vbox-dl-macos]: http://download.virtualbox.org/virtualbox/5.1.8/VirtualBox-5.1.8-111374-OSX.dmg
[vbox-dl-macos]: https://download.virtualbox.org/virtualbox/5.2.6/VirtualBox-5.2.6-120293-OSX.dmg
[vmware-fusion-dl]: http://www.vmware.com/products/fusion.html
[vagrant-vmware-fusion-dl]: https://www.vagrantup.com/vmware/
[avoiding-sudo]: https://github.com/fgrehm/vagrant-lxc#avoiding-sudo-passwords
[install-advanced]: dev-setup-non-vagrant.html
[install-advanced]: ../development/setup-advanced.html
[lxc-sf]: https://github.com/fgrehm/vagrant-lxc/wiki/FAQ#help-my-shared-folders-have-the-wrong-owner
[rtd-git-guide]: git-guide.html
[rtd-testing]: testing.html
[rtd-using-dev-env]: using-dev-environment.html
[rtd-dev-remote]: dev-remote.html
[rtd-git-guide]: ../git/index.html
[rtd-testing]: ../testing/testing.html
[rtd-using-dev-env]: using.html
[rtd-dev-remote]: remote.html
[git-bash]: https://git-for-windows.github.io/
[bash-admin-setup]: https://superuser.com/questions/1002262/run-applications-as-administrator-by-default-in-windows-10
[set-up-git]: git-guide.html#set-up-git
[travis-ci]: git-guide.html#step-3-configure-travis-ci-continuous-integration
[set-up-git]: ../git/setup.html
[travis-ci]: ../git/cloning.html#step-3-configure-travis-ci-continuous-integration

View File

@@ -51,5 +51,5 @@ restart if it crashes, and `upgrade-zulip` will take care of running
migrations and then cleanly restaring the server for you).
[django-runserver]: https://docs.djangoproject.com/en/1.8/ref/django-admin/#runserver-port-or-address-port
[new-feature-tutorial]: new-feature-tutorial.html
[testing-docs]: testing.html
[new-feature-tutorial]: ../tutorials/new-feature-tutorial.html
[testing-docs]: ../testing/testing.html

View File

@@ -1,92 +0,0 @@
# Emoji
Emoji seem like a simple idea, but there's actually a ton of
complexity that goes into an effective emoji implementation. This
document discusses a number of these issues.
Currently, Zulip uses the Noto (Android) emoji set, but we are close
to being able to support the user choosing which emoji set they want
to use.
## Emoji codes
The Unicode standard has various ranges of characters set aside for
emoji. So you can put emoji in your terminal using actual unicode
characters like 😀 and 👍. If you paste those into Zulip, Zulip will
render them as the corresponding emoji image.
However, the Unicode committee did not standardize on a set of
human-readable names for emoji. So, for example, when using the
popular `:` based style for entering emoji from the keyboard, we have
to decide whether to use `:angry:` or `:angry_face:` to represent an
angry face. Different products use different approaches, but for
purposes like emoji pickers or autocomplete, you definitely want to
pick exactly one of these names, since otherwise users will always be
seeing duplicates of a given emoji next to each other.
Picking which emoji name to use is surprisingly complicated! Zulip
has a nice library, `tools/setup/emoji/emoji_setup_utils.py`, which we
use to make these decisions systematically, with a relatively small
list of hand-coded exceptions.
### Custom emoji
Zulip supports custom user-uploaded emoji. We manage those by having
the name of the emoji be its "emoji code", and using an emoji_type
field to keep track of it. We are in the progress of migrating Zulip
to refer to these emoji only by ID, which is a requirement for being
able to support deprecating old realm emoji in a sensible way.
## Tooling
We use the [iamcal emoji data package][iamcal] to provide sprite
sheets and individual images for our emoji, as well as a data set of
emoji categories, code points, names, etc. The sprite sheets are used
by the Zulip webapp to display emoji in messages, emoji reactions,
etc. However, we can't use the sprite sheets in some contexts, such
as missed-message and digestemails, that need to have self-contained
assets. For those, we use individual emoji files under
`static/generated/emoji`. The structure of that repository contains
both files named after the unicode representation of emoji (as actual
image files) as well as symlinks pointing to those emoji.
We need to maintain those both for the names used in the iamcal emoji
data set as well as our old emoji data set (`emoji_map.json`). Zulip
has a tool, `tools/setup/emoji/build_emoji`, that combines the
`emoji.json` file from iamcal with the old `emoji-map.json` data set
to construct the various symlink farms and output files described
below that support our emoji experience.
The `build_emoji` tool generates the set of files under
`static/generated/emoji` (or really, it generates the
`/srv/zulip-emoji-cache/<sha1>/emoji` tree, and
`static/generated/emoji` is a symlink to that tree; we do this in
order to cache old versions to make provisioning and production
deployments super fast in the common case that we haven't changed the
emoji tooling). See [our dependencies document](dependencies.html)
for more details on this strategy.
The emoji tree generated by this process contains several import elements:
* `emoji_codes.js`: A set of mappings used by the Zulip frontend to
understand what unicode emoji exist and what their shortnames are,
used for autocomplete, emoji pickers, etc. This has been
deduplicated using the logic in
`tools/setup/emoji/emoji_setup_utils.py` to generally only have
`:angry:` and not also `:angry_face:`, since having both is ugly and
pointless for purposes like autocomplete and emoji pickers.
* `images/emoji/unicode/*.png`: A farm of emoji
* `images/emoji/*.png`: A farm of symlinks from emoji names to the
`images/emoji/unicode/` tree. This is used to serve individual emoji
images, as well as for the
[backend markdown processor](markdown.html) to know which emoji
names exist and what unicode emoji / images they map to. In this
tree, we currently include all of the emoji in `emoji-map.json`;
this means that if you send `:angry_face:`, it won't autocomplete,
but will still work (but not in previews).
* Some CSS and PNGs for the emoji spritesheets, used in Zulip for
emoji pickers where we would otherwise need to download over 1000 of
individual emoji images (which would cause a browser performance
problem). We have multiple spritesheets: one for each emoji
provider that we support (Google, Twitter, EmojiOne, etc.).
[iamcal]: https://github.com/iamcal/emoji-data

View File

@@ -1,54 +0,0 @@
# Git Cheat Sheet (Detailed)
See also
[fixing commits][fix-commit]
Commands:
- add
- `git add foo.py`: add `foo.py` to the staging area
- `git add foo.py bar.py`: add `foo.py` AND `bar.py` to the staging area
- checkout
- `git checkout -b new-branch-name`: create branch `new-branch-name` and switch/checkout to that new branch
- `git checkout master`: switch to your `master` branch
- `git checkout old-branch-name`: switch to an existing branch `old-branch-name`
- commit
- `git commit --amend`: changing the last commit message. Read more [here][fix-commit]
- config
- `git config --global core.editor nano`: set core editor to `nano` (you can set this to `vim` or others)
- `git config --global core.symlinks true`: allow symbolic links
- diff
- `git diff`: display the changes you have made to all files
- `git diff --cached`: display the changes you have made to staged files
- `git diff HEAD~2..`: display the 2 most recent changes you have made to files
- fetch
- `git fetch origin`: fetch origin repository
- `git fetch upstream`: fetch upstream repository
- grep
- `git grep update_unread_counts -- '*.js'`: search all files (ending in `.js`) for `update_unread_counts`
- log
- `git log`: show commit logs
- pull
- **do not use for Zulip**
- push
- `git push origin +branch-name`: push your commits to your origin repository
- rebase
- `git rebase -i HEAD~3`: interactive rebasing current branch with first three items on HEAD
- `git rebase -i master`: interactive rebasing current branch with master branch
- `git rebase upstream/master`: rebasing current branch with master branch from upstream repository
- reflog
- `git reflog | head -10`: manage reference logs for the past 10 commits
- remote
- `git remote -v`: display your origin and upstream repositories
- reset
- `git reset HEAD~2`: reset two most recent commits
- rm
- `git rm oops.txt`: remove `oops.txt`
- show
- `git show HEAD`: display most recent commit
- `git show HEAD~~~`: display third most recent commit
- `git show master`: display most recent commit on `master`
- status
- `git status`: show the working tree status, unstaged and staged files
[fix-commit]: fixing-commits.html

View File

@@ -1,52 +0,0 @@
# Git Cheat Sheet
See also [fixing commits][fix-commit]
Commands:
- add
- `git add foo.py`
- checkout
- `git checkout -b new-branch-name`
- `git checkout master`
- `git checkout old-branch-name`
- commit
- `git commit --amend`
- config
- `git config --global core.editor nano`
- `git config --global core.symlinks true`
- diff
- `git diff`
- `git diff --cached`
- `git diff HEAD~2..`
- fetch
- `git fetch origin`
- `git fetch upstream`
- grep
- `git grep update_unread_counts -- '*.js'`
- log
- `git log`
- pull
- **do not use for Zulip**
- push
- `git push origin +branch-name`
- rebase
- `git rebase -i HEAD~3`
- `git rebase -i master`
- `git rebase upstream/master`
- reflog
- `git reflog | head -10`
- remote
- `git remote -v`
- reset
- `git reset HEAD~2`
- rm
- `git rm oops.txt`
- show
- `git show HEAD`
- `git show HEAD~~~`
- `git show master`
- status
- `git status`
[fix-commit]: fixing-commits.html

File diff suppressed because it is too large Load Diff

116
docs/git/cheat-sheet.md Normal file
View File

@@ -0,0 +1,116 @@
# Git Cheat Sheet
See also [fixing commits][fix-commit]
## Common Commands
- add
- `git add foo.py`
- checkout
- `git checkout -b new-branch-name`
- `git checkout master`
- `git checkout old-branch-name`
- commit
- `git commit -m "topic: Commit message title."`
- `git commit --amend`: Modify the previous commit.
- config
- `git config --global core.editor nano`
- `git config --global core.symlinks true`
- diff
- `git diff`
- `git diff --cached`
- `git diff HEAD~2..`
- fetch
- `git fetch origin`
- `git fetch upstream`
- grep
- `git grep update_unread_counts -- '*.js'`
- log
- `git log`
- pull
- `git pull --rebase`: **Use this**. Zulip uses a [rebase oriented workflow][git-overview].
- `git pull` (with no options): Will either create a merge commit
(which you don't want) or do the same thing as `git pull --rebase`,
depending on [whether you're configured Git properly][git-clone-config]
- push
- `git push origin +branch-name`
- rebase
- `git rebase -i HEAD~3`
- `git rebase -i master`
- `git rebase upstream/master`
- reflog
- `git reflog | head -10`
- remote
- `git remote -v`
- reset
- `git reset HEAD~2`
- rm
- `git rm oops.txt`
- show
- `git show HEAD`
- `git show HEAD~~~`
- `git show master`
- status
- `git status`
## Detailed Cheat Sheet
- add
- `git add foo.py`: add `foo.py` to the staging area
- `git add foo.py bar.py`: add `foo.py` AND `bar.py` to the staging area
- `git add -u`: Adds all tracked files to the staging area.
- checkout
- `git checkout -b new-branch-name`: create branch `new-branch-name` and switch/checkout to that new branch
- `git checkout master`: switch to your `master` branch
- `git checkout old-branch-name`: switch to an existing branch `old-branch-name`
- commit
- `git commit -m "commit message"`: It is recommended to type a
multiline commit message, however.
- `git commit`: Opens your default text editor to write a commit message.
- `git commit --amend`: changing the last commit message. Read more [here][fix-commit]
- config
- `git config --global core.editor nano`: set core editor to `nano` (you can set this to `vim` or others)
- `git config --global core.symlinks true`: allow symbolic links
- diff
- `git diff`: display the changes you have made to all files
- `git diff --cached`: display the changes you have made to staged files
- `git diff HEAD~2..`: display the 2 most recent changes you have made to files
- fetch
- `git fetch origin`: fetch origin repository
- `git fetch upstream`: fetch upstream repository
- grep
- `git grep update_unread_counts -- '*.js'`: search all files (ending in `.js`) for `update_unread_counts`
- log
- `git log`: show commit logs
- `git log --oneline | head`: To quickly see the latest ten commits on a branch.
- pull
- `git pull --rebase`: rebase your changes on top of master.
- `git pull` (with no options): Will either create a merge commit
(which you don't want) or do the same thing as `git pull --rebase`,
depending on [whether you're configured Git properly][git-clone-config]
- push
- `git push origin branch-name`: push you commits to the origin repository *only if* there are no conflicts.
Use this when collaborating with others to prevent overwriting their work.
- `git push origin +branch-name`: force push your commits to your origin repository.
- rebase
- `git rebase -i HEAD~3`: interactive rebasing current branch with first three items on HEAD
- `git rebase -i master`: interactive rebasing current branch with master branch
- `git rebase upstream/master`: rebasing current branch with master branch from upstream repository
- reflog
- `git reflog | head -10`: manage reference logs for the past 10 commits
- remote
- `git remote -v`: display your origin and upstream repositories
- reset
- `git reset HEAD~2`: reset two most recent commits
- rm
- `git rm oops.txt`: remove `oops.txt`
- show
- `git show HEAD`: display most recent commit
- `git show HEAD~~~`: display third most recent commit
- `git show master`: display most recent commit on `master`
- status
- `git status`: show the working tree status, unstaged and staged files
[fix-commit]: fixing-commits.html
[git-config-clone]: cloning.html#step-1b-clone-to-your-machine
[git-overview]: overview.html

141
docs/git/cloning.md Normal file
View File

@@ -0,0 +1,141 @@
# Get Zulip code
Zulip uses a **forked-repo** and **[rebase][gitbook-rebase]-oriented
workflow.**. This means that all contributors create a fork of the [Zulip
repository][github-zulip] they want to contribute to and then submit pull
requests to the upstream repository to have their contributions reviewed and
accepted. We also recommend you work on feature branches.
## Step 1a: Create your fork
The following steps you'll only need to do the first time you setup a machine
for contributing to a given Zulip project. You'll need to repeat the steps for
any additional Zulip projects ([list][github-zulip]) that you work on.
The first thing you'll want to do to contribute to Zulip is fork ([see
how][github-help-fork]) the appropriate [Zulip repository][github-zulip]. For
the main server app, this is [zulip/zulip][github-zulip-zulip].
## Step 1b: Clone to your machine
Next, clone your fork to your local machine:
```
$ git clone --config pull.rebase git@github.com:christi3k/zulip.git
Cloning into 'zulip'
remote: Counting objects: 86768, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 86768 (delta 5), reused 1 (delta 1), pack-reused 86752
Receiving objects: 100% (86768/86768), 112.96 MiB | 523.00 KiB/s, done.
Resolving deltas: 100% (61106/61106), done.
Checking connectivity... done.
```
(The `--config pull.rebase` option configures Git so that `git pull`
will behave like `git pull --rebase` by default. Using `git pull
--rebase` to update your changes to resolve merge conflicts is
expected by essentially all of open source projects, including Zulip.
You can also set that option after cloning using `git config --add
pull.rebase true`, or just be careful to always run `git pull
--rebase`, never `git pull`).
Note: If you receive an error while cloning, you may not have [added your ssh
key to GitHub][github-help-add-ssh-key].
Once the repository is cloned, we recommend running
[setup-git-repo][zulip-rtd-tools-setup] to install Zulip's pre-commit
hook which runs the Zulip linters on the changed files when you
commit.
## Step 1c: Connect your fork to Zulip upstream
Next you'll want to [configure an upstream remote
repository][github-help-conf-remote] for your fork of Zulip. This will allow
you to [sync changes][github-help-sync-fork] from the main project back into
your fork.
First, show the currently configured remote repository:
```
$ git remote -v
origin git@github.com:YOUR_USERNAME/zulip.git (fetch)
origin git@github.com:YOUR_USERNAME/zulip.git (push)
```
Note: If you've cloned the repository using a graphical client, you may already
have the upstream remote repository configured. For example, when you clone
[zulip/zulip][github-zulip-zulip] with the GitHub desktop client it configures
the remote repository `zulip` and you see the following output from `git remote
-v`:
```
origin git@github.com:YOUR_USERNAME/zulip.git (fetch)
origin git@github.com:YOUR_USERNAME/zulip.git (push)
zulip https://github.com/zulip/zulip.git (fetch)
zulip https://github.com/zulip/zulip.git (push)
```
If your client hasn't automatically configured a remote for zulip/zulip, you'll
need to with:
```
$ git remote add -f upstream https://github.com/zulip/zulip.git
```
Finally, confirm that the new remote repository, upstream, has been configured:
```
$ git remote -v
origin git@github.com:YOUR_USERNAME/zulip.git (fetch)
origin git@github.com:YOUR_USERNAME/zulip.git (push)
upstream https://github.com/zulip/zulip.git (fetch)
upstream https://github.com/zulip/zulip.git (push)
```
## Step 2: Set up the Zulip development environment
If you haven't already, now is a good time to install the Zulip development environment
([overview][zulip-rtd-dev-overview]). If you're new to working on Zulip or open
source projects in general, we recommend following our [detailed guide for
first-time contributors][zulip-rtd-dev-first-time].
## Step 3: Configure Travis CI (continuous integration)
This step is optional, but recommended.
The Zulip Server project is configured to use [Travis CI][travis-ci]
to test and create builds upon each new commit and pull
request. Travis CI is free for open source projects and it's easy to
configure for your own fork of Zulip. After doing so, Travis CI will
run tests for new refs you push to GitHub and email you the outcome
(you can also view the results in the web interface).
Running Travis CI against your fork can help save both you and the
Zulip maintainers time by making it easy to test a change fully before
submitting a pull request. We generally recommend a worfklow where as
you make changes, you use a fast edit-refresh cycle running individual
tests locally until your changes work. But then once you've gotten
the tests you'd expect to be relevant to your changes working, push a
branch to Travis CI to run the full test suite before you create a
pull request. While you wait for Travis CI to run, you can start
working on your next task. When the tests finish, you can create a
pull request that you already know passes the tests.
First, sign in to [Travis CI][travis-ci] with your GitHub account and authorize
Travis CI to access your GitHub account and repositories. Once you've done
this, Travis CI will fetch your repository information and display it on your
[profile page][travis-ci-profile]. From there you can enable integration with
Zulip. ([See screen cast](../_static/zulip-travisci.gif).)
[gitbook-rebase]: https://git-scm.com/book/en/v2/Git-Branching-Rebasing
[github-help-add-ssh-key]: https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/
[github-help-conf-remote]: https://help.github.com/articles/configuring-a-remote-for-a-fork/
[github-help-fork]: https://help.github.com/articles/fork-a-repo/
[github-help-sync-fork]: https://help.github.com/articles/syncing-a-fork/
[github-zulip]: https://github.com/zulip/
[github-zulip-zulip]: https://github.com/zulip/zulip/
[travis-ci]: https://travis-ci.org/
[travis-ci-profile]: https://travis-ci.org/profile
[zulip-rtd-dev-first-time]: ../development/setup-vagrant.html
[zulip-rtd-dev-overview]: ../development/overview.html
[zulip-rtd-tools-setup]: ../git/zulip-tools.html#set-up-git-repo-script

57
docs/git/collaborate.md Normal file
View File

@@ -0,0 +1,57 @@
# Collaborate
## Fetch another contributor's branch
What happens when you would like to collaborate with another contributor and
they have work-in-progress on their own fork of Zulip? No problem! Just add
their fork as a remote and pull their changes.
```
$ git remote add <username> https://github.com/<username>/zulip.git
$ git fetch <username>
```
Now you can checkout their branch just like you would any other. You can name
the branch anything you want, but using both the username and branch name will
help you keep things organized.
```
$ git checkout -b <username>/<branchname>
```
You can choose to rename the branch if you prefer:
```
git checkout -b <custombranchname> <username>/<branchname>
```
## Checkout a pull request locally
Just as you can checkout any user's branch locally, you can also checkout any
pull request locally. GitHub provides a special syntax
([details][github-help-co-pr-locally]) for this since pull requests are
specific to GitHub rather than Git.
First, fetch and create a branch for the pull request, replacing *ID* and
*BRANCHNAME* with the ID of the pull request and your desired branch name:
```
$ git fetch upstream pull/ID/head:BRANCHNAME
```
Now switch to the branch:
```
$ git checkout BRANCHNAME
```
Now you work on this branch as you would any other.
Note: you can use the scripts provided in the tools/ directory to fetch pull
requests. You can read more about what they do [here][tools-PR].
```
tools/fetch-rebase-pull-request <PR-number>
tools/fetch-pull-request <PR-number>
```
[github-help-co-pr-locally]: https://help.github.com/articles/checking-out-pull-requests-locally/
[tools-PR]: ../git/zulip-tools.html#fetch-a-pull-request-and-rebase

21
docs/git/index.rst Normal file
View File

@@ -0,0 +1,21 @@
#########
Git Guide
#########
.. toctree::
:maxdepth: 3
Quick Start <overview>
Set up Git <setup>
How Git is different <the-git-difference>
Important Git terms <terminology>
Get Zulip code <cloning>
Working copies <working-copies>
Using Git as you work <using>
Pull Requests <pull-requests>
Collaborate <collaborate>
Fixing commits <fixing-commits>
Reviewing changes <reviewing>
Get and stay out of trouble <troubleshooting>
Zulip-specific-tools <zulip-tools>
Git Cheat Sheet <cheat-sheet>

71
docs/git/overview.md Normal file
View File

@@ -0,0 +1,71 @@
# Quick start: How Zulip uses Git and GitHub
This quick start provides a brief overview of how Zulip uses Git and GitHub.
Those who are familiar with Git and GitHub should be able to start contributing
with these details in mind:
- We use **GitHub for source control and code review.** To contribute, fork
[zulip/zulip][github-zulip-zulip] (or the appropriate
[repository][github-zulip], if you are working on something else besides
Zulip server) to your own account and then create feature/issue branches.
When you're ready to get feedback, submit a work-in-progress (WIP) pull
request. *We encourage you to submit WIP pull requests early and often.*
- We use a **[rebase][gitbook-rebase]-oriented workflow.** We do not use merge
commits. This means you should use `git fetch` followed by `git rebase`
rather than `git pull` (or you can use `git pull --rebase`). Also, to prevent
pull requests from becoming out of date with the main line of development,
you should rebase your feature branch prior to submitting a pull request, and
as needed thereafter. If you're unfamiliar with how to rebase a pull request,
[read this excellent guide][github-rebase-pr].
We use this strategy in order to avoid the extra commits that appear
when another branch is merged, that clutter the commit history (it's
popular with other large projects such as Django). This makes
Zulip's commit history more readable, but a side effect is that many
pull requests we merge will be reported by GitHub's UI as *closed*
instead of *merged*, since GitHub has poor support for
rebase-oriented workflows.
- We have a **[code style guide][zulip-rtd-code-style]**, a **[commit message
guide][zulip-rtd-commit-messages]**, and strive for each commit to be *a
minimal coherent idea* (see **[commit
discipline][zulip-rtd-commit-discipline]** for details).
- We provide **many tools to help you submit quality code.** These include
[linters][zulip-rtd-lint-tools], [tests][zulip-rtd-testing], continuous
integration with [Travis CI][travis-ci], and [mypy][zulip-rtd-mypy].
- We use [zulipbot][zulip-rtd-zulipbot-usage] to manage our issues and
pull requests to create a better GitHub workflow for contributors.
- We provide some handy **[Zulip-specific Git scripts][zulip-rtd-zulip-tools]**
for developers to easily do tasks like fetching and rebasing a pull
request, cleaning unimportant branches, etc. These reduce the common
tasks of testing other contributors' pull requests to single commands.
Finally, install the [Zulip developer environment][zulip-rtd-dev-overview], and then
[configure your fork for use with Travis CI][zulip-git-guide-travisci].
***
The following sections will help you be awesome with Zulip and Git/GitHub in a
rebased-based workflow. Read through it if you're new to git, to a rebase-based
git workflow, or if you'd like a git refresher.
[gitbook-rebase]: https://git-scm.com/book/en/v2/Git-Branching-Rebasing
[github-rebase-pr]: https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request
[github-zulip]: https://github.com/zulip/
[github-zulip-zulip]: https://github.com/zulip/zulip/
[travis-ci]: https://travis-ci.org/
[zulip-git-guide-travisci]: ../git/cloning.html#step-3-configure-travis-ci-continuous-integration
[zulip-rtd-code-style]: ../contributing/code-style.html
[zulip-rtd-commit-discipline]: ../contributing/version-control.html#commit-discipline
[zulip-rtd-commit-messages]: ../contributing/version-control.html#commit-messages
[zulip-rtd-dev-overview]: ../development/overview.html
[zulip-rtd-lint-tools]: ../contributing/code-style.html#lint-tools
[zulip-rtd-mypy]: ../contributing/mypy.html
[zulip-rtd-testing]: ../testing/testing.html
[zulip-rtd-zulip-tools]: ../git/zulip-tools.html
[zulip-rtd-zulipbot-usage]: ../contributing/zulipbot-usage.html

152
docs/git/pull-requests.md Normal file
View File

@@ -0,0 +1,152 @@
# Create a pull request
When you're ready for feedback, submit a pull request. Pull requests
are a feature specific to GitHub. They provide a simple, web-based way
to submit your work (often called "patches") to a project. It's called
a *pull request* because you're asking the project to *pull changes*
from your fork.
If you're unfamiliar with how to create a pull request, you can check
out GitHub's documentation on
[creating a pull request from a fork][github-help-create-pr-fork]. You
might also find GitHub's article
[about pull requests][github-help-about-pr] helpful. That all said,
the tutorial below will walk you through the process.
## Work in progress pull requests
In the Zulip project, we encourage submitting work-in-progress pull
requests early and often. This allows you to share your code to make
it easier to get feedback and help with your changes. Prefix the
titles of work-in-progress pull requests with **[WIP]**, which in our
project means that you don't think your pull request is ready to be
merged (e.g. it might not work or pass tests). This sets expectations
correctly for any feedback from other developers, and prevents your
work from being merged before you're confident in it.
## Create a pull request
### Step 1: Update your branch with git rebase
The best way to update your branch is with `git fetch` and `git rebase`. Do not
use `git pull` or `git merge` as this will create merge commits. See [keep your
fork up to date][keep-up-to-date] for details.
Here's an example (you would replace *issue-123* with the name of your feature branch):
```
$ git checkout issue-123
Switched to branch 'issue-123'
$ git fetch upstream
remote: Counting objects: 69, done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 69 (delta 49), reused 39 (delta 39), pack-reused 7
Unpacking objects: 100% (69/69), done.
From https://github.com/zulip/zulip
69fa600..43e21f6 master -> upstream/master
$ git rebase upstream/master
First, rewinding head to replay your work on top of it...
Applying: troubleshooting tip about provisioning
```
### Step 2: Push your updated branch to your remote fork
Once you've updated your local feature branch, push the changes to GitHub:
```
$ git push origin issue-123
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 658 bytes | 0 bytes/s, done.
Total 6 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 1 local objects.
To git@github.com:christi3k/zulip.git
+ 2d49e2d...bfb2433 issue-123 -> issue-123
```
If your push is rejected with error **failed to push some refs** then you need
to prefix the name of your branch with a `+`:
```
$ git push origin +issue-123
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 658 bytes | 0 bytes/s, done.
Total 6 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 1 local objects.
To git@github.com:christi3k/zulip.git
+ 2d49e2d...bfb2433 issue-123 -> issue-123 (forced update)
```
This is perfectly okay to do on your own feature branches, especially if you're
the only one making changes to the branch. If others are working along with
you, they might run into complications when they retrieve your changes because
anyone who has based their changes off a branch you rebase will have to do a
complicated rebase.
### Step 3: Open the pull request
If you've never created a pull request or need a refresher, take a look at
GitHub's article [creating a pull request from a
fork][github-help-create-pr-fork]. We'll briefly review the process here.
The first step in creating a pull request is to use your web browser to
navigate to your fork of Zulip. Sign in to GitHub if you haven't already.
Next, navigate to the branch you've been working on. Do this by clicking on the
**Branch** button and selecting the relevant branch. Finally, click the **New
pull request** button.
Alternatively, if you've recently pushed to your fork, you will see a green
**Compare & pull request** button.
You'll see the *Open a pull request* page:
![images-create-pr]
Provide a **title** and first comment for your pull request. Remember to prefix
your pull request title with [WIP] if it is a [work-in-progress][wip-prs].
If your pull request has an effect on the visuals of a component, you might want
to include a screenshot of this change or a GIF of the interaction in your first
comment. This will allow reviewers to comment on your changes without having to
checkout your branch; you can find a list of tools you can use for this over
[here][screenshots-gifs].
When ready, click the green **Create pull request** to submit the pull request.
Note: **Pull request titles are different from commit messages.** Commit
messages can be edited with `git commit --amend`, `git rebase -i`, etc., while
the title of a pull request can only be edited via GitHub.
## Update a pull request
As you get make progress on your feature or bugfix, your pull request, once
submitted, will be updated each time you [push commits][self-push-commits] to
your remote branch. This means you can keep your pull request open as long as
you need, rather than closing and opening new ones for the same feature or
bugfix.
It's a good idea to keep your pull request mergeable with Zulip upstream by
frequently fetching, rebasing, and pushing changes. See [keep your fork up to
date][keep-up-to-date] for details. You might also find this excellent
article [How to Rebase a Pull Request][edx-howto-rebase-pr] helpful.
And, as you address review comments others have made, we recommend posting a
follow-up comment in which you: a) ask for any clarifications you need, b)
explain to the reviewer how you solved any problems they mentioned, and c) ask
for another review.
[edx-howto-rebase-pr]: https://github.com/edx/edx-platform/wiki/How-to-Rebase-a-Pull-Request
[github-help-about-pr]: https://help.github.com/articles/about-pull-requests/
[github-help-create-pr-fork]: https://help.github.com/articles/creating-a-pull-request-from-a-fork/
[images-create-pr]: ../images/zulip-open-pr.png
[keep-up-to-date]: ../git/using.html#keep-your-fork-up-to-date
[push-commits]: ../git/using.html#push-your-commits-to-github
[screenshots-gifs]: ../tutorials/screenshot-and-gif-software.html
[wip-prs]: #work-in-progress-pull-requests

64
docs/git/reviewing.md Normal file
View File

@@ -0,0 +1,64 @@
# Review changes
**Note** - The following section covers reviewing changes on your local
clone. Please read the section on [code reviews][zulip-rtd-review] for a guide
on reviewing changes by other contributors.
## Changes on (local) working tree
Display changes between index and working tree (what is not yet staged for commit):
```
$ git diff
```
Display changes between index and last commit (what you have staged for commit):
```
$ git diff --cached
```
Display changes in working tree since last commit (changes that are staged as
well as ones that are not):
```
$ git diff HEAD
```
## Changes within branches
Use any git-ref to compare changes between two commits on the current branch.
Display changes between commit before last and last commit:
```
$ git diff HEAD^ HEAD
```
Display changes between two commits using their hashes:
```
$ git diff e2f404c 7977169
```
## Changes between branches
Display changes between tip of topic branch and tip of master branch:
```
$ git diff topic master
```
Display changes that have occurred on master branch since topic branch was created:
```
$ git diff topic...master
```
Display changes you've committed so far since creating a branch from upstream/master:
```
$ git diff upstream/master...HEAD
```
[zulip-rtd-review]: ../contributing/code-reviewing.html

67
docs/git/setup.md Normal file
View File

@@ -0,0 +1,67 @@
# Set up Git
If you're already using Git, have a client you like, and a GitHub account, you
can skip this section. Otherwise, read on!
## Install and configure Git, join GitHub
If you're not already using Git, you might need to [install][gitbook-install]
and [configure][gitbook-setup] it.
**If you are using Windows 10, make sure you [are running Git BASH as an
administrator][git-bash-admin] at all times.**
You'll also need a GitHub account, which you can sign up for
[here][github-join].
We highly recommend you create an ssh key if you don't already have
one and [add it to your GitHub account][github-help-add-ssh-key]. If
you don't, you'll have to type your GitHub username and password every
time you interact with GitHub, which is usually several times a day.
We also highly recommend the following:
- [Configure Git][gitbook-config] with your name and email and
[aliases][gitbook-aliases] for commands you'll use often. We
recommend using your full name (not just your first name), since
that's what we'll use to give credit to your work in places like the
Zulip release notes.
- Install the command auto-completion and/or git-prompt plugins available for
[Bash][gitbook-other-envs-bash] and [Zsh][gitbook-other-envs-zsh].
## Get a graphical client
Even if you're comfortable using git on the command line, having a graphic
client can be useful for viewing your repository. This is especially when doing
a complicated rebases and similar operations because you can check the state of
your repository after each command to see what changed. If something goes
wrong, this helps you figure out when and why.
If you don't already have one installed, here are some suggestions:
- macOS: [GitX-dev][gitgui-gitxdev]
- Ubuntu/Linux: [git-cola][gitgui-gitcola], [gitg][gitgui-gitg], [gitk][gitgui-gitk]
- Windows: [SourceTree][gitgui-sourcetree]
If you like working on the command line, but want better visualization and
navigation of your git repo, try [Tig][tig], a cross-platform ncurses-based
text-mode interface to Git.
And, if none of the above are to your liking, try [one of these][gitbook-guis].
[git-bash-admin]: ../development/setup-vagrant.html#running-git-bash-as-an-administrator
[gitbook-aliases]: https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases
[gitbook-config]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration
[gitbook-guis]: https://git-scm.com/downloads/guis
[gitbook-install]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
[github-join]: https://github.com/join
[gitbook-setup]: https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup
[gitbook-other-envs-bash]: https://git-scm.com/book/en/v2/Git-in-Other-Environments-Git-in-Bash
[gitbook-other-envs-zsh]: https://git-scm.com/book/en/v2/Git-in-Other-Environments-Git-in-Zsh
[gitgui-gitcola]: http://git-cola.github.io/
[gitgui-gitg]: https://wiki.gnome.org/Apps/Gitg
[gitgui-gitk]: https://git-scm.com/docs/gitk
[gitgui-gitxdev]: https://rowanj.github.io/gitx/
[gitgui-sourcetree]: https://www.sourcetreeapp.com/
[github-help-add-ssh-key]: https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/
[tig]: http://jonas.nitro.dk/tig/

84
docs/git/terminology.md Normal file
View File

@@ -0,0 +1,84 @@
# Important Git terms
When you install Git, it adds a manual entry for `gitglossary`. You can view
this glossary by running `man gitglossary`. Below we've included the git terms
you'll encounter most often along with their definitions from *gitglossary*.
## branch
A "branch" is an active line of development. The most recent commit
on a branch is referred to as the tip of that branch. The tip of
the branch is referenced by a branch head, which moves forward as
additional development is done on the branch. A single Git
repository can track an arbitrary number of branches, but your
working tree is associated with just one of them (the "current" or
"checked out" branch), and HEAD points to that branch.
## cache
Obsolete for: index
## checkout
The action of updating all or part of the working tree with a tree
object or blob from the object database, and updating the index and
HEAD if the whole working tree has been pointed at a new branch.
## commit
As a noun: A single point in the Git history; the entire history of
a project is represented as a set of interrelated commits. The word
"commit" is often used by Git in the same places other revision
control systems use the words "revision" or "version". Also used as
a short hand for commit object.
As a verb: The action of storing a new snapshot of the project's
state in the Git history, by creating a new commit representing the
current state of the index and advancing HEAD to point at the new
## fast-forward
A fast-forward is a special type of merge where you have a revision
and you are "merging" another branch's changes that happen to be a
descendant of what you have. In such these cases, you do not make a
new mergecommit but instead just update to their revision. This will
happen frequently on a remote-tracking branch of a remote
repository.
## fetch
Fetching a branch means to get the branch's head ref from a remote
repository, to find out which objects are missing from the local
object database, and to get them, too. See also git-fetch(1).
## hash
In Git's context, synonym for object name.
## head
A named reference to the commit at the tip of a branch. Heads are
stored in a file in $GIT_DIR/refs/heads/ directory, except when
using packed refs. (See git-pack-refs(1).)
## HEAD
The current branch. In more detail: Your working tree is normally
derived from the state of the tree referred to by HEAD. HEAD is a
reference to one of the heads in your repository, except when using
a detached HEAD, in which case it directly references an arbitrary
commit.
## index
A collection of files with stat information, whose contents are
stored as objects. The index is a stored version of your working
tree. Truth be told, it can also contain a second, and even a third
version of a working tree, which are used when merging.
## pull
Pulling a branch means to fetch it and merge it. See also git-
pull(1).
## push
Pushing a branch means to get the branch's head ref from a remote
repository, find out if it is a direct ancestor to the branch's
local head ref, and in that case, putting all objects, which are
reachable from the local head ref, and which are missing from the
remote repository, into the remote object database, and updating
the remote head ref. If the remote head is not an ancestor to the
local head, the push fails.
## rebase
To reapply a series of changes from a branch to a different base,
and reset the head of that branch to the result.

View File

@@ -0,0 +1,64 @@
# How Git is different
Whether you're new to Git or have experience with another version control
system (VCS), it's a good idea to learn a bit about how Git works. We recommend
this excellent presentation *[Understanding Git][understanding-git]* from
Nelson Elhage and Anders Kaseorg and the [Git Basics][gitbook-basics] chapter
from *Pro Git* by Scott Chacon and Ben Straub.
Here are the top things to know:
- **Git works on snapshots:** Unlike other version control systems (e.g.,
Subversion, Perforce, Bazaar), which track files and changes to those files
made over time, Git tracks *snapshots* of your project. Each time you commit
or otherwise make a change to your repository, Git takes a snapshot of your
project and stores a reference to that snapshot. If a file hasn't changed,
Git creates a link to the identical file rather than storing it again.
- **Most Git operations are local:** Git is a distributed version control
system, so once you've cloned a repository, you have a complete copy of that
repository's *entire history*. Staging, committing, branching, and browsing
history are all things you can do locally without network access and without
immediately affecting any remote repositories. To make or receive changes
from remote repositories, you need to `git fetch`, `git pull`, or `git push`.
- **Nearly all Git actions add information to the Git database**, rather than
removing it. As such, it's hard to make Git perform actions that you can't
undo. However, Git can't undo what it doesn't know about, so it's a good
practice to frequently commit your changes and frequently push your commits to
your remote repository.
- **Git is designed for lightweight branching and merging.** Branches are
simply references to snapshots. It's okay and expected to make a lot of
branches, even throwaway and experimental ones.
- **Git stores all data as objects, of which there are four types:** blob
(file), tree (directory), commit (revision), and tag. Each of these objects
is named by a unique hash, the SHA-1 has of its contents. Most of the time
you'll refer to objects by their truncated hash or more human-readable
reference like `HEAD` (the current branch). Blobs and trees represent files
and directories. Tags are named references to other objects. A commit object
includes: tree id, zero or more parents as commit ids, an author (name,
email, date), a committer (name, email, date), and a log message. A Git
repository is a collection of mutable pointers to these objects called
**refs**.
- **Cloning a repository creates a working copy.** Every working copy has a
`.git` subdirectory, which contains its own Git repository. The `.git`
subdirectory also tracks the *index*, a staging area for changes that will
become part of the next commit. All files outside of `.git` is the *working
tree*.
- **Files tracked with Git have possible three states: committed, modified, and
staged.** Committed files are those safely stored in your local `.git`
repository/database. Staged files have changes and have been marked for
inclusion in the next commit; they are part of the index. Modified files have
changes but have not yet been marked for inclusion in the next commit; they
have not been added to the index.
- **Git commit workflow is as follows:** Edit files in your *working tree*. Add
to the *index* (that is *stage*) with `git add`. *Commit* to the HEAD of the
current branch with `git commit`.
[gitbook-basics]: https://git-scm.com/book/en/v2/Getting-Started-Git-Basics
[understanding-git]: http://web.mit.edu/nelhage/Public/git-slides-2009.pdf

280
docs/git/troubleshooting.md Normal file
View File

@@ -0,0 +1,280 @@
# Get and stay out of trouble
Git is a powerful yet complex version control system. Even for contributors
experienced at using version control, it can be confusing. The good news is
that nearly all Git actions add information to the Git database, rather than
removing it. As such, it's hard to make Git perform actions that you can't
undo. However, git can't undo what it doesn't know about, so it's a good
practice to frequently commit your changes and frequently push your commits to
your remote repository.
## Undo a merge commit
A merge commit is a special type of commit that has two parent commits. It's
created by Git when you merge one branch into another and the last commit on
your current branch is not a direct ancestor of the branch you are trying to
merge in. This happens quite often in a busy project like Zulip where there are
many contributors because upstream/zulip will have new commits while you're
working on a feature or bugfix. In order for Git to merge your changes and the
changes that have occurred on zulip/upstream since you first started your work,
it must perform a three-way merge and create a merge commit.
Merge commits aren't bad, however, Zulip doesn't use them. Instead Zulip uses a
forked-repo, rebase-oriented workflow.
A merge commit is usually created when you've run `git pull` or `git merge`.
You'll know you're creating a merge commit if you're prompted for a commit
message and the default is something like this:
```
Merge branch 'master' of https://github.com/zulip/zulip
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
```
And the first entry for `git log` will show something like:
```
commit e5f8211a565a5a5448b93e98ed56415255546f94
Merge: 13bea0e e0c10ed
Author: Christie Koehler <ck@christi3k.net>
Date: Mon Oct 10 13:25:51 2016 -0700
Merge branch 'master' of https://github.com/zulip/zulip
```
Some graphical Git clients may also create merge commits.
To undo a merge commit, first run `git reflog` to identify the commit you want
to roll back to:
```
$ git reflog
e5f8211 HEAD@{0}: pull upstream master: Merge made by the 'recursive' strategy.
13bea0e HEAD@{1}: commit: test commit for docs.
```
Reflog output will be long. The most recent git refs will be listed at the top.
In the example above `e5f8211 HEAD@{0}:` is the merge commit made automatically
by `git pull` and `13bea0e HEAD@{1}:` is the last commit I made before running
`git pull`, the commit that I want to rollback to.
Once you'd identified the ref you want to revert to, you can do so with [git
reset][gitbook-reset]:
```
$ git reset --hard 13bea0e
HEAD is now at 13bea0e test commit for docs.
```
**Important:** `git reset --hard <commit>` will discard all changes in your
working directory and index since the commit you're resetting to with
*<commit>*. *This is the main way you can lose work in Git*. If you need to
keep any changes that are in your working directory or that you have committed,
use `git reset --merge <commit>` instead.
You can also use the relative reflog `HEAD@{1}` instead of the commit hash,
just keep in mind that this changes as you run git commands.
Now when you look at the output of `git reflog`, you should see that the tip of your branch points to your
last commit `13bea0e` before the merge:
```
$ git reflog
13bea0e HEAD@{2}: reset: moving to HEAD@{1}
e5f8211 HEAD@{3}: pull upstream master: Merge made by the 'recursive' strategy.
13bea0e HEAD@{4}: commit: test commit for docs.
```
And the first entry `git log` shows is this:
```
commit 13bea0e40197b1670e927a9eb05aaf50df9e8277
Author: Christie Koehler <ck@christi3k.net>
Date: Mon Oct 10 13:25:38 2016 -0700
test commit for docs.
```
## Restore a lost commit
We've mentioned you can use `git reset --hard` to rollback to a previous
commit. What if you run `git reset --hard` and then realize you actually need
one or more of the commits you just discarded? No problem, you can restore them
with `git cherry-pick` ([docs][gitbook-git-cherry-pick]).
For example, let's say you just committed "some work" and your `git log` looks
like this:
```
* 67aea58 (HEAD -> master) some work
* 13bea0e test commit for docs.
```
You then mistakenly run `git reset --hard 13bea0e`:
```
$ git reset --hard 13bea0e
HEAD is now at 13bea0e test commit for docs.
$ git log
* 13bea0e (HEAD -> master) test commit for docs.
```
And then realize you actually needed to keep commit 67aea58. First, use `git
reflog` to confirm that commit you want to restore and then run `git
cherry-pick <commit>`:
```
$ git reflog
13bea0e HEAD@{0}: reset: moving to 13bea0e
67aea58 HEAD@{1}: commit: some work
$ git cherry-pick 67aea58
[master 67aea58] some work
Date: Thu Oct 13 11:51:19 2016 -0700
1 file changed, 1 insertion(+)
create mode 100644 test4.txt
```
## Recover from a git rebase failure
One situation in which `git rebase` will fail and require you to intervene is
when your change, which git will try to re-apply on top of new commits from
which ever branch you are rebasing on top of, is to code that has been changed
by those new commits.
For example, while I'm working on a file, another contributor makes a change to
that file, submits a pull request and has their code merged into master.
Usually this is not a problem, but in this case the other contributor made a
change to a part of the file I also want to change. When I try to bring my
branch up to date with `git fetch` and then `git rebase upstream/master`, I see
the following:
```
First, rewinding head to replay your work on top of it...
Applying: test change for docs
Using index info to reconstruct a base tree...
M README.md
Falling back to patching base and 3-way merge...
Auto-merging README.md
CONFLICT (content): Merge conflict in README.md
error: Failed to merge in the changes.
Patch failed at 0001 test change for docs
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
```
This message tells me that Git was not able to apply my changes to README.md
after bringing in the new commits from upstream/master.
Running `git status` also gives me some information:
```
rebase in progress; onto 5ae56e6
You are currently rebasing branch 'docs-test' on '5ae56e6'.
(fix conflicts and then run "git rebase --continue")
(use "git rebase --skip" to skip this patch)
(use "git rebase --abort" to check out the original branch)
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")
```
To fix, open all the files with conflicts in your editor and decide which edits
should be applied. Git uses standard conflict-resolution (`<<<<<<<`, `=======`,
and `>>>>>>>`) markers to indicate where in files there are conflicts.
Tip: You can see recent changes made to a file by running the following
commands:
```
git fetch upstream
git log -p upstream/master -- /path/to/file
```
You can use this to compare the changes that you have made to a file with the
ones in upstream, helping you avoid undoing changes from a previous commit when
you are rebasing.
Once you've done that, save the file(s), stage them with `git add` and then
continue the rebase with `git rebase --continue`:
```
$ git add README.md
$ git rebase --continue
Applying: test change for docs
```
For help resolving merge conflicts, see [basic merge
conflicts][gitbook-basic-merge-conflicts], [advanced
merging][gitbook-advanced-merging], and/or GitHub's help on [how to resolve a
merge conflict][github-help-resolve-merge-conflict].
## Working from multiple computers
Working from multiple computers with Zulip and Git is fine, but you'll need to
pay attention and do a bit of work to ensure all of your work is readily
available.
Recall that most Git operations are local. When you commit your changes with
`git commit` they are safely stored in your *local* Git database only. That is,
until you *push* the commits to GitHub, they are only available on the computer
where you committed them.
So, before you stop working for the day, or before you switch computers, push
all of your commits to GitHub with `git push`:
```
$ git push origin <branchname>
```
When you first start working on a new computer, you'll [clone the Zulip
repository][clone-to-your-machine] and [connect it to Zulip
upstream][connect-upstream]. A clone retrieves all current commits,
including the ones you pushed to GitHub from your other computer.
But if you're switching to another computer on which you have already cloned
Zulip, you need to update your local Git database with new refs from your
GitHub fork. You do this with `git fetch`:
```
$ git fetch <usermame>
```
Ideally you should do this before you have made any commits on the same branch
on the second computer. Then you can `git merge` on whichever branch you need
to update:
```
$ git checkout <my-branch>
Switched to branch '<my-branch>'
$ git merge origin/master
```
**If you have already made commits on the second computer that you need to
keep,** you'll need to use `git log FETCH_HEAD` to identify that hashes of the
commits you want to keep and then `git cherry-pick <commit>` those commits into
whichever branch you need to update.
[clone-to-your-machine]: ../git/cloning.html#step-1b-clone-to-your-machine
[connect-upstream]: ../git/cloning.html#step-1c-connect-your-fork-to-zulip-upstream
[gitbook-advanced-merging]: https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_advanced_merging
[gitbook-basic-merge-conflicts]: https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging#Basic-Merge-Conflicts
[gitbook-git-cherry-pick]: https://git-scm.com/docs/git-cherry-pick
[gitbook-reset]: https://git-scm.com/docs/git-reset
[github-help-resolve-merge-conflict]: https://help.github.com/articles/resolving-a-merge-conflict-using-the-command-line/

452
docs/git/using.md Normal file
View File

@@ -0,0 +1,452 @@
# Using Git as you work
## Know what branch you're working on
When using Git, it's important to know which branch you currently have checked
out because most git commands implicitly operate on the current branch. You can
determine the currently checked out branch several ways.
One way is with [git status][gitbook-git-status]:
```
$ git status
On branch issue-demo
nothing to commit, working directory clean
```
Another is with [git branch][gitbook-git-branch] which will display all local
branches, with a star next to the current branch:
```
$ git branch
* issue-demo
master
```
To see even more information about your branches, including remote branches,
use `git branch -vva`:
```
$ git branch -vva
* issue-123 517468b troubleshooting tip about provisioning
master f0eaee6 [origin/master] bug: Fix traceback in get_missed_message_token_from_address().
remotes/origin/HEAD -> origin/master
remotes/origin/issue-1234 4aeccb7 Another test commit, with longer message.
remotes/origin/master f0eaee6 bug: Fix traceback in get_missed_message_token_from_address().
remotes/upstream/master dbeab6a Optimize checks of test database state by moving into Python.
```
You can also configure [Bash][gitbook-other-envs-bash] and
[Zsh][gitbook-other-envs-zsh] to display the current branch in your prompt.
## Keep your fork up to date
You'll want to [keep your fork][github-help-sync-fork] up-to-date with changes
from Zulip's main repositories.
**Note about git pull**: You might be used to using `git pull` on other
projects. With Zulip, because we don't use merge commits, you'll want to avoid
it. Rather that using `git pull`, which by default is a shortcut for `git fetch
&& git merge FETCH_HEAD` ([docs][gitbook-git-pull]), you should use `git fetch`
and then `git rebase`.
First, [fetch][gitbook-fetch] changes from Zulip's upstream repository you
configured in the step above:
```
$ git fetch upstream
```
Next, checkout your `master` branch and [rebase][gitbook-git-rebase] it on top
of `upstream/master`:
```
$ git checkout master
Switched to branch 'master'
$ git rebase upstream/master
```
This will rollback any changes you've made to master, update it from
`upstream/master`, and then re-apply your changes. Rebasing keeps the commit
history clean and readable.
When you're ready, [push your changes][github-help-push] to your remote fork.
Make sure you're in branch `master` and the run `git push`:
```
$ git checkout master
$ git push origin master
```
You can keep any branch up to date using this method. If you're working on a
feature branch (see next section), which we recommend, you would change the
command slightly, using the name of your `feature-branch` rather than `master`:
```
$ git checkout feature-branch
Switched to branch 'feature-branch'
$ git rebase upstream/master
$ git push origin feature-branch
```
## Work on a feature branch
One way to keep your work organized is to create a branch for each issue or
feature. Recall from [how Git is different][how-git-is-different] that
**Git is designed for lightweight branching and merging.** You can and should
create as many branches as you'd like.
First, make sure your master branch is up-to-date with Zulip upstream ([see
how][zulip-git-guide-up-to-date]).
Next, from your master branch, create a new tracking branch, providing a
descriptive name for your feature branch:
```
$ git checkout master
Switched to branch 'master'
$ git checkout -b issue-1755-fail2ban
Switched to a new branch 'issue-1755-fail2ban'
```
Alternatively, you can create a new branch explicitly based off
`upstream/master`:
```
$ git checkout -b issue-1755-fail2ban upstream/master
Switched to a new branch 'issue-1755-fail2ban'
```
Now you're ready to work on the issue or feature.
## Run linters and tests locally
In addition to having Travis run tests and linters each time you push a new
commit, you can also run them locally. See [testing](../testing/testing.html) for details.
## Stage changes
Recall that files tracked with Git have possible three states:
committed, modified, and staged.
To prepare a commit, first add the files with changes that you want
to include in your commit to your staging area. You *add* both new files and
existing ones. You can also remove files from staging when necessary.
### Get status of working directory
To see what files in the working directory have changes that have not been
staged, use `git status`.
If you have no changes in the working directory, you'll see something like
this:
```
$ git status
On branch issue-123
nothing to commit, working directory clean
```
If you have unstaged changes, you'll see something like this:
```
On branch issue-123
Untracked files:
(use "git add <file>..." to include in what will be committed)
newfile.py
nothing added to commit but untracked files present (use "git add" to track)
```
### Stage additions with git add
To add changes to your staging area, use `git add <filename>`. Because `git
add` is all about staging the changes you want to commit, you use it to add
*new files* as well as *files with changes* to your staging area.
Continuing our example from above, after we run `git add newfile.py`, we'll see
the following from `git status`:
```
On branch issue-123
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: newfile.py
```
You can view the changes in files you have staged with `git diff --cached`. To
view changes to files you haven't yet staged, just use `git diff`.
If you want to add all changes in the working directory, use `git add -A`
([documentation][gitbook-add]).
You can also stage changes using your graphical Git client.
If you stage a file, you can undo it with `git reset HEAD <filename>`. Here's
an example where we stage a file `test3.txt` and then unstage it:
```
$ git add test3.txt
On branch issue-1234
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: test3.txt
$ git reset HEAD test3.txt
$ git status
On branch issue-1234
Untracked files:
(use "git add <file>..." to include in what will be committed)
test3.txt
nothing added to commit but untracked files present (use "git add" to track)
```
### Stage deletions with git rm
To remove existing files from your repository, use `git rm`
([documentation][gitbook-rm]). This command can either stage the file for
removal from your repository AND delete it from your working directory or just
stage the file for deletion and leave it in your working directory.
To stage a file for deletion and **remove** it from your working directory, use
`git rm <filename>`:
```
$ git rm test.txt
rm 'test.txt'
$ git status
On branch issue-1234
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: test.txt
$ ls test.txt
ls: No such file or directory
```
To stage a file for deletion and **keep** it in your working directory, use
`git rm --cached <filename>`:
```
$ git rm --cached test2.txt
rm 'test2.txt'
$ git status
On branch issue-1234
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: test2.txt
$ ls test2.txt
test2.txt
```
If you stage a file for deletion with the `--cached` option, and haven't yet
run `git commit`, you can undo it with `git reset HEAD <filename>`:
```
$ git reset HEAD test2.txt
```
Unfortunately, you can't restore a file deleted with `git rm` if you didn't use
the `--cache` option. However, `git rm` only deletes files it knows about.
Files you have never added to git won't be deleted.
## Commit changes
When you've staged all your changes, you're ready to commit. You can do this
with `git commit -m "My commit message."` to include a commit message.
Here's an example of committing with the `-m` for a one-line commit message:
```
$ git commit -m "Add a test commit for docs."
[issue-123 173e17a] Add a test commit for docs.
1 file changed, 1 insertion(+)
create mode 100644 newfile.py
```
You can also use `git commit` without the `-m` option and your editor to open,
allowing you to easily draft a multi-line commit message.
How long your commit message should be depends on where you are in your work.
Using short, one-line messages for commits related to in-progress work makes
sense. For a commit that you intend to be final or that encompasses a
significant amount or complex work, you should include a longer message.
Keep in mind that your commit should contain a 'minimal coherent idea' and have
a quality commit message. See Zulip docs [Commit
Discipline][zulip-rtd-commit-discipline] and [Commit
messages][zulip-rtd-commit-messages] for details.
Here's an example of a longer commit message that will be used for a pull request:
```
Integrate Fail2Ban.
Updates Zulip logging to put an unambiguous entry into the logs such
that fail2ban can be configured to look for these entries.
Tested on my local Ubuntu development server, but would appreciate
someone testing on a production install with more users.
Fixes #1755.
```
The first line is the summary. It's a complete sentence, ending in a period. It
uses a present-tense action verb, "Integrate", rather than "Integrates" or
"Integrating".
The following paragraphs are full prose and explain why and how the change was
made. It explains what testing was done and asks specifically for further
testing in a more production-like environment.
The final paragraph indicates that this commit addresses and fixes issue #1755.
When you submit your pull request, GitHub will detect and link this reference
to the appropriate issue. Once your commit is merged into zulip/master, GitHub
will automatically close the referenced issue. See [Closing issues via commit
messages][github-help-closing-issues] for details.
Make as many commits as you need to to address the issue or implement your feature.
## Push your commits to GitHub
As you're working, it's a good idea to frequently push your changes to GitHub.
This ensures your work is backed up should something happen to your local
machine and allows others to follow your progress. It also allows you to
[work from multiple computers][self-multiple-computers] without losing work.
Pushing to a feature branch is just like pushing to master:
```
$ git push origin <branch-name>
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (6/6), 658 bytes | 0 bytes/s, done.
Total 6 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 1 local objects.
To git@github.com:christi3k/zulip.git
* [new branch] issue-demo -> issue-demo
```
If you want to see what git will do without actually performing the push, add
the `-n` (dry-run) option: `git push -n origin <branch-name>`. If everything
looks good, re-run the push command without `-n`.
If the feature branch does not already exist on GitHub, it will be created when
you push and you'll see `* [new branch]` in the command output.
## Examine and tidy your commit history
Examining your commit history prior to submitting your pull request is a good
idea. Is it tidy such that each commit represents a minimally coherent idea
(see [commit discipline][zulip-rtd-commit-discipline])? Do your commit messages
follow [Zulip's style][zulip-rtd-commit-messages]? Will the person reviewing
your commit history be able to clearly understand your progression of work?
On the command line, you can use the `git log` command to display an easy to
read list of your commits:
```
$ git log --all --graph --oneline --decorate
* 4f8d75d (HEAD -> 1754-docs-add-git-workflow) docs: Add details about configuring Travis CI.
* bfb2433 (origin/1754-docs-add-git-workflow) docs: Add section for keeping fork up-to-date to Git Guide.
* 4fe10f8 docs: Add sections for creating and configuring fork to Git Guide.
* 985116b docs: Add graphic client recs to Git Guide.
* 3c40103 docs: Add stubs for remaining Git Guide sections.
* fc2c01e docs: Add git guide quickstart.
| * f0eaee6 (upstream/master) bug: Fix traceback in get_missed_message_token_from_address().
```
Alternatively, use your graphical client to view the history for your feature branch.
If you need to update any of your commits, you can do so with an interactive
[rebase][github-help-rebase]. Common reasons to use an interactive rebase
include:
- squashing several commits into fewer commits
- splitting a single commit into two or more
- rewriting one or more commit messages
There is ample documentation on how to rebase, so we won't go into details
here. We recommend starting with GitHub's help article on
[rebasing][github-help-rebase] and then consulting Git's documentation for
[git-rebase][gitbook-git-rebase] if you need more details.
If all you need to do is edit the commit message for your last commit, you can
do that with `git commit --amend`. See [Git Basics - Undoing
Things][gitbook-basics-undoing] for details on this and other useful commands.
## Force-push changes to GitHub after you've altered your history
Any time you alter history for commits you have already pushed to GitHub,
you'll need to prefix the name of your branch with a `+`. Without this, your
updates will be rejected with a message such as:
```
$ git push origin 1754-docs-add-git-workflow
To git@github.com:christi3k/zulip.git
! [rejected] 1754-docs-add-git-workflow -> 1754-docs-add-git-workflow (non-fast-forward)
error: failed to push some refs to 'git@github.com:christi3k/zulip.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
```
Re-running the command with `+<branch>` allows the push to continue by
re-writing the history for the remote repository:
```
$ git push origin +1754-docs-add-git-workflow
Counting objects: 12, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (12/12), 3.71 KiB | 0 bytes/s, done.
Total 12 (delta 8), reused 0 (delta 0)
remote: Resolving deltas: 100% (8/8), completed with 2 local objects.
To git@github.com:christi3k/zulip.git
+ 2d49e2d...bfb2433 1754-docs-add-git-workflow -> 1754-docs-add-git-workflow (forced update)
```
This is perfectly okay to do on your own feature branches, especially if you're
the only one making changes to the branch. If others are working along with
you, they might run into complications when they retrieve your changes because
anyone who has based their changes off a branch you rebase will have to do a
complicated rebase.
[gitbook-add]: https://git-scm.com/docs/git-add
[gitbook-basics-undoing]: https://git-scm.com/book/en/v2/Git-Basics-Undoing-Things
[gitbook-fetch]: https://git-scm.com/docs/git-fetch
[gitbook-git-branch]: https://git-scm.com/docs/git-branch
[gitbook-git-pull]: https://git-scm.com/docs/git-pull
[gitbook-git-rebase]: https://git-scm.com/docs/git-rebase
[gitbook-git-status]: https://git-scm.com/docs/git-status
[gitbook-other-envs-bash]: https://git-scm.com/book/en/v2/Git-in-Other-Environments-Git-in-Bash
[gitbook-other-envs-zsh]: https://git-scm.com/book/en/v2/Git-in-Other-Environments-Git-in-Zsh
[gitbook-rm]: https://git-scm.com/docs/git-rm
[github-help-closing-issues]: https://help.github.com/articles/closing-issues-via-commit-messages/
[github-help-push]: https://help.github.com/articles/pushing-to-a-remote/
[github-help-rebase]: https://help.github.com/articles/using-git-rebase/
[github-help-sync-fork]: https://help.github.com/articles/syncing-a-fork/
[how-git-is-different]: ./the-git-difference.html
[zulip-git-guide-up-to-date]: ../git/using.html#keep-your-fork-up-to-date
[zulip-rtd-commit-discipline]: ../contributing/version-control.html#commit-discipline
[zulip-rtd-commit-messages]: ../contributing/version-control.html#commit-messages

View File

@@ -3,28 +3,28 @@
When you work on Zulip code, there are three working copies
of the Zulip git repo that you are generally concerned with:
- local copy: This lives on your laptop or your remove dev instance.
- local copy: This lives on your laptop or your remote dev instance.
- forked copy: This lives on GitHub, and it's tied to your account.
- official Zulip repo: https://github.com/zulip/zulip
- official Zulip repo: This lives on the Zulip org on GitHub. Link [here](https://github.com/zulip/zulip).
We sometimes call the forked copy the **origin** remote.
We call the forked copy the **origin** remote.
We sometimes call the official repo the **upstream** remote.
We call the official repo the **upstream** remote.
When you work on Zulip code, you will end up moving code between
the various working copies.
## Workflows
Sometimes you need to get commits. Here are some scenarios:
Sometimes you need to get commits. Here are some scenarios:
- You may fork the official Zulip repo to your GitHub fork.
- You may fetch commits from the offical Zulip repo to your local copy.
- You may fetch commits from the official Zulip repo to your local copy.
- You occasionally may fetch commits from your forked copy.
Sometimes you want to publish commits. Here are scenarios:
Sometimes you want to publish commits. Here are some scenarios:
- You push code from your local copy to your GitHub fork. (You usually
- You push code from your local copy to your GitHub fork. (You usually
want to put the commit on a feature branch.)
- You submit a PR to the official Zulip repo.
@@ -49,5 +49,5 @@ working copies:
- `git fetch`: This grabs code from another repo to your local copy.
- `git push`: This pushes code from your local repo to one of the remotes.
- `git remote`: This helps you configure short names for remotes.
- `git pull`: **Do not use this, please**!
- `git pull`: This pulls code, but by default creates a merge commit. **Do not use this, please**!

150
docs/git/zulip-tools.md Normal file
View File

@@ -0,0 +1,150 @@
# Zulip-specific tools
This article documents several useful tools that can save you a lot of
time when working with Git on the Zulip project.
## Set up git repo script
In the `tools` directory of [zulip/zulip][github-zulip-zulip] you'll
find a bash script `setup-git-repo`. This script installs the Zulip
pre-commit hook. This hook will run each time you `git commit` to
automatically run Zulip's linters on just the files that the commit
modifies. The hook passes no matter the result of the linter, but you
should still pay attention to any notices or warnings it displays.
It's simple to use. Make sure you're in the clone of zulip and run the following:
```
$ ./tools/setup-git-repo
```
The script doesn't produce any output if successful. To check that the hook has
been installed, print a directory listing for `.git/hooks` and you should see
something similar to:
```
$ ls -l .git/hooks
pre-commit -> ../../tools/pre-commit
```
## Set up Travis CI integration
You might also wish to [configure your fork for use with Travis CI][zulip-git-guide-travisci].
## Reset to pull request
`tools/reset-to-pull-request` is a short-cut for [checking out a pull request
locally][zulip-git-guide-fetch-pr]. It works slightly differently from the method
described above in that it does not create a branch for the pull request
checkout.
**This tool checks for uncommitted changes, but it will move the
current branch using `git reset --hard`. Use with caution.**
First, make sure you are working in a branch you want to move (in this
example, we'll use the local `master` branch). Then run the script
with the ID number of the pull request as the first argument.
```
$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
$ ./tools/reset-to-pull-request 1900
+ request_id=1900
+ git fetch upstream pull/1900/head
remote: Counting objects: 159, done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 159 (delta 94), reused 91 (delta 91), pack-reused 51
Receiving objects: 100% (159/159), 55.57 KiB | 0 bytes/s, done.
Resolving deltas: 100% (113/113), completed with 54 local objects.
From https://github.com/zulip/zulip
* branch refs/pull/1900/head -> FETCH_HEAD
+ git reset --hard FETCH_HEAD
HEAD is now at 2bcd1d8 troubleshooting tip about provisioning
```
## Fetch a pull request and rebase
`tools/fetch-rebase-pull-request` is a short-cut for [checking out a pull
request locally][zulip-git-guide-fetch-pr] in its own branch and then updating it with any
changes from upstream/master with `git rebase`.
Run the script with the ID number of the pull request as the first argument.
```
$ tools/fetch-rebase-pull-request 1913
+ request_id=1913
+ git fetch upstream pull/1913/head
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/zulip/zulip
* branch refs/pull/1913/head -> FETCH_HEAD
+ git checkout upstream/master -b review-1913
Branch review-1913 set up to track remote branch master from upstream.
Switched to a new branch 'review-1913'
+ git reset --hard FETCH_HEAD
HEAD is now at 99aa2bf Add provision.py fails issue in common erros
+ git pull --rebase
Current branch review-1913 is up to date.
```
## Fetch a pull request without rebasing
`tools/fetch-pull-request` is a similar to `tools/fetch-rebase-pull-request`, but
it does not rebase the pull request against upstream/master, thereby getting
exactly the same repository state as the commit author had.
Run the script with the ID number of the pull request as the first argument.
```
$ tools/fetch-pull-request 5156
+ git diff-index --quiet HEAD
+ request_id=5156
+ remote=upstream
+ git fetch upstream pull/5156/head
From https://github.com/zulip/zulip
* branch refs/pull/5156/head -> FETCH_HEAD
+ git checkout -B review-original-5156
Switched to a new branch 'review-original-5156'
+ git reset --hard FETCH_HEAD
HEAD is now at 5a1e982 tools: Update clean-branches to clean review branches.
```
## Delete unimportant branches
`tools/clean-branches` is a shell script that removes branches that are either:
1. Local branches that are ancestors of origin/master.
2. Branches in origin that are ancestors of origin/master and named like `$USER-*`.
3. Review branches created by `tools/fetch-rebase-pull-request` and `tools/fetch-pull-request`.
First, make sure you are working in branch `master`. Then run the script without any
arguments for default behavior. Since removing review branches can inadvertently remove any
feature branches whose names are like `review-*`, it is not done by default. To
use it, run `tools/clean-branches --reviews`.
```
$ tools/clean-branches --reviews
Deleting local branch review-original-5156 (was 5a1e982)
```
## Merge conflict on yarn.lock file
If there is a merge conflict on yarn.lock, yarn should be run to
regenerate the file. *Important* don't delete the yarn.lock file. Checkout the
latest one from origin/master so that yarn knows the previous asset versions.
Run the following commands
```
git checkout origin/master -- yarn.lock
yarn install
git add yarn.lock
git rebase --continue
```
[github-zulip-zulip]: https://github.com/zulip/zulip/
[zulip-git-guide-fetch-pr]: ../git/collaborate.html#checkout-a-pull-request-locally
[zulip-git-guide-travisci]: ../git/cloning.html#step-3-configure-travis-ci-continuous-integration

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

@@ -3,158 +3,105 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to Zulip documentation!
===============================
Welcome to the Zulip documentation!
===================================
Zulip is a powerful, open source group chat application. Written in
Python and using the Django framework, Zulip supports both private
messaging and group chats via conversation streams.
Welcome! Zulip's documentation is split into four parts:
Zulip also supports fast search, drag-and-drop file uploads, image
previews, group private messages, audible notifications, missed-message
emails, desktop apps, and much more.
- `User documentation <https://zulipchat.com/help>`__, for users and
administrators of Zulip organizations.
- `Installation documentation <production/overview.html>`__, for
installing and maintaining a self-hosted Zulip installation.
- `API documentation <https://zulipchat.com/api/>`__, for writing
integrations or bots using the Zulip API.
- `Contributor documentation <overview/contributing.html>`__, for
developing the Zulip software, translating, submitting bug reports,
or making other contributions to the project.
Further information on the Zulip project and its features can be found
at `https://www.zulip.org <https://www.zulip.org>`__ and in these
docs. Our code is available at `our GitHub repository
<https://github.com/zulip/>`__.
Zulip has well over 150,000 words of documentation. If you can't find
what you're looking for, please `let us know
<contributing/chat-zulip-org.html>`__! Further information on the
Zulip project and its features can be found at `https://www.zulip.org
<https://www.zulip.org>`__.
This set of documents covers installation and contribution instructions.
This site contains our installation and contributor documentation. If
this is your first time here, you may want to start with `Production
overview <production/overview.html>`_ or `Contributing to Zulip
<overview/contributing.html>`_.
Contents:
* :ref:`overview`
* :ref:`zulip-in-production`
* :ref:`development-environment`
* :ref:`developer-tutorials`
* :ref:`code-contribution-guide`
* :ref:`code-testing`
* :ref:`subsystem-documentation`
* :ref:`Overview <overview>`
* :ref:`Zulip in Production <zulip-in-production>`
* :ref:`Development Environment <development-environment>`
* :ref:`Developer Tutorials <developer-tutorials>`
* :ref:`Git Guide <git-guide>`
* :ref:`Code Contribution Guide <code-contribution-guide>`
* :ref:`Code Testing <code-testing>`
* :ref:`Subsystem Documentation <subsystem-documentation>`
* :ref:`Translating <translating>`
.. _overview:
.. toctree::
:maxdepth: 2
:caption: Overview
:maxdepth: 3
readme-symlink
architecture-overview
directory-structure
roadmap
changelog
overview/index
.. _zulip-in-production:
.. toctree::
:maxdepth: 2
:caption: Zulip in production
:maxdepth: 3
Production overview <prod>
prod-requirements
Installing a production server <prod-install>
prod-troubleshooting
prod-customize
prod-mobile-push-notifications
prod-maintain-secure-upgrade
security-model
prod-authentication-methods
prod-postgres
production/index
.. _development-environment:
.. toctree::
:maxdepth: 2
:caption: Development environment
:maxdepth: 3
Development environment installation <dev-overview>
Recommended setup (Vagrant) <dev-env-first-time-contributors>
Advanced setup (non-Vagrant) <dev-setup-non-vagrant>
Using the development environment <using-dev-environment>
Developing remotely <dev-remote>
development/index
.. _developer-tutorials:
.. toctree::
:maxdepth: 2
:caption: Developer tutorials
:maxdepth: 3
integration-guide
integration-docs-guide
webhook-walkthrough
running-bots-guide
writing-bots-guide
new-feature-tutorial
writing-views
life-of-a-request
reading-list
screenshot-and-gif-software
fixing-commits
git-cheat-sheet-detailed
git-cheat-sheet
shell-tips
working-copies
tutorials/index
.. _git-guide:
.. toctree::
:maxdepth: 3
git/index
.. _code-contribution-guide:
.. toctree::
:maxdepth: 2
:caption: Code contribution guide
:maxdepth: 3
git-guide
version-control
code-style
mypy
code-reviewing
chat-zulip-org
zulipbot-usage
accessibility
bug-reports
contributing/index
.. _code-testing:
.. toctree::
:maxdepth: 2
:caption: Code testing
:maxdepth: 3
testing
linters
testing-with-django
testing-with-node
testing-with-casper
travis
manual-testing
testing/index
.. _subsystem-documentation:
.. toctree::
:maxdepth: 2
:caption: Subsystem documentation
:maxdepth: 3
dependencies
settings
events-system
queuing
custom-apps
pointer
markdown
realms
management-commands
front-end-build-process
schema-migrations
html_css
hashchange-system
emoji
hotspots
full-text-search
email
analytics
translating
html-templates
client
logging
typing-indicators
release-checklist
api-release-checklist
swagger-api-docs
README
user-docs
subsystems/index
.. _translating:
.. toctree::
:maxdepth: 3
translating/index
Index <https://zulip.readthedocs.io/en/latest/>

View File

@@ -1,3 +0,0 @@
# Using Docker (experimental)
Moved to [Advanced setup (Docker)](dev-setup-non-vagrant.html#using-docker-experimental).

View File

@@ -1,3 +0,0 @@
# Installing manually on UNIX
Moved to [Advanced setup (Installing manually on Linux)](dev-setup-non-vagrant.html#installing-manually-on-linux).

View File

@@ -1,3 +0,0 @@
# Installing directly on Ubuntu
Moved to [Advanced setup (Install directly on Ubuntu)](dev-setup-non-vagrant.html#installing-directly-on-ubuntu).

View File

@@ -6,11 +6,10 @@ Key Codebases
The core Zulip application is at
[<https://github.com/zulip/zulip>](https://github.com/zulip/zulip) and
is a web application written in Python 2.7 (soon to also support
Python 3) and using the Django framework. That codebase includes
server-side code and the web client, as well as Python API bindings
and most of our integrations with other services and applications (see
[the directory structure guide](directory-structure.html)).
is a web application written in Python 3.x and using the Django framework. That
codebase includes server-side code and the web client, as well as Python API
bindings and most of our integrations with other services and applications (see
[the directory structure guide](../overview/directory-structure.html)).
[Zulip Mobile](https://github.com/zulip/zulip-mobile) is the official
mobile Zulip client supporting both iOS and Android, written in
@@ -57,12 +56,12 @@ choose whether to allow anyone to register an account and join, or
only allow people who have been invited, or restrict registrations to
members of particular groups (using email domain names or corporate
single-sign-on login for verification). For more on security
considerations, see [the security model section](security-model.html).
considerations, see [the security model section](../production/security-model.html).
The default Zulip home screen is like a chronologically ordered inbox;
The Zulip "All messages" screen is like a chronologically ordered inbox;
it displays messages, starting at the oldest message that the user
hasn't viewed yet (for more on that logic, see [the guide to the
pointer and unread counts](pointer.html)). The home screen displays
pointer and unread counts](../subsystems/pointer.html)). The "All messages" screen displays
the most recent messages in all the streams a user has joined (except
for the streams they've muted), as well as private messages from other
users, in strict chronological order. A user can *narrow* to view only
@@ -81,7 +80,7 @@ real-time notifications they find irrelevant.
Components
----------
![architecture-simple](images/architecture_simple.png)
![architecture-simple](../images/architecture_simple.png)
### Django and Tornado
@@ -113,7 +112,7 @@ exception to this is that Zulip uses websockets through Tornado to
minimize latency on the code path for **sending** messages.
There is detailed documentation on the
[real-time push and event queue system](events-system.html); most of
[real-time push and event queue system](../subsystems/events-system.html); most of
the code is in `zerver/tornado`.
#### HTML templates, JavaScript, etc.
@@ -126,10 +125,10 @@ live-rendering HTML from JavaScript for things like the main message
feed.
For more details on the frontend, see our documentation on
[translation](translating.html),
[templates](html-templates.html),
[directory structure](directory-structure.html), and
[the static asset pipeline](front-end-build-process.html).
[translation](../translating/translating.html),
[templates](../subsystems/html-templates.html),
[directory structure](../overview/directory-structure.html), and
[the static asset pipeline](../subsystems/front-end-build-process.html).
[Jinja2]: http://jinja.pocoo.org/
[Handlebars]: http://handlebarsjs.com/
@@ -180,7 +179,7 @@ processes that process event queues. We use event queues for the kinds
of tasks that are best run in the background because they are
expensive (in terms of performance) and don't have to be synchronous
--- e.g., sending emails or updating analytics. Also see [the queuing
guide](queuing.html).
guide](../subsystems/queuing.html).
### memcached
@@ -227,7 +226,7 @@ processes started by Supervisor are queue processors that continually
pull things out of a RabbitMQ queue and handle them; they are defined
in `zerver/worker/queue_processors.py`.
Also see [the queuing guide](queuing.html).
Also see [the queuing guide](../subsystems/queuing.html).
### PostgreSQL
@@ -295,8 +294,8 @@ are welcome!
* **star**: Zulip allows a user to mark any message they can see,
public or private, as "starred". A user can easily access messages
they've starred through the "Starred messages" link in the menu
near "Home", or use "is:starred" as a narrow or a search
they've starred through the "Starred messages" link in the
left sidebar, or use "is:starred" as a narrow or a search
constraint. Whether a user has or has not starred a particular
message is private; other users and realm admins don't know
whether a message has been starred, or by whom.

Some files were not shown because too many files have changed in this diff Show More