Commit Graph

304 Commits

Author SHA1 Message Date
Tim Abbott 7c8bde5d90 Add log/restore for fullnames and passwords.
(imported from commit 048ca3c86b9f077fcbccd5df4a509191a545da4c)
2012-10-25 15:52:26 -04:00
Keegan McAllister eef027560a Remove unused imports
(imported from commit eb576627ff72e57fee0e3a4c357f51ad74cd6c86)
2012-10-25 15:22:18 -04:00
Tim Abbott 8c4a834206 Add function for activating MIT users.
(imported from commit 0de45fc341249332909d5a0ecef4d49918658a1a)
2012-10-25 14:46:58 -04:00
Tim Abbott 722249a9fc Use a variable for repeatedly referencing old_message['type'].
(imported from commit 1b8e8fef61582dab06ffbb9a9b71c83c2629f0f2)
2012-10-25 14:46:43 -04:00
Tim Abbott 6e1ec1a2ec Move our various bots into api/bots/.
(imported from commit f5803441b9b84872b942dff8e1c0ad1100788bcd)
2012-10-25 13:53:34 -04:00
Tim Abbott f1e4a27106 Optimize populate_db's common code for setting up real users.
(imported from commit 074b30ac88101f8e00ddcb60b5b05defc0a11998)
2012-10-23 17:52:10 -04:00
Tim Abbott 1b67b6b711 Don't deliver messages to "fake" Zephyr users created by populate_db.
(imported from commit c88760a88382ffc07cf5f79f3093a2bfec429d53)
2012-10-23 17:52:10 -04:00
Tim Abbott a9667d81a8 Fix performance regression caused by last commit.
(imported from commit f0abf93dbab92c5627903284fafad310de039fe6)
2012-10-22 22:01:55 -04:00
Tim Abbott 8c16295301 populate_db: Fix replaying personal messages from logs.
(imported from commit 685a426fe59fa240c8ae5cf357a43d4df0a3f05d)
2012-10-22 21:36:32 -04:00
Tim Abbott 846469c39c [schema]: Rename userprofile to user_profile.
(imported from commit adfb6152b7ec32557e3465d961695eb870506d5a)
2012-10-22 18:55:45 -04:00
Zev Benjamin 732ca19729 Synchronize the pointer across sessions
The client may now optionally send its current pointer during
get_updates and the server will return the latest pointer if it
differs and was updated more recently by a different session.

(imported from commit e43b377d7dfb52f83cefb0b1003863d5407caf80)
2012-10-22 16:44:57 -04:00
Tim Abbott a695732bda Seed the populate_db random number generator.
This makes it not to produce 10 copies of each message.

(imported from commit 35ab5f14ec104b4ea52137dac4fa2840194f3777)
2012-10-22 13:59:46 -04:00
Tim Abbott d3a693080e Fix receiving messages on the ShakeSpeare streams.
(imported from commit 4ce60d57e66363da1bd3c2b93fcf008eee795769)
2012-10-20 19:54:29 -04:00
Tim Abbott dab25bdff7 populate_db: Be a little more defensive about message types.
(imported from commit fe23365180847065a9a3292f7873dcb36bb277db)
2012-10-20 19:48:05 -04:00
Tim Abbott 55d9c08c83 populate_db: Fix case bugs importing old messages.
(imported from commit dba8e3419f5827344a42f28c31798fdaff7cf002)
2012-10-20 19:43:06 -04:00
Tim Abbott dcfef6b1a9 Fix restored personals going to the wrong user.
(imported from commit 362c9f3d833c96a5f3530138a0e9360bff183cbf)
2012-10-20 19:20:48 -04:00
Tim Abbott 7b3b4362dd [schema] Add a Client model keeping track of the sending client.
(imported from commit 31a430b1de14ce973addafd5d13ace049a8f8091)
2012-10-20 18:41:54 -04:00
Tim Abbott 2c89103b23 Actually update current subscriptions based on changes in logs.
(imported from commit b36637562dd0e358f1718d38778c735bb75fd77a)
2012-10-20 18:41:51 -04:00
Tim Abbott 56dab6cb26 Log changes to subscriptions and replay them in populate_db.
(imported from commit d3055eb44326bdc59a6bc96d00b5b0bc6da86059)
2012-10-20 18:26:21 -04:00
Tim Abbott d68cf3696b populate_db replay: Use bulk_create to create objects.
This cuts the time required to import 38000 messages (with 140000
message receipts) from about 10 minutes to just under 40 seconds on my
laptop with sqlite.

(imported from commit d53b0d1360408c77f38353b58fbb25875262cb40)
2012-10-20 18:26:18 -04:00
Tim Abbott b2ce9aaa18 populate_db replay: Parse the json from old messages first.
(imported from commit bdd900b7618ce85d27eebe4d2a745c4d2734cb85)
2012-10-20 10:44:50 -04:00
Tim Abbott e434fa141e Use .objects.create and .objects.get_or_create.
This eliminates a bunch of unnecessary code and also fixes a bunch of
places where we were improperly not using transactions.

(imported from commit f194ae9226f9229fc56a0b1b21615534f486ea0c)
2012-10-19 17:42:14 -04:00
Keegan McAllister bbb67f61cc populate_db: Indicate progress on --replay-old-messages
(imported from commit 1f1043bca0952650c744d6012b11d607f2eb3cde)
2012-10-19 15:17:34 -04:00
Keegan McAllister b9e9938197 create_user_if_needed: Use proper initial passwords
(imported from commit 009208ac64548dd6f8773ccc7738ab0c391d816a)
2012-10-17 21:08:59 -04:00
Keegan McAllister ea916951f4 Disable notify_new_message calls in testing and populate_db
(imported from commit 07a0fea4173e2e27a90ac5f111927f0000377764)
2012-10-17 18:23:01 -04:00
Keegan McAllister a545876d56 Rename notify_waiting_clients -> notify_new_message
We might have other URLs for other notifications.

(imported from commit 4c1c5fe2f039816fef4c268f34692ca4f19d81e8)
2012-10-17 18:23:01 -04:00
Keegan McAllister b2103e61ef print_initial_password: Print API keys too
(imported from commit b4fccc2947cb2c2d9e5f732c6e151bc12f091683)
2012-10-17 18:23:01 -04:00
Keegan McAllister 8a1ba0d720 Add a management command to print the initial password for an account
(imported from commit 0a2b7d8215961801dbd24d9af89785e857b9ba14)
2012-10-17 18:23:01 -04:00
Keegan McAllister cc8a14fcf8 Create accounts with passwords which are deterministic but hard to guess (from the outside)
(imported from commit 964610fec6c4690c1e881f2bab252296663c819a)
2012-10-17 18:23:01 -04:00
Keegan McAllister 5e70b5a291 Split off the Tornado code into a separate process
(imported from commit 95dbd0f438cdba06d6e6c6c539a2a3d49c577cfd)
2012-10-17 18:23:01 -04:00
Tim Abbott 3e994c16b7 Rename/reorganize our urls to be more consistent.
(imported from commit ca3cc7ccd5d7da83a9c60968527378ee1118648e)
2012-10-16 15:56:06 -04:00
Tim Abbott 2de4d1d448 Add social and test to default subs added after DB dumps.
(imported from commit 828c733c9f5d1bdd5fc0aa2e162b800f8db7b22f)
2012-10-11 11:53:57 -04:00
Tim Abbott ac3f4393ff Rename instance to subject.
(imported from commit 6b4693da03f106448c137cf81cf9801cac44f2b8)
2012-10-10 18:01:39 -04:00
Tim Abbott 613010675c Rename class => stream in populate_db.py.
(imported from commit 8546b2e7823f8df0f69b317bb3c6df1a4da49537)
2012-10-10 17:48:17 -04:00
Tim Abbott 44e9e4cebf Rename Recipient.CLASS to Recipient.STREAM.
(imported from commit a530194163f7260c73921137fa1ff671f14516f6)
2012-10-10 17:47:13 -04:00
Tim Abbott 1fc4780a81 Rename create_class_if_needed to create_stream_if_needed.
(imported from commit 1bbc792332981723d3d29b24ad03811d62ced5f1)
2012-10-10 17:47:13 -04:00
Tim Abbott bc3646691d Rename create_classes to create_streams.
(imported from commit 5c2e1f840e4774d392554a4c4cf49746f10550a9)
2012-10-10 17:47:12 -04:00
Tim Abbott 95f95d7e54 klass => model as a local variable to refer to our models.
(imported from commit c58a3133bfd8db13d34f8def4cf73e7526214e8e)
2012-10-10 17:47:12 -04:00
Tim Abbott 8daff2e05e Rename ZephyrClass to Stream.
(imported from commit ae51b7a9e03f322dfe2dfccd250cbfc23adfe32e)
2012-10-10 17:47:12 -04:00
Tim Abbott 2170c7a352 Rename zephyrs to messages in various local variables.
(imported from commit 91ac7e47c51fdcaf6559b06f07e36b041aad3e2c)
2012-10-10 10:29:48 -04:00
Keegan McAllister e1113a6d08 populate_db: Fix mit_subs_list import
(imported from commit b67abb47892d561b9e300a324528303694bcf8de)
2012-10-06 17:53:05 -04:00
Tim Abbott 9cfa8a868f populate_db: Read from the correct messages log path.
(imported from commit ec7ef103ddf06cdc89c02659ceefcab1f64c89e4)
2012-10-05 14:59:23 -04:00
Tim Abbott 52a36945fe populated_db: Rename many functions/variables from zephyr => message.
(imported from commit d796561eded00511e4dfd7fe2bd5ac102125d4ea)
2012-10-03 18:14:15 -04:00
Tim Abbott 1ab81cff92 [schema] Rename Zephyr => Message in the schema.
(imported from commit 4f402f150c45d2097d6b16943935e6e370b4f8d8)
2012-10-03 18:14:15 -04:00
Tim Abbott 83ceba0a2d Remove old /api/get_updates view.
(imported from commit 5a33a61bfb4b3aa40e28c356f5b4048db775b901)
2012-10-03 16:58:31 -04:00
Tim Abbott cca5f7b76a Rename do_send_zephyr to do_send_message.
(imported from commit df4dc741bf00a197ca5ab39373bc9a3eda379684)
2012-10-03 12:27:34 -04:00
Tim Abbott be1a890a09 populate_db: Restore users' pointers to last after database resets.
(imported from commit d6c5a58173602e7e07b6851a6d22ed129b4f3733)
2012-10-02 16:58:13 -04:00
Tim Abbott 5a5b5de650 Rename /api/v1/get_updates to /api/v1/get_messages.
(imported from commit f856637158cf9fda64ba333b532a5941de8fcbab)
2012-10-02 16:29:34 -04:00
Tim Abbott 18a3888373 [schema] Add an API for sending/receiving messages.
(imported from commit 209d525dc5892fc4c392a8ced1588c838cbb17c4)
2012-10-02 15:49:25 -04:00
Keegan McAllister 4e6a239580 populate_db: Default to mit.edu realm on inport
This is something of a temporary hack.  In the future, we should make
zephyr_mirror.py smarter about fixing up the realms.

(imported from commit bdcff1a834904616538f430b4513ec7619b95e95)
2012-09-28 18:35:38 -04:00
Tim Abbott b43dd303b6 Use tornado for new /api/get_updates query.
(imported from commit 84b85fc5bb0de4144fde00ea13d14f74b1dd9bd1)
2012-09-27 17:37:05 -04:00
Keegan McAllister 20240d869c Rename get_updates_longpoll to get_updates
(imported from commit 15635904584b324bdfa1414caea12c3bc4ce54c8)
2012-09-27 15:46:36 -04:00
Tim Abbott 699e05383f Log messages and restore them with populate_db.
(imported from commit 959f038a736e48d32819bc04bd054632a2e911c6)
2012-09-27 15:01:30 -04:00
Tim Abbott 2f4a96e18d Use better random generation of shakespeare lines.
(imported from commit f979a8476f6fd925b9041e15dd38a9c261341be9)
2012-09-27 15:01:30 -04:00
Tim Abbott c8220ee057 Don't store the post-markdown HTML in our database content column.
(imported from commit bb81e84acc04ea0930be1026149618fbb60174fd)
2012-09-26 14:51:14 -04:00
Tim Abbott 11e5e8785d Preparation for syncing messages back to MIT.
(imported from commit 551b697366702de93579de259a9bc644be8d66ec)
2012-09-24 14:31:40 -04:00
Tim Abbott a8e83040e5 Add support for specifying per-user MIT subscription lists.
(imported from commit d6e91917c071e59b5611bfefe326ac47684299c3)
2012-09-24 10:51:49 -04:00
Tim Abbott efd2cb8fa9 Add both Humbug and MIT internal users.
(imported from commit f300c6513a9756417285ba371cb2d3f6f26fc4a3)
2012-09-21 11:15:19 -04:00
Tim Abbott 2d6683f896 Deduplicate user creation code.
(imported from commit bda76a9a44bd5ed7f0726b527fdb93cec109cbed)
2012-09-21 10:45:00 -04:00
Tim Abbott 135c82717d Authenticate by email.
Approach from http://www.micahcarrick.com/django-email-authentication.html.

(imported from commit 796b8e08d8e1f9769cd3cf8ee61d3724ac3847b7)
2012-09-21 10:34:48 -04:00
Tim Abbott 967dc37bc2 Put the Shakespeare users in a different realm from the MIT ones.
(imported from commit c75bff78380ee85c00edb4690030b6e0c1b42360)
2012-09-20 18:03:43 -04:00
Keegan McAllister 209bfdf16a populate_db: style fixes
(imported from commit bf16e9a745407a95917e4765257c54dd342fcacc)
2012-09-20 11:22:39 -04:00
Keegan McAllister 16b53fc1ef populate_db: Provide option to create extra users
(imported from commit 13d24c2af3911a06138e73619aa6091a9aeb4f1a)
2012-09-20 10:47:25 -04:00
Keegan McAllister db7a8277ff Replace create_{user_profile,zephyr_class} with {UserProfile,ZephyrClass}.create
Looks nicer and cuts down on imports.

(imported from commit 4fdbbb45cf6d8ad016481c663cf52fd555b41d91)
2012-09-19 13:01:58 -04:00
Keegan McAllister c887a5f977 Debug Tornado when Django DEBUG = True
(imported from commit ebd81e5d9344f5fb09c59a2afcaf83e9b1fc2a1d)
2012-09-18 13:45:52 -04:00
Keegan McAllister f003dddebb populate_db: Remove unused variables
(imported from commit 3f8f40134858721b372f3971c3b7ced31f9ed49e)
2012-09-17 21:55:38 -04:00
Keegan McAllister bdb1c1b97e populate_db: Break up a long line
(imported from commit cb9d1a785751af6115cbbffc4f21bc09d38cc0fa)
2012-09-17 21:39:21 -04:00
Keegan McAllister 7152fe2f73 Format messages with Markdown
(imported from commit 014a4dddd4d3db61d85c6f6bf1987aff6093fb52)
2012-09-17 15:24:41 -04:00
Tim Abbott da2494004d Make populate_db thread count an option.
(imported from commit b65de0a25a7c345a422e8f4f236bf49025c97886)
2012-09-17 11:37:14 -04:00
Tim Abbott 0b699be7eb Add some caching of userprofile objects.
(imported from commit dd8e1bec2d677e873d90806aa71519c3a37221c8)
2012-09-17 11:37:11 -04:00
Tim Abbott 2fb626c106 Fix running populate_db more than once in a row.
(imported from commit 72a59b8e6a8cedeb5ca7d242fdfd40fb3f691bc3)
2012-09-14 16:25:11 -04:00
Tim Abbott 09b1285ac1 populate_db: Create the new zephyrs in parallel.
(imported from commit e550d4f6c68502ca27a3dbdc99a495a1c4e710ac)
2012-09-14 13:32:26 -04:00
Tim Abbott 4cc2a7ef60 Restructure populate_db to use more functions.
(imported from commit a2757292c6e2ea33433ebf2028c3322c00b03a2f)
2012-09-14 13:32:25 -04:00
Keegan McAllister 054c30a6db Move MIT Zephyr subs list into its own file
(imported from commit 260ed986c1d69c141e42bea4803ebe0396a86715)
2012-09-12 20:30:07 -04:00
Jessica McKellar e60959ab64 populate_db: give users full names.
(imported from commit db78a76d983dab077dfb105431e549b46e4c60d8)
2012-09-11 16:35:00 -04:00
Tim Abbott a983276b16 Add support for populate_db adding to the existing messages.
(imported from commit 765243923c67ff4820b4cd873764a5e8172cf177)
2012-09-11 10:50:48 -04:00
Tim Abbott 37b1c1db11 Stop using foo.pk when we mean foo.id.
(imported from commit b86359254415f65b32eeefdfbcb38d7bb862c1ac)
2012-09-10 13:43:17 -04:00
Tim Abbott ca132789bb [schema] Store Recipient types more efficiently.
(imported from commit e0625ce9d2382682a5c8d53a5ac31a0399075df8)
2012-09-10 10:03:50 -04:00
Keegan McAllister 7d51dfc0a7 Remove dead function in runtornado.py
The code is buggy; the variable 'escape' is undefined.  Right now we aren't
using this code because we bypass Tornado for login.

(imported from commit 91cf6e8fc9477039c8847c7e9501d645993278b8)
2012-09-07 13:57:32 -04:00
Keegan McAllister f837ec66e8 Remove more dead code/variables in runtornado.py
(imported from commit 0d754ca1f9ce8bc53db878d6165354149016bea5)
2012-09-07 13:57:32 -04:00
Keegan McAllister ffb69ad1c8 Fix (?) logging in runtornado.py
(imported from commit d5158005abebe496959989acaa69db269126e502)
2012-09-07 13:57:32 -04:00
Keegan McAllister 80c6d09197 Remove unused imports
(imported from commit 9f5c226708e44935e8d32c18ea7dd1ad2615d8d5)
2012-09-07 13:57:32 -04:00
Tim Abbott d8ade6de5b Add create_zephyr_class helper.
(imported from commit 993fbb799b706e402ae212330e4abbe28bf84ee9)
2012-09-07 13:28:56 -04:00
Tim Abbott 6ed513f4da Update populate_db to add our user accounts.
(imported from commit 24d209c995bf9353652b376fff5d58ae5de07b5a)
2012-09-07 12:50:22 -04:00
Tim Abbott 1e42dc5728 Clear UserMessage table in populate_db as well.
(imported from commit 6d1c9b7a9974373857724ddd7b8d7805ed99c784)
2012-09-07 11:54:04 -04:00
Tim Abbott cc3b90b5a2 Fix some testing problems with new UserMessage class.
(imported from commit abcadca84e6ad21c523f339952ad0dec0868dc50)
2012-09-07 11:30:28 -04:00
Tim Abbott ef25dffb92 [schema] Add the realm to the ZepyhrClass objects.
(imported from commit 8189ef27f2feef0c92f9c06a9243c085e36a66f5)
2012-09-06 11:02:34 -04:00
Tim Abbott b761bf030b [schema] Fix names of fields in Subscription.
(imported from commit 5f5c643286d348d16caac03419ba3011a8b81eff)
2012-09-06 11:02:34 -04:00
Tim Abbott 38b30e5997 [schema] Add realms to the schema.
Note that realms aren't actually used for anything, aren't prompted
for, etc, so this is mostly just a schema change and the refactoring
needed to allow setting the realm in the future.

(imported from commit b8b483dcc9601b288702284879e9c99707a50a5c)
2012-09-06 11:02:34 -04:00
Keegan McAllister 2332fa2c72 Log server events with timestamps
(imported from commit b74274ccafcca716871058b8f9bde8dfe9e081ee)
2012-09-05 13:47:25 -04:00
Tim Abbott 3218f917ae populate_db: Repeat recipients a moderate fraction of the time.
(imported from commit 1a42ec5b585a7a64e24576350c61399601177877)
2012-09-05 13:42:05 -04:00
Tim Abbott 527058a202 Add personals and huddles to populate_db.
(imported from commit 98a8decc18bad4700260f125873ccc4367f73ebe)
2012-09-05 12:38:35 -04:00
Tim Abbott 20215eef86 Remove a bunch more trailing whitespace.
(imported from commit 5d1cc8dcb0b26eaf95ddca26574b361b6948cdb8)
2012-09-05 11:23:58 -04:00
Tim Abbott 8f058937a0 Rename recipient.user_or_class to type.id.
(imported from commit 74639cd08d0f53ae39624fc793f6fe55325b6d45)
2012-09-04 16:34:39 -04:00
Jessica McKellar ee9da75f0f Give populate_db an optional number of zephyrs to generate.
(imported from commit ceebabf7d56ceb3bba00129dc9f334c72a4956da)
2012-09-04 14:28:47 -04:00
Jessica McKellar 15516b52dc Auto-sub to personals on account creation.
(imported from commit 5b8b5b0c670bdd4c9663837a15dd80bcbc6ddcb1)
2012-08-31 10:58:09 -04:00
Jessica McKellar 172c3f0c81 Use named parameters to condense some of the new ORM object creation code.
(imported from commit e172f24956f67fe1f68ff288244b67918eb91acf)
2012-08-30 17:17:59 -04:00
Tim Abbott 9afd63692f Implement long polling using Tornado.
(imported from commit 4385304b27d7fe55a57a23133cd214fe8fc33482)
2012-08-30 14:29:34 -04:00
Jessica McKellar a7c61d5568 Add subscriptions to the test data.
(imported from commit 9332af496358b90e2a982e77017c9e8beef90d21)
2012-08-29 12:57:26 -04:00
Jessica McKellar 36cc0219d5 Make timestamps on zephyrs timezone-aware.
This will avoid Daylight Saving Time issues and resolves a Django
warning about using naive datetime objects ("RuntimeWarning:
DateTimeField received a naive datetime").

This adds a dependency on python-tz.

https://docs.djangoproject.com/en/dev/topics/i18n/timezones/

(imported from commit 10e432a67e2bcd014a0cedf4423a162609873825)
2012-08-28 17:08:38 -04:00
Jessica McKellar 7b40df9e8b Also clear the Recipient table before populating the test database.
(imported from commit e87baf72a40f3c22a6710ce2d05881673fa052d7)
2012-08-28 16:57:45 -04:00
Jessica McKellar 5dd9616f51 Add a 'clear_db' management command to drop our tables (zephyr + sessions).
(imported from commit 5763983689448944bed13feeeae9a482908a7aff)
2012-08-28 16:56:32 -04:00
Jessica McKellar 2b9a3205be Switch zephyrs to the notion of a "Recipient", which is either a class or user.
(imported from commit edc46267dab9cc972358b6020ca28b009e15d8c5)
2012-08-28 16:34:23 -04:00
Jessica McKellar 342b2a13ac Add a management command to populate the database.
It will drop the relevant account and zephyr tables and populate them
with canned data. Run the command with:

python manage.py populate_db

(imported from commit 69ddea0a405c3a34c83cbae2f65373e12142c9fb)
2012-08-28 12:45:10 -04:00