Add RealmAlias.allow_subdomains to model, frontend, and API.

Includes a database migration.

Fixes #1868.
This commit is contained in:
Harshit Bansal
2017-01-20 23:19:03 -08:00
committed by Tim Abbott
parent a16c48f0c4
commit 7d10cbc32b
15 changed files with 297 additions and 61 deletions

View File

@@ -3616,17 +3616,27 @@ def get_emails_from_user_ids(user_ids):
def get_realm_aliases(realm):
# type: (Realm) -> List[Dict[str, Text]]
return list(realm.realmalias_set.values('domain'))
return list(realm.realmalias_set.values('domain', 'allow_subdomains'))
def do_add_realm_alias(realm, domain):
# type: (Realm, Text) -> (RealmAlias)
alias = RealmAlias.objects.create(realm=realm, domain=domain)
def do_add_realm_alias(realm, domain, allow_subdomains):
# type: (Realm, Text, bool) -> (RealmAlias)
alias = RealmAlias.objects.create(realm=realm, domain=domain,
allow_subdomains=allow_subdomains)
event = dict(type="realm_domains", op="add",
alias=dict(domain=alias.domain,
))
allow_subdomains=alias.allow_subdomains))
send_event(event, active_user_ids(realm))
return alias
def do_change_realm_alias(alias, allow_subdomains):
# type: (RealmAlias, bool) -> None
alias.allow_subdomains = allow_subdomains
alias.save(update_fields=['allow_subdomains'])
event = dict(type="realm_domains", op="change",
alias=dict(domain=alias.domain,
allow_subdomains=alias.allow_subdomains))
send_event(event, active_user_ids(alias.realm))
def do_remove_realm_alias(alias):
# type: (RealmAlias) -> None
realm = alias.realm