M api/graph/generated.go => api/graph/generated.go +1 -9
@@ 22869,7 22869,7 @@ func (ec *executionContext) unmarshalInputOrganizationInput(ctx context.Context,
asMap[k] = v
}
- fieldsInOrder := [...]string{"name", "orgUsername", "image", "defaultPerm"}
+ fieldsInOrder := [...]string{"name", "orgUsername", "image"}
for _, k := range fieldsInOrder {
v, ok := asMap[k]
if !ok {
@@ 22900,14 22900,6 @@ func (ec *executionContext) unmarshalInputOrganizationInput(ctx context.Context,
if err != nil {
return it, err
}
- case "defaultPerm":
- var err error
-
- ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("defaultPerm"))
- it.DefaultPerm, err = ec.unmarshalNInt2int(ctx, v)
- if err != nil {
- return it, err
- }
}
}
M api/graph/model/models_gen.go => api/graph/model/models_gen.go +0 -1
@@ 301,7 301,6 @@ type OrganizationInput struct {
Name string `json:"name"`
OrgUsername string `json:"orgUsername"`
Image *graphql.Upload `json:"image,omitempty"`
- DefaultPerm int `json:"defaultPerm"`
}
type OrganizationStats struct {
M api/graph/schema.graphqls => api/graph/schema.graphqls +0 -1
@@ 597,7 597,6 @@ input OrganizationInput {
name: String!
orgUsername: String!
image: Upload
- defaultPerm: Int!
}
input UpdateOrganizationInput {
M api/graph/schema.resolvers.go => api/graph/schema.resolvers.go +11 -6
@@ 40,7 40,7 @@ import (
"golang.org/x/image/draw"
"golang.org/x/net/idna"
"netlandish.com/x/gobwebs"
- oauth2 "netlandish.com/x/gobwebs-oauth2"
+ "netlandish.com/x/gobwebs-oauth2"
gaccounts "netlandish.com/x/gobwebs/accounts"
"netlandish.com/x/gobwebs/crypto"
"netlandish.com/x/gobwebs/database"
@@ 84,10 84,6 @@ func (r *mutationResolver) AddOrganization(ctx context.Context, input model.Orga
validator.Expect(len(input.OrgUsername) < 150, lt.Translate("Org username may not exceed 150 characters")).
WithField("orgUsername").
WithCode(valid.ErrValidationCode)
- validator.Expect(input.DefaultPerm >= models.OrgLinkVisibilityPublic &&
- input.DefaultPerm <= models.OrgLinkVisibilityPrivate, lt.Translate("Invalid default permission value")).
- WithField("defaultPerm").
- WithCode(valid.ErrValidationCode)
if !validator.Ok() {
return nil, nil
@@ 144,7 140,7 @@ func (r *mutationResolver) AddOrganization(ctx context.Context, input model.Orga
Name: input.Name,
Slug: slug,
IsActive: true,
- Settings: models.OrganizationSettings{DefaultPerm: input.DefaultPerm},
+ Settings: models.OrganizationSettings{DefaultPerm: models.OrgLinkVisibilityPublic},
}
if input.Image != nil {
@@ 1679,6 1675,15 @@ func (r *mutationResolver) UpdateOrganization(ctx context.Context, input *model.
}
if input.DefaultPerm != nil {
+ if org.Settings.Billing.Status == models.BillingStatusFree &&
+ *input.DefaultPerm == models.OrgLinkVisibilityPrivate {
+ validator.Error(lt.Translate(
+ "Free organizations can not use Private permission. Please upgrade to use " +
+ "Private permission")).
+ WithField("defaultPerm").
+ WithCode(valid.ErrValidationCode)
+ return nil, nil
+ }
if *input.DefaultPerm < models.OrgLinkVisibilityPublic ||
*input.DefaultPerm > models.OrgLinkVisibilityPrivate {
validator.Error(lt.Translate("Invalid default permission value")).
M core/inputs.go => core/inputs.go +0 -2
@@ 35,7 35,6 @@ func (p *PlaygroundForm) Validate(c echo.Context) error {
type OrganizationForm struct {
Name string `form:"name" validate:"required"`
OrgUsername string `form:"org_username" validate:"required"`
- DefaultPerm int `form:"default_perm" validate:"number,gte=0"`
}
// Validate ...
@@ 44,7 43,6 @@ func (o *OrganizationForm) Validate(c echo.Context) error {
FailFast(false).
String("name", &o.Name).
String("org_username", &o.OrgUsername).
- Int("default_perm", &o.DefaultPerm).
BindErrors()
if errs != nil {
return validate.GetInputErrors(errs)
M core/routes.go => core/routes.go +1 -3
@@ 897,19 897,17 @@ func (s *Service) OrgCreate(c echo.Context) error {
Org models.Organization `json:"addBusinessOrganization"`
}
op := gqlclient.NewOperation(
- `mutation AddOrganization($name: String!, $image: Upload, $username: String!, $perm: Int!) {
+ `mutation AddOrganization($name: String!, $image: Upload, $username: String!) {
addOrganization(input: {
name: $name,
image: $image,
orgUsername: $username,
- defaultPerm: $perm,
}) {
id
}
}`)
op.Var("name", form.Name)
op.Var("username", form.OrgUsername)
- op.Var("perm", form.DefaultPerm)
image, err := c.FormFile("image")
if err != nil {
M templates/org_create.html => templates/org_create.html +0 -11
@@ 30,17 30,6 @@
{{ end }}
</div>
<div>
- <label for="default_perm">{{.pd.Data.visibility}}</label>
- <select name="default_perm">
- {{range $key, $value := .visibilityOpt}}
- <option value="{{$key}}"{{if eq $key $.form.DefaultPerm}}selected{{end}}>{{$value}}</option>
- {{end}}
- </select>
- {{ with .errors.DefaultPerm }}
- <p class="error">{{ . }}</p>
- {{ end }}
- </div>
- <div>
<label for="image">{{.pd.Data.image}}</label>
<input type="file" name="image" />
{{ with .errors.Image }}