Split dictionary-data.sql #804
DB name as argument in db management script
Add Role dictionary to PG #804
Add field permissions dictionary #804

    echo models = > permissions.coffee
    jq -s '[.[] | {name, applications, fields}]' \
      resources/site-config/models/*.js \
      >> permissions.coffee

    sed -i 's/null/\[\]/' permissions.coffee
    sed -i 's/": *true/": \["all"\]/' permissions.coffee

    cat << EOF >> permissions.coffee
    ;
    permission = {}

    set = (obj, path, val) ->
      key = path[0]
      if path.length == 1
        obj[key] = val
      else
        obj[key] ||= {}
        set obj[key], path.splice(1), val

    addPermissions = (model, field, pm) ->
      if pm.canRead
        for role in pm.canRead
          set permission, [role, model, field, 'r'], true
      if pm.canWrite
        for role in pm.canWrite
          set permission, [role, model, field, 'w'], true

    for model in models
      for field in model.fields
        continue if field.groupName
        addPermissions model.name, field.name, field
      for app in model.applications
        for field in app.targets
          addPermissions model.name, field, app

    for roleName, role of permission
      for modelName, model of role
        for fieldName, field of model
          console.log(
            'insert into "FieldPermission" (role, model, field, r, w) values ' +
            "('#{roleName}', '#{modelName}', '#{fieldName}', " +
            (if field.r then 'true' else 'false') + ", " +
            (if field.w then 'true' else 'false') + ");")
    EOF

    coffee -cb permissions.coffee
    node permissions.js
Use FieldPermission dicitonary to filter model fields #804
Normalize models json

for f in {../field-groups.json,*.js} ; do
  jq '.' $f > $f.new
  mv $f.new $f
done
Drop useless index&indexCollate from field-groups
Remove field permissions from json files #804

for f in *.js ; do
  jq '. |
    {name, title
    ,canCreate, canRead, canUpdate, canDelete
    ,applications: .applications | map(select(.meta != null) | {targets,meta})
    ,fields: [.fields[] | {name, groupName, type, meta}]
    }' \
    $f > $f.new
  mv $f.new $f
done
Remove SiteConfig.Permissions
Simplify code a bit
Add missing permissions #804
Bulk load field permissions #804
Add more permissions (for some unused fields) #804
Merge branch 'master' into i804-field-permissions-in-pg

Conflicts:
	database/baseline/3-data/1-dictionary-data.sql
Merge branch 'master' into i804-field-permissions-in-pg

Conflicts:
	srv/resources/site-config/models/partnerCancel.js
Merge pull request #960 from f-me/i804-field-permissions-in-pg

Move fields permissions from JSON to PG #804