mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
org settings: Add realm level default time format setting.
This commit is contained in:
committed by
Tim Abbott
parent
f4d6b2a853
commit
b7aae89029
@@ -212,6 +212,13 @@ var event_fixtures = {
|
|||||||
value: false,
|
value: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
realm__update_default_twenty_four_hour_time: {
|
||||||
|
type: 'realm',
|
||||||
|
op: 'update',
|
||||||
|
property: 'default_twenty_four_hour_time',
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
|
|
||||||
realm__update_dict__default: {
|
realm__update_dict__default: {
|
||||||
type: 'realm',
|
type: 'realm',
|
||||||
op: 'update_dict',
|
op: 'update_dict',
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ function _setup_page() {
|
|||||||
realm_send_welcome_emails: page_params.realm_send_welcome_emails,
|
realm_send_welcome_emails: page_params.realm_send_welcome_emails,
|
||||||
realm_disallow_disposable_email_addresses:
|
realm_disallow_disposable_email_addresses:
|
||||||
page_params.realm_disallow_disposable_email_addresses,
|
page_params.realm_disallow_disposable_email_addresses,
|
||||||
|
realm_default_twenty_four_hour_time: page_params.realm_default_twenty_four_hour_time,
|
||||||
};
|
};
|
||||||
|
|
||||||
options.bot_creation_policy_values = settings_bots.bot_creation_policy_values;
|
options.bot_creation_policy_values = settings_bots.bot_creation_policy_values;
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
|
|||||||
bot_creation_policy: settings_bots.update_bot_permissions_ui,
|
bot_creation_policy: settings_bots.update_bot_permissions_ui,
|
||||||
create_stream_by_admins_only: noop,
|
create_stream_by_admins_only: noop,
|
||||||
default_language: noop,
|
default_language: noop,
|
||||||
|
default_twenty_four_hour_time: noop,
|
||||||
description: noop,
|
description: noop,
|
||||||
email_changes_disabled: settings_account.update_email_change_display,
|
email_changes_disabled: settings_account.update_email_change_display,
|
||||||
disallow_disposable_email_addresses: noop,
|
disallow_disposable_email_addresses: noop,
|
||||||
|
|||||||
@@ -43,6 +43,9 @@ var org_settings = {
|
|||||||
default_language: {
|
default_language: {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
},
|
},
|
||||||
|
default_twenty_four_hour_time: {
|
||||||
|
type: 'bool',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
notifications: {
|
notifications: {
|
||||||
send_welcome_emails: {
|
send_welcome_emails: {
|
||||||
|
|||||||
@@ -132,6 +132,17 @@
|
|||||||
{{/each}}
|
{{/each}}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="input-group">
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" id="id_realm_default_twenty_four_hour_time"
|
||||||
|
name="realm_default_twenty_four_hour_time"
|
||||||
|
{{#if realm_default_twenty_four_hour_time}}checked="checked"{{/if}} />
|
||||||
|
<span></span>
|
||||||
|
</label>
|
||||||
|
<label for="id_realm_default_twenty_four_hour_time" class="inline-block">
|
||||||
|
{{t "24-hour time (17:00 instead of 5:00 PM)" }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ def create_user_profile(realm: Realm, email: Text, password: Optional[Text],
|
|||||||
tutorial_status=tutorial_status,
|
tutorial_status=tutorial_status,
|
||||||
enter_sends=enter_sends,
|
enter_sends=enter_sends,
|
||||||
onboarding_steps=ujson.dumps([]),
|
onboarding_steps=ujson.dumps([]),
|
||||||
default_language=realm.default_language)
|
default_language=realm.default_language,
|
||||||
|
twenty_four_hour_time=realm.default_twenty_four_hour_time)
|
||||||
|
|
||||||
if bot_type or not active:
|
if bot_type or not active:
|
||||||
password = None
|
password = None
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.6 on 2018-03-30 17:18
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('zerver', '0151_last_reminder_default_none'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='realm',
|
||||||
|
name='default_twenty_four_hour_time',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -157,7 +157,6 @@ class Realm(models.Model):
|
|||||||
disallow_disposable_email_addresses = models.BooleanField(default=True) # type: bool
|
disallow_disposable_email_addresses = models.BooleanField(default=True) # type: bool
|
||||||
description = models.TextField(null=True) # type: Optional[Text]
|
description = models.TextField(null=True) # type: Optional[Text]
|
||||||
send_welcome_emails = models.BooleanField(default=True) # type: bool
|
send_welcome_emails = models.BooleanField(default=True) # type: bool
|
||||||
|
|
||||||
allow_message_deleting = models.BooleanField(default=False) # type: bool
|
allow_message_deleting = models.BooleanField(default=False) # type: bool
|
||||||
allow_message_editing = models.BooleanField(default=True) # type: bool
|
allow_message_editing = models.BooleanField(default=True) # type: bool
|
||||||
DEFAULT_MESSAGE_CONTENT_EDIT_LIMIT_SECONDS = 600 # if changed, also change in admin.js
|
DEFAULT_MESSAGE_CONTENT_EDIT_LIMIT_SECONDS = 600 # if changed, also change in admin.js
|
||||||
@@ -166,6 +165,7 @@ class Realm(models.Model):
|
|||||||
allow_edit_history = models.BooleanField(default=True) # type: bool
|
allow_edit_history = models.BooleanField(default=True) # type: bool
|
||||||
DEFAULT_COMMUNITY_TOPIC_EDITING_LIMIT_SECONDS = 86400
|
DEFAULT_COMMUNITY_TOPIC_EDITING_LIMIT_SECONDS = 86400
|
||||||
allow_community_topic_editing = models.BooleanField(default=False) # type: bool
|
allow_community_topic_editing = models.BooleanField(default=False) # type: bool
|
||||||
|
default_twenty_four_hour_time = models.BooleanField(default=False) # type: bool
|
||||||
|
|
||||||
# Valid org_types are {CORPORATE, COMMUNITY}
|
# Valid org_types are {CORPORATE, COMMUNITY}
|
||||||
CORPORATE = 1
|
CORPORATE = 1
|
||||||
@@ -200,6 +200,7 @@ class Realm(models.Model):
|
|||||||
bot_creation_policy=int,
|
bot_creation_policy=int,
|
||||||
create_stream_by_admins_only=bool,
|
create_stream_by_admins_only=bool,
|
||||||
default_language=Text,
|
default_language=Text,
|
||||||
|
default_twenty_four_hour_time = bool,
|
||||||
description=Text,
|
description=Text,
|
||||||
disallow_disposable_email_addresses=bool,
|
disallow_disposable_email_addresses=bool,
|
||||||
email_changes_disabled=bool,
|
email_changes_disabled=bool,
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ class HomeTest(ZulipTestCase):
|
|||||||
"realm_default_language",
|
"realm_default_language",
|
||||||
"realm_default_stream_groups",
|
"realm_default_stream_groups",
|
||||||
"realm_default_streams",
|
"realm_default_streams",
|
||||||
|
"realm_default_twenty_four_hour_time",
|
||||||
"realm_description",
|
"realm_description",
|
||||||
"realm_disallow_disposable_email_addresses",
|
"realm_disallow_disposable_email_addresses",
|
||||||
"realm_domains",
|
"realm_domains",
|
||||||
|
|||||||
@@ -1591,6 +1591,34 @@ class UserSignUpTest(ZulipTestCase):
|
|||||||
from django.core.mail import outbox
|
from django.core.mail import outbox
|
||||||
outbox.pop()
|
outbox.pop()
|
||||||
|
|
||||||
|
def test_default_twenty_four_hour_time(self) -> None:
|
||||||
|
"""
|
||||||
|
Check if the default twenty_four_hour_time setting of new user
|
||||||
|
is the default twenty_four_hour_time of the realm.
|
||||||
|
"""
|
||||||
|
email = self.nonreg_email('newguy')
|
||||||
|
password = "newpassword"
|
||||||
|
realm = get_realm('zulip')
|
||||||
|
do_set_realm_property(realm, 'default_twenty_four_hour_time', True)
|
||||||
|
|
||||||
|
result = self.client_post('/accounts/home/', {'email': email})
|
||||||
|
self.assertEqual(result.status_code, 302)
|
||||||
|
self.assertTrue(result["Location"].endswith(
|
||||||
|
"/accounts/send_confirm/%s" % (email,)))
|
||||||
|
result = self.client_get(result["Location"])
|
||||||
|
self.assert_in_response("Check your email so we can get started.", result)
|
||||||
|
|
||||||
|
# Visit the confirmation link.
|
||||||
|
confirmation_url = self.get_confirmation_url_from_outbox(email)
|
||||||
|
result = self.client_get(confirmation_url)
|
||||||
|
self.assertEqual(result.status_code, 200)
|
||||||
|
|
||||||
|
result = self.submit_reg_form_for_user(email, password)
|
||||||
|
self.assertEqual(result.status_code, 302)
|
||||||
|
|
||||||
|
user_profile = self.nonreg_user('newguy')
|
||||||
|
self.assertEqual(user_profile.twenty_four_hour_time, realm.default_twenty_four_hour_time)
|
||||||
|
|
||||||
def test_signup_already_active(self) -> None:
|
def test_signup_already_active(self) -> None:
|
||||||
"""
|
"""
|
||||||
Check if signing up with an active email redirects to a login page.
|
Check if signing up with an active email redirects to a login page.
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ def update_realm(
|
|||||||
signup_notifications_stream_id: Optional[int]=REQ(validator=check_int, default=None),
|
signup_notifications_stream_id: Optional[int]=REQ(validator=check_int, default=None),
|
||||||
message_retention_days: Optional[int]=REQ(converter=to_not_negative_int_or_none, default=None),
|
message_retention_days: Optional[int]=REQ(converter=to_not_negative_int_or_none, default=None),
|
||||||
send_welcome_emails: Optional[bool]=REQ(validator=check_bool, default=None),
|
send_welcome_emails: Optional[bool]=REQ(validator=check_bool, default=None),
|
||||||
bot_creation_policy: Optional[int]=REQ(converter=to_not_negative_int_or_none, default=None)
|
bot_creation_policy: Optional[int]=REQ(converter=to_not_negative_int_or_none, default=None),
|
||||||
|
default_twenty_four_hour_time: Optional[bool]=REQ(validator=check_bool, default=None),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
realm = user_profile.realm
|
realm = user_profile.realm
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user