Compare commits

...

1783 Commits

Author SHA1 Message Date
Tim Abbott
a063dd3b26 Update changelog for Zulip 1.4.3 release. 2017-01-29 15:09:02 -08:00
Tim Abbott
1cdd451d70 streams: Fix autosubscribe security bug (CVE-2017-0881).
A bug in Zulip's implementation of the "stream exists" endpoint meant
that any user of a Zulip server could subscribe to an invite-only
stream without needing to be invited by using the "autosubscribe"
argument.

Thanks to Rafid Aslam for discovering this issue.
2017-01-29 15:09:02 -08:00
Tim Abbott
8cc7642cdd Update changelog for Zulip 1.4.1 and 1.4.2 releases. 2016-09-27 20:09:20 -07:00
Tim Abbott
6883c916af Upgrade Django to 1.8.15 with Zulip patches. 2016-09-27 20:09:20 -07:00
Tim Abbott
978a568c0f puppet: Fix buggy logrotate configuration. 2016-09-27 20:01:17 -07:00
Steve Howell
f6975f9334 Upgrade: revert change to default LOCAL_UPLOADS_DIR in prod settings.
The main purpose of the "var" convention is to make it easy to write stuff
inside of our git repo when running a dev instance, and then "var" gets
excluded from checkins. For production, that's not as much of a concern.
For upgrades we don't want to be changing the directory around and confusing
matters, especially with the extra moving part of nginx configs (which have
their own issues in terms of being overwritten by accident when admins go to
S3).
2016-09-02 12:30:29 -07:00
Christie Koehler
0120ff5612 upgrade: Create prod_settings symlink in step 2 if it doesn't exist.
Between releases 1.3.13 and 1.4.0, local_settings.py was renamed to
prod_settings.py. The upgrade scripts were adjusted to reflect this name
change. But because the first part of the upgrade script is run with the
currently installed version's code, the symlink to /etc/zulip/settings.py is
created with the old name. This was causing upgrade-zulip-stage-2 to fail.

Now upgrade-zulip-stage-2 creates the symlink at zproject/prod_settings.py
if it doesn't already exist.

Fixes #1731.
2016-09-01 21:17:11 -07:00
Tim Abbott
7e4caf3a67 Release Zulip 1.4. 2016-08-25 10:49:00 -07:00
Tim Abbott
fba93cb494 scripts: rename deploy-zulip-from-git to reference upgrading. 2016-08-25 10:48:59 -07:00
Tim Abbott
7f445be23d docs: Clean up headings for maintenance page. 2016-08-25 10:48:48 -07:00
Tim Abbott
54c5c989c9 docs: Fix some broken links in headings. 2016-08-25 10:41:00 -07:00
Tim Abbott
c0799a9d09 docs: Fix docs for upgrading from a git repository. 2016-08-25 10:40:51 -07:00
Tim Abbott
9839d93362 docs: Clean up duplicated content in development overview. 2016-08-25 10:40:51 -07:00
Tim Abbott
f6c4e46afe docs: Move README.dev.md into ReadTheDocs.
Fixes: #669.
2016-08-25 10:40:51 -07:00
Tim Abbott
d876909b69 docs: Clean up development environment headings. 2016-08-25 10:40:51 -07:00
Tim Abbott
30b5c2a4c0 docs: Document the fact that 14.04->16.04 is not supported. 2016-08-25 10:40:51 -07:00
Tim Abbott
f1a91c8028 docs: Document Zulip PPA is available for 16.04 as well. 2016-08-25 10:40:51 -07:00
Tim Abbott
c5417e723b docs: Fix command sequence for retrying Zulip installation. 2016-08-25 10:40:51 -07:00
Tim Abbott
c0975b03a5 docs: Document Ubuntu 16.04 support in production. 2016-08-25 10:40:51 -07:00
Tim Abbott
c0e68d59cb docs: Rename status/debug page to troubleshooting. 2016-08-25 09:37:33 -07:00
Tim Abbott
be4e806d60 docs: Collapse install steps 2 and 3 together. 2016-08-25 09:37:33 -07:00
Tim Abbott
cd632faff6 docs: Clean up scrollbar in install docs. 2016-08-25 09:37:33 -07:00
Tim Abbott
8a82c29d21 docs: Move SSL docs to a dedicated page. 2016-08-25 09:37:33 -07:00
Tim Abbott
8086cc549f docs: Merge prod-auth-first-login into main installation page. 2016-08-25 09:37:33 -07:00
Tim Abbott
1d273b93da docs: Move screenshots to their own page. 2016-08-25 09:37:33 -07:00
Tim Abbott
da0d9e716d docs: Move management docs to a better place and expand.
Now that a management command is not required to install Zulip, we can
bury the documentation on them a bit more.

Fixes: #551.
2016-08-25 09:37:33 -07:00
Christie Koehler
5a3db059d4 docs: Rewrite first time prod login docs to use new realm creation flow.
- Adds heading and reorganizes sections for improved clarity. Sections
  now ordered: Create user, grant admin access, default realm settings,
  changing realm settings, other manage.py commands, if you can't login.
- Adds screen shots of Zulip web interface.
2016-08-25 09:37:33 -07:00
Vishnu Ks
a7ead9e99d settings: Eliminate ADMIN_DOMAIN for creating initial realm.
We now use `./manage.py generate_realm_creation_link` as the flow flow
for creating one's first realm.
2016-08-25 09:37:33 -07:00
Tim Abbott
5b68e0defe settings: Fix buggy MANDRILL_API_KEY logic. 2016-08-25 09:37:33 -07:00
Tim Abbott
a90b470205 Fix regression in search interaction with wide unicode characters.
Apparently, we had incorrectly concluded that our highlight_string
search result highlighting offsets coming from tsearch_extras were
measured in bytes, whereas in fact it is measured in characters.
2016-08-25 09:04:29 -07:00
Tim Abbott
88fce4761a Remove obsolete README.prod.md.
This was left as a placeholder when we moved the production
documentation to ReadTheDocs, but is no longer required since we have
eliminated links to the old path.
2016-08-24 22:21:58 -07:00
Tim Abbott
21b9efd985 Clarify ALLOWED_HOSTS string format.
This is obvious to anyone who knows Python, but knowing Python should
not be a requirement to administer a Zulip server.

Fixes #1606.
2016-08-24 22:19:54 -07:00
Tim Abbott
f7ede485d2 docs: Move subscribe step to start of install docs. 2016-08-24 21:04:10 -07:00
Christie Koehler
7d6541867b docs: Update Let's Encrypt CertBot install instructions. 2016-08-24 19:02:22 -07:00
Tim Abbott
d09b07310d docs: Clean up and clarify documentation flow. 2016-08-24 19:02:18 -07:00
Christie Koehler
456da49b06 docs: Expand production install docs.
- Moves Let's Encrypt option for ssl certs above self-signed option.
  Updates Let's Excrypt instructions to user Certbot (new recommended
  method). Fixes #1426.
- Adds and updates headings for clarity.
- Adds new step 6 about configuring authentication (from
  prod-auth-first-login.html).
- Adds emphasis on using `su zulip`, `sudo -u zulip -i`, and `sudo -i`
  where appropriate. Fixes #1356.

Fixes #1245.
2016-08-24 19:02:11 -07:00
Tim Abbott
cd0ef4ae5b prod-requirements: Remove unnecssary authentication section. 2016-08-24 16:34:00 -07:00
Tim Abbott
2c171df9b5 docs: Reorganize requirements page with server/credentials categories. 2016-08-24 16:32:06 -07:00
Christie Koehler
b90f5537b0 docs: Improve production requirements doc.
- Adds headings and organizes for greater clarity.
- Adds some detail about each of the requirements.
2016-08-24 15:14:18 -07:00
Christie Koehler
f1daf3d66a docs: Make headings consistent and use the imperative. 2016-08-24 15:02:14 -07:00
Christie Koehler
48ba0e3974 docs: Improve 'upgrading' section of prod-maintain-secure-upgrade page.
- Reformats bullets as regular paragraphs for improved readability.
- Adds headings to subsections to make them easier to read and linkable.
- Clarifies minor points throughout.
2016-08-24 15:01:32 -07:00
Christie Koehler
36b6184be2 docs: Improve navigation of prod-customize page.
- Add headings for each of the six major sections: integrations, streams
  and topics, notification settings, mobile and desktop apps, other
  great features, and enjoy your Zulip installation.
- Add links to each of these sections to top of page, with first and
  most important four formatted as a list.
2016-08-24 14:56:39 -07:00
Christie Koehler
58ee43c3f0 docs: Improve prod-health-check-debug page.
- Adds headings for 'supervisorctl' and 'troubleshooting'.
- Rearranges to include most important info at top: that Supervisor is
  used, a reminder to review components architecture, log location, link
  to troubleshooting services section, and a request to report any
  issues not already documented on this page.
2016-08-24 14:52:44 -07:00
Christie Koehler
d4f0565c92 docs: Improve Zulip in Production page navigation and ToC.
Improves readability of ToC and makes pages more navigable by shortening
Zulip in Production page headings.
2016-08-24 14:48:11 -07:00
Christie Koehler
8782f6a198 docs: Improve navigation of prod-maintain-secure-upgrade page.
- Adds a heading for Upgrading and clarifies wording on Backups heading.
- Adds intro text with links to other sections.
2016-08-24 14:46:40 -07:00
Tim Abbott
4e33b001af Pull latest translations from Transifex.
A big addition here is tons of strings translated for Malayalam.
2016-08-24 14:42:00 -07:00
Tim Abbott
682d78bc30 puppet: Add default logrotate configuration.
This should prevent Zulip from eating all the disk now that we are
using the race-free WatchedFileHandler rather than
TimedRotatingFileHandler.
2016-08-24 14:30:54 -07:00
Tim Abbott
7965320877 Update changelog for Zulip 1.4 release. 2016-08-24 14:26:53 -07:00
Tim Abbott
4c834172ed tools: Use 'upstream' as expected name for main zulip repo.
Fixes: #1698.
2016-08-24 14:23:37 -07:00
Tim Abbott
797a7ef97b notifications: Don't spoof emails as from users by default.
The previous default configuration resulted in delivery problems if
the Zulip server was authorized in the SPF records for the domains of
all users on the Zulip server.
2016-08-24 14:10:52 -07:00
Steve Howell
6af0bdfe6e bots: Add --config-file to contrib_bots/run.py. 2016-08-24 12:09:11 -07:00
Steve Howell
acb3c6b75a bots: Fix typo in contrib_bots/lib/readme.md. 2016-08-24 12:08:39 -07:00
Tim Abbott
1c40df9363 static_asset_compiler: Use correct package name on trusty. 2016-08-22 23:47:03 -07:00
Tim Abbott
97b622dffa puppet: Fix postgres_appdb_tuned manifest on trusty. 2016-08-22 23:41:07 -07:00
Tim Abbott
750e43518f puppet: Ensure supervisord starts on boot with systemd.
This is important to ensure that Zulip comes up properly after a
reboot on Ubuntu Xenial.
2016-08-22 23:25:54 -07:00
Rishi Gupta
4bfac78303 Refactor /integrations page links to support subdomains.
Also changes all links to /integrations to be relative rather than
absolute, so that users will primarily access the /integrations page
for their subdomain.
2016-08-22 22:39:53 -07:00
Tim Abbott
e3affe96a5 subdomains: Use subdomain host in password reset emails. 2016-08-22 22:39:52 -07:00
Tim Abbott
2b0a486077 Eliminate cross-realm PM conversation with ADMIN_DOMAIN.
In the future, we can use UserProfile.is_staff to control this, but
there isn't a current use case for it.
2016-08-22 21:46:16 -07:00
Tim Abbott
3bdbc33e94 initialize_voyager_db: Fix zulip.com hardcoding. 2016-08-22 21:36:15 -07:00
Tim Abbott
55d7947b76 email_mirror: Use ERROR_BOT for error reporting.
This has the nice side effect of getting rid of the now-unnecessary
ADMIN_DOMAIN from this codepath -- we really just want whichever
realm ERROR_BOT is in.
2016-08-22 21:28:01 -07:00
Tim Abbott
7d19d1809d android: Default to the GOOGLE_CLIENT_ID needed by the Android app. 2016-08-22 21:06:40 -07:00
Brock Whittaker
edb7d72dc2 Fix 1px private message group header height difference.
Due to the border-top being tied to the .message-header-contents
element rather than the recipient_row in private message groups, the
floating container would be 1px more vertical when representing private
message groups than with public message groups.
2016-08-22 20:37:49 -07:00
Steve Howell
ba9e7e290d frontend: Extract dispatch_normal_event().
Extract dispatch_normal_event() from the inner
function dispatch_event() in get_events_success()
in server_events.js.  Also, alphabetize the cases in
the switch statement.  This starts to address #1541,
but see the discussion on the ticket for how we can
continue to clean up our event dispatching.
2016-08-22 20:18:02 -07:00
Tim Abbott
3d83f25b15 contrib_bots: Expand documentation. 2016-08-22 19:53:16 -07:00
Steve Howell
8d0c68ac39 bots: Add example bots for "followup" and "help".
This commit also starts to build out the infrastructure for
helping Zulip contributors to more easily author bots in
a way that sets up for running some bots on the server itself.
2016-08-22 19:43:12 -07:00
Steve Howell
cd2e36d66f export: Add lib.utils.query_chunker(). 2016-08-22 19:27:32 -07:00
Steve Howell
fd6ee7117f tests: Renamed AuthedTestCase to ZulipTestCase. 2016-08-22 19:07:44 -07:00
Steve Howell
29ba10dfdd docs: Add docs for Django backend tests. 2016-08-22 19:07:44 -07:00
Tim Abbott
95fbd5ba31 Update zulip.com/integrations link to point to zulipchat.com.
zulip.com will stop running at some point in the near future, and we
don't want these links to break.
2016-08-22 17:26:41 -07:00
Tim Abbott
2be597dd09 puppet: Move support for accepting a loadbalancer to zulip manifests.
Previously, we didn't have an easy process for how one should do this.

Now, it's an (undocumented) zulip.conf setting!
2016-08-22 17:19:03 -07:00
Tim Abbott
13a51737d8 update-prod-static: Fix buggy color code usage. 2016-08-22 16:38:23 -07:00
Tim Abbott
55f2c49bbf build-release-tarball: Fix code for handling update-prod-static.log.
This is still messy code, but at least the links to where the log file
is are correct.
2016-08-22 16:37:48 -07:00
Tim Abbott
96a5388fcb mandrill: Fix hardcoded check for settings.VOYAGER.
Since this delayed sending feature is the only thing
settings.MANDRILL_API_KEY is used for, it seems reasonable for that to
be the gate as to whether we actually use Mandrill.
2016-08-22 16:25:28 -07:00
Tim Abbott
916a77e764 settings: Use DEFAULT_FROM_EMAIL for error traceback reporting. 2016-08-22 16:22:52 -07:00
Tim Abbott
602c7c69a9 lint: Document line length checking. 2016-08-19 12:08:22 -07:00
Tim Abbott
2e2dee3396 lint: Ban lines longer than 140 characters without #ignorelongline. 2016-08-19 12:03:09 -07:00
Tim Abbott
e1e384acc0 realm_emoji: Fix management command usage output. 2016-08-19 11:59:38 -07:00
Taranjeet Singh
7fc170d808 lint-all: Fix line with length greater than 120.
This updates file tools/lint-all.
2016-08-19 11:56:43 -07:00
Taranjeet Singh
eef1d78e68 bitbucket2.py: Fix line with length greater than 120.
This updates file zerver/views/webhooks/bitbucket2.py.
2016-08-19 11:56:43 -07:00
Taranjeet Singh
86ecf28588 prod_settings_template.py: Fix line with length greater than 120.
This updates file zproject/prod_settings_template.py.
2016-08-19 11:56:43 -07:00
Taranjeet Singh
230cc228c2 profile_request.py: Fix line with length greater than 120.
This updates file zilencer/management/commands/profile_request.py.
2016-08-19 11:56:43 -07:00
Taranjeet Singh
57253c6ba3 makemessages.py: Fix line with length greater than 120.
This updates file zerver/management/commands/makemessages.py.
2016-08-19 11:56:43 -07:00
Taranjeet Singh
5e5ad9de0c bugdown/__init__.py: Fix line with length greater than 120.
This updates file zerver/lib/bugdown/__init__.py.
2016-08-19 11:56:43 -07:00
Taranjeet Singh
1819157a5f show-last-messages: Fix line with length greater than 120 characters.
This updates file tools/deprecated/iframe-bot/show-last-messages.
2016-08-19 11:56:43 -07:00
Steve Howell
f6b332ecdb docs: Add linters.md to document our linters.
(Also, link to it from the testing docs.)
2016-08-19 11:55:52 -07:00
Steve Howell
bf6a9ebe8a docs: Add Community links to the overview page. 2016-08-19 09:54:17 -07:00
Tim Abbott
399f4f8870 Add management command to send password reset emails.
This is a convenient tool to have around.

We require an unusual argument value of "YES" to send to everyone on
the server, since that's something one should do with a great deal of
care.
2016-08-18 20:12:36 -07:00
Rishi Gupta
64179b2fd2 confirmation: Use realm host in activation URLs.
This is preparation for merging the subdomains feature.
2016-08-18 20:12:36 -07:00
Tim Abbott
b8050ce02f Add realm.host property. 2016-08-18 18:48:40 -07:00
Tim Abbott
b5d85fe5f1 settings: Disable DisallowedHost error emails by default.
These error messages are pretty spammy because most servers on the
public Internet receive some amount of HTTP(S) scanning traffic.

We still log them, just don't email the administrators.
2016-08-18 18:44:20 -07:00
Tim Abbott
7950d3181e zmirror: Fix hardcoding of zulip.com support email address.
We now use support_email == settings.ZULIP_ADMINISTRATOR just like
every other support email address reference.
2016-08-18 18:36:07 -07:00
Tim Abbott
e0432f21f1 Move webathena views to its own file. 2016-08-18 18:26:49 -07:00
Tim Abbott
05d3094420 webathena: Remove hardcoding of zulip.com server. 2016-08-18 18:21:38 -07:00
Tomasz Kolek
b1b864341c Fix @all spam warning when typing @all in backticks.
When user'd like to send a message with @all in backticks
they see spam warning in spite of the fact that nobody
would be alerted.

Fixes: #1505.
2016-08-18 16:10:09 -07:00
Tomasz Kolek
5c82e53b9a Move checking all/everyone message to util.js module.
Create is_all_or_everyone_mentioned function in util.js.
2016-08-18 16:10:09 -07:00
Brock Whittaker
d8f108a5cf Removing unnecessary comment.
This removes a comment that is dated and no longer relevant.
2016-08-18 15:32:30 -07:00
Brock Whittaker
6936d49202 Live update new avatars across users.
This sends an event when a new avatar is uploaded that refreshes the
avatar for all browser clients without the need to reload the browser.

Fixes: #1359.
2016-08-18 15:32:29 -07:00
Umair Khan
194cbf17a1 Allow run command to accept **kwargs. 2016-08-18 15:06:22 -07:00
Tim Abbott
e7aac717e8 Fix markdown ordering bugs with some custom syntax.
!avatar, !modal_link, !gravatar, etc. were incorrectly being processed
before the escape character for code blocks.

While we're at it, we add tests for these special syntaxes.
2016-08-18 14:47:37 -07:00
Steve Howell
c6a888561a tools: Extract build_custom_checkers() in tools/lint-all. 2016-08-18 14:15:01 -07:00
Steve Howell
f955991120 tools: Add bright_red_output() to tools/lint-all 2016-08-18 14:15:01 -07:00
Steve Howell
ffe648baa8 tools: Extract EXCLUDED_FILES in tools/lint-all. 2016-08-18 14:15:01 -07:00
Steve Howell
dfe01c4f83 tools: Move run_parallel() out of run(). 2016-08-18 14:15:01 -07:00
Steve Howell
e3a7b9b1b2 tools: Move check_pyflakes() out of run(). 2016-08-18 14:15:01 -07:00
Steve Howell
3c40157195 tools: Add a run() method to tools/lint-all. 2016-08-18 14:15:01 -07:00
Steve Howell
747744ad61 lint: Allow anchor tags to span up to four lines.
This starts to address 1533.  I still think the </p> tags
should be on their own line lined up with the start tag,
so the linter won't let through the specific example
shown in the ticket.
2016-08-18 14:12:32 -07:00
Steve Howell
88a7ea54d2 lint: Enforce that code blocks can't split lines.
Fixes: #1644.
2016-08-18 14:12:26 -07:00
Steve Howell
479aa5b83d docs: Split out Django/Casper/Node testing docs. 2016-08-18 14:10:46 -07:00
Steve Howell
552a6dc017 tests: Add DocPageTest. 2016-08-18 13:28:58 -07:00
Steve Howell
d1c34a6618 tests: Fix test_create_user_backend().
It was passing in a UserProfile object to client_put(),
which is unnecessary and can break the url coverage
report.
2016-08-18 13:28:58 -07:00
Steve Howell
125dcad379 tools: Report OverflowErrors in url coverage report. 2016-08-18 13:28:58 -07:00
Christie Koehler
27c7319b50 vagrant: Suppress error output for which command. 2016-08-18 13:09:28 -07:00
Tim Abbott
e1b5a0e000 docs: Add link to life of a request docs on URLs. 2016-08-18 12:41:38 -07:00
acrefoot
920e605e17 Add extensive views writing documentation.
[section on REQ substantially expanded by tabbott]

Fixes: #880.
2016-08-18 12:37:33 -07:00
Tim Abbott
483bbfe5dc integrations: Fix a few more badly line-wrapped <code> tags. 2016-08-18 10:54:41 -07:00
Tim Abbott
685d63b6cc notifications: Update digest email link URLs to use realm.uri.
This is preparation for fully supporting each realm having its own
subdomain in Zulip.
2016-08-17 22:58:35 -07:00
Tim Abbott
f357e9d30f integrations: Fix Travis CI webhook URL to not be an example. 2016-08-17 22:53:15 -07:00
Tim Abbott
c9d3708ab8 integrations: Fix linewrapping in Nagios and Jenkins integrations. 2016-08-17 22:53:15 -07:00
Tim Abbott
e7c3a0c819 check-rabbitmq-consumers: Add missing tornado_return consumer.
I'd like to move this list to be automatically generated, but this
fixes the fact that it's missing for now.
2016-08-17 22:53:00 -07:00
Tim Abbott
91ad923d80 notifications: Use realm.uri in unsubscribe links. 2016-08-17 22:44:38 -07:00
Tim Abbott
d876fac01a Use WatchedFileHandler rather than TimedRotatingFileHandler.
TimedRotatingFileHandler does not properly handle multiple processes
writing logs at the same time, and thus can end up losing data.
2016-08-17 22:39:33 -07:00
Tim Abbott
f999f63999 zephyr_mirror_backend: Update support email address.
Arguably we should figure out a way to make this fetch the support
email from the server (or something), but in the short term it seems
worth making the email address at least correct.
2016-08-17 22:39:08 -07:00
Tim Abbott
96cc54b83d integrations: Document GitHub alternative endpoint. 2016-08-17 22:19:54 -07:00
Tim Abbott
743847bdd5 integrations: Fix some broken links / ids. 2016-08-17 22:19:54 -07:00
Tim Abbott
143bec97b4 integrations: Fix Asana page rendering. 2016-08-17 22:19:54 -07:00
Rishi Gupta
d9473979ea Add javascript # navigation for the tabs on the /apps page.
Make it so that /apps/#electron (and related #tags) open the relevant tab.
2016-08-17 22:19:54 -07:00
Tim Abbott
566bef1258 Fix API Python examples missing --site. 2016-08-17 22:19:54 -07:00
Tim Abbott
8d05aec4de zephyr-mirror: Eliminate use of old Humbug name. 2016-08-17 22:19:53 -07:00
Tim Abbott
bc7c9a5bbb corporate: Update Zephyr mirroring docs. 2016-08-17 22:19:53 -07:00
Tim Abbott
48ed7e2e31 notifications: Use realm_uri for click here link. 2016-08-17 22:19:53 -07:00
Rishi Gupta
f51c1ea4ee Minor server_uri fixes in templates/zerver/features.html 2016-08-17 22:19:53 -07:00
Tim Abbott
5f12136e7c notifications: Fix broken one click unsubscribe link. 2016-08-17 22:19:53 -07:00
Tim Abbott
6ef79ac66c notifications: Remove support@zulip.com comment in docstring. 2016-08-17 22:19:53 -07:00
Tim Abbott
74cdb4954c docs: Fix outdated security contact list. 2016-08-17 22:19:53 -07:00
Tim Abbott
c5fb6dfcb8 TOS: Fix forcing users to double-accept terms of service. 2016-08-17 22:19:53 -07:00
Tim Abbott
f0a65fe52a export_messages_single_user: Fix missing order_by.
This fixes a nasty bug where exporting messages sent by a single user
might only contain some of the messages in the event that the
unspecified sort order by the database didn't happen to be sorted by
message ID.
2016-08-17 22:18:58 -07:00
Tim Abbott
f952114010 Remove node_modules/.bin/handlebars from git.
This file, installed back when we had node_modules checked into git,
was leaked when we deleted node_modules/ from git and added it to
.gitignore.  This caused occasional weird errors for anyone who tried
to `rm -rf node_modules` as part of reprovisioning.
2016-08-17 18:01:08 -07:00
Christie Koehler
096b098410 Flush stdout and stderr prior to exiting child process.
This fixes a confusing bug that we ran into where the output from
certain child processes wouldn't appear when running `lint-all` via
`ssh` (without a tty) into the Vagrant environment.
2016-08-16 18:11:14 -07:00
Brock Whittaker
433cdfad57 Restyle input groups to be more vertical
This changes the input group elements from the style where labels are
right aligned and input left aligned, to the labels being above the
input.
2016-08-16 16:38:26 -07:00
Brock Whittaker
cddd9379c6 Add password-container and password-reset wrappers
This adds the wrappers necessary to center the content vertically and
horizontally within the page.
2016-08-16 16:36:45 -07:00
Brock Whittaker
b83691fd6f Apply styling to password reset modal
A centered version of the modal that looks more uniform and centers vertically as the screen height changes.
2016-08-16 16:36:42 -07:00
Sumana Harihareswara
f3abea0f1f doc: Add version number to Trusty in prod requirements. 2016-08-16 16:24:34 -07:00
Sumana Harihareswara
23aaca376e doc: Recommend provision stream for install help.
Adds a recommendation to the developer installation
documentation suggesting visiting the "provision" stream.

Fixes: #1537.
2016-08-16 16:22:20 -07:00
Tim Abbott
28eae24882 Add some links to new pointer docs. 2016-08-16 16:19:14 -07:00
Tim Abbott
b839db1f45 Expand pointer and unread counts guide. 2016-08-16 16:17:54 -07:00
Sumana Harihareswara
1a9f961bb4 doc: Add pointer and unread counts guide.
Tim's comments in #789 are useful to developers
in explaining message selection at browser load,
narrow, etc.
2016-08-16 16:15:38 -07:00
Steve Howell
c12bd853f7 export: Add basic export tests. (fixes #1584) 2016-08-16 13:38:37 -07:00
Steve Howell
ab053845aa export: Fetch messages with two queries. 2016-08-16 13:38:37 -07:00
Steve Howell
a5f651b81a export: Add some user_id filtering to do_export_realm().
This commit only addresses tables that currently derive from
user_profile_config in get_realm_config:

   zerver_userpresence
   zerver_useractivity
   zerver_useractivityinterval
   zerver_subscription
   zerver_recipient
   zerver_stream
   zerver_huddle

It also introduces an entry in realm.json for a virtual
table called "zerver_userprofile_mirrordummy" for dummy users,
which include prior dummy users and users excluded from the call
to do_export_realm().

Note that this feature is not yet exposed in the management command.
2016-08-16 13:38:37 -07:00
Sumana Harihareswara
83cfd3213f doc: Recommend avoiding Vagrant install on slow connections.
Per #1508, the manual install process is better
for the developer environment on slow connections.
2016-08-16 12:50:16 -07:00
Brock Whittaker
f7dac2b2e3 Show hex input field on color picker.
This enables the input field in the color pickers that allows users to
specify the hex of the color they would like to apply.

Fixes: #1364.
2016-08-16 11:31:52 -07:00
ukhan
3c1027a584 Update sockjs-tornado to latest version. 2016-08-15 16:58:58 -07:00
ukhan
a7607f843b Update Tornado to 3.2.2, which does not break tests 2016-08-15 16:57:19 -07:00
Taranjeet Singh
d606b95242 zulip_tools.py: Move zulip_tools.py in scripts/lib.
This commit moves zulip_tools.py as part of cleaning the root directory
and organizing proejct into better directory structure.
2016-08-15 16:44:50 -07:00
Brock Whittaker
c9b05a2a84 Removing the leading border-top in sidebar items.
When the feedback module is hidden the #userlist_header border would
brush against the navbar. Check if the feedback header isn’t there and
remove the border top.
2016-08-15 16:40:28 -07:00
Tim Abbott
bfa987f26e Add missing realm_uri and server_uri to HomeTest. 2016-08-13 16:52:56 -07:00
Rishi Gupta
205fb996ec templates: Use realm_uri and server_uri settings for server URL.
The policy here is essentially:
* Pages on the central server (documentation, etc.) are server_uri.
* Pages associated with a user's realm server (anything logged-in, plus
  things like their login page) are realm_uri.
2016-08-13 16:37:45 -07:00
Rishi Gupta
902a7fbfe9 Change relative paths to absolute paths when we don't want the subdomain.
Changes relative path to an absolute path (that doesn't contain the
subdomain) for various links to
/create_realm, /api, /apps, /integrations, /hello, /terms, and the logged
out / (the Zulip in the upper left corner of portico)

I typically left links internal to the relevant pages (e.g. a link from
integrations.html to a subpage of integrations/) as relative links, and
changed external links from within the app to the absolute path (e.g. the
link to integrations from the gear menu).
2016-08-13 16:27:36 -07:00
Rishi Gupta
dff43fcc5e Change https:// to external_uri_scheme in templates.
Helps in case the development environment is not using https.
We get the value from zerver/context_processors.py (which is
ultimately reading it from settings)
2016-08-13 16:27:36 -07:00
Tim Abbott
5cad3f5707 handlebars: Add server_uri and realm_uri to page_params. 2016-08-13 16:27:36 -07:00
Tim Abbott
4fbb8c3eee templates: Add new context variables to all templates.
This adds a few new helpful context variables that we can use to
compute URLs in all of our templates:
* external_uri_scheme: http(s)://
* server_uri: The base URL for the server's canonical name
* realm_uri: The base URL for the user's realm

This is preparatory work for making realm_uri != server_uri when we
add support for subdomains.
2016-08-13 16:27:35 -07:00
Tim Abbott
4a46b879ee import_uploads_s3: Fix setting of content-type. 2016-08-13 11:26:53 -07:00
Tim Abbott
8edc5110cd export: Set re_map_foreign_keys verbose default to False.
Otherwise, this is super spammy when doing a large import.
2016-08-13 11:26:16 -07:00
Tim Abbott
8b170665e4 export: Add assertion that ./manage.py exists in current directory.
Otherwise we'll fail starting the UserMessage export, later on.
2016-08-13 10:13:11 -07:00
Tim Abbott
856ab48ec6 export: Fix stream export sanity check. 2016-08-13 10:02:34 -07:00
Steve Howell
603352630b export: Update conversion docs. 2016-08-13 09:36:08 -07:00
Steve Howell
e932b03999 export: Clean up path.join/makedirs for avatars/uploads. 2016-08-13 09:31:49 -07:00
Steve Howell
12c25e7d5c export: Filter attachments by message id. 2016-08-13 09:31:49 -07:00
Steve Howell
0f493d5000 export: Return msg ids from export_partial_message_files(). 2016-08-13 09:31:49 -07:00
Tim Abbott
924d0475c1 cache_helpers: Disable filling message cache.
The message cache filling script actually used both database and
memcached queries as part of filling the cache (all used to compute
the needed display_recipient values).  We would ideally fix this by
using bulk operations to fill the display_recipient cache, but until
we do so, this cache filler is counterproductive.

I believe this disabling fixes an issue where memcached would get
overloaded and stop handling requests during a server restart on busy
servers.
2016-08-13 09:27:56 -07:00
Rishi Gupta
befd665b91 Update static_header.txt with new license information.
This is the header file for the minified javascript.
2016-08-13 00:37:21 -07:00
Rishi Gupta
708b416ca1 Terms of Service: Fix corner cases around new users being created.
This fixes a few bugs in 7910a6e134,
related to automatically created user accounts.
2016-08-13 00:19:54 -07:00
Tim Abbott
3bae3cd54d settings: Add option to disable email deliverer. 2016-08-12 19:24:45 -07:00
Steve Howell
0c3e98fa91 export: Introduce attachment.json file.
Now attachment data gets written to its own json file.  We are
splitting this out so that will be easier for us to cross-check
attachments against messages without holding up writing a lot
of the other realm data.  (message cross-checking is coming soon)
2016-08-12 18:59:14 -07:00
Steve Howell
ea0a7d87c8 export: Refactor how we fetch attachment data.
This commit doesn't change any behavior; it just moves fetching
attachments out of the Config scheme and into its own method.
This prepares us to start writing attachment data to its own
file and cross-checking against message ids (coming soon).
2016-08-12 18:59:14 -07:00
ukhan
db81647b7b Update packages in requirements that won't break tests
upgrade moto, downgrade httpretty for compatibility

downgrade commonmark for compatibility
2016-08-12 17:56:23 -07:00
ukhan
180b438c44 Upgrade setuptools prior to updating mock 2016-08-12 17:56:23 -07:00
Steve Howell
fba7a9ca21 export: Unify top-down export configuration.
We now just have a single configuration get_realm_config() that
handles most of the top-down realm export tables.  (It basically
does everything not related to messages or uploads/avatars.)

Unifying the configs allows us to be more strict in our
configuration about checking for anomalies.  In the future
we may need to loosen up some of those restrictions again,
but for now we are picky and paranoid.
2016-08-12 15:27:23 -07:00
Steve Howell
5a5353b846 export: Fetch stream data only for stream recipients.
Fetch stream data only for stream recipients, instead of
getting streams via realm_id.

(This change is kind of moot for now, since our stream recipients
include all possible stream recipients in the realm, but this
sets us up for when we start restricting users that we export
within the realm.)
2016-08-12 15:27:22 -07:00
Steve Howell
7a429d1e30 export: Add sanity_check_stream_data(). 2016-08-12 15:27:22 -07:00
Steve Howell
ec86e475b4 export: Add Config.post_process_data 2016-08-12 15:12:01 -07:00
Steve Howell
0c2c331905 export: Flip how we fetch stream subscription data.
We now get stream subscriptions BEFORE stream recipients.
2016-08-12 15:12:01 -07:00
Steve Howell
70a916aae3 export: Flip how we fetch user subscription data.
We now get user subscriptions BEFORE user recipients.
2016-08-12 15:12:01 -07:00
Steve Howell
2a2ce6ada1 export: Remove hard-to-maintain code comment.
Subsequent changes are gonna make the top-down/bottom-up comment
no longer valid.
2016-08-12 15:12:01 -07:00
Steve Howell
fd77585a8c export: Add docs/conversion.md.
This is not hooked into anything yet.  After this weekend's
conversion, it will probably be worthwhile to take a second pass
at it!
2016-08-12 15:10:49 -07:00
Steve Howell
90494cfec2 export: Note user-owned bot limitations. 2016-08-12 15:10:49 -07:00
Tim Abbott
88a123d5e0 Fix excessive CPU usage by rabbitmq-numconsumers Nagios checks.
The previous model for these Nagios checks was kinda crazy -- every
minute, we'd run a full `rabbitmctl list_consumers` for each of the
dozen+ consumers that we have, and then do the exact same parsing
logic for each to determine whether the target queue has a running
consumer to write out a state file.

Because `rabbitmctl list_consumers` takes a small amount of resources,
on systems where CPU is very limited (e.g. t2 style AWS instances),
this minor CPU wastage could be problematic.

Now we just do that `rabbitmqctl list_consumers` once per minute, and
output all the state files from a single command.

Further TODO items on this front include removing the hardcoded list
of queues.
2016-08-12 14:09:36 -07:00
Tim Abbott
852af83d3c check_postgres_replication_lag: Fix psql command line.
This allows the plugin to be run as users other than the "zulip" user,
where the "zulip" database would not be the default.
2016-08-12 13:19:08 -07:00
Tim Abbott
5194485d74 log2zulip: use a Zulip virtualenv if available.
This makes it easier to use log2zulip in a Zulip server environment.
2016-08-12 13:17:36 -07:00
Tim Abbott
5b53521b32 memcached: set a low retry_timeout. 2016-08-12 12:57:24 -07:00
Tim Abbott
4baf120c7c memcached: Enable TCP_NODELAY optimization. 2016-08-12 12:57:24 -07:00
Tim Abbott
d8c066ba52 memcached: Pass verify_keys option. 2016-08-12 12:57:23 -07:00
Tim Abbott
ed01842f95 notifications: Fix missed message emails with multiple senders.
Previously, missed message emails with multiple senders would
incorrectly have a "," outside the quoted sender name part of the from
address string, resulting in confusing email output.
2016-08-12 12:28:06 -07:00
Tim Abbott
386c6c2a31 settings: Refactor SYSTEM_ONLY_REALMS configuration. 2016-08-12 12:12:53 -07:00
Tim Abbott
ecb81fabf3 settings: Extract EVENT_LOGS_ENABLED setting. 2016-08-12 12:12:53 -07:00
Tim Abbott
f0e495831e forms: Fix check for whether terms of service are enabled. 2016-08-12 11:04:45 -07:00
Steve Howell
6fdd42c08b export: Create convenient soft links. 2016-08-12 10:48:33 -07:00
Steve Howell
70b68ddcc3 export: Use a config for export_single_user(). 2016-08-12 10:37:41 -07:00
Steve Howell
c69a5bdec3 export: Handle more tables via export_from_config().
This commit introduces the ability to do custom fetches
and to essentially use temp tables for intermediate results.

(The temp table stuff deals with recipients/subscriptions
having three different flavors--user, stream, and huddle.)
2016-08-12 10:37:35 -07:00
Steve Howell
f471a1779e export: Handle simple exports with export_from_config().
This handles the simple tables that don't need custom fetches.
2016-08-12 09:54:57 -07:00
Steve Howell
682155778d export: Add export_with_config().
Subsequent commits will start to use this.
2016-08-12 09:54:57 -07:00
Tim Abbott
6496fe2a53 travis: Remove rabbitmq nodename dependency on hostname.
Because rabbitmq doesn't support changing the nodename of a running
rabbitmq node, Zulip installations suffered a plague of issues where
e.g. a Zulip server would reboot, the hostname would change, and
suddenly the local rabbitmq instance being used by Zulip would stop
working.

We address this problem by using, by default, a fixed rabbitmq
nodename, but providing server administrators the option to set the
rabbitmq nodename used by Zulip however they choose.

To upgrade an existing server to use this new configuration, one will
need to add something like the following to /etc/zulip/zulip.conf:

[rabbitmq]
nodename = zulip@localhost

However, I don't believe we have the puppet code in place to make this
work correctly at initial installation without rabbitmq-server being
already installed (but off), as we can easily setup in Travis CI but I
haven't been willing to do for the installer.  So for now, this just
fixes our Travis CI problems.

Fixes: #1579.
2016-08-12 09:38:23 -07:00
Tim Abbott
c7059c9751 travis: Update success-http-headers to match current certs.
Travis CI seems to have changed the way the snakeoil SSL certs are
generated in their infrastructure, so we need to update our expected
"success" HTTP headers accordingly.
2016-08-12 09:35:41 -07:00
Steve Howell
b0e6d20321 export: Write stats.txt for ./manage.py export <realm>. 2016-08-12 09:06:10 -07:00
Rishi Gupta
7910a6e134 Terms of Service: Add ability to update TOS and have users re-sign.
Most directly useful for the migration to zulipchat.com.

Creates a new field in UserProfile to store the tos_version, as well as two
new settings TOS_VERSION and FIRST_TIME_TOS_TEMPLATE. We check for a version
mismatch between what the user has signed and the current
settings.TOS_VERSION whenever the user hits the home page, and redirect them
if needed.

Note that accounts_accept_terms.html and
zerver.views.accounts_accept_terms were unused before this commit
(they date from c327446537)
2016-08-11 23:37:48 -07:00
Tim Abbott
a648513580 production-helper: Remove /root/zulip during setup process.
This fixes a problem that caused production-helper to not be
idempotent.
2016-08-11 22:21:13 -07:00
Tim Abbott
7011c94465 production-helper: Use ln -nsf to install snakeoil symlinks.
This fixes a problem where production-helper was not idempotent.
2016-08-11 22:20:24 -07:00
Tim Abbott
28a7d991f6 setup-production: Remove more postgres packages.
Travis CI seems to have added Postgres 9.5 to the default-installed
Postgres package list, and we also missed a few side packages
previously as well.
2016-08-11 22:19:57 -07:00
Tim Abbott
2581ac166c puppet: Automatically scale default memcached memory allocation.
Previously, we used a fixed memcached memory allocation of 512MB,
regardless of the size of the server.  While that is a good allocation
for a server with 4GB of RAM, for servers with less, we should
decrease the allocation, and for a large server with much more RAM, we
should increase it.  We still support the user overriding the
configuration setting, but this produces more sensible defaults.
2016-08-11 20:27:45 -07:00
Tim Abbott
2e0e8193d4 puppet: Make memcached memory allocation a variable. 2016-08-11 20:27:45 -07:00
Tim Abbott
3edf880c9b Remove moreutils from zulip_internal::base.
We recently added this to zulip::base, so it would be a duplicate.
2016-08-11 18:12:59 -07:00
Tim Abbott
9afb1c7a71 puppet: Stop wholesale replacing /etc/redis/redis.conf.
Zulip had only patches the redis configuration in one small way, which
resulted in unnecessary portability issues for using Redis on
different versions of Linux.  We replace this with just a adding an
include mechanism to the redis config.

While we're at it, we configure this to take advantage of the
new REDIS_PASSWORD secret to automatically configure redis passwords.
2016-08-11 17:26:04 -07:00
Tim Abbott
11cac86a58 settings: Add support for specifying a remote redis password. 2016-08-11 16:54:22 -07:00
Tim Abbott
f418e54ae2 local_settings: Fix zulip.com terms of service. 2016-08-11 16:39:47 -07:00
Steve Howell
df3aa39be3 export: Extract write_data_to_file(). 2016-08-11 15:51:22 -07:00
Steve Howell
f29b32bbb2 export: Clarify message exporting code.
The function to create the message partial files has been
renamed to export_partial_message_files().  It now gets its own
list of user profile ids and recipient ids from the response,
so that we can de-clutter do_export_realm().
2016-08-11 15:51:22 -07:00
Steve Howell
5cd915694a export: Extract launch_user_message_subprocesses().
This is the last in a series of commits that makes it
so that do_export_realm() mostly delegates work out
to other functions.
2016-08-11 15:21:30 -07:00
Steve Howell
b383f5ca5d export: Extract fetch_user_profile_cross_realm(). 2016-08-11 15:21:30 -07:00
Steve Howell
fee2106c6f export: Extract fetch_huddle_objects().
This also removes the dead codepath for include_private=False.
2016-08-11 15:21:30 -07:00
Steve Howell
a6235f6a60 export: Add comments to export_single_user().
(This is a bit of a prefactoring to hopefully create a nice
diff in a subsequent commit.)
2016-08-11 15:21:30 -07:00
Steve Howell
6e7fe76cf4 export: s/avatar_bucket/processing_avatars
The name avatar_bucket was confusing for a boolean, and
in some places it was used for non-S3 paths.

I considered the more concise 'is_avatar', but that
was still confusing when you are processing multiple
files, because you think it's a calculated property
on one file instead of an overall codepath switch.

I also considered splitting up some functions, but
there is a lot of common logic between handling
file uploads and avatars that's not trivial to extract
into helpers, especially on the S3 side.
2016-08-11 15:21:30 -07:00
Steve Howell
3dab366733 export: Clean up names of upload/avatar export functions.
I did some minor moving around of code that made us have
one fewer function without any additional conditional
logic. The names are more explicit about saying
"from_local" and "from_s3".  Also, there is less clutter
now in do_export_realm(), which is evolving into more of
a dispatcher and less of a worker.
2016-08-11 15:21:30 -07:00
Steve Howell
9582a83d10 export: Fix usage in export_single_user command. 2016-08-11 15:21:30 -07:00
Steve Howell
d62a351107 export: Add sanity_check_output(). 2016-08-11 15:21:30 -07:00
Rishi Gupta
0301347e86 provision.py: Fix typo.
Typo in the last line of the script; fixing since we'll see it every time
we provision.
2016-08-11 15:20:29 -07:00
Tim Abbott
cb21584ffe check_send_receive_time: Support being run in a cron job. 2016-08-11 14:48:21 -07:00
Tim Abbott
4dcbaf1e6b check_send_receive_time: Cleanup unnecessary print statement. 2016-08-11 14:48:21 -07:00
Tim Abbott
95aee366c8 Enable local browser error reporting if ZILENCER_ENABLED. 2016-08-11 13:49:18 -07:00
Tim Abbott
ba7ef1c82d zilencer: Fix regression in URLs.
When we refactored zilencer to use a single urls.py file in
bf50dd7771, we accidentally lost the
prefix on the API urls.

This broke sending error report emails if zilencer was enabled.
2016-08-11 12:38:42 -07:00
Tim Abbott
dca585fa75 travis: re-disable test-queue-worker-reload.
It seems to still fail sometimes in Travis CI.
2016-08-10 16:43:00 -07:00
Umair Khan
8bf4d9288d Create a nice default language modal.
Fixes: #1396.
2016-08-10 16:22:36 -07:00
Umair Khan
af9f308f0e Send double columned language list in page_params. 2016-08-10 16:19:28 -07:00
Umair Khan
73e5289736 Add default_language_name in page_params. 2016-08-10 16:19:28 -07:00
Umair Khan
ddaf1a2b67 Return unformatted list from get_language_list. 2016-08-10 16:19:28 -07:00
Umair Khan
740b5634ac Fix and re-enable test-queue-worker-reload.
It seems that we no longer get the message, 'zerver/lib/actions.py
modified; restarting server', but the server reloads successfully
nonetheless.

Fixes: #1341.
2016-08-10 16:17:23 -07:00
Umair Khan
99c430f707 Make English the fallback language in i18next.
Fixes: #1580
2016-08-10 16:06:57 -07:00
Tim Abbott
7736925d5b compose: Fix sending PMs to Zephyr users. 2016-08-10 15:36:00 -07:00
Steve Howell
06b0df5efc export: Remove spurious select_related() call for Client. 2016-08-10 14:16:17 -07:00
Steve Howell
cb59a11f0a export: Extract get_primary_ids(). 2016-08-10 14:16:17 -07:00
Steve Howell
90e9083b81 export: Extract filter_by_realm(). 2016-08-10 14:16:17 -07:00
Steve Howell
4b6b1b8ad4 export: Extract filter_by_users(). 2016-08-10 14:16:17 -07:00
Steve Howell
db9edfce34 export: Use DATE_FIELDS in fix_datetime_fields().
Now we only call this once per table and use DATE_FIELDS to
look up the data fields.
2016-08-10 14:16:17 -07:00
Steve Howell
35c59fc4d7 export: Clean up export_messages().
This is pretty minor cleanup, but it makes it a little more
explicit what we're writing to the shard file, and it allows
us to use a more specific mypy type when calling
floatify_datetime_fields.
2016-08-10 14:16:17 -07:00
Steve Howell
1d1f36c0b8 export: Always use subprocesses to export UserMessage.
We no longer have an in-process code path to export
UserMessage rows.  We want to only maintain the
subprocess code, which we'll always use in production,
and which will work fine in dev.
2016-08-10 14:16:17 -07:00
Steve Howell
78bbefbf94 export: Create import_attachments. 2016-08-10 14:16:17 -07:00
Steve Howell
01d28458fc Add frontend_tests/node_tests/dispatch.js.
This tests the dispatching code in server_events.js.
2016-08-09 18:49:13 -07:00
Steve Howell
48af751e8d Clean up server_events.js (minor stuff).
Make exceptions more clear and upstream patching of builtins to index.js.
2016-08-09 18:49:13 -07:00
Steve Howell
ccb1d54e55 Export server_events._get_events_success for testing. 2016-08-09 18:49:13 -07:00
ukhan
dced137f6f Fix function formatting in admin.js 2016-08-09 17:52:25 -07:00
Rag Sagar
2fef36f15a Add realm-level default language setting.
Adds a new field default language in the zerver_realm model.
This realm level default language will be used as default language
for newly created users. Realm level default language can be
changed from the administration page.

Fixes #1372.
2016-08-09 17:38:29 -07:00
Steve Howell
7ec6a394fe export: Filter Attachment objects by realm. 2016-08-09 16:47:14 -07:00
Steve Howell
cecfaa7761 export: Extract import_message_data(). 2016-08-09 16:47:14 -07:00
Steve Howell
5386ed280e export: Extract update_id_map().
We also use a vanilla dictionary instead of a defaultdict, so
that we explicitly initialize what tables are being re-mapped.
2016-08-09 16:47:14 -07:00
Steve Howell
217ef8a4d2 export: Split fix_foreign_keys() into two functions.
We now have convert_to_id_fields for the simple case, and
re_map_foreign_keys for the more complex case. I also
renamed some parameters and variables.
2016-08-09 16:47:14 -07:00
Tomasz Kolek
4a25b92298 Cleanup result message code in test-js-with-node.
Remove duplicate code after quick fix in passing returned code.

Fixes: #1489.
2016-08-09 16:46:24 -07:00
Umair Khan
e1090118c5 Percent translated should be an integer. 2016-08-09 16:19:07 -07:00
Rag Sagar
5771e2eb25 Move i18n functions from zerver/views/__init__.py to zerver/lib/i18n.py 2016-08-09 16:10:24 -07:00
Rag Sagar
28f0079432 Use a constant to set UserProfile default_language field max_length attribute. 2016-08-09 16:10:24 -07:00
Steve Howell
dd88ffccfd export: Extract make_raw() in lib/export.py. 2016-08-09 15:58:27 -07:00
Steve Howell
09fa343bdd export: Use DATE_FIELDS in floatify_datetime_fields.
This avoids a little bit of code duplication, plus it should
make it a little easier to add new date fields in the future.
2016-08-09 15:58:27 -07:00
Steve Howell
c14ab3c91f export: Add annotations to zerver/lib/export.py.
I also fixed some small things like removing unnecessary return
statements, and adding a TODO.

In some cases I explicitly cast stuff at run-time to set() or
str() to appease mypy, as well as make it clear to somebody
reading the code that the callee might not respect ordering
or tolerate unicode.
2016-08-09 15:58:27 -07:00
Steve Howell
f18cc4ae3a export: Added export_avatars_local_helper(). 2016-08-09 15:58:27 -07:00
Tim Abbott
9441154316 debug: Fix actual traceback being hidden in blueslip.
When in debug mode, previously an explicit `blueslip.error()` call
would not display the original stack trace of the error, making
debugging difficult.

This isn't perfect, in that it seems to display some tracebacks
multiple times, but at least the trace is available.
2016-08-09 11:59:49 -07:00
Tim Abbott
469df75ab7 Fix admin.update_default_streams_table errors if tab not open.
It turns out that our logic for updating the default streams table
crashed in the case where the administration tab was not open.

Fixes: #1540.
2016-08-09 11:59:32 -07:00
Tim Abbott
bb392374b2 travis: unset GEMPATH.
Travis CI support suggested this as the correct solution for some
recent changes in their environment that make ruby segfault.
2016-08-09 11:59:01 -07:00
Umair Khan
86920a297c Mock out loggers in push notification tests.
Fixes: #1575
2016-08-09 22:16:09 +05:00
Umair Khan
7a84f12a38 Verify mock calls without strict order.
In push notification tests, call assert_has_calls with `any_order=True`
so that the order of the calls does not matter.
2016-08-09 22:15:37 +05:00
Tim Abbott
42b63f5caa test_templates: Fix failure to report a user-facing error. 2016-08-09 09:54:44 -07:00
Tim Abbott
f3365f4089 test_templates: Add integrations_dict to context.
This fixes the fact that this test was (silently) failing.
2016-08-09 09:54:36 -07:00
Umair Khan
25f70ebdaa Annotate zproject/jinja2/backends.py 2016-08-09 09:19:24 -07:00
Umair Khan
60f30fdb36 Annotate zproject/backends.py. 2016-08-09 09:19:24 -07:00
Umair Khan
fe812a89bf mypy: Type of remote_username should be text_type. 2016-08-09 09:19:24 -07:00
Brock Whittaker
e34b9be950 Append color picker to #subscriptions_table instead of document.body.
Adding the container attribute to the color picker options parameter
modifies the behavior of the spectrum function to allow the color
picker to be attached to the #subscriptions_table element rather than
the default document.body element.

This allows for the color picker to scroll with the subscriptions page,
fixing the bug where the color picker would not scroll up/down the page.

Fixes #1293.
2016-08-09 09:07:55 -07:00
Brock Whittaker
eda1cdd0c5 third: Add option for which container to append the color picker to.
This allows you to select the container that the color picker should
append to and therefore be absolutely positioned in accordance with.

This still defaults to document body, which was the previously default
container to append the color picker to.
2016-08-09 09:07:15 -07:00
Brock Whittaker
77aa43fffb Prevent the color-picker from appearing above the navbar.
The color picker original z-index was set to (2^31)-1 which overrode
everything on the site. This behavior is unwanted as the color picker
should not override the z-index of the navbar.

In changing the z-index to 100 the navbar remains above the color
picker.
2016-08-09 09:07:15 -07:00
Umair Khan
8c249f859e Push Notification: Add tests for GCM. 2016-08-09 16:13:02 +05:00
Steve Howell
a904222947 Add tools/find-add-class to tools/lint-all.
The find-add-class tool, when in lint mode, verifies that we can
understand all calls to addClass from our JS code.

When in non-lint mode, i.e. verbose mode, the tool prints out a
list of tuples of (fn, class) that we can use as we wish in other
tools.
2016-08-08 15:32:48 -07:00
Steve Howell
15f46a142e Remove obsolete #navbar-spacer style. 2016-08-08 15:24:45 -07:00
Steve Howell
98abe5bb3b Remove obsolete #left-of-compose style. 2016-08-08 15:24:45 -07:00
Steve Howell
95b19f9765 Add test_validate_django(). 2016-08-08 15:20:29 -07:00
Steve Howell
d29e745142 Add test_validate_handlebars(). 2016-08-08 15:20:29 -07:00
Steve Howell
70bc932913 Add test_html_tag_tree(). 2016-08-08 15:20:29 -07:00
Steve Howell
65147e7368 Add tests for template_parser.tokenize. 2016-08-08 15:20:29 -07:00
Steve Howell
184e45b774 Fix bug with tools/html-grep.
We were ignoring singleton tags like "input" tags in
html-grep.  This was an artifact of our tokenizer originally
being built to check indentation of templates, for which
singleton tags had been a distraction. This fix actually cleans up
the template checking logic as well, since it can now rely
on the tokenizer to classify special tags and singleton tags.
The tokenizer is more complete and more specific.
2016-08-08 15:20:29 -07:00
Umair Khan
acd76eb604 Annotate push_notifications.py. 2016-08-08 15:17:02 -07:00
Umair Khan
9c13e9a072 Annotate test_push_notifications. 2016-08-08 15:17:02 -07:00
Umair Khan
35dd1ffb13 Pass password as string to authenticate. 2016-08-08 15:17:01 -07:00
Umair Khan
266c791e64 Email should be a unicode. 2016-08-08 15:17:01 -07:00
Umair Khan
503ad774f5 Tokens should be unicode. 2016-08-08 15:17:01 -07:00
Umair Khan
4bc4c39528 Add *args and **kwargs to functions.
Arguments are added to:
    - SocialAuthMixin.get_email_address
    - SocialAuthMixin.get_full_name
2016-08-08 15:15:29 -07:00
Umair Khan
0dd7d0dda1 push_notifications: Change name to 'identifier'. 2016-08-08 15:15:29 -07:00
Umair Khan
fdbd132ba4 Annotate zerver/context_processors.py. 2016-08-08 15:15:29 -07:00
Umair Khan
00eab4e526 Annotate zerver/views/__init__.py. 2016-08-08 15:15:29 -07:00
Umair Khan
25dd1aeb5c Annotate zerver/lib/actions.py. 2016-08-08 15:13:29 -07:00
Umair Khan
ef62506fb1 Annotate zerver/models.py. 2016-08-08 15:13:29 -07:00
Umair Khan
e34b7a0691 Fix type annotation in message_cache_items. 2016-08-08 15:13:29 -07:00
Umair Khan
a3fd1b5d11 Annotate jinja2/__init__.py. 2016-08-08 15:12:12 -07:00
Umair Khan
ec910d96fc Annotate zerver/storage.py. 2016-08-08 15:12:12 -07:00
Umair Khan
0dfc757447 Annotate test_auth_backends.py. 2016-08-08 15:12:12 -07:00
Umair Khan
1259bc3057 Annotate jinja2/compressors.py. 2016-08-08 15:12:12 -07:00
Tim Abbott
6264ff7039 Add new Zulip realm import/export tool.
The previous export tool would only work properly for small realms,
and was missing a number of important features:
* Export of avatars and uploads from S3
* Export of presence data, activity data, etc.
* Faithful export/import of timestamps
* Parallel export of messages
* Not OOM killing for large realms

The new tool runs as a pair of documented management commands, and
solves all of those problems.

Also we add a new management command for exporting the data of an
individual user.
2016-08-08 14:58:18 -07:00
Tim Abbott
e7adaf8db1 utils: Add mkdir_p implementation. 2016-08-08 14:36:50 -07:00
Tim Abbott
b3a768f4b2 settings: Improve ALLOWED_HOSTS defaults logic and docs.
This removes the requirement for the user to put localhost/127.0.0.1
in their ALLOWED_HOSTS list, since it is now added automatically.

Fixes: #1358.
2016-08-05 21:25:29 -07:00
Tim Abbott
54a6bdc3ad views: Fix mypy annotations in get_invitee_emails_set.
Apparently this buggy annotation slipped through into master.
2016-08-05 15:04:16 -07:00
Tomasz Kolek
192f0f93e2 Change post-invite success message in case when user invites only one user.
Fixes: #1412.
2016-08-05 14:48:10 -07:00
Tomasz Kolek
64b5d0ce64 Add support for inviting emails in "name" <email> format.
Often, users will copy email addresses with a name (rather than pure
email addresses) into the Zulip "invite users" UI.  Previously, that
would throw an error.

This change also adds a get_invitee_emails_set function for parsing
emails content and a test suite for this new feature.

Fixes: #1419.
2016-08-05 14:48:04 -07:00
Alexander Trost
8d4896809a Deduplication of configuration: Database Initialization
Comment tweaked slightly by tabbott.
2016-08-05 13:33:22 -07:00
Tim Abbott
5bff72c385 Revert "Use apt-add-repository to setup Zulip PPA."
This reverts commit 3f95e567c1.

Apparently `apt-add-repository` fails periodically in CI.  I suspect
this is some sort of silly networking problem, but given that all
we're saving is a few lines of code, the old version was better if
this fails basically ever.
2016-08-05 13:29:17 -07:00
Taranjeet Singh
ba4b06c6de gitignore: Remove tools/phantomjs.
This is now installed under /srv/phantomjs.
2016-08-05 13:28:52 -07:00
Taranjeet Singh
11598484ef gitignore: Remove zerver/fixtures/test_data1.json.
This file seems to no longer exist.
2016-08-05 13:28:43 -07:00
Tim Abbott
b9208affdb Remove event_log from .gitignore.
This was moved to the var/log/ subtree some time ago.
2016-08-05 11:12:23 -07:00
Umair Khan
d33fc0046f Add APNS feedback server tests. 2016-08-05 10:36:57 -07:00
Umair Khan
33450d1a0b Add APNS push notification tests. 2016-08-05 10:36:57 -07:00
Umair Khan
40054ce26c Add APNS response listener test case. 2016-08-05 10:36:57 -07:00
Umair Khan
df8fc30b75 Create MockRedis class.
Redis is not available on Travis and creating a mock Redis server looks
easier than using `mock` module.
2016-08-05 10:36:57 -07:00
Umair Khan
2ab796aeb5 Add tests for APNS message. 2016-08-05 10:36:57 -07:00
Umair Khan
882bb5558b Push to APNS in a loop. 2016-08-05 10:36:57 -07:00
Umair Khan
4e8ca0a326 Make sure apns response code is an integer. 2016-08-05 10:36:57 -07:00
Umair Khan
5c41eae7ec Don't send connection to apns response listener. 2016-08-05 10:36:57 -07:00
Umair Khan
ffaf7cb2ba Create get_connection function for APNS. 2016-08-05 10:36:57 -07:00
Umair Khan
1d2bdfdfb1 Save user id instead of user profile. 2016-08-05 10:36:57 -07:00
Umair Khan
0cac1aa135 For APNS frame identifier generate random int. 2016-08-05 10:36:57 -07:00
Umair Khan
0b5dc56b8d Redis key expiry should be an integer. 2016-08-05 10:36:57 -07:00
Umair Khan
f6b0baef7d Give default value for APNS_SANDBOX 2016-08-05 10:36:57 -07:00
Umair Khan
cbd53fbac8 Don't import OrderedDict. 2016-08-05 10:36:57 -07:00
Umair Khan
0b88deb640 APNS_SANDBOX should be a bool.
Fixes: #1480
2016-08-05 10:36:57 -07:00
Steve Howell
cdd03dec4d Extract media queries to media.css.
Create `media.css` using media queries that had been at the bottom
of `zulip.css`, then update miscellaneous setttings/docs files.

I also add `.screen-medium-show` and `.screen-narrow-show` to
`media.css`, as they seem to be an important part of our
responsive design.

Fixes #1532.
2016-08-05 10:32:55 -07:00
Tim Abbott
3f95e567c1 Use apt-add-repository to setup Zulip PPA. 2016-08-04 22:17:07 -07:00
Tim Abbott
b50abc5131 npm: Split out production-only dependencies. 2016-08-04 22:17:07 -07:00
Tim Abbott
4d02c6efef scripts: Purge old deployments on every upgrade.
Fixes: #554.
2016-08-04 17:02:48 -07:00
Tim Abbott
51f069aa18 scripts: Refactor deployment-finished logging. 2016-08-04 17:02:48 -07:00
Tim Abbott
91b1521578 purge-old-deployments: Avoid purging last/next deployments. 2016-08-04 17:02:48 -07:00
Tim Abbott
1158a86ae7 restart-server: Maintain a last symlink. 2016-08-04 17:02:48 -07:00
Tim Abbott
82ad32f058 deploy-zulip-from-git: Update next symlink. 2016-08-04 17:02:48 -07:00
acrefoot
cf41629d80 docs: Fill gaps in New Feature Tuturial.
Adds some section headings, and provides a better example for the new
django migration system.
2016-08-04 16:02:08 -07:00
Christie Koehler
4c66bbc1ee integration guide: Move Hello World walkthrough to end. 2016-08-04 15:59:49 -07:00
Christie Koehler
6cf6341a49 integration guide: Improve readability and navigation. 2016-08-04 15:59:48 -07:00
Christie Koehler
4cd28e5e1f integration guide: Update Hello World walkthrough. 2016-08-04 15:59:28 -07:00
Tim Abbott
dcb92d41b8 Annotate test_messages.py. 2016-08-04 15:57:04 -07:00
Tim Abbott
39f1024740 test_messages: Fix remaining mypy errors. 2016-08-04 15:57:03 -07:00
Tim Abbott
88550edd9e Annotate queue_processors.py. 2016-08-04 15:57:03 -07:00
Tim Abbott
4e8054b84a Refactor queue worker tests to match actual API. 2016-08-04 15:57:03 -07:00
Tim Abbott
0219aba2b2 api: Annotate setup.py and fix import. 2016-08-04 15:57:03 -07:00
Tim Abbott
1e54897ca7 process_queue: Add missing type annotation. 2016-08-04 15:57:03 -07:00
Tim Abbott
4ddc567c50 views/__init__: Add missing annotations. 2016-08-04 15:57:03 -07:00
Tim Abbott
ac86cfcc37 Annotate zephyr_mirror.py. 2016-08-04 15:57:03 -07:00
Tim Abbott
bde3c666a9 zephyr_mirror: Add typing import. 2016-08-04 15:57:03 -07:00
Tim Abbott
3fec3f122f docs: Add missing annotation to conf.py. 2016-08-04 15:57:03 -07:00
Tim Abbott
641aa08721 compilemessages: Add mypy annotations. 2016-08-04 15:57:03 -07:00
Tim Abbott
a787dee48b makemessages: Add missing annotations and fix string types. 2016-08-04 15:57:03 -07:00
Tim Abbott
552fc06844 jabber_mirror: Add missing annotation. 2016-08-04 15:57:03 -07:00
Tim Abbott
2da6b6bfd8 views.messages: Add some more annotations. 2016-08-04 15:57:03 -07:00
Tim Abbott
2f13b0b18a actions: Fix various string annotations. 2016-08-04 15:57:03 -07:00
Tim Abbott
0d39ed82d1 Annotate cron_file_helper. 2016-08-04 15:57:03 -07:00
Tim Abbott
4f782bc186 test_events: Fix annotation gaps. 2016-08-04 15:57:03 -07:00
Tim Abbott
2eb5baa024 zendesk: Add missing type annotation. 2016-08-04 15:57:03 -07:00
Tim Abbott
d7d8d6b4d2 parallel: Add missing annotation. 2016-08-04 15:57:03 -07:00
Tim Abbott
d00719f204 Annotate IFTTT tests. 2016-08-04 15:57:03 -07:00
Tim Abbott
d449f6ba72 Annotate bitbucket2 tests. 2016-08-04 15:57:03 -07:00
Tim Abbott
5253c044e7 test_helpers: Add some missing annotations. 2016-08-04 15:57:03 -07:00
Tim Abbott
a7086d3d8a trello: Fix accidentally commented type annotation. 2016-08-04 15:57:03 -07:00
Tim Abbott
4840e493b2 decorator: Add missing annotation. 2016-08-04 15:57:03 -07:00
Tim Abbott
ef5b5bb45b views/streams: Add missing annotations. 2016-08-04 15:57:03 -07:00
Tim Abbott
92062b9526 process_queue: Add missing annotation. 2016-08-04 15:57:02 -07:00
Tim Abbott
89267f926e Annotate tools/run-dev.py. 2016-08-04 15:57:02 -07:00
Tim Abbott
cc11229377 test_auth_backends: Add missing type annotations. 2016-08-04 15:57:02 -07:00
Tim Abbott
0689485666 Add lint check for malformed type annotations missing :.
Also fix the 2 annotations that weren't being checked because of this.
2016-08-04 15:53:23 -07:00
Tim Abbott
af823f7a76 Annotate circleci integration. 2016-08-04 15:53:23 -07:00
Tim Abbott
0ca7af6137 Annotate zilencer tests. 2016-08-04 15:53:23 -07:00
Tim Abbott
1f2b3588d2 Annotate zilencer/models.py and fix str types in zilencer views. 2016-08-04 15:53:23 -07:00
Tim Abbott
55611cd21a Annotate test_i18n.py. 2016-08-04 15:53:23 -07:00
Tim Abbott
3839a25c74 Annotate generate_secrets.py. 2016-08-04 15:53:23 -07:00
Tim Abbott
028efdcb78 integrations: Add detailed module docstrings. 2016-08-04 12:13:25 -07:00
Tim Abbott
4a7e6e852f integration guide: Update documentation instructions. 2016-08-04 12:04:12 -07:00
Tim Abbott
6ab09064ac integration guide: Increase visibility level of hello world guide. 2016-08-04 11:55:19 -07:00
Tim Abbott
613781f034 integration guide: Swap created files above updated files. 2016-08-04 11:53:05 -07:00
Tim Abbott
0691832817 docs: Document new WEBHOOK_INTEGRATIONS API. 2016-08-04 11:52:28 -07:00
Tim Abbott
5f37485e7f docs: Improve integration guide link to writing documentation. 2016-08-04 11:49:17 -07:00
Tomasz Kolek
09d081d9bd Replace hardcoded integration-lozenges to generating ones. 2016-08-04 11:41:18 -07:00
Tomasz Kolek
0e33b8bd4d Add integrations library.
Define Integration and WebhookIntegration classes.
Change webhook part of integration's guide.
Replace hardcoded webhook urls to generating
based on WEBHOOKS list.
2016-08-04 11:39:20 -07:00
Taranjeet Singh
cbed266af7 gitignore: Update to remove all_messages_log.*. 2016-08-04 11:34:54 -07:00
Tim Abbott
604e2821f8 Remove tools/deprecated/backup. 2016-08-04 11:34:53 -07:00
Steve Howell
7cc1b1ebc4 Add test coverage for parsers in tools/lib.
Now, `tools/test-all` calls a new program called `tools/tests-tools`
that runs unit tests in `test_css_parser.py` and 'test_template_parser.py`.

This puts 100% line coverage on tools/lib/css_parser.py.
This puts about 50% line coverage on tools/lib/template_parser.py.
2016-08-04 10:47:09 -07:00
Steve Howell
5af47e0eef Make fn param optional with template_parser.validate().
The caller can now pass in text directly.  This is mostly for
testing, but it could be useful in other situations.
2016-08-04 10:47:09 -07:00
Steve Howell
1f8ba1d1b5 Make minor changes to css_parser.py 2016-08-04 10:47:09 -07:00
Steve Howell
f0c6af2285 Describe events/initial state in new-feature-tutorial.md. 2016-08-04 09:45:37 -07:00
Tim Abbott
03f6cb4b3e testing: Remove now-unnecessary istanbul install docs. 2016-08-04 09:43:05 -07:00
Tim Abbott
09b677b605 test-js-with-node: Fix istanbul not being in PATH. 2016-08-04 09:29:30 -07:00
Tim Abbott
82b1218af9 test-js-with-node: Fix return status on failure. 2016-08-04 09:27:54 -07:00
Tim Abbott
1d6ebd2b3d check_fts_update_log: Fix psycopg2 arguments.
* Fixes passing a string argument rather than an actual Python
  argument.
* Switches to hardcoding the database to connect to rather than the
  user, so this check can be run as an arbitrary user.
2016-08-03 14:58:46 -07:00
Tomasz Kolek
c96722b124 Add istanbul cover info to help in test-js-with-node. 2016-08-03 14:57:03 -07:00
Tomasz Kolek
87b554906d Add clear success message after node tests run.
Fixes: #1489.
2016-08-03 14:56:58 -07:00
Umair Khan
6c248a662d prod_settings_template.py: Add GitHub team and org. 2016-08-03 12:01:15 -07:00
Umair Khan
b38ca0c690 Add tests for GitHub team and organization auth. 2016-08-03 12:01:15 -07:00
Umair Khan
faa3e9b724 Give logical defaults to social auth settings.
Both key and secret settings of team and organization default to
SOCIAL_AUTH_GITHUB_KEY and SOCIAL_AUTH_GITHUB_SECRET respectively.
SOCIAL_AUTH_GITHUB_TEAM_ID and SOCIAL_AUTH_GITHUB_ORG_NAME default
to `None`.
2016-08-03 12:01:15 -07:00
Umair Khan
9bb6d45c06 Add GitHub team and organisation authentication.
Fixes: #1473
2016-08-03 12:01:15 -07:00
Umair Khan
fc1d8e217f Don't pass return_data to mock functions.
GitHubAuthBackend already passes the `return_data` keyword argument
to the `do_auth` function.
2016-08-03 12:01:15 -07:00
Steve Howell
0f8d014096 Add tools/html-grep.
This tools greps for HTML nodes that have relevants words
pertaining to classes, ids, or tags in themselves or their
parents.
2016-08-03 11:29:37 -07:00
Tim Abbott
5f275c9868 Re-enable mobile app advertisements in /apps.html. 2016-08-02 16:45:11 -07:00
Sumana Harihareswara
99da259130 Add new Electron desktop app to /apps/ page.
The Electron-based desktop app should work with all
realms, so it goes outside the voyager-related
conditional block.
2016-08-02 16:45:11 -07:00
Sumana Harihareswara
2d43431ad9 Advertise Electron app in documentation. 2016-08-02 16:41:24 -07:00
Sumana Harihareswara
d97702ead6 De-duplicate testing docs.
Addresses comment in #1218.
2016-08-02 19:26:59 -04:00
Steve Howell
3b5c187f55 Add tools/check-css and tools/lib/css_parser.py.
`tools/lint-all` now calls the new `tools/check-css`

The css_parser library parsers CSS into a data structure
that remembers line numbers and columns of semantically
meaningful tokens and adjoining white space/tokens.  It
is intended to be used for various linting tasks.

The file `tools/check-css` runs a few files through the
parser and makes sure they round trip.  This has some value
right away, as files that fail to parse will cause an
exception to be thrown and thus alert developers to syntax
errors.  We expect to grow this into more advanced linting
tasks eventually.
2016-08-02 16:22:46 -07:00
Taranjeet Singh
b82836a901 tools/setup/emoji_dump/emoji_dump.py: Move bitmaps & *.ttx to var/.
Also update .gitignore to remove the old .gitignore markings for
these files' old locations.
2016-08-02 15:18:36 -07:00
Taranjeet Singh
4c592bd8d4 .gitignore: Remove event_queues.{json,pickle}.
This files are now written under the var/ tree.
2016-08-02 15:15:14 -07:00
Christie Koehler
c95e6d4629 Recommend vagrant provision instead of vagrant reload.
Fixes #1520.
2016-08-02 15:10:59 -07:00
Tim Abbott
1c65508624 puppet: Add postgres user to Zulip group. 2016-08-02 14:59:25 -07:00
Tim Abbott
04fc3ff1e1 pg_backup_and_purge: Don't try to use a virtualenv.
This makes this actually work if the postgres server is different from
the Zulip app frontend.
2016-08-02 14:59:25 -07:00
Tim Abbott
4bdd9d3769 check_postgres_backup: Don't try to use a virtualenv.
The dependencies for this tool are installed using apt.
2016-08-02 14:59:25 -07:00
Tim Abbott
a5115d54ee env-wal-e: Rename s3_backup_bucket to s3_backups_bucket.
This makes it consistent with the other variables in this file.
2016-08-02 14:59:15 -07:00
Tim Abbott
ff80daef16 puppet: Move zulipsecret into its own file.
Apparently puppet doesn't support declaring multiple functions in the
same file.
2016-08-02 14:55:51 -07:00
Tim Abbott
b82230559c docs: Document new deploy-zulip-from-git deployment process. 2016-08-02 14:31:07 -07:00
Tim Abbott
720e905150 docs: Fix heading levels in maintaining guide. 2016-08-02 14:31:07 -07:00
Tim Abbott
a12909d0d3 deploy-zulip-from-git: Move migrations/puppet skipping options to config. 2016-08-02 14:31:07 -07:00
Tim Abbott
35cd0e122e docs/maintaining: Switch markdown header format. 2016-08-02 14:31:07 -07:00
Tim Abbott
c4d482e722 upgrade-zulip-stage-2: chdir to deploy_path explicitly.
This makes rerunning this manually if it fails much more convenient.
2016-08-02 14:31:07 -07:00
Tim Abbott
7e348df198 deploy-zulip-from-git: Cleanup git_repo_url computation.
Now we assume the main GitHub zulip.git if a repo isn't specified.
2016-08-02 14:31:07 -07:00
Tim Abbott
dc4b89fb08 deploy-zulip-from-git: Add a cache directory. 2016-08-02 14:31:07 -07:00
Tim Abbott
0ee3178167 Move update-deployment to scripts/deploy-zulip-from-git. 2016-08-02 14:31:07 -07:00
Tim Abbott
fef32af28c update-deployment: Switch to using update-zulip-part-2. 2016-08-02 14:31:07 -07:00
Tim Abbott
972b42ee7b upgrade-zulip-stage-2: Only stop services early when needed. 2016-08-02 14:31:07 -07:00
Tim Abbott
5886d3eeec upgrade-zulip-stage-2: Add --skip-migrations option. 2016-08-02 14:31:07 -07:00
Tim Abbott
759144232f upgrade-zulip-stage-2: Add --skip-puppet option. 2016-08-02 14:31:07 -07:00
Tim Abbott
8ce55b9789 upgrade-zulip-stage-2: Use argparse for options. 2016-08-02 14:31:07 -07:00
Tim Abbott
cb842c1b83 Improve su_to_zulip setting of home directory. 2016-08-02 14:31:07 -07:00
Rishi Gupta
948ea7663c ModelReprMixin: Fix handling of missing __unicode__ function.
The old behavior was to raise an exception, but Django was catching
the exception and doing unexpected things. For instance, in the
manage.py shell, printing out a ModelReprMixin object (with
__unicode__ not implemented) would result in nothing being printed,
rather than it raising a error or otherwise alerting the programmer as
to what was going on.
2016-08-02 11:46:01 -07:00
Steve Howell
9151ee42e9 Extract tools/lib/template_parser.py. 2016-08-01 16:27:50 -07:00
Steve Howell
9951e92b3b Extract tokenize() in tools/check-templates. 2016-08-01 16:05:07 -07:00
Steve Howell
7e772ed644 Clean up code in check-templates.
I extracted a few helper methods.
2016-08-01 16:05:07 -07:00
Umair Khan
2f6293027d Add test for empty email gateway pattern. 2016-07-31 20:39:09 -07:00
Umair Khan
2c07f1b19a Use NOREPLY_EMAIL_ADDRESS if email gateway not enabled.
This fixes a regression where missed message emails would not be sent
at all in the event that EMAIL_GATEWAY_PATTERN was unset.

The overall experience still isn't great, but it's better than crashing.

Fixes: #1411

[commit message expanded by tabbott]
2016-07-31 20:38:18 -07:00
Tim Abbott
25c0710800 prod_settings_template: Fix typo in redis documentation. 2016-07-31 19:45:53 -07:00
Steve Howell
af7e39fde2 Remove spurious whitespace in portico.css. 2016-07-31 19:40:21 -07:00
Tim Abbott
2867c019cb Don't show special empty narrow messages for complex narrows.
Previously we showed an empty narrow error message determined entirely
by the first operator, even though there could have been multiple
operators.
2016-07-31 19:38:19 -07:00
Kartik Maji
cea079279e Improve error message when narrowed to nonexistant or silent users.
Fixes #1418.
2016-07-31 19:38:17 -07:00
Tim Abbott
3b277c3b1f install: Give nice error message on installation failure. 2016-07-31 19:24:45 -07:00
Tim Abbott
75b5d021fa Remove unused puppet-common third-party module code. 2016-07-31 19:24:42 -07:00
Tim Abbott
084d504c39 install: Remove unnecessary cd command at end. 2016-07-31 19:24:38 -07:00
Steve Howell
2af176709a Put each selector on its own line in zulip.css. 2016-07-31 17:46:21 -07:00
Rag Sagar
b9f2397073 Add validation and tests for default language setting. 2016-07-31 17:44:10 -07:00
Tim Abbott
6158acb41b nagios: Fix path to check_debian_packages. 2016-07-31 14:25:07 -07:00
Tim Abbott
6954dd84ab postgres_appdb_tuned: Add SSL certificate path configs. 2016-07-31 14:25:07 -07:00
Tim Abbott
d66f6b8176 Fix postgresql configuration template for Ubuntu Xenial.
I incorrectly assumed that this was working because Travis CI passed
the build, whereas in fact Travis CI only tests the Trusty templates.
2016-07-31 14:24:34 -07:00
Tim Abbott
8b285ec0ff puppet: Read camo key from zulip-secrets.conf. 2016-07-31 00:23:24 -07:00
Tim Abbott
2b40309029 puppet: Add new zulipsecret function. 2016-07-31 00:23:24 -07:00
Tim Abbott
298e040bac puppet: Strip newlines in zulipconf function.
This avoids creating unnecessary extra newlines in config generated
using this.
2016-07-31 00:23:24 -07:00
Tim Abbott
16a4ce1bd2 puppet: Fix Nagios check_disk flagging special filesystems. 2016-07-30 23:57:31 -07:00
Tim Abbott
c764b46cef puppet: Fix missing base include in nagios manifest. 2016-07-30 23:48:41 -07:00
Tim Abbott
bc9bdd53aa puppet: Use hostgroup for postgres_other monitoring. 2016-07-30 23:46:05 -07:00
Tim Abbott
6b34bee806 puppet: Remove unused ancient humbug-default apache site. 2016-07-30 23:43:55 -07:00
Tim Abbott
217faed3b3 Update check_postgres plugin to version 2.22. 2016-07-30 23:19:40 -07:00
Tim Abbott
1f549dcfab check_fts_update_log: Fix use on non-appbd machines. 2016-07-30 21:48:17 -07:00
Tim Abbott
3239197fdb puppet: Silence puppet warnings about missing hiera.yaml. 2016-07-30 21:25:19 -07:00
Tim Abbott
35edd8c9dd puppet: Move crudini dependency to base.pp.
This allows us to use the new crudini-based zulipconf function in any
of our manifests in the future.
2016-07-30 21:23:12 -07:00
Tim Abbott
922a4acdc5 puppet: Add zulip.conf setting for listen_addresses tuning. 2016-07-30 21:23:12 -07:00
Tim Abbott
b2e32e6e3f puppet: Add postgres replication option for postgres_appdb_tuned.pp.
This adds a setting that controls whether to include the Zulip default
streaming replication configuration in the postgres configuration file.
2016-07-30 21:23:12 -07:00
Tim Abbott
3ab0295061 puppet: Add zulip.conf setting for effective_io_concurrency tuning. 2016-07-30 21:23:12 -07:00
Tim Abbott
f3db368a3c puppet: Add zulip.conf setting for random_page_cost tuning. 2016-07-30 21:23:12 -07:00
Tim Abbott
63c757eac3 puppet: add zulipconf function for reading settings from zulip.conf.
This makes it convenient for us to have optional user-defined settings
in the main Zulip puppet configuration.
2016-07-30 21:23:12 -07:00
Tim Abbott
98ae0516d2 docs: Fix Fedora secondary links in generic installation. 2016-07-30 21:20:54 -07:00
Tim Abbott
b63d83538e docs: Update manual install documentation for tsearch-extras.
* Suggest the PPA when possible.
* Use the `postgresql` meta package to avoid manually specifying version.
* Link to the upstream source code.
2016-07-30 21:16:56 -07:00
Tim Abbott
143575a5bd provision: Fetch tsearch_extras package from Zulip apt repository.
This fixes installing a Zulip development environment on Ubuntu Xenial.
2016-07-30 21:01:07 -07:00
Tim Abbott
af54edcaa7 scripts: Move apt repository setup to its own script. 2016-07-30 21:00:18 -07:00
Tim Abbott
d07bcf060e install: Cleanup code for PPA setup. 2016-07-30 21:00:01 -07:00
Steve Howell
ebe76dd2c3 Add stub_out_jquery() for node tests. 2016-07-30 14:54:30 -07:00
Steve Howell
6ce8f3da6d Fix node tests to be able to run standalone.
These tests would work as part of the whole suite, but
not standalone, because they were getting objects out
of node's require cache that a previous test had cleaned up.

Now they should work standalone as well, and the tests
are more explicit about their dependencies.
2016-07-30 14:54:30 -07:00
Steve Howell
2fe78dc691 Fix leaky requires between zjsunit tests.
Some node tests used to pass as long as prior tests ran,
but then they would fail if you ran them standalone.  Now
we are more aggressive about cleaning up node's require
cache after each individual test runs.
2016-07-30 14:54:30 -07:00
Steve Howell
55d8a1e960 Remove unneeded require in node_tests/activity.js 2016-07-30 14:54:30 -07:00
Steve Howell
2e254547b2 Extracted zjsunit/finder.js
This introduces a very minor different in behavior if you specify
an invalid filename as a command line argument.  We now show
warnings for those *before* running the rest of the tests.
2016-07-30 14:54:30 -07:00
Steve Howell
643f2e03e0 Extracted zjsunit/output.js 2016-07-30 14:54:30 -07:00
Steve Howell
b3bc829f61 Extracted zjsunit/render.js 2016-07-30 14:54:30 -07:00
Steve Howell
9acbff3c83 Extracted zjsunit/namespace.js 2016-07-30 14:54:30 -07:00
Steve Howell
6a65b3482c Move index.js to frontend_tests/zjsunit. 2016-07-30 14:54:30 -07:00
Tim Abbott
f0bf883772 provision: Retry node_modules setup on failures.
`npm install` fails nondeterministically occasionally, and this makes
such failures likely to be automatically resolved in most cases by
simple retrying.
2016-07-30 10:09:23 -07:00
Tim Abbott
315766ae02 provision: Provide a nice success message. 2016-07-30 10:09:23 -07:00
Tim Abbott
ed95c34b83 check-templates: Remove now-removed terms.html. 2016-07-30 09:56:54 -07:00
Steve Howell
85859fb992 Add notes about JS unit test HTML output in testing.md. 2016-07-29 22:07:24 -07:00
Steve Howell
8741903a14 Add comment to STYLESHEETS section of settings.py. 2016-07-29 22:07:24 -07:00
Steve Howell
c57bbf6c77 Introduce index.html for test-js-with-node output.
We now have an index.html for test-js-with-node output
that links to specific HTML files for various handlebar
tests.
2016-07-29 22:07:24 -07:00
Steve Howell
1d7a6c9941 Fix output from test_tr_tag_settings().
For its HTML output, it was using a wrong label and a CSS
setting that clobbered other output.
2016-07-29 22:07:24 -07:00
Steve Howell
f301ccdb3e Move source code for settings_tab() in templates.js 2016-07-29 22:07:24 -07:00
Steve Howell
b3553859f9 Move source code for propagate_notification_change() in templates.js 2016-07-29 22:07:24 -07:00
Steve Howell
9e8bff5628 Move source code for message_edit_form() in templates.js 2016-07-29 22:07:24 -07:00
Steve Howell
83a92704ee Move source code for admin_tab() in templates.js 2016-07-29 22:07:24 -07:00
Steve Howell
ec12ea5773 Consolidate bookend tests in node_tests/templates.js.
In templates.js we want to enforce outputting just
one output file per template, and we also keep the source
alphabetical by template name.  This isn't a permanent
decision, but it makes organizing the ouput a little
easier for now.
2016-07-29 22:07:24 -07:00
Steve Howell
5a3a4595f1 Move source code for admin_emoji_list() to top of its file.
We alphabetize the functions in node_tests/templates.js.  This
makes it easier for the test output to be rendered in order.
2016-07-29 22:07:24 -07:00
Steve Howell
87dbdaac68 Extract write_handlebars_output() in node tests. 2016-07-29 22:07:24 -07:00
Steve Howell
6b8e2c406b Write node test output to var/test-js-with-node/output.html
This also fixes some CSS path issues that were regressed
when files were written to 'var.'
2016-07-29 22:07:24 -07:00
Christie Koehler
31efecf03d Add HelloWorld webhook integration + Walkthough.
Improves webhook integration docs and Hello World webhook.  Includes
many suggested improvements from @timabbott and @tomaszkolek.
2016-07-29 21:38:40 -07:00
Steve Howell
2a37dafcbb Write untested_url_report.txt. 2016-07-29 21:26:51 -07:00
Steve Howell
8b13530712 Add tools/analyze-url-coverage 2016-07-29 21:23:33 -07:00
Steve Howell
21f83afe3a Add --url-coverage option to ./tools/test-backend. 2016-07-29 21:23:33 -07:00
Tim Abbott
297566510c test_activity: Increase expected query count by 1.
This is required because the Zulip UserProfile caching logic has
changed with 8e5e6a06f2, and sometimes
the current user will not be in the cache.
2016-07-29 21:15:10 -07:00
Tim Abbott
f7083b4079 test_templates: Fix Python 3 compatibility. 2016-07-29 21:11:27 -07:00
Tim Abbott
51672f9ddc Remove now-unused zulip_com template context variable. 2016-07-29 20:47:42 -07:00
acrefoot
b7ccf64c79 Move Zulip's TOS to TERMS_OF_SERVICE markdown file.
This reimplements zulip.com/terms using the new markdown system.
2016-07-29 20:47:42 -07:00
acrefoot
e568dbc76f Add TERMS_OF_SERVICE setting.
This new setting allows the server administrator to add a custom
Terms of Service page by supplying the path to a markdown file.

Also adds a test.
2016-07-29 20:47:31 -07:00
Tim Abbott
700e803840 settings: Add new DEBUG_RATE_LIMITING setting.
This exists primarily in order to allow us to mock settings.DEBUG for
the purposes of rate limiting, without actually mocking
settings.DEBUG, which I suspect Django never intended one to do, and
thus caused some very strange test failures (see
https://github.com/zulip/zulip/pull/776 for details).
2016-07-29 19:32:02 -07:00
Eklavya Sharma
5691ca61b0 Add tests for email_mirror management command. 2016-07-29 19:13:52 -07:00
Steve Howell
9fb071947d Remove expected_run_time from @slow test decorator. 2016-07-29 16:41:21 -07:00
Steve Howell
438a118ea5 Simplify enforce_timely_test_completion().
This will lead to minor differences in the warnings that
people see when they run tests that are slow.  We call out
the slowness a little more clearly from a visual standpoint,
and we simplify the calculation of the slowness threshold.

We still allow more time for tests with the `@slow` decorator
to run, but we don't use their expected_run_time.
2016-07-29 16:41:21 -07:00
Steve Howell
f67b56702a Remove @slow decorators for tests that are no longer slow.
These tests aren't exactly zippy, but they don't even make
the top 100 slow tests.
2016-07-29 16:41:21 -07:00
Steve Howell
4556bf528f Add --report-slow-tests option to tools/test-backend. 2016-07-29 16:41:20 -07:00
Tim Abbott
29b04fe654 settings: Cleanup SOCIAL_AUTH_GITHUB_KEY to match documentation. 2016-07-29 15:16:28 -07:00
Tim Abbott
2053c746c1 docs: Document GitHubAuthBackend. 2016-07-29 15:05:24 -07:00
Tim Abbott
3b5629739d docs: Cleanup typos and language in translating guide. 2016-07-29 14:49:51 -07:00
Tim Abbott
eef66ee031 Document GitHub authentication. 2016-07-29 12:49:10 -07:00
Tim Abbott
6b2b7ab3ff Rename GitHubBackend to GitHubAuthBackend for consistency. 2016-07-29 12:49:10 -07:00
Umair Khan
d43b031a32 Add tests to verify GitHub backend. 2016-07-29 12:49:10 -07:00
Umair Khan
86125080d1 Create SocialAuthMixin generic class around GitHub auth backend.
This will simplify the process of adding new social authentication
backends to Zulip.
2016-07-29 12:49:10 -07:00
Umair Khan
c1d8ad3d9a Add GitHub login button to login page. 2016-07-29 12:49:10 -07:00
Umair Khan
80d62de40a Add GitHub authentication.
Fixes: #1042
2016-07-29 12:49:10 -07:00
Tim Abbott
d9b5f3089b prod_settings: Cleanup intro to Google auth documentation. 2016-07-29 12:49:01 -07:00
Umair Khan
7531d9679b Sort language dropdown list. 2016-07-29 11:58:41 -07:00
Umair Khan
2edb79776e Calculate translation percentages.
Fixes: #1397
2016-07-29 11:58:41 -07:00
Steve Howell
f3962994b5 Fix regression for running migrations during tests.
When running ./tools/test-backend, the script to generate
fixtures, ./tools/setup/generate-fixtures, looks for a file
called migration-status to determine whether it can short
circuit doing database migrations.  This file got moved as
part of the effort to put files in "var," but the existence
check was still looking for that file in its old location.
2016-07-29 08:57:56 -07:00
Tomasz Kolek
971939caba Fix extra footer bullet in portico.html when register_link_disabled.
Fixes: #1462.
2016-07-29 08:51:09 -07:00
Tim Abbott
568dd0e142 lint-all: Improve regular expression for json_error. 2016-07-28 16:19:55 -07:00
Umair Khan
0aa72cb347 Point registration to correct url.
While logging through GitHub if the realm of the user doesn't
exist then we are redirected to registration page but the action
points to the complete url of the GitHub oAuth overflow.
2016-07-28 15:27:22 -07:00
Umair Khan
2df62d4539 Add socialauth requirements file. 2016-07-28 15:26:00 -07:00
Umair Khan
4bd0ccb6af Update zocial. 2016-07-28 15:18:18 -07:00
Reid Barton
a45b28e0b8 Don't use sudo in commands to be run as root.
It's confusing as it implicitly sends the message that the commands are to be run as a non-root user.
2016-07-28 15:13:48 -07:00
Eklavya Sharma
3b3b5c7c16 Rename management command email-mirror to email_mirror.
All other zulip management command names have underscores, so
rename email-mirror to email_mirror.

This will also make it possible to import this module, which will
help in writing tests for it.
2016-07-28 14:52:09 -07:00
Eklavya Sharma
b98b049377 Fix string handling in email_mirror queue_processor. 2016-07-28 14:52:09 -07:00
Eklavya Sharma
80bb27570d Remove unneeded dependencies.
We install service-identity to prevent twisted from giving spammy
warnings.  However, we don't need the security features provided
by service-identity.  So we can remove most of its cryptographic
dependencies.
2016-07-28 14:52:09 -07:00
Eklavya Sharma
9922ecc7d6 Shift twisted to requirements/py2_dev.txt.
Since twisted is only used for running tools/run-dev.py, we only
need it in development.  Also twisted is not python 3 compatible.
So it should be shifter to requirements/py2_dev.txt.
2016-07-28 14:52:09 -07:00
Eklavya Sharma
6e9bc44123 Re-implement email-mirror using imaplib.
Switch from twisted to imaplib to gain python 3 compatibility and
make code easier to understand.
2016-07-28 14:52:09 -07:00
Eklavya Sharma
af28d026e3 Upgrade coverage. 2016-07-28 14:38:23 -07:00
Eklavya Sharma
68058d6ca0 Upgrade transifex-client and urllib3. 2016-07-28 14:38:23 -07:00
Eklavya Sharma
cdf73ccf84 Upgrade lxml. 2016-07-28 14:38:23 -07:00
Tim Abbott
832951d2dd Fix IFTTT integration documention on 'content' field. 2016-07-28 14:05:45 -07:00
Steve Howell
ffe364c719 Don't pass UserProfile object to client_put().
This was in AdminCreateUserTest.test_create_user_backend().
For end to end tests we are logged in, and we need to verify
that our decorators add UserProfile to the parameters of
the view on our behalf, so that we don't get false positives.

In an upcoming commit, we will want to be able to serialize
the parameters for client_put to produce url coverage reports,
so that is another reason not to pass in the UserProfile
object.  (That was how this was discovered.)
2016-07-28 13:57:28 -07:00
Sumana Harihareswara
c0e1e23941 Update copyright year in documentation. 2016-07-28 13:57:05 -07:00
Umair Khan
f20f9ce8c8 Update casper testing documentation.
This adds a note that waitFor functions cannot be chained together if
the wait can cause race condition.
2016-07-28 13:55:27 -07:00
Umair Khan
8e5e6a06f2 Delete cache entry for user profile.
Our flush functions update user profile cache entries which can cause
confusing race conditions (see e.g. #1257).  To resolve this, we move
all the user_profile flush functions to delete the entry instead of
updating it -- it will then be fetched as part of the next request
that needs to access the user object.

There are still races here, and there is perhaps an argument that a
better fix for this would be to re-fetch the object and then put it
into the cache, but this resolves the main cache correctness problem
we had with the previous implementation.

Fixes: #1322.
2016-07-28 13:43:14 -07:00
Umair Khan
1a6e8282c8 Run 'check_send_receive_time' as 'zulip' user.
Run '/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time'
script as 'zulip' user so that the connection to the database can be
made correctly.
2016-07-28 13:39:29 -07:00
Tim Abbott
69528790a5 check_worker_memory: Fix handling of no queue workers running. 2016-07-28 13:26:31 -07:00
Tim Abbott
beedfb2939 Revert "[third] Upgrade jquery to version 1.8.3."
This reverts commit be93b6ea28.

Unfortunately, the newer jquery comes with a huge performance
regression affecting the hotkeys code, which has the effect of making
typing super slow.

Fixes: #1449.
2016-07-28 11:39:06 -07:00
Steve Howell
713797a65c Add lint checks for self.client.{get,patch,put,post,delete}. 2016-07-27 20:50:54 -07:00
Steve Howell
985de51903 Use self.client_delete() wrapper in more places. 2016-07-27 20:49:33 -07:00
Steve Howell
6937f63fd5 Add client_get() test helper. 2016-07-27 20:49:33 -07:00
Steve Howell
38f2a2f475 Add client_post() test helper.
This makes us more consistent, since we have other wrappers
like client_patch, client_put, and client_delete.

Wrapping also will facilitate instrumentation of our posting code.
2016-07-27 20:49:32 -07:00
Eklavya Sharma
eb34c249d7 Upgrade doc-building dependencies.
Upgrade alabaster and sphinx to latest version.
commonmark can't be updated because recommonmark uses an old
version of commonmark which is incompatible with latest version.
2016-07-27 14:47:29 -07:00
Steve Howell
51bae8abc4 Remove stub() test helper. 2016-07-27 14:12:10 -07:00
rahuldeve
ec6c9ba436 Add test for removing an uploaded file via message editing.
Fixes #1373.
2016-07-27 14:10:15 -07:00
rahuldeve
4267dcbb68 Change the way referred attachments are removed on message update.
This fixes incorrect behavior when two or more attachments are removed
in the same message.
2016-07-27 14:08:59 -07:00
Tim Abbott
65175ef15a Test upgrading Tornado to 3.1.1. 2016-07-27 13:47:34 -07:00
Tim Abbott
97e0306795 Replace localhost with 127.0.0.1 in casper tests. 2016-07-27 13:47:26 -07:00
Rishi Gupta
e515484c41 Fix typos in the documentation.
Pushing this now so as to not create merge conflicts with others working on
the prod docs.
2016-07-27 13:44:27 -07:00
Eklavya Sharma
c51b5bced8 Upgrade regex. 2016-07-27 13:03:31 -07:00
Eklavya Sharma
933d327c1a Upgrade python-ldap. 2016-07-27 13:03:31 -07:00
Eklavya Sharma
3473891aa5 Upgrade enum34. 2016-07-27 13:03:31 -07:00
Eklavya Sharma
7c37316432 Upgrade pylibmc. 2016-07-27 13:03:31 -07:00
Umair Khan
bede14724d Fix non-determinism in admin frontend tests.
According to http://docs.casperjs.org/en/latest/modules/casper.html#waitfor,
waitFor functions cannot be chained together. All functions that start with
'waitFor', like `waitForSelector`, use `waitFor` function so they should be
wrapped in a `then`.

Fixes: #1352
2016-07-27 12:32:48 -07:00
Tim Abbott
c2bed83a84 run-dev: Hardcode 127.0.0.1 rather than localhost.
Using "localhost" is problematic in Travis CI, where they have
/etc/hosts configured to make `localhost` resolve to both 127.0.0.1
and ::1.
2016-07-27 11:39:12 -07:00
Tim Abbott
df525ad1c5 Remove old MitUser model and related code.
The MitUser model caused a constant series of little problems for
users with mit.edu email addresses trying to sign up for different
Zulip servers.

The new implementation just uses conditionals on the realm object when
selecting the confirmation template to use.
2016-07-26 20:30:12 -07:00
Tim Abbott
ed6c134cf4 Clean up and document clean_email code path. 2016-07-26 20:30:12 -07:00
Tim Abbott
375551aaa6 Clean up most hardcoding of mit.edu domain checks.
This moves all this code to be gated on a few virtual realm settings.
2016-07-26 20:30:12 -07:00
Tim Abbott
70543e059a bugdown: Remove hardcoding of mit.edu for zephyr_mirror realm config. 2016-07-26 20:30:12 -07:00
Tim Abbott
c17676b00c Cleanup MIT hardcoding for disabling presence. 2016-07-26 20:30:12 -07:00
Tim Abbott
884f50cdd7 validate_user_access: Assert user_profile is not None.
This function is only called in cases where user_profile isn't None,
and the code reads better if we just check that first rather than
checking it on every line that accesses user_profile.
2016-07-26 20:30:12 -07:00
Tim Abbott
d1adbd798b get_subscribers_to_streams: Pass through requesting_user. 2016-07-26 20:30:12 -07:00
Tim Abbott
691ad7fcfc maybe_get_subscriber_emails: Pass user_profile through. 2016-07-26 20:30:12 -07:00
Tim Abbott
f790a04102 Remove unused get_subscriber_ids. 2016-07-26 20:30:12 -07:00
Tim Abbott
1771b8275c Remove unused get_other_subscriber_ids. 2016-07-26 20:30:12 -07:00
Steve Howell
eb11e02309 Add MirroredMessageUsersTest. 2016-07-26 20:01:36 -07:00
Steve Howell
3fa745ebe3 Remove untested code in is_public_stream().
We were calling valid_stream_name(), but more appropriate
validation checks for stream names happen elsewhere in the codepath.
2016-07-26 18:10:00 -07:00
Steve Howell
81cd9d33e4 Add test_non_string_narrow_operand_in_dict(). 2016-07-26 18:10:00 -07:00
Tim Abbott
b2d1c18268 views: Move push token views to new push_notification.py. 2016-07-26 14:44:24 -07:00
Tim Abbott
6dc5681171 views: Move presence views to presence.py. 2016-07-26 14:29:32 -07:00
Tim Abbott
62affa53c9 views: Move update_realm to new realm.py views file. 2016-07-26 14:29:24 -07:00
Umair Khan
7c138c6e33 Import is_inactive from proper file. 2016-07-26 12:26:55 -07:00
Eklavya Sharma
408d070170 puppet/: Make subprocess calls unicode-aware. 2016-07-26 12:06:41 -07:00
Eklavya Sharma
51ea5c1602 scripts/: Make subprocess calls unicode-aware. 2016-07-26 12:06:41 -07:00
Eklavya Sharma
97d877f49e tools/: Make subprocess calls unicode-aware. 2016-07-26 12:06:41 -07:00
Eklavya Sharma
e0dbaf1031 Use universal_newlines=True in subprocess.check_output.
In python 3, subprocess uses bytes for input and output if
universal_newlines=False (the default).  It uses str for input and
output if universal_newlines=True.

Since we mostly deal with strings, add universal_newlines=True to
subprocess.check_output.
2016-07-26 12:06:41 -07:00
Eklavya Sharma
5ce80eb4ba Update types of images accepted as avatars.
* Reject SVG in frontend because backend doesn't accept it.
* Add JPEG format in backend tests for avatar upload.
2016-07-26 16:36:47 +05:30
Eklavya Sharma
a2a8b54f6e Upgrade pillow.
Update test images because pillow's resize algorithm has changed.
2016-07-26 16:36:07 +05:30
rahuldeve
5ed2b01bc7 upload: Fix single attachments not being claimed on message edit.
Fixed an attachments not being claimed if just one new attachment is
added (aka the common case).
2016-07-25 17:56:27 -07:00
rahuldeve
e06d5fbec9 Pass Message object instead of message dict to do_claim_attachments. 2016-07-25 17:54:36 -07:00
rahuldeve
c61d149837 Pass Message object instead of message dict to claim_attachment. 2016-07-25 17:51:17 -07:00
Alexander Trost
6e10236972 Disable auto-service-restart for docker installations. 2016-07-25 16:40:29 -07:00
Steve Howell
57c436b32d Add TODOs for #1379 (bugdown mutual dependency) 2016-07-25 14:59:32 -07:00
Ashish Kumar
8398dac025 Fix 'Invalid stream' error message in get_subscription_or_die(). 2016-07-25 14:48:48 -07:00
Ashish Kumar
56048919f5 Increase test coverage of streams API by covering JSON errors. 2016-07-25 14:48:48 -07:00
Ashish Kumar
84566c750f Add test_successful_subscriptions_add_with_announce(). 2016-07-25 14:45:29 -07:00
Ashish Kumar
a143677ea2 Add test_json_get_subscribers(). 2016-07-25 14:45:28 -07:00
Ashish Kumar
9104468926 Add test_existing_subscriptions_autosubscription(). 2016-07-25 14:43:27 -07:00
Taranjeet Singh
1328a10069 Move available-migration and migration-status to var/. 2016-07-25 14:39:35 -07:00
Taranjeet Singh
b143d6ca6e Move test_credentials.js to var/casper. 2016-07-25 14:39:23 -07:00
Taranjeet Singh
a131fc74f0 frontend_tests/run-casper: Move server.log to var/casper. 2016-07-25 14:39:16 -07:00
Tim Abbott
b49b3d5899 Upgrade moto dependency versions. 2016-07-25 12:31:32 -07:00
Tim Abbott
df32750f88 docs: Add a bit of discussion of settings philosophy. 2016-07-25 11:43:41 -07:00
Tim Abbott
488cc547d2 docs: Expand discussion of settings secrets. 2016-07-25 11:43:41 -07:00
Eklavya Sharma
f067c7fb15 Fix email-mirror instructions in prod_settings_template.py.
When email mirroring is done via polling, the IMAP account's
password should be stored in zulip-secrets.conf in
email_gateway_password, not in email_gateway_login.
2016-07-25 11:30:17 -07:00
Eklavya Sharma
29af1419db Make tools/update-deployment pass mypy check. 2016-07-25 22:06:05 +05:30
Eklavya Sharma
fb62e5c7bd Upgrade Twisted. 2016-07-25 08:45:10 -07:00
Eklavya Sharma
6ed5163795 Upgrade Jinja2. 2016-07-24 19:45:52 -07:00
Steve Howell
2846e23cfc Extracted test helper: get_and_check_messages().
This new helper combines two old helpers, one of which was misnamed
and the other of which was always called after the first, so it
made sense to just combine the helpers.

Fixes: #1386
2016-07-24 19:43:56 -07:00
Eklavya Sharma
b08d6769c1 tools/zulip-export/zulip-export: Fix how files are opened.
Instead of using codecs.open, use the builtin open in binary mode
and write data after encoding it in utf-8.
2016-07-24 22:32:08 +05:30
Eklavya Sharma
df7dcdda5f Annotate tools/get-handlebar-vars. 2016-07-24 22:12:32 +05:30
Eklavya Sharma
61ffd835e1 Annotate tools/minify-js. 2016-07-24 21:58:02 +05:30
Eklavya Sharma
1e0a971178 Annotate tools/test-run-dev. 2016-07-24 21:33:40 +05:30
Eklavya Sharma
7edc38bbf7 Remove tools/test-js-with-casper from mypy exclude list. 2016-07-24 21:07:07 +05:30
Eklavya Sharma
e6264fa6fb Annotate tools/compile-handlebars-templates. 2016-07-24 21:07:06 +05:30
Eklavya Sharma
1a77b599f6 Make tools/post-receive python 3 compatible. 2016-07-24 21:07:06 +05:30
Eklavya Sharma
00a120c34f Improve a string in tools/post-receive. 2016-07-24 21:07:02 +05:30
Eklavya Sharma
ab8890b304 Annotate tools/check-templates. 2016-07-24 21:04:32 +05:30
Eklavya Sharma
2f889550cb tools/check-templates: Use __init__ in Record.
Initialize Record by using __init__ instead of setting attributes
in validate.  This is needed because mypy complains when we set
new attributes outside __init__.
2016-07-24 21:04:32 +05:30
Eklavya Sharma
ecf2249536 tools/check-templates: Set modified's default to False.
Set default value of options.modified to False.
2016-07-24 21:04:31 +05:30
Eklavya Sharma
9c177fcd1b tools/check-templates: Remove unneeded return. 2016-07-24 21:04:31 +05:30
Eklavya Sharma
bd0fa3e77b Annotate tools/lint-all. 2016-07-24 21:04:31 +05:30
Eklavya Sharma
ec6b630537 Make tools/run-mypy pass mypy check. 2016-07-24 21:04:22 +05:30
Eklavya Sharma
3d87c376c2 Make zulip-ec2-configure-interfaces pass mypy check. 2016-07-24 12:52:58 +05:30
Eklavya Sharma
0a5aa2ccc7 Make check_send_receive_time pass mypy check. 2016-07-24 12:41:06 +05:30
Eklavya Sharma
1820f961b3 frontend_tests/run-casper: Fix annotations. 2016-07-24 10:52:54 +05:30
Steve Howell
1da9325476 Require non-empty full_name or password in json_change_settings 2016-07-23 14:53:15 -07:00
Steve Howell
14717f414c Add default for full_name in json_change_settings. 2016-07-23 14:53:15 -07:00
Steve Howell
f27ad0d800 Add test_changing_nothing_still_returns_success().
(in ChangeSettingsTest)
2016-07-23 14:53:15 -07:00
Steve Howell
728ac09df9 Remove ChangeSettingsTest.post_with_params().
The individual tests now explicitly show all the parameters
they are passing to the endpoint, which makes them easier
to troubleshoot.
2016-07-23 14:53:15 -07:00
Steve Howell
f01b10f97a Improve test coverage for use_first_unread_anchor parameter.
This commit adds these two tests:

test_use_first_unread_anchor_with_some_unread_messages
test_use_first_unread_anchor_with_no_unread_messages

The new tests add coverage to the conditional logic in
get_old_messages_backend() that looks at first_unread_result
when use_first_unread_anchor is set to True.
2016-07-23 14:39:58 -07:00
Steve Howell
08f6ae7c14 Improved and renamed test_use_first_unread_anchor().
The test is now called test_use_first_unread_anchor_with_muted_topics().
Before this commit, the test exercised setting
use_first_unread_anchor to True, but it didn't inspect the
most relevant query affected by the flag.  Now it does.

This test is still kind of hard to read, and it's far from ideal,
but I'm reluctant to remove it from the test suite.
2016-07-23 14:39:58 -07:00
Steve Howell
ee2007136d Test "empty list" logic in exclude_muting_conditions(). 2016-07-23 14:39:58 -07:00
Eklavya Sharma
196e021a7f Add automated tests for zerver/lib/type_debug.py. 2016-07-23 14:38:28 -07:00
Eklavya Sharma
ed03619f95 docs/mypy.md: Document zerver/lib/type_debug.py. 2016-07-23 14:38:24 -07:00
Eklavya Sharma
5b06edc402 zerver/lib/type_debug.py: Handle container types better. 2016-07-23 14:35:39 -07:00
Eklavya Sharma
a632c71cce Add zerver/lib/type_debug.py.
This file has a decorator print_types, which makes the decorated
function print the types of its arguments whenever it is called.
2016-07-23 14:35:39 -07:00
Taranjeet Singh
250c617dc8 zulip_tools.py: Fix line with length greater than 120. 2016-07-23 14:33:57 -07:00
Taranjeet Singh
9bea1f46c7 zerver/views/webhooks/bitbucket2.py: Fix line with length greater than 120. 2016-07-23 14:33:11 -07:00
Taranjeet Singh
5e34e5bf40 iframe-bot/show-last-messages: Fix line with length greater than 120. 2016-07-23 14:33:11 -07:00
Taranjeet Singh
3faa5c1dd9 README.dev.md: Fix test suite dev markup formatting. 2016-07-23 14:32:39 -07:00
Eklavya Sharma
11732f9ab0 Make all scripts in scripts/ pass mypy check. 2016-07-24 00:17:21 +05:30
Tim Abbott
eba2d470dc Fix removing attachments when editing a message.
Fixes #1373.
2016-07-22 14:48:47 -07:00
Tim Abbott
4de203a23f Fix MIT users joining a Zulip realm. 2016-07-22 14:27:36 -07:00
Eklavya Sharma
09e4e5aea7 Add links after type: ignores. 2016-07-22 13:59:31 -07:00
Tim Abbott
226a57d2c8 travis: Disable test-queue-worker-reload temporarily.
It's failing nondetermistically pretty often, and I'd like to cut the
impact to other users' work.
2016-07-22 11:36:52 -07:00
Eklavya Sharma
fb59a07a89 Run mypy on extensionless python scripts in Travis. 2016-07-22 11:16:29 -07:00
Eklavya Sharma
f4c557d2a7 tools/run-mypy: Exclude scripts which don't pass mypy. 2016-07-22 11:16:29 -07:00
Eklavya Sharma
c12db5246d Use separate exclude list for scripts. 2016-07-22 11:16:29 -07:00
Eklavya Sharma
102fcda4ab tools/run-mypy: Add option --scripts-only.
This option is for checking only extensionless python scripts.
2016-07-22 11:16:29 -07:00
Eklavya Sharma
674f6999e1 Improve annotations of decorators. 2016-07-22 11:14:33 -07:00
Eklavya Sharma
4b7d94564a zerver/views/streams.py: Annotate variables to help mypy. 2016-07-22 11:14:33 -07:00
Eklavya Sharma
07e36d87a2 Remove return where no return value is expected.
zerver.lib.notifications.send_future_email has return type None.
So replace `return send_future_email(...` by `send_future_email(...`.
2016-07-22 11:14:33 -07:00
Krit Karan
a61ef3bc0e Reformat the content variable in `do_refer_friend()`.
Fixes #1162.
2016-07-22 10:36:35 -07:00
Eklavya Sharma
baa157344c Patch activate script only in development. 2016-07-21 14:11:41 -07:00
Eklavya Sharma
e7813094d7 Patch activate script to set VIRTUAL_ENV correctly.
Patch a virtualenv's activate script to not resolve symlinks when
setting the environment variable VIRTUAL_ENV.

Fixes #1190.
2016-07-21 14:11:41 -07:00
Eklavya Sharma
c59740385d zerver/lib/str_utils.py: Replace ValueError by TypeError.
When a parameter of a wrong type is passed to a `force_*` method
in str_utils.py, raise a TypeError.
2016-07-21 23:14:00 +05:30
Umair Khan
dce48d58b6 Cache translations.
Fixes: #1158
2016-07-21 10:23:31 -07:00
Tim Abbott
30dd8cfd4a test-queue-worker-reload: Increase sleep resolution. 2016-07-21 10:21:29 -07:00
Umair Khan
7d687b0f79 Increase the timeout in test-queue-worker-reload.
May fix #1341.
2016-07-21 10:19:49 -07:00
Eklavya Sharma
7bd935bef2 Add option to only show extensionless files in lister. 2016-07-21 16:59:52 +05:30
Tim Abbott
2a209e46dd puppet: Fix remaining hardcoding of postgres 9.1 in manifests. 2016-07-20 21:11:22 -07:00
Tim Abbott
175e9f1593 run-casper: Move remote_debug argument construction earlier. 2016-07-20 20:35:48 -07:00
Tim Abbott
345d7b670a run-casper: Move list of files to be run_tests arguments. 2016-07-20 20:35:48 -07:00
Tim Abbott
2187ba231e run_casper: Move run_tests into a function. 2016-07-20 20:35:47 -07:00
Tim Abbott
b58e1fd5fc run-casper: Add server argument to server_is_up. 2016-07-20 20:24:43 -07:00
Tim Abbott
69a9db17d3 run_casper: Move some setup tasks later in the file. 2016-07-20 20:17:40 -07:00
hackerkid
b6620cfa57 Replace UserProfile with HttpRequest in logged_in_and_active. 2016-07-20 20:08:00 -07:00
Tim Abbott
2bcce28b07 changelog: Clean up some minor text issues.
Thanks @rishig for the review!  I forgot to apply these before
merging.
2016-07-20 20:01:30 -07:00
Tim Abbott
5b583c7417 Fix django statsd packages. 2016-07-20 19:03:29 -07:00
Tim Abbott
21c30b9fed Vagrantfile: Update default RAM in development. 2016-07-20 18:40:10 -07:00
Tim Abbott
568a2facce docs: Fix links to troubleshooting guide. 2016-07-20 18:40:10 -07:00
Christie Koehler
827c015458 Updates Zulip dev setup for first-time contributors
Updates Zulip dev setup for first-time contributors as follows:

- Recommends and links to Vagrant version 1.8.4 (from 1.8.1)
- Consolidates Ubuntu 14.04 and Ubuntu 16.04 instructions since they are
  now identical.
- Updates memory requirement to 2GB to address out of memory related
  errors (see issue #1333).

Fixes #1288.
2016-07-20 18:40:10 -07:00
Tim Abbott
9fb933d456 docs: Fix style issues in life-of-a-request. 2016-07-20 18:31:41 -07:00
Taranjeet Singh
44d23975ed Move update-prod-static.log to var/log. 2016-07-20 18:27:44 -07:00
Taranjeet Singh
9b31f0a67a node tests: Move .test-js-with-node.html to var/." 2016-07-20 18:23:56 -07:00
Eklavya Sharma
6548f1dd1c Factor out venv-installing code into a module.
Factor out the code in tools/provision.py which installs a python2
and python3 venv into a module (tools/setup/setup_venvs.py) which
can also be used as a script.
2016-07-20 18:20:37 -07:00
Eklavya Sharma
2930a769a9 Add __init__.py to tools/ and tools/setup/.
This will make it possible to import stuff from tools/setup/.
2016-07-20 18:20:37 -07:00
acrefoot
38bf0bf39b Add Life of a Request doc (#1302)
This doc follows the different layers that Zulip uses
to handle a request, detailing parts of those layers that
would be most commonly interesting to developers.
2016-07-20 17:12:15 -07:00
acrefoot
c671ae22d1 Error better when handlebars template is missing (#1338)
Currently if you try to use a non-existent handlebars
template, you get this error:

Uncaught TypeError: Handlebars.templates[name] is not a function

This change makes it a little more clear what the issue is
and what the fix would be.
2016-07-20 15:56:27 -07:00
Tim Abbott
dd6e92a714 setup_venv: Fix missing dependencies on image libraries. 2016-07-20 14:55:45 -07:00
Tim Abbott
a07eca2639 Revert "Factor out venv-installation into a script."
This reverts commit 852c49a44e.

I think this may have broken provisioning without a venv.
2016-07-20 14:55:45 -07:00
Eklavya Sharma
f664d00fe8 Add python2 and python3 venv install instructions. 2016-07-20 14:18:51 -07:00
Eklavya Sharma
852c49a44e Factor out venv-installation into a script. 2016-07-20 14:18:51 -07:00
Tim Abbott
c791037166 narrow: Document BuildNarrowFilterTest. 2016-07-20 14:18:40 -07:00
acrefoot
0dfb76fc5e Change HTTP verb for create_user_backend to PUT (#1326) 2016-07-20 12:57:47 -07:00
Steve Howell
2484d870b4 Add test_build_narrow_filter(). 2016-07-20 11:04:00 -07:00
Tim Abbott
14143e2222 roadmap: Fix issue number for upgrading every dependency.
The previous issue number corresponded to just the work to move to a
virtualenv, not to actually upgrade the dependency versions.
2016-07-20 10:54:52 -07:00
Umair Khan
9dad92f323 Switch to upstream Talon repository. 2016-07-20 10:47:05 -07:00
Tim Abbott
f4ffae8685 docs: Update roadmap with completed projects, etc. 2016-07-20 10:28:35 -07:00
Tim Abbott
b96a10ec9a Add draft changelog since Zulip 1.3.13 release. 2016-07-20 10:12:57 -07:00
Eklavya Sharma
576a090499 Add libpq-dev to VENV_DEPENDENCIES. 2016-07-20 22:15:06 +05:30
Tim Abbott
741c21c3ce update_deployment: Make git repository URL configurable. 2016-07-19 21:02:47 -07:00
Tim Abbott
a5a79280cb update_deployment: Add symlink for use in voyager installs. 2016-07-19 20:59:59 -07:00
Tim Abbott
35339f5117 Rename local_settings_template to prod_settings_template. 2016-07-19 20:59:59 -07:00
Tim Abbott
19b860ceec Rename local_settings.py symlink to prod_settings.py. 2016-07-19 20:59:59 -07:00
Tim Abbott
82f9f8f941 update-deployment: Compute ZULIP_COM setting. 2016-07-19 20:52:08 -07:00
Tim Abbott
7348841e65 update-prod-static: Copy static/locale rather than moving.
The old behavior results in a large diff when deploying based on a git
commit.
2016-07-19 20:52:08 -07:00
Tim Abbott
28fa4e8346 build_release_tarball: Remove local_settings.py overwrite hack. 2016-07-19 20:52:06 -07:00
Tim Abbott
78a0c7c557 tools: Rewrite install-server to not hardcode configuration.
Now install-aws-server is a reusable script for setting up a Zulip
role server in AWS, without any hardcoded configuration.
2016-07-19 20:12:43 -07:00
Tim Abbott
9c9b6176a9 install: Fix feature detection/set -e incompatibility.
Previously, the whole script would stop when a feature wasn't
available.
2016-07-19 20:12:27 -07:00
Tim Abbott
8eaa75b90f setup_venv: Remove unnecessary postgresql-server-dev-all dependency.
This package is a dependency for building tsearch_extras, but isn't
needed for building a Zulip virtualenv.
2016-07-19 19:19:42 -07:00
Tim Abbott
d529bc12ef pg_backup_and_purge: Fix hardcoding of postgres version. 2016-07-19 19:19:42 -07:00
Tim Abbott
bdb1ce04a2 puppet: Move pg_backup_and_purge to main config. 2016-07-19 19:19:42 -07:00
Tim Abbott
81136ff092 env-wal-e: Eliminate hardcoding of AWS keys.
Pre-Zulip being open sourced, this file just had the AWS keys for
backups hardcoded.

Instead, these are simply read from zulip-secrets.conf.
2016-07-19 19:19:42 -07:00
Tim Abbott
3023745ed7 puppet: Move env-wal-e to Zulip main distribution.
This doesn't yet include the dependencies for env-wal-e.
2016-07-19 19:19:42 -07:00
Tim Abbott
d0dcc8bf26 puppet: Create static_asset_compiler manifest. 2016-07-19 16:38:09 -07:00
Tim Abbott
601ab24d2a zulip_internal::app_frontend: Remove now-unnecessary dependencies.
These Python packages are no longer relevant, since we install all of
our Python dependencies via virtualenvs.
2016-07-19 16:37:50 -07:00
Tim Abbott
e876f12b83 settings: Extract settings.WELCOME_EMAIL_SENDER. 2016-07-19 15:28:41 -07:00
Tim Abbott
7725c62892 Use VERBOSE_SUPPORT_OFFERS in day1 emails. 2016-07-19 15:28:41 -07:00
Tim Abbott
3ea4cbb5c3 settings: Extract settings.VERBOSE_SUPPORT_OFFERS. 2016-07-19 15:28:41 -07:00
Tim Abbott
543311848d templates: Replace not_voyager check with dropboxAppKey check.
Also remove useless/confusing value of DROPBOX_APP_KEY in
DEFAULT_SETTINGS (it's overridden by the get_secret call anyway).
2016-07-19 15:28:41 -07:00
Tim Abbott
ff1faffecd settings: Extract EMAIL_GATEWAY_EXTRA_PATTERN_HACK. 2016-07-19 15:28:41 -07:00
Tim Abbott
82f78621dd settings: Extract CUSTOM_LOGO_URL. 2016-07-19 15:28:41 -07:00
Tim Abbott
de679a23c9 settings: Extract settings.REGISTER_LINK_DISABLED. 2016-07-19 15:28:41 -07:00
Tim Abbott
c25b077224 settings: Extract settings.SHOW_OSS_ANNOUNCEMENT. 2016-07-19 15:28:41 -07:00
Tim Abbott
ed285e22f1 settings: Remove ZULIP_COM_STAGING setting.
This setting is no longer used outside the local_settings.py file for
zulip.com.
2016-07-19 15:28:41 -07:00
Tim Abbott
fb386da552 settings: Extract settings.SAVE_FRONTEND_STACKTRACES. 2016-07-19 15:28:41 -07:00
Tim Abbott
522ccf8eb2 settings: Extract settings.STAGING_ERROR_NOTIFICATIONS. 2016-07-19 15:28:41 -07:00
Tim Abbott
1f4c9eefe4 settings: Extract settings.ZILENCER_ENABLED. 2016-07-19 15:28:41 -07:00
Tim Abbott
0aaa55fb8f settings: Extract settings.SHARE_THE_LOVE. 2016-07-19 15:28:41 -07:00
Tim Abbott
afaac85dc6 Move get_sqlalchemy_connection to its own file. 2016-07-19 15:28:41 -07:00
Tim Abbott
6a90dc07dc docs: Fix headings for possible testing issues. 2016-07-19 15:00:14 -07:00
Sumana Harihareswara
d828ba5688 Move testing instructions to main test suite doc.
Also, improve links and headers in testing.md.
2016-07-19 14:57:07 -07:00
Sumana Harihareswara
db6c9702c2 Update links in README and integration guide. 2016-07-19 14:57:07 -07:00
Sumana Harihareswara
e98f24734c Update developer install docs links and image embed.
Sphinx/RTD creates different anchor tags for subheadings than
Markdown does, and treats image embedding differently.
This commit updates hyperlinks to affected anchors,
and fixes an image embed for move to RTD.
2016-07-19 14:57:07 -07:00
Sumana Harihareswara
5473b03e3b Split out generic UNIX developer install doc. 2016-07-19 14:57:07 -07:00
Sumana Harihareswara
9aba0f84a8 Split non-Vagrant Ubuntu install doc into topic page. 2016-07-19 14:57:07 -07:00
Sumana Harihareswara
cf7b1af508 Split developer environment usage instructions into new page. 2016-07-19 14:57:07 -07:00
Sumana Harihareswara
c40ffd9538 Split out docker setup doc. 2016-07-19 14:57:07 -07:00
Sumana Harihareswara
97ff43e972 Move and rearrange vagrant instructions. 2016-07-19 14:57:07 -07:00
Sumana Harihareswara
b95370f833 Move and rearrange developer setup instructions.
We aim to consolidate developer documentation on Read The Docs. As a
start, this commit turns the first part of README.dev.md into a topic
page within /docs/ , and links to it from the doc index.

See #669.
2016-07-19 14:57:07 -07:00
Alex Dehnert
b0f037eb82 Add support for client certs to the Python API.
This adds support for passing a client cert (in the format expected by the
`requests` library) to the `Client` constructor, as well as for specifying
one on the command line or in .zuliprc (through new `client_cert` and
`client_cert_key` options).
2016-07-19 14:40:26 -07:00
Eklavya Sharma
d745f20b1b Run frontend and backend tests in python3 on Travis. 2016-07-19 14:15:35 -07:00
Eklavya Sharma
fd007c4554 Make tools/test-run-dev python3 compatible.
Use universal_newlines=True with subprocess.check_output in
tools/test-run-dev.
2016-07-19 14:15:35 -07:00
Eklavya Sharma
e86539649c Use tools/travis/activate-venv in test suites. 2016-07-19 14:15:35 -07:00
Eklavya Sharma
5054a8d6c9 tools/run-dev.py: Use twisted venv if on python 3. 2016-07-19 14:15:35 -07:00
Eklavya Sharma
cfed816a52 tools/provision.py: Install a python2 venv with twisted.
Twisted is not python 3 compatible.  So for now create a python2
venv and install twisted in it when running provision.py in python3
mode and use twisted from the python2 venv.
2016-07-19 14:15:35 -07:00
Eklavya Sharma
9c66cb7130 tools/provision.py: Install both py2 and py3 venvs.
Install both python2 and python3 venvs in tools/provision.py by
default.  Use old behavior when run with --travis to save time.
2016-07-19 23:39:50 +05:30
Eklavya Sharma
eb43f7f581 tools/provision.py: Factor out "--travis" in sys.argv. 2016-07-19 23:39:50 +05:30
Tim Abbott
13c2effb61 update-deployment: Make zulip-dropbox.png logic conditional. 2016-07-19 10:01:14 -07:00
Tim Abbott
6b0d8ecfba update-deployment: Run create-production-venv as root. 2016-07-19 09:51:13 -07:00
Tim Abbott
07473f4007 update-prod-static: Use a virtualenv to find dependencies.
This is needed to support using update-deployment with a virtualenv.
2016-07-19 09:51:13 -07:00
Umair Khan
62c3751b98 06-settings.js: Rearrange code for readability. 2016-07-19 08:57:42 -07:00
Umair Khan
87dc96b474 Disable casper tests for alert words.
As they stand now, alert words tests will cause a race condition with
all subsequent tests which access the UserProfile object these tests
modify. Currently, if we modify alert words, we don't get any
notification from the server, issue reported at #1269. Consequently, we
can't wait on any condition to avoid the race condition. The best option
is to wait for the fix of #1269 and modify the tests in that issue.

Fixes: #1244
2016-07-19 08:57:42 -07:00
Tim Abbott
139bca720d Upgrade ipython dependency versions. 2016-07-19 00:00:01 -07:00
Tim Abbott
ef4d11e906 Upgrade Python RSA module. 2016-07-19 00:00:01 -07:00
Tim Abbott
40371422cd Upgrade to typing 3.5.2.2. 2016-07-19 00:00:01 -07:00
Steve Howell
83679a7775 Test search queries and highlight_string().
This increases test coverage by exercising highlight_string().
It also gives deeper test coverage to NarrowBuilder.by_search(),
which had test coverage before, but only in terms of inspecting
the SQL that was generated.  This test actually runs the SQL
under the hood.

This partly fixes #1006.
2016-07-18 16:39:19 -07:00
Tim Abbott
50c3e42f0e Fix test failure due to recent merge interaction.
599b15cb84 broke master because it had
previously only been tested before HomeTest was created.
2016-07-18 16:37:25 -07:00
Kartik Maji
599b15cb84 Allow fetching subscribers for streams the user has never subscribed to.
This allows the frontend to fetch data on the subscribers list (etc.)
for streams where the user has never been subscribed, making it
possible to implement UI showing details like subscribe counts on the
subscriptions page.

This is likely a performance regression for very large teams with
large numbers of streams; we'll want to do some testing to determine
the impact (and thus whether we should make this feature only fully
enabled for larger realms).
2016-07-18 16:24:19 -07:00
Taranjeet Singh
5462341cb4 zerver/views/webhooks/github.py: Fix lines with length greater than 120. 2016-07-18 15:10:41 -07:00
Taranjeet Singh
3031214718 zerver/views/messages.py: Fix line with length greater than 120. 2016-07-18 15:05:52 -07:00
Tim Abbott
3c591aa724 compilemessages: Don't try to include zh-CN and zh_CN in language options. 2016-07-18 15:02:43 -07:00
Tim Abbott
55a98a41d8 compilemessages: Improve error handling for unknown locale. 2016-07-18 15:02:43 -07:00
Tim Abbott
6d21a1ec65 Update translations data from Transifex. 2016-07-18 15:02:43 -07:00
Taranjeet Singh
84660a5087 zerver/views/__init__.py: Fix lines with length greater than 120. 2016-07-18 14:51:06 -07:00
Taranjeet Singh
0cafd9268d zilencer/management/commands/populate_db.py: Fix line with len > 120. 2016-07-18 14:42:39 -07:00
Taranjeet Singh
37ea785b8f zerver/forms.py: Fix line with length greater than 120. 2016-07-18 14:42:39 -07:00
Taranjeet Singh
9f3f82d06d zerver/lib/socket.py: Fix line with length greater than 120. 2016-07-18 14:42:39 -07:00
Taranjeet Singh
5499136bfd zerver/views/webhooks/teamcity.py: Fix line with length greater than 120. 2016-07-18 14:42:39 -07:00
Taranjeet Singh
7199ee8f08 zerver/views/webhooks/taiga.py: Fix line with length greater than 120. 2016-07-18 14:42:39 -07:00
Taranjeet Singh
3e17011f9c zerver/views/webhooks/pivotal.py: Fix line with length greater than 120. 2016-07-18 14:42:39 -07:00
Taranjeet Singh
c437659cd9 zerver/views/webhooks/pingdom.py: Fix line with length greater than 120.
zerver/views/webhooks/pingdom.py: Fix indetation for function args.
2016-07-18 14:42:39 -07:00
Taranjeet Singh
7ddb254d2e zerver/views/webhooks/circleci.py: Fix line with length greater than 120.
zerver/views/webhooks/circleci.py: Fix indentation for function args.
2016-07-18 14:42:39 -07:00
Taranjeet Singh
1323685140 zerver/views/webhooks/beanstalk.py: Fix line with length greater than 120.
zerver/views/webhooks/beanstalk.py: Capture string in a temp variable.
2016-07-18 14:42:39 -07:00
Taranjeet Singh
569d14a826 zerver/views/webhooks/airbrake.py: Fix line with length greater than 120.
zerver/views/webhooks/airbrake.py: Fix Indentation.

zerver/views/webhooks/airbrake.py: Fix Indentation for args in function.
2016-07-18 14:42:39 -07:00
Taranjeet Singh
10afbc06f9 zerver/views/report.py: Fix line with length greater than 120.
zerver/views/report.py: Capture string in temporary variables.
2016-07-18 14:42:39 -07:00
Taranjeet Singh
24ba060421 Fix line with length greater than 120 in deliver_email.py. 2016-07-18 14:34:34 -07:00
Eklavya Sharma
38b1353f42 tools/run-dev.py: Clear memcached.
Clear memcached when tools/run-dev.py is run.  This prevents
errors on using a different python version because values are
pickled before being stored in memcached and different python
versions implement pickling differently.

Also provide a command-line option --no-clear-mc to prevent
memcached from being cleared.
2016-07-18 14:25:13 -07:00
Tim Abbott
014a13df7c cache: Fix echoing of mkdir command to console. 2016-07-18 14:25:13 -07:00
Taranjeet Singh
4c805b8757 gitignore: Remove unnecessary files and dirs. 2016-07-18 14:13:33 -07:00
Taranjeet Singh
64332d8816 Update linecoverage directory to linecoverage-report.
tools/provision.py: Create directory var/linecoverage-report.

tools/run-mypy: Update coverage dir to var/linecoverage-report.
2016-07-18 14:13:33 -07:00
Taranjeet Singh
4d2cb3754c Update upload dir to var/uploads.
tools/provision.py: Create directory var/uploads.

zproject/local_settings_template.py: Update Upload dir to var/uploads.

zproject/dev_settings.py: Update upload dir to var/uploads.
2016-07-18 14:13:33 -07:00
Taranjeet Singh
d4021fc641 zproject/settings.py: Update path for JSON_PERSISTENT_QUEUE_FULENAME.
This commit updates the path for JSON_PERSISTENT_QUEUE_FILENAME
to var directory instead of var/log.
2016-07-18 14:13:33 -07:00
Taranjeet Singh
ba3f9de9a9 zerver/lib/cache.py: Move remote_cache_prefix to var directory.
This commit ensures the var directory exists before its needed in both
development and production environments.
2016-07-18 14:13:02 -07:00
Steve Howell
8ac1398b0f Use topic_name() in to_log_dict(). 2016-07-18 14:10:11 -07:00
Steve Howell
e341fe0102 Use topic_name() in do_edit_message_assert_error(). 2016-07-18 14:10:11 -07:00
Steve Howell
2bfa763c0b Use topic_name() in update_message_backend(). 2016-07-18 14:10:11 -07:00
Umair Khan
4519efa266 Document frontend translation syntax.
Fixes: #1090
2016-07-18 13:59:07 -07:00
Umair Khan
b546391f0b Move locale to static/locale 2016-07-18 13:59:07 -07:00
Umair Khan
cdf2664030 makemessages command should not remove plurals. 2016-07-18 13:59:07 -07:00
Steve Howell
1a9a630526 Add zerver.tests.tests.HomeTest.test_home. 2016-07-18 12:22:14 -07:00
Steve Howell
3869e6d008 Fix docs path in docs/README.md. 2016-07-18 12:03:18 -07:00
Steve Howell
bf58c06f97 Link to migration-renumbering.html in schema-migrations.md 2016-07-18 12:02:50 -07:00
Steve Howell
4f4092ecce Add docs/migration-renumbering.md 2016-07-18 12:02:50 -07:00
Steve Howell
5fcbd0a178 Remove muting logic in approximate_unread_count().
The muting logic in approximate_unread_count() was confusing
stream/subject and only using the first of many stream/subject
pairs, so it was rarely excluding rows from the count, and when
it did exclude rows, they were the wrong rows.

This fixes part of #1300, but we may want to keep the issue open.
2016-07-18 11:21:51 -07:00
Steve Howell
dc0a26deab Unify styles for settings panel. 2016-07-18 11:11:32 -07:00
Steve Howell
7a66d74f8f Merge common compose_table styles. 2016-07-18 11:11:32 -07:00
Steve Howell
287752ee5f Consolidate CSS styles with similar background color. 2016-07-18 11:11:32 -07:00
Steve Howell
51e35cbad4 Remove empty CSS blocks. 2016-07-18 11:11:32 -07:00
Steve Howell
0c96d39f2e Fix whitespace in CSS. 2016-07-18 11:11:32 -07:00
Tim Abbott
fb86d91de2 Add missing django-statsd dependency.
This dependency is only needed if USING_STATSD is set, and so had
apparently been missed from our dependency list previously (since few
sites use that setting).
2016-07-18 11:01:13 -07:00
Rishi Gupta
3d1251328e 10-admin.js: Comment out failing casper tests.
There is a hard to reproduce race condition causing these tests to
occasionally fail. We believe it is caused by switching to the home tab and
not properly waiting for all the messages to load; see Issue #1243. The
tests are for the following pathway (not a high priority to test):
1. User starts editing a message.
2. allow_message_editing is turned off for the realm (in this case, by the
   user going to the admin page and turning it off).
3. User finishes editing the message and hits send.
2016-07-18 10:44:35 -07:00
Tim Abbott
77ccc0d87f Patch httpoxy security issue. 2016-07-18 10:24:03 -07:00
Eklavya Sharma
bc901ac6d8 tools/travis/py3-backend: Add tools/test-management. 2016-07-18 09:57:28 -07:00
Eklavya Sharma
e10caf0b65 Gracefully give up when using email-mirror on python 3.
Running `./manage.py email-mirror` used to fail on python 3
because twisted.mail.imap4 is not python 3 compatible.
Display a message informing the user that email-mirror is not
available on python 3 instead of failing with a traceback.

Also add tools/test-management to py3-backend.
2016-07-18 09:57:28 -07:00
Steve Howell
6afa22f473 Add LogDictTest.test_to_log_dict(). 2016-07-17 11:25:02 -07:00
Eklavya Sharma
da36947400 Change unbuffering strategy in runtornado.py.
runtornado unbuffers its output using
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0).
This is not python 3 compatible since we can't specify
buffering on a text stream in python 3.  So use the '-u'
option of python when calling runtornado.py to make output
unbuffered.
2016-07-17 10:31:15 -07:00
Eklavya Sharma
3ee15feeb8 Make twitter tests more readable. 2016-07-17 10:23:25 -07:00
Eklavya Sharma
c389d22b5f Fix twitter mock data. 2016-07-17 10:23:25 -07:00
Eklavya Sharma
fb1d00fc6c Upgrade python-twitter to latest version.
Fixes #1145.
2016-07-17 10:23:25 -07:00
Eklavya Sharma
4130170da8 bugdown: Fix string handling.
Use unicode strings where needed and correctly encode/decode strings.
2016-07-17 10:23:25 -07:00
Eklavya Sharma
abe7faa2f9 bugdown: Annotate some variables. 2016-07-17 10:23:25 -07:00
Steve Howell
60bd20da61 Remove zerver/lib/query.py (dead code). 2016-07-16 14:51:15 -07:00
Rishi Gupta
09754c9861 Remove JsonableErrors from actions.do_update_message.
There were a bunch of authorization and well-formedness checks in
zerver.lib.actions.do_update_message that I moved to
zerver.views.messages.update_message_backend.

Reason: by convention, functions in actions.py complete their actions;
error checking should be done outside the file when possible.

Fixes: #1150.
2016-07-15 13:55:49 -07:00
Rishi Gupta
d529a94e4d Add realm setting to time-limit editing of message content.
This is controlled through the admin tab and a new field in the Realms table.
Notes:
* The admin tab setting takes a value in minutes, whereas the backend stores it
  in seconds.
* This setting is unused when allow_message_editing is false.
* There is some generosity in how the limit is enforced. For instance, if the
  user sees the hovering edit button, we ensure they have at least 5 seconds to
  click it, and if the user gets to the message edit form, we ensure they have
  at least 10 seconds to make the edit, by relaxing the limit.
* This commit also includes a countdown timer in the message edit form.

Resolves #903.
2016-07-15 13:55:49 -07:00
Alex Gaynor
a8a2e13096 Upgrade to the latest cryptography. 2016-07-15 12:25:48 -07:00
Rishi Gupta
d34000b211 prod install docs: Make minor fixes and edits. 2016-07-15 11:19:58 -07:00
Eklavya Sharma
29673411df Make backend tests (hackishly) pass on python3.4.
Replace bot_owner=bot_owner by bot_owner_id=bot_owner.id while
creating a UserProfile object.
2016-07-15 11:13:33 -07:00
Eklavya Sharma
8c0d7311ac zerver/decorator.py: Use BytesIO to read request.
Use BytesIO instead of StringIO to get a file-like object on the
request's body.
2016-07-15 11:13:33 -07:00
Umair Khan
8dabc97d9e Add tests for frontend i18n regexes. 2016-07-15 14:48:09 +05:00
Umair Khan
a07a810a2e Fix regex for capturing frontned strings.
Fixes: #1155
2016-07-15 14:48:05 +05:00
Steve Howell
9d7716f368 Add message.topic_name() helper function.
This little helper will facilitate adding a new Topic
table in the future.
2016-07-14 09:54:56 -07:00
Steve Howell
a5b9e3b893 Add test_patch_bot_avatar().
Fixes: #1002
2016-07-13 22:53:46 -07:00
Steve Howell
21fb7693d2 Add test_helpers.client_patch_multipart(). 2016-07-13 22:53:40 -07:00
Steve Howell
538962f3ca Add test_add_bot_with_username_in_use(). 2016-07-13 22:53:40 -07:00
Steve Howell
468faf5724 Add test_add_bot_with_bad_username(). 2016-07-13 22:53:40 -07:00
Steve Howell
de4cc80aa0 Add test_add_bot_with_too_many_files(). 2016-07-13 22:53:40 -07:00
Steve Howell
e9ddf28b2c Add test_add_bot_with_user_avatar(). 2016-07-13 22:53:40 -07:00
Preston Hansen
87e485c89f Add error message when user attempts to submit empty alert word.
Resolves #1194.
2016-07-13 21:07:20 -07:00
Eklavya Sharma
3894ea0e30 Upgrade mypy version. 2016-07-13 21:05:12 -07:00
Tim Abbott
c7819ed177 Fix broken link to old FoundationDB integration. 2016-07-13 21:00:38 -07:00
Tomasz Kolek
f689fbfa4d Replace old Trello integration with a webhook integration.
Fixes: #709.

[With tweaks on the documentation by tabbott]
2016-07-13 21:00:27 -07:00
Tim Abbott
f8a83fcb11 integrations: Fix top-of-page instructions appearing on every page. 2016-07-13 20:59:38 -07:00
Steve Howell
701bb7a59f Remove test_helpers.DummySession 2016-07-13 19:08:28 -07:00
Steve Howell
616e49e2e8 Remove test_helpers.DummyTornadoRequest 2016-07-13 19:08:28 -07:00
Steve Howell
0060ea7903 Remove test_helpers.DummyStream 2016-07-13 19:08:28 -07:00
Steve Howell
191ac80475 Remove callback logic from test_helpers.DummyHandler. 2016-07-13 19:08:28 -07:00
Taranjeet Singh
9db457e8fa provision.py: Create var/coverage directory to store coverage data.
test-backend: Update coverage directory to var/coverage.

This commit updates the coverage directory to var/coverage as a part
of Issue 1132.
2016-07-13 18:58:00 -07:00
Tim Abbott
6254e29ebf update-deployment: Use the virtualenv in deployment process. 2016-07-13 18:56:44 -07:00
Tim Abbott
599f12f94f update-prod-static: Fix deploy path for language_options.json. 2016-07-13 18:56:37 -07:00
Tim Abbott
baeaf0f870 check-templates: Fix traceback with missing closing tag at end of file.
Previously, this would crash with an unclear traceback in this situation.
2016-07-13 18:55:40 -07:00
Eklavya Sharma
d7ea2b8a67 zerver/tests/test_upload.py: Use byte strings.
Some string literals are incorrectly marked as `str` strings.
Change them to byte strings.
2016-07-13 16:00:46 -07:00
Eklavya Sharma
a7d2dab28f Fix non-deterministic output from Taiga integration.
Taiga's webhook integration would give output events in a random
order which caused test failures on python 3 (seems like python
3 is more prone to non-deterministic failures).  Fix that by
sorting the outputs obtained from events before concatenating them.
2016-07-13 16:00:46 -07:00
Eklavya Sharma
5382aeb385 Render PagerDuty message using ujson.dumps.
Use ujson.dumps to render raw messages sent by the PagerDuty
integration instead of using pprint.pformat.  pprint.pformat
gives different results on python 2 and 3.
2016-07-13 16:00:46 -07:00
Eklavya Sharma
4f633bcd0b zerver/lib/notifications.py: Fix string encoding/decoding.
Correctly encode and decode strings in convert_html_to_markdown.
It wasn't possible to use universal_newlines=True since
Popen.communicate doesn't encode/decode strings correctly on
python 2.
2016-07-13 16:00:46 -07:00
Eklavya Sharma
e6502710b6 Change exception.message to str(exception).
The 'message' attribute in Exception has been deprecated.
It has been removed in python 3.
2016-07-13 16:00:46 -07:00
Eklavya Sharma
993558c680 Get mogrified SQL queries as text.
zerver.lib.test_helpers.queries_captured returns a byte string,
while we want the queries to be text.  So decode the captured
queries.
2016-07-13 16:00:46 -07:00
Rishi Gupta
94b68baf2f 10-admin.js: Comment out failing casper tests.
There is a hard to reproduce race condition causing these tests to
occasionally fail. We believe it is caused by switching to the home tab and
not properly waiting for all the messages to load; see Issue #1243. The
tests are for the following pathway (not a high priority to test):
1. User starts editing a message.
2. allow_message_editing is turned off for the realm (in this case, by the
   user going to the admin page and turning it off).
3. User finishes editing the message and hits send.
2016-07-13 15:59:44 -07:00
Tim Abbott
c0a6672471 Update path to language_options.json in production.
The previous code didn't correctly transport language_options.json to
the production environment.
2016-07-13 12:30:45 -07:00
Umair Khan
9f42fda7f4 Use stripped down version of Talon. 2016-07-13 11:24:18 -07:00
Umair Khan
f45848f62f Install mypy-lang as egg.
It seems that --install-option given in any pip requirement
pollutes the pollutes the global space and causes installation
of mypy-lang to give error.
2016-07-13 11:24:18 -07:00
Umair Khan
395e053ce3 Revert "Revert "Extract reply from email.""
This reverts commit f1ba3ded42.
2016-07-13 11:24:18 -07:00
Umair Khan
f15dfc69fb Make code Python 3 compatible.
Make convert_html_to_markdown function Python 3 compatible.
2016-07-13 11:24:18 -07:00
Tim Abbott
34a251adb1 upload: Fix exception uploaded files with unknown content type.
It turns out our detected content_type can actually be None, which
meant calling force_text on it broke uploading some files.
2016-07-13 10:57:55 -07:00
Umair Khan
0aae0eab49 Switch to PyAPNS for sending push notifications.
Switch to [PyAPNS](https://github.com/djacobs/PyAPNs).

Fixes #538.
2016-07-13 10:55:07 -07:00
Umair Khan
636466ff8b Fix unreliable tests for missed messages.
Generate random token using getrandints.

Resolves the proximal issue discussed in #1212.
2016-07-13 10:51:21 -07:00
Steve Howell
c069c8f1e7 Add test_update_api_key_for_invalid_user(). 2016-07-13 07:51:00 -07:00
Steve Howell
aea79517f5 Test bot_owner logic in /json/users
This fixes a small gap in our coverage for get_members_backend.
2016-07-12 23:01:56 -07:00
Tim Abbott
af8047967f Upgrade ujson to latest version (has indent option). 2016-07-12 22:39:06 -07:00
Steve Howell
108ce82571 Add test_api_with_insufficient_permissions(). 2016-07-12 22:16:00 -07:00
Steve Howell
cee47e7f82 Add test_api_with_nonexistent_user(). 2016-07-12 22:16:00 -07:00
Steve Howell
f43be3bd8f Add test_updating_non_existent_user(). 2016-07-12 22:16:00 -07:00
Tim Abbott
4c8a0340ef Update requirements docs with LetsEncrypt mention. 2016-07-12 22:15:01 -07:00
Tim Abbott
564d41644d deactivated: Fix whitespace around before the . end of sentence. 2016-07-12 20:38:49 -07:00
Taranjeet Singh
5971203864 settings: Store uploaded files under var/ in development environment. 2016-07-12 20:33:31 -07:00
Taranjeet Singh
f18f3f4c1a settings: Move development logs to var/log for development environment.
This updates all the paths in ZULIP_PATHS to store logs in the
zulip/var/log directory.
2016-07-12 20:33:31 -07:00
Taranjeet Singh
03384deb86 provision: Create zulip/var/log directory.
The purpose of this is to move a lot of the log and other generated
files used by the Zulip development environment into a consistent
hierarchy.

We also need to create this in tools/build-release-tarball as well,
since that runs a development environment out of a temporary
directory.
2016-07-12 20:33:30 -07:00
Rishi Gupta
a3aebb63b7 casper tests: Increase default viewport size.
Changed from 1280x768 to 1280x1024 (from 5:3 to 5:4 aspect ratio) to make
failure screenshots more useful.
2016-07-12 19:26:54 -07:00
Tim Abbott
2338421c6d lint: Add documentation lint check for JavaScript spelling. 2016-07-12 19:22:21 -07:00
Sumana Harihareswara
8257701dc9 Fix formatting & capitalization in testing doc. 2016-07-12 19:14:31 -07:00
Sumana Harihareswara
850d8d1181 Fix formatting, capitalization, & grammar in mypy doc. 2016-07-12 19:14:31 -07:00
Tim Abbott
647cead0d1 slow queries: Include full log line in slow query log.
The extra data is useful, and I think this won't make the lines annoying long.
2016-07-12 19:12:49 -07:00
Tim Abbott
305189956b update_message_flags: Log number of messages updated. 2016-07-12 19:12:49 -07:00
Tim Abbott
4972154df9 setup-production: Improve debugging of build-release-tarball errors. 2016-07-12 19:09:28 -07:00
Tim Abbott
0b7788be6b Fix indentation in compose.html. 2016-07-12 18:36:02 -07:00
Tim Abbott
d424813687 Fix indentation in deactivated.html. 2016-07-12 18:34:17 -07:00
Tim Abbott
491e98e457 docs: Document the fact that installer is idempotent. 2016-07-12 18:26:44 -07:00
Jeff Fowler
6102110a1b timerender: Include year in message interstitials.
For longer running servers, searching the backlog can become ambiguous
since the date stamps that demarcate the messages only include the month
and day. This commit changes the behavior to include the year for
messages which are more than a year old.
2016-07-12 18:26:42 -07:00
Eklavya Sharma
e28b038f1d Use assert_in_response by fixing line-wrapping in templates. 2016-07-12 17:52:47 -07:00
Rishi Gupta
235162e000 admin.js: Rename overloaded variable.
We were using data for both the request and response data in
$(".administration").on("submit", "form.admin-realm-form".
Left the request data as data to be consistent with the rest of the
file, renamed the response data to response_data.
2016-07-12 17:41:48 -07:00
Steve Howell
3923f94a2b Remove unused code path in avatar() endpoint. 2016-07-12 17:37:02 -07:00
Steve Howell
3995a5d8eb Add test coverage for /avatar/<email> 2016-07-12 17:37:02 -07:00
Tomasz Kolek
d0066c37ff Add bitbucket2 integration.
Bitbucket changed the format of their API.  The old format is still
useful for BitBucket enterprise, but for the main cloud verison of
Bitbucket, we need a new BitBucket integration supporting the new API.
2016-07-12 17:34:34 -07:00
Tim Abbott
71b3c116bb local_settings_template: Improve AUTHENTICATION_BACKENDS comments. 2016-07-12 16:19:13 -07:00
Tim Abbott
6301fd22dc docs: Turn SSO auth documentation into general auth page.
Also remove this page from the breadcrumb.
2016-07-12 16:19:13 -07:00
Sumana Harihareswara
6ed73b430a Change doc links to point to RTD for prod docs. 2016-07-12 15:46:10 -07:00
Sumana Harihareswara
260baff4db Move prod postgres details to separate page. 2016-07-12 15:46:10 -07:00
Sumana Harihareswara
3a13cf1865 Move prod remote user SSO auth guide to new page. 2016-07-12 15:46:10 -07:00
Sumana Harihareswara
bfa81a80ad Move prod maintenance guide to new page. 2016-07-12 15:46:10 -07:00
Sumana Harihareswara
76fea4f4d4 Move prod customization guide to new page. 2016-07-12 15:46:10 -07:00
Sumana Harihareswara
07afc9d34b Move production health check doc to separate page. 2016-07-12 15:46:10 -07:00
Sumana Harihareswara
ec005726c4 Move prod auth and first login doc to new page. 2016-07-12 15:46:10 -07:00
Sumana Harihareswara
7d092d2cc4 Move production install instructions to new page. 2016-07-12 15:46:09 -07:00
Tim Abbott
a10833f489 Simplify title for production requrements page. 2016-07-12 15:44:48 -07:00
Sumana Harihareswara
3f90f9e29e Move production installation requirements to separate page.
To begin the process of consolidating Zulip documentation on Read
the Docs, the requirements are now their own topic page, and
index.rst links to it.

Fixes: #669.
2016-07-12 15:43:06 -07:00
Tim Abbott
883e991adf install: Improve support for non-default puppet rules.
Previously, the install script would fail if you passed various
non-default puppet rules, since the code to configure and restart
services that runs later on in the install script largely ran
unconditionally, regardless of whether the relevant service was
actually installed on the target system.

This should make the main install script reusable for installing
e.g. a dedicated Postgres server for use with Zulip.
2016-07-12 14:12:09 -07:00
Tim Abbott
80bf7e32a4 Add option to not create a virtualenv. 2016-07-12 14:12:05 -07:00
Steve Howell
f57a17abdf Lint-check more Django files for indentation.
(This starts to address github ticket #1236.)
2016-07-12 14:08:17 -07:00
Steve Howell
52af46a74b Fix whitespace in keyboard_shortcuts.html 2016-07-12 14:08:17 -07:00
Eklavya Sharma
c98c3d5f8d Re-enable some backend tests on python 3. 2016-07-12 14:06:29 -07:00
Eklavya Sharma
d740a87d04 zerver/tests: Use unicode strings.
* Use unicode strings for strings containing non-ASCII characters.
* Decode response content when text output is expected.
2016-07-12 14:06:29 -07:00
Eklavya Sharma
161c27d0e9 Add methods to AuthedTestCase to test response content.
Add methods assert_equals_response and assert_in_response to
AuthedTestCase.  These methods make it convenient to check if
a string equals the contents of an HttpResponse's body or if a
string is a substring of the contents of an HttpResponse's body.
2016-07-12 14:06:29 -07:00
Eklavya Sharma
2080ff6c2a Decode response.content everywhere except in tests.
response.content is binary data, but code usually assumes it to
be text.  Fix this by decoding response.content where required.
Don't do this in tests yet.
2016-07-12 14:06:29 -07:00
Steve Howell
97f28f3792 Revert "Close HTML singleton tags in Casper files."
This reverts commit 520b255d95,
and also blacklists Casper files from our linter.
2016-07-12 13:35:50 -07:00
Steve Howell
45d1eefc52 Add test_create_user_backend().
This tests provides full line coverage on the
create_user_backend view.
2016-07-12 12:29:24 -07:00
Sumana Harihareswara
2ece2192d9 Fix misspelling in HTML CSS documentation. 2016-07-12 14:15:23 -04:00
Tim Abbott
5d990c28d0 Fix running run-mypy from any working directory. 2016-07-12 10:39:33 -07:00
Tim Abbott
497142d7b1 Fix running test-backend from any working directory. 2016-07-12 10:39:33 -07:00
Tim Abbott
b39e113fef settings: Fix path to dev-secrets.conf with arbitrary working directory. 2016-07-12 10:39:33 -07:00
Tim Abbott
ace8ae8301 puppet: Fix supervisor restart rule catching itself in pgrep. 2016-07-12 10:39:33 -07:00
Eklavya Sharma
05c9f09850 Annotate zulip_tools.py. 2016-07-12 10:10:22 -07:00
Eklavya Sharma
934a0f7c6c Add tools/test-backend to py3-backend test suite. 2016-07-12 09:27:55 -07:00
Eklavya Sharma
73a3c9fa47 On python 3, skip expected failures in backend tests. 2016-07-12 09:27:55 -07:00
Eklavya Sharma
4868cd9969 zerver/lib/test_helpers.py: Add skip_py3 decorator. 2016-07-12 09:27:55 -07:00
Eklavya Sharma
0a9c600c8b Show skipped tests in test runner. 2016-07-12 09:27:55 -07:00
Eklavya Sharma
5de91c4115 Use subprocess_text_output in tools/provision.py. 2016-07-12 20:25:20 +05:30
Tim Abbott
4f41aa0c0d Update ipython to version 5.0.0.
iPython 5.0.0 has awesome syntax highlighting.
2016-07-11 21:32:11 -07:00
Eklavya Sharma
158d67e702 Run tools/test-migrations in Travis. 2016-07-11 21:30:32 -07:00
Eklavya Sharma
57ce3f4af1 tools/travis/lint-all: Factor out error message. 2016-07-11 21:30:32 -07:00
Eklavya Sharma
958335bdb3 Change all default values in models to unicode. 2016-07-11 21:30:32 -07:00
Eklavya Sharma
51239f225b Mention build name in docs.
Mention in docs that tools/run-mypy and tools/check-py3k are run
in the 'static-analysis' build.
2016-07-11 21:28:01 -07:00
Eklavya Sharma
08a4555e0f Merge mypy and py3k test suites in Travis. 2016-07-11 21:28:01 -07:00
Eklavya Sharma
0de3b17f19 tools/test-backend: Add option to skip generate-fixtures.
Not calling generate-fixtures can reduce running time, which is
especially helpful when running a single test.
2016-07-12 09:34:37 +05:30
Tomasz Kolek
d7c7279523 Add is_status_message method to Message model. 2016-07-11 12:09:06 -07:00
Eklavya Sharma
d139f13e57 Remove output.txt.
It was accidentally added in 1f3ce7cf38.
2016-07-11 22:55:05 +05:30
Tim Abbott
e21bc11cfd Extract attachment_url_to_path_id. 2016-07-10 18:07:37 -07:00
Tim Abbott
48ae178d0b Refactor attachment_url_re to be a common value in upload.py. 2016-07-10 18:04:58 -07:00
rahuldeve
c5756e4fa4 Update attachment tracking on message update. 2016-07-10 18:01:59 -07:00
Tim Abbott
3647973069 update_message_backend: Reorganize validation checks.
The new organization more clearly does the permission check first.
2016-07-10 18:01:59 -07:00
Tim Abbott
05632b68e1 edit: Add validation for setting empty content. 2016-07-10 18:01:59 -07:00
Tim Abbott
0d418d5695 Add some message editing tests for invalid input. 2016-07-10 18:01:59 -07:00
Tim Abbott
211a166abc message edit: Move new topic non-empty check to view. 2016-07-10 18:01:59 -07:00
Eklavya Sharma
0900ca5353 Replace assertItemsEqual by assertEqual.
This is needed because assertItemsEqual doesn't exist in python 3.
2016-07-10 17:33:11 -07:00
Tim Abbott
f513a68ac9 lint-all: Check for missing whitespace before { in CSS.
Also fix the existing violations of this rule.
2016-07-10 17:29:36 -07:00
Rishi Gupta
43c2f35776 Add realm setting to disable message editing.
This is controlled through the admin tab and a new field in the Realms
table.  This mirrors the behavior of the old hardcoded setting
feature_flags.disable_message_editing.  Partially resolves #903.
2016-07-10 11:57:24 -07:00
Rishi Gupta
07e7230ae1 models.py: Add post_save to Message.
Flushes message from cache after a message.save(). Needed for tests
where we directly manipulate Message objects in the database.
2016-07-10 11:42:18 -07:00
Eklavya Sharma
f1ba3ded42 Revert "Extract reply from email."
This reverts commit f1f48f305e.

The use of sklearn unfortunately caused a substantial slowdown to the
Zulip provisioning process, which didn't seem worth it for a
relatively minor feature.
2016-07-10 11:30:30 -07:00
Eklavya Sharma
9161ddaee0 zerver/middleware.py: Handle binary data in errors.
In write_log_line, error_content can be binary_type and
error_content_iter can be a Sequence of binary_type.  Handle
this this in a python 3 compatible way.  Also change annotations
to reflect this fact.
2016-07-10 11:30:13 -07:00
Tim Abbott
88368397aa lint-all: Add Python check for space after if. 2016-07-10 10:58:16 -07:00
Tim Abbott
dfc9e75342 nginx: Enable shared SSL session cache. 2016-07-10 08:30:10 -07:00
Alex Gaynor
ee47da8790 nginx: Disable RC4 and prefer server cipher order. 2016-07-10 08:30:05 -07:00
Steve Howell
c671881713 decorators: Extract is_local_addr(). 2016-07-09 17:58:48 -07:00
Steve Howell
8e528569a7 Clean up rate_limit() for deployments that opt out.
If settings.RATE_LIMITING is False, short circuit rate
limiting earlier in rate_limit().  This change particularly
avoids inspect request.user and possibly spamming the error
log for sites that don't care about rate limiting.
2016-07-09 17:58:20 -07:00
Eklavya Sharma
801bcdd956 zerver/tests/tests.py: Fix non-deterministic failure.
Replace occurences of list(d.keys()) by sorted(d.keys()).
2016-07-09 17:54:54 -07:00
Eklavya Sharma
1f3ce7cf38 zerver/worker/queue_processors.py: Open file in binary.
Open a file in binary mode instead of text mode.
2016-07-09 17:54:54 -07:00
Eklavya Sharma
2f2e543a0e zerver/tests/tests.py: Replace assertItemsEqual.
Replace assertItemsEqual(a, b) by assertEqual(sorted(a), sorted(b))
because assertItemsEqual has been removed in python 3.
2016-07-09 17:54:54 -07:00
Steve Howell
a8f11501eb Add htmlcov directory to .gitignore. 2016-07-09 17:37:30 -07:00
Steve Howell
538bc61c54 Check more html files in check-templates.
Instead of just checking .html files in the templates directory,
we now also check them everywhere, including .html files used
for Casper tests and some static files.
2016-07-09 17:34:49 -07:00
Steve Howell
494ea4a4f4 Fix end tags in 404/5xx pages. 2016-07-09 17:34:49 -07:00
Steve Howell
520b255d95 Close HTML singleton tags in Casper files. 2016-07-09 17:34:49 -07:00
Tim Abbott
4d28111178 Move alert_words CSS to settings.css. 2016-07-09 08:01:54 -07:00
Tim Abbott
a43021005a Remove unused notification-docs CSS. 2016-07-09 08:01:19 -07:00
aakash-cr7
63475a55f3 Add bots and avatars css to settings.css. 2016-07-09 08:01:12 -07:00
aakash-cr7
e37e384dd4 Add notification css to settings.css. 2016-07-09 07:53:51 -07:00
Steve Howell
89105e41d7 Added TestInternalNotifyView. 2016-07-09 07:47:12 -07:00
Steve Howell
ce14a3551d Added test_get_client_name(). 2016-07-09 07:37:13 -07:00
Steve Howell
69f18c26fc Improve test_api_key_only_webhook_view().
This test now covers all lines of api_key_only_webhook_view(),
including the error logic and rate limiting logic.
2016-07-09 07:37:13 -07:00
Steve Howell
3d095beb63 Extracted client_is_exempt_from_rate_limiting(). 2016-07-09 07:37:13 -07:00
Steve Howell
49543b9ec4 Added RateLimitTestCase tests. 2016-07-09 07:37:13 -07:00
Steve Howell
c680c6a981 Removed unused to_non_negative_float() function. 2016-07-09 07:37:13 -07:00
Umair Khan
b7ec66fc96 Remove templates, styles and js through storage. 2016-07-09 07:33:35 -07:00
Umair Khan
397da44744 Update documentaton to reflect Django-Pipeline==1.6.8. 2016-07-09 07:09:55 -07:00
Umair Khan
043ae8ad65 Upgrade to Django-Pipeline==1.6.8. 2016-07-09 07:09:55 -07:00
Umair Khan
2d243c0703 get_all_templates should not return __init__.py. 2016-07-09 07:09:55 -07:00
Tim Abbott
1e2d38e790 Move stringify_message_dict into to_dict_uncached. 2016-07-08 17:58:56 -07:00
Tim Abbott
72e948d19a Remove now-unused message_cache_key message cache.
Originally this cache was used to transmit data from Django to Tornado
(and also for general message caching purposes), but now nothing
actually reads from this cache, so we can eliminate it.
2016-07-08 17:58:56 -07:00
Tim Abbott
8d5ec14b31 cache_helpers: Fill to_dict cache instead of old message cache.
Apparently, the message cache we were filling was completely useless
and unused, and furthermore, the cache we were filling as part of
restarting the server was also totally useless, since it didn't have
the messages users would be requesting.
2016-07-08 17:58:56 -07:00
Steve Howell
704c57a141 Fix end tag issues in api.html
(This fixes a minor style issue with the API keys/bots section,
but the change is mostly to make the HTML have balanced tags.)
2016-07-08 16:30:49 -07:00
Steve Howell
e35b84d438 Have lint-all pass along -m to check-templates. 2016-07-08 16:30:49 -07:00
Steve Howell
6154c73125 Support -m flag to check only modified templates. 2016-07-08 16:30:49 -07:00
Steve Howell
d1964a243e Use lister module to find files for linting. 2016-07-08 16:30:49 -07:00
Steve Howell
1006b95898 Extract check_handlebar_templates. 2016-07-08 16:30:49 -07:00
Steve Howell
4e326ed138 Extract check_django_templates. 2016-07-08 16:30:49 -07:00
Steve Howell
3e9ceaeaf0 Move templates check to ok() function. 2016-07-08 16:30:49 -07:00
Tim Abbott
ea089518ee Add Zulip customizations to Postgres 9.5 config file.
This includes reasonable tuning of memory usage parameters based on
the values that pgtune would use, roughly.
2016-07-08 16:16:12 -07:00
Tim Abbott
e818dff0b0 postgres: Remove comment matching Puppet ERB syntax. 2016-07-08 16:16:12 -07:00
Tim Abbott
6ba659aeec Add a stock Ubuntu Xenial Postgres 9.5 configuration file. 2016-07-08 16:16:12 -07:00
Tim Abbott
0f5e62e994 puppet: Don't use pgtune on Linux versions where it doesn't exist. 2016-07-08 16:16:12 -07:00
Tim Abbott
903f728587 Scope postgresql.conf templates by postgres version. 2016-07-08 16:16:12 -07:00
Tim Abbott
ffe79e0d50 Fix EPMD restart being attempted on every puppet apply. 2016-07-08 16:16:11 -07:00
Tim Abbott
b13eeae24c Remove finbot from Zulip repository.
It's been split into its own repository,
https://github.com/zulip/finbot.
2016-07-08 16:15:55 -07:00
Tim Abbott
12028339a3 puppet: Use --detailed-exitcodes to return nonzero exit code on failure.
Apparently, puppet has messed up exit codes and doesn't by default
return the usual 0=success, nonzero=failure codes.  By default, it
seems to always return 0; and with `--detailed-exitcodes`, it returns
the complicated thing documented in the comments.

We fix this by checking the exit code and translating it to what we
actually care about, namely whether errors occurred.

See https://tickets.puppetlabs.com/browse/PUP-2754 for details.

Fixes #1094.
2016-07-08 12:11:44 -07:00
Taranjeet
a8a4caf2c0 zerver: Fix lines with length greater than 120. 2016-07-08 11:41:43 -07:00
Tim Abbott
be93b6ea28 [third] Upgrade jquery to version 1.8.3.
Also use the modern NPM name of 'jquery' (all lower case), which is
required as part of this migration.

Fixes #1141.
2016-07-08 11:09:54 -07:00
Tim Abbott
cb18ef07a7 Rename hashchange.zulip event to avoid jquery 1.8 interaction. 2016-07-08 11:09:09 -07:00
Tim Abbott
d5be9e8b2d Upgrade django-auth-ldap to 1.2.8.
The new version is needed for Python 3 support.

Fixes #1175.
2016-07-08 11:08:08 -07:00
Umair Khan
f1f48f305e Extract reply from email. 2016-07-08 10:58:25 -07:00
Umair Khan
75bd3541ea Add tests for new email policy.
- Update test_extra_context_in_missed_stream_messages
- Add test_extra_context_in_personal_missed_stream_messages
- Add test_extra_context_in_huddle_missed_stream_messages
2016-07-08 10:58:25 -07:00
Umair Khan
8538ba8ea8 Remove do_send_missedmessage_events function. 2016-07-08 10:58:25 -07:00
Umair Khan
06355105f5 Missed message emails should come from user email.
Fixes #448
FIxes #612
2016-07-08 10:58:25 -07:00
Eklavya Sharma
aa68fd1679 Run tools/lint-all on Travis in python 3. 2016-07-08 10:43:48 -07:00
Eklavya Sharma
618410fa1a .travis.yml: Set BOTO_CONFIG to bogus value.
See https://github.com/travis-ci/travis-ci/issues/5246.
2016-07-08 11:38:57 +05:30
Eklavya Sharma
52129c03c8 requirements/py3_common.txt: Add missing packages.
These packages are imported but not used during setup.  So it's
okay to include them even if zulip doesn't support them yet.
2016-07-08 11:38:57 +05:30
Tim Abbott
367f6e5bf7 Vagrantfile: Add option for setting the port used on the host.
This makes it easier to (for example) run a Zulip development
environment on a host machine and sometimes run a Vagrant guest
inside.
2016-07-07 15:17:44 -07:00
Tim Abbott
3dee8a3dcb README.dev.md: Use wildcard when copying tsearch data. 2016-07-07 15:12:37 -07:00
Tim Abbott
8b92775daa README.dev.md: Fix path to emoji_dump scripts. 2016-07-07 15:11:26 -07:00
Tomasz Kolek
581f076d57 Automatically gather logs from provisioning.
Fixes: #1156.
2016-07-07 14:58:16 -07:00
Tomasz Kolek
c15695e514 Add support for running test-js-with-node on particular files.
Fixed: #1127.
2016-07-07 14:32:07 -07:00
Eklavya Sharma
3e9349df4f zerver/decorator.py: Use force_bytes instead of encode.
The value type of request.META is str, not text type.
So use force_bytes on the data instead of encode('utf-8').
2016-07-08 01:24:30 +05:30
Eklavya Sharma
4cf7641ab1 zerver/tests/test_i18n.py: Ignore due to incomplete stubs.
In python 3, http.cookies has incomplete stubs.
2016-07-07 12:42:51 -07:00
Eklavya Sharma
6c3f1bb967 beanstalk.py: Encode and decode strings correctly. 2016-07-07 12:42:51 -07:00
Eklavya Sharma
26b8e7357a zerver/views/messages.py: Operate on bytes in highlight_string. 2016-07-07 12:42:51 -07:00
Umair Khan
53662ccd11 Cache email address hint content.
This substantially improves the performance of loading the
/#subscriptions page with 1000+ streams in the realm.
2016-07-07 11:39:52 -07:00
Eklavya Sharma
83640ed0cd runtornado.py: Ignore due to incorrect stubs. 2016-07-07 10:09:35 -07:00
Eklavya Sharma
6fd8906358 rename_stream.py: Fix broken code.
* get_realm returns None if no matching realm is present, but
  create_stream.py assumed it raises Realm.DoesNotExist.
* encoded/decode strings properly.
2016-07-07 10:08:29 -07:00
Eklavya Sharma
c679c180f5 enqueue_file.py: Add type hint for mypy. 2016-07-07 10:07:51 -07:00
Eklavya Sharma
896c18a57b email-mirror.py: Make it pass on mypy in python 3.
* Replace filter by list comprehension.

* Add '# type: ignore' to statements which use attributes from
  modeule `posix`, since stubs for posix are missing on python 3.
2016-07-07 10:07:28 -07:00
Eklavya Sharma
17cb6e00bd create_stream.py: Fix broken code.
* get_realm returns None if no matching realm is present, but
  create_stream.py assumed it raises Realm.DoesNotExist.
* encoded/decode strings properly.
2016-07-07 10:06:39 -07:00
Eklavya Sharma
7956fcbf0d zerver/lib/str_utils.py: Allow specifying encoding. 2016-07-07 10:06:22 -07:00
Eklavya Sharma
63d55bdd86 zerver/views/__init__.py: decode b64encoded ccache.
Convert b64encoded ccache to `str` before passing to
subprocess.check_call.
2016-07-07 10:02:08 -07:00
Eklavya Sharma
628e45defc zerver/lib/actions.py: Use text_type in truncate_ functions.
The functions truncate_content, truncate_body and truncate_topic
are only meant to be used on text strings.  So change its
parameter types from AnyStr to text_type.
2016-07-07 10:02:08 -07:00
Eklavya Sharma
976858f536 tornado_ioloop_logging.py: Ignore because of missing stub.
There is no stub for select.epoll on python 3.  So ignore the
statement which uses it.
2016-07-07 10:02:08 -07:00
Eklavya Sharma
9d2a539aaa zerver/lib/notifications.py: Add hints for mypy.
Add type hints for mypy using isinstance in assert and if.
2016-07-07 10:02:08 -07:00
Tim Abbott
98db1d996f email_mirror: Fix some indentation issues. 2016-07-07 10:02:08 -07:00
Eklavya Sharma
5e81a4d93f zerver/lib/email_mirror.py: Improve annotation in python 3.
Add asserts and if statements to help mypy.
2016-07-07 10:01:30 -07:00
Eklavya Sharma
4f221c21a0 zerver/lib/email_mirror.py: Improve subject extraction.
Improve subject extraction in process_message.
2016-07-07 09:55:23 -07:00
Eklavya Sharma
06a7a6caee zerver/lib/debug.py: Remove from mypy's exclude_py3.
traceback.print_stack doesn't have a stub yet.  So ignore the
statement which uses it.
2016-07-07 09:52:24 -07:00
Eklavya Sharma
6bb266d262 bugdown's __init__.py: Add python 3 compatibility.
* Use Response.text instead of Response.content.
* Make unescaping work on python 3.
2016-07-07 09:52:24 -07:00
Eklavya Sharma
05046d9288 bugdown's codehilite.py: Fix annotations in python 3 mode.
Many stubs in xml.etree.ElementTree use Union[str, bytes] as
return type.  Mypy wants us to correctly handle each case.  This
is correct, but not useful for us since we know that we'll always
get str.  So force the return value to text_type, to supress mypy
errors.
2016-07-07 09:52:24 -07:00
Eklavya Sharma
610f19c791 zerver/lib/camo.py: Type ignore statement with hex encode. 2016-07-07 09:52:24 -07:00
Eklavya Sharma
6a63870136 zerver/decorator.py: Correctly encode/decode strings. 2016-07-07 09:52:24 -07:00
Eklavya Sharma
4e698ab1f6 Remove zerver/lib/parallel.py from mypy's exclude_py3. 2016-07-07 09:52:24 -07:00
Eklavya Sharma
5e8dba4c75 Add mypy in python 3 mode to travis.
This helps catch Python 3 compatibility issues.
2016-07-07 09:44:00 -07:00
Kartik Maji
e5a3339725 Add search box for filtering users to add when creating new streams.
Fixes: #779.
2016-07-06 16:01:33 -07:00
Tim Abbott
8fb4e161dd Disable browser autocomplete adding stream members.
We have our own autocomplete, and the two forms of autocomplete
conflict with each other awkwardly.
2016-07-06 16:01:16 -07:00
Rishi Gupta
7ef434ec62 08-edit: Change how we wait for messages to be sent in casper tests.
We originally waited for .message_edit_notice to appear, now we wait for
textarea.message_edit_content to disappear.

This is better because the previous code didn't correctly handle
editing the same message twice (the "EDITED" tag would still be there
from the first edit, so it wouldn't wait at all the second time!).
2016-07-06 15:27:13 -07:00
Taranjeet
a137bf15ed Wrap some lines with length greater than 120.
With some tweaks by tabbott.
2016-07-06 14:35:16 -07:00
Eklavya Sharma
e26afeeecf Add .coverage to .gititnore. 2016-07-06 14:25:09 -07:00
Eklavya Sharma
4f181acb83 Add python 3 mode to provision.py.
When provision.py is run using python 2, retain original behavior
of creating a python 2 venv using requirements/py2_dev.txt and
creating a python 3 venv using requirements/mypy.txt.
When provision.py is run using python 3, install a single python 3
venv with requirements/py3_dev.txt.
2016-07-06 13:50:55 -07:00
Eklavya Sharma
cdc067e751 tools/provision.py: Use universal_newlines=True. 2016-07-06 13:50:55 -07:00
Eklavya Sharma
7e020e3dae scripts/lib/setup_venv.py: Use universal_newlines=True.
In python 3, subprocess uses bytes for input and output if
universal_newlines=False (the default).  It uses str for input and
output if universal_newlines=True.
Since we're dealing with strings here, add universal_newlines=True
to subprocess.check_output calls.
2016-07-06 13:50:55 -07:00
Eklavya Sharma
ce6ddd574a zerver/lib/test_helpers.py: Replace os.path.walk by os.walk.
os.path.walk has been removed in python 3.
2016-07-06 11:49:55 -07:00
Eklavya Sharma
6505cbf2bf zerver/lib/timeout.py: Replace isAlive by is_alive.
In threading.Thread, isAlive has been removed in python 3.
We should use is_alive instead.
2016-07-06 11:49:48 -07:00
Eklavya Sharma
d8de54abe5 zerver/migrations: Squash an AlterField from 0002 into 0001.
Squash the AlterField on UserProfile.groups in 0002 into the
AddField in 0001.  This is done to avoid a probable bug in Django,
where running migrations in python 3 sometimes led to a KeyError.
2016-07-06 11:40:12 -07:00
Umair Khan
05d36626e8 Revert "Revert "Add casper tests for default language setting.""
This reverts commit ce1676e219.

Now that we've fixed the English locale being missing, these tests
should work again.
2016-07-06 11:35:17 -07:00
Umair Khan
47fb293f8a i18n: Add English locale to language list if missing.
The English locale data is only present if the user has run `manage.py
makemigrations` on the system.
2016-07-06 11:34:28 -07:00
Tim Abbott
84dac8950f Add language_options.json to .gitignore. 2016-07-06 10:30:45 -07:00
Tim Abbott
ce1676e219 Revert "Add casper tests for default language setting."
This reverts commit e4b32905bf.

This new test was failing in Travis CI.
2016-07-04 12:45:18 -07:00
Eklavya Sharma
2d4dcd1698 Replace bytes by strings in zerver migrations 2, 13, 18. 2016-07-04 12:08:37 -07:00
Eklavya Sharma
6553e16b89 Replace bytes by strings in zerver/migrations/0001. 2016-07-04 12:08:37 -07:00
Eklavya Sharma
90f306421f Replace bytes by strings in zilencer/migrations. 2016-07-04 12:08:37 -07:00
Umair Khan
e4b32905bf Add casper tests for default language setting.
Fixes #1076.
2016-07-04 11:56:31 -07:00
Umair Khan
054d14bb96 Add documentation to announce default language setting. 2016-07-04 11:56:24 -07:00
Umair Khan
4c178bc00f Improve the alert messages for display settings. 2016-07-04 11:56:02 -07:00
Umair Khan
035fceb814 Add dynamically loaded language dropdown. 2016-07-04 11:56:02 -07:00
Conrad Dean
bbf7a9c801 Annotate zerver/lib/event_queue.py. 2016-07-04 03:01:33 +05:30
Conrad Dean
9812e676f0 Annotate zerver/lib/queue.py. 2016-07-04 03:01:32 +05:30
Eklavya Sharma
192663edcf zerver/lib/narrow.py: Fix annotations. 2016-07-04 03:01:32 +05:30
Eklavya Sharma
95b6e668a7 zerver/lib/actions.py: Fix annotations.
Change queue_ids from text_type to str.
2016-07-04 03:01:32 +05:30
Eklavya Sharma
9772a512cb Use abstract types in annotations. 2016-07-04 03:01:32 +05:30
Eklavya Sharma
fdf4d67cde zerver/tornado.py: Convert queue_id to str. 2016-07-04 02:58:57 +05:30
Eklavya Sharma
de19b24f74 zerver/lib/handlers.py: Fix an annotation. 2016-07-04 02:20:25 +05:30
Eklavya Sharma
4761cc27dd zerver/middleware.py: Fix annotations.
* Use abstract types where relevant.
* Fix string types.
* Fix annotation of args and kwargs.
2016-07-04 02:14:42 +05:30
Eklavya Sharma
f1b72c5f41 Upgrade wheel before installing venv requirements.
This is required because an older wheel version causes problems
when building wheels on python 3.
2016-07-02 11:53:26 -07:00
Eklavya Sharma
7daa40bf4f Add python3-specific requirements files. 2016-07-02 11:53:26 -07:00
Eklavya Sharma
fea6c56978 Move packages from prod.txt to py2_prod.txt. 2016-07-02 11:53:26 -07:00
Eklavya Sharma
bf345a0b30 Move packages from common.txt to py2_common.txt. 2016-07-02 11:53:26 -07:00
Eklavya Sharma
0b714ea6c6 Use python2-specific requirements files. 2016-07-02 11:53:26 -07:00
Eklavya Sharma
146dc310a7 Add python2-specific requirements files.
For now just make these files point to their non-specific
counterparts.
2016-07-02 11:53:26 -07:00
Eklavya Sharma
6d8ba90db9 zerver/models.py: Modify imports for mypy in py3 mode.
Change 'from zerver.lib import bugdown' to
'import zerver.lib.bugdown as bugdown' to make zerver/models.py
pass mypy check in python 3 mode.
2016-07-02 10:38:48 -07:00
Eklavya Sharma
dcd568960b Add files to mypy's python 3 exclude list. 2016-07-02 10:38:48 -07:00
Eklavya Sharma
5879e18bad Add a 'type: ignore' in zulip_tools.py.
Subprocess.CalledProcessError's __init__ takes 4 arguments out
of which 2 are optional.  It is being passed 2 arguments in
zulip_tools.py. However, python 3 stubs are incorrect and only
1 argument has been marked as default.
See https://github.com/python/typeshed/pull/329.
Add '# type: ignore' to that line so that mypy check passes in
python 3 mode.
2016-07-02 10:38:48 -07:00
Eklavya Sharma
b44ae38bff tools/run-mypy: Add Python 3 mode. 2016-07-02 10:38:48 -07:00
Eklavya Sharma
b902c1ae45 bugdown: Replace raw unicode literal with non-raw.
Raw unicode literals are disallowed in python 3.
2016-07-02 10:38:48 -07:00
Eklavya Sharma
3177cee740 Upgrade pyflakes. 2016-07-02 08:01:53 +05:30
Eklavya Sharma
766e055229 Upgrade six. 2016-07-02 08:01:48 +05:30
Krit Karan
406cce7027 README: Repoint translating documentation at RTD. 2016-07-01 10:11:48 -07:00
Krit Karan
6c38023cbb REAMDE: Fix (transifex) to [transifex].
This caused the Transifex link to be broken.
2016-07-01 10:11:33 -07:00
Eklavya Sharma
61d052ae41 Upgrade mypy version. 2016-07-01 20:16:36 +05:30
Tim Abbott
3b16daad18 provision: Add a shebang line. 2016-06-30 22:34:58 -07:00
Kartik Maji
f8bb7503e6 Add ability to pin streams to top of the streams sidebar list.
Based on work by Lauren Long, with some tweaks by tabbott.
2016-06-30 22:26:09 -07:00
Kartik Maji
a32167d921 test_events: Sort subscribers list.
The subscribers list is appended to in `peer_add` events with not
regard for preserving the ordering, and ordering isn't really
important here, so it seems best to just sort it in these checks.
2016-06-30 16:52:51 -07:00
Vishnu Ks
1cbd39b768 Unique link generator for realm creation. 2016-06-30 15:52:41 -07:00
Alex Wilson
8c62cff1b7 bugdown: Clean up paths to emojis. 2016-06-30 15:48:02 -07:00
Alex Wilson
2f47945981 Separate unicode emojis from named emojis. 2016-06-30 15:48:02 -07:00
Alex Wilson
b040839c76 Add unicode emoji to frontend markdown parser.
Fixes 2nd half of #1011.
2016-06-30 15:48:02 -07:00
Alex Wilson
5ec29101eb Add unicode emoji support to bugdown.
Fixes half of #1011.
2016-06-30 15:48:02 -07:00
Alex Wilson
434c8d4b08 Add codepointat.js, a polyfill for String.prototype.codePointAt(). 2016-06-30 15:48:02 -07:00
Tim Abbott
ee8ce48d63 settings: Make STATIC_ROOT always an absolute path. 2016-06-30 15:48:02 -07:00
Tim Abbott
cccf748244 index.html: Fix webpack URL.
This was accidentally changed in
a78c1b9750.
2016-06-30 15:48:02 -07:00
Tim Abbott
0397855fdd test_hooks: Use send_json_payload for private message tests. 2016-06-30 15:12:03 -07:00
Tim Abbott
a78c1b9750 Fix casper tests hanging while development server is running.
This works around a nasty problem with Webpack that you can't run two
copies of the Webpack development server on the same project at the
same time (even if on different ports).  The second copy doesn't fail,
it just hangs waiting for some lock, which is confusing; but even if
that were to be solved, we don't actually need the webpack development
server running to run the Casper tests; we just need bundle.js built.
So the easy solution is to just run webpack manually and be sure to
include bundle.js in the JS_SPECS entry.

As a follow-up to this change, we should clean up how test_settings.py
is implemented to not require duplicating code from settings.py.

Fixes #878.
2016-06-30 14:18:50 -07:00
Rishi Gupta
17b6d136d5 Add Semaphore webhook integration. 2016-06-29 16:36:19 -07:00
Vishnu Ks
e4b72c3a65 Move respond_to_message to compose.js. 2016-06-29 13:04:02 -07:00
Eklavya Sharma
def8cd8e78 Annotate zerver/lib/timeout.py. 2016-06-29 10:41:01 -07:00
Eklavya Sharma
88354ad1fc zilencer's populate_db.py: Remove unnecessary cast to text_type. 2016-06-29 10:36:50 -07:00
Eklavya Sharma
21f789eb05 zerver/lib/session_user.py: Replace Dict by Mapping. 2016-06-29 10:36:50 -07:00
Eklavya Sharma
b76dc9bf4e zerver/lib/upload.py: Fix string types. 2016-06-29 20:43:28 +05:30
Tim Abbott
f094123fd3 install: Add support for installing Xenial systems.
This isn't fully supported yet, but merging this makes it more
convenient to test Zulip on Ubuntu Xenial.
2016-06-28 23:05:38 -07:00
Tim Abbott
4ea75528ea docs: Expand instructions for Zulip localhost SSO.
In particular, this makes it clear how to set the basic HTTP auth
version quickly.
2016-06-28 23:05:38 -07:00
Tim Abbott
abc2c03b0f Fix missing 'current_url' value in registration flow.
This fixes some tracebacks I got while testing the Zulip htpasswd SSO
functionality.

I think that this stopped working as a result of the Jinja2 migration.
2016-06-28 23:05:38 -07:00
Tim Abbott
809a45394f puppet: Start supervisord if it isn't running on restart. 2016-06-28 22:09:36 -07:00
Tim Abbott
058d0ab0ec README.prod.md: Cleanup letsencrypt installation instructions.
Installing `nginx` is problematic, because it means something is using
port 80 and thus `letsencrypt-auto --standalone` doesn't work.  But we
do want `openssl` so that the directory trees we create symlinks in
will exist.
2016-06-28 22:08:56 -07:00
Tim Abbott
5ce0637da9 run-mypy: Explode exclude lists to specific files. 2016-06-28 16:42:59 -07:00
Tim Abbott
56e7a2f6f3 Annotate zerver.migrations. 2016-06-28 16:38:33 -07:00
Tim Abbott
c8aae360be test-backend: Fix spelling of an example in usage text. 2016-06-28 16:24:58 -07:00
Eklavya Sharma
2cba2caa7f zerver/lib/test_helpers.py: Fix string annotations. 2016-06-29 01:54:17 +05:30
Eklavya Sharma
d9eb711e5e zerver/tests/test_helpers.py: Use text_type for api_keys.
Also encode/decode strings appropriately when using api_keys to generate
basic auth header.
Also fix clashing annotations in zerver/tests/test_external.py.
2016-06-29 01:50:38 +05:30
Eklavya Sharma
eb3bde40a0 zerver/lib/test_helpers.py: Improve type annotations. 2016-06-29 01:35:34 +05:30
Eklavya Sharma
97760702a8 zerver/lib/actions.py: Use Sequence as parameter type. 2016-06-29 01:11:41 +05:30
Eklavya Sharma
dca9256f3c zerver/lib/socket.py: Improve annotations.
* Add Optional where required.
* Set type of req_redis_key as `(text_type) -> text_type` for consistency.
  Almost all our cache keys and redis keys use this signature.
2016-06-29 00:45:13 +05:30
Tim Abbott
4aae4de294 Properly cache production virtualenvs in Travis CI.
Previously, the --travis argument wasn't available to the `setup_venv`
code when creating the production virtualenv.
2016-06-28 12:04:11 -07:00
Tim Abbott
7ed0ab8c4a Ensure Zulip virtualenvs are world-readable.
This is important for both ensuring the Nagios checks work correctly
in production, as well as making sure the `zulip` user can access the
virtualenv (owned by the `travis` user) in Travis CI.
2016-06-28 12:03:01 -07:00
Eklavya Sharma
b305af05b3 Fix string annotations in custom cursors. 2016-06-28 15:58:57 +05:30
Eklavya Sharma
1a00b08a11 zerver/lib/db.py: Use a type alias to shorten annotations. 2016-06-28 15:57:43 +05:30
Tim Abbott
4a7913bc22 setup_venv: Use correct VENV_CACHE_PATH for production suite. 2016-06-27 21:16:22 -07:00
Tim Abbott
fd7cb3fc2b docs: Fix hardcoding of links to zulip.readthedocs.io.
This makes things work better if you're testing the documentation
locally.
2016-06-27 20:54:21 -07:00
Tim Abbott
31f7fb2fa0 docs: Fix new feature tutorial link to testing docs. 2016-06-27 20:52:20 -07:00
Tim Abbott
40aa8a2336 clean-venv-cache: Fix python 3 compatibility. 2016-06-27 20:39:22 -07:00
Tim Abbott
404c61ba97 clean-venv-cache: Use better approach to pruning caches.
Rather than looking at which venvs are used by this particular build,
we instead look at which venvs have a hash that is the hash_reqs value
of a current requirements.txt file.
2016-06-27 20:30:39 -07:00
Tim Abbott
7d5c1864f7 clean-venv-cache: Avoid cleaning production venvs. 2016-06-27 20:08:45 -07:00
Katerina Kampardi
707df7b55b README.dev.md: Clarify location of Zulip's root directory.
This adds some specifications for noobies - like me - while installing
the dev environment with vagrant on Ubuntu 14.04
2016-06-27 20:04:31 -07:00
Eklavya Sharma
7a98d7bd24 manifests/base.pp: Remove apt python package dependencies. 2016-06-27 19:55:35 -07:00
Eklavya Sharma
ebad1415c0 app_frontend_base.pp: Remove apt python package dependencies. 2016-06-27 19:55:35 -07:00
Eklavya Sharma
a9835c0ab2 Activate virtualenv in production Python code.
The manage.py change effectively switches the Zulip production server
to use the virtualenv, since all of our supervisord commands for the
various Python services go through manage.py.

Additionally, this migrates the production scripts and Nagios plugins
to use the virtualenv as well.
2016-06-27 19:55:35 -07:00
Eklavya Sharma
64affb83f9 Create a virtualenv when installing/upgrading production instances. 2016-06-27 19:55:11 -07:00
Eklavya Sharma
bbd24168b6 requirements/prod.txt: Add netifaces, flup and python-dateutils.
netifaces is used in puppet/zulip_internal/files/zulip-ec2-configure-interfaces.
flup is used for fastcgi.
python-dateutils is used in some puppet scripts.
2016-06-27 19:12:32 -07:00
Tim Abbott
beb8b50623 Move provision.py under tools/. 2016-06-27 19:04:32 -07:00
Tim Abbott
e1860e5b46 Remove tools/provision/zulip-dev.conf.
This was originally supervisord configuration for the Zulip
development environment; it never really worked how we wanted it to.
2016-06-27 19:04:32 -07:00
Tim Abbott
32eb021434 Make provision.py executable. 2016-06-27 19:04:23 -07:00
acrefoot
7ff89dc137 Add markdown-specific whitespace lint rule to /tools/lint-all.
Match one space or three+ spaces after content, or positive
number of spaces on an empty line.
2016-06-27 18:43:20 -07:00
acrefoot
acd7ff7aff Fix typo in Recipient comment. 2016-06-27 18:34:02 -07:00
acrefoot
a36e5d4987 Add get_auth_backends endpoint to API.
We would like to know which kind of authentication backends the server
supports.

This is information you can get from /login, but not in a way easily
parseable by API apps (e.g. the Zulip mobile apps).
2016-06-27 18:30:34 -07:00
Umair Khan
3115e13caf Remove extra call to i18n.t. 2016-06-27 14:17:47 -07:00
Aakash Tyagi
7a9a7189ae Added help text for running single casper tests.
[formatting tweaked by tabbott]
2016-06-27 14:15:32 -07:00
Aakash Tyagi
9154d93669 Added help text for running single backend tests. 2016-06-27 14:15:30 -07:00
Tim Abbott
e72f41cdec Remove old prototype data import/export tool.
This prototype from Dropbox Hack Week turned out to be too inefficient
to be used for realms with any significant amount of history, so we're
removing it.

It will be replaced by https://github.com/zulip/zulip/pull/673.
2016-06-27 13:47:08 -07:00
Tim Abbott
101820bc29 Move docker development environment scripts to tools/.
scripts/ is for scripts which are used in production.
2016-06-27 13:38:06 -07:00
Tim Abbott
879ca4b9ea docs: Add documentation on HTML and CSS. 2016-06-27 12:38:53 -07:00
Tim Abbott
74d86449e4 README.dev.md: Cleanup docs on testing. 2016-06-27 12:38:53 -07:00
Tim Abbott
292556c846 docs: Expand RTD testing section. 2016-06-27 12:38:53 -07:00
Tim Abbott
b2a24e0306 Revert "Add authorization check before serving files."
This reverts commit e985b57259.

This commit will break production when we next do a release, because
we haven't done a migration to create Attachment objects for
previously uploaded files.
2016-06-27 12:09:56 -07:00
Tim Abbott
f7e87bc1f0 test_helpers: Require that login calls actually succeed.
This caught several bugs where test code wasn't doing what it's author
intended.
2016-06-27 11:51:04 -07:00
Tim Abbott
4cac7bbb32 test_helpers: Refactor login test helpers.
We now have a separate login helper for the case where the return
value is desired.
2016-06-27 11:50:43 -07:00
Tim Abbott
a05c03d3b5 test_messages: Fix trying to login as a bot user.
Due to a recent refactoring, the first user in the subscribers list is
now a bot.
2016-06-27 11:48:39 -07:00
Tim Abbott
370b38696a test_messages: Fix broken huddle messages test.
The second login call was failing because the user didn't exist.
2016-06-27 11:48:36 -07:00
rahuldeve
e985b57259 Add authorization check before serving files. 2016-06-27 11:24:35 -07:00
rahuldeve
674def30ee Add support for serving files using API authentication.
Also remove 'get_uploaded_file' view function and the corresponding
old '/user_upload/' url pattern.
2016-06-27 11:00:41 -07:00
rahuldeve
2bf15603f3 Modify rest_dispatch to support method specific flags.
[simplified substantially by tabbott]
2016-06-27 10:53:15 -07:00
rahuldeve
823bf15c6e Add API route for uploading files. 2016-06-27 10:30:58 -07:00
Tim Abbott
79570f99c2 json_upload_file: Remove unnecessary has_request_variables. 2016-06-27 10:29:30 -07:00
Tim Abbott
8272fb4a94 zerver.views.upload: Move upload functions later in file. 2016-06-27 10:28:09 -07:00
Eklavya Sharma
e155573a1c zilencer's populate_db.py: Type annotate all variables. 2016-06-27 10:22:49 -07:00
Eklavya Sharma
8cacd5fcf8 zilencer's populate_db.py: Type annotate some variables. 2016-06-27 21:00:10 +05:30
Eklavya Sharma
ea3c671494 zilencer's populate_db.py: Improve an annotation. 2016-06-27 21:00:10 +05:30
Eklavya Sharma
66d1867869 zilencer's populate_db.py: Fix string types. 2016-06-27 21:00:10 +05:30
Eklavya Sharma
a9fa78fc4a api/zulip/__init__.py: Make compatible with newer mypy. 2016-06-27 21:00:09 +05:30
Eklavya Sharma
f20699b615 zerver/lib/statistics.py: Fix annotations.
Add type annotation to a variable.
Use abstract base container types where suitable.
Add missing imports from typing.
2016-06-27 18:03:29 +05:30
Eklavya Sharma
3917b822e5 zerver/lib/bulk_create.py: Type annotate variables. 2016-06-27 17:52:37 +05:30
Eklavya Sharma
d7a83ed019 zerver/views/__init__.py: Type annotate a variable. 2016-06-27 17:52:37 +05:30
Eklavya Sharma
63a5323259 zerver/views/streams.py: Type annotate variables. 2016-06-27 17:52:22 +05:30
Eklavya Sharma
9aa6fd988a zerver/lib/actions.py: Type annotate variables. 2016-06-27 17:52:07 +05:30
Eklavya Sharma
7ca1e658b5 zerver/lib/cache.py: Change some TypeVars to Any.
Change ItemT and CompressedItemT to Any.
See https://github.com/python/mypy/issues/1721.
2016-06-27 16:50:50 +05:30
Tim Abbott
f8c710b70e Update documentation on development auto-reloading.
Now that queue workers auto-reload, we need to document that fact.
And we make a few tweaks to the relevant discussion, while we're at
it.
2016-06-26 20:20:13 -07:00
rahuldeve
3ca53df152 Add test for worker queue autoreloading. 2016-06-26 20:12:37 -07:00
rahuldeve
a3745178e5 Use django.utils.autoreload to restart queue workers at code change.
Fixes #621, #1045.
2016-06-26 20:12:11 -07:00
Tim Abbott
61d1de19cf docs: Don't require typing module to be installed. 2016-06-26 10:10:59 -07:00
Tim Abbott
dc014b0866 docs: Add link to documentation building docs. 2016-06-26 10:04:07 -07:00
Tim Abbott
74c23d71e2 docs: Add details on viewing/editing these docs. 2016-06-26 10:04:06 -07:00
Tim Abbott
1838cd4d8f docs: Split out version control guidelines. 2016-06-26 10:04:06 -07:00
Tim Abbott
96fef7a0a1 docs: Reorganize RTD table of contents. 2016-06-26 10:04:05 -07:00
Tim Abbott
9aea3cdc9b docs: Add current Zulip release version to docs. 2016-06-26 10:03:56 -07:00
Tim Abbott
89b5eaaa7d docs: Improve several headings. 2016-06-26 09:54:19 -07:00
Tim Abbott
149fd88733 docs: Add missing link in schema-migrations.md. 2016-06-26 09:54:19 -07:00
Tim Abbott
ea611c0dcd docs: Add some full-text search documentation. 2016-06-26 09:32:54 -07:00
Tim Abbott
199e2df1e3 Split styles/settings.css out of zulip.css. 2016-06-26 08:21:39 -07:00
dhanus
1169329a71 Annotate zerver/views/webhooks/github.py. 2016-06-26 08:13:49 -07:00
Eklavya Sharma
85cb3e6103 zerver/views/webhooks/github.py: Make exception string str.
Passing a unicode string to Exception can sometimes fail.
Convert it to str to prevent that.
2016-06-26 08:13:49 -07:00
Eklavya Sharma
a32f83b182 zerver/views/webhooks/github.py: Fix string literals.
Change some string literals to unicode.
2016-06-26 08:13:49 -07:00
Eklavya Sharma
fa4adf0c62 zerver/views/webhooks/bitbucket.py: Fix an annotation. 2016-06-26 08:13:49 -07:00
Eklavya Sharma
36c2214d94 zerver/views/webhooks/bitbucket.py: Fix string literals.
Convert some strings literals to unicode.
2016-06-26 08:13:49 -07:00
Max
9b6205d0ed Annotate zerver/decorator.py. 2016-06-26 08:13:49 -07:00
Max
daab2ca475 zerver/tornadoviews.py: Improve an annotation.
Use django.core.handlers.base.BaseHandler instead of Any.
2016-06-26 19:05:54 +05:30
Tim Abbott
7d3b451902 lint: Check for extremely long lines.
Currently, we check for lines longer than 180 characters; we can lower
this as we clean up or wrap longer strings.
2016-06-25 10:52:03 -07:00
Tim Abbott
ce7c7d3510 Wrap youtube_re. 2016-06-25 10:52:03 -07:00
Tim Abbott
c25c8d8c98 forms: Wrap some very long lines. 2016-06-25 10:52:03 -07:00
Vishnu Ks
7d654a26c8 Casper test for realm creation. 2016-06-25 10:50:12 -07:00
Vishnu Ks
eb9798027c Move development URLs into dev_urls.py. 2016-06-25 10:50:12 -07:00
Tim Abbott
28b6f1d850 urls: Move non-legacy URLs back out of legacy_urls.py.
Only the old API endpoints were actually legacy URLs.
2016-06-25 10:49:56 -07:00
Tim Abbott
982cd5005b requirements: Remove duplicate coverage dependency. 2016-06-24 21:50:31 -07:00
Taranjeet
71c02c3391 Requirements: Add comments in common.txt.
Sourced primarily from puppet/zulip/manifests/app_frontend_base.pp.

[with some additions by tabbott]
2016-06-24 21:49:55 -07:00
Rishi Gupta
8070be4a93 admin_tab: Add a missing translation tag. 2016-06-24 21:22:36 -07:00
Rishi Gupta
ec996c7fb2 admin_tab: Clean up line-wrapping in admin-realm-form. 2016-06-24 21:21:43 -07:00
Rishi Gupta
6c6f70dd96 Change checked=yes/true to checked=checked in handlebars files.
Only checked="checked" is actually valid according to w3c standards.
2016-06-24 21:16:20 -07:00
Vishnu Ks
20adcbc64b Make send_registration_completion_email return the Confirmation object. 2016-06-24 17:47:56 -07:00
Vishnu Ks
420ee968f7 Renumber the casper tests to make space for realm-creation test.
And also fix the mysterious gaps at 6 and 8.
2016-06-24 17:47:56 -07:00
Vishnu Ks
8350b89798 Add support for custom error message in realm-creation-failed template. 2016-06-24 17:47:56 -07:00
Tim Abbott
6d71c25a0f accounts_register: Stop using _ as dummy variable.
This conflicts with internationalization.
2016-06-24 17:47:31 -07:00
Preston Hansen
57dec15c6c Update alert word UI to match the style of bots.
Resolves #1075.
2016-06-24 16:43:19 -07:00
Taranjeet
122fb8eb62 Requirements: Add comments in dev.txt. 2016-06-24 16:25:09 -07:00
Taranjeet
c52049a85b Requirements: Add comments in docs.txt. 2016-06-24 16:25:08 -07:00
Taranjeet
c5ceac9739 Requirements: Add comments in ipython.txt. 2016-06-24 16:24:05 -07:00
Taranjeet
c9720f9b74 Requirements: Add comments in moto.txt. 2016-06-24 16:24:03 -07:00
Akash Nimare
8c06c234d3 Improve reset email password link formatting. 2016-06-24 16:22:04 -07:00
acrefoot
e4ed9195dc Remove rest_dispatch hack and optimize imports.
For a long time, rest_dispatch has had this hack where we have to
create a copy of it in each views file using it, in order to directly
access the globals list in that file.  This removes that hack, instead
making rest_dispatch just use Django's import_string to access the
target method to use.

[tweaked and reorganized from acrefoot's original branch in various
ways by tabbott]
2016-06-24 16:11:03 -07:00
Tim Abbott
aebd84cb1b urls: Clarify comment on mobile device credentials. 2016-06-24 16:04:14 -07:00
Tim Abbott
6f06101b73 urls: Add comments on sections of REST URLs. 2016-06-24 16:01:35 -07:00
Tim Abbott
71313fbbdf urls: Move users/me urls further down. 2016-06-24 16:00:32 -07:00
acrefoot
788853a632 urls: Fix over-broad /users/email regexs in urls.py.
/users/me could get captured as an email--our urls shouldn't be so
sentitive to ordering.
2016-06-24 15:53:12 -07:00
Tim Abbott
5235ad5416 urls: Rearrange a few REST URL entries. 2016-06-24 15:51:54 -07:00
Tim Abbott
810d392947 urls: Fix mis-indented URLs entries. 2016-06-24 15:45:26 -07:00
Tim Abbott
16d260d36a urls: Cleanup unnecessary use of 'patterns` calls. 2016-06-24 15:42:04 -07:00
Tim Abbott
aa228c9719 urls: Update some comments. 2016-06-24 15:39:14 -07:00
Tim Abbott
6dc416b6c3 urls: Wrap some comments better. 2016-06-24 15:39:14 -07:00
Tim Abbott
92f5e38171 urls: Move the dual-use patterns config up. 2016-06-24 15:39:14 -07:00
Tim Abbott
169810b874 urls: Move development avatars config further down. 2016-06-24 15:39:09 -07:00
acrefoot
0c799dc6b8 Add comments to label important sections of urls.py. 2016-06-24 15:21:36 -07:00
acrefoot
b36bc051af Move old-style API endpoints to legacy_urls.py. 2016-06-24 15:14:03 -07:00
acrefoot
5a49c5e280 Denormalize urls in routes file.
Currently we use the deprecated django pattern() prefix pattern.
This make it hard to read the router logic in zproject/urls.py

This commit denormalizes the urls so that they can be read
more easily, at the expense of some verbosity. This also makes it
easier to reorganize urls in that file.

We skip denomalizing rest_dispatch due to its unique complications.
2016-06-24 15:12:51 -07:00
acrefoot
5d21fb0681 Remove unused imports from tornadoviews.py. 2016-06-24 14:53:13 -07:00
acrefoot
bca5613551 Add PyCharm files to .gitignore. 2016-06-24 14:53:11 -07:00
acrefoot
be484b25c6 Add comments on how rest_dispatch authenticates. 2016-06-24 14:52:22 -07:00
Tomasz Kolek
e6861636c8 Fix editing messages by adding or removing leading /me.
Previously, this did not correctly rerender the message to be (or not
to be) rendered as a /me style message.

Fixes: #835.
2016-06-24 11:18:29 -07:00
Tim Abbott
dfd8fede4a setup_venv: Add missing build essential dependencies.
Apparently, c74a74dc74 introduced a bug
where we are no longer correctly depending on build-essential as part
of the Zulip development environment installation process.

Fixes #1111.
2016-06-24 09:11:10 -07:00
rahuldeve
8cecb37743 Modify Attachment model to track file access permissions. 2016-06-23 17:46:16 -07:00
Michael Cordover
a51ec44005 Search streams from left sidebar (resolves #565).
Assigns hotkey 'w' to search streams.
Only show search box when active. Activate with hotkey or by clicking
STREAMS.
Filter matches at the beginning of words in stream name.
Behaviour is otherwise almost identical to user search.
Casper tests.
2016-06-23 17:21:57 -07:00
Vishnu Ks
574a304b12 Mention invite emails are printed in console in dev.
This is part 2 of #1046.
2016-06-23 17:07:11 -07:00
Umair Khan
a70d5041d2 Don't allow literal strings in report_error. 2016-06-23 16:23:01 -07:00
Umair Khan
939ebbbc98 Mark report_error arguments translatable. 2016-06-23 16:23:01 -07:00
Umair Khan
b7bb49c6f5 Don't allow literal string in report_success. 2016-06-23 16:23:01 -07:00
Umair Khan
4da1a3ecd6 Mark report_success arguments translatable. 2016-06-23 16:23:01 -07:00
krtkmj
734ab8d5e3 Correctly narrow to stream using search box from subscription page.
Fixes #1012.
2016-06-23 15:20:57 -07:00
Eklavya Sharma
9482cdccf4 scripts/lib/setup-venv.py: Accept None as target_venv_path.
If target_venv_path in setup_virtualenv is None, create a virtualenv
named 'venv' but don't make a symlink to it.  Also return
cached_venv_path.
2016-06-23 14:17:17 -07:00
Eklavya Sharma
0365a4a9f2 Factor out apt dependencies for setting up virtualenv.
Move apt dependencies for creating a virtualenv from provision.py
to scripts/lib/setup_venv.py.
2016-06-23 14:17:17 -07:00
Taranjeet
3ca76b63c9 Remove use of $(document).data('events') to enable jQuery 1.8 upgrade.
jQuery renamed this (not supported) API in jQuery 1.8.

Fixes #1034.
2016-06-23 14:06:47 -07:00
Tim Abbott
85798e2b2c Dramatically expand directory structure docs. 2016-06-23 14:01:54 -07:00
Tim Abbott
c8a1c3a86b docs: Reorder directory structure doc. 2016-06-23 13:58:41 -07:00
Tim Abbott
b0e1ae4245 docs: Make directory structure headings linkable. 2016-06-23 13:58:41 -07:00
Tim Abbott
5a1a540377 Expand directory structure details on scripts. 2016-06-23 13:58:41 -07:00
Tim Abbott
2080038e7c Fix Jinja2 conversion bug in placeholder email value.
The `email` parameter to this template is only set if the user is
redirected to the login form after attempting to register for a new
account with an email address that already has an account.
2016-06-22 17:07:02 -07:00
James Porter
25a13cb09b Defer loading zxcvbn in main webapp until necessary.
We only use zxcvbn in the main webapp for checking the user's password
in the change password form.  Since zxcvbn is a very large javascript
library (~700KB), loading it asynchronously only when a user is trying
to change their password results in a significant performance
improvement for loading the Zulip webapp on a slow network.

Fixes #263.
2016-06-22 17:06:37 -07:00
Tim Abbott
039c175d68 production-helper: Hold tons of packages.
This saves almost a minute doing apt upgrades in the production test
suite.
2016-06-22 10:41:09 -07:00
Tim Abbott
9b436c7190 setup-production: Remove more irrelevant postgres packages. 2016-06-22 10:41:09 -07:00
Tim Abbott
4b2e661705 travis: Skip development service restarts in production tests. 2016-06-22 10:41:09 -07:00
Tim Abbott
5a109cf816 travis: Skip development database setup in production tests.
This saves about 20s on the runtime of the production build.
2016-06-22 10:41:09 -07:00
Tim Abbott
0f2729f5fb production-helper: use dist-upgrade to match install script.
Previously, we were wasting time every time we installed packages,
because `apt-get upgrade` would only install most of the packages
`apt-get dist-upgrade` would.
2016-06-22 10:38:27 -07:00
Tim Abbott
c74a74dc74 provision: Use --no-install-recommends when installing deps. 2016-06-22 09:34:49 -07:00
Umair Khan
33e6b471e2 Fix spelling of mesage_count_by_recipient_subject. 2016-06-22 09:02:35 -07:00
Tim Abbott
d3f3046629 Add python-six to early installer dependencies.
Since we're now using python-six in zulip-puppet-apply, we need to
install python-six before calling into zulip-puppet-apply.
2016-06-22 08:11:34 -07:00
Eklavya Sharma
b30690e760 Move prod.txt to requirements/.
In 81ecfc5, prod.txt was unintentionally placed in Zulip's root directory
instead of requirements/.
2016-06-22 18:41:58 +05:30
Eklavya Sharma
121a5f26fb Move hash_reqs.py from tools/ to scripts/lib/.
This is needed because hash_reqs.py is used to create a virtualenv.
Currently we only use virtualenv in development, but we will soon
start using it in production.  Scripts used in production should be
put in scripts/.
2016-06-22 18:12:08 +05:30
Tim Abbott
c668f1e299 roadmap: Add strikethrough for completed projects. 2016-06-21 17:30:33 -07:00
Tim Abbott
6b8e9c7254 Exclude static/locale from linters. 2016-06-21 17:17:34 -07:00
Tim Abbott
4958828747 Add changelog for Zulip 1.3.13 release. 2016-06-21 16:59:48 -07:00
Tim Abbott
1d2d147a62 Update translations data from Transifex. 2016-06-21 16:45:55 -07:00
Tim Abbott
250781e843 Fix HTTP Basic Auth popups caused by auth failures.
If a user's session cookie expired, the next REST API request their
browser did would go into the json_unauthorized code path.  This
returned a response with a WWW-Authenticate tag for HTTP Basic Auth
(since that's what the REST API uses), even for /json requests which
should only be authenticated using session auth.

We fix this by explicitly passing the desired WWW-Authenticate state.

Fixes: #800.
2016-06-21 16:18:36 -07:00
Tim Abbott
45beac7d6c test_decorators: Add test for /json/fetch_api_key. 2016-06-21 16:14:22 -07:00
Tim Abbott
f39c9161fe Fix fetching user API keys via settings page when using LDAP backend.
Previously, json_fetch_api_key was hardcoding a check using Zulip's
built-in password functionality, rather than using authenticate().
2016-06-21 14:58:25 -07:00
Tim Abbott
1565ee8453 Fix using LDAP backend with Zulip mobile apps.
The recent changes to api_fetch_api_key to receive detailed data via
the "return_data" object did not properly update the LDAP backend to
accept that argument, causing mobile password authentication to not
work with the LDAP backend.
2016-06-21 14:57:54 -07:00
akashnimare
42ebf6acb7 Update Zulip /hello page to match zulip.org.
[with rebasing tweaks by tabbott].
2016-06-21 14:54:46 -07:00
Tomasz Kolek
7aa45ffa45 Increase send_message_backend coverage. 2016-06-21 14:33:21 -07:00
Vishnu Ks
055c7eed04 Tweak the CSS of skip-tutorial button. 2016-06-21 14:23:17 -07:00
Tim Abbott
50f723f50b Split test_narrow.py out of test_messages.py. 2016-06-21 12:25:08 -07:00
Tomasz Kolek
e3e03e2946 Add NarrowBuilder test cases.
Refactor existing add_term test cases.
2016-06-21 11:53:31 -07:00
Tomasz Kolek
f8c368c07f Add default-bot during populate_db. 2016-06-21 11:47:38 -07:00
Tomasz Kolek
9ae68ade8b Add is_webhook option to authentication decorats.
Modified:
authenticated_rest_api_view
authenticated_api_view and validate_api_key.
2016-06-21 11:47:38 -07:00
Tim Abbott
80d92c1651 Add comment documenting confusing list_to_streams code. 2016-06-21 11:45:35 -07:00
Eklavya Sharma
fc8d4f9ef5 Factor out venv-creating code from provision.py.
Move setup_virtualenv and do_setup_virtualenv from provision.py to
scripts/lib/setup_venv.py.
2016-06-21 11:25:41 -07:00
Alex Wilson
f68a392250 Run django.setup() after coverage.start() in tests to fix coverage report.
Fixes #1007.
2016-06-21 10:37:45 -07:00
Tim Abbott
2640cc44c7 Move coverage to dev requirements.txt. 2016-06-21 07:48:58 -07:00
Tim Abbott
5f958f46a5 Move pyflakes to dev requirements.txt. 2016-06-21 07:48:58 -07:00
Tim Abbott
1a876310bc Move ipython dependencies to their own requirements file. 2016-06-21 07:48:58 -07:00
Tim Abbott
09fcc079b4 Move moto dependencies to new requirements file. 2016-06-21 07:48:58 -07:00
Tim Abbott
fd1a134bef Move transifex dependencies to dev.txt. 2016-06-21 07:48:58 -07:00
Tim Abbott
b43bf10a93 Move recommonmark requirement to docs.txt. 2016-06-21 07:48:58 -07:00
Eklavya Sharma
be70907eaa Remove references to requirements.txt. 2016-06-21 07:48:24 -07:00
Eklavya Sharma
b5d08bb5de README.dev.md: Improve pip instructions.
Recommend using a virtualenv.
Add instruction to do `pip install --upgrade pip` before installing
python packages.
2016-06-21 07:35:26 -07:00
Umair Khan
4149b0bb56 Fix path to hash_req.py in provision.py.
Fixes #1081.
2016-06-21 07:01:45 -07:00
Akash Nimare
8939dc1cdd Fixed broken Docker linux installation link.
[This](https://docs.docker.com/engine/started/) link is broken. Updated to the latest.
2016-06-21 08:36:40 +05:30
krtkmj
9dadab6eac Replace placeholder variables x with more meaningful ones. 2016-06-20 19:36:07 -07:00
Tim Abbott
7370fd69d7 Move doc building dependencies to requirements/docs.txt. 2016-06-20 16:05:42 -07:00
medullaskyline
e2eb4e0b7e Annotate zerver/lib/email_mirror.py.
[With some fixes from @sharmaeklavya2].
2016-06-20 15:58:40 -07:00
Eklavya Sharma
a2668a2853 zerver/lib/notifications.py: Fix an annotation. 2016-06-21 02:20:36 +05:30
Umair Khan
c61a3dfbcc Ensure translations are loaded.
Since i18next loads translations asynchronously we need to make sure
that they are loaded before we call the JS code which depends on them.

Fixes #982
2016-06-20 11:31:28 -07:00
Umair Khan
d29ab6651b Mark strings translatable in the frontend. 2016-06-20 11:31:28 -07:00
Umair Khan
134b165b1a Fix frontend translation string bug.
The translation string which contain \n are not captured
within {{#tr}}{{/tr}} blocks. Fix is to escape the slash.
2016-06-20 11:31:28 -07:00
Eklavya Sharma
81ecfc5a43 Split requirements.txt into multiple files. 2016-06-20 11:09:20 -07:00
Eklavya Sharma
500cc32e64 provision.py: Use tools/hash_reqs.py.
Use tools/hash_reqs.py to generate hash of requirements.txt in
provision.py while setting up virtualenv.
2016-06-20 11:09:20 -07:00
Eklavya Sharma
8148cbe173 Add tools/hash_reqs.py.
tools/hash_reqs.py generates a hash of a requirements file.  It
does that by generating a sorted list of unique dependencies referred
to by that requirements file.  To do that, it also recurses into other
requirements files specified inside that requirements file.
2016-06-20 11:09:20 -07:00
Vishnu Ks
ff66ce780a Mention emails are printed in run-dev.py console.
Fixes: #1046
2016-06-20 11:07:20 -07:00
Tim Abbott
f7ce5fc179 generate_secrets: Silence mypy error with configparser.
See https://github.com/python/typeshed/issues/307.
2016-06-20 09:03:09 -07:00
Tim Abbott
eb71173be3 lint: Fix warnings under confirmation/. 2016-06-20 08:19:54 -07:00
Umair Khan
a9a6687b7d Make generate-secrets script use existing values.
Fixes #1035
2016-06-20 17:00:27 +05:00
Eklavya Sharma
aceee3da11 zerver/lib/rate_limiter.py: Annotate rate_limiter.rules.
After annotating rate_limiter.rules, mypy complained that rules does
not support cmp.  So use key to customize sort instead of cmp.
Python docs also recommend using key over cmp.
2016-06-18 16:41:41 -07:00
Eklavya Sharma
13f62da4ce zerver/lib/rate_limiter.py: Fix annotations. 2016-06-18 16:41:40 -07:00
Eklavya Sharma
6097f6eed5 zerver/lib/initial_password.py: Encode return value.
zerver.lib.initial_password.initial_password is supposed to return an
Optional[text_type], but it returns an Optional[binary_type] instead.
Encode the return value to make sure it returns an Optional[text_type].
2016-06-18 16:41:40 -07:00
Eklavya Sharma
018041625c zerver/lib/html_diff.py: Fix annotations. 2016-06-18 16:41:40 -07:00
Eklavya Sharma
68823767e2 zerver/lib/digest.py: Fix annotations. 2016-06-18 16:41:40 -07:00
Eklavya Sharma
64ccb390ff Annotate zerver/lib/create_user.py. 2016-06-18 16:41:40 -07:00
Tim Abbott
3899b4c913 Move py3k requirements to requirements/py3k.txt. 2016-06-18 16:41:40 -07:00
Tim Abbott
5c92639f81 Move mypy requirements to requirements/ directory. 2016-06-18 16:41:40 -07:00
Eklavya Sharma
666041e1b2 Remove wsgiref, argparse and South from requirements.txt.
wsgiref and argparse are part of the Python 2.7 standard library, and
South ceased being relevant in Django 1.6.
2016-06-18 15:50:06 -07:00
Tim Abbott
46c2416cc8 puppet: Add postgres version map for xenial.
This is an early step towards Ubuntu Xenial support in production.
2016-06-17 16:41:42 -07:00
Vishnu Ks
ad1c3894d9 Add interface for creating new realms.
This is controlled by settings.OPEN_REALM_CREATION; if that setting is
off, this feature doesn't do anything.
2016-06-17 16:15:28 -07:00
Vishnu Ks
8213ca135a Move default_stream list to settings. 2016-06-17 16:01:38 -07:00
Rishi Gupta
ce5e7d3ba6 Make minor edits to new settings documentation. 2016-06-17 12:15:15 -07:00
Tim Abbott
b5e92f541a Add new documentation on Zulip settings system.
Fixes: #962.
2016-06-17 12:15:15 -07:00
Tim Abbott
6d1d7471e6 Refactor out zproject/dev_settings.py. 2016-06-17 12:15:15 -07:00
Taranjeet
964ff027bd Dockerfile: Create symlink in home folder for project. 2016-06-17 11:48:59 -07:00
Taranjeet
3fae7a69b3 VagrantFile: Create symlink in home folder for project.
Fixes: #922.
2016-06-17 11:48:55 -07:00
Eklavya Sharma
14c4ff2d25 docs/code-style.md: Use ASCII spaces consistently.
At some places, '\xc2\xa0' was used instead of ' '.  This characters looks
identical, but can hamper searches and lint checks.
2016-06-17 11:33:41 -07:00
Tim Abbott
07abfc189b Update docs/README.md to reflect the current state of the world.
Fixes #1050.
2016-06-17 11:30:22 -07:00
kunall17
007eee6061 Add route to fetch emails for mobile passwordless login.
[Tweaked by tabbott to rename API to explicitly support not just
Android]
2016-06-17 11:03:19 -07:00
kunall17
7ea0eaed1c Add passwordless login for mobile app development.
[Tweaked by tabbott to rename API to explicitly support not just
Android].
2016-06-17 10:58:33 -07:00
Tim Abbott
d117ec8664 lint: Fix redundant stripping of strings. 2016-06-17 10:41:39 -07:00
Tim Abbott
267a71cf20 Run Python custom RE checks in parallel with non-python.
This saves about 1s (out of originally 3.3s) of time running all the
linters in my development environment.
2016-06-17 10:26:50 -07:00
Vishnu Ks
01c9bb2d5e Make name_changes_disabled() work with no argument. 2016-06-16 17:13:59 -07:00
Tim Abbott
e109b50152 Fix alignment of airbrake integration in urls.py. 2016-06-16 15:30:45 -07:00
Tomasz Kolek
76cbe89613 Add IFTTT integration. 2016-06-16 15:30:45 -07:00
Eklavya Sharma
598fb1ff28 zerver/lib/bugdown/fenced_code.py: Add BaseHandler.
Add a class 'BaseHandler' and make it a base class of OuterHandler,
QuoteHandler and CodeHandler.  This will help annotate some functions
and improve type checking.
2016-06-16 15:21:17 -07:00
Eklavya Sharma
142bcadb68 Annotate zerver/lib/bugdown/fenced_code.py. 2016-06-16 15:21:17 -07:00
Eklavya Sharma
9b72b7b37e Annotate zerver/lib/bugdown/codehilite.py.
Also change some string literals to unicode.
2016-06-16 15:21:17 -07:00
Eklavya Sharma
744007f33f zerver/lib/bugdown/__init__.py: Fix string types.
Change important string constants from str to text_type.
Replace str by text_type in annotations where relevant.
2016-06-16 15:21:17 -07:00
Eklavya Sharma
04f44b12ad zerver/lib/bugdown/testing_mocks.py: Fix types.
Also fix clashing annotations in zerver/lib/bugdown/__init__.py.
2016-06-16 15:21:17 -07:00
Eklavya Sharma
7db0765a18 zerver/lib/bugdown/fenced_code.py: Fix types.
Change some important string literals from str to unicode.
Annotate format_code and codehilite_conf in FencedBlockProcessor.
2016-06-16 15:21:17 -07:00
Eklavya Sharma
48c5b299b6 zerver/lib/bugdown/codehilite.py: Add type annotation.
Mypy incorrectly infers a dict's type as `Dict[str, List[object]]`.
Change that to `Dict[str, List[Any]]`.
2016-06-16 15:21:17 -07:00
Eklavya Sharma
a485d63975 zerver/lib/bugdown/__init__.py: Fix non-string annotations. 2016-06-16 15:21:17 -07:00
Tim Abbott
eafb91719c get_tweet_id: Fix return type to by None. 2016-06-16 15:21:01 -07:00
Tim Abbott
33df0b29d3 Annotate zerver/tests/test_hooks.py. 2016-06-16 14:07:34 -07:00
Tim Abbott
49ae0052b2 send_json_payload: payload arg can be text_type. 2016-06-16 14:07:34 -07:00
Tim Abbott
df9f89fe2c test_helpers: Change send_json_payload to use text_type. 2016-06-16 14:07:34 -07:00
Tim Abbott
b14eacd552 test_helpers: Change fixture_data to text_type. 2016-06-16 14:07:34 -07:00
Tim Abbott
5b05644c95 Run mypy on zerver/tests/test_hooks.py. 2016-06-16 14:07:34 -07:00
Tim Abbott
6723525fd3 Annotate zerver/tests/tests.py. 2016-06-16 14:07:34 -07:00
Tim Abbott
45883386ce AlertWordTests: Cleanup confusing message variable reuse. 2016-06-16 13:55:58 -07:00
John Hergenroeder
16a19226f6 Add linter check for redundant REQ whence argument. 2016-06-16 13:53:39 -07:00
Christie Koehler
a9b277368a requirements: Add dependencies required by Sphinx.
Since `pip install` is passed `--no-deps`, we need to explicitly list
it's dependencies in requirements.txt in order for docs generation to
work.
2016-06-16 09:39:47 -07:00
Taranjeet
219ecfff99 Readme.dev.md: Update broken link for docker architecture. 2016-06-16 09:02:02 -07:00
Tim Abbott
0071731915 test-run-dev: Display original error messages on failures.
This helped with debugging a failure recently.
2016-06-15 22:44:04 -07:00
Tim Abbott
b65c187398 Fix docker instructions using port 80 on localhost.
This was confusing, because we otherwise suggest consistently to users
that they should connect to their development environment on port
9991.

Fixes #1032.
2016-06-15 16:41:47 -07:00
Eklavya Sharma
98553e8caa zerver/lib/push_notifications.py: Fix strings.
Use appropriate string encode/decode operations and fix annotations.
2016-06-15 15:25:28 -07:00
Eklavya Sharma
78565a96c9 zerver/lib/notifications.py: Fix string annotations. 2016-06-15 15:25:28 -07:00
Tim Abbott
39a8c82957 travis: Remove verbose coverage report from end of build output. 2016-06-15 15:05:38 -07:00
Tim Abbott
10dd9addb7 Fix ChangeSettingsTest caching issue causing test failures. 2016-06-15 14:57:58 -07:00
Tim Abbott
06079042d4 ChangeSettingsTest: Move login to test helper method. 2016-06-15 14:28:24 -07:00
Tim Abbott
8f67b7e498 Simplify check_for_toggle_param. 2016-06-15 14:23:51 -07:00
Ashish Kumar
0a98d9edcf Add test_enter_sends_setting. 2016-06-15 14:23:51 -07:00
Ashish Kumar
8a55098ca7 Add test_time_setting. 2016-06-15 14:23:51 -07:00
Ashish Kumar
345df3538f Add test_toggling_left_side_userlist. 2016-06-15 14:23:51 -07:00
Ashish Kumar
24767302c4 Update test_ui_settings to use new abstraction. 2016-06-15 14:23:51 -07:00
Ashish Kumar
006e528e18 Update test_notify_settings to use new abstraction. 2016-06-15 14:23:51 -07:00
Ashish Kumar
5ae06e8c33 Added test helper function: check_for_toggle_param 2016-06-15 14:18:55 -07:00
Tim Abbott
ce938ca39c Annotate provision.py.
Annotations aren't particularly important here, but it will prevent
coveralls from complaining whenever someone patches provision.py.
2016-06-15 12:12:23 -07:00
Eklavya Sharma
553a9d0b75 tools/run-mypy: Exclude py files which have a pyi.
If a .py file has a corresponding .pyi stub file, exclude that
.py file from mypy.
2016-06-15 22:40:31 +05:30
Umair Khan
7d3dc5d0b3 Cache npm for Travis CI.
This should speed up all the major Zulip builds in Travis CI.

Fixes #712.
2016-06-15 09:32:50 -07:00
Tim Abbott
9e6b9dacf6 test-migrations: Fix missing exit status on error.
Previously this test was correctly detecting missing migrations, but
not causing the build to fail.
2016-06-15 09:26:04 -07:00
Tim Abbott
f88e5b7438 Add missing no-op migration for realm_emoji.
Because of how Django's migration system works, changing the error
message attached to a model field's validator results in an extra
migration.
2016-06-15 09:26:01 -07:00
Tim Abbott
7f06fec9d5 Fix spelling of _streams_deferred. 2016-06-14 16:36:54 -07:00
Tim Abbott
c7f0e66f7e Replace deprecated jQuery deferred.isResolved(). 2016-06-14 16:36:54 -07:00
Tim Abbott
c0e8f3f2bf [third] Upgrade underscore.js to version 1.8.3.
This seems to have no backwards-incompatible changes affecting us, and
likely brings a number of performance and compatibility improvements.
2016-06-14 16:36:54 -07:00
Tim Abbott
02e6d267f1 [third] Replace jquery-caret with newer implementation.
Apparently, there are like 5 independently developed jquery-caret
plugins, none of which are great.  The previous one we were using was
last modified in 2010.  This new one comes from
https://github.com/acdvorak/jquery.caret and at least doesn't use
deprecated jQuery syntax and has a repository on GitHub.

This plugin is way larger than it needs to be for what it does, but we
can deal with that later.
2016-06-14 16:36:51 -07:00
Umair Khan
a976ccefbf [third] Urlencode name of the uploaded file.
Update jquery-filedrop to send urlencoded filenames.

As discussed in https://github.com/zulip/zulip/pull/1023, this fix is
already in jquery-filedrop upstream.

Fixes #981.
2016-06-14 15:32:41 -07:00
Tomasz Kolek
4e51a86ea4 Add updownio integration. 2016-06-14 12:14:07 -07:00
Tomasz Kolek
14d69348d3 Add Airbrake integration. 2016-06-13 20:36:40 -07:00
Eklavya Sharma
72ed1f4187 Fix python 3 pyflakes error.
Change raw unicode literal to non-raw.  A raw unicode literal is a
syntax error in python 3.  This error was detected by pyflakes.
2016-06-13 19:44:56 -07:00
Tim Abbott
2219ef7bef bugdown: Rename upload_re to upload_title_re for clarity. 2016-06-13 19:44:56 -07:00
Tim Abbott
6c78036811 Add tests for upload title functionality. 2016-06-13 19:44:56 -07:00
Tim Abbott
5b1cfbc977 bugdown: Fix extraction of titles for uploaded files.
The previous code was associated with a previous version of the upload
URL naming scheme, and thus never triggered in practice.
2016-06-13 19:44:51 -07:00
Michael Cordover
b401ec0af7 Warn on postgres-init-db if >200 messages exist.
Closes #548.
2016-06-13 15:57:51 -07:00
Michael Cordover
53e23743ca Refactor hotkey logic.
Place all hotkey names into a set of three objects in hotkeys.js:

 * hotkeys_shift_insensitive
   These are keys where the behaviour is the same whether they are
   pressed with shift or not.

 * hotkeys_no_modifiers
   These are keys where the event should only be fired when shift
   is not being pressed.

 * hotkeys_shift
   These are keys where the event should only be fired when the key
   is pressed simultaneously with shift.

Each object is a dictionary of key value pairs, with the key being
the keyscan code (e.which) for the key. This is normally the ASCII
key code. The value is an object with two properties, name (which
is the event name) and message_view_only, a boolean. Hotkeys with
message_view_only set to true will not be fired when the home tab
is obscured.
2016-06-13 15:43:49 -07:00
Tim Abbott
0f8d33c488 Fix URL for zulip_main.png for i18n site. 2016-06-13 09:12:52 -07:00
Umair Khan
c8d139b2b1 Fix emoji urls interaction with i18n.
When accessing emojis with relative urls we should start the urls with
a slash so that language code doesn't become part of these urls.

Fixes #1014.
2016-06-13 09:10:11 -07:00
Umair Khan
c1f5ac375c Add linter checks for javascript strings and HTML placeholders.
Checks are added for:
- i18n.t
- placeholder
- compose_error
2016-06-13 09:05:27 -07:00
Umair Khan
6fcfed8d9e Update regexes to capture translation strings.
Strings are captured from:
- i18n.t
- compose_error
- placeholder
2016-06-13 09:03:56 -07:00
Umair Khan
6fb0baaa25 Mark strings translatable.
Following strings are marked translatable:
- All strings which are passed to `button.text` or which affect the
    text of buttons.
- All strings passed to `placeholder`.
- All strings passed to `compose_error`.

Fixes #969
2016-06-13 09:03:56 -07:00
Eklavya Sharma
7ec9cb7e93 Annotate model fields: Attachment.
Also fix clashing annotations.
2016-06-13 20:01:03 +05:30
Eklavya Sharma
86978cb2a3 Annotate model fields: Stream. 2016-06-13 20:01:03 +05:30
Eklavya Sharma
6f5ed6e7c9 Fix annotations clashing with Stream model fields. 2016-06-13 20:01:02 +05:30
Eklavya Sharma
1ec7e124c7 Annotate model fields: Message. 2016-06-13 20:01:02 +05:30
Eklavya Sharma
5a5934a76f Fix annotations clashing with Message model fields. 2016-06-13 20:01:02 +05:30
Eklavya Sharma
f27cff57c3 Annotate model fields: UserProfile. 2016-06-13 20:01:02 +05:30
Eklavya Sharma
71e613424b Fix annotations clashing with UserProfile's model fields. 2016-06-13 20:01:01 +05:30
Eklavya Sharma
9d7a2fdf9d zerver/views/streams.py: Fix annotations.
Mainly fix `str` to `text_type` and use abstract containers.
2016-06-13 20:01:01 +05:30
Eklavya Sharma
9f39c9276f Annotate model fields: DefaultStream, Referral, ScheduledJob. 2016-06-13 19:37:07 +05:30
Eklavya Sharma
4f890cca2a Annotate model fields: UserActivity, UserActivityInterval, UserPresence. 2016-06-13 19:37:07 +05:30
Eklavya Sharma
7290f9cb83 Annotate model fields: Subscription and Huddle. 2016-06-13 19:37:07 +05:30
Eklavya Sharma
ddaaa98b25 Annotate model fields: UserMessage. 2016-06-13 19:30:58 +05:30
Eklavya Sharma
acd1767398 Annotate model fields: Recipient and Client. 2016-06-13 19:30:57 +05:30
Eklavya Sharma
c0004a5874 Annotate model fields: PushDeviceToken and MitUser. 2016-06-13 19:30:57 +05:30
Eklavya Sharma
04740fb620 Annotate model fields: PreregistrationUser. 2016-06-13 19:30:56 +05:30
Eklavya Sharma
d666e00833 Annotate model fields: RealmEmoji and RealmFilter. 2016-06-13 19:30:56 +05:30
Eklavya Sharma
6c7dd07ec2 Annotate model fields: Realm and RealmAlias. 2016-06-13 19:30:56 +05:30
Eklavya Sharma
d169cc5376 zerver/lib/bulk_create.py: Fix string annotations.
Change string type from `str` to `text_type` where required.
Also fix clashing annotations.
2016-06-13 10:08:14 +05:30
Eklavya Sharma
c654c4032d zerver/models.py: Annotate get_display_recipient.
get_display_recipient's annotation clashes with other wrong annotations.
Fix those wrong annotations.
Since get_display_recipient returns a Union, use isinstance checks and
casts to make mypy checks succeed.
2016-06-12 23:34:57 +05:30
Tim Abbott
9f980c64b6 Add detailed LetsEncrypt instructions.
We'll likely want to follow this up with:
(1) Making Let's Encrypt the default instructions for getting a cert.
(2) Moving the "how to get an SSL cert" discussion to its own page.
(3) Eliminating the duplicate content in zulip.org/server.html

But this is definitely an improvement!
2016-06-12 10:35:07 -07:00
Eklavya Sharma
ed61c4c581 Improve model string representation.
Define __str__, __repr__ and __unicode__ correctly on models.
This will help in python 3 compatibility.
2016-06-12 09:55:12 -07:00
Eklavya Sharma
17b9422546 zerver/models.py: Fix regex strings.
Some regex strings were not declared as raw, even though they used
a lot of backslashes.
2016-06-12 09:31:19 -07:00
Eklavya Sharma
81759d56be zerver/models.py: Fix string annotations in UserPresence. 2016-06-12 09:30:53 -07:00
Eklavya Sharma
e11bec28c2 zerver/models.py: Fix annotations (str -> text_type).
Change str to text_type where appropriate in annotations related to
Attachment, PreregistrationUser and Huddle.
2016-06-12 09:30:53 -07:00
Eklavya Sharma
d76bea8f25 zerver/models.py: Identify functions returning QuerySets.
Identify functions which return QuerySets and give them a return type
`Sequence` with appropriate parameter.  Typing them as QuerySet will
not be useful since generic stubs for QuerySets are not available and
not knowing the type of QuerySets is hardly useful for type checking.
2016-06-12 09:30:53 -07:00
Eklavya Sharma
39060aa221 zerver/models.py: Fix annotations related to Message. 2016-06-12 09:30:53 -07:00
Eklavya Sharma
2841aa642d Fix annotations related to make_safe_digest and hashes. 2016-06-12 09:30:53 -07:00
Eklavya Sharma
9020177418 zerver/models.py: Add annotations related to Stream and Client. 2016-06-12 09:30:53 -07:00
Eklavya Sharma
10f2ec043d Fix zerver.lib.utils.generate_random_token.
generate_random_token used to return a value of type six.binary_type
and its return type was annotated as `str`.  This commit fixes that
by making it return a value of type `six.text_type` and updating
the annotation accordingly.
Also fix clashing annnotations.
2016-06-12 09:30:53 -07:00
Eklavya Sharma
56d5785c2e zerver/models.py: Change some constants to unicode literals.
Change choices of UserProfile.avatar_sources and UserProfile.tutorial_status
from str literals to unicode literals.  This is done because these fields
are CharFields, which are of type `six.text_type`.  So the set of values
which they can take should also be of the type `six.text_type`.
Also fix clashing annotations.
2016-06-12 09:30:53 -07:00
Eklavya Sharma
0cc7a6583c zerver/models.py: Fix last_reminder_tzaware annotation.
Fix annotated return type of UserProfile.last_reminder_tzaware from
`str` to `Optional[datetime.datetime]`.
2016-06-12 09:30:33 -07:00
Eklavya Sharma
8acc51218e Fix realm emoji and realm filter annotations.
Change `str` to `text_type` in annotations in zerver/models.py
related to realm emoji and realm filters.
Also fix clashing annotations in zerver/lib/bugdown/__init__.py.
2016-06-12 09:25:42 -07:00
Eklavya Sharma
e68d99eb2e zerver/models.py: Make cache_keys text_type. 2016-06-12 09:25:32 -07:00
Babak
ad895eb690 Annotate zerver/views/report.py. 2016-06-11 18:42:37 -07:00
Vishnu Ks
77ec6217eb Add validation for private message recipients.
The function will reject messages where recipients aren't either a
member of the realm or a member of cross_realm_user_emails.

Fixes: #930.
2016-06-11 11:24:45 -07:00
Vishnu Ks
a717c7df18 Seperate extract PM recipients as function. 2016-06-11 11:22:22 -07:00
Tim Abbott
f44b227b85 Refactor getting cross-realm users into a function. 2016-06-11 11:22:22 -07:00
Eklavya Sharma
f82b28e835 zerver/lib/cache.py: Fix get_cache_backend's annotation. 2016-06-11 09:12:58 -07:00
Eklavya Sharma
0b2d1c30e9 zerver/lib/cache.py: Replace Any with appropriate models.
Due to a cyclic dependency issue, functions having models as parameters
were annotated as Any.
That issue is fixed by importing models inside an `if False:` block,
so that mypy sees them but they are not imported at runtime.
2016-06-11 09:12:58 -07:00
Eklavya Sharma
ff4e95d941 Improve generic_bulk_cached_fetch annotation using TypeVars. 2016-06-11 09:12:42 -07:00
Eklavya Sharma
d27a0e162a zerver/lib/cache.py: update_user_profile_caches return type is None.
In update_user_profile_caches, the return type in annotation was
marked as Any.  Change that to None because, nothing is being returned
in that function.
2016-06-11 09:11:52 -07:00
Eklavya Sharma
53084fe03c Use text_type as type of cache keys and update users.
This changes the type annotations for the cache keys in Zulip to be
consistently text_type, and updates the annotations for values that
are used as cache keys across the codebase.
2016-06-11 09:10:34 -07:00
Eklavya Sharma
d3b80d94a2 Use appropriate string types and correctly encode/decode them. 2016-06-11 17:34:23 +05:30
Eklavya Sharma
f18493f922 Add documentation about zerver/lib/str_utils.py. 2016-06-11 17:31:56 +05:30
Eklavya Sharma
6d29da8cee Add zerver/lib/str_utils.py.
str_utils.py has functions for converting strings from one type to
another.  It also has a TypeVar called NonBinaryStr, which is like AnyStr
except that it doesn't allow bytes.
2016-06-11 16:17:47 +05:30
Tim Abbott
ddd44189a9 Fix coverage reporting on GitHub homepage.
The previous Markdown syntax didn't work correctly on ReadTheDocs, and
now that we have Coveralls reporting backend test coverage as well,
describing our coverage as just "mypy static type" is no longer accurate.

Fixes #964.
2016-06-10 18:48:14 -07:00
Tim Abbott
062287d0b0 Coveralls: Add coverage reporting to backend test suite. 2016-06-10 17:20:00 -07:00
Tim Abbott
8b9c66aac5 Fix missing $ at end of webhook URL patterns. 2016-06-10 17:12:05 -07:00
Vishnu Ks
b926826ea1 Remove default_stream addition and deletion from update_stream_backend.
Default stream addition/removal is done via the /default_stream REST
endpoints.
2016-06-10 16:59:15 -07:00
Eklavya Sharma
85ef5900b4 docs/mypy.md: Add section on annotating strings. 2016-06-10 16:30:14 -07:00
Tim Abbott
c9ef726048 docs/mypy: Add note about Zulip's annotation goals. 2016-06-10 16:30:14 -07:00
Eklavya Sharma
a4c14cd448 Improve docs/mypy.md.
Add link to mypy cheat sheet.
Warn against modifying annotations to somehow make them pass on buggy code.

[Description expanded by tabbott]
2016-06-10 16:30:00 -07:00
Tim Abbott
110d278b86 Fix api/endpoints.html template.
This was apparently broken in the Jinja2 migration.
2016-06-10 15:14:50 -07:00
Tim Abbott
ec8b8cc5c0 Add warning at top of zulip.js about adding new things. 2016-06-10 10:22:24 -07:00
Tim Abbott
7c80456321 Fix and re-enable test_file_upload_authed.
Now that we have a working S3 mock and an effective way to toggle the
upload backend that Zulip is using, we can re-enable this important
end-to-end test of the Zulip S3 upload backend.
2016-06-09 23:07:24 -07:00
rahuldeve
fa13582ffb Serve uploaded files through get_uploaded_file in development.
Previously, uploaded files were served:
* With S3UploadBackend, via get_uploaded_file (redirects to S3)
* With LocalUploadBackend in production, via nginx directly
* With LocalUploadBackend in development, via Django's static file server

This changes that last case to use get_uploaded_file in development,
which is a key step towards being able to do proper access control
authorization.

Does not affect production.
2016-06-09 22:58:25 -07:00
Tim Abbott
719e5487b9 upload: Use classes to define S3/Local upload backends.
This has no functional changes; we just replace the old hacky
assignment of functions with assignment of the upload backend to a
variable.

I'm not totally happy with this, because we end up having to copy the
type annotations of the three methods 4 times each, but this should
make it a lot easier to test the (non-default-in-tests) S3 backend
using end-to-end tests, which would have caught
13bac1cc2a.

I expect we'll iterate on the interface over time; ideally, I'd like
all the code that checks LOCAL_UPLOADS_DIR to be inside upload.py, and
primarily in these classes.
2016-06-09 22:45:03 -07:00
Tim Abbott
13bac1cc2a Fix serving files uploaded to S3.
This was broken by the refactoring to realm_id_str in:
a261a6bbac.
2016-06-09 21:55:50 -07:00
rahuldeve
3e3462da0d Refactor zerver.lib.upload.upload_message_image_through_web_client.
upload_message_image_through_web_client -> upload_message_image_from_request
2016-06-09 21:09:12 -07:00
medullaskyline
39eaf02b40 Annotate zerver.views.webhooks.taiga. 2016-06-09 17:08:55 -07:00
Eklavya Sharma
286d23734a zerver/lib/cache.py: Remove unneeded return statements. 2016-06-09 16:57:11 -07:00
Vishnu Ks
f9f31b79d0 Make default_streams web controllable.
Fixes: #665
2016-06-09 15:24:32 -07:00
Caroline Liu
0c322403a6 Create common test function for select_item_via_typeahead. 2016-06-09 14:55:31 -07:00
Caroline Liu
60e5140406 Add warning for @all / @everyone.
* The warning contains a count of the number of people in the stream.
* An error appears if the warning is ignored and the user tries to
  send the message anyway.
* The message cannot be sent until the warning is acknowledged or @all
  / @everyone is removed.
* This only applies to stream messages and not private messages.

Fixes #853.
2016-06-09 14:38:58 -07:00
Umair Khan
08045241a7 Cache node_modules in Travis.
Fixes: #712
2016-06-09 14:36:22 -07:00
Tim Abbott
584887e588 lint: Require folding of } on same line in else if statements. 2016-06-09 14:05:34 -07:00
Tim Abbott
c35781d505 lint: Require folding of } on same line as else statements. 2016-06-09 14:02:49 -07:00
Tim Abbott
0c1b5006f7 lint: Check for space after if in javascript. 2016-06-09 13:47:12 -07:00
Tim Abbott
eba0d6339f lint: Require space after // in JS comments. 2016-06-09 13:44:24 -07:00
Tim Abbott
a09b950097 lint-all: Check for relative URLs in JSON calls from JS. 2016-06-09 11:59:40 -07:00
Tim Abbott
f9951bb1ca Fix uploading files when using Zulip in another language.
Apparently, relatively URLs in our javascript no longer work.
2016-06-09 11:57:29 -07:00
rahuldeve
ed83bb7f54 Refactor zerver.views.upload. 2016-06-08 09:49:14 -07:00
rahuldeve
e1a2660e70 Refactor realm_id to realm_id_str in url.py. 2016-06-08 09:49:14 -07:00
rahuldeve
23ff717bee Fix annotations: zerver.lib.upload. 2016-06-08 09:49:14 -07:00
Umair Khan
938291a922 Add run-dev.py test to Travis CI test suites.
Fixes #919
2016-06-08 14:10:37 +05:00
Tim Abbott
a829366733 util: Create and use is_pm_recipient helper function. 2016-06-07 21:58:45 -07:00
Tim Abbott
60f6616030 people.js remove: Fix case-sensitive email matching. 2016-06-07 21:58:45 -07:00
Tim Abbott
567c0796f9 Filter: Fix case-sensitive comparisons of email addresses.
Previously, a query containing capital letters might match nothing if
these code paths were ever activated.
2016-06-07 21:58:45 -07:00
Tim Abbott
b25562ca1d Add and use util.is_current_user helper function.
Previously, we were checking if a particular user was the current user
in dozens of places in the codebase, and correct case-insensitive
checks were not used consistently, leading to bugs like #502.
2016-06-07 21:58:44 -07:00
Givorenon
0bf2d171ae Fix fading of messages in dialog and users in side-bar.
Make comparison of emails in compose_fade.js and util.js
case-insensitive to fix fading of users and messages respectively.
2016-06-07 21:31:47 -07:00
Tim Abbott
e14732a12c Remove unused test_beankstalk_message function. 2016-06-07 21:27:29 -07:00
Tomasz Kolek
2ac9c792f3 test_hooks: Use an incoming webhook bot for webhook tests. 2016-06-07 21:27:04 -07:00
Tomasz Kolek
999093b227 Add new is_incoming_webhook bot type.
This type of bot is only able to send messages via webhook endpoints.
2016-06-07 21:23:35 -07:00
Hyunchel Kim
b0702c62fc Annotate zerver.views.messages partially. 2016-06-07 21:09:30 -07:00
Nathan Florea
6bcb6c3192 Removed some unused imports. 2016-06-07 18:13:58 -07:00
Nathan Florea
f11eee8b41 Remove redundant file open.
Calling open() with mode 'w' or 'a' will create a file if it doesn't exist,
while mode 'r' will cause an exception.  This can be easily tested with:
python -c 'open("test.tmp", "w")'
ls test.tmp
2016-06-07 18:10:44 -07:00
Vishnu Ks
d30ea0bc44 Move recent_subjects to stream_data. 2016-06-07 17:50:16 -07:00
Tim Abbott
760ff216ad realm emoji: Add description of the custom emoji feature in settings. 2016-06-07 16:24:07 -07:00
Evan Palmer
bd0fd61821 Annotate zilencer.error_notify.
Also fix the annotation of zilencer.views.report_error.

The `report` arguments are a Dict containing both strings and the
`more_info` sub-dictionary, so we type them as Dict[str, Any].

[tweaked by tabbott]
2016-06-07 13:44:56 -07:00
Conrad Dean
fe2c352ac0 ClientDescriptor: Pass inline sets, not lists, to do_gc_event_queues.
This allows us to more precisely type do_gc_event_queues.
2016-06-07 13:28:45 -07:00
Conrad Dean
d77c70220c send_event: Remove useless return value and annotate.
Detected by mypy.

[tweaked by tabbott to pass mypy check and remove annotations]
2016-06-07 13:27:40 -07:00
Conrad Dean
a4704ba8b2 event_queue: Fix deque values type annotation.
Event IDs in here are ints, as shown by the prune operation.
2016-06-07 13:05:46 -07:00
Tomasz Kolek
29ec2a328b Fix save in topic edit also saving message content edit box.
Fixes #932.
2016-06-07 12:55:58 -07:00
Umair Khan
5becd53414 Add tests for json_error and JsonableError. 2016-06-07 12:41:59 +05:00
Tim Abbott
bc2961d3ac Refactor file upload routes to their own file. 2016-06-06 16:09:05 -07:00
Vishnu Ks
f3a8962612 Replace make_dict() with stream.to_dict(). 2016-06-06 14:46:12 -07:00
gregmccoy
1844f1b054 Add button to exit the Zulip tutorial.
Fixes: #872.

[Tweaked by tabbott to fix focus and rename to "Exit tutorial".]
2016-06-06 14:38:11 -07:00
Tim Abbott
2595ce4a35 Annotate frontend_tests/run-casper. 2016-06-06 13:41:44 -07:00
Tim Abbott
be53c9e39e tests: Check for presence of typing in venv guard.
Since relatively few systems have the typing module, this makes the
checks for whether the user is properly running our test scripts in
the virtualenv more likely to trigger well.
2016-06-06 13:41:34 -07:00
Ernesto Vargas
ffb2f9e84b lint/tests: Give nice error message for common import failures.
This should make users much more likely to be able to debug issues
where they ran Zulip outside the Vagrant environment or virtualenv.

[error messages tweaked by tabbott]
2016-06-06 13:39:26 -07:00
Umair Khan
0ab6b99cbb Fix backend i18n bug.
`makemessages` escapes the `%` sign in `.po` files, but Jinja2 does
not unescape it while replacing the tranlation strings. In Jinja2,
there is an updated implementation of gettext available called
new-style gettext which handles escaping better; this commit switches
to using that.

Fixes #906.
2016-06-06 09:34:51 -07:00
Umair Khan
3092f509b0 Fix Handlebars translations.
Change file mapping between Transifex and Zulip. Fix the typo
in the translation file resource url for Chinese.
2016-06-06 09:30:56 -07:00
Evan Palmer
8afeb7d8ce Annotate webhooks/transifex.py, webhooks/yo.py. 2016-06-05 17:01:53 -07:00
Daw-Ran Liou
7f0709b65c Annotate zerver.views.webhooks.freshdesk
Change the comments into docstrings.
Modified the return type of parse_freshdesk_event to always return a
list of str.
2016-06-05 15:56:27 -07:00
Dalek-Sec
c457f551ea Annotate zerver/views/webhooks/crashlytics.py 2016-06-05 15:54:13 -07:00
medullaskyline
7e30de04ca Annotate zerver.views.webhooks.pingdom. 2016-06-05 15:52:53 -07:00
medullaskyline
4c1da236ad Annotate zerver.views.webhooks.pagerduty. 2016-06-05 15:47:33 -07:00
Daw-Ran Liou
4428287846 Annotate zerver.views.webhooks.stash. 2016-06-05 15:42:25 -07:00
Hyunchel Kim
b79cad0404 Annotate zerver.views.webhooks.teamcity 2016-06-05 15:11:45 -07:00
Hyunchel Kim
f226456675 Add type annotations for analytics/views.py.
Type of parameter for function `is_recent`(line no.812) is `datetime`.
MyPy errors out, however, when the parameter is defined as `datetime`.
To get around, type `Any` is used.
2016-06-05 15:04:24 -07:00
Daw-Ran Liou
26d067fc97 Annotate zerver.views.webhooks.pivotal. 2016-06-05 14:57:53 -07:00
medullaskyline
2369d48a9b Annotate zerver.views.webhooks.newrelic. 2016-06-05 14:52:20 -07:00
Evan Palmer
4bf81b58b4 Annotate zerver/views/webhooks/zendesk.py. 2016-06-05 14:50:52 -07:00
Hyunchel Kim
de34dd1187 Annotate travis webhoook function. 2016-06-05 14:46:26 -07:00
medullaskyline
158914aa98 Annotate zerver.views.webhooks.jira. 2016-06-05 14:36:39 -07:00
Hyunchel Kim
bc87685ea6 bitbucket: Correct return type in annotation. 2016-06-05 14:33:31 -07:00
Daw-Ran Liou
70f44c00b0 check_send_message: Replace args/kwargs with explicit args.
This lets us actually type-checks the various views that are using
check_send_message.
2016-06-05 14:30:38 -07:00
Tim Abbott
553ef81f92 Add lint rules for mypy type annotations. 2016-06-05 13:00:55 -07:00
Max
86fb6467e7 Add annotations to avatar.py, db.py, logging_util.py, unminify.py.
Also, fixed a a small type annotation in users.py because email must
be a string because emails don't support UTF-8 at this time (according
a comment in gravatar_hash in avatar.py).
2016-06-05 12:38:20 -07:00
medullaskyline
2855c285b4 Annotate zerver.forms. 2016-06-05 12:02:19 -07:00
Daw-Ran Liou
90a2dead46 Annotate zerver/views/webhooks/deskdotcom.py. 2016-06-05 11:53:44 -07:00
Deborah Hanus
a261a6bbac Annotate zerver/views/__init__.py.
Also fix typing errors in a few related files.

[with tweaks from tabbott]
2016-06-05 11:34:19 -07:00
Daw-Ran Liou
c9bb93b0d2 Annotate zerver/views/webhooks/beanstalk.py. 2016-06-05 10:54:23 -07:00
Tomasz Kolek
c5b56c15de Fix placement of EDITED in one line status messages.
Fixes #836.
2016-06-05 10:11:05 -07:00
Tim Abbott
15b2dd085e Annotate zerver.lib.test_runner. 2016-06-04 23:23:31 -07:00
Tim Abbott
1ca7c3378b Annotate zerver.lib.testing_mocks.
Also fix some annotations in bugdown to match.
2016-06-04 22:54:49 -07:00
Tim Abbott
157a3efb78 Annotate zerver.exceptions, zerver.filters, zerver.logging_handlers. 2016-06-04 22:51:18 -07:00
Conrad Dean
33dee43179 Annotate zerver/lib/socket.py.
Currently this uses a Union type for connection_id; we need to figure
out what actually sets that and what its type is and fix that later
(see https://github.com/zulip/zulip/issues/896).
2016-06-04 22:36:03 -07:00
Sumana Harihareswara
45b1893284 Convert architecture overview from rST to md for consistency.
Fixes: #668.
2016-06-04 22:27:00 -07:00
Sumana Harihareswara
6f59683324 Fix and clarify architecture overview. 2016-06-04 22:27:00 -07:00
pxhanus
e247d9783f Annotate zilencer/views.py. 2016-06-04 22:07:01 -07:00
Dalek-Sec
2bcf313a85 Added MyPy types to zerver/views/webhooks/codeship.py 2016-06-04 22:03:41 -07:00
acrefoot
7a5bbe040b Fix flaky casper test for messsage edits
.message_edit_notice is too broad of a selector to
test if your most recent edit has posted. Also
check if the currently selected message is the one
that's been edited.
2016-06-04 22:02:18 -07:00
medullaskyline
47c3ec1283 Annotate zerver.lib.upload. 2016-06-04 19:13:03 -07:00
Umair Khan
1bfe566c8d [i18n] Make Json error messages translatable. 2016-06-04 18:48:36 -07:00
Umair Khan
7057b2ae37 Add documentation for json_error and JsonableError.
Add documentation on how to make the strings passing through
json_error and JsonableError translatable.
2016-06-04 18:48:32 -07:00
acrefoot
0f960e04c4 Fix flaky casper test in admin page.
When you deactivate a user, visit another page, and then
come back, the user shows up in another table (the
"Deactivated Users" table), and no longer has the
strikeout styling of a recently deactivated user.

Using the strikeout class as a selector to test if the
user has been reactivated will of course not be a good
test, and if you have a slow machine, lose a
race condition.

When you deactivate a user, visit another page,
and then come back, the user shows up in another
table, and no longer has the strikeout styling
of a recently deactivated user. Using strikeout
class to test if the user has been reactivated
will of course not be a good test, and if you
have a slow machine, lose a race condition.
2016-06-04 18:34:27 -07:00
medullaskyline
c5f0d5b40a Annotate zerver.middleware. 2016-06-04 18:32:06 -07:00
Tim Abbott
9c5f15e89b models: Fix use of non-lazy ugettext at import time.
Was introduced in 03debdf82f.
2016-06-04 17:46:03 -07:00
Daw-Ran Liou
0265968ea2 Annotate zerver/views/user_settings. 2016-06-04 17:41:59 -07:00
James Porter
2a8e8129d1 Make emoji_dump delete old ttx files on start. 2016-06-04 17:05:48 -07:00
James Porter
f5f2d72178 Wrap main bit of emoji_dump.py in a main function. 2016-06-04 17:05:48 -07:00
James Porter
9d58624359 Minor reformatting of emoji_dump.py. 2016-06-04 17:05:48 -07:00
James Porter
d008d96597 Update Emoji set. 2016-06-04 17:05:48 -07:00
Reid Barton
cf93c8bce0 Annotate zerver/views/webhooks/bitbucket.py. 2016-06-04 17:02:59 -07:00
Daw-Ran Liou
8bbd93011d Annotate zerver/views/users.py. 2016-06-04 17:00:53 -07:00
medullaskyline
fcdcccb5df Annotate zerver.lib.digest. 2016-06-04 16:20:18 -07:00
Tim Abbott
d9d0515d3b Add mypy bug number for check_redis type: ignore. 2016-06-04 16:11:18 -07:00
Tim Abbott
f2320bf27f Fix populate_db send_messages annotation. 2016-06-04 16:11:14 -07:00
medullaskyline
7c2c7fb31c Annotate zerver/lib/bulk_create.py. 2016-06-04 15:51:05 -07:00
Tomasz Kolek
8411b2e574 Add Crashlytics integration. 2016-06-04 15:18:42 -07:00
Tomasz Kolek
093e5a96d4 Add Transifex integration.
Fixes: #810.
2016-06-04 14:52:57 -07:00
Taranjeet
c6cfd21bd4 Readme: Fix links for readme.dev and readme.prod.
Absolute links is necessary for readthedocs to properly
link to the files.
2016-06-04 14:15:08 -07:00
Tim Abbott
697125eeae Fix coveralls badge to point to the right branch. 2016-06-04 14:11:21 -07:00
Reid Barton
a0f906edf9 Add mypy coverage status to README.md. 2016-06-04 13:01:19 -07:00
Reid Barton
0b7852f081 Generate mypy coverage report for travis + coveralls. 2016-06-04 13:01:19 -07:00
Max
04e2745136 Annotate debug.py, initial_password.py, narrow.py, response.py.
Also, fixed up the annotations for tornadoviews to better align with
how narrows was defined as `Iterable[Sequence[str]]` rather than
`List[Tuple[str, str]]`.
2016-06-04 12:56:36 -07:00
medullaskyline
7b2db95d02 Annotate zerver/lib/ccache.py. 2016-06-04 12:19:34 -07:00
Tim Abbott
6fba0879a4 Annotate much of the rest of zerver/tests. 2016-06-04 11:53:20 -07:00
Tim Abbott
27e9d3f06b Annotate test_external and test_signup. 2016-06-04 11:53:20 -07:00
Tim Abbott
966375d74c Annotate test_events, test_realm_emoji, test_uploads. 2016-06-04 11:53:20 -07:00
Tim Abbott
f1d58e767b Annotate zerver/tests/test_subs.py.
This required a number of unique-related changes to test_helpers.
2016-06-04 11:53:10 -07:00
Tim Abbott
6f69053911 Annotate most of the rest of bugdown. 2016-06-04 11:35:29 -07:00
Max
c8dc033c3c Annotate camo.py, mandrill_client.py, query.py, session_user.py 2016-06-04 11:28:42 -07:00
Tim Abbott
a1a27b1789 Annotate most Zulip management commands. 2016-06-04 10:12:06 -07:00
Tim Abbott
c2bea0fa08 zulip_finish: Remove useless return statement. 2016-06-04 10:06:31 -07:00
Tim Abbott
ac3989c114 models: Add most missing type annotations. 2016-06-04 00:03:54 -07:00
David Adamec
9e8ea93d3d Add annotations for zerver/lib/validator. 2016-06-03 23:53:49 -07:00
David Adamec
4f3c85a20c Add type annotations to zerver/lib/rest. 2016-06-03 23:48:46 -07:00
Conrad Dean
e7f0698884 Annotate zerver/lib/notifications.py. 2016-06-03 23:45:29 -07:00
Tim Abbott
7fd2956f29 clear_followup_emails_queue: Rename confusing local variable. 2016-06-03 23:45:29 -07:00
medullaskyline
cb84f72f2d Annotate zerver/lib/html_diff.py. 2016-06-03 23:21:26 -07:00
Tim Abbott
2ec0114079 test_bugdown: Add tests for mentions. 2016-06-03 23:18:39 -07:00
Tim Abbott
cfff4f1d49 test_bugdown: Add a bugdown test for alert_words functionality. 2016-06-03 23:18:39 -07:00
Tim Abbott
8c757292cf test_bugdown: Add test for nonmatching realm filters. 2016-06-03 23:18:39 -07:00
Tim Abbott
3a0eb01dda test_messages: Fix huddle test failing when not on Internet. 2016-06-03 23:18:39 -07:00
Tim Abbott
e89730dc8f subject_links: Remove useless RealmFilter.DoesNotExist case. 2016-06-03 23:18:39 -07:00
Tim Abbott
68fba3579d test_bugdown: Add testing of subject_links feature. 2016-06-03 23:18:39 -07:00
gregmccoy
d77e8df3fa Add tests for zerver/views/realm_emoji.py. 2016-06-03 23:12:53 -07:00
Tim Abbott
03debdf82f Fix malformed error message when creating invalid Realm Emoji.
Thanks to Greg McCoy for his help finding this bug.
2016-06-03 23:12:36 -07:00
David Adamec
8ad20e9775 mypy type annotations for zerver/lib/utils 2016-06-03 22:58:15 -07:00
Tim Abbott
a0b332d6cf Add missing dependency decorator of ipython. 2016-06-03 19:29:54 -07:00
Tim Abbott
1552b9308b Fix apnsclient import to match version 0.1.8 used in production.
Apparently, apnsclient moved Connection to a different module between
0.1.8 and 0.2.1.
2016-06-03 19:28:36 -07:00
Tim Abbott
9b86fa96e7 Downgrade python-apnsclient in development to match prod. 2016-06-03 19:27:34 -07:00
Tim Abbott
e7d9b28dfc install-mypy: Pass --upgrade to correctly handle new mypy versions. 2016-06-03 19:11:32 -07:00
Max
0f4673ae3b Add type annotation to mention.py, redis_utils.py, timestamp.py, user_agent.py
Some functions in models.py had input typed as int when they needed to be typed as datetime.datetime
2016-06-03 19:00:16 -07:00
Max
1148f6ff8a Rename timestamp kwarg in to_presence_dict to dt
It is not a timestamp, it is a datetime object. This is better ducktyping
2016-06-03 19:00:16 -07:00
Tim Abbott
5d5f1f46dc Upgrade mypy and typed_ast to latest versions. 2016-06-03 18:59:55 -07:00
Tim Abbott
654bd663aa bugdown: Add annotations for a few more functions.
This resolves the issue with Typeshed #244 by making `upload_re` start
with `ur`.
2016-06-03 18:11:53 -07:00
Tim Abbott
f97b025a33 push_notifications: Fix incorrect Connection import. 2016-06-03 18:11:53 -07:00
medullaskyline
303bd21068 Annotate zserver.lib.push_notifications. 2016-06-03 17:45:54 -07:00
Oren Leaffer
2916fb30cb bugdown: add some type annotations.
Had to add some "type: ignore" because the pattern used in match
doesn't affect the type returned. A fix for this issue has been pushed
to typeshed - https://github.com/python/typeshed/pull/244
2016-06-03 17:03:52 -07:00
medullaskyline
2213a9f41f Annotate zerver/lib/cache_helpers.py 2016-06-03 16:34:30 -07:00
Sumana Harihareswara
8c2382deeb De-duplicate three sections of architecture overview. 2016-06-03 12:56:31 -07:00
Conrad Dean
7f61a5e862 Add type annotations to zerver.lib.test_helpers. 2016-06-03 12:17:26 -07:00
Sumana Harihareswara
4a10923bf1 Add architectural overview documentation.
Fixes: #453.
2016-06-03 11:54:02 -07:00
Max
a6e60419c4 Add types to confirmation/views.py and zerver/tornadoviews.py 2016-06-03 11:26:30 -07:00
Vishnu Ks
4fd569f910 Change add_default_stream method from PATCH to PUT.
This is more consistent with our other routes.
2016-06-03 09:52:51 -07:00
Nathan Florea
85c0da67a4 Changed make_request lambda to more readable function. 2016-06-03 09:17:04 -07:00
Nathan Florea
04c71fadc6 More removal of mutable default arguments.
I've left a few that clearly aren't being passed and aren't being mutated, but
I think I've gotten the rest of them.
2016-06-03 09:17:04 -07:00
Nathan Florea
5fe9076631 Remove some mutable default arguments.
These ones don't fix any bugs, because the mutable arg is never passed
outside of the callable or mutated.  But it's good practice to not use
them in case those invariants are changed in the future.
2016-06-03 09:16:56 -07:00
Nathan Florea
2e4283f60a api: Remove some mutable default arguments.
This could be more succinct with a conditional expression, but this is
easier to read.
2016-06-03 09:16:52 -07:00
Ashish Kumar
9b990e3bd0 Type annotation of zerver/views/alert_words.
[Tweaked by tabbott to annotate the REQ variables the new way]
2016-06-03 08:07:58 -07:00
Ashish Kumar
31bf6b8259 Type annotation of zerver/models.py
[Substantially revised by tabbott]

This probably still has some bugs in it, but having mostly complete
annotations for models.py will help a lot for the annotations folks
are adding to other files.
2016-06-02 23:28:34 -07:00
Tim Abbott
37015fd7c5 Run mypy on zerver/lib/test_auth_backends.py. 2016-06-02 23:01:15 -07:00
Tim Abbott
8cef9675c8 Run mypy on zerver/lib/test_events.py. 2016-06-02 23:00:04 -07:00
Tim Abbott
e6d2b0cdbc Run mypy on zerver/lib/test_unread.py. 2016-06-02 22:59:00 -07:00
Tim Abbott
f3b07ee9aa Run mypy on zerver/lib/test_subs.py. 2016-06-02 22:57:07 -07:00
Tim Abbott
1bdbdd1110 Run mypy on test files where it already passes. 2016-06-02 22:53:28 -07:00
Umair Khan
072551a94e Fix most redownloading in 'vagrant reload --provision'.
Fixes #264.
2016-06-02 22:32:56 -07:00
Oren Leaffer
c2ce5119c6 Annotate zerver.views.tutorial. 2016-06-02 18:49:27 -07:00
Conrad Dean
f8f2f45410 run-mypy: Add --linecount-report and --disallow-untyped-defs flags. 2016-06-02 18:45:52 -07:00
acrefoot
cf15b0b4e6 Fix hanging nc and 'invalid wait time' error on Trusty.
Apparently, 0 isn't a supported wait time value in some versions of nc.
2016-06-02 18:02:13 -07:00
Rachel Kelly
df36216914 Change instances of 'coworkers' to 'users'.
In order to genericize use of Zulip outside companies,
    all instances of coworkers have been changed to users.
    NOTABLE EXCEPTION: When the Zulip instance is domain-
    locked, the reference to coworkers remains.  The reason
    for this is twofold: first, the majority of Zulip instances
    which require a particular domain will be locked to a
    company, and second, the template variable for the domain
    necessary should be added to the alert so it is clear
    to the user what the domain needs to be for access.

Fixes: #861.
2016-06-02 16:05:27 -07:00
Pei-Wei Wu
8d2733ae8c Add mypy type annotations to zerver/views/streams.py. 2016-06-02 15:44:43 -07:00
Ashley Dunn
7826aa7e7f Type annotation of zerver/views/realm_emoji. 2016-06-02 14:01:28 -07:00
John Hampton
d4dbcb80cc README.prod.md: Remove redundant unpacking of the tarball. 2016-06-02 10:32:52 -07:00
Taranjeet
a45bde7822 Docs: Fix typos in docs. 2016-06-02 10:31:41 -07:00
Ashish Kumar
cad342aff6 Correct annotation of generic_bulk_cached_fetch in zerver/lib/cache.py.
Previously, object_ids was tagged as an int, but it is called from
models.py with a string, so we make it an Any.
2016-06-01 14:00:49 -07:00
Tim Abbott
44929523d6 Harden extraction of AUTH_LDAP_BIND_PASSWORD. 2016-05-31 15:06:43 -07:00
Tim Abbott
dac8f7d923 Fix buggy extraction of EMAIL_GATEWAY_PASSWORD.
EMAIL_GATEWAY_PASSWORD has a value of None in the defaults list, so it
will never fail to be in vars().
2016-05-31 15:06:17 -07:00
Tim Abbott
fbc30c2914 test-all: Add a call to run-mypy.
Using mypy to check the codebase is stable and useful enough that it's
worth including it in the default tests run locally.
2016-05-31 15:00:15 -07:00
Tim Abbott
c5b495b775 Update changelog with important changes since last release. 2016-05-31 11:39:47 -07:00
Sumana Harihareswara
cb6ae3a766 Add anchor tags to README.md. 2016-05-31 11:27:21 -07:00
Tim Abbott
d056b5601b docs: Add python-tyoing to RTD dependencies.
This should fix the RTD build having been broken since
d9c4be87d1.
2016-05-31 11:19:49 -07:00
Sumana Harihareswara
337155f280 Remove rST files to replace with Markdown.
Currently (https://github.com/rtfd/recommonmark/issues/3)
the recommonmark bridge (which allows Sphinx to read
Markdown) does not support tables, so the directory structure
doc is now a bulleted list instead of a set of tables.
2016-05-31 10:55:49 -07:00
Sumana Harihareswara
e0bc57ddb1 Rearrange docs table of contents for coherence.
The order and structure of the Read The Docs documentation
was fairly arbitrary; here's a suggestion for how to change
its information architecture so it's more useful to a new
contributor. This adds a short Zulip overview, and a table
of contents and code contribution intro for new contributors.

Fixes: #668.

Signed-off-by: Sumana Harihareswara <sumanah@panix.com>
2016-05-31 09:07:09 -07:00
Sumana Harihareswara
3029b3681f Rearrange sections of testing doc for coherence. 2016-05-31 09:05:38 -07:00
Sumana Harihareswara
f65778f1e2 Improve sub-headings in documentation.
Signed-off-by: Sumana Harihareswara <sumanah@panix.com>
2016-05-31 09:05:38 -07:00
Sumana Harihareswara
86f7695b8c Fix style, formatting in Bugdown docs. 2016-05-31 08:56:58 -07:00
Sumana Harihareswara
ad644afa97 Improve code style guidelines. 2016-05-31 08:56:58 -07:00
Sumana Harihareswara
3631cf3078 Add links in front end build process doc.
Signed-off-by: Sumana Harihareswara <sumanah@panix.com>
2016-05-31 08:56:58 -07:00
Tomasz Kolek
0820ab591a Refresh page when message with /me is edited.
Fixes: #163.

Thanks to Catherine Nguyen (@cnguye11) for her work on this.
2016-05-31 08:29:07 -07:00
Tim Abbott
3ed78eb746 docs/testing: Clean up discussion of rebuilding database. 2016-05-31 07:48:00 -07:00
Christie Koehler
e06492ec3a Improve first-time contributor docs.
Fixes #747. Fixes #748.

This updates README.dev.md to include clear, step-by-step instructions
for setting up the Zulip dev environment Windows 10, OS X El Capitan,
Ubuntu 14.04 Trusty, and Ubuntu 16.04 Xenial. It is aimed at first-time
contributors.

I tested these instructions multiple times on each of the target
systems.

Also added is a "trobleshooting and common errors" section which
documents the most common errors contributors are likely to encounter
during setup and how to fix them.

Improvements based on feedback from @timabbott.

- Fixes whitespace issues so linter will pass.
- Updates memory requirement.
- Re-orders so operating systems are listed alphabetically.
- Updates headings to be clearer.
- Updates and adds ToC entries for clarity.
- Adds screen shot of Zulip dev environment running in browser.
- Adds details about using dev environment, including about logging.
- Misc other minor changes for clarity.
- Adds a stub for docs/logging.md
- Adds details about configuring Cygwin for native symlinks.
2016-05-31 07:47:45 -07:00
Umair Khan
bd4e471706 Check json_error and JsonableError in linter.
Mainly the check is to ensure that all the strings that pass through
these two functions are captured by `makemessages`.
2016-05-31 07:40:42 -07:00
Umair Khan
08fbd57245 [i18n] Make error messages translatable.
Make all strings passing through `json_error` and `JsonableError`
translatable.

Fixes #727
2016-05-31 07:40:42 -07:00
Umair Khan
4b28fcd2f3 Add option to linter to exclude lines from files. 2016-05-31 07:40:42 -07:00
Tim Abbott
ab2d325a08 Update production default streams to be less engineering-centric. 2016-05-31 07:38:25 -07:00
Vishnu Ks
100d885f23 Change default announcement stream to announce.
Fixes #788.
2016-05-31 07:38:07 -07:00
Tim Abbott
960144a49e Desupport using uninstantiated REQ with has_request_variables.
This makes life difficult for doing static type annotations, and
didn't make the code look that much better anyway.
2016-05-31 07:31:15 -07:00
Tim Abbott
41336f3782 lint-all: Check for use of '== None'. 2016-05-31 07:02:04 -07:00
Umair Khan
9a57176ad6 Do shallow testing of backend templates.
Just render the templates without the actual workflow to see if they
don't return a 500 error; this lets us catch various classes of
template bugs automatically.

Fixes #784.
2016-05-31 05:42:17 -07:00
Umair Khan
c884559ec6 Show templates rendered report.
Add two options to the `test-backend` script:

1. verbose
    If given the `test-backend` script will give detailed output.
2. no-shallow
    Default value is False. If given the `test-backend` script will
    fail if it finds a template which is shallow tested.
2016-05-31 16:46:11 +05:00
Umair Khan
daf3d51d4b Send 'template_rendered' signal from Jinja2.
Send the signal only under DEBUG=True just like Django.
2016-05-31 14:31:13 +05:00
Umair Khan
29859c191d Call url correctly from password_reset_email.txt.
In Jinja2 the url function is called differently. We can't give keyword
arguments directly instead we need to pass them through kwargs argument.
2016-05-30 21:05:03 -07:00
Tomasz Kolek
ff4e92dc3d settings: change tab indentation to space. 2016-05-30 20:16:00 -07:00
Greg Price
436499a129 Clean up some relative-path handling in lister using Git magic
This lets us cut out the line which hard-codes how deeply nested in
the tree the `run-mypy` script is, making it simpler to borrow these
scripts in other projects.
2016-05-30 20:01:37 -07:00
Tomasz Kolek
8e144a1f57 Add zip and absoulte_import to pass py3k test. 2016-05-30 22:28:05 +02:00
Tim Abbott
baec0f12cf Add a proper annotation for REQ in streams.py. 2016-05-30 11:41:16 -07:00
Reid Barton
8c6afac7cd Add a stub file for request.py.
This stub file allows us to annotate view functions using the actual
types present in the bodies of the functions, rather than everything
having the type REQ.
2016-05-30 11:28:53 -07:00
Tim Abbott
572c69f3c2 Move REQ and friends to their own module. 2016-05-30 11:24:17 -07:00
Eklavya Sharma
48e7e1a2a1 zerver/lib/actions.py: Rename stream_name to stream.
In function bulk_add_subscriptions, some variables were named
`stream_name` but their type is Stream, not a string.  Rename
those variables to `stream`.
2016-05-30 09:52:59 -07:00
Reid Barton
ff845ebb96 Make tools/install-mypy exit on error. 2016-05-30 09:49:45 -07:00
Tim Abbott
1b59b6826a docs/code-style.rst: Update and clarify shebang rules. 2016-05-29 05:07:50 -07:00
Eklavya Sharma
94e4b39112 Replace python2.7 by python everywhere. 2016-05-29 05:03:08 -07:00
Eklavya Sharma
149938d468 Change shebangs from python2.7 to python. 2016-05-29 05:03:08 -07:00
Eklavya Sharma
1bb6a0db4c Annotate zerver/lib/actions.py. 2016-05-29 04:26:17 -07:00
Eklavya Sharma
2308107805 zerver/lib/actions.py: Use unicode literals.
Convert some strings literals to unicode strings by prefixing with `u`.
2016-05-29 04:26:17 -07:00
Eklavya Sharma
b74f603682 zerver/lib/actions.py: Rename variables and add/edit comments. 2016-05-29 04:26:17 -07:00
Eklavya Sharma
efab224bd1 zerver/lib/actions.py: Remove unneeded return {} statements. 2016-05-29 04:26:17 -07:00
Eklavya Sharma
a2b48f05e5 zerver/lib/actions.py: Fix return values. 2016-05-29 04:26:17 -07:00
Vishnu Ks
dc060248b4 Add instruction to check screenshot of failed tests. 2016-05-28 23:27:24 +05:30
Vishnu Ks
31968f668c Correct frontend_test script path. 2016-05-28 23:23:39 +05:30
Vishnu Ks
fea5ed5b60 Remove unread_subjects from check-all.js
unread_subjects is not used by other modules.
2016-05-27 01:03:21 -07:00
Vishnu Ks
51c86a8e2e Move get_private_message_recipient to message_store.js 2016-05-27 01:03:21 -07:00
Vishnu Ks
89d743787e Move recenter_view to viewport.js. 2016-05-27 01:03:21 -07:00
Vishnu Ks
4be20c4b4a Move scroll_to_selected to navigate.js. 2016-05-27 01:03:21 -07:00
Vishnu Ks
e329c9e0f5 Move maybe_scroll_to_selected to navigate.js. 2016-05-27 01:03:21 -07:00
Vishnu Ks
dc577343fe Move last_viewport_movement_direction to viewport. 2016-05-27 01:03:21 -07:00
Umair Khan
0278ce9102 Move tools/py3_test_reqs.txt to tools/setup/.
Fixes #708
2016-05-26 18:43:24 +05:00
Umair Khan
57f477dd8b Move tools/install-phantomjs to tools/setup/. 2016-05-26 18:28:14 +05:00
Umair Khan
1161862b07 Move tools/emoji_dump to tools/setup/. 2016-05-26 18:28:14 +05:00
Umair Khan
b85526576a Move tools/postgres-init-dev-db to tools/setup/. 2016-05-26 18:28:10 +05:00
Umair Khan
b0991966ab Move tools/postgres-init-test-db to tools/setup/. 2016-05-26 18:28:05 +05:00
Umair Khan
d425e05a02 Move tools/generate-fixtures to tools/setup/. 2016-05-26 17:54:32 +05:00
Umair Khan
8335bd672f Move tools/generate-test-credentials to tools/setup/. 2016-05-26 17:54:28 +05:00
Umair Khan
d5f3a82284 Move tools/download-zxcvbn to tools/setup. 2016-05-26 16:05:23 +05:00
Eklavya Sharma
09400a7e50 End compile-handlebars-templates gracefully.
Catch KeyboardInterrupt from tools/compile-handlebars-templates,
print a message and exit when running in forever mode.
2016-05-25 16:06:35 -07:00
Eklavya Sharma
1ea6171179 Fix an annotation in zerver/lib/cache.py.
This is done to make annotations in zerver/lib/actions.py work correctly.
2016-05-25 15:11:48 -07:00
Eklavya Sharma
d9c4be87d1 Make docs/conf.py pass mypy check. 2016-05-25 15:04:39 -07:00
Eklavya Sharma
30892b2f99 Make makemessages.py pass mypy check. 2016-05-25 15:04:39 -07:00
Eklavya Sharma
ea52fc05ed Make zproject/urls.py pass mypy check. 2016-05-25 15:04:39 -07:00
Eklavya Sharma
1c04560def Re-enable pyflakes in linter and remove python 3 pyflakes errors. 2016-05-25 19:25:13 +05:30
Eklavya Sharma
1a6257394c Make tools/lint-all run on python 3.
Since pyflakes catches some extra errors in python 3, disable
pyflakes for now.
2016-05-25 19:23:13 +05:30
Eklavya Sharma
3185b7e750 Remove unneeded imports from tools/lint-all. 2016-05-25 19:12:09 +05:30
Eklavya Sharma
459c6640bf Fix type annotations in zerver/lib/alert_words.py. 2016-05-24 14:12:11 -07:00
Eklavya Sharma
95d059bfb3 Fix typo in zerver/lib/actions.py. 2016-05-24 14:12:11 -07:00
Eklavya Sharma
c800c87d2d Remove __pycache__ in tools/clean-repo. 2016-05-24 13:43:49 -07:00
Eklavya Sharma
b6bd5445bc End puppet/.../process_fts_updates gracefully.
Catch KeyboardInterrupt in puppet/zulip/files/postgresql/process_fts_updates,
print a message and exit.
2016-05-24 13:28:05 -07:00
Eklavya Sharma
b210727e5c Enable running tools/run-mypy on a subdirectory.
Previously tools/run-mypy could not run on a subdirectory properly
because run-mypy assumed exclude files to be in that subdirectory.
2016-05-24 13:24:15 -07:00
Eklavya Sharma
bd63caed96 Fix exclude startegy in tools/lister.py.
Previously lister.py used to check whether the exclude path is a
substring of a path being considered.  So it would fail when the
exclude path is an absolute path or uses '..' or '.'.
2016-05-24 13:24:15 -07:00
Eklavya Sharma
508a080e08 do_change_bot_type: Add update_fields to user_profile.save(). 2016-05-24 13:21:44 -07:00
Eklavya Sharma
f3e25c68c7 Prevent tools/travis/mypy from failing silently.
Also improve the format of tools/travis/mypy's output.
Also add those files to the exclude list which are failing mypy check.
2016-05-21 12:37:04 +05:30
Umair Khan
ac13187d76 Add translation tags to the templates.
Fixes #726
2016-05-19 22:58:26 -07:00
Umair Khan
82b5d9304b [third] Integrate i18next with Handlebars 2016-05-19 22:58:25 -07:00
Tim Abbott
da69949ccd requirements: Add ipython dependencies. 2016-05-19 22:55:55 -07:00
Tomasz Kolek
8c18b8947f Add bot_type field to UserProfile.
This is intended to support creating different types of bots with
potentially limited permissions.
2016-05-19 22:37:37 -07:00
Paul Traylor
06bc1007fd Add missing \ in CentOS setup instructions. 2016-05-19 19:47:53 -07:00
Tim Abbott
cadbe64265 Fix venv files being included in coverage reports in CI.
e4707af2e2 didn't correctly deal with
the different path for the venv cache in Travis CI.
2016-05-19 10:25:56 -07:00
Tim Abbott
e4707af2e2 test-backend: Fix venv files being included in coverage reports. 2016-05-19 09:36:53 -07:00
Umair Khan
f9bbc5d6ff Enable i18n support in URL configuration.
This supports i18n using all of the following:
- I18N urls
- Session
- Cookie
- HTTP header
2016-05-19 08:33:30 -07:00
Umair Khan
94b2af76f9 Add language mapping for Transifex, Django recognizes zh_CN.
See https://code.djangoproject.com/ticket/18419 for furhter details.
2016-05-19 08:30:56 -07:00
Vishnu Ks
425363ced4 Fix non determinism bug in casper tests.
This manifested as "ReferenceError: Can't find variable: message_list"
on random tests in the Casper test suite.
2016-05-19 08:27:46 -07:00
Tim Abbott
b01196db86 to_log_dict: Add sender_id to logged fields. 2016-05-18 23:02:43 -07:00
Kartik Maji
3d77aa49db Add subscribe button in narrowed view when stream has no messages.
A temporary message appears on successful subscription, with a button
offering to unsubscribe in case the user subscribed by accident.
2016-05-18 20:06:30 -07:00
Kartik Maji
206452c867 Add stream subscription button added narrowed views.
Fixes: #273
2016-05-18 20:06:23 -07:00
Umair Khan
e56d3196ef Update provisioning/release scripts to build .mo files.
We need to update provision.py to compile the messages files, since
they are needed for the new i18n tests.  And of course we need to
include the .mo files in release tarballs; there's a bit of complexity
there around how the tarball archives are created.
2016-05-18 19:30:00 -07:00
Tim Abbott
f35327d148 Add po files imported from Transifex. 2016-05-18 19:03:56 -07:00
Umair Khan
b170b47465 Remove dot from django.po in .tx/config. 2016-05-18 18:59:30 -07:00
Umair Khan
e6d33e8834 jslint: Fix typo. 2016-05-18 18:58:06 -07:00
Aristeidis Fkiaras
3ee210d9e8 Add setting to only allow admins create new streams.
Fixes: #691.

Thanks to Preston Hansen for work on this feature!
2016-05-18 18:53:13 -07:00
Tim Abbott
e781136132 Fix subscribing to existing streams when can_create_streams=False.
Previously, a user with can_create_streams=False would be incorrectly
unable to subscribe to streams, whether the streams previously existed
or not.
2016-05-18 18:47:24 -07:00
Tomasz Kolek
c4254497b2 Add WebhookTestCase abstract class for writing webhook tests.
This cuts a ton of code duplication and semi-duplication between the
webhook tests, and thus should make it a lot easier to write new ones.
2016-05-18 14:37:31 -07:00
Eklavya Sharma
016a2faa23 Make zproject/local_settings.py pass mypy check. 2016-05-18 17:10:18 +05:30
Eklavya Sharma
54759be785 Make zproject/local_settings_template.py pass mypy check. 2016-05-18 17:10:18 +05:30
Eklavya Sharma
70a94a5b23 Expand zproject/ in mypy exclude list. 2016-05-18 17:10:18 +05:30
Eklavya Sharma
6606c30355 Remove zilencer/models.py from mypy exclude list.
zilencer/models.py no longer gives an error on type checking with
mypy.
2016-05-18 17:10:18 +05:30
Eklavya Sharma
7c77522ce4 Make zerver/middleware.py pass mypy check.
This was done by reporting python/mypy#1540 and upgrading to the
latest version of mypy which has the fix for this.
2016-05-18 17:10:18 +05:30
Eklavya Sharma
98afe000ee Make zerver/lib/statistics.py pass mypy check. 2016-05-18 17:10:18 +05:30
Eklavya Sharma
0dcd8b387d Make zerver/lib/bugdown/fenced_code.py pass mypy check. 2016-05-18 17:10:17 +05:30
Eklavya Sharma
3441f0848c Annotate pg_backup_and_purge.py. 2016-05-18 17:10:17 +05:30
Eklavya Sharma
66bb6394e5 Make api/zulip/__init__.py pass mypy check. 2016-05-18 17:10:17 +05:30
Eklavya Sharma
46757f07bf Make zerver/lib/actions.py pass mypy check. 2016-05-18 17:10:17 +05:30
Eklavya Sharma
16067b7013 Make zerver/views/webhooks/jira.py pass mypy check. 2016-05-18 17:10:17 +05:30
Sumana Harihareswara
5f053e0047 Add remaining codebases to README.md.
The README should link to all the Zulip codebases. Also, it makes
sense to split up app code from integration and other glue code.

Fixes: #674.
2016-05-17 16:56:46 -07:00
Sumana Harihareswara
3d267a5438 Add doc-building dependencies to requirements.txt.
Fixes: #794.
2016-05-17 12:21:25 -07:00
Tim Abbott
b38913c8f9 Upgrade sphinx version used in ReadTheDocs.
According to https://github.com/spatialaudio/nbsphinx/issues/26, this
should fix support for mixing rST and markdown in our docs.

Fixes #668.
2016-05-14 14:27:21 -07:00
Sumana Harihareswara
34d2c505e9 Fix typos in README.md. 2016-05-13 22:18:20 -07:00
Tim Abbott
c3985520e5 webhooks: Remove unnecessary get_client imports. 2016-05-13 12:25:12 -07:00
Tomasz Kolek
db7ea8b484 Move getting client to api_key_only_webhook_view.
This decreases the amount of convention developers need to understand
in order to write a new webhook integration.
2016-05-13 12:22:38 -07:00
Tim Abbott
d55c3bd142 Add npm-debug.log to gitignore. 2016-05-12 16:32:51 -07:00
Tim Abbott
12b32d3889 check-py3: Display git status --porcelain output. 2016-05-12 16:30:58 -07:00
Tim Abbott
aa7ff158b6 Reduce development environment RAM requirements by 750MB.
Since we merged cd2348e9ae more than a
month ago and haven't seen any noticable regresions as a result, it's
reasonable at this point to do a corresponding decrease in our
documented RAM requirements for the Zulip development environment.
2016-05-12 16:12:43 -07:00
Tim Abbott
e7cb1e3f92 README.dev: Make 'official Zulip PPA' link to the PPA. 2016-05-12 15:38:02 -07:00
Tim Abbott
efd24b374e analytics: Fix cnts variable reuse with different type.
Found using mypy.
2016-05-12 14:07:32 -07:00
Sumana Harihareswara
038c1ea20f Add integration project links to README.
The README should link to all Zulip-specific open source projects
so users know where to file bugs and code contributors can pitch
in.

Fixes: #674.
2016-05-12 13:45:20 -07:00
Tomasz Kolek
f486e47d4d Change CircleCI logo on /integrations to leave off the name.
The name is already present in the label just below.
2016-05-12 13:14:18 -07:00
Umair Khan
99b73c2728 digest emails: Fix typo in remaining_unread_pms_count.
This error likely caused this feature to never trigger.
2016-05-12 13:09:37 -07:00
Umair Khan
dfc58b0ed0 Upgrade digest email templates to Jinja2.
Fixes: #780
2016-05-13 01:01:28 +05:00
Tim Abbott
60722a8fce Integration guide: Add a note about spelling integraiton names. 2016-05-11 21:19:15 -07:00
Tomasz Kolek
eeeb4d0c92 Add CircleCI integration.
Fixes: #617.
2016-05-11 21:17:37 -07:00
Tom
014fcf7570 README.dev.md: Add PPA instructions to get tsearch-extras.
Fixes #109.
2016-05-11 16:22:53 -07:00
Sumana Harihareswara
c270b94b21 Fix formatting, grammar, and style in Yo integration docs. 2016-05-10 21:34:05 -07:00
Sumana Harihareswara
4c529cdf37 Update Getting Started With Hubot doc link. 2016-05-10 20:54:28 -04:00
Bert Muthalaly
261dac25a5 Fix skipping to latest messages (fast_forward_pointer).
The refactoring in b8ec8f5ef0 had a
slightly wrong URL.
2016-05-10 17:24:42 -07:00
Tim Abbott
2409ac9b2f cache: Add type annotations to active_*_dict_fields. 2016-05-10 11:48:03 -07:00
Tim Abbott
f2aee961e1 test_auth_backends: Fix unused variables. 2016-05-10 11:46:39 -07:00
Tim Abbott
92bec8cfea Merge Zulip 1.3.12 security release. 2016-05-10 11:32:26 -07:00
Tim Abbott
90634356cb Add changelog for Zulip 1.3.12 release. 2016-05-10 09:51:49 -07:00
Tim Abbott
9b65464b6b logout_all_users: Add option to logout deactivated users. 2016-05-10 09:50:57 -07:00
Tim Abbott
393159bbd8 queue: Disable RabbitMQ heartbeat in BlockingConnection.
Fixes #741.
2016-05-10 09:50:57 -07:00
Tim Abbott
6f282581f7 requirements: Upgrade pika to version 0.10.0.
This is needed to fix RabbitMQ heartbeat issues that cause connections
to drop (#741).  It's also relevant for Python 3 support.
2016-05-10 09:50:57 -07:00
Tim Abbott
d82e44ecd0 queue: Refactor Pika credentials code to be a bit cleaner. 2016-05-10 09:50:57 -07:00
Tim Abbott
620debc5fd Change PrincipalError to return status code 403 by default. 2016-05-10 09:50:57 -07:00
Tim Abbott
85c64c9f93 zulip_login_required: Add checks for active users and realms.
Like the recent change blocking JSON endpoints for deactivated users
and users in deactivated realms, this change is a hardening
improvement.  Those users should be unable to get an active session
anyway, but if somehow one is leaked, this means they won't be able to
access any user data.
2016-05-10 09:50:57 -07:00
Tim Abbott
be216506a9 Improve api_fetch_api_key error messages.
Previously, api_fetch_api_key would not give clear error messages if
password auth was disabled or the user's realm had been deactivated;
additionally, the account disabled error stopped triggering when we
moved the active account check into the auth decorators.
2016-05-10 09:50:57 -07:00
Tim Abbott
52ddd500f0 Add tests for authentication backends. 2016-05-10 09:50:57 -07:00
Tim Abbott
38c82083de Add test suite for deactivated users. 2016-05-10 09:50:57 -07:00
Tim Abbott
df7466e893 Add test suite for deactivate realms. 2016-05-10 09:50:57 -07:00
Tim Abbott
76814f37a3 decorators: Block access to JSON endpoints for deactivated users.
While in theory users should be unable to get a valid session in order
to access these endpoints in the first place, this provides an extra
layer of hardering to prevent a deactivated user with a session from
accessing data via the old-style JSON API.
2016-05-10 09:50:57 -07:00
Tim Abbott
b28b3cd65c CVE-2016-4427: Fix access by deactivated realms/users.
The security model for deactivated users (and users in deactivated
realms) being unable to access the service is intended to work via two
mechanisms:

* All active user sessions are deleted, and all login code paths
  (where a user could get a new session) check whether the user (or
  realm) is inactive before authorizing the request, preventing the
  user from accessing the website and AJAX endpoints.
* All API code paths (which don't require a session) check whether the
  user (and realm) are active.

However, this security model was not implemented correctly.  In
particular, the check for whether a user has an active account in the
login process was done inside the login form's validators, which meant
that authentication mechanisms that did not use the login form
(e.g. Google and REMOTE_USER auth) could succeed in granting a session
even with an inactive account.  The Zulip homepage would still fail to
load because the code for / includes an API call to Tornado authorized
by the user's token that would fail, but this mechanism could allow an
inactive user to access realm data or users to access data in a
deactivated realm.

This fixes the issue by adding explicit checks for inactive users and
inactive realms in all authentication backends (even those that were
already protected by the login form validator).

Mirror dummy users are already inactive, so we can remove the explicit
code around mirror dummy users.

The following commits add a complete set of tests for Zulip's inactive
user and realm security model.
2016-05-10 09:50:48 -07:00
Tim Abbott
b31ac1eca9 Fix users in deactivated realms sending webhook messages.
In a deactivated realm, webhooks would still successfully send
messages, since there was no check for whether the realm was active in
api_key_only_webhook_view.
2016-05-10 09:50:48 -07:00
Tim Abbott
9da73b22d3 assert_json_error_contains: Support passing a status code.
Previously this test helper function hardcoded 400.
2016-05-10 09:50:48 -07:00
Tim Abbott
3cde06ea33 Add support for setting HTTP status codes in JsonableError. 2016-05-10 09:50:48 -07:00
Tim Abbott
b38c50c6bb docs: Document possible auditing features in security model. 2016-05-10 09:50:47 -07:00
Tim Abbott
44fae09a48 docs: Clarify security model around bots and invite-only streams. 2016-05-10 09:50:47 -07:00
Tim Abbott
b4ccca300b Add tests for whether API keys appear in initial state data. 2016-05-10 09:50:47 -07:00
Tim Abbott
07fc47f953 CVE-2016-4426: Fix non-admin users having access to all bot API keys.
Long ago, there was work on an experimental integration model where
every user in a realm would have administrative control over all bots,
with the goal of simplifying the process of setting up communally
administered bots for smaller teams.  While that new model was never
fully implemented (and thus never setup as an option), an error in
that original implementation meant that the data on all bots in a
realm, including their API keys, was sent to the browsers of users via
the `realm_bots` variable in `page_params`.  The data wasn't displayed
in the UI for non-admin users, but was available via e.g. the
javascript console.

This commit updates this behavior to only send sensitive bot data like
API keys to the owner of the bot (and realm admins).

We may in the future implement a model simplifying communally
administered integrations, but if we do that, those bots should be
limited in their capabilities (e.g. only able to send webhook
messages).

This bug has been present since Zulip was released as open source.
2016-05-10 09:50:02 -07:00
Tim Abbott
b869be9301 style: Use 'not in' consistently rather than not foo in. 2016-05-09 17:00:10 -07:00
Tim Abbott
9cf18f8535 settings: Fix whitespace errors. 2016-05-09 16:53:12 -07:00
Tim Abbott
624258750c confirmation: Fix trailing whitespace. 2016-05-09 16:49:33 -07:00
Tim Abbott
43f167849b queue: Disable RabbitMQ heartbeat in BlockingConnection.
Fixes #741.
2016-05-09 10:23:28 -07:00
Tim Abbott
2dfa7562e2 requirements: Upgrade pika to version 0.10.0.
This is needed to fix RabbitMQ heartbeat issues that cause connections
to drop (#741).  It's also relevant for Python 3 support.
2016-05-09 10:23:28 -07:00
Tim Abbott
0c42fc2f8f queue: Refactor Pika credentials code to be a bit cleaner. 2016-05-09 10:23:28 -07:00
Tim Abbott
0161d2fddd Cleanup guardian-based complexity in get_realm_user_dicts.
The old code for this lookup was unnecessarily complicated because we
were working around Guardian, where the `is_realm_admin` check was
extremely expensive.
2016-05-09 10:12:35 -07:00
Tim Abbott
2a2cbd60c3 cache: Fix fragile active_bot_dicts_in_realm caching model.
The issue here is similar to that in the previous commit.
2016-05-09 10:12:35 -07:00
Tim Abbott
fbc7e977ac cache: Fix fragile active_user_dicts_in_realm caching model.
Previously we relied on having two matching list of fields for the
get_active_user_dicts_in_realm, one in the actual code and the other
in the caching system.  By unifying these lists to have a single
source, we eliminate a class of caching bugs we might otherwise
regularly introduce.
2016-05-09 10:12:35 -07:00
Tim Abbott
f02571202a EventsRegisterTest: display full error diffs. 2016-05-09 10:12:35 -07:00
Tim Abbott
6c744564a7 travis: Add debugging code for rabbitmq nagios failures. 2016-05-09 09:55:18 -07:00
Umair Khan
0d324925b5 Add documentation on translation tags.
[substantially modified by tabbott]
2016-05-09 09:55:18 -07:00
Umair Khan
5359e6b0d4 Convert Zulip to use Jinja2 templates.
This results in a substantial performance improvement for all of
Zulip's backend templates.

Changes in templates:
- Change `block.super` to `super()`.
- Remove `load` tag because Jinja2 doesn't support it.
- Use `minified_js()|safe` instead of `{% minified_js %}`.
- Use `compressed_css()|safe` instead of `{% compressed_css %}`.
- `forloop.first` -> `loop.first`.
- Use `{{ csrf_input }}` instead of `{% csrf_token %}`.
- Use `{# ... #}` instead of `{% comment %}`.
- Use `url()` instead of `{% url %}`.
- Use `_()` instead of `{% trans %}` because in Jinja `trans` is a block tag.
- Use `{% trans %}` instead of `{% blocktrans %}`.
- Use `{% raw %}` instead of `{% verbatim %}`.

Changes in tools:
- Check for `trans` block in `check-templates` instead of `blocktrans`

Changes in backend:
- Create custom `render_to_response` function which takes `request` objects
  instead of `RequestContext` object. There are two reasons to do this:
    1. `RequestContext` is not compatible with Jinja2
    2. `RequestContext` in `render_to_response` is deprecated.
- Add Jinja2 related support files in zproject/jinja2 directory. It
  includes a custom backend and a template renderer, compressors for js
  and css and Jinja2 environment handler.
- Enable `slugify` and `pluralize` filters in Jinja2 environment.

Fixes #620.
2016-05-09 09:55:18 -07:00
Umair Khan
cec0530fd8 analytics: Fix reference to potentially null row.hours_per_user. 2016-05-09 09:54:39 -07:00
Umair Khan
f20b907f96 base.html: Add check for undefined user_profile.
The previous code that neglected this check worked with the Django
templating engine but will not work with Jinja2.
2016-05-09 09:48:37 -07:00
Tim Abbott
804dad42e6 travis: Run various Nagios checks in production tests. 2016-05-08 17:35:50 -07:00
Tim Abbott
00ccf147cd check_nagios_send_time: Add --insecure option for use in tests. 2016-05-08 17:35:50 -07:00
Tim Abbott
744e8ad0e3 travis: Set prod EXTERNAL_HOST to resolve correctly.
This is needed to use check_send_receive_time in the tests.
2016-05-08 17:35:50 -07:00
Tim Abbott
e4c098fba4 travis: Verify all supervisord jobs are running in production test.
This requires a bit of complexity since supervisord automatically
restarts failing jobs.
2016-05-08 17:35:50 -07:00
Tim Abbott
40de75d9e6 travis: Verify the server doesn't 500 in production test. 2016-05-08 17:35:50 -07:00
Tim Abbott
c0d38f42f1 supervisor: Use 127.0.0.1 rather than localhost for tornado.
In theory these should be the same, but in misconfigured environments
(such at Travis CI) where /etc/hosts has multiple entries for
"localhost", 127.0.0.1 is safer than "localhost".
2016-05-08 17:35:50 -07:00
Vladislav Manchev
52e96915e2 check-templates: Allow HTML tag brackets inside tag attributes. 2016-05-08 16:33:03 -07:00
Preston Hansen
635828069f Add feature to mark all in stream/topic as read with mouse.
Fixes #736.
2016-05-08 09:02:46 -07:00
Tim Abbott
34fb276b7b changelog: Add some items since the last release. 2016-05-07 20:34:14 -07:00
Tim Abbott
c5a44043a8 Cleanup changelog.md to be better documentation. 2016-05-07 20:34:06 -07:00
Tim Abbott
1c24cb32a5 Move changelog.md to docs/ and add to ReadTheDocs. 2016-05-07 20:26:44 -07:00
Tim Abbott
e5e133eccc Update docs to reflect the elimination of /bin. 2016-05-07 19:37:06 -07:00
Tim Abbott
6e1872987d Move bin/get-django-setting to scripts/. 2016-05-07 19:37:06 -07:00
Tim Abbott
a315849a9e Move bin/log-management-command to scripts/lib/.
We're in the process of eliminating the bin/ subdirectory in favor of
the scripts/ tree, and this one isn't user-facing.
2016-05-07 19:37:06 -07:00
Tim Abbott
cb81a59e38 Move write-rabbitmq-consumers-state-file to scripts/nagios/. 2016-05-07 19:37:06 -07:00
Tim Abbott
2761c012e5 Move rabbitmq consumer checks from bots/ to scripts/nagios/. 2016-05-07 19:37:06 -07:00
Tim Abbott
be6566dc5c nagios: Move cron_file_helper from bots/ to scripts/lib.
This ensures the tool is available in Zulip production deployments.
2016-05-07 19:37:06 -07:00
Tim Abbott
73b3f7a26e settings: Fix new-style template LOADERS syntax. 2016-05-07 19:35:16 -07:00
Tim Abbott
4c7b4fcea1 requirements: Downgrade Jinja2 and MarkupSafe to match Trusty apt.
The moto-based tests still pass with the older version, and this will
safe some trouble when we migrate Zulip to the Jinja2 templating system.
2016-05-07 17:38:26 -07:00
Tim Abbott
d20791eb6a docs/new-feature-tutorial: Fix typos in templates path. 2016-05-07 17:37:01 -07:00
Umair Khan
6a0c7fec72 analytics: Add at_risk_count to Totals row in realm summary.
This fixes reading from an unset value in realm_summary_table, which
is fine with the Django template engine but will be problematic with
jinja2.
2016-05-07 17:30:06 -07:00
Umair Khan
4620cd8483 settings: Migrate template settings to using TEMPLATES.
This is cleaner and also is necessary preparation for supporting
Jinja2.
2016-05-07 17:29:51 -07:00
Umair Khan
a3acd5e8e9 settings: Add LocaleMiddleware to MIDDLEWARE_CLASSES.
This is needed for internationalization.
2016-05-07 17:00:10 -07:00
Tim Abbott
c1c1be1d36 Add Transifex config file and Transifex client dependency.
This makes it easy to download translations from Transifex.
2016-05-07 16:59:59 -07:00
Tim Abbott
5efb38f093 Add compiled translation messages files (.mo) to gitignore. 2016-05-07 16:59:45 -07:00
Tim Abbott
bfdde2e9b9 provision: Add missing dependency on python3-dev.
This fixes an issue introduced by
b21454d05e, where the typed_ast module
wouldn't build properly when provisioning, because we didn't have the
necessary headers installed.
2016-05-07 13:31:26 -07:00
Tim Abbott
6139e8948a travis: User REQ framework for extracting JSON payload. 2016-05-07 11:54:14 -07:00
Tim Abbott
678adc2048 webhooks: Use REQ more consistently in stream name parsing.
To avoid the potential for introducing regressions here, we carefully
pass a default to REQ or not based on how the existing webhook's
parsing code worked.  In the longer term, we'll want to make the
behavior consistent.
2016-05-07 11:54:14 -07:00
Tomasz Kolek
c2de38239e Add payload validation to has_request_variables and REQ tasks.
[with tweaks by tabbott]
2016-05-07 11:54:09 -07:00
Tim Abbott
c1a680e2a9 rate_limiter: Fix misplaced type annotation and cleanup code.
You don't put type annotations on return values.
2016-05-06 13:38:12 -07:00
Tim Abbott
3a0e7c217f mypy: Move verbose error output to travis CI wrapper.
This makes it easier to pipe the output of tools/run-mypy to tools
like grep.
2016-05-06 13:38:12 -07:00
Tim Abbott
b21454d05e mypy: Use the new --fast-parser option.
This makes mypy about 15% faster running on the Zulip codebase (from
7s=>6s on my laptop), which seems worth it for losing a couple files.

This option requires a new dependency, which we add to the
mypy-specific requirements.txt file.
2016-05-06 13:38:12 -07:00
Tim Abbott
1807e855e7 Upgrade mypy to the new 0.4.0 release.
Also update the mypy command line to not use deprecated argument names.

This introduces a few errors, so we exclude the relevant files to keep
the mypy output clean.
2016-05-06 13:38:12 -07:00
Tim Abbott
4219a6779f socket: Initialize client_id to None by default.
This fixes an exception where client_id was never set in an error code
path.  It shouldn't be needed, but I think this makes the code clearer
and this will help in debugging the actual problem.

Related to #753.
2016-05-05 14:49:26 -07:00
Tim Abbott
542af0d6b6 lint: Add option to print verbose timing output. 2016-05-04 14:22:52 -07:00
Tim Abbott
e2aeee0c35 lint: Add check for unnecessary whitespace between % and (. 2016-05-04 14:22:52 -07:00
Tim Abbott
191201bd10 Fix unnecessary whitespace between % and (. 2016-05-04 14:22:52 -07:00
Tim Abbott
72ee9f5137 lint: Check for unnecssary whitespace after ','s. 2016-05-04 14:17:27 -07:00
Tim Abbott
54022ac204 Fix unnecessary whitespace between , and ). 2016-05-04 14:16:53 -07:00
Tim Abbott
dd40f51fee Add code to clean the venv cache of old venvs. 2016-05-03 15:04:03 -07:00
Tim Abbott
6a335fc090 Travis: Use /srv/zulip-venv-cache cache. 2016-05-03 14:48:21 -07:00
Tim Abbott
9970341ede Fix caching of install-phantomjs library in Travis CI. 2016-05-03 14:48:21 -07:00
Tim Abbott
ae6037668a test_runner: Add debugging tips for missing test modules. 2016-05-03 12:33:47 -07:00
Tim Abbott
bab267f332 test_runner: Improve error handling when importing test files.
The error message for a test file that doesn't import properly was
previously pretty difficult to understand and it wasn't clear how to
debug the issue.
2016-05-03 12:17:10 -07:00
Tim Abbott
9f786a5131 provision: Add caching of virtualenvs by sha1sum of requirements.txt.
This should save a couple minutes on the time it takes to provision a
Zulip environment on a machine that has provisioned with the same
requirements.txt file content before.

We can't yet use this in Travis CI because Travis CI doesn't support
using both sudo and caching in the same build.
2016-05-02 23:08:59 -07:00
Tim Abbott
ef95917da5 provision: Refactor virtualenv creation into a function. 2016-05-02 22:35:18 -07:00
rahuldeve
899bfb97ee Add tests for managing uploads in S3. 2016-05-02 22:14:47 -07:00
rahuldeve
01fb6c77a2 Add test for managing files in Local Storage. 2016-05-02 22:14:47 -07:00
rahuldeve
c9b242b5d1 Modify requirements.txt for adding moto package and its dependencies. 2016-05-02 22:14:47 -07:00
rahuldeve
dde832b158 Add Attachment model to keep track of uploads.
This commit adds the capability to keep track and remove uploaded
files.  Unclaimed attachments are files that have been uploaded to the
server but are not referred in any messages.  A management command to
remove old unclaimed files after a week is also included.

Tests for getting the file referred in messages are also included.
2016-05-02 22:14:47 -07:00
Tim Abbott
391a225595 lint: Check for missing space after comments. 2016-05-02 22:10:47 -07:00
Tim Abbott
762a3188ee Fix missing whitespace after # in comments. 2016-05-02 22:10:47 -07:00
952 changed files with 80095 additions and 18520 deletions

2
.coveralls.yml Normal file
View File

@@ -0,0 +1,2 @@
service_name: travis-pro
repo_token: hnXUEBKsORKHc8xIENGs9JjktlTb2HKlG

1
.gitattributes vendored
View File

@@ -18,3 +18,4 @@
/frontend_tests export-ignore
/node_modules export-ignore
/humbug export-ignore
/locale export-ignore

32
.gitignore vendored
View File

@@ -1,46 +1,26 @@
*.pyc
*~
/all_messages_log.*
/event_log/*
/digest.log*
/errors.log*
/manage.log*
/server.log*
/workers.log*
/email-deliverer.log
/email-mirror.log
/sync_ldap_user_data.log
/update-prod-static.log
frontend_tests/casper_tests/server.log
frontend_tests/casper_lib/test_credentials.js
memcached_prefix
/prod-static
/errors/*
*.sw[po]
*.DS_Store
event_queues.pickle
stats/
zerver/fixtures/available-migrations
zerver/fixtures/migration-status
zerver/fixtures/test_data1.json
.kdev4
.idea
zulip.kdev4
remote_cache_prefix
coverage/
.coverage
/queue_error
.test-js-with-node.html
.kateproject.d/
.kateproject
*.kate-swp
event_queues.json
.vagrant
/zproject/dev-secrets.conf
static/js/bundle.js
static/third/gemoji/
static/third/zxcvbn/
tools/emoji_dump/bitmaps/
tools/emoji_dump/*.ttx
tools/phantomjs
static/locale/language_options.json
node_modules
uploads/
test_uploads/
npm-debug.log
*.mo
var/*

View File

@@ -1,28 +1,47 @@
dist: trusty
before_install:
- nvm install 0.10
install:
- pip install coveralls
- tools/travis/setup-$TEST_SUITE
- tools/clean-venv-cache --travis
cache:
- apt: false
- directories:
- /srv/phantomjs
- $HOME/phantomjs
- $HOME/zulip-venv-cache
- node_modules
- $HOME/node
env:
- TEST_SUITE=frontend
- TEST_SUITE=backend
- TEST_SUITE=production
- TEST_SUITE=py3k
global:
- COVERALLS_PARALLEL=true
- COVERALLS_SERVICE_NAME=travis-pro
- COVERALLS_REPO_TOKEN=hnXUEBKsORKHc8xIENGs9JjktlTb2HKlG
- BOTO_CONFIG=/tmp/nowhere
matrix:
- TEST_SUITE=frontend
- TEST_SUITE=backend
language: python
python:
- "2.7"
- "3.4"
matrix:
include:
- python: "3.4"
env: TEST_SUITE=mypy
env: TEST_SUITE=static-analysis
- python: "2.7"
env: TEST_SUITE=production
sudo: required
# command to run tests
script:
- unset GEM_PATH
- ./tools/travis/$TEST_SUITE
sudo: required
services:
- docker
addons:
postgresql: "9.3"
after_success:
coveralls
notifications:
webhooks: https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN

17
.tx/config Normal file
View File

@@ -0,0 +1,17 @@
[main]
host = https://www.transifex.com
[zulip.djangopo]
source_file = static/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO
file_filter = static/locale/<lang>/LC_MESSAGES/django.po
lang_map = zh-Hans: zh_CN
[zulip.translationsjson]
source_file = static/locale/en/translations.json
source_lang = en
type = KEYVALUEJSON
file_filter = static/locale/<lang>/translations.json
lang_map = zh-Hans: zh-CN

View File

@@ -9,4 +9,7 @@ RUN apt-get update && apt-get install -y \
RUN useradd -d /home/zulip -m zulip && echo 'zulip ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER zulip
RUN ln -nsf /srv/zulip ~/zulip
WORKDIR /srv/zulip

View File

@@ -1,554 +0,0 @@
Installing the Zulip Development environment
============================================
You will need a machine with at least 2GB of RAM available (see
https://github.com/zulip/zulip/issues/32 for a plan for how to
dramatically reduce this requirement).
Start by cloning this repository: `git clone https://github.com/zulip/zulip.git`
Using Vagrant
-------------
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 OS X or older Linux, [download VirtualBox][vbox-dl],
[download Vagrant][vagrant-dl], and install them both.
* If you're on OS X and have VMWare, it should be possible to patch
Vagrantfile to use the VMWare vagrant provider which should perform
much better than Virtualbox. Patches to do this by default if
VMWare is available are welcome!
* 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
[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 -- -L9991:localhost:9991
# Now inside the container
cd /srv/zulip
source /srv/zulip-venv/bin/activate
./tools/run-dev.py --interface=''
```
To get shell access to the virtual machine running the server to run
lint, management commands, etc., use `vagrant ssh`.
(A small note on tools/run-dev.py: the `--interface=''` option will
make the development server listen on all network interfaces. While
this is correct for the Vagrant guest sitting behind a NAT, you
probably don't want to use that option when using run-dev.py in other
environments).
At this point you should [read about using the development
environment][using-dev].
[using-dev]: #using-the-development-environment
## 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.
Using provision.py without Vagrant
----------------------------------
If you'd like to install a Zulip development environment on a server
that's already running Ubuntu 14.04 Trusty, you can do that by just
running:
```
sudo apt-get update
python /srv/zulip/provision.py
cd /srv/zulip
source /srv/zulip-venv/bin/activate
./tools/run-dev.py
```
Note that there is no supported uninstallation process without Vagrant
(with Vagrant, you can just do `vagrant destroy` to clean up the
development environment).
By hand
-------
If you really want to install everything by hand, the below
instructions should work.
Install the following non-Python dependencies:
* libffi-dev — needed for some Python extensions
* postgresql 9.1 or later — our database (client, server, headers)
* nodejs 0.10 (and npm)
* memcached (and headers)
* rabbitmq-server
* libldap2-dev
* python-dev
* redis-server — rate limiting
* tsearch-extras — better text search
* libfreetype6-dev — needed before you pip install Pillow to properly generate emoji PNGs
### On Debian or Ubuntu systems:
```
sudo apt-get install closure-compiler libfreetype6-dev libffi-dev \
memcached rabbitmq-server libldap2-dev redis-server \
postgresql-server-dev-all libmemcached-dev python-dev \
hunspell-en-us nodejs nodejs-legacy npm git yui-compressor \
puppet gettext
# If on 12.04 or wheezy:
sudo apt-get install postgresql-9.1
wget https://dl.dropboxusercontent.com/u/283158365/zuliposs/postgresql-9.1-tsearch-extras_0.1.2_amd64.deb
sudo dpkg -i postgresql-9.1-tsearch-extras_0.1.2_amd64.deb
# If on 14.04:
sudo apt-get install postgresql-9.3
wget https://dl.dropboxusercontent.com/u/283158365/zuliposs/postgresql-9.3-tsearch-extras_0.1.2_amd64.deb
sudo dpkg -i postgresql-9.3-tsearch-extras_0.1.2_amd64.deb
# If on 15.04 or jessie:
sudo apt-get install postgresql-9.4
wget https://dl.dropboxusercontent.com/u/283158365/zuliposs/postgresql-9.4-tsearch-extras_0.1_amd64.deb
sudo dpkg -i postgresql-9.4-tsearch-extras_0.1_amd64.deb
```
Now continue with the "All systems" instructions below.
### On Fedora 22 (experimental):
These instructions are experimental and may have bugs; patches
welcome!
```
sudo dnf install libffi-devel memcached rabbitmq-server \
openldap-devel python-devel redis postgresql-server \
postgresql-devel postgresql libmemcached-devel freetype-devel \
nodejs npm yuicompressor closure-compiler gettext
```
Now continue with the Common to Fedora/CentOS instructions below.
### On CentOS 7 Core (experimental):
These instructions are experimental and may have bugs; patches
welcome!
```
# Add user zulip to the system (not necessary if you configured zulip
# as the administrator user during the install process of CentOS 7).
useradd zulip
# Create a password for zulip user
passwd zulip
# Allow zulip to sudo
visudo
# Add this line after line `root ALL=(ALL) ALL`
zulip ALL=(ALL) ALL
# Switch to zulip user
su zulip
# Enable EPEL 7 repo so we can install rabbitmq-server, redis and
# other dependencies
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# Install dependencies
sudo yum install libffi-devel memcached rabbitmq-server openldap-devel
python-devel redis postgresql-server postgresql-devel postgresql \
libmemcached-devel wget python-pip openssl-devel freetype-devel \
libjpeg-turbo-devel zlib-devel nodejs yuicompressor \
closure-compiler gettext
# We need these packages to compile tsearch-extras
sudo yum groupinstall "Development Tools"
# clone Zulip's git repo and cd into it
cd && git clone 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
sudo postgresql-setup initdb
# Edit the postgres settings:
sudo vi /var/lib/pgsql/data/pg_hba.conf
# Change these lines:
host all all 127.0.0.1/32 ident
host all all ::1/128 ident
# to this:
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
```
Now continue with the Common to Fedora/CentOS instructions below.
### On OpenBSD 5.8 (experimental):
These instructions are experimental and may have bugs; patches
welcome!
```
doas pkg_add sudo bash gcc postgresql-server redis rabbitmq \
memcached node libmemcached py-Pillow py-cryptography py-cffi
# Get tsearch_extras and build it (using a modified version which
# aliases int4 on OpenBSD):
git clone https://github.com/blablacio/tsearch_extras
cd tsearch_extras
gmake && sudo gmake install
# Point environment to custom include locations and use newer GCC
# (needed for Node modules):
export CFLAGS="-I/usr/local/include -I/usr/local/include/sasl"
export CXX=eg++
# Create tsearch_data directory:
sudo mkdir /usr/local/share/postgresql/tsearch_data
# Hack around missing dictionary files -- need to fix this to get the
# proper dictionaries from what in debian is the hunspell-en-us
# package.
sudo touch /usr/local/share/postgresql/tsearch_data/english.stop
sudo touch /usr/local/share/postgresql/tsearch_data/en_us.dict
sudo touch /usr/local/share/postgresql/tsearch_data/en_us.affix
```
Now continue with the All Systems instructions below.
### Common to Fedora/CentOS instructions
```
# Build and install postgres tsearch-extras module
wget https://launchpad.net/~tabbott/+archive/ubuntu/zulip/+files/tsearch-extras_0.1.3.tar.gz
tar xvzf tsearch-extras_0.1.3.tar.gz
cd ts2
make
sudo make install
# Hack around missing dictionary files -- need to fix this to get the
# proper dictionaries from what in debian is the hunspell-en-us
# package.
sudo touch /usr/share/pgsql/tsearch_data/english.stop
sudo touch /usr/share/pgsql/tsearch_data/en_us.dict
sudo touch /usr/share/pgsql/tsearch_data/en_us.affix
# Edit the postgres settings:
sudo vi /var/lib/pgsql/data/pg_hba.conf
# Add this line before the first uncommented line to enable password
# auth:
host all all 127.0.0.1/32 md5
# Start the services
sudo systemctl start redis memcached rabbitmq-server postgresql
# Enable automatic service startup after the system startup
sudo systemctl enable redis rabbitmq-server memcached postgresql
```
Finally continue with the All Systems instructions below.
### All Systems:
```
pip install --no-deps -r requirements.txt
./tools/install-phantomjs
./tools/install-mypy
./tools/download-zxcvbn
./tools/emoji_dump/build_emoji
./scripts/setup/generate_secrets.py -d
if [ $(uname) = "OpenBSD" ]; then sudo cp ./puppet/zulip/files/postgresql/zulip_english.stop /var/postgresql/tsearch_data/; else sudo cp ./puppet/zulip/files/postgresql/zulip_english.stop /usr/share/postgresql/9.3/tsearch_data/; fi
./scripts/setup/configure-rabbitmq
./tools/postgres-init-dev-db
./tools/do-destroy-rebuild-database
./tools/postgres-init-test-db
./tools/do-destroy-rebuild-test-database
npm install
```
If `npm install` fails, the issue may be that you need a newer version
of `npm`. You can use `npm install -g npm` to update your version of
`npm` and try again.
To start the development server:
```
./tools/run-dev.py
```
… and visit [http://localhost:9991/](http://localhost:9991/).
#### Proxy setup for by-hand installation
If you are building the development environment on a network where a
proxy is required to access the Internet, you will need to set the
proxy in the environment as follows:
- On Ubuntu, set the proxy environment variables using:
```
export https_proxy=http://proxy_host:port
export http_proxy=http://proxy_host:port
```
- And set the npm proxy and https-proxy using:
```
npm config set proxy http://proxy_host:port
npm config set https-proxy http://proxy_host:port
```
Using Docker (experimental)
---------------------------
The docker instructions for development are experimental, so they may
have bugs. If you try them and run into any issues, please report
them!
You can also use Docker to run a Zulip development environment.
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/linux/started/)
* [Understand the architecture](https://docs.docker.com/engine/introduction/understanding-docker/)
* [Docker run reference](https://docs.docker.com/engine/reference/run/)
* [Dockerfile reference](https://docs.docker.com/engine/reference/builder/)
[docker-install]: https://docs.docker.com/engine/installation/
Then you should create the Docker image based on Ubuntu Linux, first
go to the directory with the Zulip source code:
```
docker build -t user/zulipdev .
```
Now you're going to install Zulip dependencies in the image:
```
docker run -itv $(pwd):/srv/zulip -p 80:9991 user/zulipdev /bin/bash
$ /usr/bin/python /srv/zulip/provision.py --docker
docker ps -af ancestor=user/zulipdev
docker commit -m "Zulip installed" <container id> user/zulipdev:v2
```
Finally you can run the docker server with:
```
docker run -itv $(pwd):/srv/zulip -p 80:9991 user/zulipdev:v2 \
/srv/zulip/scripts/start-dockers
```
If you want to connect to the Docker instance to build a release
tarball you can use:
```
docker ps
docker exec -it <container id> /bin/bash
$ source /home/zulip/.bash_profile
$ <Your commands>
$ exit
```
To stop the server use:
```
docker ps
docker kill <container id>
```
If you want to run all the tests you need to start the servers first,
you can do it with:
```
docker run -itv $(pwd):/srv/zulip user/zulipdev:v2 /bin/bash
$ scripts/test-all-docker
```
You can modify the source code in your development machine and review
the results in your browser.
Using the Development Environment
=================================
Once the development environment is running, you can visit
<http://localhost:9991/> in your browser. By default, the development
server homepage just shows a list of the users that exist on the
server and you can login as any of them by just clicking on a user.
This setup saves time for the common case where you want to test
something other than the login process; to test the login process
you'll want to change `AUTHENTICATION_BACKENDS` in the not-PRODUCTION
case of `zproject/settings.py` from zproject.backends.DevAuthBackend
to use the auth method(s) you'd like to test.
While developing, it's helpful to watch the `run-dev.py` console
output, which will show any errors your Zulip development server
encounters.
When you make a change, here's a guide for what you need to do in
order to see your change take effect in Development:
* If you change Javascript or CSS, you'll just need to reload the
browser window to see changes take effect.
* If you change Python code used by the the main Django/Tornado server
processes, these services are run on top of Django's [manage.py
runserver][django-runserver] which will automatically restart the
Zulip Django and Tornado servers whenever you save changes to Python
code. You can watch this happen in the `run-dev.py` console to make
sure the backend has reloaded.
* The Python queue workers don't automatically restart when you save
changes (or when they stop running), so you will want to ctrl-C and
then restart `run-dev.py` manually if you are testing changes to the
queue workers or if a queue worker has crashed.
* If you change the database schema, you'll need to use the standard
Django migrations process to create and then run your migrations; see
the [new feature tutorial][new-feature-tutorial] for an example.
Additionally you should check out the [detailed testing
docs][testing-docs] for how to run the tests properly after doing a
migration.
(In production, everything runs under supervisord and thus will
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]: http://zulip.readthedocs.io/en/latest/new-feature-tutorial.html
[testing-docs]: http://zulip.readthedocs.io/en/latest/testing.html
Running the test suite
======================
For more details, especially on how to write tests, check out the
[detailed testing docs][tdocs].
[tdocs]: http://zulip.readthedocs.io/en/latest/testing.html
To run all the tests, do this:
```
./tools/test-all
```
For the Vagrant environment, you'll want to first enter the
environment:
```
vagrant ssh
source /srv/zulip-venv/bin/activate
cd /srv/zulip
```
This runs the linter (`tools/lint-all`) plus all of our test suites;
they can all be run separately (just read `tools/test-all` to see
them). You can also run individual tests which can save you a lot of
time debugging a test failure, e.g.:
```
./tools/lint-all # Runs all the linters in parallel
./tools/test-backend zerver.tests.test_bugdown.BugdownTest.test_inline_youtube
./tools/test-js-with-casper 10-navigation.js
./tools/test-js-with-node # Runs all node tests but is very fast
```
The above setup instructions include the first-time setup of test
databases, but you may need to rebuild the test database occasionally
if you're working on new database migrations. To do this, run:
```
./tools/postgres-init-test-db
./tools/do-destroy-rebuild-test-database
```
Possible testing issues
=======================
- When running the test suite, if you get an error like this:
```
sqlalchemy.exc.ProgrammingError: (ProgrammingError) function ts_match_locs_array(unknown, text, tsquery) does not exist
LINE 2: ...ECT message_id, flags, subject, rendered_content, ts_match_l...
^
```
… then you need to install tsearch-extras, described
above. Afterwards, re-run the `init*-db` and the
`do-destroy-rebuild*-database` scripts.
- When building the development environment using Vagrant and the LXC
provider, if you encounter permissions errors, you may need to
`chown -R 1000:$(whoami) /path/to/zulip` on the host before running
`vagrant up` in order to ensure that the synced directory has the
correct owner during provision. This issue will arise if you run `id
username` on the host where `username` is the user running Vagrant
and the output is anything but 1000.
This seems to be caused by Vagrant behavior; for more information,
see [the vagrant-lxc FAQ entry about shared folder permissions
][lxc-sf].
[lxc-sf]: https://github.com/fgrehm/vagrant-lxc/wiki/FAQ#help-my-shared-folders-have-the-wrong-owner)

View File

@@ -1,5 +1,12 @@
Zulip
=====
**[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
@@ -12,28 +19,45 @@ 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][1]][2]
[![Build Status](https://travis-ci.org/zulip/zulip.svg?branch=master)](https://travis-ci.org/zulip/zulip) [![Coverage Status](https://coveralls.io/repos/github/zulip/zulip/badge.svg?branch=master)](https://coveralls.io/github/zulip/zulip?branch=master)
[1]: https://travis-ci.org/zulip/zulip.svg?branch=master
[2]: https://travis-ci.org/zulip/zulip
## Community
Installing the Zulip Development environment
============================================
There are several places online where folks discuss Zulip.
The Zulip development environment is the recommened option for folks
interested in trying out Zulip. This is documented in
[README.dev.md](README.dev.md).
One of those places is our [public Zulip instance](https://zulip.tabbott.net/).
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 16:00 UTC and 23:59 UTC. Most questions get answered
within a day.
Running Zulip in production
===========================
We have a [Google mailing list](https://groups.google.com/forum/#!forum/zulip-devel)
that is currently pretty low traffic. It is where we do things like
announce public meetings or major releases. You can also use it to
ask questions about features or possible bugs.
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.
## Installing the Zulip Development environment
The Zulip development environment is the recommended option for folks
interested in trying out Zulip. This is documented in [the developer
installation guide][dev-install].
## Running Zulip in production
Zulip in production only supports Ubuntu 14.04 right now, but work is
ongoing on adding support for additional platforms. The installation
process is documented in https://zulip.org/server.html and in more
detail in [README.prod.md](README.prod.md).
process is documented at https://zulip.org/server.html and in more
detail in [the
documentation](https://zulip.readthedocs.io/en/latest/prod-install.html).
Contributing to Zulip
=====================
## Ways to contribute
Zulip welcomes all forms of contributions! The page documents the
Zulip development process.
@@ -45,12 +69,15 @@ please skim our [commit message style guidelines][doc-commit-style].
* **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].
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].
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][gg-devel] and uses [GitHub issues
@@ -61,31 +88,49 @@ relevant list! Please report any security issues you discover to
zulip-security@googlegroups.com.
* **App codebases**. This repository is for the Zulip server and web
app; the [desktop][], [Android][], and [iOS][] apps are separate
repositories.
app (including most integrations); the [desktop][], [Android][], and
[iOS][] apps, are separate repositories, as are our [experimental
React Native iOS app][ios-exp] and [alpha Electron desktop
app][electron].
* **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], 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
[translating documentation][transifex] if you're interested in
contributing!
[cla]: https://opensource.dropbox.com/cla/
[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/code-style.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]: https://github.com/zulip/zulip/blob/master/README.dev.md#running-the-test-suite
[doc-test]: http://zulip.readthedocs.io/en/latest/testing.html
[electron]: https://github.com/zulip/zulip-electron
[gg-devel]: https://groups.google.com/forum/#!forum/zulip-devel
[gh-issues]: https://github.com/zulip/zulip/issues
[desktop]: https://github.com/zulip/zulip-desktop
[android]: https://github.com/zulip/zulip-android
[ios]: https://github.com/zulip/zulip-ios
[ios-exp]: https://github.com/zulip/zulip-mobile
[email-android]: https://groups.google.com/forum/#!forum/zulip-android
[email-ios]: https://groups.google.com/forum/#!forum/zulip-ios
[transifex]: https://www.transifex.com/zulip/zulip/
[hubot-adapter]: https://github.com/zulip/hubot-zulip
[jenkins]: https://github.com/zulip/zulip-jenkins-plugin
[node]: https://github.com/zulip/zulip-node
[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
How to get involved with contributing to Zulip
==============================================
## How to get involved with contributing to Zulip
First, subscribe to the Zulip [development discussion mailing
list][gg-devel].
@@ -159,8 +204,7 @@ 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 Developers list with your thoughts.
License
=======
## License
Copyright 2011-2015 Dropbox, Inc.

File diff suppressed because it is too large Load Diff

View File

@@ -42,13 +42,6 @@ Files: puppet/apt/*
Copyright: 2011, Evolving Web Inc.
License: Expat
Files: puppet/common/*
Copyright: 2007, David Schmitt
License: BSD-3-Clause
Comment: https://github.com/DavidS/puppet-common
Distribution includes a file `lib/puppet/parser/functions/ip_to_cron.rb` which
we removed due to unclear license
Files: puppet/stdlib/*
Copyright: 2011, Krzysztof Wilczynski
2011, Puppet Labs Inc
@@ -122,7 +115,7 @@ Copyright: 2013 Nijiko Yonskai
License: Apache-2.0
Comment: The software has been modified.
Files: static/third/gemoji/images/emoji/unicode/* tools/emoji_dump/*.ttf
Files: static/third/gemoji/images/emoji/unicode/* tools/setup/emoji_dump/*.ttf
Copyright: Google, Inc.
License: Apache-2.0
Comment: These are actually Noto Emoji, not gemoji.
@@ -142,7 +135,7 @@ Copyright: 2013 Jack Moore
License: Expat
Files: static/third/jquery-caret/*
Copyright: 2010 C.F., Wong
Copyright: 2012, 2013 Andrew C. Dvorak
License: Expat
Files: static/third/jquery-filedrop/jquery.filedrop.js
@@ -182,6 +175,10 @@ Files: static/third/marked/*
Copyright: 2011-2013, Christopher Jeffrey
License: Expat
Files: static/third/string-prototype-codepointat/*
Copyright: 2014 Mathias Bynens
License: Expat
Files: static/third/sockjs/sockjs-0.3.4.js
Copyright: 2011-2012 VMware, Inc.
2012 Douglas Crockford
@@ -204,7 +201,7 @@ Copyright: 2011-2013 Felix Gnass
License: Expat
Files: static/third/underscore/underscore.js
Copyright: 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
Copyright: 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
License: Expat
Comment: https://github.com/jashkenas/underscore/blob/master/LICENSE

42
Vagrantfile vendored
View File

@@ -3,7 +3,7 @@
VAGRANTFILE_API_VERSION = "2"
def command?(name)
`which #{name}`
`which #{name} > /dev/null 2>&1`
$?.success?
end
@@ -13,16 +13,15 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "fgrehm/trusty64-lxc"
# The Zulip development environment runs on 9991 on the guest.
config.vm.network "forwarded_port", guest: 9991, host: 9991, host_ip: "127.0.0.1"
host_port = 9991
http_proxy = https_proxy = no_proxy = ""
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder ".", "/srv/zulip"
proxy_config_file = ENV['HOME'] + "/.zulip-vagrant-config"
if File.file?(proxy_config_file)
http_proxy = https_proxy = no_proxy = ""
IO.foreach(proxy_config_file) do |line|
vagrant_config_file = ENV['HOME'] + "/.zulip-vagrant-config"
if File.file?(vagrant_config_file)
IO.foreach(vagrant_config_file) do |line|
line.chomp!
key, value = line.split(nil, 2)
case key
@@ -30,19 +29,22 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
when "HTTP_PROXY"; http_proxy = value
when "HTTPS_PROXY"; https_proxy = value
when "NO_PROXY"; no_proxy = value
when "HOST_PORT"; host_port = value.to_i
end
end
end
if Vagrant.has_plugin?("vagrant-proxyconf")
if http_proxy != ""
config.proxy.http = http_proxy
end
if https_proxy != ""
config.proxy.https = https_proxy
end
if https_proxy != ""
config.proxy.no_proxy = no_proxy
end
config.vm.network "forwarded_port", guest: 9991, host: host_port, host_ip: "127.0.0.1"
if Vagrant.has_plugin?("vagrant-proxyconf")
if http_proxy != ""
config.proxy.http = http_proxy
end
if https_proxy != ""
config.proxy.https = https_proxy
end
if https_proxy != ""
config.proxy.no_proxy = no_proxy
end
end
@@ -63,14 +65,16 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider "virtualbox" do |vb, override|
override.vm.box = "ubuntu/trusty64"
# 2GiB seemed reasonable here. The VM OOMs with only 1024MiB.
# It's possible we can get away with just 1.5GB; more testing needed
vb.memory = 2048
end
$provision_script = <<SCRIPT
set -x
set -e
/usr/bin/python /srv/zulip/provision.py
set -o pipefail
ln -nsf /srv/zulip ~/zulip
/usr/bin/python /srv/zulip/tools/provision.py | sudo tee -a /var/log/zulip_provision.log
SCRIPT
config.vm.provision "shell",

View File

@@ -2,6 +2,7 @@ from __future__ import absolute_import
from __future__ import print_function
from django.core.management.base import BaseCommand
from typing import Any
from zerver.models import UserPresence, UserActivity
from zerver.lib.utils import statsd, statsd_key
@@ -15,6 +16,7 @@ class Command(BaseCommand):
Run as a cron job that runs every 10 minutes."""
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
# Get list of all active users in the last 1 week
cutoff = datetime.now() - timedelta(minutes=30, hours=168)
@@ -31,7 +33,7 @@ class Command(BaseCommand):
known_active = last_presence.timestamp
for bucket in hour_buckets:
if not bucket in user_info[last_presence.user_profile.realm.domain]:
if bucket not in user_info[last_presence.user_profile.realm.domain]:
user_info[last_presence.user_profile.realm.domain][bucket] = []
if datetime.now(known_active.tzinfo) - known_active < timedelta(hours=bucket):
user_info[last_presence.user_profile.realm.domain][bucket].append(last_presence.user_profile.email)
@@ -40,14 +42,14 @@ class Command(BaseCommand):
print("Realm %s" % (realm,))
for hr, users in sorted(buckets.items()):
print("\tUsers for %s: %s" % (hr, len(users)))
statsd.gauge("users.active.%s.%shr" % (statsd_key(realm, True), statsd_key(hr, True)), len(users))
statsd.gauge("users.active.%s.%shr" % (statsd_key(realm, True), statsd_key(hr, True)), len(users))
# Also do stats for how many users have been reading the app.
users_reading = UserActivity.objects.select_related().filter(query="/json/messages/flags")
user_info = defaultdict(dict)
for activity in users_reading:
for bucket in hour_buckets:
if not bucket in user_info[activity.user_profile.realm.domain]:
if bucket not in user_info[activity.user_profile.realm.domain]:
user_info[activity.user_profile.realm.domain][bucket] = []
if datetime.now(activity.last_visit.tzinfo) - activity.last_visit < timedelta(hours=bucket):
user_info[activity.user_profile.realm.domain][bucket].append(activity.user_profile.email)
@@ -55,4 +57,4 @@ class Command(BaseCommand):
print("Realm %s" % (realm,))
for hr, users in sorted(buckets.items()):
print("\tUsers reading for %s: %s" % (hr, len(users)))
statsd.gauge("users.reading.%s.%shr" % (statsd_key(realm, True), statsd_key(hr, True)), len(users))
statsd.gauge("users.reading.%s.%shr" % (statsd_key(realm, True), statsd_key(hr, True)), len(users))

View File

@@ -5,6 +5,7 @@ import datetime
import pytz
from optparse import make_option
from typing import Any
from django.core.management.base import BaseCommand
from zerver.lib.statistics import activity_averages_during_day
@@ -16,6 +17,7 @@ class Command(BaseCommand):
help="Day to query in format 2013-12-05. Default is yesterday"),)
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
if options["date"] is None:
date = datetime.datetime.now() - datetime.timedelta(days=1)
else:

View File

@@ -1,6 +1,8 @@
from __future__ import absolute_import
from __future__ import print_function
from typing import Any
from optparse import make_option
from django.core.management.base import BaseCommand
from zerver.models import Recipient, Message
@@ -10,6 +12,7 @@ import time
import logging
def compute_stats(log_level):
# type: (int) -> None
logger = logging.getLogger()
logger.setLevel(log_level)
@@ -76,6 +79,7 @@ class Command(BaseCommand):
help = "Compute statistics on MIT Zephyr usage."
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
level = logging.INFO
if options["verbose"]:
level = logging.DEBUG

View File

@@ -2,6 +2,8 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from typing import Any, Dict
from zerver.lib.statistics import seconds_usage_between
from optparse import make_option
@@ -11,6 +13,7 @@ import datetime
from django.utils.timezone import utc
def analyze_activity(options):
# type: (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"])
@@ -27,7 +30,7 @@ def analyze_activity(options):
continue
total_duration += duration
print("%-*s%s" % (37, user_profile.email, duration, ))
print("%-*s%s" % (37, user_profile.email, duration,))
print("\nTotal Duration: %s" % (total_duration,))
print("\nTotal Duration in minutes: %s" % (total_duration.total_seconds() / 60.,))
@@ -44,7 +47,7 @@ It will correctly not count server-initiated reloads in the activity statistics.
The duration flag can be used to control how many days to show usage duration for
Usage: python2.7 manage.py analyze_user_activity [--realm=zulip.com] [--date=2013-09-10] [--duration=1]
Usage: python manage.py analyze_user_activity [--realm=zulip.com] [--date=2013-09-10] [--duration=1]
By default, if no date is selected 2013-09-10 is used. If no realm is provided, information
is shown for all realms"""
@@ -52,8 +55,10 @@ is shown for all realms"""
option_list = BaseCommand.option_list + (
make_option('--realm', action='store'),
make_option('--date', action='store', default="2013-09-06"),
make_option('--duration', action='store', default=1, type=int, help="How many days to show usage information for"),
make_option('--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
analyze_activity(options)

View File

@@ -1,8 +1,11 @@
from __future__ import absolute_import
from __future__ import print_function
from typing import Any
from argparse import ArgumentParser
from django.core.management.base import BaseCommand
from django.db.models import Count
from django.db.models import Count, QuerySet
from zerver.models import UserActivity, UserProfile, Realm, \
get_realm, get_user_profile_by_email
@@ -14,15 +17,17 @@ class Command(BaseCommand):
Usage examples:
python2.7 manage.py client_activity
python2.7 manage.py client_activity zulip.com
python2.7 manage.py client_activity jesstess@zulip.com"""
python manage.py client_activity
python manage.py client_activity zulip.com
python manage.py client_activity jesstess@zulip.com"""
def add_arguments(self, parser):
# type: (ArgumentParser) -> None
parser.add_argument('arg', metavar='<arg>', type=str, nargs='?', default=None,
help="realm or user to estimate client activity for")
def compute_activity(self, user_activity_objects):
# type: (QuerySet) -> None
# Report data from the past week.
#
# This is a rough report of client activity because we inconsistently
@@ -54,6 +59,7 @@ python2.7 manage.py client_activity jesstess@zulip.com"""
def handle(self, *args, **options):
# type: (*Any, **str) -> None
if options['arg'] is None:
# Report global activity.
self.compute_activity(UserActivity.objects.all())

View File

@@ -2,6 +2,9 @@ from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from typing import Any
from argparse import ArgumentParser
import datetime
import pytz
@@ -19,10 +22,12 @@ class Command(BaseCommand):
help = "Generate statistics on realm activity."
def add_arguments(self, parser):
# type: (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]
# Has been active (on the website, for now) in the last 7 days.
activity_cutoff = datetime.datetime.now(tz=pytz.utc) - datetime.timedelta(days=7)
return [activity.user_profile for activity in \
@@ -33,36 +38,44 @@ class Command(BaseCommand):
client__name="website")]
def messages_sent_by(self, user, days_ago):
# type: (UserProfile, int) -> int
sent_time_cutoff = datetime.datetime.now(tz=pytz.utc) - 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
sent_time_cutoff = datetime.datetime.now(tz=pytz.utc) - 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
sent_time_cutoff = datetime.datetime.now(tz=pytz.utc) - 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
return (self.total_messages(realm, days_ago) - self.human_messages(realm, days_ago))
def stream_messages(self, realm, days_ago):
# type: (Realm, int) -> int
sent_time_cutoff = datetime.datetime.now(tz=pytz.utc) - 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
sent_time_cutoff = datetime.datetime.now(tz=pytz.utc) - 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
sent_time_cutoff = datetime.datetime.now(tz=pytz.utc) - 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
if not denominator:
fraction = 0.0
else:
@@ -70,6 +83,7 @@ class Command(BaseCommand):
print("%.2f%% of" % (fraction * 100,), text)
def handle(self, *args, **options):
# type: (*Any, **Any) -> None
if options['realms']:
try:
realms = [get_realm(domain) for domain in options['realms']]

View File

@@ -1,6 +1,9 @@
from __future__ import absolute_import
from __future__ import print_function
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
@@ -9,10 +12,12 @@ class Command(BaseCommand):
help = "Generate statistics on the streams for a realm."
def add_arguments(self, parser):
# type: (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
if options['realms']:
try:
realms = [get_realm(domain) for domain in options['realms']]

View File

@@ -1,8 +1,10 @@
from __future__ import absolute_import
from __future__ import print_function
from argparse import ArgumentParser
import datetime
import pytz
from typing import Any
from django.core.management.base import BaseCommand
from zerver.models import UserProfile, Realm, Stream, Message, get_realm
@@ -12,15 +14,18 @@ class Command(BaseCommand):
help = "Generate statistics on user activity."
def add_arguments(self, parser):
# type: (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
start = datetime.datetime.now(tz=pytz.utc) - datetime.timedelta(days=(week + 1)*7)
end = datetime.datetime.now(tz=pytz.utc) - 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
if options['realms']:
try:
realms = [get_realm(domain) for domain in options['realms']]

View File

@@ -1,8 +1,9 @@
from django.conf.urls import patterns, url
urlpatterns = patterns('analytics.views',
url(r'^activity$', 'get_activity'),
url(r'^realm_activity/(?P<realm>[\S]+)/$', 'get_realm_activity'),
url(r'^user_activity/(?P<email>[\S]+)/$', 'get_user_activity'),
)
i18n_urlpatterns = [
url(r'^activity$', 'analytics.views.get_activity'),
url(r'^realm_activity/(?P<realm>[\S]+)/$', 'analytics.views.get_realm_activity'),
url(r'^user_activity/(?P<email>[\S]+)/$', 'analytics.views.get_user_activity'),
]
urlpatterns = patterns('', *i18n_urlpatterns)

View File

@@ -1,13 +1,14 @@
from __future__ import absolute_import
from __future__ import division
from typing import Any, Dict, List, Tuple
from six import text_type
from typing import Any, Dict, List, Tuple, Optional, Sequence, Callable, Union
from django.db import connection
from django.db.models.query import QuerySet
from django.template import RequestContext, loader
from django.utils.html import mark_safe
from django.shortcuts import render_to_response
from django.core import urlresolvers
from django.http import HttpResponseNotFound
from django.http import HttpResponseNotFound, HttpRequest, HttpResponse
from jinja2 import Markup as mark_safe
from zerver.decorator import has_request_variables, REQ, zulip_internal
from zerver.models import get_realm, UserActivity, UserActivityInterval, Realm
@@ -25,10 +26,14 @@ from six.moves import range
from six.moves import zip
eastern_tz = pytz.timezone('US/Eastern')
from zproject.jinja2 import render_to_response
def make_table(title, cols, rows, has_row_class=False):
# type: (str, List[str], List[Any], bool) -> str
if not has_row_class:
def fix_row(row):
# type: (Any) -> Dict[str, Any]
return dict(cells=row, row_class=None)
rows = list(map(fix_row, rows))
@@ -42,6 +47,7 @@ def make_table(title, cols, rows, has_row_class=False):
return content
def dictfetchall(cursor):
# type: (connection.cursor) -> List[Dict[str, Any]]
"Returns all rows from a cursor as a dict"
desc = cursor.description
return [
@@ -51,6 +57,7 @@ def dictfetchall(cursor):
def get_realm_day_counts():
# type: () -> Dict[str, Dict[str, str]]
query = '''
select
r.domain,
@@ -85,11 +92,12 @@ def get_realm_day_counts():
result = {}
for domain in counts:
cnts = [counts[domain].get(age, 0) for age in range(8)]
min_cnt = min(cnts)
max_cnt = max(cnts)
raw_cnts = [counts[domain].get(age, 0) for age in range(8)]
min_cnt = min(raw_cnts)
max_cnt = max(raw_cnts)
def format_count(cnt):
# type: (int) -> str
if cnt == min_cnt:
good_bad = 'bad'
elif cnt == max_cnt:
@@ -99,12 +107,13 @@ def get_realm_day_counts():
return '<td class="number %s">%s</td>' % (good_bad, cnt)
cnts = ''.join(map(format_count, cnts))
cnts = ''.join(map(format_count, raw_cnts))
result[domain] = dict(cnts=cnts)
return result
def realm_summary_table(realm_minutes):
# type: (Dict[str, float]) -> str
query = '''
SELECT
realm.domain,
@@ -217,10 +226,10 @@ def realm_summary_table(realm_minutes):
row['history'] = ''
# augment data with realm_minutes
total_hours = 0
total_hours = 0.0
for row in rows:
domain = row['domain']
minutes = realm_minutes.get(domain, 0)
minutes = realm_minutes.get(domain, 0.0)
hours = minutes / 60.0
total_hours += hours
row['hours'] = str(int(hours))
@@ -235,6 +244,7 @@ def realm_summary_table(realm_minutes):
# Count active sites
def meets_goal(row):
# type: (Dict[str, int]) -> bool
return row['active_user_count'] >= 5
num_active_sites = len(list(filter(meets_goal, rows)))
@@ -243,10 +253,12 @@ def realm_summary_table(realm_minutes):
total_active_user_count = 0
total_user_profile_count = 0
total_bot_count = 0
total_at_risk_count = 0
for row in rows:
total_active_user_count += int(row['active_user_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'])
rows.append(dict(
@@ -254,7 +266,8 @@ def realm_summary_table(realm_minutes):
active_user_count=total_active_user_count,
user_profile_count=total_user_profile_count,
bot_count=total_bot_count,
hours=int(total_hours)
hours=int(total_hours),
at_risk_count=total_at_risk_count,
))
content = loader.render_to_string(
@@ -265,6 +278,7 @@ def realm_summary_table(realm_minutes):
def user_activity_intervals():
# type: () -> Tuple[mark_safe, Dict[str, float]]
day_end = timestamp_to_datetime(time.time())
day_start = day_end - timedelta(hours=24)
@@ -304,7 +318,7 @@ def user_activity_intervals():
total_duration += duration
realm_duration += duration
output += " %-*s%s\n" % (37, email, duration, )
output += " %-*s%s\n" % (37, email, duration)
realm_minutes[domain] = realm_duration.total_seconds() / 60
@@ -315,6 +329,7 @@ def user_activity_intervals():
return content, realm_minutes
def sent_messages_report(realm):
# type: (str) -> str
title = 'Recently sent messages for ' + realm
cols = [
@@ -382,7 +397,9 @@ 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]
cursor = connection.cursor()
cursor.execute(query)
rows = cursor.fetchall()
@@ -390,6 +407,7 @@ def ad_hoc_queries():
cursor.close()
def fix_rows(i, fixup_func):
# type: (int, Union[Callable[[Realm], mark_safe], Callable[[datetime], str]]) -> None
for row in rows:
row[i] = fixup_func(row[i])
@@ -552,8 +570,9 @@ def ad_hoc_queries():
@zulip_internal
@has_request_variables
def get_activity(request):
duration_content, realm_minutes = user_activity_intervals()
counts_content = realm_summary_table(realm_minutes)
# type: (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 = [
('Counts', counts_content),
('Durations', duration_content),
@@ -566,10 +585,11 @@ def get_activity(request):
return render_to_response(
'analytics/activity.html',
dict(data=data, title=title, is_home=True),
context_instance=RequestContext(request)
request=request
)
def get_user_activity_records_for_realm(realm, is_bot):
# type: (str, bool) -> QuerySet
fields = [
'user_profile__full_name',
'user_profile__email',
@@ -589,6 +609,7 @@ def get_user_activity_records_for_realm(realm, is_bot):
return records
def get_user_activity_records_for_email(email):
# type: (str) -> List[QuerySet]
fields = [
'user_profile__full_name',
'query',
@@ -605,6 +626,7 @@ def get_user_activity_records_for_email(email):
return records
def raw_user_activity_table(records):
# type: (List[QuerySet]) -> str
cols = [
'query',
'client',
@@ -613,6 +635,7 @@ def raw_user_activity_table(records):
]
def row(record):
# type: (QuerySet) -> List[Any]
return [
record.query,
record.client.name,
@@ -625,9 +648,15 @@ def raw_user_activity_table(records):
return make_table(title, cols, rows)
def get_user_activity_summary(records):
# type: (Any) -> Any
# type: (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:
# `Union[Dict[str, Dict[str, int]], Dict[str, Dict[str, datetime]]]`
#: 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
if action not in summary:
summary[action] = dict(
count=record.count,
@@ -669,24 +698,28 @@ def get_user_activity_summary(records):
return summary
def format_date_for_activity_reports(date):
# type: (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
url_name = 'analytics.views.get_user_activity'
url = urlresolvers.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):
# type: (str) -> mark_safe
url_name = 'analytics.views.get_realm_activity'
url = urlresolvers.reverse(url_name, kwargs=dict(realm=realm))
realm_link = '<a href="%s">%s</a>' % (url, realm)
return mark_safe(realm_link)
def realm_client_table(user_summaries):
# type: (Dict[str, Dict[str, Dict[str, Any]]]) -> str
exclude_keys = [
'internal',
'name',
@@ -731,6 +764,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
rows = []
for k, v in user_summary.items():
if k == 'name':
@@ -757,28 +791,33 @@ def user_activity_summary_table(user_summary):
return make_table(title, cols, rows)
def realm_user_summary_table(all_records, admin_emails):
# type: (List[QuerySet], Set[text_type]) -> Tuple[Dict[str, Dict[str, Any]], str]
user_records = {}
def by_email(record):
# type: (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]
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
if k in user_summary:
return user_summary[k]['count']
else:
return ''
def is_recent(val):
age = datetime.now(val.tzinfo) - val
# type: (Optional[datetime]) -> bool
age = datetime.now(val.tzinfo) - val # type: ignore # datetie.now tzinfo bug.
return age.total_seconds() < 5 * 60
rows = []
@@ -788,18 +827,19 @@ def realm_user_summary_table(all_records, admin_emails):
cells = [user_summary['name'], email_link, sent_count]
row_class = ''
for field in ['use', 'send', 'pointer', 'desktop', 'ZulipiOS', 'Android']:
val = get_last_visit(user_summary, field)
visit = get_last_visit(user_summary, field)
if field == 'use':
if val and is_recent(val):
if visit and is_recent(visit):
row_class += ' recently_active'
if email in admin_emails:
row_class += ' admin'
val = format_date_for_activity_reports(val)
val = format_date_for_activity_reports(visit)
cells.append(val)
row = dict(cells=cells, row_class=row_class)
rows.append(row)
def by_used_time(row):
# type: (Dict[str, Sequence[str]]) -> str
return row['cells'][3]
rows = sorted(rows, key=by_used_time, reverse=True)
@@ -823,7 +863,7 @@ def realm_user_summary_table(all_records, admin_emails):
@zulip_internal
def get_realm_activity(request, realm):
# type: (Any, Any) -> Any
# type: (HttpRequest, str) -> HttpResponse
data = [] # type: List[Tuple[str, str]]
all_user_records = {} # type: Dict[str, Any]
@@ -860,11 +900,12 @@ def get_realm_activity(request, realm):
return render_to_response(
'analytics/activity.html',
dict(data=data, realm_link=realm_link, title=title),
context_instance=RequestContext(request)
request=request
)
@zulip_internal
def get_user_activity(request, email):
# type: (HttpRequest, str) -> HttpResponse
records = get_user_activity_records_for_email(email)
data = [] # type: List[Tuple[str, str]]
@@ -880,5 +921,5 @@ def get_user_activity(request, email):
return render_to_response(
'analytics/activity.html',
dict(data=data, title=title),
context_instance=RequestContext(request)
request=request
)

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# zulip-send -- Sends a message to the specified recipients.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2012-2014 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2012 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2012 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2014 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2012 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2012 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2012 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2012 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2012 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2012 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2012 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2012 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright © 2014 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Asana integration for Zulip

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright © 2014 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Zulip mirror of Basecamp activity

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright © 2014 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Zulip mirror of Codebase HQ activity
@@ -135,7 +135,7 @@ def handle_event(event):
content = "%s deleted branch %s from %s" % (actor_name, branch, project)
else:
if new_ref:
branch = "new branch %s" % (branch, )
branch = "new branch %s" % (branch,)
content = "%s pushed %s commit(s) to %s in project %s:\n\n" % \
(actor_name, num_commits, branch, project)
for commit in raw_props.get('commits'):
@@ -208,7 +208,8 @@ def handle_event(event):
subject = "Discussion: %s" % (subj,)
if category:
content = "%s started a new discussion in %s:\n\n~~~ quote\n%s\n~~~" % (actor_name, category, comment_content)
format_str = "%s started a new discussion in %s:\n\n~~~ quote\n%s\n~~~"
content = format_str % (actor_name, category, comment_content)
else:
content = "%s posted:\n\n~~~ quote\n%s\n~~~" % (actor_name, comment_content)
@@ -223,7 +224,8 @@ def handle_event(event):
start_ref_url = make_url("projects/%s/repositories/%s/commit/%s" % (project_link, repo_link, start_ref))
end_ref_url = make_url("projects/%s/repositories/%s/commit/%s" % (project_link, repo_link, end_ref))
between_url = make_url("projects/%s/repositories/%s/compare/%s...%s" % (project_link, repo_link, start_ref, end_ref))
between_url = make_url("projects/%s/repositories/%s/compare/%s...%s" % (
project_link, repo_link, start_ref, end_ref))
subject = "Deployment to %s" % (environment,)

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Zulip notification post-receive hook.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright © 2014 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Zulip hook for Mercurial changeset pushes.
@@ -24,7 +24,7 @@
#
#
# This hook is called when changesets are pushed to the master repository (ie
# `hg push`). See https://zulip.com/integrations for installation instructions.
# `hg push`). See https://zulipchat.com/integrations for installation instructions.
from __future__ import absolute_import
import zulip

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
import optparse
import zulip

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
#
# git-p4.py -- A tool for bidirectional operation between a Perforce depot and git.
#
@@ -33,7 +33,7 @@ import stat
try:
from subprocess import CalledProcessError
except ImportError:
# from python2.7:subprocess.py
# from python:subprocess.py
# Exception classes used by this module.
class CalledProcessError(Exception):
"""This exception is raised when a process run by check_call() returns

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright © 2012-2014 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright © 2014 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# RSS integration for Zulip

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Zulip notification post-commit hook.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright © 2014 Zulip, Inc.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Twitter integration for Zulip
@@ -45,11 +45,12 @@ parser = optparse.OptionParser(r"""
Slurp tweets on your timeline into a specific zulip stream.
Run this on your personal machine. Your API key and twitter id are revealed to local
users through the command line or config file.
Run this on your personal machine. Your API key and twitter id
are revealed to local users through the command line or config
file.
This bot uses OAuth to authenticate with twitter. Please create a ~/.zulip_twitterrc with
the following contents:
This bot uses OAuth to authenticate with twitter. Please create a
~/.zulip_twitterrc with the following contents:
[twitter]
consumer_key =
@@ -57,14 +58,16 @@ parser = optparse.OptionParser(r"""
access_token_key =
access_token_secret =
In order to obtain a consumer key & secret, you must register a new application under your twitter account:
In order to obtain a consumer key & secret, you must register a
new application under your twitter account:
1. Go to http://dev.twitter.com
2. Log in
3. In the menu under your username, click My Applications
4. Create a new application
Make sure to go the application you created and click "create my access token" as well. Fill in the values displayed.
Make sure to go the application you created and click "create my
access token" as well. Fill in the values displayed.
Depends on: twitter-python
""")

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Twitter search integration for Zulip

View File

@@ -1,8 +1,8 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
from typing import Any, Generator, List, Tuple
if False: from typing import Any, Generator, List, Tuple
import os
import sys
@@ -10,6 +10,7 @@ import sys
import itertools
def version():
# type: () -> str
version_py = os.path.join(os.path.dirname(__file__), "zulip", "__init__.py")
with open(version_py) as in_handle:
version_line = next(itertools.dropwhile(lambda x: not x.startswith("__version__"),
@@ -46,7 +47,7 @@ package_info = dict(
"examples/print-messages", "examples/recent-messages"])] + \
list(recur_expand('share/zulip', 'integrations/')),
scripts=["bin/zulip-send"],
)
) # type: Dict[str, Any]
setuptools_info = dict(
install_requires=['requests>=0.12.1',

View File

@@ -38,6 +38,7 @@ from six.moves.configparser import SafeConfigParser
from six.moves import urllib
import logging
import six
from typing import Any, Dict
__version__ = "0.2.5"
@@ -46,7 +47,7 @@ logger = logging.getLogger(__name__)
# Check that we have a recent enough version
# Older versions don't provide the 'json' attribute on responses.
assert(LooseVersion(requests.__version__) >= LooseVersion('0.12.1'))
assert(LooseVersion(requests.__version__) >= LooseVersion('0.12.1')) # type: ignore # https://github.com/python/mypy/issues/1165 and https://github.com/python/typeshed/pull/206
# In newer versions, the 'json' attribute is a function, not a property
requests_json_is_function = callable(requests.Response.json)
@@ -133,6 +134,17 @@ def generate_option_group(parser, prefix=''):
CA certificates. This will be used to
verify the server's identity. All
certificates should be PEM encoded.''')
group.add_option('--client-cert',
action='store',
dest='client_cert',
help='''Specify a file containing a client
certificate (not needed for most deployments).''')
group.add_option('--client-cert-key',
action='store',
dest='client_cert_key',
help='''Specify a file containing the client
certificate's key (if it is in a separate
file).''')
return group
def init_from_options(options, client=None):
@@ -143,20 +155,24 @@ def init_from_options(options, client=None):
return Client(email=options.zulip_email, api_key=options.zulip_api_key,
config_file=options.zulip_config_file, verbose=options.verbose,
site=options.zulip_site, client=client,
cert_bundle=options.cert_bundle, insecure=options.insecure)
cert_bundle=options.cert_bundle, insecure=options.insecure,
client_cert=options.client_cert,
client_cert_key=options.client_cert_key)
def get_default_config_filename():
config_file = os.path.join(os.environ["HOME"], ".zuliprc")
if (not os.path.exists(config_file) and
os.path.exists(os.path.join(os.environ["HOME"], ".humbugrc"))):
raise RuntimeError("The Zulip API configuration file is now ~/.zuliprc; please run:\n\n mv ~/.humbugrc ~/.zuliprc\n")
raise RuntimeError("The Zulip API configuration file is now ~/.zuliprc; please run:\n\n"
" mv ~/.humbugrc ~/.zuliprc\n")
return config_file
class Client(object):
def __init__(self, email=None, api_key=None, config_file=None,
verbose=False, retry_on_errors=True,
site=None, client=None,
cert_bundle=None, insecure=None):
cert_bundle=None, insecure=None,
client_cert=None, client_cert_key=None):
if client is None:
client = _default_client()
@@ -172,6 +188,10 @@ class Client(object):
email = config.get("api", "email")
if site is None and config.has_option("api", "site"):
site = config.get("api", "site")
if client_cert is None and config.has_option("api", "client_cert"):
client_cert = config.get("api", "client_cert")
if client_cert_key is None and config.has_option("api", "client_cert_key"):
client_cert_key = config.get("api", "client_cert_key")
if cert_bundle is None and config.has_option("api", "cert_bundle"):
cert_bundle = config.get("api", "cert_bundle")
if insecure is None and config.has_option("api", "insecure"):
@@ -218,6 +238,21 @@ class Client(object):
# Default behavior: verify against system CA certificates
self.tls_verification=True
if client_cert is None:
if client_cert_key is not None:
raise RuntimeError("client cert key '%s' specified, but no client cert public part provided"
%(client_cert_key,))
else: # we have a client cert
if not os.path.isfile(client_cert):
raise RuntimeError("client cert '%s' does not exist"
%(client_cert,))
if client_cert_key is not None:
if not os.path.isfile(client_cert_key):
raise RuntimeError("client cert key '%s' does not exist"
%(client_cert_key,))
self.client_cert = client_cert
self.client_cert_key = client_cert_key
def get_user_agent(self):
vendor = ''
vendor_version = ''
@@ -246,16 +281,16 @@ class Client(object):
request = {}
for (key, val) in six.iteritems(orig_request):
if not (isinstance(val, str) or isinstance(val, six.text_type)):
request[key] = simplejson.dumps(val)
else:
if isinstance(val, str) or isinstance(val, six.text_type):
request[key] = val
else:
request[key] = simplejson.dumps(val)
query_state = {
'had_error_retry': False,
'request': request,
'failures': 0,
}
} # type: Dict[str, Any]
def error_retry(error_string):
if not self.retry_on_errors or query_state["failures"] >= 10:
@@ -287,12 +322,21 @@ class Client(object):
else:
kwarg = "data"
kwargs = {kwarg: query_state["request"]}
# Build a client cert object for requests
if self.client_cert_key is not None:
client_cert = (self.client_cert, self.client_cert_key)
else:
client_cert = self.client_cert
res = requests.request(
method,
urllib.parse.urljoin(self.base_url, url),
auth=requests.auth.HTTPBasicAuth(self.email,
self.api_key),
verify=self.tls_verification, timeout=90,
verify=self.tls_verification,
cert=client_cert,
timeout=90,
headers={"User-agent": self.get_user_agent()},
**kwargs)
@@ -343,10 +387,15 @@ class Client(object):
"status_code": res.status_code}
@classmethod
def _register(cls, name, url=None, make_request=(lambda request={}: request),
def _register(cls, name, url=None, make_request=None,
method="POST", computed_url=None, **query_kwargs):
if url is None:
url = name
if make_request is None:
def make_request(request=None):
if request is None:
request = {}
return request
def call(self, *args, **kwargs):
request = make_request(*args, **kwargs)
if computed_url is not None:
@@ -357,7 +406,9 @@ class Client(object):
call.__name__ = name
setattr(cls, name, call)
def call_on_each_event(self, callback, event_types=None, narrow=[]):
def call_on_each_event(self, callback, event_types=None, narrow=None):
if narrow is None:
narrow = []
def do_register():
while True:
if event_types is None:
@@ -425,9 +476,11 @@ def _mk_rm_subs(streams):
def _mk_deregister(queue_id):
return {'queue_id': queue_id}
def _mk_events(event_types=None, narrow=[]):
def _mk_events(event_types=None, narrow=None):
if event_types is None:
return dict()
if narrow is None:
narrow = []
return dict(event_types=event_types, narrow=narrow)
def _kwargs_to_dict(**kwargs):

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
from __future__ import absolute_import
import xml.etree.ElementTree as ET
import subprocess

View File

@@ -1,16 +0,0 @@
#!/usr/bin/env bash
set -e
queue=$1
if [ -z "$queue" ]; then
echo "Usage: $0 <queue-name>"
exit 2
fi
ZULIP_DIR=/home/zulip/deployments/current
STATE_DIR=/var/lib/nagios_state
STATE_FILE=$STATE_DIR/check-rabbitmq-consumers-$queue
"$ZULIP_DIR/bots/check-rabbitmq-consumers" "--queue=$queue" &> "${STATE_FILE}-tmp";
mv "${STATE_FILE}-tmp" "$STATE_FILE"

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
from __future__ import print_function
from __future__ import absolute_import
import sys

View File

@@ -1,56 +0,0 @@
#!/usr/bin/env python2.7
from __future__ import print_function
import sys
import time
import optparse
from collections import defaultdict
import os
import subprocess
states = {
0: "OK",
1: "WARNING",
2: "CRITICAL",
3: "UNKNOWN"
}
if 'USER' in os.environ and not os.environ['USER'] in ['root', 'rabbitmq']:
print("This script must be run as the root or rabbitmq user")
usage = """Usage: check-rabbitmq-consumers --queue=[queue-name] --min-threshold=[min-threshold]"""
parser = optparse.OptionParser(usage=usage)
parser.add_option('--queue',
dest='queue_name',
default="notify_tornado",
action='store')
parser.add_option('--min-threshold',
dest='min_count',
type="int",
default=1,
action='store')
(options, args) = parser.parse_args()
output = subprocess.check_output(['/usr/sbin/rabbitmqctl', 'list_consumers'], shell=False)
consumers = defaultdict(int)
for line in output.split('\n'):
parts = line.split('\t')
if len(parts) and parts[0] == options.queue_name:
consumers[parts[0]] += 1
now = int(time.time())
if consumers[options.queue_name] < options.min_count:
status = 2
else:
status = 0
print("%s|%s|%s|queue %s has %s consumers, needs %s" % (
now, status, states[status], options.queue_name,
consumers[options.queue_name], options.min_count))

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
from __future__ import print_function
import sys
import time

View File

@@ -1,4 +1,4 @@
#! /usr/bin/env python2.7
#!/usr/bin/env python
#
# EXPERIMENTAL
# IRC <=> Zulip mirroring bot
@@ -93,11 +93,11 @@ class IRCBot(irc.bot.SingleServerIRCBot):
return
self.dcc_connect(address, port)
usage = """python2.7 irc-mirror.py --server=IRC_SERVER --channel=<CHANNEL> --nick-prefix=<NICK> [optional args]
usage = """python irc-mirror.py --server=IRC_SERVER --channel=<CHANNEL> --nick-prefix=<NICK> [optional args]
Example:
python2.7 irc-mirror.py --irc-server=127.0.0.1 --channel='#test' --nick-prefix=username
python irc-mirror.py --irc-server=127.0.0.1 --channel='#test' --nick-prefix=username
--site=https://zulip.example.com --user=irc-bot@example.com
--api-key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# Copyright (C) 2014 Zulip, Inc.
#
# Permission is hereby granted, free of charge, to any person
@@ -27,10 +27,13 @@ import subprocess
import os
import traceback
import signal
from types import FrameType
from typing import Any
from zulip import RandomExponentialBackoff
def die(signal, frame):
# We actually want to exit, so run os._exit (so as not to be caught and restarted)
# type: (int, FrameType) -> None
"""We actually want to exit, so run os._exit (so as not to be caught and restarted)"""
os._exit(1)
signal.signal(signal.SIGINT, die)

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
#
# Copyright (C) 2013 Permabit, Inc.
# Copyright (C) 2013--2014 Zulip, Inc.
@@ -381,7 +381,8 @@ option does not affect login credentials.'''.replace("\n", " "))
config.readfp(f, config_file)
except IOError:
pass
for option in ("jid", "jabber_password", "conference_domain", "mode", "zulip_email_suffix", "jabber_server_address", "jabber_server_port"):
for option in ("jid", "jabber_password", "conference_domain", "mode", "zulip_email_suffix",
"jabber_server_address", "jabber_server_port"):
if (getattr(options, option) is None
and config.has_option("jabber_mirror", option)):
setattr(options, option, config.get("jabber_mirror", option))

View File

@@ -1,16 +1,25 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
from __future__ import print_function
import subprocess
import os
import sys
import shutil
import errno
import json
import ujson
import os
import platform
import re
import sys
import shutil
import subprocess
import traceback
try:
# Use the Zulip virtualenv if available
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import scripts.lib.setup_path_on_import
except ImportError:
pass
import json
import ujson
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../api"))
import zulip

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
import sys
import subprocess
import base64

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
import sys
import os
import logging

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# Copyright (C) 2012 Zulip, Inc.
#
# Permission is hereby granted, free of charge, to any person

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# Copyright (C) 2012 Zulip, Inc.
#
# Permission is hereby granted, free of charge, to any person
@@ -31,15 +31,21 @@ import signal
from .zephyr_mirror_backend import parse_args
(options, args) = parse_args()
sys.path[:0] = [os.path.join(options.root_path, 'api')]
from types import FrameType
from typing import Any
def die(signal, frame):
# type: (int, FrameType) -> None
# We actually want to exit, so run os._exit (so as not to be caught and restarted)
os._exit(1)
signal.signal(signal.SIGINT, die)
(options, args) = parse_args()
sys.path[:0] = [os.path.join(options.root_path, 'api')]
from zulip import RandomExponentialBackoff
args = [os.path.join(options.root_path, "user_root", "zephyr_mirror_backend.py")]
@@ -57,6 +63,7 @@ if options.forward_class_messages and not options.noshard:
print("Starting parallel zephyr class mirroring bot")
jobs = list("0123456789abcdef")
def run_job(shard):
# type: (str) -> int
subprocess.call(args + ["--shard=%s" % (shard,)])
return 0
for (status, job) in run_parallel(run_job, jobs, threads=16):

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
# Copyright (C) 2012 Zulip, Inc.
#
# Permission is hereby granted, free of charge, to any person
@@ -92,7 +92,7 @@ def different_paragraph(line, next_line):
len(line) < len(words[0]))
# Linewrapping algorithm based on:
# http://gcbenison.wordpress.com/2011/07/03/a-program-to-intelligently-remove-carriage-returns-so-you-can-paste-text-without-having-it-look-awful/
# http://gcbenison.wordpress.com/2011/07/03/a-program-to-intelligently-remove-carriage-returns-so-you-can-paste-text-without-having-it-look-awful/ #ignorelongline
def unwrap_lines(body):
lines = body.split("\n")
result = ""
@@ -598,7 +598,7 @@ def zcrypt_encrypt_content(zephyr_class, instance, content):
def forward_to_zephyr(message):
support_heading = "Hi there! This is an automated message from Zulip."
support_closing = """If you have any questions, please be in touch through the \
Feedback button or at support@zulip.com."""
Feedback button or at support@zulipchat.com."""
wrapper = textwrap.TextWrapper(break_long_words=False, break_on_hyphens=False)
wrapped_content = "\n".join("\n".join(wrapper.wrap(line))

View File

@@ -1,81 +0,0 @@
# Change Log
All notable changes to this project will be documented in this file.
[Unreleased]
[1.3.11]
- Moved email digest support into the default Zulip production configuration.
- Added options for configuring Postgres, RabbitMQ, Redis, and memcached
in settings.py.
- Added documentation on using Hubot to integrate with useful services
not yet integrated with Zulip directly (e.g. Google Hangouts).
- Added new management command to test sending email from Zulip.
- Added Codeship, Pingdom, Taiga, Teamcity, and Yo integrations.
- Added Nagios plugins to the main distribution.
- Added ability for realm administrators to manage custom emoji.
- Added guide to writing new integrations.
- Enabled camo image proxy to fix mixed-content warnings for http images.
- Refactored the Zulip puppet modules to be more modular.
- Refactored the Tornado event system, fixing old memory leaks.
- Removed many old-style /json API endpoints
- Implemented running queue processors multithreaded in development,
decreasing RAM requirements for a Zulip development environment from
~1GB to ~300MB.
- Fixed rerendering the complete buddy list whenever a user came back from
idle, which was a significant performance issue in larger realms.
- Fixed the disabling of desktop notifications from 1.3.7 for new users.
- Fixed the (admin) create_user API enforcing restricted_to_domain, even
if that setting was disabled for the realm.
- Fixed bugs changing certain settings in administration pages.
- Fixed collapsing messages in narrowed views.
- Fixed 500 errors when uploading a non-image file as an avatar.
- Fixed Jira integration incorrectly not @-mentioning assignee.
[1.3.10]
- Added new integration for Travis CI.
- Added settings option to control maximum file upload size.
- Added support for running Zulip development environment in Docker.
- Added easy configuration support for a remote postgres database.
- Added extensive documentation on scalability, backups, and security.
- Recent private message threads are now displayed expanded similar to
the pre-existing recent topics feature.
- Made it possible to set LDAP and EMAIL_HOST passwords in
/etc/zulip/secrets.conf.
- Improved the styling for the Administration page and added tabs.
- Substantially improved loading performance on slow networks by enabling
GZIP compression on more assets.
- Changed the page title in narrowed views to include the current narrow.
- Fixed several backend performance issues affecting very large realms.
- Fixed bugs where draft compose content might be lost when reloading site.
- Fixed support for disabling the "zulip" notifications stream.
- Fixed missing step in postfix_localmail installation instructions.
- Fixed several bugs/inconveniences in the production upgrade process.
- Fixed realm restrictions for servers with a unique, open realm.
- Substantially cleaned up console logging from run-dev.py.
[1.3.9] - 2015-11-16
- Fixed buggy #! lines in upgrade scripts.
[1.3.8] - 2015-11-15
- Added options to the Python api for working with untrusted server certificates.
- Added a lot of documentation on the development environment and testing.
- Added partial support for translating the Zulip UI.
- Migrated installing Node dependencies to use npm.
- Fixed LDAP integration breaking autocomplete of @-mentions.
- Fixed admin panel reactivation/deactivation of bots.
- Fixed inaccurate documentation for downloading the desktop apps.
- Fixed various minor bugs in production installation process.
- Fixed security issue where recent history on private streams might
be visible to new users (to the Zulip team) who were invited with that
private stream as one of their initial streams
(https://github.com/zulip/zulip/issues/230).
- Major preliminary progress towards supporting Python 3.
[1.3.7] - 2015-10-19
- Turn off desktop and audible notifications for streams by default.
- Added support for the LDAP authentication integration creating new users.
- Added new endpoint to support Google auth on mobile.
- Fixed desktop notifications in modern Firefox.
- Fixed several installation issues for both production and development environments.
- Improved documentation for outgoing SMTP and the email mirror integration.

View File

@@ -2,23 +2,23 @@
# Copyright: (c) 2008, Jarek Zgoda <jarek.zgoda@gmail.com>
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, dis-
# tribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the fol-
# lowing conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish, dis-
# tribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the fol-
# lowing conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
VERSION = (0, 9, 'pre')

View File

@@ -4,6 +4,7 @@
__revision__ = '$Id: cleanupconfirmation.py 5 2008-11-18 09:10:12Z jarek.zgoda $'
from typing import Any
from django.core.management.base import NoArgsCommand
@@ -14,4 +15,5 @@ class Command(NoArgsCommand):
help = 'Delete expired confirmations from database'
def handle_noargs(self, **options):
# type: (**Any) -> None
Confirmation.objects.delete_expired_confirmations()

View File

@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('confirmation', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='RealmCreationKey',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('creation_key', models.CharField(max_length=40, verbose_name='activation key')),
('date_created', models.DateTimeField(default=django.utils.timezone.now, verbose_name='created')),
],
),
]

View File

@@ -30,15 +30,33 @@ except ImportError:
B16_RE = re.compile('^[a-f0-9]{40}$')
def check_key_is_valid(creation_key):
if not RealmCreationKey.objects.filter(creation_key=creation_key).exists():
return False
days_sofar = (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 generate_key():
return generate_random_token(40)
def generate_activation_url(key):
def generate_activation_url(key, host=None):
if host is None:
host = settings.EXTERNAL_HOST
return u'%s%s%s' % (settings.EXTERNAL_URI_SCHEME,
settings.EXTERNAL_HOST,
host,
reverse('confirmation.views.confirm',
kwargs={'confirmation_key': key}))
def generate_realm_creation_url():
key = generate_key()
RealmCreationKey.objects.create(creation_key=key, date_created=now())
return u'%s%s%s' % (settings.EXTERNAL_URI_SCHEME,
settings.EXTERNAL_HOST,
reverse('zerver.views.create_realm',
kwargs={'creation_key': key}))
class ConfirmationManager(models.Manager):
@@ -55,16 +73,17 @@ class ConfirmationManager(models.Manager):
return obj
return False
def get_link_for_object(self, obj):
def get_link_for_object(self, obj, host=None):
key = generate_key()
self.create(content_object=obj, date_sent=now(), confirmation_key=key)
return generate_activation_url(key)
return generate_activation_url(key, host=host)
def send_confirmation(self, obj, email_address, additional_context=None,
subject_template_path=None, body_template_path=None):
subject_template_path=None, body_template_path=None,
host=None):
confirmation_key = generate_key()
current_site = Site.objects.get_current()
activate_url = generate_activation_url(confirmation_key)
activate_url = generate_activation_url(confirmation_key, host=host)
context = Context({
'activate_url': activate_url,
'current_site': current_site,
@@ -74,8 +93,12 @@ class ConfirmationManager(models.Manager):
})
if additional_context is not None:
context.update(additional_context)
if obj.realm is not None and obj.realm.is_zephyr_mirror_realm:
template_name = "mituser"
else:
template_name = obj._meta.model_name
templates = [
'confirmation/%s_confirmation_email_subject.txt' % obj._meta.model_name,
'confirmation/%s_confirmation_email_subject.txt' % (template_name,),
'confirmation/confirmation_email_subject.txt',
]
if subject_template_path:
@@ -84,7 +107,7 @@ class ConfirmationManager(models.Manager):
template = loader.select_template(templates)
subject = template.render(context).strip().replace(u'\n', u' ') # no newlines, please
templates = [
'confirmation/%s_confirmation_email_body.txt' % obj._meta.model_name,
'confirmation/%s_confirmation_email_body.txt' % (template_name,),
'confirmation/confirmation_email_body.txt',
]
if body_template_path:
@@ -110,4 +133,8 @@ class Confirmation(models.Model):
verbose_name_plural = _('confirmation emails')
def __unicode__(self):
return _('confirmation email for %s') % self.content_object
return _('confirmation email for %s') % (self.content_object,)
class RealmCreationKey(models.Model):
creation_key = models.CharField(_('activation key'), max_length=40)
date_created = models.DateTimeField(_('created'), default=now)

View File

@@ -9,4 +9,4 @@ from django.conf import settings
def get_status_field(app_label, model_name):
model = '%s.%s' % (app_label, model_name)
mapping = getattr(settings, 'STATUS_FIELDS', {})
return mapping.get(model, 'status')
return mapping.get(model, 'status')

View File

@@ -8,11 +8,14 @@ __revision__ = '$Id: views.py 21 2008-12-05 09:21:03Z jarek.zgoda $'
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.conf import settings
from django.http import HttpRequest, HttpResponse
from confirmation.models import Confirmation
from zproject.jinja2 import render_to_response
def confirm(request, confirmation_key):
# type: (HttpRequest, str) -> HttpResponse
confirmation_key = confirmation_key.lower()
obj = Confirmation.objects.confirm(confirmation_key)
confirmed = True
@@ -31,13 +34,12 @@ def confirm(request, confirmation_key):
'key': confirmation_key,
'full_name': request.GET.get("full_name", None),
'support_email': settings.ZULIP_ADMINISTRATOR,
'voyager': settings.VOYAGER
'verbose_support_offers': settings.VERBOSE_SUPPORT_OFFERS,
}
templates = [
'confirmation/confirm.html',
]
if obj:
# if we have an object, we can use specific template
templates.insert(0, 'confirmation/confirm_%s.html' % obj._meta.model_name)
return render_to_response(templates, ctx,
context_instance=RequestContext(request))
templates.insert(0, 'confirmation/confirm_%s.html' % (obj._meta.model_name,))
return render_to_response(templates, ctx, request=request)

View File

View File

@@ -0,0 +1,53 @@
# See readme.md for instructions on running this code.
class FollowupHandler(object):
'''
This plugin facilitates creating follow-up tasks when
you are using Zulip to conduct a virtual meeting. It
looks for messages starting with '@followup'.
In this example, we write follow up items to a special
Zulip stream called "followup," but this code could
be adapted to write follow up items to some kind of
external issue tracker as well.
'''
def usage(self):
return '''
This plugin will allow users to flag messages
as being follow-up items. Users should preface
messages with "@followup".
Before running this, make sure to create a stream
called "followup" that your API user can send to.
'''
def triage_message(self, message):
# return True iff we want to (possibly) response to this message
original_content = message['content']
# This next line of code is defensive, as we
# never want to get into an infinite loop of posting follow
# ups for own follow ups!
if message['display_recipient'] == 'followup':
return False
is_follow_up = (original_content.startswith('@followup') or
original_content.startswith('@follow-up'))
return is_follow_up
def handle_message(self, message, client):
original_content = message['content']
original_sender = message['sender_email']
new_content = original_content.replace('@followup',
'from %s:' % (original_sender,))
client.send_message(dict(
type='stream',
to='followup',
subject=message['sender_email'],
content=new_content,
))
handler_class = FollowupHandler

39
contrib_bots/lib/help.py Normal file
View File

@@ -0,0 +1,39 @@
# See readme.md for instructions on running this code.
class HelpHandler(object):
def usage(self):
return '''
This plugin will give info about Zulip to
any user that types a message saying "help".
This is example code; ideally, you would flesh
this out for more useful help pertaining to
your Zulip instance.
'''
def triage_message(self, message):
# return True if we think the message may be of interest
original_content = message['content']
if message['type'] != 'stream':
return True
if original_content.lower().strip() != 'help':
return False
return True
def handle_message(self, message, client):
help_content = '''
Info on Zulip can be found here:
https://github.com/zulip/zulip
'''.strip()
client.send_message(dict(
type='stream',
to=message['display_recipient'],
subject=message['subject'],
content=help_content,
))
handler_class = HelpHandler

109
contrib_bots/lib/readme.md Normal file
View File

@@ -0,0 +1,109 @@
# Overview
This is the documentation for an experimental new system for writing
bots that react to messages.
This directory contains library code for running Zulip
bots that react to messages sent by users.
This document explains how to run the code, and it also
talks about the architecture for creating bots.
## Design goals
The goal is to have a common framework for hosting a bot that reacts
to messages in any of the following settings:
* Run as a long-running process using `call_on_each_event`
(implemented today).
* Run via a simple web service that can be deployed to PAAS providers
and handles outgoing webhook requests from Zulip.
* Embedded into the Zulip server (so that no hosting is required),
which would be done for high quality, reusable bots; we would have a
nice "bot store" sort of UI for browsing and activating them.
## Running bots
Here is an example of running the "follow-up" bot from
inside a Zulip repo:
cd ~/zulip/contrib_bots
python run.py lib/followup.py --config-file ~/.zuliprc-prod
Once the bot code starts running, you will see a
message explaining how to use the bot, as well as
some log messages. You can use the `--quiet` option
to suppress these messages.
The bot code will run continuously until you kill them with
control-C (or otherwise).
### Configuration
For this document we assume you have some prior experience
with using the Zulip API, but here is a quick review of
what a `.zuliprc` files looks like. You can connect to the
API as your own human user, or you can go into the Zulip settings
page to create a user-owned bot.
[api]
email=someuser@example.com
key=<your api key>
site=https://zulip.somewhere.com
## Architecture
In order to make bot development easy, we separate
out boilerplate code (loading up the Client API, etc.)
from bot-specific code (do what makes the bot unique).
All of the boilerplate code lives in `../run.py`. The
runner code does things like find where it can import
the Zulip API, instantiate a client with correct
credentials, set up the logging level, find the
library code for the specific bot, etc.
Then, for bot-specific logic, you will find `.py` files
in the `lib` directory (i.e. the same directory as the
document you are reading now).
Each bot library simply needs to do the following:
- Define a class that supports the methods `usage`,
`triage_message`, and `handle_message`.
- Set `handler_class` to be the name of that class.
(We make this a two-step process, so that you can give
a descriptive name to your handler class.)
## Portability
Creating a handler class for each bot allows your bot
code to be more portable. For example, if you want to
use your bot code in some other kind of bot platform, then
if all of your bots conform to the `handler_class` protocol,
you can write simple adapter code to use them elsewhere.
Another future direction to consider is that Zulip will
eventually support running certain types of bots on
the server side, to essentially implement post-send
hooks and things of those nature.
Conforming to the `handler_class` protocol will make
it easier for Zulip admins to integrate custom bots.
In particular, `run.py` already passes in instances
of a restricted variant of the Client class to your
library code, which helps you ensure that your bot
does only things that would be acceptable for running
in a server-side environment.
## Other approaches
If you are not interested in running your bots on the
server, then you can still use the full Zulip API. The
hope, though, is that this architecture will make
writing simple bots a quick/easy process.

100
contrib_bots/run.py Normal file
View File

@@ -0,0 +1,100 @@
from __future__ import print_function
import importlib
import logging
import optparse
import os
import sys
our_dir = os.path.dirname(os.path.abspath(__file__))
# For dev setups, we can find the API in the repo itself.
if os.path.exists(os.path.join(our_dir, '../api/zulip')):
sys.path.append('../api')
from zulip import Client
class RestrictedClient(object):
def __init__(self, client):
# Only expose a subset of our Client's functionality
self.send_message = client.send_message
def get_lib_module(lib_fn):
lib_fn = os.path.abspath(lib_fn)
if os.path.dirname(lib_fn) != os.path.join(our_dir, 'lib'):
print('Sorry, we will only import code from contrib_bots/lib.')
sys.exit(1)
if not lib_fn.endswith('.py'):
print('Please use a .py extension for library files.')
sys.exit(1)
sys.path.append('lib')
base_lib_fn = os.path.basename(os.path.splitext(lib_fn)[0])
module_name = 'lib.' + base_lib_fn
module = importlib.import_module(module_name)
return module
def run_message_handler_for_bot(lib_module, quiet, config_file):
# Make sure you set up your ~/.zuliprc
client = Client(config_file=config_file)
restricted_client = RestrictedClient(client)
message_handler = lib_module.handler_class()
if not quiet:
print(message_handler.usage())
def handle_message(message):
logging.info('waiting for next message')
if message_handler.triage_message(message=message):
message_handler.handle_message(
message=message,
client=restricted_client)
logging.info('starting message handling...')
client.call_on_each_message(handle_message)
def run():
usage = '''
python run.py <lib file>
Example: python run.py lib/followup.py
(This program loads bot-related code from the
library code and then runs a message loop,
feeding messages to the library code to handle.)
Please make sure you have a current ~/.zuliprc
file with the credentials you want to use for
this bot.
See lib/readme.md for more context.
'''
parser = optparse.OptionParser(usage=usage)
parser.add_option('--quiet', '-q',
action='store_true',
help='Turn off logging output.')
parser.add_option('--config-file',
action='store',
help='(alternate config file to ~/.zuliprc)')
(options, args) = parser.parse_args()
if len(args) == 0:
print('You must specify a library!')
sys.exit(1)
lib_module = get_lib_module(lib_fn=args[0])
if not options.quiet:
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
run_message_handler_for_bot(
lib_module=lib_module,
config_file=options.config_file,
quiet=options.quiet
)
if __name__ == '__main__':
run()

244
corporate/terms.md Normal file
View File

@@ -0,0 +1,244 @@
# Zulip Terms of Service
### Welcome to Zulip!
Thanks for using our products and services ("Services"). The Services are
provided by Zulip, Inc. ("Zulip"), located at 552 Massachusetts Ave Suite 203,
Cambridge, MA 02139, United States.
By using our Services, you are agreeing to these terms. Please read them
carefully.
The Services are not intended for use by you if you are under 13 years of
age. By agreeing to these terms, you are representing to us that you are over
13.
### Using our Services
You must follow any policies made available to you within the Services.
Don't misuse our Services. For example, don't interfere with our Services or
try to access them using a method other than the interface and the instructions
that we provide. You may use our Services only as permitted by law, including
applicable export and re-export control laws and regulations. We may suspend or
stop providing our Services to you if you do not comply with our terms or
policies or if we are investigating suspected misconduct.
Using our Services does not give you ownership of any intellectual property
rights in our Services or the content you access. You may not use content from
our Services unless you obtain permission from its owner or are otherwise
permitted by law. These terms do not grant you the right to use any branding or
logos used in our Services. Don't remove, obscure, or alter any legal notices
displayed in or along with our Services.
Our Services display some content that is not Zulip's. This content is the
sole responsibility of the entity that makes it available. We may review
content to determine whether it is illegal or violates our policies, and we may
remove or refuse to display content that we reasonably believe violates our
policies or the law. But that does not necessarily mean that we review content,
so please don't assume that we do.
In connection with your use of the Services, we may send you service
announcements, administrative messages, and other information. You may opt out
of some of those communications.
### Your Zulip Account
You may need a Zulip Account in order to use some of our Services. You may
create your own Zulip Account, or your Zulip Account may be assigned to you
by an administrator, such as your employer or educational institution. If you
are using a Zulip Account assigned to you by an administrator, different or
additional terms may apply and your administrator may be able to access or
disable your account.
If you learn of any unauthorized use of your password or account, contact
[support@zulip.com](mailto:support@zulip.com).
### Privacy and Copyright Protection
Zulip's [privacy policy](/privacy) explains how we treat your
personal data and protect your privacy when you use our Services. By using our
Services, you agree that Zulip can use such data in accordance with our
privacy policy.
We respond to notices of alleged copyright infringement and terminate
accounts of repeat infringers according to the process set out in the U.S.
Digital Millennium Copyright Act.
Our designated agent for notice of alleged copyright infringement on the
Services is:
> Copyright Agent
> Zulip, Inc.
> 552 Massachusetts Ave Suite 203
> Cambridge, MA 02139
> [copyright@zulip.com](mailto:copyright@zulip.com)
### Your Content in our Services
Some of our Services allow you to submit content. You retain ownership of
any intellectual property rights that you hold in that content. In short, what
belongs to you stays yours.
When you upload or otherwise submit content to our Services, you give Zulip
(and those we work with) a worldwide license to use, host, store, reproduce,
modify, create derivative works (such as those resulting from translations,
adaptations or other changes we make so that your content works better with our
Services), communicate, publish, perform, display and distribute such content.
The rights you grant in this license are for the limited purpose of operating
and improving our Services, and to develop new ones. This license continues
even if you stop using our Services (for example, so that we can deliver a
message that you sent to another Zulip Account before you stopped using our
Services). Some Services may offer you ways to access and remove content that
has been provided to that Service. Also, in some of our Services, there may be
terms or settings that narrow the scope of our use of the content submitted in
those Services. Make sure you have the necessary rights to grant us this
license for any content that you submit to our Services. If you use the
Services to share content with others, anyone you've shared content with
(including the general public, in certain circumstances) may have access to the
content.
In order to provide the Services, our servers save a record of the messages
received by each Zulip Account (the "Received Messsage Information" for the
account). If you are using our Services on behalf of a business and a
representative of that business sends [data@zulip.com](mailto:data@zulip.com)
a request to delete all of your business' accounts with us, then within a
commercially reasonable period of time, we will close all of your business'
accounts with us and delete the Received Message Information for each such
account by removing pointers to the information on our active servers and
overwriting it over time. Notwithstanding the foregoing, deleting the Received
Message Information for your business' accounts will not require deleting any
information about messages that were sent or received by any Zulip Accounts that
are not one of your business' accounts with us (such as system-wide announcement
messages or any messages corresponding with the Zulip support team).
You can find more information about how Zulip uses and stores content in
the privacy policy. If you submit feedback or suggestions about our Services,
we may use your feedback or suggestions without obligation to you.
### About Software in our Services
When a Service requires or includes downloadable software, this software may
update automatically on your device once a new version or feature is available.
Some Services may let you adjust your automatic update settings.
Zulip gives you a personal, worldwide, royalty-free, non-assignable and
non-exclusive license to use the software provided to you by Zulip as part of
the Services. This license is for the sole purpose of enabling you to use and
enjoy the benefit of the Services as provided by Zulip, in the manner
permitted by these terms. You may not copy, modify, distribute, sell, or lease
any part of our Services or included software, nor may you reverse engineer or
attempt to extract the source code of that software, unless laws prohibit those
restrictions or you have our written permission.
Some software used in our Services may be offered under an open source
license that we will make available to you. There may be provisions in the
open source license that expressly override some of these terms.
### Modifying and Terminating our Services
We are constantly changing and improving our Services. We may add or remove
functionalities or features, and we may suspend or stop a Service
altogether.
You can stop using our Services at any time, although we'll be sorry to see
you go. Zulip may also stop providing Services to you, or add or create new
limits to our Services at any time.
We believe that you own your data and preserving your access to such data is
important. If we discontinue a Service, we will, if it is practical in our sole
discretion, give you reasonable advance notice and a chance to get information
out of that Service.
### Our Warranties and Disclaimers
We hope that you will enjoy using our Services, but there are certain things
that we don't promise about our Services.
OTHER THAN AS EXPRESSLY SET OUT IN THESE TERMS, NEITHER ZULIP NOR ITS
SUPPLIERS OR DISTRIBUTORS MAKE ANY SPECIFIC PROMISES ABOUT THE SERVICES. FOR
EXAMPLE, WE DON'T MAKE ANY COMMITMENTS ABOUT THE CONTENT WITHIN THE SERVICES,
THE SPECIFIC FUNCTION OF THE SERVICES, OR THEIR RELIABILITY, AVAILABILITY, OR
ABILITY TO MEET YOUR NEEDS. WE PROVIDE THE SERVICES "AS IS".
SOME JURISDICTIONS PROVIDE FOR CERTAIN WARRANTIES, LIKE THE IMPLIED WARRANTY
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. TO
THE EXTENT PERMITTED BY LAW, WE EXCLUDE ALL WARRANTIES.
### Liability for our Services
WHEN PERMITTED BY LAW, ZULIP, AND ZULIP'S SUPPLIERS AND DISTRIBUTORS, WILL
NOT BE RESPONSIBLE FOR LOST PROFITS, REVENUES, OR DATA, FINANCIAL LOSSES OR
INDIRECT, SPECIAL, CONSEQUENTIAL, EXEMPLARY, OR PUNITIVE DAMAGES.
TO THE EXTENT PERMITTED BY LAW, THE TOTAL LIABILITY OF ZULIP, AND ITS
SUPPLIERS AND DISTRIBUTORS, FOR ANY CLAIM UNDER THESE TERMS, INCLUDING FOR ANY
IMPLIED WARRANTIES, IS LIMITED TO THE GREATER OF FIVE DOLLARS ($5) OR THE
AMOUNT PAID BY YOU TO ZULIP FOR THE PAST THREE MONTHS OF THE SERVICES IN
QUESTION.
IN ALL CASES, ZULIP, AND ITS SUPPLIERS AND DISTRIBUTORS, WILL NOT BE LIABLE
FOR ANY LOSS OR DAMAGE THAT IS NOT REASONABLY FORESEEABLE.
### Business uses of our Services
If you are using our Services on behalf of a business, that business accepts
these terms. It will hold harmless and indemnify Zulip and its affiliates,
officers, agents, and employees from any claim, suit or action arising from or
related to the use of the Services or violation of these terms, including any
liability or expense arising from claims, losses, damages, suits, judgments,
litigation costs and attorneys' fees.
You agree that we, in our sole discretion, may use your trade names,
trademarks, service marks, logos, domain names and other distinctive brand
features in presentations, marketing materials, customer lists, financial
reports and Web site listings (including links to your website) for the purpose
of advertising or publicizing your use of our products or services.
### Export Compliance
If you are located outside of the United States or are not a U.S. person,
you certify that you do not reside in Cuba, Iran, North Korea, Sudan, or Syria,
and you certify the following: "We certify that this beta test software will
only be used for beta testing purposes, and will not be rented, leased, sold,
sublicensed, assigned, or otherwise transferred. Further, we certify that we
will not transfer or export any product, process, or service that is the direct
product of the beta test software."
### About these Terms
If it turns out that a particular term is not enforceable, this will not
affect any other terms.
If you do not comply with these terms, and we don't take action right away,
this doesn't mean that we are giving up any rights that we may have (such as
taking action in the future).
These terms control the relationship between Zulip and you. They do not
create any third party beneficiary rights.
The laws of Massachusetts, U.S.A., excluding Massachusetts's conflict of
laws rules, will apply to any disputes arising out of or relating to these
terms or the Services. All claims arising out of or relating to these terms or
the Services will be litigated exclusively in the applicable federal or state
courts of Massachusetts, and you and Zulip consent to personal jurisdiction in
those courts.
Zulip reserves the right to amend or modify these terms at any time and in
any manner by providing reasonable notice to you. You agree that reasonable
notice may be provided by posting on Zulip's web site, email, or other written
notice. By continuing to access or use the Services after revisions become
effective, you agree to be bound by the revised terms. If you do not agree to
the new terms, please stop using the Services.
These terms constitute the whole legal agreement between you and Zulip, and
completely replace any prior agreements between you and Zulip in relation to
the Services.
Last modified: October 4, 2013

View File

@@ -1,15 +1,15 @@
from django.conf.urls import patterns, url
from django.views.generic import TemplateView, RedirectView
urlpatterns = patterns('',
i18n_urlpatterns = [
# Zephyr/MIT
url(r'^zephyr/$', TemplateView.as_view(template_name='corporate/zephyr.html')),
url(r'^mit/$', TemplateView.as_view(template_name='corporate/mit.html')),
url(r'^zephyr-mirror/$', TemplateView.as_view(template_name='corporate/zephyr-mirror.html')),
# Terms of service and privacy policy
url(r'^terms/$', TemplateView.as_view(template_name='corporate/terms.html')),
url(r'^terms-enterprise/$', TemplateView.as_view(template_name='corporate/terms-enterprise.html')),
url(r'^privacy/$', TemplateView.as_view(template_name='corporate/privacy.html')),
]
)
urlpatterns = patterns('', *i18n_urlpatterns)

View File

@@ -1,23 +1,29 @@
These docs are written in rST, and are included on the zulip.org website
as well as on each development installation. Many of these docs
have been ported from the internal docs of Zulip Inc.,
and may need to be updated for use in the open source project.
# Documentation
To generate HTML docs locally from rST:
These docs are written in [Commonmark
Markdown](http://commonmark.org/) with a small bit of rST. We've
chosen Markdown because it is [easy to
write](http://commonmark.org/help). The docs are served in production
at [zulip.readthedocs.io](https://zulip.readthedocs.io/en/latest/).
* `pip install sphinx`
* In this directory, `make html`. Output appears in a `_build/html` subdirectory.
If you want to build the documentation locally (e.g. to test your
changes), the dependencies are automatically installed as part of
Zulip development environment provisioning, and you can build the
documentation using:
To create rST from MediaWiki input:
```
cd docs/
make html
```
* Use `pandoc -r mediawiki -w rst` on MediaWiki source.
* Use unescape.py to remove any leftover HTML entities (often inside <pre>
tags and the like).
and then opening `file:///path/to/zulip/docs/_build/html/index.html` in
your browser (you can also use e.g. `firefox
docs/_build/html/index.html` from the root of your Zulip checkout).
We can use pandoc to translate mediawiki into reStructuredText, but some things need fixing up:
* Add page titles.
* Review pages for formatting (especially inline code chunks) and content.
* Fix wiki links?
* Add pages to the table of contents (`index.rst`).
You can also usually test your changes by pushing a branch to GitHub
and looking at the content on the GitHub web UI, since GitHub renders
Markdown.
When editing dependencies for the Zulip documentation, you should edit
`requirements/docs.txt` (which is used by ReadTheDocs to build the
documentation quickly, without installing all of Zulip's dependencies).

View File

@@ -0,0 +1,238 @@
Zulip architectural overview
============================
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)).
We maintain several separate repositories for integrations and other
glue code: a [Hubot adapter](https://github.com/zulip/hubot-zulip);
integrations with
[Phabricator](https://github.com/zulip/phabricator-to-zulip),
[Jenkins](https://github.com/zulip/zulip-jenkins-plugin),
[Puppet](https://github.com/matthewbarr/puppet-zulip),
[Redmine](https://github.com/zulip/zulip-redmine-plugin), and
[Trello](https://github.com/zulip/trello-to-zulip); [node.js API
bindings](https://github.com/zulip/zulip-node); and our [full-text
search PostgreSQL extension](https://github.com/zulip/tsearch_extras).
Our mobile clients are separate code repositories:
[Android](https://github.com/zulip/zulip-android), [iOS
(stable)](https://github.com/zulip/zulip-ios), and [our experimental
React Native iOS app](https://github.com/zulip/zulip-mobile). Our
[legacy desktop application (implemented in
QT/WebKit)](https://github.com/zulip/zulip-desktop) and our new, alpha
[cross-platform desktop app (implemented in
Electron)](https://github.com/zulip/zulip-electron) are also separate
repositories.
We use [Transifex](https://www.transifex.com/zulip/zulip/) to do
translations.
In this overview we'll mainly discuss the core Zulip server and web
application.
Usage assumptions and concepts
------------------------------
Zulip is a real-time web-based chat application meant for companies and
similar groups ranging in size from a small team to more than a thousand
users. It features real-time notifications, message persistence and
search, public group conversations (*streams*), invite-only streams,
private one-on-one and group conversations, inline image previews, team
presence/buddy list, a rich API, Markdown message support, and numerous
integrations with other services. The maintainer team aims to support
users who connect to Zulip using dedicated iOS, Android, Linux, Windows,
and Mac OS X clients, as well as people using modern web browsers or
dedicated Zulip API clients.
A server can host multiple Zulip *realms* (organizations) at the same
domain, each of which is a private chamber with its own users,
streams, customizations, and so on. This means that one person might
be a user of multiple Zulip realms. The administrators of a realm can
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 scalability and
security considerations, see [the security section of the production
maintenance
instructions](prod-maintain-secure-upgrade.html#security-model).
The default Zulip home 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
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
the messages in a single stream, and can further narrow to focus on a
*topic* (thread) within that stream. Each narrow has its own URL.
Zulip's philosophy is to provide sensible defaults but give the user
fine-grained control over their incoming information flow; a user can
mute topics and streams, and can make fine-grained choices to reduce
real-time notifications they find irrelevant.
Components
----------
### Tornado and Django
We use both the [Tornado](http://www.tornadoweb.org) and
[Django](https://www.djangoproject.com/) Python web frameworks.
Django is the main web application server; Tornado runs the
server-to-client real-time push system. The app servers are configured
by the Supervisor configuration (which explains how to start the server
processes; see "Supervisor" below) and the nginx configuration (which
explains which HTTP requests get sent to which app server).
Tornado is an asynchronous server and is meant specifically to hold open
tens of thousands of long-lived (long-polling or websocket) connections
-- that is to say, routes that maintain a persistent connection from
every running client. For this reason, it's responsible for event
(message) delivery, but not much else. We try to avoid any blocking
calls in Tornado because we don't want to delay delivery to thousands of
other connections (as this would make Zulip very much not real-time).
For instance, we avoid doing cache or database queries inside the
Tornado code paths, since those blocking requests carry a very high
performance penalty for a single-threaded, asynchronous server.
The parts that are activated relatively rarely (e.g. when people type or
click on something) are processed by the Django application server. One
exception to this is that Zulip uses websockets through Tornado to
minimize latency on the code path for **sending** messages.
### nginx
nginx is the front-end web server to all Zulip traffic; it serves static
assets and proxies to Django and Tornado. It handles HTTP requests
according to the rules laid down in the many config files found in
`zulip/puppet/zulip/files/nginx/`.
`zulip/puppet/zulip/files/nginx/zulip-include-frontend/app` is the most
important of these files. It explains what happens when requests come in
from outside.
- In production, all requests to URLs beginning with `/static/` are
served from the corresponding files in `/home/zulip/prod-static/`,
and the production build process (`tools/build-release-tarball`)
compiles, minifies, and installs the static assets into the
`prod-static/` tree form. In development, files are served directly
from `/static/` in the git repository.
- Requests to `/json/get_events`, `/api/v1/events`, and `/sockjs` are
sent to the Tornado server. These are requests to the real-time push
system, because the user's web browser sets up a long-lived TCP
connection with Tornado to serve as [a channel for push
notifications](https://en.wikipedia.org/wiki/Push_technology#Long_Polling).
nginx gets the hostname for the Tornado server via
`puppet/zulip/files/nginx/zulip-include-frontend/upstreams`.
- Requests to all other paths are sent to the Django app via the UNIX
socket `unix:/home/zulip/deployments/fastcgi-socket` (defined in
`puppet/zulip/files/nginx/zulip-include-frontend/upstreams`). We use
`zproject/wsgi.py` to implement FastCGI here (see
`django.core.wsgi`).
### Supervisor
We use [supervisord](http://supervisord.org/) to start server processes,
restart them automatically if they crash, and direct logging.
The config file is
`zulip/puppet/zulip/files/supervisor/conf.d/zulip.conf`. This is where
Tornado and Django are set up, as well as a number of background
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).
### memcached
memcached is used to cache database model objects. `zerver/lib/cache.py`
and `zerver/lib/cache_helpers.py` manage putting things into memcached,
and invalidating the cache when values change. The memcached
configuration is in `puppet/zulip/files/memcached.conf`.
### Redis
Redis is used for a few very short-term data stores, such as in the
basis of `zerver/lib/rate_limiter.py`, a per-user rate limiting scheme
[example](http://blog.domaintools.com/2013/04/rate-limiting-with-redis/)),
and the [email-to-Zulip
integration](https://zulipchat.com/integrations/#email).
Redis is configured in `zulip/puppet/zulip/files/redis` and it's a
pretty standard configuration except for the last line, which turns off
persistence:
# Zulip-specific configuration: disable saving to disk.
save ""
memcached was used first and then we added Redis specifically to
implement rate limiting. [We're discussing switching everything over to
Redis.](https://github.com/zulip/zulip/issues/16)
### RabbitMQ
RabbitMQ is a queueing system. Its config files live in
`zulip/puppet/zulip/files/rabbitmq`. Initial configuration happens in
`zulip/scripts/setup/configure-rabbitmq`.
We use RabbitMQ for queuing expensive work (e.g. sending emails
triggered by a message, push notifications, some analytics, etc.) that
require reliable delivery but which we don't want to do on the main
thread. It's also used for communication between the application server
and the Tornado push system.
Two simple wrappers around `pika` (the Python RabbitMQ client) are in
`zulip/server/lib/queue.py`. There's an asynchronous client for use in
Tornado and a more general client for use elsewhere.
`zerver/lib/event_queue.py` has helper functions for putting events into
one queue or another. Most of the processes started by Supervisor are
queue processors that continually pull things out of a RabbitMQ queue
and handle them.
Also see [the queuing guide](queuing.html).
### PostgreSQL
PostgreSQL (also known as Postgres) is the database that stores all
persistent data, that is, data that's expected to live beyond a user's
current session.
In production, Postgres is installed with a default configuration. The
directory that would contain configuration files
(`puppet/zulip/files/postgresql`) has only a utility script and a custom
list of stopwords used by a Postgresql extension.
In a development environment, configuration of that postgresql
extension is handled by `tools/postgres-init-dev-db` (invoked by
`tools/provision.py`). That file also manages setting up the
development postgresql user.
`tools/provision.py` also invokes `tools/do-destroy-rebuild-database`
to create the actual database with its schema.
### Nagios
Nagios is an optional component used for notifications to the system
administrator, e.g., in case of outages.
`zulip/puppet/zulip/manifests/nagios.pp` installs Nagios plugins from
puppet/`zulip/files/nagios_plugins/`.
This component is intended to install Nagios plugins intended to be run
on a Nagios server; most of the Zulip Nagios plugins are intended to be
run on the Zulip servers themselves, and are included with the relevant
component of the Zulip server (e.g.
`puppet/zulip/manifests/postgres_common.pp` installs a few under
`/usr/lib/nagios/plugins/zulip_postgres_common`).

View File

@@ -0,0 +1,113 @@
# 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 OS X or older Linux, [download VirtualBox][vbox-dl],
[download Vagrant][vagrant-dl], and install them both.
* If you're on OS X and have VMWare, it should be possible to patch
Vagrantfile to use the VMWare vagrant provider which should perform
much better than Virtualbox. Patches to do this by default if
VMWare is available are welcome!
* 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
[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 --interface=''
```
To get shell access to the virtual machine running the server to run
lint, management commands, etc., use `vagrant ssh`.
(A small note on tools/run-dev.py: the `--interface=''` option will
make the development server listen on all network interfaces. While
this is correct for the Vagrant guest sitting behind a NAT, you
probably don't want to use that option when using run-dev.py in other
environments).
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.

244
docs/changelog.md Normal file
View File

@@ -0,0 +1,244 @@
# Version History
All notable changes to the Zulip server are documented in this file.
### Unreleased
### 1.4.3 - 2017-01-29
- CVE-2017-0881: Users could subscribe to invite-only streams.
### 1.4.2 - 2016-09-27
- Upgraded Django to version 1.8.15 (with the Zulip patches applied),
fixing a CSRF vulnerability in Django (see
https://www.djangoproject.com/weblog/2016/sep/26/security-releases/),
and a number of other Django bugs from past Django stable releases
that largely affects parts of Django that are not used by Zulip.
- Fixed buggy logrotate configuration.
### 1.4.1 - 2016-09-03
- Fixed settings bug upgrading from pre-1.4.0 releases to 1.4.0.
- Fixed local file uploads integration being broken for new 1.4.0
installations.
### 1.4 - 2016-08-25
- Migrated Zulip's python dependencies to be installed via a virtualenv,
instead of the via apt. This is a major change to how Zulip
is installed that we expect will simplify upgrades in the future.
- Fixed unnecessary loading of zxcvbn password strength checker. This
saves a huge fraction of the uncached network transfer for loading
Zulip.
- Added support for using Ubuntu Xenial in production.
- Added a powerful and complete realm import/export tool.
- Added nice UI for selecting a default language to display settings.
- Added UI for searching streams in left sidebar with hotkeys.
- Added Semaphore, Bitbucket, and HelloWorld (example) integrations.
- Added new webhook-based integration for Trello.
- Added management command for creating realms through web UI.
- Added management command to send password reset emails.
- Added endpoint for mobile apps to query available auth backends.
- Added LetsEncrypt documentation for getting SSL certificates.
- Added nice rendering of unicode emoji.
- Added support for pinning streams to the top of the left sidebar.
- Added search box for filtering user list when creating a new stream.
- Added realm setting to disable message editing.
- Added realm setting to time-limit message editing. Default is 10m.
- Added realm setting for default language.
- Added year to timestamps in message interstitials for old messages.
- Added GitHub authentication (and integrated python-social-auth, so it's
easy to add additional social authentication methods).
- Added TERMS_OF_SERVICE setting using markdown formatting to configure
the terms of service for a Zulip server.
- Added numerous hooks to puppet modules to enable more configurations.
- Moved several useful puppet components into the main puppet
manifests (setting a redis password, etc.).
- Added automatic configuration of postgres/memcached settings based
on the server's available RAM.
- Added scripts/upgrade-zulip-from-git for upgrading Zulip from a Git repo.
- Added preliminary support for Python 3. All of Zulip's test suites now
pass using Python 3.4.
- Added support for `Name <email@example.com>` format when inviting users.
- Added numerous special-purpose settings options.
- Added a hex input field in color picker.
- Documented new Electron beta app and mobile apps in the /apps/ page.
- Enabled Android Google authentication support.
- Enhanced logic for tracking origin of user uploads.
- Improved error messages for various empty narrows.
- Improved missed message emails to better support directly replying.
- Increased backend test coverage of Python code to 85.5%.
- Increased mypy static type coverage of Python code to 95%. Also
fixed many string annotations to properly handle unicode.
- Fixed major i18n-related frontend performance regression on
/#subscriptions page. Saves several seconds of load time with 1k
streams.
- Fixed Jinja2 migration bug when trying to register an email that
already has an account.
- Fixed narrowing to a stream from other pages.
- Fixed various frontend strings that weren't marked for translation.
- Fixed several bugs around editing status (/me) messages.
- Fixed queue workers not restarting after changes in development.
- Fixed Casper tests hanging while development server is running.
- Fixed browser autocomplete issue when adding new stream members.
- Fixed broken create_stream and rename_stream management commands.
- Fixed zulip-puppet-apply exit code when puppet throws errors.
- Fixed EPMD restart being attempted on every puppet apply.
- Fixed message cache filling; should improve perf after server restart.
- Fixed caching race condition when changing user objects.
- Fixed buggy puppet configuration for supervisord restarts.
- Fixed some error handling race conditions when editing messages.
- Fixed fastcgi_params to protect against the httpoxy attack.
- Fixed bug preventing users with mit.edu emails from registering accounts.
- Fixed incorrect settings docs for the email mirror.
- Fixed APNS push notification support (had been broken by Apple changing
the APNS API).
- Fixed some logic bugs in how attachments are tracked.
- Fixed unnecessarily resource-intensive rabbitmq cron checks.
- Fixed old deployment directories leaking indefinitely.
- Fixed need to manually add localhost in ALLOWED_HOSTS.
- Fixed display positioning for the color picker on subscriptions page.
- Fixed escaping of Zulip extensions to markdown.
- Fixed requiring a reload to see newly uploaded avatars.
- Fixed @all warning firing even for `@all`.
- Restyled password reset form to look nice.
- Improved formatting in reset password links.
- Improved alert words UI to match style of other settings.
- Improved error experience when sending to nonexistent users.
- Portions of integrations documentation are now automatically generated.
- Restructured the URLs files to be more readable.
- Upgraded almost all Python dependencies to current versions.
- Substantially expanded and reorganized developer documentation.
- Reorganized production documentation and moved to ReadTheDocs.
- Reorganized .gitignore type files to be written under var/
- Refactored substantial portions of templates to support subdomains.
- Renamed local_settings.py symlink to prod_settings.py for clarity.
- Renamed email-mirror management command to email_mirror.
- Changed HTTP verb for create_user_backend to PUT.
- Eliminated all remaining settings hardcoded for zulip.com.
- Eliminated essentially all remaining hardcoding of mit.edu.
- Optimized the performance of all the test suites.
- Optimized Django memcached configuration.
- Removed old prototype data export tool.
- Disabled insecure RC4 cipher in nginx configuration.
- Enabled shared SSL session cache in nginx configuration.
- Updated header for Zulip static assets to reflect Zulip being
open source.
### 1.3.13 - 2016-06-21
- Added nearly complete internationalization of the Zulip UI.
- Added warning when using @all/@everyone.
- Added button offering to subscribe at bottom of narrows to streams
the user is not subscribed to.
- Added integrations with Airbrake, CircleCI, Crashlytics, IFTTT,
Transifex, and Updown.io.
- Added menu option to mark all messages in a stream or topic as read.
- Added new Attachment model to keep track of uploaded files.
- Added caching of virtualenvs in development.
- Added mypy static type annotations to about 85% of the Zulip Python codebase.
- Added automated test of backend templates to test for regressions.
- Added lots of detailed documentation on the Zulip development environment.
- Added setting allowing only administrators to create new streams.
- Added button to exit the Zulip tutorial early.
- Added web UI for configuring default streams.
- Added new OPEN_REALM_CREATION setting (default off), providing a UI
for creating additional realms on a Zulip server.
- Fixed email_gateway_password secret not working properly.
- Fixed missing helper scripts for RabbitMQ Nagios plugins.
- Fixed skipping forward to latest messages ("More messages below" button).
- Fixed netcat issue causing Zulip installation to hang on Scaleway machines.
- Fixed rendering of /me status messages after message editing.
- Fixed case sensitivity of right sidebar fading when compose is open.
- Fixed error messages when composing to invalid PM recipients.
- Fixed LDAP auth backend not working with Zulip mobile apps.
- Fixed erroneous WWW-Authenticate headers with expired sessions.
- Changed "coworkers" to "users" in the Zulip UI.
- Changed add_default_stream REST API to correctly use PUT rather than PATCH.
- Updated the Zulip emoji set (the Android Emoji) to a modern version.
- Made numerous small improvements to the Zulip development experience.
- Migrated backend templates to the faster Jinja2 templating system.
- Migrated development environment setup scripts to tools/setup/.
- Expanded test coverage for several areas of the product.
- Simplified the API for writing new webhook integrations.
- Removed most of the remaining JavaScript global variables.
### 1.3.12 - 2016-05-10
- CVE-2016-4426: Bot API keys were accessible to other users in the same realm.
- CVE-2016-4427: Deactivated users could access messages if SSO was enabled.
- Fixed a RabbitMQ configuration bug that resulted in reordered messages.
- Added expansive test suite for authentication backends and decorators.
- Added an option to logout_all_users to delete only sessions for deactivated users.
### 1.3.11 - 2016-05-02
- Moved email digest support into the default Zulip production configuration.
- Added options for configuring Postgres, RabbitMQ, Redis, and memcached
in settings.py.
- Added documentation on using Hubot to integrate with useful services
not yet integrated with Zulip directly (e.g. Google Hangouts).
- Added new management command to test sending email from Zulip.
- Added Codeship, Pingdom, Taiga, Teamcity, and Yo integrations.
- Added Nagios plugins to the main distribution.
- Added ability for realm administrators to manage custom emoji.
- Added guide to writing new integrations.
- Enabled camo image proxy to fix mixed-content warnings for http images.
- Refactored the Zulip puppet modules to be more modular.
- Refactored the Tornado event system, fixing old memory leaks.
- Removed many old-style /json API endpoints
- Implemented running queue processors multithreaded in development,
decreasing RAM requirements for a Zulip development environment from
~1GB to ~300MB.
- Fixed rerendering the complete buddy list whenever a user came back from
idle, which was a significant performance issue in larger realms.
- Fixed the disabling of desktop notifications from 1.3.7 for new users.
- Fixed the (admin) create_user API enforcing restricted_to_domain, even
if that setting was disabled for the realm.
- Fixed bugs changing certain settings in administration pages.
- Fixed collapsing messages in narrowed views.
- Fixed 500 errors when uploading a non-image file as an avatar.
- Fixed Jira integration incorrectly not @-mentioning assignee.
### 1.3.10 - 2016-01-21
- Added new integration for Travis CI.
- Added settings option to control maximum file upload size.
- Added support for running Zulip development environment in Docker.
- Added easy configuration support for a remote postgres database.
- Added extensive documentation on scalability, backups, and security.
- Recent private message threads are now displayed expanded similar to
the pre-existing recent topics feature.
- Made it possible to set LDAP and EMAIL_HOST passwords in
/etc/zulip/secrets.conf.
- Improved the styling for the Administration page and added tabs.
- Substantially improved loading performance on slow networks by enabling
GZIP compression on more assets.
- Changed the page title in narrowed views to include the current narrow.
- Fixed several backend performance issues affecting very large realms.
- Fixed bugs where draft compose content might be lost when reloading site.
- Fixed support for disabling the "zulip" notifications stream.
- Fixed missing step in postfix_localmail installation instructions.
- Fixed several bugs/inconveniences in the production upgrade process.
- Fixed realm restrictions for servers with a unique, open realm.
- Substantially cleaned up console logging from run-dev.py.
### 1.3.9 - 2015-11-16
- Fixed buggy #! lines in upgrade scripts.
### 1.3.8 - 2015-11-15
- Added options to the Python api for working with untrusted server certificates.
- Added a lot of documentation on the development environment and testing.
- Added partial support for translating the Zulip UI.
- Migrated installing Node dependencies to use npm.
- Fixed LDAP integration breaking autocomplete of @-mentions.
- Fixed admin panel reactivation/deactivation of bots.
- Fixed inaccurate documentation for downloading the desktop apps.
- Fixed various minor bugs in production installation process.
- Fixed security issue where recent history on private streams might
be visible to new users (to the Zulip team) who were invited with that
private stream as one of their initial streams
(https://github.com/zulip/zulip/issues/230).
- Major preliminary progress towards supporting Python 3.
### 1.3.7 - 2015-10-19
- Turn off desktop and audible notifications for streams by default.
- Added support for the LDAP authentication integration creating new users.
- Added new endpoint to support Google auth on mobile.
- Fixed desktop notifications in modern Firefox.
- Fixed several installation issues for both production and development environments.
- Improved documentation for outgoing SMTP and the email mirror integration.

358
docs/code-style.md Normal file
View File

@@ -0,0 +1,358 @@
# Code style and conventions
## Be consistent!
Look at the surrounding code, or a similar part of the project, and try
to do the same thing. If you think the other code has actively bad
style, fix it (in a separate commit).
When in doubt, send an email to <zulip-devel@googlegroups.com> with your
question.
## Lint tools
You can run them all at once with
./tools/lint-all
You can set this up as a local Git commit hook with
``tools/setup-git-repo``
The Vagrant setup process runs this for you.
`lint-all` runs many lint checks in parallel, including
- JavaScript ([JSLint](http://www.jslint.com/))
> `tools/jslint/check-all.js` contains a pretty fine-grained set of
> JSLint options, rule exceptions, and allowed global variables. If
> you add a new global, you'll need to add it to the list.
- Python ([Pyflakes](http://pypi.python.org/pypi/pyflakes))
- templates
- Puppet configuration
- custom checks (e.g. trailing whitespace and spaces-not-tabs)
## Secrets
Please don't put any passwords, secret access keys, etc. inline in the
code. Instead, use the `get_secret` function in `zproject/settings.py`
to read secrets from `/etc/zulip/secrets.conf`.
## Dangerous constructs
### Misuse of database queries
Look out for Django code like this:
[Foo.objects.get(id=bar.x.id)
for bar in Bar.objects.filter(...)
if bar.baz < 7]
This will make one database query for each `Bar`, which is slow in
production (but not in local testing!). Instead of a list comprehension,
write a single query using Django's [QuerySet
API](https://docs.djangoproject.com/en/dev/ref/models/querysets/).
If you can't rewrite it as a single query, that's a sign that something
is wrong with the database schema. So don't defer this optimization when
performing schema changes, or else you may later find that it's
impossible.
### UserProfile.objects.get() / Client.objects.get / etc.
In our Django code, never do direct `UserProfile.objects.get(email=foo)`
database queries. Instead always use `get_user_profile_by_{email,id}`.
There are 3 reasons for this:
1. It's guaranteed to correctly do a case-inexact lookup
2. It fetches the user object from remote cache, which is faster
3. It always fetches a UserProfile object which has been queried using
.selected\_related(), and thus will perform well when one later
accesses related models like the Realm.
Similarly we have `get_client` and `get_stream` functions to fetch those
commonly accessed objects via remote cache.
### Using Django model objects as keys in sets/dicts
Don't use Django model objects as keys in sets/dictionaries -- you will
get unexpected behavior when dealing with objects obtained from
different database queries:
For example,
`UserProfile.objects.only("id").get(id=17) in set([UserProfile.objects.get(id=17)])`
is False
You should work with the IDs instead.
### user\_profile.save()
You should always pass the update\_fields keyword argument to .save()
when modifying an existing Django model object. By default, .save() will
overwrite every value in the column, which results in lots of race
conditions where unrelated changes made by one thread can be
accidentally overwritten by another thread that fetched its UserProfile
object before the first thread wrote out its change.
### Using raw saves to update important model objects
In most cases, we already have a function in zephyr/lib/actions.py with
a name like do\_activate\_user that will correctly handle lookups,
caching, and notifying running browsers via the event system about your
change. So please check whether such a function exists before writing
new code to modify a model object, since your new code has a good chance
of getting at least one of these things wrong.
### `x.attr('zid')` vs. `rows.id(x)`
Our message row DOM elements have a custom attribute `zid` which
contains the numerical message ID. **Don't access this directly as**
`x.attr('zid')` ! The result will be a string and comparisons (e.g. with
`<=`) will give the wrong result, occasionally, just enough to make a
bug that's impossible to track down.
You should instead use the `id` function from the `rows` module, as in
`rows.id(x)`. This returns a number. Even in cases where you do want a
string, use the `id` function, as it will simplify future code changes.
In most contexts in JavaScript where a string is needed, you can pass a
number without any explicit conversion.
### JavaScript var
Always declare JavaScript variables using `var`:
var x = ...;
In a function, `var` is necessary or else `x` will be a global variable.
For variables declared at global scope, this has no effect, but we do it
for consistency.
JavaScript has function scope only, not block scope. This means that a
`var` declaration inside a `for` or `if` acts the same as a `var`
declaration at the beginning of the surrounding `function`. To avoid
confusion, declare all variables at the top of a function.
### JavaScript `for (i in myArray)`
Don't use it:
[[1]](http://stackoverflow.com/questions/500504/javascript-for-in-with-arrays),
[[2]](http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml#for-in_loop),
[[3]](http://www.jslint.com/lint.html#forin)
### jQuery global state
Don't mess with jQuery global state once the app has loaded. Code like
this is very dangerous:
$.ajaxSetup({ async: false });
$.get(...);
$.ajaxSetup({ async: true });
jQuery and the browser are free to run other code while the request is
pending, which could perform other Ajax requests with the altered
settings.
Instead, switch to the more general `$.ajax`\_ function, which can take
options like `async`.
### State and logs files
Do not write state and logs files inside the current working directory
in the production environment. This will not how you expect, because the
current working directory for the app changes every time we do a deploy.
Instead, hardcode a path in settings.py -- see SERVER\_LOG\_PATH in
settings.py for an example.
## JS array/object manipulation
For generic functions that operate on arrays or JavaScript objects, you
should generally use [Underscore](http://underscorejs.org/). We used to
use jQuery's utility functions, but the Underscore equivalents are more
consistent, better-behaved and offer more choices.
A quick conversion table:
$.each → _.each (parameters to the callback reversed)
$.inArray → _.indexOf (parameters reversed)
$.grep → _.filter
$.map → _.map
$.extend → _.extend
There's a subtle difference in the case of `_.extend`; it will replace
attributes with undefined, whereas jQuery won't:
$.extend({foo: 2}, {foo: undefined}); // yields {foo: 2}, BUT...
_.extend({foo: 2}, {foo: undefined}); // yields {foo: undefined}!
Also, `_.each` does not let you break out of the iteration early by
returning false, the way jQuery's version does. If you're doing this,
you probably want `_.find`, `_.every`, or `_.any`, rather than 'each'.
Some Underscore functions have multiple names. You should always use the
canonical name (given in large print in the Underscore documentation),
with the exception of `_.any`, which we prefer over the less clear
'some'.
## More arbitrary style things
### General
Indentation is four space characters for Python, JS, CSS, and shell
scripts. Indentation is two space characters for HTML templates.
We never use tabs anywhere in source code we write, but we have some
third-party files which contain tabs.
Keep third-party static files under the directory
`zephyr/static/third/`, with one subdirectory per third-party project.
We don't have an absolute hard limit on line length, but we should avoid
extremely long lines. A general guideline is: refactor stuff to get it
under 85 characters, unless that makes the code a lot uglier, in which
case it's fine to go up to 120 or so.
Whitespace guidelines:
- Put one space (or more for alignment) around binary arithmetic and
equality operators.
- Put one space around each part of the ternary operator.
- Put one space between keywords like `if` and `while` and their
associated open paren.
- Put one space between the closing paren for `if` and `while`-like
constructs and the opening curly brace. Put the curly brace on the
same line unless doing otherwise improves readability.
- Put no space before or after the open paren for function calls and
no space before the close paren for function calls.
- For the comma operator and colon operator in languages where it is
used for inline dictionaries, put no space before it and at least
one space after. Only use more than one space for alignment.
### JavaScript
Don't use `==` and `!=` because these operators perform type coercions,
which can mask bugs. Always use `===` and `!==`.
End every statement with a semicolon.
`if` statements with no braces are allowed, if the body is simple and
its extent is abundantly clear from context and formatting.
Anonymous functions should have spaces before and after the argument
list:
var x = function (foo, bar) { // ...
When calling a function with an anonymous function as an argument, use
this style:
$.get('foo', function (data) {
var x = ...;
// ...
});
The inner function body is indented one level from the outer function
call. The closing brace for the inner function and the closing
parenthesis for the outer call are together on the same line. This style
isn't necessarily appropriate for calls with multiple anonymous
functions or other arguments following them.
Use
$(function () { ...
rather than
$(document).ready(function () { ...
and combine adjacent on-ready functions, if they are logically related.
The best way to build complicated DOM elements is a Mustache template
like `zephyr/static/templates/message.handlebars`. For simpler things
you can use jQuery DOM building APIs like so:
var new_tr = $('<tr />').attr('id', zephyr.id);
Passing a HTML string to jQuery is fine for simple hardcoded things:
foo.append('<p id="selected">foo</p>');
but avoid programmatically building complicated strings.
We used to favor attaching behaviors in templates like so:
<p onclick="select_zephyr({{id}})">
but there are some reasons to prefer attaching events using jQuery code:
- Potential huge performance gains by using delegated events where
possible
- When calling a function from an `onclick` attribute, `this` is not
bound to the element like you might think
- jQuery does event normalization
Either way, avoid complicated JavaScript code inside HTML attributes;
call a helper function instead.
### HTML / CSS
Don't use the `style=` attribute. Instead, define logical classes and
put your styles in external files such as `zulip.css`.
Don't use the tag name in a selector unless you have to. In other words,
use `.foo` instead of `span.foo`. We shouldn't have to care if the tag
type changes in the future.
Don't use inline event handlers (`onclick=`, etc. attributes). Instead,
attach a jQuery event handler
(`$('#foo').on('click', function () {...})`) when the DOM is ready
(inside a `$(function () {...})` block).
Use this format when you have the same block applying to multiple CSS
styles (separate lines for each selector):
selector1,
selector2 {
};
### Python
- Scripts should start with `#!/usr/bin/env python` and not
`#/usr/bin/python` (the right Python may not be installed in
`/usr/bin`) or `#/usr/bin/env/python2.7` (bad for Python 3
compatibility). Don't put a shebang line on a Python file unless
it's meaningful to run it as a script. (Some libraries can also be
run as scripts, e.g. to run a test suite.)
- The first import in a file should be
`from __future__ import absolute_import`, per [PEP
328](http://docs.python.org/2/whatsnew/2.5.html#pep-328-absolute-and-relative-imports)
- Put all imports together at the top of the file, absent a compelling
reason to do otherwise.
- Unpacking sequences doesn't require list brackets:
[x, y] = xs # unnecessary
x, y = xs # better
- For string formatting, use `x % (y,)` rather than `x % y`, to avoid
ambiguity if `y` happens to be a tuple.
- When selecting by id, don't use `foo.pk` when you mean `foo.id`.
E.g.
recipient = Recipient(type_id=huddle.pk, type=Recipient.HUDDLE)
should be written as
recipient = Recipient(type_id=huddle.id, type=Recipient.HUDDLE)
in case we ever change the primary keys.
### Tests
All significant new features should come with tests. See testing.
### Third party code
When adding new third-party packages to our codebase, please include
"[third]" at the beginning of the commit message. You don't necessarily
need to do this when patching third-party code that's already in tree.

View File

@@ -1,521 +0,0 @@
==========================
Code style and conventions
==========================
Be consistent!
==============
Look at the surrounding code, or a similar part of the project, and
try to do the same thing. If you think the other code has actively bad
style, fix it (in a separate commit).
When in doubt, send an email to zulip-devel@googlegroups.com with your
question.
Lint tools
==========
You can run them all at once with
::
./tools/lint-all
You can set this up as a local Git commit hook with
::
``tools/setup-git-repo``
The Vagrant setup process runs this for you.
``lint-all`` runs many lint checks in parallel, including
- Javascript (`JSLint <http://www.jslint.com/>`__)
``tools/jslint/check-all.js`` contains a pretty fine-grained set of
JSLint options, rule exceptions, and allowed global variables. If you
add a new global, you'll need to add it to the list.
- Python (`Pyflakes <http://pypi.python.org/pypi/pyflakes>`__)
- templates
- Puppet configuration
- custom checks (e.g. trailing whitespace and spaces-not-tabs)
Secrets
=======
Please don't put any passwords, secret access keys, etc. inline in the
code. Instead, use the ``get_secret`` function in
``zproject/settings.py`` to read secrets from ``/etc/zulip/secrets.conf``.
Dangerous constructs
====================
Misuse of database queries
--------------------------
Look out for Django code like this::
[Foo.objects.get(id=bar.x.id)
for bar in Bar.objects.filter(...)
if  bar.baz < 7]
This will make one database query for each ``Bar``, which is slow in
production (but not in local testing!). Instead of a list comprehension,
write a single query using Django's `QuerySet
API <https://docs.djangoproject.com/en/dev/ref/models/querysets/>`__.
If you can't rewrite it as a single query, that's a sign that something
is wrong with the database schema. So don't defer this optimization when
performing schema changes, or else you may later find that it's
impossible.
UserProfile.objects.get() / Client.objects.get / etc.
-----------------------------------------------------
In our Django code, never do direct
``UserProfile.objects.get(email=foo)`` database queries. Instead always
use ``get_user_profile_by_{email,id}``. There are 3 reasons for this:
#. It's guaranteed to correctly do a case-inexact lookup
#. It fetches the user object from remote cache, which is faster
#. It always fetches a UserProfile object which has been queried using
.selected\_related(), and thus will perform well when one later
accesses related models like the Realm.
Similarly we have ``get_client`` and ``get_stream`` functions to fetch
those commonly accessed objects via remote cache.
Using Django model objects as keys in sets/dicts
------------------------------------------------
Don't use Django model objects as keys in sets/dictionaries -- you will
get unexpected behavior when dealing with objects obtained from
different database queries:
For example,
``UserProfile.objects.only("id").get(id=17) in set([UserProfile.objects.get(id=17)])``
is False
You should work with the IDs instead.
user\_profile.save()
--------------------
You should always pass the update\_fields keyword argument to .save()
when modifying an existing Django model object. By default, .save() will
overwrite every value in the column, which results in lots of race
conditions where unrelated changes made by one thread can be
accidentally overwritten by another thread that fetched its UserProfile
object before the first thread wrote out its change.
Using raw saves to update important model objects
-------------------------------------------------
In most cases, we already have a function in zephyr/lib/actions.py with
a name like do\_activate\_user that will correctly handle lookups,
caching, and notifying running browsers via the event system about your
change. So please check whether such a function exists before writing
new code to modify a model object, since your new code has a good chance
of getting at least one of these things wrong.
``x.attr('zid')`` vs. ``rows.id(x)``
------------------------------------
Our message row DOM elements have a custom attribute ``zid`` which
contains the numerical message ID. **Don't access this directly as**
``x.attr('zid')`` ! The result will be a string and comparisons (e.g.
with ``<=``) will give the wrong result, occasionally, just enough to
make a bug that's impossible to track down.
You should instead use the ``id`` function from the ``rows`` module, as
in ``rows.id(x)``. This returns a number. Even in cases where you do
want a string, use the ``id`` function, as it will simplify future code
changes. In most contexts in JavaScript where a string is needed, you
can pass a number without any explicit conversion.
Javascript var
--------------
Always declare Javascript variables using ``var``::
var x = ...;
In a function, ``var`` is necessary or else ``x`` will be a global
variable. For variables declared at global scope, this has no effect,
but we do it for consistency.
Javascript has function scope only, not block scope. This means that a
``var`` declaration inside a ``for`` or ``if`` acts the same as a
``var`` declaration at the beginning of the surrounding ``function``. To
avoid confusion, declare all variables at the top of a function.
Javascript ``for (i in myArray)``
---------------------------------
Don't use it:
`[1] <http://stackoverflow.com/questions/500504/javascript-for-in-with-arrays>`__,
`[2] <http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml#for-in_loop>`__,
`[3] <http://www.jslint.com/lint.html#forin>`__
jQuery global state
-------------------
Don't mess with jQuery global state once the app has loaded. Code like
this is very dangerous::
$.ajaxSetup({ async: false });
$.get(...);
$.ajaxSetup({ async: true });
jQuery and the browser are free to run other code while the request is
pending, which could perform other Ajax requests with the altered
settings.
Instead, switch to the more general |ajax|_ function, which can take options
like ``async``.
.. |ajax| replace:: ``$.ajax``
.. _ajax: http://api.jquery.com/jQuery.ajax
State and logs files
--------------------
Do not write state and logs files inside the current working directory
in the production environment. This will not how you expect, because the
current working directory for the app changes every time we do a deploy.
Instead, hardcode a path in settings.py -- see SERVER\_LOG\_PATH in
settings.py for an example.
JS array/object manipulation
============================
For generic functions that operate on arrays or JavaScript objects, you
should generally use `Underscore <http://underscorejs.org/>`__. We used
to use jQuery's utility functions, but the Underscore equivalents are
more consistent, better-behaved and offer more choices.
A quick conversion table::
   $.each  _.each (parameters to the callback reversed)
   $.inArray  _.indexOf (parameters reversed)
   $.grep  _.filter
   $.map  _.map
   $.extend  _.extend
There's a subtle difference in the case of ``_.extend``; it will replace
attributes with undefined, whereas jQuery won't::
   $.extend({foo: 2}, {foo: undefined});  // yields {foo: 2}, BUT...
   _.extend({foo: 2}, {foo: undefined});  // yields {foo: undefined}!
Also, ``_.each`` does not let you break out of the iteration early by
returning false, the way jQuery's version does. If you're doing this,
you probably want ``_.find``, ``_.every``, or ``_.any``, rather than
'each'.
Some Underscore functions have multiple names. You should always use the
canonical name (given in large print in the Underscore documentation),
with the exception of ``_.any``, which we prefer over the less clear
'some'.
More arbitrary style things
===========================
General
-------
Indentation is four space characters for Python, JS, CSS, and shell
scripts. Indentation is two space characters for HTML templates.
We never use tabs anywhere in source code we write, but we have some
third-party files which contain tabs.
Keep third-party static files under the directory
``zephyr/static/third/``, with one subdirectory per third-party project.
We don't have an absolute hard limit on line length, but we should avoid
extremely long lines. A general guideline is: refactor stuff to get it
under 85 characters, unless that makes the code a lot uglier, in which
case it's fine to go up to 120 or so.
Whitespace guidelines:
- Put one space (or more for alignment) around binary arithmetic and
equality operators.
- Put one space around each part of the ternary operator.
- Put one space between keywords like ``if`` and ``while`` and their
associated open paren.
- Put one space between the closing paren for ``if`` and ``while``-like
constructs and the opening curly brace. Put the curly brace on the
same line unless doing otherwise improves readability.
- Put no space before or after the open paren for function calls and no
space before the close paren for function calls.
- For the comma operator and colon operator in languages where it is
used for inline dictionaries, put no space before it and at least one
space after. Only use more than one space for alignment.
Javascript
----------
Don't use ``==`` and ``!=`` because these operators perform type
coercions, which can mask bugs. Always use ``===`` and ``!==``.
End every statement with a semicolon.
``if`` statements with no braces are allowed, if the body is simple and
its extent is abundantly clear from context and formatting.
Anonymous functions should have spaces before and after the argument
list::
var x = function (foo, bar) { // ...
When calling a function with an anonymous function as an argument, use
this style::
$.get('foo', function (data) {
    var x = ...;
    // ...
});
The inner function body is indented one level from the outer function
call. The closing brace for the inner function and the closing
parenthesis for the outer call are together on the same line. This style
isn't necessarily appropriate for calls with multiple anonymous
functions or other arguments following them.
Use
::
$(function () { ...
rather than
::
$(document).ready(function () { ...
and combine adjacent on-ready functions, if they are logically related.
The best way to build complicated DOM elements is a Mustache template
like ``zephyr/static/templates/message.handlebars``. For simpler things
you can use jQuery DOM building APIs like so::
var new_tr = $('<tr />').attr('id', zephyr.id);
Passing a HTML string to jQuery is fine for simple hardcoded things::
foo.append('<p id="selected">foo</p>');
but avoid programmatically building complicated strings.
We used to favor attaching behaviors in templates like so::
<p onclick="select_zephyr({{id}})">
but there are some reasons to prefer attaching events using jQuery code:
- Potential huge performance gains by using delegated events where
possible
- When calling a function from an ``onclick`` attribute, ``this`` is
not bound to the element like you might think
- jQuery does event normalization
Either way, avoid complicated JavaScript code inside HTML attributes;
call a helper function instead.
HTML / CSS
----------
Don't use the ``style=`` attribute. Instead, define logical classes and
put your styles in ``zulip.css``.
Don't use the tag name in a selector unless you have to. In other words,
use ``.foo`` instead of ``span.foo``. We shouldn't have to care if the
tag type changes in the future.
Don't use inline event handlers (``onclick=``, etc. attributes).
Instead, attach a jQuery event handler
(``$('#foo').on('click', function () {...})``) when the DOM is ready
(inside a ``$(function () {...})`` block).
Use this format when you have the same block applying to multiple CSS
styles (separate lines for each selector)::
selector1,
selector2 {
};
Python
------
- Scripts should start with ``#!/usr/bin/env python2.7`` and not
``#!/usr/bin/env python2.7``. See commit ``437d4aee`` for an explanation of
why. Don't put such a line on a Python file unless it's meaningful to
run it as a script. (Some libraries can also be run as scripts, e.g.
to run a test suite.)
- The first import in a file should be
``from __future__ import absolute_import``, per `PEP
328 <http://docs.python.org/2/whatsnew/2.5.html#pep-328-absolute-and-relative-imports>`__
- Put all imports together at the top of the file, absent a compelling
reason to do otherwise.
- Unpacking sequences doesn't require list brackets::
[x, y] = xs    # unnecessary
x, y = xs      # better
- For string formatting, use ``x % (y,)`` rather than ``x % y``, to
avoid ambiguity if ``y`` happens to be a tuple.
- When selecting by id, don't use ``foo.pk`` when you mean ``foo.id``.
E.g.
::
recipient = Recipient(type_id=huddle.pk, type=Recipient.HUDDLE)
should be written as
::
recipient = Recipient(type_id=huddle.id, type=Recipient.HUDDLE)
in case we ever change the primary keys.
Version Control
===============
Commit Discipline
-----------------
We follow the Git project's own commit discipline practice of "Each
commit is a minimal coherent idea". This discipline takes a bit of
work, but it makes it much easier for code reviewers to spot bugs, and
makesthe commit history a much more useful resource for developers
trying to understand why the code works the way it does, which also
helps a lot in preventing bugs.
Coherency requirements for any commit:
- It should pass tests (so test updates needed by a change should be in
the same commit as the original change, not a separate "fix the tests
that were broken by the last commit" commit).
- It should be safe to deploy individually, or comment in detail in the
commit message as to why it isn't (maybe with a [manual] tag). So
implementing a new API endpoint in one commit and then adding the
security checks in a future commit should be avoided -- the security
checks should be there from the beginning.
- Error handling should generally be included along with the code that
might trigger the error.
- TODO comments should be in the commit that introduces the
issue or functionality with further work required.
When you should be minimal:
- Significant refactorings should be done in a separate commit from
functional changes.
- Moving code from one file to another should be done in a separate
commits from functional changes or even refactoring within a file.
- 2 different refactorings should be done in different commits.
- 2 different features should be done in different commits.
- If you find yourself writing a commit message that reads like a list
of somewhat dissimilar things that you did, you probably should have
just done 2 commits.
When not to be overly minimal:
- For completely new features, you don't necessarily need to split out
new commits for each little subfeature of the new feature. E.g. if
you're writing a new tool from scratch, it's fine to have the initial
tool have plenty of options/features without doing separate commits
for each one. That said, reviewing a 2000-line giant blob of new
code isn't fun, so please be thoughtful about submitting things in
reviewable units.
- Don't bother to split back end commits from front end commits, even
though the backend can often be coherent on its own.
Other considerations:
- Overly fine commits are easily squashed, but not vice versa, so err
toward small commits, and the code reviewer can advise on squashing.
- If a commit you write doesn't pass tests, you should usually fix
that by amending the commit to fix the bug, not writing a new "fix
tests" commit on top of it.
- When you fix a GitHub issue, `mark that you've fixed the issue in
your commit message
<https://help.github.com/articles/closing-issues-via-commit-messages/>`__
so that the issue is automatically closed when your code is merged.
Zulip's preferred style for this is to have the final paragraph
of the commit message read e.g. "Fixes: #123."
Zulip expects you to structure the commits in your pull requests to
form a clean history before we will merge them; it's best to write
your commits following these guidelines in the first place, but if you
don't, you can always fix your history using `git rebase -i`.
It can take some practice to get used to writing your commits with a
clean history so that you don't spend much time doing interactive
rebases. For example, often you'll start adding a feature, and
discover you need to a refactoring partway through writing the
feature. When that happens, we recommend stashing your partial
feature, do the refactoring, commit it, and then finish implementing
your feature.
Commit Messages
---------------
- The first line of commit messages should be written in the imperative
and be kept relatively short while concisely explaining what the
commit does. For example:
Bad::
bugfix
gather_subscriptions was broken
fix bug #234.
Good::
Fix gather_subscriptions throwing an exception when given bad input.
- Use present-tense action verbs in your commit messages.
Bad::
Fixing gather_subscriptions throwing an exception when given bad input.
Fixed gather_subscriptions throwing an exception when given bad input.
Good::
Fix gather_subscriptions throwing an exception when given bad input.
- Please use a complete sentence in the summary, ending with a
period.
- The rest of the commit message should be written in full prose and
explain why and how the change was made. If the commit makes
performance improvements, you should generally include some rough
benchmarks showing that it actually improves the performance.
- Any paragraph content in the commit message should be line-wrapped
to less than 76 characters per line, so that your commit message
will be reasonably readable in `git log` in a normal terminal.
- In your commit message, you should describe any manual testing you
did in addition to running the automated tests, and any aspects of
the commit that you think are questionable and you'd like special
attention applied to.
Tests
-----
All significant new features should come with tests.
Third party code
----------------
When adding new third-party packages to our codebase, please include
"[third]" at the beginning of the commit message. You don't necessarily
need to do this when patching third-party code that's already in tree.

View File

@@ -15,6 +15,7 @@
import sys
import os
import shlex
if False: 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
@@ -29,16 +30,11 @@ import shlex
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []
extensions = [] # type: List[str]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The encoding of source files.
#source_encoding = 'utf-8-sig'
@@ -47,7 +43,7 @@ master_doc = 'index'
# General information about the project.
project = u'Zulip'
copyright = u'2015, The Zulip Team'
copyright = u'2015-2016, The Zulip Team'
author = u'The Zulip Team'
# The version info for the project you're documenting, acts as replacement for
@@ -55,16 +51,16 @@ author = u'The Zulip Team'
# built documents.
#
# The short X.Y version.
version = '0.1'
version = '1.4'
# The full version, including alpha/beta/rc tags.
release = '0.1'
release = '1.4.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = None # type: Optional[str]
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
@@ -210,6 +206,8 @@ html_static_path = ['_static']
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
@@ -227,7 +225,7 @@ latex_elements = {
# Latex figure (float) alignment
#'figure_align': 'htbp',
}
} # type: Dict[str, str]
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
@@ -300,4 +298,6 @@ source_parsers = {
'.md': CommonMarkParser,
}
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
source_suffix = ['.rst', '.md']

242
docs/conversion.md Normal file
View File

@@ -0,0 +1,242 @@
# Exporting data
## Overview
Occasionally Zulip administrators will need to move data from one
server to another.
There are many major operational aspects to doing a conversion. I will
list them here, noting that several are not within the scope of this
document:
- Get new servers running.
- Export data from the old DB.
- Export files from S3.
- Import files into new storage.
- Import data into new DB.
- Restart new servers.
- Decommission old server.
This document focuses almost entirely on the **export** piece. Issues
with getting Zulip itself running are totally out of scope here. For the
import side of things, I only touch on it implicity. (My reasoning is
that we *have* to get the export piece right in a timely fashion, even
if it means we have to sort out some straggling issues on the import side
later.)
## Export
We have tools that essentially export Zulip data to the file system.
A good overview of the process is here:
[management/export.py](https://github.com/zulip/zulip/blob/master/zerver/management/commands/export.py)
This document supplements that explanation, but here we focus more
on the logistics of a big conversion. For some historical perspective,
this document was originally drafted as part of a big Zulip cut-over.
The main exporting tools in place as of summer 2016 are below:
- We can export single realms (but not yet limit users within the realm).
- We can export single users (but then we get no realm-wide data in the process).
- We can run exports simultaneously (but have to navigate a bunch of /tmp directories).
Things that we still may need:
- We may want to export multiple realms simultaneously.
- We may want to export multiple single users simultaneously.
- We may want to limit users within realm exports.
- We may want more operational robustness/convenience while doing several exports simultaenously.
- We may want to merge multiple export files to remove duplicates.
We have a few major classes of data. They are listed below in the order
that we process them in `do_export_realm()`:
#### Public Realm Data
Realm/RealmAlias/RealmEmoji/RealmFilter/DefaultStream.
#### Cross Realm Data
Client/zerver_userprofile_cross_realm
This includes Client and three bots.
Client is unique in being a fairly core table that is
not tied to UserProfile or Realm (unless you somewhat painfully tie
it back to users in a bottom-up fashion though other tables).
#### Disjoint User Data
UserProfile/UserActivity/UserActivityInterval/UserPresence.
#### Recipient Data
Recipient/Stream/Subscription/Huddle.
These tables are tied back to users, but they introduce complications
when you try to deal with multi-user subsets.
#### File-related Data
Attachment
This includes Attachment, and it referencs the avatar_source field of
UserProfile. Most importantly, of course, it requires us to grab files
from S3. Finally, Attachment's m2m relationship ties to Message.
#### Message Data
Message/UserMessage
### Summary
Here are the same classes of data, listed in roughly
decreasing order of riskiness:
- Message Data (sheer volume/lack of time/security)
- File-Related Data (S3/security/lots of moving parts)
- Recipient Data (complexity/security/cross-realm considerations)
- Cross Realm Data (duplicate ids)
- Disjoint User Data
- Public Realm Data
(Note the above list is essentially in reverse order of how we
process the data, which isn't surprising for a top-down approach.)
The next section of the document talks about risk factors.
# Risk Mitigation
## Generic considerations
We have two major mechanisms for getting data:
##### Top Down
Get realm data, then all users in realm, then all recipients, then all messages, etc.
The problem with the top down approach will be **filtering**. Also, if
errors arise during top-down passes, it may be time consuming to re-run
the processes.
##### Bottom Up
Start with users, get their recipient data, etc.
The problems with the bottom up approach will be **merging**. Also, if
we run multiple bottom-up passes, there is the danger of duplicating some
work, particularly on the message side of things.
### Approved Transfers
We have not yet integrated the approved-transfer model, which tells us
which users can be moved.
## Risk factors broken out by data categories
### Message Data
- models: Message/UserMessage.
- assets: messages-*.json, subprocesses, partial files
Rows in the Message model depend on Recipient/UserProfile.
Rows in the UserMessage model depend on UserProfile/Message.
The biggest concern here is the **sheer volume** of data, with
security being a close second. (They are interrelated, as without
security concerns, we could just bulk-export everything one time.)
We currently have these measures in place for top-down processing:
- chunking
- multi-processing
- messages are filtered by both sender and recipient
### File Related Data
- models: Attachment
- assets: S3, attachment.json, uploads-temp/, image files in avatars/, assorted files in uploads/, avatars/records.json, uploads/records.json, zerver_attachment_messages
When it comes to exporting attachment data, we have some minor volume issues, but the
main concern is just that there are **lots of moving parts**:
- S3 needs to be up, and we get some metadata from it as well as files.
- We have security concerns about copying over only files that belong to users who approved the transfer.
- This piece is just different in how we store data from all the other DB-centric pieces.
- At import time we have to populate the m2m table (but fortunately, this is pretty low
risk in terms of breaking anything.)
### Recipient Data
- models: Recipient/Stream/Subscription/Huddle
- assets: realm.json, (user,stream,huddle)_(recipient,subscription)
This data is fortunately low to medium in volume. The risk here will come
from **model complexity** and **cross-realm concerns**.
From the top down, here are the dependencies:
- Recipient depends on UserProfile
- Subscription depends on Recipient
- Stream currently depends on Realm (but maybe it should be tied to Subscription)
- Huddle depends on Subscription and UserProfile
The biggest risk factor here is probably just the possibility that we could introduce
some bug in our code as we try to segment Recipient into user, stream, and huddle components,
especially if we try to handle multiple users or realms.
I think this can be largely mitigated by the new Config approach.
And then we also have some complicated Huddle logic that will be customized
regardless. The fiddliest part
of the Huddle logic is creating the set of unsafe_huddle_recipient_ids.
Last but not least, if we go with some hybrid of bottom-up and top-down, these tables
are neither close to the bottom nor close to the top, so they may have the most
fiddly edge cases when it comes to filtering and merging.
Recommendation: We probably want to get a backup of all this data that is very simply
bulk-exported from the entire DB, and we should obviously put it in a secure place.
### Cross Realm Data
- models: Client
- assets: realm.json, three bots (notification/email/welcome), id_maps
The good news here is that Client is a small table, and there are
only three special bots.
The bad news is that cross-realm data **complicates everything else**,
and we have to avoid **database id conflicts**.
If we use bottom-up approaches to load small user populations at a time, we may
have **merging** issues here. We will need to consolidate ids either by merging
exports in /tmp or handle it import time.
For the three bots, they live in zerver_userprofile_crossrealm, and we re-map
their ids on the new server.
Recommendation: Do not sweat the exports too much. Deal with all the messiness at
import time, and rely on the tables being really small. We already have logic
to catch Client.DoesNotExist exceptions, for example. As for possibly missing
messages that the welcome bot and friends have sent in the past, I am not sure
what our risk profile is there, but I imagine it is relatively low.
### Disjoint User Data
- models: UserProfile/UserActivity/UserActivityInterval/UserPresence
- assets: realm.json, password, api_key, avatar salt, id_maps
On the DB side this data should be fairly easy to deal with. All of these
tables are basically disjoint by user profile id. Our biggest
risk is **remapped user ids** at import time, but this is mostly covered
in the section above.
We have code in place to exclude password and api_key from UserProfile
rows. The import process calls set_unusable_password().
### Public Realm Data
- models: Realm/RealmAlias/RealmEmoji/RealmFilter/DefaultStream
- asserts: realm.json
All of these tables are public (per-realm), and they are keyed by
realm id. There is not a ton to worry about here, except possibly
**merging** if we run multiple bottom-up jobs for a single realm.

View File

@@ -0,0 +1,697 @@
## Vagrant environment setup tutorial
This section guides first-time contributors through installing the Zulip dev
environment on Windows 10, OS X El Capitan, Ubuntu 14.04, and Ubuntu 16.04.
The recommended method for installing the Zulip dev environment is to use
Vagrant with VirtualBox on Windows and OS X, and Vagrant with LXC on
Ubuntu. This method creates a virtual machine (for Windows and OS X)
or a Linux container (for Ubuntu) inside which the Zulip server and
all related services will run.
Contents:
* [Requirements](#requirements)
* [Step 1: Install Prerequisites](#step-1-install-prerequisites)
* [Step 2: Get Zulip code](#step-2-get-zulip-code)
* [Step 3: Start the dev environment](#step-3-start-the-dev-environment)
* [Step 4: Developing](#step-4-developing)
* [Troubleshooting & Common Errors](#troubleshooting-common-errors)
If you encounter errors installing the Zulip development environment,
check [Troubleshooting & Common
Errors](#troubleshooting-common-errors). If that doesn't help, please
visit [the `provision` stream in the Zulip developers'
chat](https://zulip.tabbott.net/#narrow/stream/provision) for realtime
help, or 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).
### Requirements
Installing the Zulip dev environment requires downloading several
hundred megabytes of dependencies. You will need an active internet
connection throughout the entire installation processes. (See
[Specifying a
proxy](brief-install-vagrant-dev.html#specifying-a-proxy) if you need
a proxy to access the internet.)
- **All**: 2GB available RAM, Active broadband internet connection.
- **OS X**: OS X (El Capitan recommended, untested on previous versions), Git,
[VirtualBox][vbox-dl], [Vagrant][vagrant-dl].
- **Ubuntu**: 14.04 64-bit or 16.04 64-bit, Git, [Vagrant][vagrant-dl], lxc.
- **Windows**: Windows 64-bit (Win 10 recommended; Win 7 untested), hardware
virtualization enabled (VT-X or AMD-V), administrator access,
[Cygwin][cygwin-dl], [VirtualBox][vbox-dl], [Vagrant][vagrant-dl].
Don't see your system listed above? Check out:
* [Brief installation instructions for Vagrant development
environment](brief-install-vagrant-dev.html)
* [Installing manually on UNIX-based platforms](install-generic-unix-dev.html)
[cygwin-dl]: http://cygwin.com/
### Step 1: Install Prerequisites
Jump to:
* [OS X](#os-x)
* [Ubuntu](#ubuntu)
* [Windows](#windows-10)
#### OS X
1. Install [VirtualBox][vbox-dl]
2. Install [Vagrant][vagrant-dl]
Now you are ready for [Step 2: Get Zulip Code.](#step-2-get-zulip-code)
#### Ubuntu
The setup for Ubuntu 14.04 Trusty and Ubuntu 16.04 Xenial are the same.
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):
```
sudo apt-get purge vagrant
wget https://releases.hashicorp.com/vagrant/1.8.4/vagrant_1.8.4_x86_64.deb
sudo dpkg -i vagrant*.deb
sudo apt-get install build-essential git ruby lxc lxc-templates cgroup-lite redir
vagrant plugin install vagrant-lxc
vagrant lxc sudoers
```
For a step-by-step explanation, read on.
##### 1. Install Vagrant
For both 14.04 Trusty and 16.04 Xenial, you'll need a more recent version of
Vagrant than what's available in the official Ubuntu repositories.
First uninstall any vagrant package you may have installed from the Ubuntu
repository:
```
christie@ubuntu-desktop:~
$ sudo apt-get purge vagrant
```
Now download and install the most recent .deb package from [Vagrant][vagrant-dl]:
```
christie@ubuntu-desktop:~
$ wget https://releases.hashicorp.com/vagrant/1.8.4/vagrant_1.8.4_x86_64.deb
christie@ubuntu-desktop:~
$ sudo dpkg -i vagrant*.deb
```
##### 2. Install remaining dependencies
Now install git and lxc-related packages:
```
christie@ubuntu-desktop:~
$ sudo apt-get install build-essential git ruby lxc lxc-templates cgroup-lite redir
```
##### 3. Install the vagrant lxc plugin:
```
christie@ubuntu-desktop:~
$ vagrant plugin install vagrant-lxc
Installing the 'vagrant-lxc' plugin. This can take a few minutes...
Installed the plugin 'vagrant-lxc (1.2.1)'!
```
If you encounter an error when trying to install the vagrant-lxc plugin, [see
this](#nomethoderror-when-installing-vagrant-lxc-plugin-ubuntu-1604).
##### 4. Configure sudo to be passwordless
Finally, [configure sudo to be passwordless when using Vagrant LXC][avoiding-sudo]:
```
christie@ubuntu-desktop:~
$ vagrant lxc sudoers
[sudo] password for christie:
```
Now you are ready for [Step 2: Get Zulip Code.](#step-2-get-zulip-code)
[vagrant-dl]: https://www.vagrantup.com/downloads.html
[vagrant-lxc]: https://github.com/fgrehm/vagrant-lxc
[vbox-dl]: https://www.virtualbox.org/wiki/Downloads
[avoiding-sudo]: https://github.com/fgrehm/vagrant-lxc#avoiding-sudo-passwords
#### Windows 10
1. Install [Cygwin][cygwin-dl]. Make sure to install default required
packages along with **git**, **curl**, **openssh**, and **rsync**
binaries.
2. Install [VirtualBox][vbox-dl]
3. Install [Vagrant][vagrant-dl]
##### Configure Cygwin
In order for symlinks to work within the Ubuntu virtual machine, you must tell
Cygwin to create them as [native Windows
symlinks](https://cygwin.com/cygwin-ug-net/using.html#pathnames-symlinks). The
easiest way to do this is to add a line to `~/.bash_profile` setting the CYGWIN
environment variable.
Open a Cygwin window and do this:
```
christie@win10 ~
$ echo 'export "CYGWIN=$CYGWIN winsymlinks:native"' >> ~/.bash_profile
```
Next, close that Cygwin window and open another. If you `echo` $CYGWIN you
should see:
```
christie@win10 ~
$ echo $CYGWIN
winsymlinks:native
```
Now you are ready for [Step 2: Get Zulip Code.](#step-2-get-zulip-code)
### Step 2: Get Zulip Code
If you haven't already created an ssh key and added it to your Github account,
you should do that now by following [these
instructions](https://help.github.com/articles/generating-an-ssh-key/).
1. In your browser, visit https://github.com/zulip/zulip and click the
`fork` button. You will need to be logged in to Github to do this.
2. Open Terminal (OS X/Ubuntu) or Cygwin (Windows; must run as an Administrator)
3. In Terminal/Cygwin, clone your fork:
```
git clone git@github.com:YOURUSERNAME/zulip.git
```
This will create a 'zulip' directory and download the Zulip code into it.
Don't forget to replace YOURUSERNAME with your git username. You will see
something like:
```
christie@win10 ~
$ git clone git@github.com:YOURUSERNAME/zulip.git
Cloning into 'zulip'...
remote: Counting objects: 73571, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 73571 (delta 1), reused 0 (delta 0), pack-reused 73569
Receiving objects: 100% (73571/73571), 105.30 MiB | 6.46 MiB/s, done.
Resolving deltas: 100% (51448/51448), done.
Checking connectivity... done.
Checking out files: 100% (1912/1912), done.`
```
Now you are ready for [Step 3: Start the dev
environment.](#step-3-start-the-dev-environment)
### Step 3: Start the dev environment
Change into the zulip directory and tell vagrant to start the Zulip
dev environment with `vagrant up`.
```
christie@win10 ~
$ cd zulip
christie@win10 ~/zulip
$ vagrant up
```
The first time you run this command it will take some time because vagrant
does the following:
- downloads the base Ubuntu 14.04 virtual machine image (for OS X and Windows)
or container (for Ubuntu)
- configures this virtual machine/container for use with Zulip,
- creates a shared directory mapping your clone of the Zulip code inside the
virtual machine/container at `/srv/zulip`
- runs the `tools/provision.py` script inside the virtual machine/container, which
downloads all required dependencies, sets up the python environment for
the Zulip dev environment, and initializes a default test database.
You will need an active internet connection during the entire
processes. (See [Specifying a
proxy](brief-install-vagrant-dev.html#specifying-a-proxy) if you need
a proxy to access the internet.) And if you're running into any
problems, please come chat with us [in the `provision` stream of our
developers' chat](https://zulip.tabbott.net/#narrow/stream/provision).
Once `vagrant up` has completed, connect to the dev environment with `vagrant
ssh`:
```
christie@win10 ~/zulip
$ vagrant ssh
```
You should see something like this on Windows and OS X:
```
Welcome to Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-85-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Wed May 4 21:45:43 UTC 2016
System load: 0.61 Processes: 88
Usage of /: 3.5% of 39.34GB Users logged in: 0
Memory usage: 7% IP address for eth0: 10.0.2.15
Swap usage: 0%
Graph this data and manage this system at:
https://landscape.canonical.com/
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
0 packages can be updated.
0 updates are security updates.
```
Or something as brief as this in the case of Ubuntu:
```
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 4.4.0-21-generic x86_64)
* Documentation: https://help.ubuntu.com/
```
Congrats, you're now inside the Zulip dev environment!
You can confirm this by looking at the command prompt, which starts with
`(zulip-venv)`.
Next, start the Zulip server:
```
(zulip-venv)vagrant@vagrant-ubuntu-trusty-64:~ $
/srv/zulip/tools/run-dev.py --interface=''
```
As you can see above the application's root directory, where you can
execute Django's command line utilities is:
```
/srv/zulip/
```
You will see several lines of output starting with something like:
```
2016-05-04 22:20:33,895 INFO: process_fts_updates starting
Recompiling templates
2016-05-04 18:20:34,804 INFO: Not in recovery; listening for FTS updates
done
Validating Django models.py...
System check identified no issues (0 silenced).
Django version 1.8
Tornado server is running at http://localhost:9993/
Quit the server with CTRL-C.
2016-05-04 18:20:40,716 INFO Tornado loaded 0 event queues in 0.001s
2016-05-04 18:20:40,722 INFO Tornado 95.5% busy over the past 0.0 seconds
Performing system checks...
```
And ending with something similar to:
```
http://localhost:9994/webpack-dev-server/
webpack result is served from http://localhost:9991/webpack/
content is served from /srv/zulip
webpack: bundle is now VALID.
2016-05-06 21:43:29,553 INFO Tornado 31.6% busy over the past 10.6 seconds
2016-05-06 21:43:35,007 INFO Tornado 23.9% busy over the past 16.0 seconds
```
Now the Zulip server should be running and accessible. Verify this by
navigating to [http://localhost:9991/](http://localhost:9991/) in your browser
on your main machine.
You should see something like [(this screenshot of the Zulip dev
environment)](https://raw.githubusercontent.com/zulip/zulip/master/docs/images/zulip-dev.png).
![Image of Zulip dev environment](https://raw.githubusercontent.com/zulip/zulip/master/docs/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
should see something like:
```
2016-05-04 18:21:57,547 INFO 127.0.0.1 GET 302 582ms (+start: 417ms) / (unauth via ?)
[04/May/2016 18:21:57]"GET / HTTP/1.0" 302 0
2016-05-04 18:21:57,568 INFO 127.0.0.1 GET 301 4ms /login (unauth via ?)
[04/May/2016 18:21:57]"GET /login HTTP/1.0" 301 0
2016-05-04 18:21:57,819 INFO 127.0.0.1 GET 200 209ms (db: 7ms/2q) /login/ (unauth via ?)
```
Now you're ready for [Step 4: Developing.](#step-4-developing)
### Step 4: Developing
#### Where to edit files
You'll work by editing files on your host machine, in the directory where you
cloned Zulip. Use your favorite editor (Sublime, Atom, Vim, Emacs, Notepad++,
etc.).
When you save changes they will be synced automatically to the Zulip dev environment
on the virtual machine/container.
Each component of the Zulip development server will automatically
restart itself or reload data appropriately when you make changes. So,
to see your changes, all you usually have to do is reload your
browser. More details on how this works are available below.
Don't forget to read through the [code style
guidelines](https://zulip.readthedocs.io/en/latest/code-style.html#general) for
details about how to configure your editor for Zulip. For example, indentation
should be set to 4 spaces rather than tabs.
#### Understanding run-dev.py debugging output
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](http://zulip.readthedocs.io/en/latest/logging.html) for
further details on the run-dev.py console output.
#### Committing and pushing changes with git
When you're ready to commit or push changes via git, you will do this by
running git commands in Terminal (OS X/Ubuntu) or Cygwin (Windows) in the directory
where you cloned Zulip on your main machine.
If you're new to working with Git/Github, check out [this
guide](https://help.github.com/articles/create-a-repo/#commit-your-first-change).
#### Maintaining the dev environment
If after rebasing onto a new version of the Zulip server, you receive
new errors while starting the Zulip server or running tests, this is
probably not because Zulip's master branch is broken. Instead, this
is likely because we've recently merged changes to the development
environment provisioning process that you need to apply to your
development environmnet. To update your environment, you'll need to
re-provision your vagrant machine using `vagrant provision`
(or just `python tools/provision.py` from `/srv/zulip` inside the Vagrant
guest); this should be pretty fast and we're working to make it faster.
See also the documentation on the [testing
page](http://zulip.readthedocs.io/en/latest/testing.html#manual-testing-local-app-web-browser)
for how to destroy and rebuild your database if you want to clear out test data.
#### Rebuilding the dev environment
If you ever want to recreate your development environment again from
scratch (e.g. to test as change you've made to the provisioning
process, or because you think something is broken), you can do so
using `vagrant destroy` and then `vagrant up`. This will usually be
much faster than the original `vagrant up` since the base image is
already cached on your machine (it takes about 5 minutes to run with a
fast Internet connection).
#### Shutting down the dev environment for use later
To shut down but preserve the dev environment so you can use it again
later use `vagrant halt` or `vagrant suspend`.
You can do this from the same Terminal/Cygwin window that is running
run-dev.py by pressing ^C to halt the server and then typing `exit`. Or you
can halt vagrant from another Terminal/Cygwin window.
From the window where run-dev.py is running:
```
2016-05-04 18:33:13,330 INFO 127.0.0.1 GET 200 92ms /register/ (unauth via ?)
^C
KeyboardInterrupt
(zulip-venv)vagrant@vagrant-ubuntu-trusty-64:/srv/zulip$ exit
logout
Connection to 127.0.0.1 closed.
christie@win10 ~/zulip
```
Now you can suspend the dev environment:
```
christie@win10 ~/zulip
$ vagrant suspend
==> default: Saving VM state and suspending execution...
```
If `vagrant suspend` doesn't work, try `vagrant halt`:
```
christie@win10 ~/zulip
$ vagrant halt
==> default: Attempting graceful shutdown of VM...
```
Check out the Vagrant documentation to learn more about
[suspend](https://www.vagrantup.com/docs/cli/suspend.html) and
[halt](https://www.vagrantup.com/docs/cli/halt.html).
#### Resuming the dev environment
When you're ready to work on Zulip again, run `vagrant up`. You will also need
to connect to the virtual machine with `vagrant ssh` and re-start the Zulip
server:
```
christie@win10 ~/zulip
$ vagrant up
$ vagrant ssh
/srv/zulip/tools/run-dev.py --interface=''
```
#### Next Steps
At this point you should [read about using the development
environment][using-dev-environment.html].
### Troubleshooting & Common Errors
Zulip's `vagrant` provisioning process logs useful debugging output to
`/var/log/zulip_provision.log`; if you encounter a new issue, please
attach a copy of that file to your bug report.
#### The box 'ubuntu/trusty64' could not be found (Windows/Cygwin)
If you see the following error when you run `vagrant up` on Windows:
```
The box 'ubuntu/trusty64' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:
URL: ["https://atlas.hashicorp.com/ubuntu/trusty64"]
```
Then the version of curl that ships with Vagrant is not working on your
machine. The fix is simple: replace it with the version from Cygwin.
First, determine the location of Cygwin's curl with `which curl`:
```
christie@win10 ~/zulip
$ which curl
/usr/bin/curl
```
Now determine the location of Vagrant with `which vagrant`:
```
christie@win10 ~/zulip
$ which vagrant
/cygdrive/c/HashiCorp/Vagrant/bin/vagrant
```
The path **up until `/bin/vagrant`** is what you need to know. In the example above it's `/cygdrive/c/HashiCorp/Vagrant`.
Finally, copy Cygwin's curl to Vagrant `embedded/bin` directory:
```
christie@win10 ~/zulip
$ cp /usr/bin/curl.exe /cygdrive/c/HashiCorp/Vagrant/embedded/bin/
```
Now re-run `vagrant up` and vagrant should be able to fetch the required
box file.
#### os.symlink error
If you receive the following error while running `vagrant up`:
```
==> default: Traceback (most recent call last):
==> default: File "./emoji_dump.py", line 75, in <module>
==> default:
==> default: os.symlink('unicode/{}.png'.format(code_point), 'out/{}.png'.format(name))
==> default: OSError
==> default: :
==> default: [Errno 71] Protocol error
```
Then Vagrant was not able to create a symbolic link.
First, if you are using Windows, **make sure you have run Cygwin as an
administrator**. By default, only administrators can create symbolic links on
Windows.
Second, VirtualBox does not enable symbolic links by default. Vagrant
starting with version 1.6.0 enables symbolic links for VirtualBox shared
folder.
You can check to see that this is enabled for your virtual machine with
`vboxmanage` command.
Get the name of your virtual machine by running `vboxmanage list vms` and
then print out the custom settings for this virtual machine with
`vboxmanage getextradata YOURVMNAME enumerate`:
```
christie@win10 ~/zulip
$ vboxmanage list vms
"zulip_default_1462498139595_55484" {5a65199d-8afa-4265-b2f6-6b1f162f157d}
christie@win10 ~/zulip
$ vboxmanage getextradata zulip_default_1462498139595_55484 enumerate
Key: VBoxInternal2/SharedFoldersEnableSymlinksCreate/srv_zulip, Value: 1
Key: supported, Value: false
```
If you see "command not found" when you try to run VBoxManage, you need to
add the VirtualBox directory to your path. On Windows this is mostly likely
`C:\Program Files\Oracle\VirtualBox\`.
If `vboxmanage enumerate` prints nothing, or shows a value of 0 for
VBoxInternal2/SharedFoldersEnableSymlinksCreate/srv_zulip, then enable
symbolic links by running this command in Terminal/Cygwin:
```
vboxmanage setextradata YOURVMNAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/srv_zulip 1
```
The virtual machine needs to be shut down when you run this command.
#### Connection timeout on `vagrant up`
If you see the following error after running `vagrant up`:
```
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
default: Error: Connection timeout. Retrying...
```
A likely cause is that hardware virtualization is not enabled for your
computer. This must be done via your computer's BIOS settings. Look for a
setting called VT-x (Intel) or (AMD-V).
If this is already enabled in your BIOS, double-check that you are running a
64-bit operating system.
For further information about troubleshooting vagrant timeout errors [see
this post](http://stackoverflow.com/questions/22575261/vagrant-stuck-connection-timeout-retrying#22575302).
#### npm install error
The `tools/provision.py` script may encounter an error related to `npm install`
that looks something like:
```
==> default: + npm install
==> default: Traceback (most recent call last):
==> default: File "/srv/zulip/tools/provision.py", line 195, in <module>
==> default:
==> default: sys.exit(main())
==> default: File "/srv/zulip/tools/provision.py", line 191, in main
==> default:
==> default: run(["npm", "install"])
==> default: File "/srv/zulip/scripts/lib/zulip_tools.py", line 78, in run
==> default:
==> default: raise subprocess.CalledProcessError(rc, args)
==> default: subprocess
==> default: .
==> default: CalledProcessError
==> default: :
==> default: Command '['npm', 'install']' returned non-zero exit status 34
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.
```
Usually this error is not fatal. Try connecting to the dev environment and
re-trying the command from withing the virtual machine:
```
christie@win10 ~/zulip
$ vagrant ssh
(zulip-venv)vagrant@vagrant-ubuntu-trusty-64:~
$ cd /srv/zulip
(zulip-venv)vagrant@vagrant-ubuntu-trusty-64:/srv/zulip
$ npm install
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.12
```
These are just warnings so it is okay to proceed and start the Zulip server.
#### NoMethodError when installing vagrant-lxc plugin (Ubuntu 16.04)
If you see the following error when you try to install the vagrant-lxc plugin:
```
/usr/lib/ruby/2.3.0/rubygems/specification.rb:946:in `all=': undefined method `group_by' for nil:NilClass (NoMethodError)
from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:275:in `with_isolated_gem'
from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:231:in `internal_install'
from /usr/lib/ruby/vendor_ruby/vagrant/bundler.rb:102:in `install'
from /usr/lib/ruby/vendor_ruby/vagrant/plugin/manager.rb:62:in `block in install_plugin'
from /usr/lib/ruby/vendor_ruby/vagrant/plugin/manager.rb:72:in `install_plugin'
from /usr/share/vagrant/plugins/commands/plugin/action/install_gem.rb:37:in `call'
from /usr/lib/ruby/vendor_ruby/vagrant/action/warden.rb:34:in `call'
from /usr/lib/ruby/vendor_ruby/vagrant/action/builder.rb:116:in `call'
from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:66:in `block in run'
from /usr/lib/ruby/vendor_ruby/vagrant/util/busy.rb:19:in `busy'
from /usr/lib/ruby/vendor_ruby/vagrant/action/runner.rb:66:in `run'
from /usr/share/vagrant/plugins/commands/plugin/command/base.rb:14:in `action'
from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:32:in `block in execute'
from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:31:in `each'
from /usr/share/vagrant/plugins/commands/plugin/command/install.rb:31:in `execute'
from /usr/share/vagrant/plugins/commands/plugin/command/root.rb:56:in `execute'
from /usr/lib/ruby/vendor_ruby/vagrant/cli.rb:42:in `execute'
from /usr/lib/ruby/vendor_ruby/vagrant/environment.rb:268:in `cli'
from /usr/bin/vagrant:173:in `<main>'
```
And you have vagrant version 1.8.1, then you need to patch vagrant manually.
See [this post](https://github.com/mitchellh/vagrant/issues/7073) for an
explanation of the issue, which should be fixed when Vagrant 1.8.2 is released.
In the meantime, read [this
post](http://stackoverflow.com/questions/36811863/cant-install-vagrant-plugins-in-ubuntu-16-04/36991648#36991648)
for how to create and apply the patch.
It will look something like this:
```
christie@xenial:~
$ sudo patch --directory /usr/lib/ruby/vendor_ruby/vagrant < vagrant-plugin.patch
patching file bundler.rb
```
#### Permissions errors when running the test suite in LXC
See ["Possible testing issues"](testing.html#possible-testing-issues).

17
docs/dev-overview.md Normal file
View File

@@ -0,0 +1,17 @@
# Development environment options
Zulip offers a wide range of options for how to install the
development environment:
* [Detailed tutorial for Vagrant development environment](dev-env-first-time-contributors.html). Recommended for first-time contributors.
* [Brief installation instructions for Vagrant development environment](brief-install-vagrant-dev.html)
* [Installing on Ubuntu 14.04 Trusty or 16.04 Xenial directly](install-ubuntu-without-vagrant-dev.html) (convenient but more work to maintain/uninstall).
* [Installing manually on other UNIX platforms](install-generic-unix-dev.html)
* [Using Docker (experimental)](install-docker-dev.html)
* [Using the Development Environment](using-dev-environment.html)
* [Testing](testing.html)
If you have a slow network connection, you should probably avoid
installing Vagrant (which is large) and either install
[directly](install-ubuntu-without-vagrant-dev.html) or use [the manual
install process](install-generic-unix-dev.html) instead.

180
docs/directory-structure.md Normal file
View File

@@ -0,0 +1,180 @@
# Directory structure
This page documents the Zulip directory structure, where to find
things, and how to decide where to put a file.
You may also find the [new application feature
tutorial](new-feature-tutorial.html) helpful for understanding the
flow through these files.
### Core Python files
Zulip uses the [Django web
framework](https://docs.djangoproject.com/en/1.8/), so a lot of these
paths will be familiar to Django developers.
* `zproject/urls.py` Main [Django routes file](https://docs.djangoproject.com/en/1.8/topics/http/urls/). Defines which URLs are handled by which view functions or templates.
* `zerver/models.py` Main [Django models](https://docs.djangoproject.com/en/1.8/topics/db/models/) file. Defines Zulip's database tables.
* `zerver/lib/actions.py` Most code doing writes to user-facing database tables.
* `zerver/views/*.py` Most [Django views](https://docs.djangoproject.com/en/1.8/topics/http/views/).
* `zerver/views/webhooks/` Webhook views for [Zulip integrations](integration-guide.html).
* `zerver/tornadoviews.py` Tornado views.
* `zerver/worker/queue_processors.py` [Queue workers](queuing.html).
* `zerver/lib/*.py` Most library code.
* `zerver/lib/bugdown/` [Backend Markdown processor](markdown.html).
* `zproject/backends.py` [Authentication backends](https://docs.djangoproject.com/en/1.8/topics/auth/customizing/).
-------------------------------------------------------------------
### HTML Templates
See [our translating docs](translating.html) for details on Zulip's
templating systems.
* `templates/zerver/` For [Jinja2](http://jinja.pocoo.org/) templates for the backend (for zerver app).
* `static/templates/` [Handlebars](http://handlebarsjs.com/) templates for the frontend.
----------------------------------------
### JavaScript and other static assets
* `static/js/` Zulip's own JavaScript.
* `static/styles/` Zulip's own CSS.
* `static/images/` Zulip's images.
* `static/third/` Third-party JavaScript and CSS that has been vendored.
* `node_modules/` Third-party JavaScript installed via `npm`.
* `assets/` For assets not to be served to the web (e.g. the system to
generate our favicons).
-----------------------------------------------------------------------
### Tests
* `zerver/tests/` Backend tests.
* `frontend_tests/node_tests/` Node Frontend unit tests.
* `frontend_tests/casper_tests/` Casper frontend tests.
* `tools/test-*` Developer-facing test runner scripts.
-----------------------------------------------------
### Management commands
These are distinguished from scripts, below, by needing to run a
Django context (i.e. with database access).
* `zerver/management/commands/` Management commands one might run at a
production deployment site (e.g. scripts to change a value or
deactivate a user properly).
---------------------------------------------------------------
### Scripts
* `scripts/` Scripts that production deployments might run manually
(e.g., `restart-server`).
* `scripts/lib/` Scripts that are needed on production deployments but
humans should never run directly.
* `scripts/setup/` Scripts that production deployments will only run
once, during installation.
* `tools/` Scripts used only in a Zulip development environment.
These are not included in production release tarballs for Zulip, so
that we can include scripts here one wouldn't want someone to run in
production accidentally (e.g. things that delete the Zulip database
without prompting).
* `tools/setup/` Subdirectory of `tools/` for things only used during
the development environment setup process.
* `tools/travis/` Subdirectory of `tools/` for things only used to
setup and run our tests in Travis CI. Actually test suites should
go in `tools/`.
---------------------------------------------------------
### API and Bots
* `api/` Zulip's Python API bindings (released separately).
* `api/examples/` API examples.
* `api/integrations/` Bots distributed as part of the Zulip API bundle.
* `bots/` Previously Zulip internal bots. These usually need a bit of
work.
-------------------------------------------------------------------------
### Production puppet configuration
This is used to deploy essentially all configuration in production.
* `puppet/zulip/` For configuration for production deployments.
* `puppet/zulip/manifests/voyager.pp` Main manifest for Zulip standalone deployments.
-----------------------------------------------------------------------
### Additional Django apps
* `confirmation` Email confirmation system.
* `analytics` Analytics for the Zulip server administrator (needs work to
be useful to normal Zulip sites).
* `corporate` The old Zulip.com website. Not included in production
distribution.
* `zilencer` Primarily used to hold management commands that aren't
used in production. Not included in production distribution.
-----------------------------------------------------------------------
### Jinja2 Compatibility Files
* `zproject/jinja2/__init__.py` Jinja2 environment.
* `zproject/jinja2/backends.py` Jinja2 backend.
* `zproject/jinja2/compressors.py` Jinja2 compatible functions of
Django-Pipeline.
-----------------------------------------------------------------------
### Translation files
* `locale/` Backend (Django) translations data files.
* `static/locale/` Frontend translations data files.
-----------------------------------------------------------------------
### Documentation
* `docs/` Source for this documentation.
--------------------------------------------------------------
You can consult the repository's `.gitattributes` file to see exactly
which components are excluded from production releases (release
tarballs are generated using `tools/build-release-tarball`).

View File

@@ -1,95 +0,0 @@
===================
Directory structure
===================
This page documents the Zulip directory structure and how to decide where to
put a file.
Scripts
=======
+--------------------+-----------------------------------------------------------------------------------+
| ``scripts/`` | Scripts that production deployments might run manually (e.g. ``restart-server``) |
+--------------------+-----------------------------------------------------------------------------------+
| ``bin/`` | Scripts that are needed on production deployments but humans should never run |
+--------------------+-----------------------------------------------------------------------------------+
| ``scripts/setup/`` | Tools that production deployments will only run once, during installation |
+--------------------+-----------------------------------------------------------------------------------+
| ``tools/`` | Development tools |
+--------------------+-----------------------------------------------------------------------------------+
Bots
====
+------------------------+----------------------------------------------------------------------+
| ``api/integrations`` | Bots distributed as part of the Zulip API bundle. |
+------------------------+----------------------------------------------------------------------+
| ``bots/`` | Previously Zulip internal bots. These usually need a bit of work. |
+------------------------+----------------------------------------------------------------------+
Management commands
===================
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
| ``zerver/management/commands/`` | Management commands one might run at a production deployment site (e.g. scripts to change a value or deactivate a user properly) |
+-------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
Views
=====
+--------------------------------+-----------------------------------------+
| ``zerver/tornadoviews.py`` | Tornado views |
+--------------------------------+-----------------------------------------+
| ``zerver/views/webhooks.py`` | Webhook views |
+--------------------------------+-----------------------------------------+
| ``zerver/views/messages.py`` | message-related views |
+--------------------------------+-----------------------------------------+
| ``zerver/views/__init__.py`` | other Django views |
+--------------------------------+-----------------------------------------+
Static assets
=============
+---------------+---------------------------------------------------------------------------------------------------------------+
| ``assets/`` | For assets not to be served to the web (e.g. the system to generate our favicons) |
+---------------+---------------------------------------------------------------------------------------------------------------+
| ``static/`` | For things we do want to both serve to the web and distribute to production deployments (e.g. the webpages) |
+---------------+---------------------------------------------------------------------------------------------------------------+
Puppet
======
+--------------------+----------------------------------------------------------------------------------+
| ``puppet/zulip`` | For configuration for production deployments |
+--------------------+----------------------------------------------------------------------------------+
Templates
=========
+--------------------------+--------------------------------------------------------+
| ``templates/zerver`` | For templates related to zerver views |
+--------------------------+--------------------------------------------------------+
| ``static/templates`` | Handlebars templates for the frontend |
+--------------------------+--------------------------------------------------------+
Tests
=====
+-------------------------+-----------------------------------+
| ``zerver/tests/`` | Backend tests |
+-------------------------+-----------------------------------+
| ``frontend_tests/node`` | Node Frontend unit tests |
+-------------------------+-----------------------------------+
| ``frontend_tests/tests``| Casper frontend tests |
+-------------------------+-----------------------------------+
Documentation
=============
+-------------+-----------------------------------------------+
| ``docs/`` | Source for this documentation |
+-------------+-----------------------------------------------+
You can consult the repository's .gitattributes file to see exactly
which components are excluded from production releases (release
tarballs are generated using tools/build-release-tarball).

View File

@@ -0,0 +1,70 @@
# Static asset pipeline
This page documents additional information that may be useful when
developing new features for Zulip that require front-end changes. For a
more general overview, see the new-feature-tutorial. The code-style
documentation also has relevant information about how Zulip's code is
structured.
## Primary build process
Most of the existing JS in Zulip is written in IIFE-wrapped modules, one
per file in the static/js directory. When running Zulip in development
mode, each file is loaded seperately. In production mode (and when
creating a release tarball using tools/build-release-tarball),
JavaScript files are concatenated and minified.
If you add a new JavaScript file, it needs to be specified in the
JS\_SPECS dictionary defined in zproject/settings.py to be included in
the concatenated file.
## Webpack/CommonJS modules
New JS written for Zulip can be written as CommonJS modules (bundled
using [webpack](https://webpack.github.io/), though this will taken care
of automatically whenever `run-dev.py` is running). (CommonJS is the
same module format that Node uses, so see the [Node
documentation](https://nodejs.org/docs/latest/api/modules.html) for
more information on the syntax.)
Benefits of using CommonJS modules over the
[IIFE](http://benalman.com/news/2010/11/immediately-invoked-function-expression/)
module approach:
- namespacing/module boilerplate will be added automatically in the
bundling process
- dependencies between modules are more explicit and easier to trace
- no separate list of JS files needs to be maintained for
concatenation and minification
- third-party libraries can be more easily installed/versioned using
npm
- running the same code in the browser and in Node for testing is
simplified (as both environments use the same module syntax)
The entry point file for the bundle generated by webpack is
`static/js/src/main.js`. Any modules you add will need to be required
from this file (or one of its dependencies) in order to be included in
the script bundle.
## Adding static files
To add a static file to the app (JavaScript, CSS, images, etc), first
add it to the appropriate place under `static/`.
- Third-party files should all go in `static/third/`. Tag the commit
with "[third]" when adding or modifying a third-party package.
- Our own JS lives under `static/js`; CSS lives under `static/styles`.
- JavaScript and CSS files are combined and minified in production. In
this case all you need to do is add the filename to
PIPELINE['STYLESHEET'] or JS\_SPECS in `zproject/settings.py`. (If
you plan to only use the JS/CSS within the app proper, and not on
the login page or other standalone pages, put it in the 'app'
category.)
If you want to test minified files in development, look for the
`PIPELINE_ENABLED =` line in `zproject/settings.py` and set it to `True`
-- or just set `DEBUG = False`.
Note that `static/html/{400,5xx}.html` will only render properly if
minification is enabled, since they hardcode the path
`static/min/portico.css`.

View File

@@ -1,71 +0,0 @@
=======================
Front End Build Process
=======================
This page documents additional information that may be useful when developing new features for Zulip that require front-end changes. For a more general overview, see the new feature tutorial. The code style documentation also has relevant information about how Zulip's code is structured.
Primary build process
=====================
Most of the existing JS in Zulip is written in IIFE-wrapped modules,
one per file in the `static/js` directory. When running Zulip in
development mode, each file is loaded seperately. In production mode
(and when creating a release tarball using
`tools/build-release-tarball`), JavaScript files are concatenated and
minified.
If you add a new JavaScript file, it needs to be specified in the
`JS_SPECS` dictionary defined in `zproject/settings.py` to be included
in the concatenated file.
Webpack/CommonJS modules
========================
New JS written for Zulip can be written as CommonJS modules (bundled
using `webpack <https://webpack.github.io/>`_, though this will taken
care of automatically whenever ``run-dev.py`` is running). (CommonJS
is the same module format that Node uses, so see `the Node
documentation <https://nodejs.org/docs/latest/api/modules.html>` for
more information on the syntax.)
Benefits of using CommonJS modules over the `IIFE
<http://benalman.com/news/2010/11/immediately-invoked-function-expression/>`_
module approach:
* namespacing/module boilerplate will be added automatically in the bundling process
* dependencies between modules are more explicit and easier to trace
* no separate list of JS files needs to be maintained for concatenation and minification
* third-party libraries can be more easily installed/versioned using npm
* running the same code in the browser and in Node for testing is
simplified (as both environments use the same module syntax)
The entry point file for the bundle generated by webpack is
``static/js/src/main.js``. Any modules you add will need to be
required from this file (or one of its dependencies) in order to be
included in the script bundle.
Adding static files
===================
To add a static file to the app (JavaScript, CSS, images, etc), first
add it to the appropriate place under ``static/``.
* Third-party files should all go in ``static/third/``. Tag the commit
with "[third]" when adding or modifying a third-party package.
* Our own JS lives under ``static/js``; CSS lives under ``static/styles``.
* JavaScript and CSS files are combined and minified in production. In
this case all you need to do is add the filename to PIPELINE_CSS or
JS_SPECS in ``zproject/settings.py``. (If you plan to only use the
JS/CSS within the app proper, and not on the login page or other
standalone pages, put it in the 'app' category.)
If you want to test minified files in development, look for the
``PIPELINE =`` line in ``zproject/settings.py`` and set it to ``True`` -- or
just set ``DEBUG = False``.
Note that ``static/html/{400,5xx}.html`` will only render properly if
minification is enabled, since they hardcode the path
``static/min/portico.css``.

39
docs/full-text-search.md Normal file
View File

@@ -0,0 +1,39 @@
# Full-text search
Zulip supports full-text search, which can be combined arbitrarily
with Zulip's full suite of narrowing operators. By default, it only
supports English text, but there is an experimental
[PGroonga](http://pgroonga.github.io/) integration that provides
full-text search for all languages.
The user interface and feature set for Zulip's full-text search is
documented in the "Search help" documentation section in the Zulip
app's gear menu.
## The default full-text search implementation
Zulip's uses [PostgreSQL's built-in full-text search
feature](http://www.postgresql.org/docs/current/static/textsearch.html),
with a custom set of English stop words to improve the quality of the
search results.
We use a small extension,
[tsearch_extras](https://github.com/zulip/tsearch_extras), for
highlighting of the matching words. There is [some discussion of
removing this extension, at least as an
option](https://github.com/zulip/zulip/issues/467), so that Zulip can
be used with database-as-a-service platforms.
In order to optimize the performance of delivering messages, the
full-text search index is updated for newly sent messages in the
background, after the message has been delivered. This background
updating is done by
`puppet/zulip/files/postgresql/process_fts_updates`, which is usually
deployed on the database server, but could be deployed on an
application server instead.
## An optional full-text search implementation
See [the option PGroonga pull
request](https://github.com/zulip/zulip/pull/700) for details on the
status of the PGroonga integration.

72
docs/html_css.md Normal file
View File

@@ -0,0 +1,72 @@
# HTML and CSS
## Zulip CSS organization
The Zulip application's CSS can be found in the `static/styles/`
directory. Zulip uses [Bootstrap](http://getbootstrap.com/) as its
main third-party CSS library.
Zulip currently does not use any CSS preprocessors, and is organized
into several files. For most pages, the CSS is combined into a single
CSS file by the [static asset pipeline](front-end-build-process.html),
controlled by the `PIPELINE_CSS` code in `zproject/settings.py`.
The CSS files are:
* `portico.css` - Main CSS for logged-out pages
* `pygments.css` - CSS for Python syntax highlighting
* `activity.css` - CSS for the `activity` app
* `fonts.css` - Fonts for text in the Zulip app
* `static/styles/thirdparty-fonts.css` - Font Awesome (used for icons)
The CSS for the Zulip web application UI is primarily here:
* `settings.css` - CSS for the Zulip settings and administration pages
* `zulip.css` - CSS for the rest of the Zulip logged-in app
* `media.css` - CSS for media queries (particularly related to screen width)
We are in the process of [splitting zulip.css into several more
files](https://github.com/zulip/zulip/issues/731); help with that
project is very welcome!
## Editing Zulip CSS
If you aren't experienced with doing web development and want to make
CSS changes, we recommend reading the excellent [Chrome web inspector
guide on editing HTML/CSS](https://developer.chrome.com/devtools/docs/dom-and-styles),
especially the [section on
CSS](https://developer.chrome.com/devtools/docs/dom-and-styles#styles)
to learn about all the great tools that you can use to modify and test
changes to CSS interactively in-browser (without even having the
reload the page!).
## CSS Style guidelines
### Avoid duplicated code
Without care, it's easy for a web application to end up with thousands
of lines of duplicated CSS code, which can make it very difficult to
understand the current styling or modify it. We would very much like
to avoid such a fate. So please make an effort to reuse existing
styling, clean up now-unused CSS, etc., to keep things maintainable.
### Be consistent with existing similar UI
Ideally, do this by reusing existing CSS declarations, so that any
improvements we make to the styling can improve all similar UI
elements.
### Use clear, unique names for classes and object IDs
This makes it much easier to read the code and use `git grep` to find
where a particular class is used.
## Validating CSS
When changing any part of the Zulip CSS, it's important to check that
the new CSS looks good at a wide range of screen widths, from very
wide screen (e.g. 1920px) all the way down to narrow phone screens
(e.g. 480px).
For complex changes, it's definitely worth testing in a few different
browsers to make sure things look the same.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
from __future__ import print_function
# Remove HTML entity escaping left over from MediaWiki->rST conversion.

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Some files were not shown because too many files have changed in this diff Show More