diff --git a/api/zephyr_mirror.py b/api/zephyr_mirror.py index 63777e8ca1..60eb4e9689 100644 --- a/api/zephyr_mirror.py +++ b/api/zephyr_mirror.py @@ -66,8 +66,8 @@ def send_humbug(zeph): zeph["sender"] = compute_humbug_username(zeph["sender"]) zeph['fullname'] = username_to_fullname(zeph['sender']) zeph['shortname'] = zeph['sender'].split('@')[0] - if "instance" in zeph: - zeph["instance"] = zeph["instance"][:30] + if "subject" in zeph: + zeph["subject"] = zeph["subject"][:30] for key in zeph.keys(): if isinstance(zeph[key], unicode): @@ -157,7 +157,7 @@ def process_loop(log): 'time' : str(notice.time), 'sender' : sender, 'stream' : notice.cls.lower(), - 'instance' : notice.instance.lower(), + 'subject' : notice.instance.lower(), 'zsig' : zsig, # logged here but not used by app 'content' : body } @@ -224,7 +224,7 @@ def forward_to_zephyr(message): if message['type'] == "stream": zeph = zephyr.ZNotice(sender=message["sender_email"].replace("mit.edu", "ATHENA.MIT.EDU"), auth=True, cls=message["display_recipient"], - instance=message["instance"]) + instance=message["subject"]) body = "%s\0%s" % (zsig, wrapped_content) zeph.setmessage(body) zeph.send() diff --git a/templates/zephyr/home.html b/templates/zephyr/home.html index f54b9cb30b..c25fec3269 100644 --- a/templates/zephyr/home.html +++ b/templates/zephyr/home.html @@ -39,10 +39,10 @@ - + - - + + diff --git a/tools/jslint/check-all.js b/tools/jslint/check-all.js index 253ba20f95..88e27ac80e 100644 --- a/tools/jslint/check-all.js +++ b/tools/jslint/check-all.js @@ -22,7 +22,7 @@ var globals = // narrow.js + ' narrowed show_all_messages' - + ' narrow_all_personals narrow_by_recipient narrow_instance' + + ' narrow_all_personals narrow_by_recipient narrow_subject' // setup.js + ' loading_spinner templates' @@ -38,7 +38,7 @@ var globals = // zephyr.js + ' message_array message_dict' - + ' status_classes clear_table add_to_table instance_list' + + ' status_classes clear_table add_to_table subject_list' + ' keep_pointer_in_view move_pointer_at_page_top_and_bottom' + ' respond_to_message' + ' select_message select_message_by_id' diff --git a/tools/post-receive b/tools/post-receive index e89d47d235..61760a7ad8 100755 --- a/tools/post-receive +++ b/tools/post-receive @@ -45,7 +45,7 @@ def process_push(oldrev, newrev, refname): message_data = { "type": "stream", "stream": "test" if refname == "refs/heads/test-post-receive" else "devel", - "instance": "commits", + "subject": "commits", "content": "The following commits were just pushed to `%s`:\n\n" % (refname.replace("refs/heads/", ""),) + commits, "recipient": "tabbott@humbughq.com", diff --git a/zephyr/jstemplates/message.html b/zephyr/jstemplates/message.html index 2b46c29547..c272b51a35 100644 --- a/zephyr/jstemplates/message.html +++ b/zephyr/jstemplates/message.html @@ -25,9 +25,9 @@ class="message_label_clickable message_newstyle_stream" onclick="select_message_by_id({{id}}); narrow_stream();" title="{{display_recipient}}">{{display_recipient}} - {{instance}} + {{subject}} {{else}} diff --git a/zephyr/management/commands/populate_db.py b/zephyr/management/commands/populate_db.py index 1776f65b3b..70a40c82c0 100644 --- a/zephyr/management/commands/populate_db.py +++ b/zephyr/management/commands/populate_db.py @@ -238,7 +238,7 @@ def restore_saved_messages(): type_hash = {"stream": Recipient.STREAM, "huddle": Recipient.HUDDLE, "personal": Recipient.PERSONAL} message.type = type_hash[old_message["type"]] message.content = old_message["content"] - message.instance = old_message["instance"] + message.subject = old_message["subject"] message.pub_date = datetime.datetime.utcfromtimestamp(float(old_message["timestamp"])).replace(tzinfo=utc) if message.type == Recipient.PERSONAL: @@ -267,10 +267,10 @@ def restore_saved_messages(): # Create some test messages, including: # - multiple streams -# - multiple instances per stream +# - multiple subjects per stream # - multiple huddles # - multiple personals converastions -# - multiple messages per instance +# - multiple messages per subject # - both single and multi-line content def send_messages(data): (tot_messages, personals_pairs, options, output) = data @@ -310,7 +310,7 @@ def send_messages(data): personals_pair = saved_data random.shuffle(personals_pair) elif message_type == Recipient.STREAM: - message.instance = saved_data + message.subject = saved_data message.recipient = get_recipient_by_id(recipient_id) elif message_type == Recipient.HUDDLE: message.recipient = get_recipient_by_id(recipient_id) @@ -338,8 +338,8 @@ def send_messages(data): # Pick a random subscriber to the stream message.sender = random.choice(Subscription.objects.filter( recipient=message.recipient)).userprofile - message.instance = stream.name + str(random.randint(1, 3)) - saved_data = message.instance + message.subject = stream.name + str(random.randint(1, 3)) + saved_data = message.subject message.pub_date = datetime.datetime.utcnow().replace(tzinfo=utc) do_send_message(message) diff --git a/zephyr/models.py b/zephyr/models.py index 2ede1df535..b621797776 100644 --- a/zephyr/models.py +++ b/zephyr/models.py @@ -17,7 +17,7 @@ md_engine = markdown.Markdown( def get_display_recipient(recipient): """ - recipient: an instance of Recipient. + recipient: an subject of Recipient. returns: an appropriate string describing the recipient (the stream name, for a stream, or the email, for a user). @@ -36,7 +36,7 @@ def get_display_recipient(recipient): def get_log_recipient(recipient): """ - recipient: an instance of Recipient. + recipient: an subject of Recipient. returns: an appropriate string describing the recipient (the stream name, for a stream, or the email, for a user). @@ -197,13 +197,13 @@ class Recipient(models.Model): class Message(models.Model): sender = models.ForeignKey(UserProfile) recipient = models.ForeignKey(Recipient) - instance = models.CharField(max_length=30) + subject = models.CharField(max_length=30) content = models.TextField() pub_date = models.DateTimeField('date published') def __repr__(self): display_recipient = get_display_recipient(self.recipient) - return "" % (display_recipient, self.instance, self.sender) + return "" % (display_recipient, self.subject, self.sender) def __str__(self): return self.__repr__() @@ -234,7 +234,7 @@ class Message(models.Model): 'type' : self.recipient.type_name(), 'display_recipient': get_display_recipient(self.recipient), 'recipient_id' : self.recipient.id, - 'instance' : self.instance, + 'subject' : self.subject, 'content' : content, 'timestamp' : calendar.timegm(self.pub_date.timetuple()), 'gravatar_hash' : hashlib.md5(self.sender.user.email.lower()).hexdigest(), @@ -247,7 +247,7 @@ class Message(models.Model): 'sender_short_name': self.sender.full_name, 'type' : self.recipient.type_name(), 'recipient' : get_log_recipient(self.recipient), - 'instance' : self.instance, + 'subject' : self.subject, 'content' : self.content, 'timestamp' : self.pub_date.strftime("%s"), } diff --git a/zephyr/static/js/compose.js b/zephyr/static/js/compose.js index 98eb9578a9..b4bcac8999 100644 --- a/zephyr/static/js/compose.js +++ b/zephyr/static/js/compose.js @@ -46,8 +46,8 @@ function compose_stream_name() { return $.trim($("#stream").val()); } -function compose_instance() { - return $.trim($("#instance").val()); +function compose_subject() { + return $.trim($("#subject").val()); } function compose_message() { @@ -112,8 +112,8 @@ function validate_stream_message() { return false; } - if (compose_instance() === "") { - compose_error("Please specify an instance", $("#instance")); + if (compose_subject() === "") { + compose_error("Please specify an subject", $("#subject")); return false; } diff --git a/zephyr/static/js/hotkey.js b/zephyr/static/js/hotkey.js index 7d372baa7f..bc2840ea5d 100644 --- a/zephyr/static/js/hotkey.js +++ b/zephyr/static/js/hotkey.js @@ -100,7 +100,7 @@ var keydown_handler = process_hotkey; var goto_hotkeys = { 99: narrow_by_recipient, // 'c' - 105: narrow_instance, // 'i' + 105: narrow_subject, // 'i' 112: narrow_all_personals, // 'p' 97: show_all_messages, // 'a' 27: hide_compose // Esc diff --git a/zephyr/static/js/narrow.js b/zephyr/static/js/narrow.js index db703856b9..44bec8e241 100644 --- a/zephyr/static/js/narrow.js +++ b/zephyr/static/js/narrow.js @@ -67,16 +67,16 @@ function narrow_stream() { }); } -function narrow_instance() { +function narrow_subject() { var original = message_dict[selected_message_id]; if (original.type !== 'stream') return; - var message = original.display_recipient + " | " + original.instance; + var message = original.display_recipient + " | " + original.subject; do_narrow(message, function (other) { return (other.type === 'stream' && original.recipient_id === other.recipient_id && - original.instance === other.instance); + original.subject === other.subject); }); } diff --git a/zephyr/static/js/ui.js b/zephyr/static/js/ui.js index 31823f291b..bc94d0a1c7 100644 --- a/zephyr/static/js/ui.js +++ b/zephyr/static/js/ui.js @@ -75,7 +75,7 @@ var autocomplete_needs_update = false; function update_autocomplete() { stream_list.sort(); - instance_list.sort(); + subject_list.sort(); people_list.sort(); // limit number of items so the list doesn't fall off the screen @@ -83,8 +83,8 @@ function update_autocomplete() { source: stream_list, items: 3 }); - $( "#instance" ).typeahead({ - source: instance_list, + $( "#subject" ).typeahead({ + source: subject_list, items: 2 }); $( "#huddle_recipient" ).typeahead({ diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index 5c54548a4d..b10d60c576 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -1,6 +1,6 @@ var message_array = []; var message_dict = {}; -var instance_list = []; +var subject_list = []; $(function () { var i; @@ -118,10 +118,10 @@ function respond_to_message(reply_type) { message = message_dict[selected_message_id]; if (message.type === "stream") { $("#stream").val(message.display_recipient); - $("#instance").val(message.instance); + $("#subject").val(message.subject); } else { $("#stream").val(""); - $("#instance").val(""); + $("#subject").val(""); } $("#huddle_recipient").val(message.reply_to); if (reply_type === "personal" && message.type === "huddle") { @@ -209,7 +209,7 @@ function same_recipient(a, b) { return a.reply_to === b.reply_to; case 'stream': return (a.recipient_id === b.recipient_id) && - (a.instance === b.instance); + (a.subject === b.subject); } // should never get here @@ -266,8 +266,8 @@ function add_to_table(messages, table_name, filter_function, where) { // messages, in order to collapse properly. // // This means we redraw the entire view on each update when narrowed by - // instance, which could be a problem down the line. For now we hope - // that instance views will not be very big. + // subject, which could be a problem down the line. For now we hope + // that subject views will not be very big. var top_group = message_groups[table_name][0]; var top_messages = []; @@ -366,8 +366,8 @@ function add_message_metadata(dummy, message) { switch (message.type) { case 'stream': message.is_stream = true; - if ($.inArray(message.instance, instance_list) === -1) { - instance_list.push(message.instance); + if ($.inArray(message.subject, subject_list) === -1) { + subject_list.push(message.subject); autocomplete_needs_update = true; } message.reply_to = message.sender_email; diff --git a/zephyr/static/styles/zephyr.css b/zephyr/static/styles/zephyr.css index ac403997dd..bcff99592b 100644 --- a/zephyr/static/styles/zephyr.css +++ b/zephyr/static/styles/zephyr.css @@ -59,7 +59,7 @@ td.pointer { .ztable_col2 { /* pointer */ width: 2px; } -.ztable_col3 { /* instancename */ +.ztable_col3 { /* subjectname */ width: 85%; } @@ -75,7 +75,7 @@ td.pointer { border: 1px solid grey; } -.message_newstyle_instance { +.message_newstyle_subject { vertical-align: middle; text-align: left; overflow-x: hidden; diff --git a/zephyr/tests.py b/zephyr/tests.py index cbdf31837f..0584d629e1 100644 --- a/zephyr/tests.py +++ b/zephyr/tests.py @@ -56,7 +56,7 @@ class AuthedTestCase(TestCase): recipient = Stream.objects.get(name=recipient_name, realm=sender.realm) recipient = Recipient.objects.get(type_id=recipient.id, type=message_type) pub_date = datetime.datetime.utcnow().replace(tzinfo=utc) - do_send_message(Message(sender=sender, recipient=recipient, instance="test", pub_date=pub_date), + do_send_message(Message(sender=sender, recipient=recipient, subject="test", pub_date=pub_date), synced_from_mit=True) def users_subscribed_to_stream(self, stream_name, realm_domain): @@ -319,7 +319,7 @@ class MessagePOSTTest(AuthedTestCase): result = self.client.post("/send_message/", {"type": "stream", "stream": "Verona", "content": "Test message", - "instance": "Test instance"}) + "subject": "Test subject"}) self.assert_json_success(result) def test_message_to_nonexistent_stream(self): @@ -332,7 +332,7 @@ class MessagePOSTTest(AuthedTestCase): result = self.client.post("/send_message/", {"type": "stream", "stream": "nonexistent_stream", "content": "Test message", - "instance": "Test instance"}) + "subject": "Test subject"}) self.assert_json_success(result) self.assertTrue(Stream.objects.filter(name="nonexistent_stream")) diff --git a/zephyr/views.py b/zephyr/views.py index dbf00e6ffb..a60bcdb0c3 100644 --- a/zephyr/views.py +++ b/zephyr/views.py @@ -357,16 +357,16 @@ def send_message_backend(request, user_profile, sender): if message_type_name == 'stream': if "stream" not in request.POST: return json_error("Missing stream") - if "instance" not in request.POST: - return json_error("Missing instance") + if "subject" not in request.POST: + return json_error("Missing subject") stream_name = strip_html(request.POST['stream']).strip() - instance_name = strip_html(request.POST['instance']).strip() + subject_name = strip_html(request.POST['subject']).strip() if not valid_stream_name(stream_name): return json_error("Invalid stream name") ## FIXME: Commented out temporarily while we figure out what we want - # if not valid_stream_name(instance_name): - # return json_error("Invalid instance name") + # if not valid_stream_name(subject_name): + # return json_error("Invalid subject name") stream = create_stream_if_needed(user_profile.realm, stream_name) recipient = Recipient.objects.get(type_id=stream.id, type=Recipient.STREAM) @@ -409,7 +409,7 @@ def send_message_backend(request, user_profile, sender): message.content = strip_html(request.POST['content']) message.recipient = recipient if message_type_name == 'stream': - message.instance = instance_name + message.subject = subject_name if 'time' in request.POST: # Forged messages come with a timestamp message.pub_date = datetime.datetime.utcfromtimestamp(float(request.POST['time'])).replace(tzinfo=utc)