Change send_message to accept a stream, not a class.

(imported from commit 0f58de2502bec227f5f33e44692d03f2f28d6f63)
This commit is contained in:
Tim Abbott 2012-10-10 17:09:16 -04:00
parent 6dc913766d
commit 08e832e093
8 changed files with 16 additions and 16 deletions

View File

@ -156,7 +156,7 @@ def process_loop(log):
zeph = { 'type' : 'stream',
'time' : str(notice.time),
'sender' : sender,
'class' : notice.cls.lower(),
'stream' : notice.cls.lower(),
'instance' : notice.instance.lower(),
'zsig' : zsig, # logged here but not used by app
'content' : body }

View File

@ -28,7 +28,7 @@
<div class="close composebox-close" onclick="hide_compose()">&times;</div>
<div class="message_comp">
<form action="/send_message/" method="post" class="zephyr">
<input type="hidden" name="type" value="class" id="new_message_type"/>
<input type="hidden" name="type" value="stream" id="new_message_type"/>
{% csrf_token %}
<table class="compose_table">
<tbody>
@ -39,7 +39,7 @@
</tr>
<tr id="class-message">
<td colspan="2" class="message_newstyle_class">
<input type="text" class="recipient_box" name="class" id="class" onchange="focus_on('instance')" value="" placeholder="Stream" autocomplete="off"/>
<input type="text" class="recipient_box" name="stream" id="class" onchange="focus_on('instance')" 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"/>

View File

@ -44,7 +44,7 @@ def process_push(oldrev, newrev, refname):
commits = subprocess.check_output(["git", "log", "--reverse", "--pretty=- **%aN**: %s", "%s..%s" % (oldrev, newrev)])
message_data = {
"type": "stream",
"class": "test" if refname == "refs/heads/test-post-receive" else "devel",
"stream": "test" if refname == "refs/heads/test-post-receive" else "devel",
"instance": "commits",
"content": "The following commits were just pushed to `%s`:\n\n"
% (refname.replace("refs/heads/", ""),) + commits,

View File

@ -62,19 +62,19 @@ function narrow_class() {
var original = message_dict[selected_message_id];
var message = original.display_recipient;
do_narrow(message, function (other) {
return (other.type === 'class' &&
return (other.type === 'stream' &&
original.recipient_id === other.recipient_id);
});
}
function narrow_instance() {
var original = message_dict[selected_message_id];
if (original.type !== 'class')
if (original.type !== 'stream')
return;
var message = original.display_recipient + " | " + original.instance;
do_narrow(message, function (other) {
return (other.type === 'class' &&
return (other.type === 'stream' &&
original.recipient_id === other.recipient_id &&
original.instance === other.instance);
});
@ -85,7 +85,7 @@ function narrow_by_recipient() {
switch (message_dict[selected_message_id].type) {
case 'personal': narrow_personals(); break;
case 'huddle': narrow_huddle(); break;
case 'class': narrow_class(); break;
case 'stream': narrow_class(); break;
}
}

View File

@ -119,9 +119,9 @@ $(function () {
$('#message-type-tabs a[href="#class-message"]').on('shown', function (e) {
$('#personal-message').hide();
$('#class-message').show();
$('#new_message_type').val('class');
$('#new_message_type').val('stream');
$("#send-status").removeClass(status_classes).hide();
focus_on("class");
focus_on("stream");
});
$('#message-type-tabs a[href="#personal-message"]').on('shown', function (e) {
$('#personal-message').show();

View File

@ -116,7 +116,7 @@ function get_huddle_recipient_names(message) {
function respond_to_message(reply_type) {
var message, tabname;
message = message_dict[selected_message_id];
if (message.type === "class") {
if (message.type === "stream") {
$("#class").val(message.display_recipient);
$("#instance").val(message.instance);
} else {

View File

@ -317,7 +317,7 @@ class MessagePOSTTest(AuthedTestCase):
"""
self.login("hamlet@humbughq.com", "hamlet")
result = self.client.post("/send_message/", {"type": "stream",
"class": "Verona",
"stream": "Verona",
"content": "Test message",
"instance": "Test instance"})
self.assert_json_success(result)
@ -330,7 +330,7 @@ class MessagePOSTTest(AuthedTestCase):
self.login("hamlet@humbughq.com", "hamlet")
self.assertFalse(Stream.objects.filter(name="nonexistent_class"))
result = self.client.post("/send_message/", {"type": "stream",
"class": "nonexistent_class",
"stream": "nonexistent_class",
"content": "Test message",
"instance": "Test instance"})
self.assert_json_success(result)

View File

@ -355,11 +355,11 @@ def send_message_backend(request, user_profile, sender):
message_type_name = request.POST["type"]
if message_type_name == 'stream':
if "class" not in request.POST:
return json_error("Missing class")
if "stream" not in request.POST:
return json_error("Missing stream")
if "instance" not in request.POST:
return json_error("Missing instance")
stream_name = strip_html(request.POST['class']).strip()
stream_name = strip_html(request.POST['stream']).strip()
instance_name = strip_html(request.POST['instance']).strip()
if not valid_stream_name(stream_name):