Skip to content

Commit

Permalink
org attributes updated in db and api layer
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmenendez committed Sep 16, 2024
1 parent 9b1bb20 commit de5818a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
14 changes: 13 additions & 1 deletion api/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ func (a *API) updateOrganizationHandler(w http.ResponseWriter, r *http.Request)
org.Description = newOrgInfo.Description
updateOrg = true
}
if newOrgInfo.Size > 0 {
if newOrgInfo.Website != "" {
org.Website = newOrgInfo.Website
updateOrg = true
}
if newOrgInfo.Size != "" {
org.Size = newOrgInfo.Size
updateOrg = true
}
Expand All @@ -191,6 +195,10 @@ func (a *API) updateOrganizationHandler(w http.ResponseWriter, r *http.Request)
org.Logo = newOrgInfo.Logo
updateOrg = true
}
if newOrgInfo.Header != "" {
org.Header = newOrgInfo.Header
updateOrg = true
}
if newOrgInfo.Subdomain != "" {
org.Subdomain = newOrgInfo.Subdomain
updateOrg = true
Expand All @@ -199,6 +207,10 @@ func (a *API) updateOrganizationHandler(w http.ResponseWriter, r *http.Request)
org.Timezone = newOrgInfo.Timezone
updateOrg = true
}
if newOrgInfo.Language != "" {
org.Language = newOrgInfo.Language
updateOrg = true
}
if newOrgInfo.Active != org.Active {
org.Active = newOrgInfo.Active
updateOrg = true
Expand Down
8 changes: 7 additions & 1 deletion api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ import (
type OrganizationInfo struct {
Address string `json:"address"`
Name string `json:"name"`
Website string `json:"website"`
CreatedAt string `json:"createdAt"`
Type string `json:"type"`
Description string `json:"description"`
Size uint64 `json:"size"`
Size string `json:"size"`
Color string `json:"color"`
Logo string `json:"logo"`
Header string `json:"header"`
Subdomain string `json:"subdomain"`
Timezone string `json:"timezone"`
Language string `json:"language"`
Active bool `json:"active"`
Parent *OrganizationInfo `json:"parent"`
}
Expand Down Expand Up @@ -92,14 +95,17 @@ func organizationFromDB(dbOrg, parent *db.Organization) *OrganizationInfo {
return &OrganizationInfo{
Address: dbOrg.Address,
Name: dbOrg.Name,
Website: dbOrg.Website,
CreatedAt: dbOrg.CreatedAt.Format(time.RFC3339),
Type: string(dbOrg.Type),
Description: dbOrg.Description,
Size: dbOrg.Size,
Color: dbOrg.Color,
Logo: dbOrg.Logo,
Header: dbOrg.Header,
Subdomain: dbOrg.Subdomain,
Timezone: dbOrg.Timezone,
Language: dbOrg.Language,
Active: dbOrg.Active,
Parent: parentOrg,
}
Expand Down
5 changes: 4 additions & 1 deletion db/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@ type OrganizationMember struct {
type Organization struct {
Address string `json:"address" bson:"_id"`
Name string `json:"name" bson:"name"`
Website string `json:"website" bson:"website"`
Type OrganizationType `json:"type" bson:"type"`
Creator string `json:"creator" bson:"creator"`
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
Nonce string `json:"nonce" bson:"nonce"`
Description string `json:"description" bson:"description"`
Size uint64 `json:"size" bson:"size"`
Size string `json:"size" bson:"size"`
Color string `json:"color" bson:"color"`
Logo string `json:"logo" bson:"logo"`
Header string `json:"header" bson:"header"`
Subdomain string `json:"subdomain" bson:"subdomain"`
Timezone string `json:"timezone" bson:"timezone"`
Language string `json:"language" bson:"language"`
Active bool `json:"active" bson:"active"`
TokensPurchased uint64 `json:"tokensPurchased" bson:"tokensPurchased"`
TokensRemaining uint64 `json:"tokensRemaining" bson:"tokensRemaining"`
Expand Down

0 comments on commit de5818a

Please sign in to comment.