From e22b9f53034280cd3b730c03520469dca4046484 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Mon, 26 Oct 2015 22:11:22 -0700 Subject: Adding new fields to team model --- model/team.go | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'model') diff --git a/model/team.go b/model/team.go index 9da2cd5b2..7f301b71c 100644 --- a/model/team.go +++ b/model/team.go @@ -17,16 +17,19 @@ const ( ) type Team struct { - Id string `json:"id"` - CreateAt int64 `json:"create_at"` - UpdateAt int64 `json:"update_at"` - DeleteAt int64 `json:"delete_at"` - DisplayName string `json:"display_name"` - Name string `json:"name"` - Email string `json:"email"` - Type string `json:"type"` - CompanyName string `json:"company_name"` - AllowedDomains string `json:"allowed_domains"` + Id string `json:"id"` + CreateAt int64 `json:"create_at"` + UpdateAt int64 `json:"update_at"` + DeleteAt int64 `json:"delete_at"` + DisplayName string `json:"display_name"` + Name string `json:"name"` + Email string `json:"email"` + Type string `json:"type"` + CompanyName string `json:"company_name"` + AllowedDomains string `json:"allowed_domains"` + InviteId string `json:"invite_id"` + AllowOpenInvite bool `json:"allow_open_invite"` + AllowTeamListing bool `json:"allow_team_listing"` } type Invites struct { @@ -147,6 +150,10 @@ func (o *Team) IsValid(restrictTeamNames bool) *AppError { return NewAppError("Team.IsValid", "Invalid allowed domains", "id="+o.Id) } + if len(o.InviteId) > 0 && len(o.InviteId) != 26 { + return NewAppError("Team.IsValid", "Invalid inviate Id", "") + } + return nil } -- cgit v1.2.3-1-g7c22 From bb25056d9afca501f147450466aaeecca9fef66f Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 27 Oct 2015 22:18:52 -0700 Subject: PLT-340 --- model/client.go | 4 ++-- model/config.go | 6 ++++++ model/team.go | 10 +++++----- 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'model') diff --git a/model/client.go b/model/client.go index 4d2c49e70..9232bac5b 100644 --- a/model/client.go +++ b/model/client.go @@ -211,8 +211,8 @@ func (c *Client) InviteMembers(invites *Invites) (*Result, *AppError) { } } -func (c *Client) UpdateTeamDisplayName(data map[string]string) (*Result, *AppError) { - if r, err := c.DoApiPost("/teams/update_name", MapToJson(data)); err != nil { +func (c *Client) UpdateTeam(team *Team) (*Result, *AppError) { + if r, err := c.DoApiPost("/teams/update", team.ToJson()); err != nil { return nil, err } else { return &Result{r.Header.Get(HEADER_REQUEST_ID), diff --git a/model/config.go b/model/config.go index 216b1de86..50a8dc133 100644 --- a/model/config.go +++ b/model/config.go @@ -123,6 +123,7 @@ type TeamSettings struct { EnableUserCreation bool RestrictCreationToDomains string RestrictTeamNames *bool + EnableTeamListing *bool } type Config struct { @@ -175,6 +176,11 @@ func (o *Config) SetDefaults() { o.TeamSettings.RestrictTeamNames = new(bool) *o.TeamSettings.RestrictTeamNames = true } + + if o.TeamSettings.EnableTeamListing == nil { + o.TeamSettings.EnableTeamListing = new(bool) + *o.TeamSettings.EnableTeamListing = false + } } func (o *Config) IsValid() *AppError { diff --git a/model/team.go b/model/team.go index 7f301b71c..4d14ec2ee 100644 --- a/model/team.go +++ b/model/team.go @@ -122,7 +122,7 @@ func (o *Team) IsValid(restrictTeamNames bool) *AppError { return NewAppError("Team.IsValid", "Invalid email", "id="+o.Id) } - if len(o.DisplayName) > 64 { + if len(o.DisplayName) == 0 || len(o.DisplayName) > 64 { return NewAppError("Team.IsValid", "Invalid name", "id="+o.Id) } @@ -150,10 +150,6 @@ func (o *Team) IsValid(restrictTeamNames bool) *AppError { return NewAppError("Team.IsValid", "Invalid allowed domains", "id="+o.Id) } - if len(o.InviteId) > 0 && len(o.InviteId) != 26 { - return NewAppError("Team.IsValid", "Invalid inviate Id", "") - } - return nil } @@ -164,6 +160,10 @@ func (o *Team) PreSave() { o.CreateAt = GetMillis() o.UpdateAt = o.CreateAt + + if len(o.InviteId) == 0 { + o.InviteId = NewId() + } } func (o *Team) PreUpdate() { -- cgit v1.2.3-1-g7c22