mirror of https://github.com/zulip/zulip.git
zerver: Text-wrap long lines exceeding 110.
This commit is contained in:
parent
23a481c5d2
commit
a93b7c40a7
|
@ -12,7 +12,8 @@ import logging
|
|||
import time
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = """Checks redis to make sure our rate limiting system hasn't grown a bug and left redis with a bunch of data
|
||||
help = """Checks redis to make sure our rate limiting system hasn't grown a bug
|
||||
and left redis with a bunch of data
|
||||
|
||||
Usage: ./manage.py [--trim] check_redis"""
|
||||
|
||||
|
|
|
@ -45,9 +45,11 @@ Create default stream groups which the users can choose during sign up.
|
|||
streams.append(stream)
|
||||
|
||||
try:
|
||||
default_stream_group = DefaultStreamGroup.objects.get(name=options["default_stream_group"], realm=realm)
|
||||
default_stream_group = DefaultStreamGroup.objects.get(
|
||||
name=options["default_stream_group"], realm=realm)
|
||||
except DefaultStreamGroup.DoesNotExist:
|
||||
default_stream_group = DefaultStreamGroup.objects.create(name=options["default_stream_group"], realm=realm)
|
||||
default_stream_group = DefaultStreamGroup.objects.create(
|
||||
name=options["default_stream_group"], realm=realm)
|
||||
default_stream_group.streams = streams
|
||||
default_stream_group.save()
|
||||
|
||||
|
|
|
@ -46,7 +46,8 @@ Omit both <email> and <full name> for interactive user creation.
|
|||
help='The file containing the password of the new user.')
|
||||
parser.add_argument('email', metavar='<email>', type=str, nargs='?', default=argparse.SUPPRESS,
|
||||
help='email address of new user')
|
||||
parser.add_argument('full_name', metavar='<full name>', type=str, nargs='?', default=argparse.SUPPRESS,
|
||||
parser.add_argument('full_name', metavar='<full name>', type=str, nargs='?',
|
||||
default=argparse.SUPPRESS,
|
||||
help='full name of new user')
|
||||
self.add_realm_args(parser, True, "The name of the existing realm to which to add the user.")
|
||||
|
||||
|
|
|
@ -43,7 +43,8 @@ Usage: ./manage.py deliver_email
|
|||
|
||||
with lockfile("/tmp/zulip_email_deliver.lockfile"):
|
||||
while True:
|
||||
email_jobs_to_deliver = ScheduledEmail.objects.filter(scheduled_timestamp__lte=timezone_now())
|
||||
email_jobs_to_deliver = ScheduledEmail.objects.filter(
|
||||
scheduled_timestamp__lte=timezone_now())
|
||||
if email_jobs_to_deliver:
|
||||
for job in email_jobs_to_deliver:
|
||||
try:
|
||||
|
@ -53,5 +54,6 @@ Usage: ./manage.py deliver_email
|
|||
logger.warning("%r not delivered" % (job,))
|
||||
time.sleep(10)
|
||||
else:
|
||||
# Less load on the db during times of activity, and more responsiveness when the load is low
|
||||
# Less load on the db during times of activity,
|
||||
# and more responsiveness when the load is low
|
||||
time.sleep(2)
|
||||
|
|
|
@ -31,7 +31,8 @@ class Command(BaseCommand):
|
|||
sys.exit(1)
|
||||
|
||||
url = generate_realm_creation_url()
|
||||
self.stdout.write(self.style.SUCCESS("Please visit the following secure single-use link to register your "))
|
||||
self.stdout.write(self.style.SUCCESS("Please visit the following "
|
||||
"secure single-use link to register your "))
|
||||
self.stdout.write(self.style.SUCCESS("new Zulip organization:\033[0m"))
|
||||
self.stdout.write("")
|
||||
self.stdout.write(self.style.SUCCESS(" \033[1;92m%s\033[0m" % (url,)))
|
||||
|
|
|
@ -43,7 +43,8 @@ import a database dump from one or more JSON files."""
|
|||
if count:
|
||||
print("Zulip instance is not empty, found %d rows in %s table. "
|
||||
% (count, model._meta.db_table))
|
||||
print("You may use --destroy-rebuild-database to destroy and rebuild the database prior to import.")
|
||||
print("You may use --destroy-rebuild-database to destroy and "
|
||||
"rebuild the database prior to import.")
|
||||
exit(1)
|
||||
|
||||
def do_destroy_and_rebuild_database(self, db_name: str) -> None:
|
||||
|
|
|
@ -25,7 +25,7 @@ unfortunately isn't extensible, so we can:
|
|||
We are currently doing that last thing. It turns out there we are lucky
|
||||
for once: It's simply a matter of extending two regular expressions.
|
||||
Credit for the approach goes to:
|
||||
http://stackoverflow.com/questions/2090717/getting-translation-strings-for-jinja2-templates-integrated-with-django-1-x
|
||||
http://stackoverflow.com/questions/2090717
|
||||
|
||||
"""
|
||||
|
||||
|
@ -44,7 +44,8 @@ from django.utils.translation import template
|
|||
|
||||
from zerver.lib.str_utils import force_text
|
||||
|
||||
strip_whitespace_right = re.compile("(%s-?\\s*(trans|pluralize).*?-%s)\\s+" % (BLOCK_TAG_START, BLOCK_TAG_END), re.U)
|
||||
strip_whitespace_right = re.compile("(%s-?\\s*(trans|pluralize).*?-%s)\\s+" % (
|
||||
BLOCK_TAG_START, BLOCK_TAG_END), re.U)
|
||||
strip_whitespace_left = re.compile("\\s+(%s-\\s*(endtrans|pluralize).*?-?%s)" % (
|
||||
BLOCK_TAG_START, BLOCK_TAG_END), re.U)
|
||||
|
||||
|
|
|
@ -64,7 +64,8 @@ class Command(ZulipBaseCommand):
|
|||
user_emails_found = [user.email for user in users_to_activate]
|
||||
for user in user_emails:
|
||||
if user not in user_emails_found:
|
||||
raise Exception('User with email %s was not found. Check if the email is correct.' % (user))
|
||||
raise Exception('User with email %s was not found. '
|
||||
'Check if the email is correct.' % (user))
|
||||
|
||||
users_activated = do_soft_activate_users(users_to_activate)
|
||||
logger.info('Soft Reactivated %d user(s)' % (len(users_activated)))
|
||||
|
@ -86,7 +87,8 @@ class Command(ZulipBaseCommand):
|
|||
else:
|
||||
if realm is not None:
|
||||
filter_kwargs = dict(user_profile__realm=realm)
|
||||
users_to_deactivate = get_users_for_soft_deactivation(int(options['inactive_for']), filter_kwargs)
|
||||
users_to_deactivate = get_users_for_soft_deactivation(int(options['inactive_for']),
|
||||
filter_kwargs)
|
||||
|
||||
if users_to_deactivate:
|
||||
users_deactivated = do_soft_deactivate_users(users_to_deactivate)
|
||||
|
|
|
@ -374,7 +374,8 @@ def get_realm_domains(realm):
|
|||
class RealmEmoji(models.Model):
|
||||
author = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
|
||||
realm = models.ForeignKey(Realm, on_delete=CASCADE) # type: Realm
|
||||
# Second part of the regex (negative lookbehind) disallows names ending with one of the punctuation characters
|
||||
# Second part of the regex (negative lookbehind) disallows names ending with
|
||||
# one of the punctuation characters
|
||||
name = models.TextField(validators=[MinLengthValidator(1),
|
||||
RegexValidator(regex=r'^[0-9a-z.\-_]+(?<![.\-_])$',
|
||||
message=_("Invalid characters in emoji name"))]) # type: Text
|
||||
|
@ -435,7 +436,8 @@ def filter_format_validator(value):
|
|||
regex = re.compile(r'^[\.\/:a-zA-Z0-9_?=-]+%\(([a-zA-Z0-9_-]+)\)s[a-zA-Z0-9_-]*$')
|
||||
|
||||
if not regex.match(value):
|
||||
raise ValidationError('URL format string must be in the following format: `https://example.com/%(\w+)s`')
|
||||
raise ValidationError('URL format string must be in the following format: '
|
||||
'`https://example.com/%(\w+)s`')
|
||||
|
||||
class RealmFilter(models.Model):
|
||||
realm = models.ForeignKey(Realm, on_delete=CASCADE) # type: Realm
|
||||
|
@ -479,7 +481,9 @@ def all_realm_filters():
|
|||
# type: () -> Dict[int, List[Tuple[Text, Text, int]]]
|
||||
filters = defaultdict(list) # type: DefaultDict[int, List[Tuple[Text, Text, int]]]
|
||||
for realm_filter in RealmFilter.objects.all():
|
||||
filters[realm_filter.realm_id].append((realm_filter.pattern, realm_filter.url_format_string, realm_filter.id))
|
||||
filters[realm_filter.realm_id].append((realm_filter.pattern,
|
||||
realm_filter.url_format_string,
|
||||
realm_filter.id))
|
||||
|
||||
return filters
|
||||
|
||||
|
@ -503,7 +507,8 @@ class UserProfile(AbstractBaseUser, PermissionsMixin):
|
|||
since they can't be used to read messages.
|
||||
"""
|
||||
INCOMING_WEBHOOK_BOT = 2
|
||||
# This value is also being used in static/js/settings_bots.js. On updating it here, update it there as well.
|
||||
# This value is also being used in static/js/settings_bots.js.
|
||||
# On updating it here, update it there as well.
|
||||
OUTGOING_WEBHOOK_BOT = 3
|
||||
"""
|
||||
Embedded bots run within the Zulip server itself; events are added to the
|
||||
|
@ -1207,7 +1212,8 @@ class Message(AbstractMessage):
|
|||
@staticmethod
|
||||
def content_has_image(content):
|
||||
# type: (Text) -> bool
|
||||
return bool(re.search(r'[/\-]user[\-_]uploads[/\.-]\S+\.(bmp|gif|jpg|jpeg|png|webp)', content, re.IGNORECASE))
|
||||
return bool(re.search(r'[/\-]user[\-_]uploads[/\.-]\S+\.(bmp|gif|jpg|jpeg|png|webp)',
|
||||
content, re.IGNORECASE))
|
||||
|
||||
@staticmethod
|
||||
def content_has_link(content):
|
||||
|
@ -1972,8 +1978,9 @@ class Service(models.Model):
|
|||
|
||||
def get_realm_outgoing_webhook_services_name(realm):
|
||||
# type: (Realm) -> List[Any]
|
||||
return list(Service.objects.filter(user_profile__realm=realm, user_profile__is_bot=True,
|
||||
user_profile__bot_type=UserProfile.OUTGOING_WEBHOOK_BOT).values('name'))
|
||||
return list(Service.objects.filter(
|
||||
user_profile__realm=realm, user_profile__is_bot=True,
|
||||
user_profile__bot_type=UserProfile.OUTGOING_WEBHOOK_BOT).values('name'))
|
||||
|
||||
def get_bot_services(user_profile_id):
|
||||
# type: (str) -> List[Service]
|
||||
|
|
|
@ -61,8 +61,11 @@ class BadNarrowOperator(JsonableError):
|
|||
# type: () -> str
|
||||
return _('Invalid narrow operator: {desc}')
|
||||
|
||||
Query = Any # TODO: Should be Select, but sqlalchemy stubs are busted
|
||||
ConditionTransform = Any # TODO: should be Callable[[ColumnElement], ColumnElement], but sqlalchemy stubs are busted
|
||||
# TODO: Should be Select, but sqlalchemy stubs are busted
|
||||
Query = Any
|
||||
|
||||
# TODO: should be Callable[[ColumnElement], ColumnElement], but sqlalchemy stubs are busted
|
||||
ConditionTransform = Any
|
||||
|
||||
# When you add a new operator to this, also update zerver/lib/narrow.py
|
||||
class NarrowBuilder:
|
||||
|
|
|
@ -38,7 +38,8 @@ def report_send_times(request: HttpRequest, user_profile: UserProfile,
|
|||
received: int=REQ(converter=to_non_negative_int, default=-1),
|
||||
displayed: int=REQ(converter=to_non_negative_int, default=-1),
|
||||
locally_echoed: bool=REQ(validator=check_bool, default=False),
|
||||
rendered_content_disparity: bool=REQ(validator=check_bool, default=False)) -> HttpResponse:
|
||||
rendered_content_disparity: bool=REQ(validator=check_bool,
|
||||
default=False)) -> HttpResponse:
|
||||
received_str = "(unknown)"
|
||||
if received > 0:
|
||||
received_str = str(received)
|
||||
|
|
Loading…
Reference in New Issue