diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-03-22 21:15:55 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-03-22 21:25:24 +0100 |
commit | 6e07c3de88791a0b342e0cc319590048117f9c2d (patch) | |
tree | 049f88d3f6d3ec0aeea09702a583deb86d6ef78f /server/initializers | |
parent | 2d7653dc8726185615bab66353c4e3fb8fbb5a5f (diff) | |
download | PeerTube-6e07c3de88791a0b342e0cc319590048117f9c2d.tar.gz PeerTube-6e07c3de88791a0b342e0cc319590048117f9c2d.tar.zst PeerTube-6e07c3de88791a0b342e0cc319590048117f9c2d.zip |
Add video category support
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/constants.js | 24 | ||||
-rw-r--r-- | server/initializers/migrations/0030-video-category.js | 34 |
2 files changed, 57 insertions, 1 deletions
diff --git a/server/initializers/constants.js b/server/initializers/constants.js index 96321b211..6c5287b19 100644 --- a/server/initializers/constants.js +++ b/server/initializers/constants.js | |||
@@ -5,7 +5,7 @@ const path = require('path') | |||
5 | 5 | ||
6 | // --------------------------------------------------------------------------- | 6 | // --------------------------------------------------------------------------- |
7 | 7 | ||
8 | const LAST_MIGRATION_VERSION = 25 | 8 | const LAST_MIGRATION_VERSION = 30 |
9 | 9 | ||
10 | // --------------------------------------------------------------------------- | 10 | // --------------------------------------------------------------------------- |
11 | 11 | ||
@@ -103,6 +103,27 @@ const VIDEO_RATE_TYPES = { | |||
103 | DISLIKE: 'dislike' | 103 | DISLIKE: 'dislike' |
104 | } | 104 | } |
105 | 105 | ||
106 | const VIDEO_CATEGORIES = { | ||
107 | 1: 'Music', | ||
108 | 2: 'Films', | ||
109 | 3: 'Vehicles', | ||
110 | 4: 'Art', | ||
111 | 5: 'Sports', | ||
112 | 6: 'Travels', | ||
113 | 7: 'Gaming', | ||
114 | 8: 'People', | ||
115 | 9: 'Comedy', | ||
116 | 10: 'Entertainment', | ||
117 | 11: 'News', | ||
118 | 12: 'Howto', | ||
119 | 13: 'Education', | ||
120 | 14: 'Activism', | ||
121 | 15: 'Science & Technology', | ||
122 | 16: 'Animals', | ||
123 | 17: 'Kids', | ||
124 | 18: 'Food' | ||
125 | } | ||
126 | |||
106 | // --------------------------------------------------------------------------- | 127 | // --------------------------------------------------------------------------- |
107 | 128 | ||
108 | // Score a pod has when we create it as a friend | 129 | // Score a pod has when we create it as a friend |
@@ -258,6 +279,7 @@ module.exports = { | |||
258 | STATIC_PATHS, | 279 | STATIC_PATHS, |
259 | THUMBNAILS_SIZE, | 280 | THUMBNAILS_SIZE, |
260 | USER_ROLES, | 281 | USER_ROLES, |
282 | VIDEO_CATEGORIES, | ||
261 | VIDEO_RATE_TYPES | 283 | VIDEO_RATE_TYPES |
262 | } | 284 | } |
263 | 285 | ||
diff --git a/server/initializers/migrations/0030-video-category.js b/server/initializers/migrations/0030-video-category.js new file mode 100644 index 000000000..ada95b2fe --- /dev/null +++ b/server/initializers/migrations/0030-video-category.js | |||
@@ -0,0 +1,34 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | const waterfall = require('async/waterfall') | ||
4 | |||
5 | // utils = { transaction, queryInterface, sequelize, Sequelize } | ||
6 | exports.up = function (utils, finalCallback) { | ||
7 | const q = utils.queryInterface | ||
8 | const Sequelize = utils.Sequelize | ||
9 | |||
10 | const data = { | ||
11 | type: Sequelize.INTEGER, | ||
12 | allowNull: false, | ||
13 | defaultValue: 0 | ||
14 | } | ||
15 | |||
16 | waterfall([ | ||
17 | |||
18 | function addCategoryColumn (callback) { | ||
19 | q.addColumn('Videos', 'category', data, { transaction: utils.transaction }).asCallback(function (err) { | ||
20 | return callback(err) | ||
21 | }) | ||
22 | }, | ||
23 | |||
24 | function nullOnDefault (callback) { | ||
25 | data.defaultValue = null | ||
26 | |||
27 | q.changeColumn('Videos', 'category', data, { transaction: utils.transaction }).asCallback(callback) | ||
28 | } | ||
29 | ], finalCallback) | ||
30 | } | ||
31 | |||
32 | exports.down = function (options, callback) { | ||
33 | throw new Error('Not implemented.') | ||
34 | } | ||