Rename instance to subject.

(imported from commit 6b4693da03f106448c137cf81cf9801cac44f2b8)
This commit is contained in:
Tim Abbott 2012-10-10 18:01:39 -04:00
parent 8dca315a18
commit ac3f4393ff
15 changed files with 55 additions and 55 deletions

View File

@ -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()

View File

@ -39,10 +39,10 @@
</tr>
<tr id="stream-message">
<td colspan="2" class="message_newstyle_stream">
<input type="text" class="recipient_box" name="stream" id="stream" onchange="focus_on('instance')" value="" placeholder="Stream" autocomplete="off"/>
<input type="text" class="recipient_box" name="stream" id="stream" onchange="focus_on('subject')" value="" placeholder="Stream" autocomplete="off"/>
</td>
<td class="message_newstyle_instance">
<input type="text" class="recipient_box" name="instance" id="instance" onchange="focus_on('new_message_content')" value="" placeholder="Subject" autocomplete="off"/>
<td class="message_newstyle_subject">
<input type="text" class="recipient_box" name="subject" id="subject" onchange="focus_on('new_message_content')" value="" placeholder="Subject" autocomplete="off"/>
</td>
</tr>
<tr id="personal-message">

View File

@ -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'

View File

@ -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",

View File

@ -25,9 +25,9 @@
class="message_label_clickable message_newstyle_stream"
onclick="select_message_by_id({{id}}); narrow_stream();"
title="{{display_recipient}}">{{display_recipient}}</td>
<td class="message_label_clickable message_newstyle_instance"
onclick="select_message_by_id({{id}}); narrow_instance();"
title="{{instance}}">{{instance}}</td>
<td class="message_label_clickable message_newstyle_subject"
onclick="select_message_by_id({{id}}); narrow_subject();"
title="{{subject}}">{{subject}}</td>
</tr>
{{else}}
<tr class="recipient_row">

View File

@ -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)

View File

@ -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 "<Message: %s / %s / %r>" % (display_recipient, self.instance, self.sender)
return "<Message: %s / %s / %r>" % (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"),
}

View File

@ -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;
}

View File

@ -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

View File

@ -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);
});
}

View File

@ -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({

View File

@ -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;

View File

@ -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;

View File

@ -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"))

View File

@ -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)