Skip to content

Commit e5f412c

Browse files
committed
Add License policy label to FlatFile model #215
Signed-off-by: Steven Esser <[email protected]>
1 parent 8569d07 commit e5f412c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

assets/app/js/controllers/scanDataTable.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,13 @@ ScanDataTable.COPYRIGHT_COLUMNS =
567567

568568
ScanDataTable.LICENSE_COLUMNS =
569569
[
570+
{
571+
'data': 'license_policy[<hr/>]',
572+
'title': 'License Policy',
573+
'name': 'license_policy',
574+
'bar_char_class': 'bar-chart-licenses',
575+
'visible': false
576+
},
570577
{
571578
'data': 'license_expressions[<hr/>]',
572579
'title': 'License Expressions',
@@ -886,6 +893,7 @@ ScanDataTable.ORIGIN_COLUMN_NAMES =
886893
[
887894
'copyright_statements',
888895
'license_short_name',
896+
'license_policy',
889897
'license_category',
890898
'email',
891899
'url',
@@ -896,6 +904,7 @@ ScanDataTable.ORIGIN_COLUMN_NAMES =
896904

897905
ScanDataTable.LICENSE_COLUMN_NAMES =
898906
[
907+
'license_policy',
899908
'license_expressions',
900909
'license_key',
901910
'license_score',

assets/app/js/models/flatFile.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module.exports = function(sequelize, DataTypes) {
3131
copyright_authors: jsonDataType('copyright_authors'),
3232
copyright_start_line: jsonDataType('copyright_start_line'),
3333
copyright_end_line: jsonDataType('copyright_end_line'),
34+
license_policy: jsonDataType('license_policy'),
3435
license_expressions: jsonDataType('license_expressions'),
3536
license_key: jsonDataType('license_key'),
3637
license_score: jsonDataType('license_score'),
@@ -135,6 +136,7 @@ module.exports = function(sequelize, DataTypes) {
135136
copyright_authors: getCopyrightValues(file.authors),
136137
copyright_start_line: getValues(file.holders, 'start_line'),
137138
copyright_end_line: getValues(file.holders, 'end_line'),
139+
license_policy: getLicensePolicyLabel(file.license_policy),
138140
license_expressions: file.license_expressions,
139141
license_key: getValues(file.licenses, 'key'),
140142
license_score: getValues(file.licenses, 'score'),
@@ -203,6 +205,15 @@ module.exports = function(sequelize, DataTypes) {
203205
return Model;
204206
};
205207

208+
function getLicensePolicyLabel(policy) {
209+
if (!policy) {
210+
return;
211+
} else if (!policy['label']) {
212+
return;
213+
}
214+
return [policy['label']];
215+
}
216+
206217
function getCopyrightValues(array) {
207218
if (!array) {
208219
array = [];

0 commit comments

Comments
 (0)