forked from greylockhackfest/07.21.2012
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpopulate.js
More file actions
61 lines (51 loc) · 2.04 KB
/
populate.js
File metadata and controls
61 lines (51 loc) · 2.04 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var application_root = __dirname,
express = require('express'),
mongoose = require('mongoose'),
models = require('./models');
mongoose.connect("mongodb://localhost/tau");
function user (email, name) {
var k = new models.User({email:email, password: "cmu", name: name});
k.save(function (e) { console.log(k);});
return k;
}
function file (path, slug) {
var f = new models.File({name: slug, slug: slug,
path: (application_root + path),
timestamp: new Date()});
f.save(function (e) { console.log(f);});
return f;
}
function handle(user, file, c) {
var a = new models.Assignment({name: "Final Project - "+ user.name, slug: "final_project",
course: c, user: user});
a.files.push(file._id);
user.assignments.push(a._id);
a.save(function (e) { console.log(a);});
user.save(function (e) { console.log(e);});
return a;
}
console.log("asdfasdf");
var c1 = new models.Course({name:"15-110", slug:"15-110"}),
u1 = user("o1@andrew.cmu.edu", "Omer1"), f1 = file("/data/handins/derp1.py", "derp1.py"),
u2 = user("o2@andrew.cmu.edu", "Omer2"), f2 = file("/data/handins/derp2.py", "derp2.py"),
u3 = user("o3@andrew.cmu.edu", "Omer3"), f3 = file("/data/handins/derp3.py", "derp3.py"),
u4 = user("o4@andrew.cmu.edu", "Omer4"), f4 = file("/data/handins/derp4.py", "derp4.py"),
u5 = user("o5@andrew.cmu.edu", "Omer5"), f5 = file("/data/handins/derp5.py", "derp5.py"),
u6 = user("o6@andrew.cmu.edu", "Omer6"), f6 = file("/data/handins/derp6.py", "derp6.py"),
h1 = handle(u1, f1, c1),
h2 = handle(u2, f2, c1),
h3 = handle(u3, f3, c1),
h4 = handle(u4, f4, c1),
h5 = handle(u5, f5, c1),
h6 = handle(u6, f6, c1),
koz = user("kosbie@andrew.cmu.edu", "Kosbie");
c1.staff.push(koz._id);
c1.students.push(u1._id);
c1.students.push(u2._id);
c1.students.push(u3._id);
c1.students.push(u4._id);
c1.students.push(u5._id);
c1.students.push(u6._id);
c1.assignments.push("final_project");
console.log("asdfasdf");
c1.save(function(e) {console.log(c1);});