Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions client/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ngAnimate from 'angular-animate';
import ngCookies from 'angular-cookies';
import ngResource from 'angular-resource';
import ngSanitize from 'angular-sanitize';
import ngSweetAlert from 'angular-sweetalert';
import 'angular-socket-io';
const ngRoute = require('angular-route');

Expand Down Expand Up @@ -65,21 +66,21 @@ import courseform from '../components/courseform/courseform.directive';
import pictureBanner from '../components/pictureBanner/pictureBanner.directive';
import eventForm from '../components/eventform/eventform.module'


import './app.less';

angular.module('venueApp', [
ngCookies,
ngResource, ngSanitize, 'btford.socket-io', ngRoute,
uiBootstrap,
ngAnimate, ngMessages, ngValidationMatch,
ngFileUpload, ngCsv,
ngFileUpload,ngCsv,
//
'geolocation',
'dibari.angular-ellipsis',
'ui.bootstrap.datetimepicker',
'uiGmapgoogle-maps',

'oitozero.ngSweetAlert',

_CourseFactory,
_SectionEventFactory,
_EventInfoFactory,
Expand Down
1 change: 1 addition & 0 deletions client/app/app.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import '~bootstrap/less/bootstrap.less';
@import '~bootstrap-social/bootstrap-social.less';
@import '~font-awesome/less/font-awesome.less';
@import '../../node_modules/sweetalert/dist/sweetalert.css';

@colorPurple: #911BC4;
@colorBlue: #1DAEEB;
Expand Down
2 changes: 1 addition & 1 deletion client/app/courses/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import search from './search';
import sections from './sections';
import view from './view';

export default angular.module('venueApp.courses', ['venueApp.auth', 'venueApp.CourseFactory', ngRoute, edit, search, sections, view ])
export default angular.module('venueApp.courses', ['venueApp.auth', 'venueApp.CourseFactory', ngRoute, edit, search, sections, view , 'oitozero.ngSweetAlert'])
.config(routing)
.name;
31 changes: 30 additions & 1 deletion client/app/courses/view/courseview.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
export default class CourseViewCtrl {

/*@ngInject*/
constructor($scope, $location, $http, $routeParams, Auth, User, Course, Section) {
constructor($scope, $location, $http, $routeParams, Auth, User, Course, Section,SweetAlert){
$scope.isStudent = false;
$scope.isInstructor = false;
$scope.same_creator = false;
$scope.once = 1;
var creator;
Auth.getCurrentUser((user) => {
$scope.user = user;
if (user.hasOwnProperty('role')){
Expand All @@ -27,6 +30,29 @@ export default class CourseViewCtrl {
$scope.editCourse = function(){
return "/courses/"+ $routeParams.id + "/edit";
};
$scope.deleteCourse = function(){

var courseid = $routeParams.id;
SweetAlert.swal({
title: "Are you sure?",
text: "Your will not be able to recover this course!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",confirmButtonText: "Yes, delete the course!",
cancelButtonText: "Cancel",
closeOnConfirm: false,
closeOnCancel: false },
function(isConfirm){
if (isConfirm) {
SweetAlert.swal("Deleted!", "Your course has been deleted.", "success");
Course.delete({id: courseid}, (res) => {
$location.path("/instructor/dashboard");
})
} else {
SweetAlert.swal("Cancelled", "Course is not deleted.", "error");
}
});
};

$scope.editSection = function(section){
return "/courses/"+ $routeParams.id + "/sections/" + section._id + "/edit"
Expand Down Expand Up @@ -55,6 +81,9 @@ export default class CourseViewCtrl {
}, course => {
$scope.course = course;
$scope.coursesLoaded = true;
if($scope.course.creator == $scope.user._id){
$scope.same_creator = true;
}
}, () =>{
$location.path('/courses')
});
Expand Down
1 change: 1 addition & 0 deletions client/app/courses/view/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

import CourseViewCtrl from './courseview.controller';
import ngSweetAlert from 'angular-sweetalert';

export default angular.module('venueApp.courseview', ['venueApp.auth', 'venueApp.CourseFactory','venueApp.SectionFactory', 'directives.courseTitleBanner'])
.controller('CourseViewCtrl', CourseViewCtrl)
Expand Down
7 changes: 6 additions & 1 deletion client/components/courseform/courseform.controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
export function CourseFormCtrl ($scope, Course, Upload){
export function CourseFormCtrl ($scope, Course, Upload, Auth, $routeParams){
"ngInject";
$scope.courseCreated = false;
$scope.submitForm = (form)=>{
Expand All @@ -21,6 +21,10 @@ export function CourseFormCtrl ($scope, Course, Upload){
}else{
// promise = Course.create($scope.course).$promise;
$scope.course.files = [$scope.file];
Auth.getCurrentUser().then((user)=>{
$scope.course.creator = user._id;
});

promise = Upload.upload({
url: '/api/courses/',
data: $scope.course,
Expand All @@ -47,4 +51,5 @@ export function CourseFormCtrl ($scope, Course, Upload){
});
}
};

};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"angular-sanitize": "~1.5.5",
"angular-simple-logger": "^0.1.7",
"angular-socket-io": "~0.7.0",
"angular-sweetalert": "^1.1.2",
"angular-ui-bootstrap": "^2.0.1",
"angular-validation-match": "^1.9.0",
"angularjs-geolocation": "^0.1.3",
Expand Down Expand Up @@ -65,6 +66,7 @@
"ng-annotate": "^1.2.1",
"ng-csv": "^0.3.6",
"ng-file-upload": "^12.0.4",
"ng-sweet-alert": "^1.0.11",
"node-uuid": "^1.4.7",
"node-zopfli": "^2.0.1",
"nodemailer": "^2.5.0",
Expand Down
40 changes: 37 additions & 3 deletions server/api/course/course.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import _ from 'lodash';
import Course from './course.model';
import Section from '../section/section.model.js';
import fs from 'fs';
import mkdirp from 'mkdirp';
import config from '../../config/environment';
Expand Down Expand Up @@ -137,6 +138,7 @@ export function create(req: $ExtRequest, res: $Response) {
else{
course.semester = "Fall" + (date.getFullYear() - 100).toString();
}
course.creator = req.user._id;
Course.createAsync(course)
.then(responseWithResult(res, 201))
.catch(handleError(res));
Expand Down Expand Up @@ -174,9 +176,31 @@ export function update(req: $Request, res: $Response) {
export function destroy(req: $Request, res: $Response) {
Course.findByIdAsync(req.params.id)
.then(handleEntityNotFound(res))
.then(removeEntity(res))
.catch(handleError(res));
};
.then((course)=>{
Section.findAsync({course: course._id})
.then(handleEntityNotFound(res))
.then((sections)=>{
var events;
sections.forEach(section=>{
section.getSectionEventsAsync()
.then((received_events)=>{
received_events.forEach(secEvent=>{
secEvent.fullRemove();
})
received_events.remove(function(err,section){
if(err) handleError(res);
})
}).catch(handleError)
section.remove(function(err,section){
if(err) handleError(res);
})
})
return null;
}).catch(handleError(res))
return course;
}).then(removeEntity(res))
.catch(handleError(res));
};

export function image(req: $Request, res: $Response){
// Prevents requesting arbitary files from the server
Expand All @@ -199,3 +223,13 @@ export function imageSize(req: $Request, res: $Response){
req.query.size = req.params.size;
return exports.image(req, res);
};
export function check(req: $Request, res: $Response){
Course.findByIdAsync(req.params.courseid,'creator')
.then((course)=>{
var is_creator = course.checkCreator(req.params.studentid);
return
})
.catch(function(err){
handleEntityNotFound(res);
})
};
12 changes: 11 additions & 1 deletion server/api/course/course.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,32 @@ var Schema = mongoose.Schema;

import Section from '../section/section.model';
import async from 'async';
import User from '../user/user.model';

var CourseSchema = new Schema({
name: String,
department: String,
courseNumber: Number,
creator: {type:Schema.Types.ObjectId, ref: 'User'},
description: String,
semester: String,
active: Boolean,
imageURLs: [String]
imageURLs: [String],
deleted: Boolean
});

/**
* Methods
*/
CourseSchema.methods = {

checkCreator(userId){
if(userId == this.creator._id){
return true;
}
return false;
},

getRelatedUsers(){
return Section.findAsync({course:this._id})
.then(sections =>{
Expand Down
1 change: 1 addition & 0 deletions server/api/course/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ router.get('/', controller.index);
router.get('/image/:name', controller.image);
router.get('/image/:size/:name', controller.imageSize);
router.get('/:id', controller.show);
router.get('/:courseId/checkcreator/:creatorID', auth.isInstructor(),controller.check);
router.post('/', auth.isInstructor(), upload.array('files[0]'), controller.create);
router.put('/:id', auth.isInstructor(), upload.array('files[0]'), controller.update);
router.patch('/:id', auth.isInstructor(), upload.array('files[0]'), controller.update);
Expand Down
1 change: 1 addition & 0 deletions server/api/section/section.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var SectionSchema = new Schema({
pendingStudents: [{type : Schema.Types.ObjectId, ref: 'User'}],
sectionNumbers: [Number],
enrollmentPolicy: {type: String, enum: ['open', 'closed', 'approvalRequired']},
deleted: Boolean
});

/**
Expand Down
2 changes: 1 addition & 1 deletion server/api/sectionevent/sectionevent.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function notifySectionCreation(sectionEvent){
.execAsync()
.then(section => {
section.students.forEach(student => {
scheduler.now("create sectionEvent", {user:student.toObject(), sectionId: section._id.toString(), eventInfo: eventInfo.toObject()});
scheduler.now("create sectionEvent", {user:student.toObject(), sectionId: section._id.toString(), eventInfo: eventInfo.toObject(), deleted: false});
});
return sectionEvent.updateUserNotifications();
}).then(()=> {return sectionEvent});
Expand Down
3 changes: 2 additions & 1 deletion server/api/sectionevent/sectionevent.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ var SectionEventSchema = new Schema({
info: {type: Schema.Types.ObjectId, ref: 'EventInfo'},
author: {type: Schema.Types.ObjectId, ref: 'User'},
submissionInstructions: String,
creationDate: Date
creationDate: Date,
deleted: Boolean
});


Expand Down
3 changes: 2 additions & 1 deletion server/api/submission/submission.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ exports.create = function(req, res) {
verified: false,
locationMatch: false,
time: Date.now(),
content: req.body.content
content: req.body.content,
deleted: false
};

Submission.create(submit, (err, submission) => {
Expand Down
1 change: 1 addition & 0 deletions server/api/submission/submission.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var SubmissionSchema = new Schema({
comments: String
},
instructorVerification: { type: String, enum: ["verified", "rejected", "none"] },
deleted: Boolean,
verified: Boolean,
locationMatch: Boolean,
location: {
Expand Down
23 changes: 20 additions & 3 deletions server/config/seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export function allCourses(){return {
semester: "Fall15",
active: false,
_id: mongoose.Types.ObjectId('000000000000000000000010'),
creator: allUsers().bob._id,
},
openSource:{
name: "Introduction to Open Source",
Expand All @@ -162,6 +163,7 @@ export function allCourses(){return {
semester: "Spring15",
active: true,
_id: mongoose.Types.ObjectId('000000000000000000000011'),
creator:allUsers().bob._id,
},
robotics:{
name: "Mestizo Robotics",
Expand All @@ -172,6 +174,7 @@ export function allCourses(){return {
semester: "Spring15",
active: true,
_id: mongoose.Types.ObjectId('000000000000000000000012'),
creator: allUsers().bob._id,
},
art:{
name: "Art, Community and Technology",
Expand All @@ -182,6 +185,7 @@ export function allCourses(){return {
semester: "Spring15",
active: true,
_id: mongoose.Types.ObjectId('000000000000000000000013'),
creator:allUsers().bob._id,
},
imaging:{
name: "Media Studio: Imaging",
Expand All @@ -192,6 +196,7 @@ export function allCourses(){return {
semester: "Spring15",
active: true,
_id: mongoose.Types.ObjectId('000000000000000000000014'),

},
materials:{
name: "Materials and Design",
Expand Down Expand Up @@ -222,9 +227,21 @@ export function allCourses(){return {
semester: "Spring15",
active: true,
_id: mongoose.Types.ObjectId('000000000000000000000017'),
}
};
}
creator: allUsers().travis._id,
},
venue:{
_id : mongoose.Types.ObjectId("222222222222222222222220"),
department : "TEST",
imageURLs: ["/api/courses/image/test-1470287331303.jpeg"], // url to image
courseNumber : 1234,
name : "Venue Testing",
description : "This course is for testing new venue features.",
active : true,
semester : "Spring16",
}
};
}


export function allSections(){ return {
netArt12: {
Expand Down
1 change: 1 addition & 0 deletions webpack.make.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module.exports = function makeWebpackConfig(options) {
'angular-simple-logger',
'angular-socket-io',
'angular-validation-match',
'angular-sweetalert',
// 'webpack-bootstrap',
'bootstrap-social',
'bootstrap-ui-datetime-picker',
Expand Down