mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	settings: Add support for longer, markdown-powered realm descriptions.
This makes it possible to create much prettier login pages. Further work on styling may be necessary.
This commit is contained in:
		@@ -408,6 +408,9 @@ exports.process_hotkey = function (e, hotkey) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (modals.settings_open()) {
 | 
			
		||||
        if (exports.processing_text()) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        switch (event_name) {
 | 
			
		||||
            case 'up_arrow':
 | 
			
		||||
                settings.handle_up_arrow(e);
 | 
			
		||||
 
 | 
			
		||||
@@ -75,6 +75,11 @@ label {
 | 
			
		||||
    display: block;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.admin-realm-description {
 | 
			
		||||
    height: 16em;
 | 
			
		||||
    width: 36em;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.padded-container {
 | 
			
		||||
    padding: 20px;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -25,8 +25,9 @@
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="input-group admin-realm">
 | 
			
		||||
      <label for="realm_description">{{t "Your organization's description" }}</label>
 | 
			
		||||
      <input type="text" id="id_realm_description" name="realm_description" class="admin-realm-description"
 | 
			
		||||
        maxlength="100" value="{{ realm_description }}" />
 | 
			
		||||
      <textarea id="id_realm_description" name="realm_description" class="admin-realm-description"
 | 
			
		||||
        maxlength="1000">{{ realm_description }}
 | 
			
		||||
      </textarea>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div class="input-group admin-restricted-to-domain">
 | 
			
		||||
      <label class="checkbox">
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@ $(function () {
 | 
			
		||||
                        </div>
 | 
			
		||||
                    </div>
 | 
			
		||||
                    <div class="description">
 | 
			
		||||
                        {{ realm_description }}
 | 
			
		||||
                        {{ realm_description|safe }}
 | 
			
		||||
                    </div>
 | 
			
		||||
                </div>
 | 
			
		||||
                {% endif %}
 | 
			
		||||
 
 | 
			
		||||
@@ -67,7 +67,7 @@ autofocus('#id_username');
 | 
			
		||||
                    </div>
 | 
			
		||||
                </div>
 | 
			
		||||
                <div class="description">
 | 
			
		||||
                    {{ realm_description }}
 | 
			
		||||
                    {{ realm_description|safe }}
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
            {% endif %}
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@ from zproject.backends import (
 | 
			
		||||
    auth_enabled_helper,
 | 
			
		||||
    AUTH_BACKEND_NAME_MAP
 | 
			
		||||
)
 | 
			
		||||
from zerver.lib.bugdown import convert
 | 
			
		||||
from zerver.lib.utils import get_subdomain
 | 
			
		||||
from zerver.lib.realm_icon import get_realm_icon_url
 | 
			
		||||
 | 
			
		||||
@@ -58,7 +59,7 @@ def zulip_default_context(request):
 | 
			
		||||
        realm_uri = realm.uri
 | 
			
		||||
        realm_name = realm.name
 | 
			
		||||
        realm_icon = get_realm_icon_url(realm)
 | 
			
		||||
        realm_description = realm.description or "The coolest place in the universe."
 | 
			
		||||
        realm_description = convert(realm.description, message_realm=realm) or "The coolest place in the universe."
 | 
			
		||||
    else:
 | 
			
		||||
        realm_uri = settings.SERVER_URI
 | 
			
		||||
        realm_name = None
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										20
									
								
								zerver/migrations/0080_realm_description_length.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								zerver/migrations/0080_realm_description_length.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,20 @@
 | 
			
		||||
# -*- coding: utf-8 -*-
 | 
			
		||||
# Generated by Django 1.10.5 on 2017-05-11 20:27
 | 
			
		||||
from __future__ import unicode_literals
 | 
			
		||||
 | 
			
		||||
from django.db import migrations, models
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class Migration(migrations.Migration):
 | 
			
		||||
 | 
			
		||||
    dependencies = [
 | 
			
		||||
        ('zerver', '0079_remove_old_scheduled_jobs'),
 | 
			
		||||
    ]
 | 
			
		||||
 | 
			
		||||
    operations = [
 | 
			
		||||
        migrations.AlterField(
 | 
			
		||||
            model_name='realm',
 | 
			
		||||
            name='description',
 | 
			
		||||
            field=models.TextField(null=True),
 | 
			
		||||
        ),
 | 
			
		||||
    ]
 | 
			
		||||
@@ -122,7 +122,7 @@ class Realm(ModelReprMixin, models.Model):
 | 
			
		||||
    show_digest_email = models.BooleanField(default=True) # type: bool
 | 
			
		||||
    name_changes_disabled = models.BooleanField(default=False) # type: bool
 | 
			
		||||
    email_changes_disabled = models.BooleanField(default=False) # type: bool
 | 
			
		||||
    description = models.TextField(max_length=100, null=True) # type: Optional[Text]
 | 
			
		||||
    description = models.TextField(null=True) # type: Optional[Text]
 | 
			
		||||
 | 
			
		||||
    allow_message_editing = models.BooleanField(default=True) # type: bool
 | 
			
		||||
    DEFAULT_MESSAGE_CONTENT_EDIT_LIMIT_SECONDS = 600 # if changed, also change in admin.js
 | 
			
		||||
 
 | 
			
		||||
@@ -90,7 +90,7 @@ class RealmTest(ZulipTestCase):
 | 
			
		||||
 | 
			
		||||
    def test_realm_description_length(self):
 | 
			
		||||
        # type: () -> None
 | 
			
		||||
        new_description = u'A' * 101
 | 
			
		||||
        new_description = u'A' * 1001
 | 
			
		||||
        data = dict(description=ujson.dumps(new_description))
 | 
			
		||||
 | 
			
		||||
        # create an admin user
 | 
			
		||||
@@ -98,7 +98,7 @@ class RealmTest(ZulipTestCase):
 | 
			
		||||
        self.login(email)
 | 
			
		||||
 | 
			
		||||
        result = self.client_patch('/json/realm', data)
 | 
			
		||||
        self.assert_json_error(result, 'Realm description cannot exceed 100 characters.')
 | 
			
		||||
        self.assert_json_error(result, 'Realm description is too long.')
 | 
			
		||||
        realm = get_realm('zulip')
 | 
			
		||||
        self.assertNotEqual(realm.description, new_description)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -43,8 +43,8 @@ def update_realm(request, user_profile, name=REQ(validator=check_string, default
 | 
			
		||||
    # the entire request can succeed or fail atomically.
 | 
			
		||||
    if default_language is not None and default_language not in get_available_language_codes():
 | 
			
		||||
        raise JsonableError(_("Invalid language '%s'" % (default_language,)))
 | 
			
		||||
    if description is not None and len(description) > 100:
 | 
			
		||||
        return json_error(_("Realm description cannot exceed 100 characters."))
 | 
			
		||||
    if description is not None and len(description) > 1000:
 | 
			
		||||
        return json_error(_("Realm description is too long."))
 | 
			
		||||
    if authentication_methods is not None and True not in list(authentication_methods.values()):
 | 
			
		||||
        return json_error(_("At least one authentication method must be enabled."),
 | 
			
		||||
                          data={"reason": "no authentication"},
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user