-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add #201 Ability to configure default organisation and types on initi… #203
Add #201 Ability to configure default organisation and types on initi… #203
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Create/update organisation and type
) | ||
|
||
// AddOrganization Adds an organization | ||
func AddOrganization(orgReq config.Organization, userId string) (org.Organization, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this function to organizations.go
file under org
package.
src/middleware/middleware.go
Outdated
common.HandleError(w, http.StatusBadRequest, m, err) | ||
return | ||
} | ||
if count > 1 { | ||
_, err := org.DeleteAllOrganizations() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this logic to main.go
?
|
||
// checking if the string contained whitespace only | ||
if strings.TrimSpace(orgReq.Name) == "" { | ||
log.Printf("Failed to add organization: Missing mandatory param - Name") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Application should exit if organisation configuration is invalid.
@@ -138,7 +138,7 @@ func GetOrganizationByID(w http.ResponseWriter, r *http.Request) { | |||
func GetOrganizationId() (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to org package
@@ -138,7 +138,7 @@ func GetOrganizationByID(w http.ResponseWriter, r *http.Request) { | |||
func GetOrganizationId() (string, error) { | |||
org, err := org.GetOrganization() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this to GetFirstOrganization
src/org/organizations.go
Outdated
@@ -660,3 +660,25 @@ func GetName(organizationID string) (string, error) { | |||
|
|||
return result.Name, err | |||
} | |||
|
|||
// GetOrganizationCount Get organization count | |||
func GetOrganizationCount() (int64, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to GetOrganizationsCount
@@ -138,7 +138,7 @@ func GetOrganizationByID(w http.ResponseWriter, r *http.Request) { | |||
func GetOrganizationId() (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to GetFirstOrganisation
467aed5
to
c04ed48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove all the unused code ?
src/config/config.go
Outdated
} | ||
|
||
type OrgType struct { | ||
Type string `valid:"required"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this to name
src/org/organizations.go
Outdated
return orgResp, err | ||
} | ||
|
||
func IsOrganizationUpdateRequired(org Organization, orgReq config.Organization, typeName string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@albinpa We don't need this anymore ?
src/org/organizations.go
Outdated
} | ||
|
||
// UpdateOrganization Updates an organization | ||
func UpdateOrganization(org Organization, orgReq config.Organization, orgType orgtype.OrgType) (Organization, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@albinpa We don't need this anymore ?
src/orgtype/orgType.go
Outdated
} | ||
|
||
// UpdateOrganizationType Updates an organization type | ||
func UpdateOrganizationType(orgType OrgType, typeReq config.OrgType) (OrgType, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this ?
…on configuration and create/update
c04ed48
to
f0a352a
Compare
…al start of the application if not existing