forked from zulip/zulip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Users sidebar should show a highlighted buddy list (Backend).
This adds support for displaying a buddy list and adding and removing users to it. The buddy list also displays users in alphabetically increasing order. For moving users to and from buddy list, user handlebar is re-rendered at the appropriate place. A new endpoint has been created which manipulates the buddy list and a backend test for the same has also been added. Fixes: zulip#236.
- Loading branch information
Showing
9 changed files
with
121 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.10.4 on 2017-01-12 12:52 | ||
from __future__ import unicode_literals | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('zerver', '0049_userprofile_pm_content_in_desktop_notifications'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='BuddyList', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('buddy', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='buddy', to=settings.AUTH_USER_MODEL)), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user', to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
migrations.AlterUniqueTogether( | ||
name='buddylist', | ||
unique_together=set([('user', 'buddy')]), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import | ||
from __future__ import print_function | ||
|
||
from zerver.lib.test_classes import ( | ||
ZulipTestCase, | ||
) | ||
|
||
from zerver.models import ( | ||
get_user_profile_by_email, | ||
) | ||
|
||
import ujson | ||
|
||
class BuddyListUpdateTest(ZulipTestCase): | ||
def test_update_buddy_list(self): | ||
# type: () -> None | ||
user_email = "hamlet@zulip.com" | ||
buddy_email = "iago@zulip.com" | ||
|
||
self.login(user_email) | ||
user_profile = get_user_profile_by_email(user_email) | ||
buddy_profile = get_user_profile_by_email(buddy_email) | ||
|
||
result = self.client_patch("/json/users/me/buddy", { | ||
'user_id': ujson.dumps(str(user_profile.id)), | ||
'buddy_id': ujson.dumps(str(buddy_profile.id)), | ||
'should_add': ujson.dumps(str(True)), | ||
}) | ||
self.assert_json_success(result) | ||
|
||
result = self.client_patch("/json/users/me/buddy", { | ||
'user_id': ujson.dumps(str(user_profile.id)), | ||
'buddy_id': ujson.dumps(str(buddy_profile.id)), | ||
'should_add': ujson.dumps(str(False)), | ||
}) | ||
self.assert_json_success(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters