Cleanup MIT hardcoding for disabling presence.

This commit is contained in:
Tim Abbott 2016-07-26 17:09:10 -07:00
parent 884f50cdd7
commit c17676b00c
6 changed files with 14 additions and 8 deletions

View File

@ -216,8 +216,8 @@ function filter_and_sort(users) {
exports._filter_and_sort = filter_and_sort;
exports.update_users = function (user_list) {
if (page_params.domain === 'mit.edu') {
return; // MIT realm doesn't have a presence list
if (page_params.presence_disabled) {
return;
}
var users = exports.presence_info;
@ -278,8 +278,8 @@ function actually_update_users_for_search() {
var update_users_for_search = _.throttle(actually_update_users_for_search, 50);
exports.update_huddles = function () {
if (page_params.domain === 'mit.edu') {
return; // MIT realm doesn't have a presence list
if (page_params.presence_disabled) {
return;
}
var section = $('#group-pm-list').expectOne();

View File

@ -488,8 +488,7 @@ $(function () {
$("#edit-message-hotkey-help").hide();
}
// Some MIT-specific customizations
if (page_params.domain === 'mit.edu') {
if (page_params.presence_disabled) {
$("#user-list").hide();
$("#group-pm-list").hide();
}

View File

@ -2653,7 +2653,7 @@ def gather_subscriptions(user_profile):
def get_status_dict(requesting_user_profile):
# type: (UserProfile) -> Dict[text_type, Dict[text_type, Dict[str, Any]]]
# Return no status info for MIT
if requesting_user_profile.realm.domain == 'mit.edu':
if requesting_user_profile.realm.presence_disabled:
return defaultdict(dict)
return UserPresence.get_status_dict_by_realm(requesting_user_profile.realm_id)

View File

@ -188,6 +188,11 @@ class Realm(ModelReprMixin, models.Model):
# TODO: Change return type to QuerySet[UserProfile]
return UserProfile.objects.filter(realm=self, is_active=True).select_related()
@property
def presence_disabled(self):
# type: () -> bool
return self.domain == "mit.edu"
class Meta(object):
permissions = (
('administer', "Administer a realm"),

View File

@ -1525,7 +1525,7 @@ class UserPresenceTests(AuthedTestCase):
def test_no_mit(self):
# type: () -> None
"""MIT never gets a list of users"""
"""Zephyr mirror realms such as MIT never get a list of users"""
self.login("espuser@mit.edu")
result = self.client.post("/json/users/me/presence", {'status': 'idle'})
self.assert_json_success(result)
@ -1796,6 +1796,7 @@ class HomeTest(AuthedTestCase):
"password_auth_enabled",
"people_list",
"poll_timeout",
"presence_disabled",
"product_name",
"prompt_for_invites",
"realm_allow_message_editing",

View File

@ -999,6 +999,7 @@ def home(request):
avatar_url = avatar_url(user_profile),
mandatory_topics = user_profile.realm.mandatory_topics,
show_digest_email = user_profile.realm.show_digest_email,
presence_disabled = user_profile.realm.presence_disabled,
)
if narrow_stream is not None:
# In narrow_stream context, initial pointer is just latest message