mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
[schema] Save enter_sends on the server in the database.
(imported from commit 4d82f6aaf5918f155a930253c9cc334dbcc0d97a)
This commit is contained in:
@@ -71,6 +71,7 @@ urlpatterns = patterns('',
|
|||||||
url(r'^json/update_active_status$', 'zephyr.views.json_update_active_status'),
|
url(r'^json/update_active_status$', 'zephyr.views.json_update_active_status'),
|
||||||
url(r'^json/get_active_statuses$', 'zephyr.views.json_get_active_statuses'),
|
url(r'^json/get_active_statuses$', 'zephyr.views.json_get_active_statuses'),
|
||||||
url(r'^json/tutorial_send_message$', 'zephyr.views.json_tutorial_send_message'),
|
url(r'^json/tutorial_send_message$', 'zephyr.views.json_tutorial_send_message'),
|
||||||
|
url(r'^json/change_enter_sends$', 'zephyr.views.json_change_enter_sends'),
|
||||||
|
|
||||||
# These are json format views used by the API. They require an API key.
|
# These are json format views used by the API. They require an API key.
|
||||||
url(r'^api/v1/get_messages$', 'zephyr.tornadoviews.api_get_messages'),
|
url(r'^api/v1/get_messages$', 'zephyr.tornadoviews.api_get_messages'),
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ var email = "{{ user_profile.user.email|escapejs }}";
|
|||||||
var domain = "{{ user_profile.realm.domain|escapejs }}";
|
var domain = "{{ user_profile.realm.domain|escapejs }}";
|
||||||
var have_initial_messages = {{ have_initial_messages|escapejs }};
|
var have_initial_messages = {{ have_initial_messages|escapejs }};
|
||||||
var desktop_notifications_enabled = {{ desktop_notifications_enabled|escapejs }};
|
var desktop_notifications_enabled = {{ desktop_notifications_enabled|escapejs }};
|
||||||
|
var enter_sends = {{ enter_sends|escapejs }};
|
||||||
|
|
||||||
{# We use JSONEncoderForHTML to generate "streams". #}
|
{# We use JSONEncoderForHTML to generate "streams". #}
|
||||||
var stream_list = {{ streams }};
|
var stream_list = {{ streams }};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ var globals =
|
|||||||
|
|
||||||
// index.html
|
// index.html
|
||||||
+ ' initial_pointer email stream_list people_list have_initial_messages'
|
+ ' initial_pointer email stream_list people_list have_initial_messages'
|
||||||
+ ' fullname desktop_notifications_enabled domain poll_timeout'
|
+ ' fullname desktop_notifications_enabled enter_sends domain poll_timeout'
|
||||||
|
|
||||||
// common.js
|
// common.js
|
||||||
+ ' status_classes'
|
+ ' status_classes'
|
||||||
|
|||||||
@@ -292,6 +292,10 @@ def do_change_enable_desktop_notifications(user_profile, enable_desktop_notifica
|
|||||||
'user': user_profile.user.email,
|
'user': user_profile.user.email,
|
||||||
'enable_desktop_notifications': enable_desktop_notifications})
|
'enable_desktop_notifications': enable_desktop_notifications})
|
||||||
|
|
||||||
|
def do_change_enter_sends(user_profile, enter_sends):
|
||||||
|
user_profile.enter_sends = enter_sends
|
||||||
|
user_profile.save()
|
||||||
|
|
||||||
def set_default_streams(realm, stream_names):
|
def set_default_streams(realm, stream_names):
|
||||||
DefaultStream.objects.filter(realm=realm).delete()
|
DefaultStream.objects.filter(realm=realm).delete()
|
||||||
for stream_name in stream_names:
|
for stream_name in stream_names:
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class UserProfile(models.Model):
|
|||||||
realm = models.ForeignKey(Realm)
|
realm = models.ForeignKey(Realm)
|
||||||
api_key = models.CharField(max_length=32)
|
api_key = models.CharField(max_length=32)
|
||||||
enable_desktop_notifications = models.BooleanField(default=True)
|
enable_desktop_notifications = models.BooleanField(default=True)
|
||||||
|
enter_sends = models.NullBooleanField(default=False)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<UserProfile: %s %s>" % (self.user.email, self.realm)
|
return "<UserProfile: %s %s>" % (self.user.email, self.realm)
|
||||||
|
|||||||
@@ -99,8 +99,7 @@ function handle_keydown(e) {
|
|||||||
|
|
||||||
// If no typeaheads are shown and the user has configured enter to send,
|
// If no typeaheads are shown and the user has configured enter to send,
|
||||||
// then make enter send instead of inserting a line break.
|
// then make enter send instead of inserting a line break.
|
||||||
if (e.target.id === "new_message_content" && code === 13 &&
|
if (e.target.id === "new_message_content" && code === 13 && enter_sends) {
|
||||||
$("#enter_sends").is(':checked')) {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
compose.finish();
|
compose.finish();
|
||||||
}
|
}
|
||||||
@@ -147,6 +146,17 @@ exports.initialize = function () {
|
|||||||
handle_keyup(e);
|
handle_keyup(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$("#enter_sends").click(function () {
|
||||||
|
enter_sends = $("#enter_sends").is(":checked");
|
||||||
|
return $.ajax({
|
||||||
|
dataType: 'json',
|
||||||
|
url: '/json/change_enter_sends',
|
||||||
|
type: 'POST',
|
||||||
|
data: {'enter_sends': enter_sends}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$("#enter_sends").prop('checked', enter_sends);
|
||||||
|
|
||||||
// limit number of items so the list doesn't fall off the screen
|
// limit number of items so the list doesn't fall off the screen
|
||||||
$( "#stream" ).typeahead({
|
$( "#stream" ).typeahead({
|
||||||
source: function (query, process) {
|
source: function (query, process) {
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ from zephyr.models import Message, UserProfile, Stream, Subscription, \
|
|||||||
StreamColor, PreregistrationUser, get_client, MitUser, User, UserActivity, \
|
StreamColor, PreregistrationUser, get_client, MitUser, User, UserActivity, \
|
||||||
MAX_SUBJECT_LENGTH, MAX_MESSAGE_LENGTH, get_stream, UserPresence
|
MAX_SUBJECT_LENGTH, MAX_MESSAGE_LENGTH, get_stream, UserPresence
|
||||||
from zephyr.lib.actions import do_add_subscription, do_remove_subscription, \
|
from zephyr.lib.actions import do_add_subscription, do_remove_subscription, \
|
||||||
do_change_password, create_mit_user_if_needed, \
|
do_change_password, create_mit_user_if_needed, do_change_full_name, \
|
||||||
do_change_full_name, do_change_enable_desktop_notifications, \
|
do_change_enable_desktop_notifications, do_change_enter_sends, \
|
||||||
do_activate_user, add_default_subs, do_create_user, do_send_message, \
|
do_activate_user, add_default_subs, do_create_user, do_send_message, \
|
||||||
log_subscription_property_change, internal_send_message, \
|
log_subscription_property_change, internal_send_message, \
|
||||||
create_stream_if_needed, gather_subscriptions, subscribed_to_stream, \
|
create_stream_if_needed, gather_subscriptions, subscribed_to_stream, \
|
||||||
@@ -419,6 +419,8 @@ def home(request):
|
|||||||
js_bool(num_messages > 0),
|
js_bool(num_messages > 0),
|
||||||
'desktop_notifications_enabled':
|
'desktop_notifications_enabled':
|
||||||
js_bool(user_profile.enable_desktop_notifications),
|
js_bool(user_profile.enable_desktop_notifications),
|
||||||
|
'enter_sends':
|
||||||
|
js_bool(user_profile.enter_sends),
|
||||||
'show_debug':
|
'show_debug':
|
||||||
settings.DEBUG and ('show_debug' in request.GET),
|
settings.DEBUG and ('show_debug' in request.GET),
|
||||||
'show_activity': can_view_activity(request),
|
'show_activity': can_view_activity(request),
|
||||||
@@ -649,6 +651,12 @@ def json_tutorial_send_message(request, user_profile, message=POST('message')):
|
|||||||
message)
|
message)
|
||||||
return json_success()
|
return json_success()
|
||||||
|
|
||||||
|
@authenticated_json_post_view
|
||||||
|
@has_request_variables
|
||||||
|
def json_change_enter_sends(request, user_profile, enter_sends=POST('enter_sends', json_to_bool)):
|
||||||
|
do_change_enter_sends(user_profile, enter_sends)
|
||||||
|
return json_success()
|
||||||
|
|
||||||
# Currently tabbott/extra@mit.edu is our only superuser. TODO: Make
|
# Currently tabbott/extra@mit.edu is our only superuser. TODO: Make
|
||||||
# this a real superuser security check.
|
# this a real superuser security check.
|
||||||
def is_super_user_api(request):
|
def is_super_user_api(request):
|
||||||
|
|||||||
Reference in New Issue
Block a user