diff --git a/.gitignore b/.gitignore index 0213dbd..18a7ec6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ .DS_Store +httpd-app.conf +npm-debug.log public/.DS_Store node_modules bower_components -server/config/config.js \ No newline at end of file +server/config/config.js +.idea \ No newline at end of file diff --git a/package.json b/package.json index abb17d8..18c02ce 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,11 @@ "dependencies": { "angular-video-time": "^1.0.0", "body-parser": "^1.12.4", + "connect-redis": "^3.1.0", "connect-session-sequelize": "^2.3.0", "cookie-parser": "^1.3.5", "express": "^4.12.4", - "express-session": "^1.11.2", + "express-session": "^1.14.2", "jade": "^1.10.0", "moment": "^2.10.6", "moment-timezone": "^0.4.0", @@ -27,7 +28,8 @@ }, "scripts": { "test": "node_modules/mocha/bin/mocha", - "start": "node server.js" + "start": "node server.js", + "sync": "node cli/sync.js" }, "repository": { "type": "git", diff --git a/public/.DS_Store b/public/.DS_Store index 5cde2d0..4401bbf 100644 Binary files a/public/.DS_Store and b/public/.DS_Store differ diff --git a/public/app/issues/checking.jade b/public/app/issues/checking.jade index 771e4b6..526c358 100644 --- a/public/app/issues/checking.jade +++ b/public/app/issues/checking.jade @@ -14,6 +14,8 @@ .panel-heading.text-center {{ctrl.lesson.languageSery.title + " #" + ctrl.lesson.number + " - " + ctrl.lesson.title}} .panel-body.text-center video-player(config="ctrl.config") +.container.text-right + a(href="{{ctrl.lesson.qaUrl}}") Watch on Dropbox .container(ng-show="ctrl.identity.isAdmin()") .btn-group(role="group") button.btn.btn-default(ng-hide="ctrl.lesson.checkedLanguage", type="button", ng-click="ctrl.markAsLanguageApproved()") Mark as Language Approved diff --git a/public/app/languageSeries/language-series-details.jade b/public/app/languageSeries/language-series-details.jade index e4a5f7d..3a44abb 100644 --- a/public/app/languageSeries/language-series-details.jade +++ b/public/app/languageSeries/language-series-details.jade @@ -9,4 +9,14 @@ h1 a(href="#", editable-text="languageSeries.title", onbeforesave="update({title: $data})") {{languageSeries.title}} .container-fluid - lessons-list(config="lessonsConfig") \ No newline at end of file + lessons-list(config="lessonsConfig") + .col-sm-6 + .panel.panel-default(ng-show="identity.isAdmin()") + .panel-heading + h3.panel-title Create Lessons in Series + .panel-body + .input-group + select.form-control(ng-model="newLessons.selectedNumber") + option(ng-repeat="number in newLessons.possibleValues", value="{{number}}") {{number}} + span.input-group-btn + button.btn.btn-default(type="button", ng-click="createNewLessons()") Add {{newLessons.selectedNumber}} Lessons \ No newline at end of file diff --git a/public/app/languageSeries/vtmsLanguageSeriesDetailsController.js b/public/app/languageSeries/vtmsLanguageSeriesDetailsController.js index 5c764db..82c9fed 100644 --- a/public/app/languageSeries/vtmsLanguageSeriesDetailsController.js +++ b/public/app/languageSeries/vtmsLanguageSeriesDetailsController.js @@ -1,4 +1,6 @@ -angular.module('vtms').controller('vtmsLanguageSeriesDetailController', function($scope, vtmsLanguageSeries, vtmsLesson, $routeParams, vtmsNotifier) { +angular.module('vtms').controller('vtmsLanguageSeriesDetailController', function($scope, vtmsLanguageSeries, vtmsGlobalTask, vtmsLesson, vtmsTask, $routeParams, vtmsNotifier, vtmsIdentity) { + + $scope.identity = vtmsIdentity.currentUser; $scope.sortOptions = [ {value: "number", text: "Sort by Number"}, @@ -8,7 +10,9 @@ angular.module('vtms').controller('vtmsLanguageSeriesDetailController', function $scope.selectedSortOption = $scope.sortOptions[0].value; - $scope.languageSeries = vtmsLanguageSeries.get({id: $routeParams.id}); + $scope.languageSeries = vtmsLanguageSeries.get({id: $routeParams.id}, function(languageSeries) { + $scope.globalTaskList = vtmsGlobalTask.getListForSeries({id: languageSeries.fkSeries}); + }); $scope.lessonsConfig = { title: 'Lessons', @@ -39,6 +43,42 @@ angular.module('vtms').controller('vtmsLanguageSeriesDetailController', function } }; + $scope.globalTaskList = + + $scope.newLessons = { + selectedNumber: 0, + currentMaxNumber: 0, + possibleValues: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 50, 100] + }; + + $scope.createNewLessons = function() { + if($scope.newLessons.selectedNumber > 0) { + console.log($scope.globalTaskList); + vtmsLesson.getList({id: $routeParams.id}, function(list) { + var maxLesson = list.length; + + for(var i = 0; i < $scope.newLessons.selectedNumber; i++) { + + var lessonNumber = i + maxLesson + 1; + var newLesson = new vtmsLesson({fkLanguageSeries: $routeParams.id, number: lessonNumber, title: "Lesson " + lessonNumber}); + newLesson.$save().then(function(lesson) { + var taskList = $scope.globalTaskList; + for (var j = 0; j < taskList.length; j++) { + var newTask = new vtmsTask({fkLesson: lesson.id, fkTaskGlobal: taskList[j].id, fkTeamMember: taskList[j].defaultTeamMember}); + newTask.$save(); + } + + console.log("Lesson created!"); + console.log(lesson); + }); + } + vtmsNotifier.success("Create " + $scope.newLessons.selectedNumber + " lessons in this language series"); + }); + } else { + vtmsNotifier.error("Please select a number greater than 0 to create a language series."); + } + } + $scope.update = function(newData) { angular.extend($scope.languageSeries, newData); @@ -54,4 +94,4 @@ angular.module('vtms').controller('vtmsLanguageSeriesDetailController', function }); }; -}); +}); \ No newline at end of file diff --git a/public/app/publishDates/publish-dates-list.jade b/public/app/publishDates/publish-dates-list.jade index fe9bfa1..c2b6b0a 100644 --- a/public/app/publishDates/publish-dates-list.jade +++ b/public/app/publishDates/publish-dates-list.jade @@ -25,8 +25,8 @@ th(ng-show="config.columns.actions && identity.isLoggedIn()") Actions th(ng-show="config.columns.series") Series th(ng-show="config.columns.number") Number - th(ng-show="config.columns.title") Title th(ng-show="config.columns.shortLesson") Lesson + th(ng-show="config.columns.title") Title th(ng-show="config.columns.platform") Platform th(ng-show="config.columns.date") Publish Date th(ng-show="config.columns.date && identity.isAdmin()") Edit @@ -47,10 +47,10 @@ a(href="#", ng-click="delete(publishDate)") Delete td(ng-show="config.columns.series") {{publishDate.lesson.languageSery.title}} td(ng-show="config.columns.number") {{publishDate.lesson.number}} - td(ng-show="config.columns.title") - a(ng-href="/lesson/{{publishDate.lesson.id}}") {{publishDate.lesson.title}} td(ng-show="config.columns.shortLesson") a(href="/lesson/{{publishDate.lesson.id}}") {{publishDate.lesson.languageSery.language.name}} {{publishDate.lesson.languageSery.series.title}} ({{publishDate.lesson.languageSery.level.code}}) {{"#" + publishDate.lesson.number}} + td(ng-show="config.columns.title") + a(ng-href="/lesson/{{publishDate.lesson.id}}") {{publishDate.lesson.title}} td(ng-show="config.columns.platform") {{publishDate.platform.name }} td(ng-show="config.columns.date") {{publishDate.date | date: 'EEE, MMM d, yyyy'}} td(ng-show="config.columns.date && identity.isAdmin()") @@ -74,6 +74,7 @@ select(ng-model="newDateValues.fkPlatform") option(value="1") pod101 option(value="2") youtube + option(value="3") facebook td(ng-show="config.columns.date") td(ng-show="config.columns.date && identity.isAdmin()") td(ng-show="config.columns.deliveredOn") diff --git a/public/app/publishDates/vtmsPublishingReadyController.js b/public/app/publishDates/vtmsPublishingReadyController.js index c0076e9..575e1f7 100644 --- a/public/app/publishDates/vtmsPublishingReadyController.js +++ b/public/app/publishDates/vtmsPublishingReadyController.js @@ -17,6 +17,7 @@ angular.module('vtms').controller('vtmsPublishingReadyController', function($sco }, columns: { actions: true, + title: true, shortLesson: true, platform: true, date: true, diff --git a/server/config/express.js b/server/config/express.js index 00d74b7..9c0b52b 100644 --- a/server/config/express.js +++ b/server/config/express.js @@ -7,7 +7,7 @@ var express = require('express'), passport = require('passport'), shortid = require('shortid'); -var SequelizeStore = require('connect-session-sequelize')(session.Store); +var RedisStore = require('connect-redis')(session); module.exports = function(app, config) { app.set('view engine', 'jade'); @@ -25,8 +25,10 @@ module.exports = function(app, config) { return shortid.generate(); }, cookie: {}, - store: new SequelizeStore({ - db: sequelize + store: new RedisStore({ + //host: 'localhost', + //port: 9382 + socket: '/opt/bitnami/redis/var/run/redis.sock' }) })); app.use(passport.initialize()); diff --git a/server/controllers/lesson.js b/server/controllers/lesson.js index a879ebd..6ac4173 100644 --- a/server/controllers/lesson.js +++ b/server/controllers/lesson.js @@ -1,6 +1,7 @@ -var models = require('../models/models'); +'use strict'; +let models = require('../models/models'); -var getList = function(req, res, query) { +let getList = function(req, res, query) { models.Lesson.findAll(query).then(function(lessons) { if(lessons) { res.send(lessons); @@ -29,7 +30,7 @@ exports.getLessons = function (req, res) { if (lessons) { res.send(lessons); } else { - res.send(404).send({error: "No lessons found."}); + res.send(404).send({error: 'No lessons found.'}); } }).catch(function (err) { res.status(500).send({error: err}); @@ -45,7 +46,7 @@ exports.getLessonById = function (req, res) { if (lesson) { res.send(lesson); } else { - res.status(404).send({error: "There is no lesson with that ID."}); + res.status(404).send({error: 'There is no lesson with that ID.'}); } }).catch(function(err) { res.status(500).send({error: err}); @@ -58,7 +59,7 @@ exports.createNewLesson = function (req, res) { return res.send(lesson); }).catch(function(err) { res.status(400); - return res.send({reason: err.errors[0].message}); + return res.send({reason: err}); }); }; @@ -81,7 +82,7 @@ exports.getLessonsWithUnassignedIssues = function (req, res) { if (lessons) { res.send(lessons); } else { - res.status(404).send({error: "No pending unclassified issues."}) + res.status(404).send({error: 'No pending unclassified issues.'}); } }).catch(function(err) { res.status(500).send({error: err}); @@ -120,7 +121,7 @@ exports.getUpcomingLessons = function (req, res) { if (lessons) { res.send(lessons); } else { - res.send(404).send({error: "No lessons found."}); + res.send(404).send({error: 'No lessons found.'}); } }).catch(function (err) { res.status(500).send({error: err}); @@ -145,7 +146,7 @@ exports.getQaLessons = function (req, res) { if (lessons) { res.send(lessons); } else { - res.send(404).send({error: "No lessons found."}); + res.send(404).send({error: 'No lessons found.'}); } }).catch(function (err) { res.status(500).send({error: err}); @@ -178,7 +179,7 @@ exports.getVideoCheckableLessons = function (req, res) { } res.send(checkableLessons); } else { - res.status(404).send({error: "No lessons found."}); + res.status(404).send({error: 'No lessons found.'}); } }).catch(function (err) { res.status(500).send(err); @@ -203,7 +204,7 @@ exports.getArchiveableLessons = function (req, res) { if (lessons) { res.send(lessons); } else { - res.send(404).send({error: "No lessons found."}); + res.send(404).send({error: 'No lessons found.'}); } }).catch(function (err) { res.status(500).send({error: err}); @@ -224,7 +225,7 @@ exports.getQueuedLessons = function (req, res) { if (lessons.length > 0) { res.send(lessons); } else { - res.status(404).send({error: "No lessons found."}); + res.status(404).send({error: 'No lessons found.'}); } }).catch(function (err) { res.status(500).send({error: err}); @@ -238,7 +239,7 @@ exports.deleteLesson = function (req, res) { res.status(200).end(); }); } else { - res.status(404).send({error: "No lesson was found with that ID."}) + res.status(404).send({error: 'No lesson was found with that ID.'}); } }).catch(function(err) { res.status(500).send({error: err}); @@ -264,7 +265,7 @@ exports.getReadyToRenderLessons = function (req, res) { var renderQueueLessons = []; for(var i = 0; i < lessons.length; i++) { // Cannot insert value as null, so this catches lessons that were unqueued - if(lessons[i].queuedTime === '0000-00-00 00:00:00') lessons[i].queuedTime = null; + if(lessons[i].queuedTime === '0000-00-00 00:00:00') { lessons[i].queuedTime = null; } if(lessons[i].lastTaskTime > lessons[i].queuedTime || lessons[i].lastIssueTime > lessons[i].queuedTime || lessons[i].queuedTime === '0000-00-00 00:00:00') { if(lessons[i].checkedLanguage) { // if it's checked language, then we shouldn't export again until all tasks are completed @@ -278,7 +279,7 @@ exports.getReadyToRenderLessons = function (req, res) { } res.send(renderQueueLessons); } else { - res.status(404).send({error: "No lessons found."}); + res.status(404).send({error: 'No lessons found.'}); } }).catch(function (err) { res.status(500).send(err); @@ -335,4 +336,4 @@ exports.getLessonsForTeamMemberWithIssues = function(req, res) { } ] }); -}; +}; \ No newline at end of file diff --git a/server/controllers/publishDate.js b/server/controllers/publishDate.js index a5e936f..91113f2 100644 --- a/server/controllers/publishDate.js +++ b/server/controllers/publishDate.js @@ -129,7 +129,24 @@ exports.getReadyToDeliverPublishDates = function(req, res) { }) .then(function(publishDates) { if(publishDates) { - res.send(publishDates); + // for each youtube publish date + // check to see if there is a site publish date + // if so, hide the youtube publish date + var siteReadyToPublishLessons = []; + publishDates.forEach(function(publishDate) { + if (publishDate.platform.name === 'pod101') { + siteReadyToPublishLessons.push(publishDate.lesson.id); + } + }); + publishDates.forEach(function(publishDate) { + for (var i = 0; i < siteReadyToPublishLessons.length; i++) { + if (publishDate.lesson.id === siteReadyToPublishLessons[i] && publishDate.platform.name == 'youtube') { + publishDate.lesson.title = "**Publish on Site First** " + publishDate.lesson.title; + console.log('Lesson with id ' + publishDate.lesson.id + ' has a YouTube publish date, removing site publish date...'); + } + } + }); + res.send(publishDates); } else { res.status(404).send({error: 'No publish dates were found.'}); }