Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
145fbf50
Commit
145fbf50
authored
10 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Add validity checks for Field.field_type in Clojure land; remove "None"
option from UI
parent
e119e73d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
resources/frontend_client/app/services.js
+10
-13
10 additions, 13 deletions
resources/frontend_client/app/services.js
src/metabase/models/field.clj
+23
-9
23 additions, 9 deletions
src/metabase/models/field.clj
with
33 additions
and
22 deletions
resources/frontend_client/app/services.js
+
10
−
13
View file @
145fbf50
...
...
@@ -52,31 +52,31 @@ CorvusServices.factory('AppState', ['$rootScope', '$routeParams', '$q', '$locati
service
.
model
.
currentUser
=
result
;
// add isMember(orgSlug) method to the object
service
.
model
.
currentUser
.
isMember
=
function
(
orgSlug
)
{
return
this
.
org_perms
.
some
(
function
(
org_perm
)
{
service
.
model
.
currentUser
.
isMember
=
function
(
orgSlug
)
{
return
this
.
org_perms
.
some
(
function
(
org_perm
)
{
return
org_perm
.
organization
.
slug
===
orgSlug
;
});
};
// add isAdmin(orgSlug) method to the object
service
.
model
.
currentUser
.
isAdmin
=
function
(
orgSlug
)
{
return
this
.
org_perms
.
some
(
function
(
org_perm
)
{
service
.
model
.
currentUser
.
isAdmin
=
function
(
orgSlug
)
{
return
this
.
org_perms
.
some
(
function
(
org_perm
)
{
return
org_perm
.
organization
.
slug
===
orgSlug
&&
org_perm
.
admin
;
})
||
this
.
is_superuser
;
};
// add memberOf() method to the object enumerating Organizations user is member of
service
.
model
.
currentUser
.
memberOf
=
function
()
{
return
this
.
org_perms
.
map
(
function
(
org_perm
)
{
service
.
model
.
currentUser
.
memberOf
=
function
()
{
return
this
.
org_perms
.
map
(
function
(
org_perm
)
{
return
org_perm
.
organization
;
});
};
// add adminOf() method to the object enumerating Organizations user is admin of
service
.
model
.
currentUser
.
adminOf
=
function
()
{
return
this
.
org_perms
.
filter
(
function
(
org_perm
)
{
service
.
model
.
currentUser
.
adminOf
=
function
()
{
return
this
.
org_perms
.
filter
(
function
(
org_perm
)
{
return
org_perm
.
admin
;
}).
map
(
function
(
org_perm
)
{
}).
map
(
function
(
org_perm
)
{
return
org_perm
.
organization
;
});
};
...
...
@@ -417,9 +417,6 @@ CorvusServices.service('CorvusCore', ['$resource', 'User', function($resource, U
'
name
'
:
'
Zip Code
'
}];
this
.
field_field_types
=
[{
'
id
'
:
null
,
'
name
'
:
'
None
'
},
{
'
id
'
:
'
info
'
,
'
name
'
:
'
Information
'
},
{
...
...
@@ -831,4 +828,4 @@ CoreServices.factory('PermissionViolation', ['$resource', '$cookies', function($
},
});
}]);
}]);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/metabase/models/field.clj
+
23
−
9
View file @
145fbf50
(
ns
metabase.models.field
(
:require
[
korma.core
:refer
:all
]
[
metabase.api.common
:refer
[
check
]]
[
metabase.db
:refer
:all
]
(
metabase.models
[
database
:refer
[
Database
]])
[
metabase.util
:as
util
]))
...
...
@@ -62,25 +63,38 @@
:dimension
:info
})
(
defn-
check-valid-field-type
"Assert that FIELD-TYPE is valid value for `Field.field_type`, or throw a 400."
[
field-type
]
(
check
(
contains?
field-types
(
keyword
field-type
))
[
400
(
format
"Invalid field_type: '%s'"
(
when
field-type
(
name
field-type
)))]))
(
defentity
Field
(
table
:metabase_field
))
(
defmethod
post-select
Field
[
_
{
:keys
[
table_id
]
:as
field
}]
(
util/assoc*
field
:table
(
delay
(
sel
:one
'metabase.models.table/Table
:id
table_id
))
:db
(
delay
@
(
:db
@
(
:table
<>
)))
:can_read
(
delay
@
(
:can_read
@
(
:table
<>
)))
:can_write
(
delay
@
(
:can_write
@
(
:table
<>
)))))
:table
(
delay
(
sel
:one
'metabase.models.table/Table
:id
table_id
))
:db
(
delay
@
(
:db
@
(
:table
<>
)))
:can_read
(
delay
@
(
:can_read
@
(
:table
<>
)))
:can_write
(
delay
@
(
:can_write
@
(
:table
<>
)))))
(
defmethod
pre-insert
Field
[
_
field
]
(
let
[
defaults
{
:created_at
(
util/new-sql-timestamp
)
:updated_at
(
util/new-sql-timestamp
)
:active
true
(
let
[
defaults
{
:created_at
(
util/new-sql-timestamp
)
:updated_at
(
util/new-sql-timestamp
)
:active
true
:preview_display
true
:field_type
:info
:position
0
}]
:field_type
:info
:position
0
}]
(
let
[{
:keys
[
field_type
base_type
special_type
]
:as
field
}
(
merge
defaults
field
)]
(
check-valid-field-type
field_type
)
(
assoc
field
:base_type
(
name
base_type
)
:special_type
(
when
special_type
(
name
special_type
))
:field_type
(
name
field_type
)))))
(
defmethod
pre-update
Field
[
_
field
]
(
when
(
contains?
field
:field_type
)
(
check-valid-field-type
(
:field_type
field
)))
field
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment