mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
Properly compute the name of our tutorial stream server-side.
It's subtle, but the slice was in the wrong place and wasn't actually truncating the stream name at all, so the client and server disagreed about where the tutorial messages should go. (It might be the case that we should accept the tutorial stream name from the client directly, rather than computing it in two places.) (imported from commit 8273223f182e8ad36eaea1cbf75e1426fcfdfbab)
This commit is contained in:
@@ -82,8 +82,11 @@ class UserProfile(AbstractBaseUser):
|
||||
tutorial_status = models.CharField(default=TUTORIAL_WAITING, choices=TUTORIAL_STATES, max_length=1)
|
||||
|
||||
def tutorial_stream_name(self):
|
||||
return "tutorial-%s" % \
|
||||
(self.email.split('@')[0],)[:Stream.MAX_NAME_LENGTH]
|
||||
# If you change this, you need to change the corresponding
|
||||
# client-computed version of it in tutorial.js
|
||||
long_name = "tutorial-%s" % (self.email.split('@')[0],)
|
||||
short_name = long_name[:Stream.MAX_NAME_LENGTH]
|
||||
return short_name
|
||||
|
||||
objects = UserManager()
|
||||
|
||||
@@ -113,6 +116,8 @@ class MitUser(models.Model):
|
||||
status = models.IntegerField(default=0)
|
||||
|
||||
class Stream(models.Model):
|
||||
# If you change this, you also need to change the
|
||||
# corresponding value in tutorial.js
|
||||
MAX_NAME_LENGTH = 30
|
||||
name = models.CharField(max_length=MAX_NAME_LENGTH, db_index=True)
|
||||
realm = models.ForeignKey(Realm, db_index=True)
|
||||
|
||||
@@ -269,6 +269,8 @@ exports.is_running = function () {
|
||||
|
||||
function make_script() {
|
||||
my_tutorial_stream = 'tutorial-' + page_params.email.split('@')[0];
|
||||
// If you change this, you need to change the corresponding
|
||||
// client-computed version in models.py on the server.
|
||||
my_tutorial_stream = my_tutorial_stream.substring(0, 30);
|
||||
|
||||
script = [
|
||||
|
||||
Reference in New Issue
Block a user