Rename new_subscription argument to streams.

(imported from commit 8024f47564fe580734d5e452f5092520870003a7)
This commit is contained in:
Tim Abbott 2012-10-31 18:10:18 -04:00
parent 0120b2b239
commit 01bf0868a9
3 changed files with 9 additions and 9 deletions

View File

@ -6,7 +6,7 @@
<h1>Subscriptions</h1>
<form id="add_new_subscription" action="/json/subscriptions/add"
method="post" class="form-inline">{% csrf_token %}
<input type="text" name="new_subscription" id="new_subscription"
<input type="text" name="streams" id="streams"
placeholder="Stream name" value="" class="span4" />
<input type="submit" name="add_subscription" value="Subscribe" class="btn btn-primary" />
</form>

View File

@ -44,7 +44,7 @@ exports.fetch = function () {
$('#subscriptions_table').append(templates.subscription({subscription: name}));
});
}
$('#new_subscription').focus().select();
$('#streams').focus().select();
},
error: function (xhr) {
report_error("Error listing subscriptions", xhr, $("#subscriptions-status"));
@ -62,7 +62,7 @@ exports.add_for_send = function (stream, prompt_button) {
$.ajax({
type: 'POST',
url: '/json/subscriptions/add',
data: {new_subscription: stream},
data: {streams: stream},
dataType: 'json',
timeout: 10*60*1000, // 10 minutes in ms
success: function (response) {
@ -112,17 +112,17 @@ $(function () {
$("#add_new_subscription").ajaxForm({
dataType: 'json', // This seems to be ignored. We still get back an xhr.
success: function (resp, statusText, xhr, form) {
$("#new_subscription").val("");
$("#streams").val("");
var name = $.parseJSON(xhr.responseText).data;
$('#subscriptions_table').prepend(templates.subscription({subscription: name}));
add_to_stream_list(name);
report_success("Successfully added subscription to " + name,
$("#subscriptions-status"));
$("#new_subscription").focus();
$("#streams").focus();
},
error: function (xhr) {
report_error("Error adding subscription", xhr, $("#subscriptions-status"));
$("#new_subscription").focus();
$("#streams").focus();
}
});
});

View File

@ -781,9 +781,9 @@ def api_subscribe(request, user_profile):
def json_add_subscription(request):
user_profile = UserProfile.objects.get(user=request.user)
if "new_subscription" not in request.POST:
return json_error("Missing new_subscription argument")
stream_name = request.POST.get('new_subscription').strip()
if "streams" not in request.POST:
return json_error("Missing streams argument")
stream_name = request.POST.get('streams').strip()
if not valid_stream_name(stream_name):
return json_error("Invalid characters in stream names")
if len(stream_name) > 30: