Commit ea4d73d090e35256855da348ed92d8be15fbfc13
Exists in
master
Merge branch 'master' of https://bitbucket.org/youngdesk/ydapp
Showing
16 changed files
Show diff stats
client/stylesheets/custom.css
1 | 1 | body |
2 | 2 | { |
3 | - background: -webkit-linear-gradient(#00b395, #00cdaa); | |
4 | - background: -o-linear-gradient(#00b395, #00cdaa); | |
5 | - background: linear-gradient(#00b395, #00cdaa); | |
3 | + background: -webkit-linear-gradient(#00b395, #00b395); | |
4 | + background: -o-linear-gradient(#00b395, #00b395); | |
5 | + background: linear-gradient(#00b395, #00b395); | |
6 | 6 | } |
7 | 7 | |
8 | 8 | table .dropdown span{ | ... | ... |
imports/client/app/routes.js
... | ... | @@ -23,7 +23,8 @@ import { importCsvController } from '/imports/client/views/org/impo |
23 | 23 | |
24 | 24 | //admin |
25 | 25 | import { StudentDataController } from '/imports/client/views/org/admin/students/index' |
26 | -import { staffViewController } from '/imports/client/views/org/admin/staff/index' | |
26 | +import { staffViewController } from '/imports/client/views/org/admin/staff/index' | |
27 | +import { ParentViewController } from '/imports/client/views/org/admin/parents/index' | |
27 | 28 | //students |
28 | 29 | |
29 | 30 | //teachers |
... | ... | @@ -56,6 +57,7 @@ const getOrgRoutes = () => ( |
56 | 57 | <Route name="import" path="/import" component={ importCsvController } /> |
57 | 58 | <Route name="student" path="/students" component={ StudentDataController } /> |
58 | 59 | <Route name="staff" path="/staff" component={ staffViewController } /> |
60 | + <Route name="parent" path="/parents" component={ ParentViewController } /> | |
59 | 61 | <Route path="*" component={ NotFound } /> |
60 | 62 | </Route> |
61 | 63 | </Router> | ... | ... |
imports/client/views/nonOrg/enter/signup.css
imports/client/views/org/admin/AdminLayout.js
... | ... | @@ -57,6 +57,18 @@ export class AdminAppLayout extends Component { |
57 | 57 | </Link> |
58 | 58 | </div> |
59 | 59 | </div> |
60 | + <div className="col-lg-3 col-md-6"> | |
61 | + <div className="thumbnail"> | |
62 | + <Link to="/parents" > | |
63 | + <div className="thumb thumb-rounded"> | |
64 | + <img src="assets/images/download3.png" alt=""/> | |
65 | + </div> | |
66 | + <div className="caption text-center"> | |
67 | + <h6 className="text-semibold no-margin">Parents <small className="display-block">Click to view</small></h6> | |
68 | + </div> | |
69 | + </Link> | |
70 | + </div> | |
71 | + </div> | |
60 | 72 | </div> |
61 | 73 | </div> |
62 | 74 | </div> | ... | ... |
imports/client/views/org/admin/Header.js
... | ... | @@ -5,6 +5,7 @@ import React, { Component } from 'react'; |
5 | 5 | import { Link,browserHistory } from 'react-router'; |
6 | 6 | import { FormGroup, |
7 | 7 | FormControl,Glyphicon,Button } from 'react-bootstrap'; |
8 | +import './header.css'; | |
8 | 9 | |
9 | 10 | |
10 | 11 | export class Header extends Component { |
... | ... | @@ -25,29 +26,55 @@ export class Header extends Component { |
25 | 26 | return ( |
26 | 27 | <div className = "enterPane-box"> |
27 | 28 | <div className="row"> |
29 | + | |
28 | 30 | <div className="col-lg-3 col-md-6"> |
29 | - <div className="thumbnail"> | |
30 | - <Link to="/students" > | |
31 | - <div className="thumb thumb-rounded"> | |
32 | - <img src="assets/images/download2.png" alt="" /> | |
31 | + <Link to="/parents" > | |
32 | + <div className="panel panel-body"> | |
33 | + <div className="media"> | |
34 | + <div className="media-left"> | |
35 | + <img src="assets/images/download2.png" className="img-circle" alt=""/> | |
33 | 36 | </div> |
34 | - <div className="caption text-center"> | |
35 | - <h6 className="text-semibold no-margin">Students <small className="display-block">Click to view</small></h6> | |
37 | + | |
38 | + <div className="media-body"> | |
39 | + <h6 className="media-heading">Students</h6> | |
40 | + <p className="text-muted">Click to view</p> | |
36 | 41 | </div> |
37 | - </Link> | |
38 | 42 | </div> |
43 | + </div> | |
44 | + </Link> | |
39 | 45 | </div> |
40 | 46 | <div className="col-lg-3 col-md-6"> |
41 | - <div className="thumbnail"> | |
42 | - <Link to="/staff" > | |
43 | - <div className="thumb thumb-rounded"> | |
44 | - <img src="assets/images/download3.png" alt=""/> | |
47 | + <Link to="/parents" > | |
48 | + <div className="panel panel-body"> | |
49 | + <div className="media"> | |
50 | + <div className="media-left"> | |
51 | + <img src="assets/images/download.png" className="img-circle" alt=""/> | |
45 | 52 | </div> |
46 | - <div className="caption text-center"> | |
47 | - <h6 className="text-semibold no-margin">Teachers <small className="display-block">Click to view</small></h6> | |
53 | + | |
54 | + <div className="media-body"> | |
55 | + <h6 className="media-heading">Teachers</h6> | |
56 | + <p className="text-muted">Click to view</p> | |
48 | 57 | </div> |
49 | - </Link> | |
58 | + </div> | |
59 | + </div> | |
60 | + </Link> | |
61 | + </div> | |
62 | + | |
63 | + <div className="col-lg-3 col-md-6"> | |
64 | + <Link to="/parents" > | |
65 | + <div className="panel panel-body"> | |
66 | + <div className="media"> | |
67 | + <div className="media-left"> | |
68 | + <img src="assets/images/download3.png" className="img-circle" alt=""/> | |
69 | + </div> | |
70 | + | |
71 | + <div className="media-body"> | |
72 | + <h6 className="media-heading">Parents</h6> | |
73 | + <p className="text-muted">Click to view</p> | |
74 | + </div> | |
75 | + </div> | |
50 | 76 | </div> |
77 | + </Link> | |
51 | 78 | </div> |
52 | 79 | |
53 | 80 | </div> | ... | ... |
imports/client/views/org/admin/header.css
imports/client/views/org/admin/parents/index.js
... | ... | @@ -0,0 +1,66 @@ |
1 | +import _ from 'lodash'; | |
2 | +import { | |
3 | + composeWithTracker, | |
4 | + compose, | |
5 | + composeAll | |
6 | + } from 'react-komposer'; | |
7 | +import { Loading } from '/imports/client/components/Loading'; | |
8 | + | |
9 | +import { Orgs } from '/imports/collections/orgs/index'; | |
10 | +import { Users } from '/imports/collections/users/index'; | |
11 | +import { Parents } from '/imports/collections/parents/index'; | |
12 | +import { ParentsView } from './parentsview'; | |
13 | + | |
14 | + | |
15 | + | |
16 | +const meteorTick = (props, onData) => { | |
17 | + | |
18 | + const handles = [ | |
19 | + Meteor.subscribe('users.current'), | |
20 | + Meteor.subscribe('orgs.current'), | |
21 | + Meteor.subscribe('users.forMyOrg'), | |
22 | + Meteor.subscribe('parent.forMyOrg'), | |
23 | + ]; | |
24 | + | |
25 | + if(_.every(handles, (handle) => (handle.ready()) )) { | |
26 | + const user = Users.current(); | |
27 | + const org = Orgs.current(); | |
28 | + console.log("parents"); | |
29 | + parent = Users.find({"role":"PARENT"}).fetch() ? Users.find({"role":"PARENT"}).fetch() : ""; | |
30 | + console.log(Users.find({"role":"PARENT"}).fetch()); | |
31 | + parentData = Parents.find().fetch() ? Parents.find().fetch() : ""; | |
32 | + console.log("parentData"); | |
33 | + console.log(parentData); | |
34 | + for(var i=0; i< parent.length; i++){ | |
35 | + for(var j=0; j< parentData.length; j++){ | |
36 | + if(parent[i]._id == parentData[j].userId){ | |
37 | + parent[i].relationship = parentData[j].relationship; | |
38 | + } | |
39 | + } | |
40 | + } | |
41 | + onData(null, { | |
42 | + data: { | |
43 | + user: user, | |
44 | + org: org, | |
45 | + parent: parent | |
46 | + }, | |
47 | + }); | |
48 | + } | |
49 | + | |
50 | + return () => { | |
51 | + _.each(handles, (handle) => handle.stop() ); | |
52 | + }; | |
53 | +}; | |
54 | + | |
55 | + | |
56 | +const reduxTick = (props, onData) => { | |
57 | + onData(null, { | |
58 | + data: {} | |
59 | + }); | |
60 | +}; | |
61 | + | |
62 | + | |
63 | +export const ParentViewController = composeAll( | |
64 | + composeWithTracker(meteorTick, Loading), | |
65 | + compose(reduxTick, Loading), | |
66 | +)(ParentsView); | ... | ... |
imports/client/views/org/admin/parents/parentsview.js
... | ... | @@ -0,0 +1,108 @@ |
1 | +import _ from 'lodash'; | |
2 | +import { Meteor } from 'meteor/meteor'; | |
3 | + | |
4 | +import React, { Component } from 'react'; | |
5 | +import { Link,browserHistory } from 'react-router'; | |
6 | +import { FormGroup, | |
7 | + FormControl,Glyphicon,Button } from 'react-bootstrap'; | |
8 | +import { Header } from '../Header'; | |
9 | +import { AdminSidebar } from '../Sidebar' | |
10 | +import { AdminBreadcrumb } from '../Breadcrumb' | |
11 | +import { ParentTable } from './view/ParentTable' | |
12 | + | |
13 | + | |
14 | +export class ParentsView extends Component { | |
15 | + | |
16 | + constructor(props) { | |
17 | + super(props); | |
18 | + this.state = { | |
19 | + | |
20 | + }; | |
21 | + this.onUpdate = this.onUpdate.bind(this); | |
22 | + }; | |
23 | + | |
24 | + onUpdate(key, value) { | |
25 | + this.setState({[key]: value}); | |
26 | + }; | |
27 | + | |
28 | + render() { | |
29 | + const {user, org, parent} = this.props.data; | |
30 | + return ( | |
31 | + <div className="appLayout-box"> | |
32 | + <div className="page-container"> | |
33 | + <div className="page-content"> | |
34 | + <AdminSidebar | |
35 | + user = {user} | |
36 | + org = {org} | |
37 | + /> | |
38 | + <div className="content-wrapper"> | |
39 | + <AdminBreadcrumb /> | |
40 | + | |
41 | + <div className="content has-detached-left"> | |
42 | + <div className="container-detached"> | |
43 | + <div className="content-detached"> | |
44 | + <Header | |
45 | + user = {user} | |
46 | + org = {org} | |
47 | + /> | |
48 | + <ParentTable | |
49 | + data = {this.props.data} | |
50 | + parent = {parent} | |
51 | + /> | |
52 | + {/* <AddStaff/> | |
53 | + <UploadCsvStaff /> */} | |
54 | + </div> | |
55 | + </div> | |
56 | + <div className="sidebar-detached affix-top"> | |
57 | + <div className="sidebar sidebar-default"> | |
58 | + <div className="sidebar-content"> | |
59 | + | |
60 | + <div className="sidebar-category"> | |
61 | + <div className="category-title"> | |
62 | + <span>Advanced Search</span> | |
63 | + <ul className="icons-list"> | |
64 | + <li><a href="#" data-action="collapse"></a></li> | |
65 | + </ul> | |
66 | + </div> | |
67 | + | |
68 | + <div className="category-content"> | |
69 | + <form action="#"> | |
70 | + <div className="has-feedback has-feedback-left"> | |
71 | + <input type="search" className="form-control" | |
72 | + value={this.state.firstNameSearch} | |
73 | + onChange={e=>this.onUpdate('firstNameSearch',e.target.value)} | |
74 | + placeholder="First Name" | |
75 | + /> | |
76 | + <div className="form-control-feedback"> | |
77 | + <i className="icon-search4 text-size-base text-muted"></i> | |
78 | + </div> | |
79 | + </div> | |
80 | + </form> | |
81 | + </div> | |
82 | + <div className="category-content"> | |
83 | + <form action="#"> | |
84 | + <div className="has-feedback has-feedback-left"> | |
85 | + <input type="search" className="form-control" | |
86 | + value={this.state.lastNameSearch} | |
87 | + onChange={e=>this.onUpdate('lastNameSearch',e.target.value)} | |
88 | + placeholder="Last Name" /> | |
89 | + <div className="form-control-feedback"> | |
90 | + <i className="icon-search4 text-size-base text-muted"></i> | |
91 | + </div> | |
92 | + </div> | |
93 | + </form> | |
94 | + </div> | |
95 | + </div> | |
96 | + </div> | |
97 | + </div> | |
98 | + </div> | |
99 | + </div> | |
100 | + </div> | |
101 | + </div> | |
102 | + </div> | |
103 | + </div> | |
104 | + ); | |
105 | + }; | |
106 | + | |
107 | + | |
108 | +}; | ... | ... |
imports/client/views/org/admin/parents/view/ParentRow.js
... | ... | @@ -0,0 +1,54 @@ |
1 | +import _ from 'lodash'; | |
2 | +import { Meteor } from 'meteor/meteor'; | |
3 | + | |
4 | +import React, { Component } from 'react'; | |
5 | +import { Link,browserHistory } from 'react-router'; | |
6 | +import { FormGroup, | |
7 | + FormControl,Glyphicon,Button } from 'react-bootstrap'; | |
8 | + | |
9 | + | |
10 | + export class ParentRow extends Component { | |
11 | + | |
12 | + constructor(props) { | |
13 | + super(props); | |
14 | + this.state = { | |
15 | + | |
16 | + }; | |
17 | + this.onUpdate = this.onUpdate.bind(this); | |
18 | + }; | |
19 | + | |
20 | + onUpdate(key, value) { | |
21 | + this.setState({[key]: value}); | |
22 | + }; | |
23 | + | |
24 | + render() { | |
25 | + const {parent} = this.props; | |
26 | + if(parent.firstName){ | |
27 | + return ( | |
28 | + <tr> | |
29 | + <td>{parent.firstName}</td> | |
30 | + <td>{parent.relationship}</td> {/* relationship doesnt reflect here */} | |
31 | + <td><span className="label label-success">Active</span></td> | |
32 | + <td className="text-center"> | |
33 | + <ul className="icons-list"> | |
34 | + <li className="dropdown"> | |
35 | + <a href="#" className="dropdown-toggle" data-toggle="dropdown"> | |
36 | + <i className="icon-menu9"></i> | |
37 | + </a> | |
38 | + <ul className="dropdown-menu dropdown-menu-right"> | |
39 | + <li><a href="#"><i className="icon-file-pdf"></i> Export to .pdf</a></li> | |
40 | + <li><a href="#"><i className="icon-file-excel"></i> Export to .csv</a></li> | |
41 | + <li><a href="#"><i className="icon-file-word"></i> Export to .doc</a></li> | |
42 | + </ul> | |
43 | + </li> | |
44 | + </ul> | |
45 | + </td> | |
46 | + </tr> | |
47 | + ); | |
48 | + }else { | |
49 | + return null; | |
50 | + } | |
51 | + | |
52 | + }; | |
53 | + | |
54 | + }; | ... | ... |
imports/client/views/org/admin/parents/view/ParentTable.js
... | ... | @@ -0,0 +1,64 @@ |
1 | +import _ from 'lodash'; | |
2 | +import { Meteor } from 'meteor/meteor'; | |
3 | + | |
4 | +import React, { Component } from 'react'; | |
5 | +import { Link,browserHistory } from 'react-router'; | |
6 | +import { FormGroup,Panel,Table, | |
7 | + ButtonToolbar,Modal, | |
8 | + FormControl,Glyphicon,Button } from 'react-bootstrap'; | |
9 | +import {moment} from 'meteor/momentjs:moment' | |
10 | +import {ParentRow} from './ParentRow' | |
11 | + | |
12 | +export class ParentTable extends Component { | |
13 | + | |
14 | + constructor(props) { | |
15 | + super(props); | |
16 | + this.state = { | |
17 | + show: false | |
18 | + }; | |
19 | + this.onUpdate = this.onUpdate.bind(this); | |
20 | + }; | |
21 | + onUpdate(key, value) { | |
22 | + this.setState({[key]: value}); | |
23 | + }; | |
24 | + | |
25 | + render() { | |
26 | + return ( | |
27 | + <div className="panel panel-flat"> | |
28 | + <div className="panel-heading"> | |
29 | + <h5 className="panel-title">Parent Details</h5> | |
30 | + <div className="heading-elements"> | |
31 | + <ul className="icons-list"> | |
32 | + <li><a data-action="collapse"></a></li> | |
33 | + <li><a data-action="reload"></a></li> | |
34 | + </ul> | |
35 | + </div> | |
36 | + </div> | |
37 | + <Table striped bordered condensed hover> | |
38 | + <thead> | |
39 | + <tr> | |
40 | + <th>First Name</th> | |
41 | + <th>Relationship</th> | |
42 | + <th>Status</th> | |
43 | + <th className="text-center">Actions</th> | |
44 | + </tr> | |
45 | + </thead> | |
46 | + <tbody> | |
47 | + { | |
48 | + this.props.parent.map(function(parent, i) | |
49 | + { | |
50 | + return( | |
51 | + <ParentRow | |
52 | + key = {i} | |
53 | + parent = {parent} | |
54 | + /> | |
55 | + ) | |
56 | + }) | |
57 | + } | |
58 | + </tbody> | |
59 | + </Table> | |
60 | + </div> | |
61 | + ); | |
62 | + }; | |
63 | + | |
64 | +}; | ... | ... |
imports/client/views/org/admin/students/index.js
... | ... | @@ -26,6 +26,7 @@ const meteorTick = (props, onData) => { |
26 | 26 | const user = Users.current(); |
27 | 27 | const org = Orgs.current(); |
28 | 28 | students = Users.find({"role":"STUDENT"}).fetch() ? Users.find({"role":"STUDENT"}).fetch() : ""; |
29 | + console.log(students); | |
29 | 30 | studentData = Students.find().fetch() ? Students.find().fetch() : ""; |
30 | 31 | for(var i=0; i< students.length; i++){ |
31 | 32 | for(var j=0; j< studentData.length; j++){ | ... | ... |
imports/collections/parents/methods.js
... | ... | @@ -8,8 +8,8 @@ import { Bert } from 'meteor/themeteorchef:bert'; |
8 | 8 | import { Users } from '/imports/collections/users/index'; |
9 | 9 | import { Students } from '/imports/collections/students/index'; |
10 | 10 | import { Orgs } from '/imports/collections/orgs/index'; |
11 | -export const studentMethods = new ValidatedMethod({ | |
12 | - name: 'student.method', | |
11 | +export const parentMethods = new ValidatedMethod({ | |
12 | + name: 'parent.method', | |
13 | 13 | |
14 | 14 | validate: new SimpleSchema({ |
15 | 15 | itemId: { type: String }, |
... | ... | @@ -20,80 +20,3 @@ export const studentMethods = new ValidatedMethod({ |
20 | 20 | }, |
21 | 21 | |
22 | 22 | }); |
23 | - | |
24 | -export const addStudentManually = new ValidatedMethod({ | |
25 | - name: 'student.addManually', | |
26 | - | |
27 | - validate: new SimpleSchema({ | |
28 | - admissionId: { type: String }, | |
29 | - firstName: { type: String }, | |
30 | - middleName: { type: String }, | |
31 | - lastName: { type: String }, | |
32 | - email: { type: String }, | |
33 | - dob: { type: String }, | |
34 | - formattedDob: { type: String }, | |
35 | - gender: { type: String }, | |
36 | - rollNo: { type: String }, | |
37 | - studentclass: { type: String }, | |
38 | - section: { type: String }, | |
39 | - community: { type: String }, | |
40 | - bloodGroup: { type: String }, | |
41 | - phone: { type: String }, | |
42 | - address: { type: String }, | |
43 | - city: { type: String }, | |
44 | - state: { type: String }, | |
45 | - parentName: { type: String }, | |
46 | - parentEmail: { type: String }, | |
47 | - relation: { type: String }, | |
48 | - profession: { type: String }, | |
49 | - parentGender: { type: String }, | |
50 | - parentPhone: { type: String }, | |
51 | - parentAddress: { type: String }, | |
52 | - parentCity: { type: String }, | |
53 | - parentState: { type: String }, | |
54 | - parentZipcode: { type: String }, | |
55 | - }).validator(), | |
56 | - | |
57 | - run(data) { | |
58 | - console.log("data"); | |
59 | - console.log(data); | |
60 | - const user = Users.findOne({_id: this.userId}); | |
61 | - orgId = user.orgId; | |
62 | - newStudentId = Users.insert({ | |
63 | - emails: [data.email], | |
64 | - username: firstName, | |
65 | - firstName: firstName, | |
66 | - middleName: middleName, | |
67 | - lastName: lastName, | |
68 | - orgId: orgId, | |
69 | - role: 'STUDENT' | |
70 | - }); | |
71 | - newParentId = Users.insert({ | |
72 | - emails: [data.parentEmail], | |
73 | - username: parentName, | |
74 | - firstName: parentName, | |
75 | - orgId: orgId, | |
76 | - role: 'PARENT' | |
77 | - }); | |
78 | - console.log("newUserId"); | |
79 | - console.log(newUserId); | |
80 | - if(newUserId){ | |
81 | - Students.insert({ | |
82 | - userId: newUserId, | |
83 | - orgId: orgId, | |
84 | - admissionId: data.admissionId, | |
85 | - address: data.address, | |
86 | - gender: data.gender, | |
87 | - dob: data.dob, | |
88 | - rollNo: data.rollNo, | |
89 | - class: data.studentclass, | |
90 | - section: data.section, | |
91 | - bloodGroup: data.bloodGroup, | |
92 | - community: data.community, | |
93 | - | |
94 | - }); | |
95 | - } | |
96 | - return {newUserId}; | |
97 | - }, | |
98 | - | |
99 | -}); | ... | ... |
imports/collections/parents/publications.js
... | ... | @@ -0,0 +1,12 @@ |
1 | +import { Meteor } from 'meteor/meteor'; | |
2 | +import { check, Match } from 'meteor/check' | |
3 | + | |
4 | +import { Orgs } from '/imports/collections/orgs/index'; | |
5 | +import { Users } from '/imports/collections/users/index'; | |
6 | +import { Parents } from '/imports/collections/parents/index'; | |
7 | + | |
8 | +Meteor.publish('parent.forMyOrg', function () { | |
9 | + const user = Users.findOne({_id: this.userId}); | |
10 | + if(!user) return []; | |
11 | + return Parents.find({orgId: user.orgId}); | |
12 | +}); | ... | ... |
imports/collections/staff/serverCsvUpload.js
... | ... | @@ -64,6 +64,8 @@ export const addStaffCSV= new ValidatedMethod({ |
64 | 64 | //username: data["First Name*"], |
65 | 65 | firstName: data["First Name*"], |
66 | 66 | lastName: data['Last Name*'], |
67 | + emails: [{ address: data['Staff Email*'],verified: false }], | |
68 | + phones: [{ number: data['Staff Phone*'],verified: false }], | |
67 | 69 | orgId: orgId, |
68 | 70 | role: 'STAFF' |
69 | 71 | }); |
... | ... | @@ -141,9 +143,6 @@ export const staffUploadCsv = new ValidatedMethod({ |
141 | 143 | run({data}) { |
142 | 144 | let validation = new Validation(); |
143 | 145 | let constants = new Constants(); |
144 | - //console.log("++++++++++++++++++++++++"+constants.csv_students_data()); | |
145 | - temp = constants.csv_students_data(); | |
146 | - console.log(temp); | |
147 | 146 | var CSV_valid_buffer = []; |
148 | 147 | var CSV_invalid_buffer = []; |
149 | 148 | var filename = "Staff-" + new Date().getTime().toString(); |
... | ... | @@ -177,22 +176,33 @@ export const staffUploadCsv = new ValidatedMethod({ |
177 | 176 | } |
178 | 177 | |
179 | 178 | var is_valid = formate_validation && is_not_null ; |
179 | + | |
180 | + | |
181 | + | |
180 | 182 | if (is_valid) |
181 | 183 | { |
182 | - CSV_valid_buffer.push(item); | |
183 | - console.log("----------------------------------------1"); | |
184 | + exists = Users.findOne({"firstName": item["First Name*"],"lastName": item["Last Name*"],'emails.$.address' : item['Staff Email*'],'phones.$.number' : item['Staff Phone*']}, {"_id": 1}); | |
184 | 185 | |
185 | - Meteor.call('staff.addCSV',item); | |
186 | - console.log("----------------------------------------2"); | |
187 | - | |
186 | + if (!exists) | |
187 | + { | |
188 | + CSV_valid_buffer.push(item); | |
189 | + Meteor.call('staff.addCSV',item); | |
190 | + console.warn('done'); | |
191 | + } | |
192 | + else | |
193 | + { | |
194 | + console.warn('This data already exists.'); | |
195 | + errors.push('This data already exists'); | |
196 | + var str = errors.toString(); | |
197 | + item.Errors = str; | |
198 | + CSV_invalid_buffer.push(item); | |
199 | + } | |
200 | + | |
188 | 201 | } |
189 | - else | |
190 | - { | |
191 | - var str = errors.toString(); | |
192 | - item.Errors = str; | |
193 | - CSV_invalid_buffer.push(item); | |
194 | - } | |
202 | + | |
195 | 203 | } |
204 | + | |
205 | + | |
196 | 206 | console.log(csv_filepath+filename+"_CSV_invalid_data"+".csv"); |
197 | 207 | Meteor.call('staff.saveCsvData',{ item : CSV_invalid_buffer, filename: csv_filepath+filename+"_CSV_invalid_data"+".csv",csv_fiels :constants.csv_staff_data()}); |
198 | 208 | Meteor.call('staff.saveCsvData',{ item : CSV_valid_buffer,filename: csv_filepath+filename+"_CSV_valid_data"+".csv",csv_fiels :constants.csv_staff_data()}); | ... | ... |
imports/collections/students/serverCsvUpload.js
... | ... | @@ -58,9 +58,6 @@ export const addStudentCSV= new ValidatedMethod({ |
58 | 58 | |
59 | 59 | run(item){ |
60 | 60 | data = item ; |
61 | - console.log("data"); | |
62 | - console.log(data); | |
63 | - // return true; | |
64 | 61 | const user = Users.findOne({_id: this.userId}); |
65 | 62 | orgId = user.orgId; |
66 | 63 | newStudentId = Users.insert({ |
... | ... | @@ -74,9 +71,12 @@ export const addStudentCSV= new ValidatedMethod({ |
74 | 71 | newParentUserId = Users.insert({ |
75 | 72 | //emails: [{address:data.parentEmail, verified: false}], |
76 | 73 | //3: data['Parent Name*'], |
77 | - firstName: data['Parent Name*'], | |
78 | 74 | orgId: orgId, |
75 | + firstName: data['Parent Name*'], | |
76 | + emails: [{ address: data['Parent Email*'],verified: false }], | |
77 | + phones: [{ number: data['Parent Mobile*'],verified: false }], | |
79 | 78 | role: 'PARENT' |
79 | + | |
80 | 80 | }); |
81 | 81 | if(newParentUserId){ |
82 | 82 | newParentId = Parents.insert({ |
... | ... | @@ -135,10 +135,7 @@ export const studentUploadCsv = new ValidatedMethod({ |
135 | 135 | run({data}) { |
136 | 136 | let validation = new Validation(); |
137 | 137 | let constants = new Constants(); |
138 | - //console.log("++++++++++++++++++++++++"+constants.csv_students_data()); | |
139 | - temp = constants.csv_students_data(); | |
140 | - // | |
141 | - console.log(temp); | |
138 | + | |
142 | 139 | // var data_1=csv1.csvtojson(("/Users/satheeshnagaraj/Downloads/11.csv")); //csvtojson is function that accepts csv filenames and returns JSON object |
143 | 140 | //console.log(data);'' |
144 | 141 | // Stores = new Mongo.Collection('stores'); |
... | ... | @@ -147,7 +144,8 @@ export const studentUploadCsv = new ValidatedMethod({ |
147 | 144 | var CSV_valid_buffer = []; |
148 | 145 | var CSV_invalid_buffer = []; |
149 | 146 | var filename = "Student" + new Date().getTime().toString(); |
150 | - var csv_filepath = '/Users/deepak/dev/yd/csv'; | |
147 | + var csv_filepath ='/Users/satheeshnagaraj/Documents/Workspace/Meteor/production/ydapp/CSV_Files/'; | |
148 | + //var csv_filepath = '/Users/deepak/dev/yd/csv'; | |
151 | 149 | |
152 | 150 | |
153 | 151 | |
... | ... | @@ -193,35 +191,40 @@ export const studentUploadCsv = new ValidatedMethod({ |
193 | 191 | // console.log(formate_validation); |
194 | 192 | if (is_valid) |
195 | 193 | { |
196 | - CSV_valid_buffer.push(item); | |
197 | - console.log("----------------------------------------1"); | |
198 | - console.log("----------------------------------------item"); | |
199 | - console.log(item); | |
200 | - console.log (Users.findOne({"firstName": item["First Name*"],"lastName": item["Last Name*"]})); | |
201 | - | |
202 | - Meteor.call('student.addCSV',item); | |
203 | - console.log("----------------------------------------2"); | |
204 | - | |
205 | - // exists = Stores.findOne({ | |
206 | - // "Student 'Admission' ID*": item["Student Admission ID*"] | |
207 | - // }); | |
208 | - // if (!exists) | |
209 | - // { | |
210 | - // Stores.insert(item); | |
211 | - // } | |
212 | - // else | |
213 | - // { | |
214 | - // console.warn('Rejected. This item already exists.'); | |
215 | - // } | |
216 | - } | |
217 | - else | |
218 | - { | |
219 | - var str = errors.toString(); | |
220 | - item.Errors = str; | |
221 | - CSV_invalid_buffer.push(item); | |
222 | - //console.log(str); | |
223 | - // console.log(CSV_invalid_buffer); | |
224 | - } | |
194 | + | |
195 | + exists = Users.findOne({"firstName": item["First Name*"],"lastName": item["Last Name*"]}, {"_id": 1}); | |
196 | + | |
197 | + if (!exists) | |
198 | + { | |
199 | + CSV_valid_buffer.push(item); | |
200 | + Meteor.call('student.addCSV',item); | |
201 | + console.warn('done'); | |
202 | + } | |
203 | + else | |
204 | + { | |
205 | + console.log(exists._id); | |
206 | + student_data = Students.findOne({"userId":exists._id}); | |
207 | + console.log("--------------"+student_data); | |
208 | + | |
209 | + parent_data = Users.findOne({"_id":student_data.parent[0].id}); | |
210 | + | |
211 | + console.log(parent_data.emails[0].address); | |
212 | + if ( parent_data.emails[0].address != item["Parent Email*"]) | |
213 | + { | |
214 | + CSV_valid_buffer.push(item); | |
215 | + Meteor.call('student.addCSV',item); | |
216 | + console.warn('done'); | |
217 | + } | |
218 | + else | |
219 | + { | |
220 | + console.warn('This data already exists.'); | |
221 | + errors.push('This data already exists'); | |
222 | + var str = errors.toString(); | |
223 | + item.Errors = str; | |
224 | + CSV_invalid_buffer.push(item); | |
225 | + } | |
226 | + } | |
227 | + } | |
225 | 228 | } |
226 | 229 | Meteor.call('save_csv_data',{ item : CSV_invalid_buffer, filename: csv_filepath+filename+"_CSV_invalid_data"+".csv",csv_fiels :constants.csv_students_data()}); |
227 | 230 | Meteor.call('save_csv_data',{ item : CSV_valid_buffer,filename: csv_filepath+filename+"_CSV_valid_data"+".csv",csv_fiels :constants.csv_students_data()}); | ... | ... |
imports/server/collections.js
... | ... | @@ -10,3 +10,6 @@ import '/imports/collections/students/serverCsvUpload'; |
10 | 10 | import '/imports/collections/staff/methods'; |
11 | 11 | import '/imports/collections/staff/publications'; |
12 | 12 | import '/imports/collections/staff/serverCsvUpload'; |
13 | + | |
14 | +import '/imports/collections/parents/methods'; | |
15 | +import '/imports/collections/parents/publications'; | ... | ... |