1 | import play.api._ |
---|
2 | |
---|
3 | import models._ |
---|
4 | import anorm._ |
---|
5 | |
---|
6 | object Global extends GlobalSettings { |
---|
7 | |
---|
8 | override def onStart(app: Application) { |
---|
9 | InitialData.insert() |
---|
10 | } |
---|
11 | |
---|
12 | } |
---|
13 | |
---|
14 | /** |
---|
15 | * Initial set of data to be imported |
---|
16 | * in the sample application. |
---|
17 | */ |
---|
18 | object InitialData { |
---|
19 | |
---|
20 | def date(str: String) = new java.text.SimpleDateFormat("yyyy-MM-dd").parse(str) |
---|
21 | |
---|
22 | def insert() = { |
---|
23 | |
---|
24 | if(User.findAll.isEmpty) { |
---|
25 | |
---|
26 | Seq( |
---|
27 | User("guillaume@sample.com", "Guillaume Bort", "secret"), |
---|
28 | User("maxime@sample.com", "Maxime Dantec", "secret"), |
---|
29 | User("sadek@sample.com", "Sadek Drobi", "secret"), |
---|
30 | User("erwan@sample.com", "Erwan Loisant", "secret") |
---|
31 | ).foreach(User.create) |
---|
32 | |
---|
33 | Seq( |
---|
34 | Project(Id(1), "Play framework", "Play 2.0") -> Seq("guillaume@sample.com", "maxime@sample.com", "sadek@sample.com", "erwan@sample.com"), |
---|
35 | Project(Id(2), "Play framework", "Play 1.2.4") -> Seq("guillaume@sample.com", "erwan@sample.com"), |
---|
36 | Project(Id(3), "Play framework", "Website") -> Seq("guillaume@sample.com", "maxime@sample.com"), |
---|
37 | Project(Id(4), "Zenexity", "Secret project") -> Seq("guillaume@sample.com", "maxime@sample.com", "sadek@sample.com", "erwan@sample.com"), |
---|
38 | Project(Id(5), "Zenexity", "Playmate") -> Seq("maxime@sample.com"), |
---|
39 | Project(Id(6), "Personal", "Things to do") -> Seq("guillaume@sample.com"), |
---|
40 | Project(Id(7), "Zenexity", "Play samples") -> Seq("guillaume@sample.com", "maxime@sample.com"), |
---|
41 | Project(Id(8), "Personal", "Private") -> Seq("maxime@sample.com"), |
---|
42 | Project(Id(9), "Personal", "Private") -> Seq("guillaume@sample.com"), |
---|
43 | Project(Id(10), "Personal", "Private") -> Seq("erwan@sample.com"), |
---|
44 | Project(Id(11), "Personal", "Private") -> Seq("sadek@sample.com") |
---|
45 | ).foreach { |
---|
46 | case (project,members) => Project.create(project, members) |
---|
47 | } |
---|
48 | |
---|
49 | Seq( |
---|
50 | Task(NotAssigned, "Todo", 1, "Fix the documentation", false, None, Some("guillaume@sample.com")), |
---|
51 | Task(NotAssigned, "Urgent", 1, "Prepare the beta release", false, Some(date("2011-11-15")), None), |
---|
52 | Task(NotAssigned, "Todo", 9, "Buy some milk", false, None, None), |
---|
53 | Task(NotAssigned, "Todo", 2, "Check 1.2.4-RC2", false, Some(date("2011-11-18")), Some("guillaume@sample.com")), |
---|
54 | Task(NotAssigned, "Todo", 7, "Finish zentask integration", true, Some(date("2011-11-15")), Some("maxime@sample.com")), |
---|
55 | Task(NotAssigned, "Todo", 4, "Release the secret project", false, Some(date("2012-01-01")), Some("sadek@sample.com")) |
---|
56 | ).foreach(Task.create) |
---|
57 | |
---|
58 | } |
---|
59 | |
---|
60 | } |
---|
61 | |
---|
62 | } |
---|