Skip to content

Commit 57bc809

Browse files
authored
Merge pull request #207 from topcoder-platform/feature/Add_new_field_subCategory_to_productTemplates
Added new field subCategory to productTemplates to support Addons
2 parents 5cf210e + b3de8d0 commit 57bc809

File tree

20 files changed

+45
-2
lines changed

20 files changed

+45
-2
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--
2+
-- UPDATE EXISTING TABLES:
3+
-- product_templates:
4+
-- added column `subCategory`
5+
6+
--
7+
-- product_templates
8+
9+
-- Add new column
10+
ALTER TABLE product_templates ADD COLUMN "subCategory" character varying(45);
11+
-- Update new column
12+
UPDATE product_templates SET "subCategory"="category" WHERE "subCategory" is NULL;
13+
-- Set not null
14+
ALTER TABLE product_templates ALTER COLUMN "subCategory" SET NOT NULL;

src/models/productTemplate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = (sequelize, DataTypes) => {
99
name: { type: DataTypes.STRING(255), allowNull: false },
1010
productKey: { type: DataTypes.STRING(45), allowNull: false },
1111
category: { type: DataTypes.STRING(45), allowNull: false },
12+
subCategory: { type: DataTypes.STRING(45), allowNull: false },
1213
icon: { type: DataTypes.STRING(255), allowNull: false },
1314
brief: { type: DataTypes.STRING(45), allowNull: false },
1415
details: { type: DataTypes.STRING(255), allowNull: false },

src/routes/metadata/list.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const productTemplates = [
3030
name: 'name 1',
3131
productKey: 'productKey 1',
3232
category: 'category',
33+
subCategory: 'category',
3334
icon: 'http://example.com/icon1.ico',
3435
brief: 'brief 1',
3536
details: 'details 1',

src/routes/milestoneTemplates/clone.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const productTemplates = [
1414
name: 'name 1',
1515
productKey: 'productKey 1',
1616
category: 'category',
17+
subCategory: 'category',
1718
icon: 'http://example.com/icon1.ico',
1819
brief: 'brief 1',
1920
details: 'details 1',
@@ -47,6 +48,7 @@ const productTemplates = [
4748
name: 'name 2',
4849
productKey: 'productKey 2',
4950
category: 'category',
51+
subCategory: 'category',
5052
icon: 'http://example.com/icon1.ico',
5153
brief: 'brief 2',
5254
details: 'details 2',

src/routes/milestoneTemplates/create.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const productTemplates = [
1515
name: 'name 1',
1616
productKey: 'productKey 1',
1717
category: 'category',
18+
subCategory: 'category',
1819
icon: 'http://example.com/icon1.ico',
1920
brief: 'brief 1',
2021
details: 'details 1',
@@ -48,6 +49,7 @@ const productTemplates = [
4849
name: 'template 2',
4950
productKey: 'productKey 2',
5051
category: 'category',
52+
subCategory: 'category',
5153
icon: 'http://example.com/icon2.ico',
5254
brief: 'brief 2',
5355
details: 'details 2',

src/routes/milestoneTemplates/delete.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const productTemplates = [
4040
name: 'name 1',
4141
productKey: 'productKey 1',
4242
category: 'category',
43+
subCategory: 'category',
4344
icon: 'http://example.com/icon1.ico',
4445
brief: 'brief 1',
4546
details: 'details 1',
@@ -73,6 +74,7 @@ const productTemplates = [
7374
name: 'template 2',
7475
productKey: 'productKey 2',
7576
category: 'category',
77+
subCategory: 'category',
7678
icon: 'http://example.com/icon2.ico',
7779
brief: 'brief 2',
7880
details: 'details 2',

src/routes/milestoneTemplates/get.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const productTemplates = [
1515
name: 'name 1',
1616
productKey: 'productKey 1',
1717
category: 'category',
18+
subCategory: 'category',
1819
icon: 'http://example.com/icon1.ico',
1920
brief: 'brief 1',
2021
details: 'details 1',
@@ -48,6 +49,7 @@ const productTemplates = [
4849
name: 'template 2',
4950
productKey: 'productKey 2',
5051
category: 'category',
52+
subCategory: 'category',
5153
icon: 'http://example.com/icon2.ico',
5254
brief: 'brief 2',
5355
details: 'details 2',

src/routes/milestoneTemplates/list.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const productTemplates = [
1515
name: 'name 1',
1616
productKey: 'productKey 1',
1717
category: 'category',
18+
subCategory: 'category',
1819
icon: 'http://example.com/icon1.ico',
1920
brief: 'brief 1',
2021
details: 'details 1',
@@ -48,6 +49,7 @@ const productTemplates = [
4849
name: 'template 2',
4950
productKey: 'productKey 2',
5051
category: 'category',
52+
subCategory: 'category',
5153
icon: 'http://example.com/icon2.ico',
5254
brief: 'brief 2',
5355
details: 'details 2',

src/routes/milestoneTemplates/update.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const productTemplates = [
1515
name: 'name 1',
1616
productKey: 'productKey 1',
1717
category: 'category',
18+
subCategory: 'category',
1819
icon: 'http://example.com/icon1.ico',
1920
brief: 'brief 1',
2021
details: 'details 1',
@@ -48,6 +49,7 @@ const productTemplates = [
4849
name: 'template 2',
4950
productKey: 'productKey 2',
5051
category: 'category',
52+
subCategory: 'category',
5153
icon: 'http://example.com/icon2.ico',
5254
brief: 'brief 2',
5355
details: 'details 2',

src/routes/phases/create.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ describe('Project Phases', () => {
9797
name: 'name 1',
9898
productKey: 'productKey 1',
9999
category: 'generic',
100+
subCategory: 'generic',
100101
icon: 'http://example.com/icon1.ico',
101102
brief: 'brief 1',
102103
details: 'details 1',

src/routes/productTemplates/create.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const schema = {
1616
param: Joi.object().keys({
1717
id: Joi.any().strip(),
1818
category: Joi.string().max(45).required(),
19+
subCategory: Joi.string().max(45).required(),
1920
name: Joi.string().max(255).required(),
2021
productKey: Joi.string().max(45).required(),
2122
icon: Joi.string().max(255).required(),

src/routes/productTemplates/create.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ describe('CREATE product template', () => {
3535
name: 'name 1',
3636
productKey: 'productKey 1',
3737
category: 'generic',
38+
subCategory: 'generic',
3839
icon: 'http://example.com/icon1.ico',
3940
brief: 'brief 1',
4041
details: 'details 1',

src/routes/productTemplates/delete.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ describe('DELETE product template', () => {
4343
name: 'name 1',
4444
productKey: 'productKey 1',
4545
category: 'generic',
46+
subCategory: 'generic',
4647
icon: 'http://example.com/icon1.ico',
4748
brief: 'brief 1',
4849
details: 'details 1',

src/routes/productTemplates/get.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe('GET product template', () => {
1515
name: 'name 1',
1616
productKey: 'productKey 1',
1717
category: 'generic',
18+
subCategory: 'generic',
1819
icon: 'http://example.com/icon1.ico',
1920
brief: 'brief 1',
2021
details: 'details 1',

src/routes/productTemplates/list.spec.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ import testUtil from '../../tests/util';
1414
const validateProductTemplates = (count, resJson, expectedTemplates) => {
1515
resJson.should.have.length(count);
1616
resJson.forEach((pt, idx) => {
17-
pt.should.have.all.keys('id', 'name', 'productKey', 'category', 'icon', 'brief', 'details', 'aliases',
18-
'template', 'disabled', 'hidden', 'createdBy', 'createdAt', 'updatedBy', 'updatedAt');
17+
pt.should.have.all.keys('id', 'name', 'productKey', 'category', 'subCategory', 'icon', 'brief', 'details',
18+
'aliases', 'template', 'disabled', 'hidden', 'createdBy', 'createdAt', 'updatedBy', 'updatedAt');
1919
pt.should.not.have.all.keys('deletedAt', 'deletedBy');
2020
pt.name.should.be.eql(expectedTemplates[idx].name);
2121
pt.productKey.should.be.eql(expectedTemplates[idx].productKey);
2222
pt.category.should.be.eql(expectedTemplates[idx].category);
23+
pt.subCategory.should.be.eql(expectedTemplates[idx].subCategory);
2324
pt.icon.should.be.eql(expectedTemplates[idx].icon);
2425
pt.brief.should.be.eql(expectedTemplates[idx].brief);
2526
pt.details.should.be.eql(expectedTemplates[idx].details);
@@ -38,6 +39,7 @@ describe('LIST product templates', () => {
3839
name: 'name 1',
3940
productKey: 'productKey-1',
4041
category: 'generic',
42+
subCategory: 'generic',
4143
icon: 'http://example.com/icon1.ico',
4244
brief: 'brief 1',
4345
details: 'details 1',
@@ -73,6 +75,7 @@ describe('LIST product templates', () => {
7375
name: 'template 2',
7476
productKey: 'productKey-2',
7577
category: 'concrete',
78+
subCategory: 'concrete',
7679
icon: 'http://example.com/icon2.ico',
7780
brief: 'brief 2',
7881
details: 'details 2',

src/routes/productTemplates/update.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe('UPDATE product template', () => {
1515
name: 'name 1',
1616
productKey: 'productKey 1',
1717
category: 'generic',
18+
subCategory: 'generic',
1819
icon: 'http://example.com/icon1.ico',
1920
brief: 'brief 1',
2021
details: 'details 1',

src/routes/projectUpgrade/create.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ describe('Project upgrade', () => {
9595
name: 'name 1',
9696
productKey: 'a product key',
9797
category: 'category',
98+
subCategory: 'category',
9899
icon: 'http://example.com/icon1.ico',
99100
brief: 'brief 1',
100101
details: 'details 1',

src/routes/projects/create.spec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe('Project create', () => {
3838
name: 'template 1',
3939
productKey: 'productKey-1',
4040
category: 'generic',
41+
subCategory: 'generic',
4142
icon: 'http://example.com/icon2.ico',
4243
brief: 'brief 1',
4344
details: 'details 1',
@@ -51,6 +52,7 @@ describe('Project create', () => {
5152
name: 'template 2',
5253
productKey: 'productKey-2',
5354
category: 'generic',
55+
subCategory: 'generic',
5456
icon: 'http://example.com/icon2.ico',
5557
brief: 'brief 2',
5658
details: 'details 2',
@@ -64,6 +66,7 @@ describe('Project create', () => {
6466
name: 'template 3',
6567
productKey: 'productKey-3',
6668
category: 'generic',
69+
subCategory: 'generic',
6770
icon: 'http://example.com/icon3.ico',
6871
brief: 'brief 3',
6972
details: 'details 3',

src/routes/timelines/create.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const productTemplates = [
4545
name: 'name 1',
4646
productKey: 'productKey 1',
4747
category: 'generic',
48+
subCategory: 'generic',
4849
icon: 'http://example.com/icon1.ico',
4950
brief: 'brief 1',
5051
details: 'details 1',

src/tests/seed.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ models.sequelize.sync({ force: true })
326326
name: 'name 1',
327327
productKey: 'productKey 1',
328328
category: 'category',
329+
subCategory: 'category',
329330
icon: 'http://example.com/icon1.ico',
330331
question: 'question 1',
331332
info: 'info 1',

0 commit comments

Comments
 (0)