Commit bdd4abb61022f7a971cf2f1663ab24a55ce3169c

Authored by Deepak
1 parent 316564385f
Exists in master

some cleanup

imports/client/app/routes.js
... ... @@ -9,7 +9,6 @@ import { Meteor } from 'meteor/meteor';
9 9 /**
10 10 * General Components
11 11 */
12   -import Index from '/imports/client/views/app/module/Index';
13 12 import NotFound from '/imports/client/views/org/NotFound';
14 13  
15 14 /**
... ... @@ -25,21 +24,13 @@ import { importCsvController } from '/imports/client/views/org/impo
25 24 import { StudentDataController } from '/imports/client/views/org/admin/students/index'
26 25 import { staffViewController } from '/imports/client/views/org/admin/staff/index'
27 26 import { ParentViewController } from '/imports/client/views/org/admin/parents/index'
  27 +import { AdminSettingsController } from '/imports/client/views/org/admin/settings/index'
28 28 //students
29 29  
30 30 //teachers
31 31  
32 32 //parents
33 33  
34   -
35   -
36   -/**
37   - * NonOrg Components
38   - */
39   -import Signup from '/imports/client/views/nonOrg/enter/SignupView';
40   -import { NonOrgApp } from '/imports/client/layouts/NonOrgApp';
41   -import {NonOrgAppModule} from '/imports/client/views/nonOrg/app/module/Index';
42   -
43 34 /**
44 35 * Invalid Org Components
45 36 */
... ... @@ -57,7 +48,8 @@ const getOrgRoutes = () => (
57 48 <Route name="import" path="/import" component={ importCsvController } />
58 49 <Route name="student" path="/students" component={ StudentDataController } />
59 50 <Route name="staff" path="/staff" component={ staffViewController } />
60   - <Route name="parent" path="/parents" component={ ParentViewController } />
  51 + <Route name="parent" path="/parents" component={ ParentViewController } />
  52 + <Route name="settings" path="/settings" component={ AdminSettingsController } />
61 53 <Route path="*" component={ NotFound } />
62 54 </Route>
63 55 </Router>
... ... @@ -73,6 +65,14 @@ const getInvalidOrgRoute = () =&gt; (
73 65 </Router>
74 66 )
75 67  
  68 +
  69 +/**
  70 + * NonOrg Components
  71 + */
  72 +import Signup from '/imports/client/views/nonOrg/enter/SignupView';
  73 +import { NonOrgApp } from '/imports/client/layouts/NonOrgApp';
  74 +import {NonOrgAppModule} from '/imports/client/views/nonOrg/app/module/Index';
  75 +
76 76 const getNonOrgRoutes = () => (
77 77 <Router history={ browserHistory }>
78 78 <Route path="/" component={ NonOrgApp }>
... ... @@ -99,7 +99,10 @@ const authenticate = (nextState, replace) =&gt; {
99 99 **/
100 100 const detectOrg = () => {
101 101 orgSlug = "";
  102 + //www.app.ydapp.in
  103 + //
102 104 var hostnameArray = document.location.hostname.split( "." );
  105 + //['www','app', 'ydapp','in'];
103 106 if(hostnameArray[0] !== "www"){
104 107 if((hostnameArray[1]==='localhost'||hostnameArray[1]==='ydapp')){
105 108 orgSlug = hostnameArray[0];
... ... @@ -113,6 +116,8 @@ const detectOrg = () =&gt; {
113 116 if(orgSlug!==""){
114 117 console.log(orgSlug);
115 118 Meteor.call('checkExistingOrg', {slug:orgSlug}, function(err, res) {
  119 + console.log(err);
  120 + console.log(res);
116 121 if(res){
117 122 Session.set('orgId', res._id);
118 123 Session.set('orgSlug', orgSlug);
... ...
imports/client/layouts/OrgApp.js
... ... @@ -13,12 +13,8 @@ import {AppNavigationController} from &#39;/imports/client/views/org/app/module/n
13 13 };
14 14 render(){
15 15 return (
16   - <div>
17   - <AppNavigationController />
  16 + <div className="app-main-layout">
18 17 { this.props.children }
19   - <Grid>
20   -
21   - </Grid>
22 18 </div>
23 19 )
24 20 }
... ...
imports/client/views/app/module/Index.js
... ... @@ -1,15 +0,0 @@
1   -import React from 'react';
2   -import { Jumbotron } from 'react-bootstrap';
3   -
4   -const Index = () => (
5   - <div className="Index">
6   - <Jumbotron className="text-center">
7   - <h2>Base</h2>
8   - <p>A starting point for Meteor applications.</p>
9   - <p><a className="btn btn-success" href="https://themeteorchef.com/base" role="button">Read the Documentation</a></p>
10   - <p style={ { fontSize: '16px', color: '#aaa' } }>Currently at v4.11.1</p>
11   - </Jumbotron>
12   - </div>
13   -);
14   -
15   -export default Index;
imports/client/views/app/module/navigation/AppNavigation.js
... ... @@ -1,27 +0,0 @@
1   -import React from 'react';
2   -import { Navbar } from 'react-bootstrap';
3   -import { Link } from 'react-router';
4   -import PublicNavigation from './PublicNavigation.js';
5   -import AuthenticatedNavigation from './AuthenticatedNavigation.js';
6   -
7   -const renderNavigation = hasUser => (hasUser ? <AuthenticatedNavigation /> : <PublicNavigation />);
8   -
9   -const AppNavigation = ({ hasUser }) => (
10   - <Navbar>
11   - <Navbar.Header>
12   - <Navbar.Brand>
13   - <Link to="/">Application Name</Link>
14   - </Navbar.Brand>
15   - <Navbar.Toggle />
16   - </Navbar.Header>
17   - <Navbar.Collapse>
18   - { renderNavigation(hasUser) }
19   - </Navbar.Collapse>
20   - </Navbar>
21   -);
22   -
23   -AppNavigation.propTypes = {
24   - hasUser: React.PropTypes.object,
25   -};
26   -
27   -export default AppNavigation;
imports/client/views/app/module/navigation/AuthenticatedNavigation.js
... ... @@ -1,30 +0,0 @@
1   -import React from 'react';
2   -import { browserHistory } from 'react-router';
3   -import { LinkContainer } from 'react-router-bootstrap';
4   -import { Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap';
5   -import { Meteor } from 'meteor/meteor';
6   -
7   -const handleLogout = () => Meteor.logout(() => browserHistory.push('/login'));
8   -
9   -const userName = () => {
10   - const user = Meteor.user();
11   - const name = user && user.profile ? user.profile.name : '';
12   - return user ? `${name.first} ${name.last}` : '';
13   -};
14   -
15   -const AuthenticatedNavigation = () => (
16   - <div>
17   - <Nav>
18   - <LinkContainer to="/documents">
19   - <NavItem eventKey={ 2 } href="/documents">Documents</NavItem>
20   - </LinkContainer>
21   - </Nav>
22   - <Nav pullRight>
23   - <NavDropdown eventKey={ 3 } title={ userName() } id="basic-nav-dropdown">
24   - <MenuItem eventKey={ 3.1 } onClick={ handleLogout }>Logout</MenuItem>
25   - </NavDropdown>
26   - </Nav>
27   - </div>
28   -);
29   -
30   -export default AuthenticatedNavigation;
imports/client/views/app/module/navigation/Loading.js
... ... @@ -1,30 +0,0 @@
1   -import React from 'react';
2   -
3   -const Loading = () => (
4   - <svg
5   - version="1.1"
6   - className="Loading"
7   - xmlns="http://www.w3.org/2000/svg"
8   - x="0px"
9   - y="0px"
10   - width="40px"
11   - height="40px"
12   - viewBox="0 0 40 40"
13   - enableBackground="new 0 0 40 40">
14   - <path
15   - opacity="1.0"
16   - fill="#eee"
17   - d="M20.201,5.169c-8.254,0-14.946,6.692-14.946,14.946c0,8.255,6.692,14.946,
18   - 14.946,14.946s14.946-6.691,14.946-14.946C35.146,11.861,28.455,5.169,20.201,
19   - 5.169z M20.201,31.749c-6.425,0-11.634-5.208-11.634-11.634c0-6.425,
20   - 5.209-11.634,11.634-11.634c6.425,0,11.633,5.209,11.633,11.634C31.834,
21   - 26.541,26.626,31.749,20.201,31.749z"/>
22   - <path
23   - fill="#da5347"
24   - d="M26.013,10.047l1.654-2.866c-2.198-1.272-4.743-2.012-7.466-2.012h0v3.312h0
25   - C22.32,8.481,24.301,9.057,26.013,10.047z">
26   - </path>
27   - </svg>
28   -);
29   -
30   -export default Loading;
imports/client/views/app/module/navigation/PublicNavigation.js
... ... @@ -1,16 +0,0 @@
1   -import React from 'react';
2   -import { LinkContainer } from 'react-router-bootstrap';
3   -import { Nav, NavItem } from 'react-bootstrap';
4   -
5   -const PublicNavigation = () => (
6   - <Nav pullRight>
7   - <LinkContainer to="signup">
8   - <NavItem eventKey={ 1 } href="/signup">Sign Up</NavItem>
9   - </LinkContainer>
10   - <LinkContainer to="login">
11   - <NavItem eventKey={ 2 } href="/login">Log In</NavItem>
12   - </LinkContainer>
13   - </Nav>
14   -);
15   -
16   -export default PublicNavigation;
imports/client/views/app/module/navigation/index.js
... ... @@ -1,7 +0,0 @@
1   -import { composeWithTracker } from 'react-komposer';
2   -import { Meteor } from 'meteor/meteor';
3   -import AppNavigation from '../components/AppNavigation.js';
4   -
5   -const composer = (props, onData) => onData(null, { hasUser: Meteor.user() });
6   -
7   -export default composeWithTracker(composer, {}, {}, { pure: false })(AppNavigation);
imports/client/views/org/admin/settings/adminSettingsView.js
... ... @@ -0,0 +1,33 @@
  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 AdminSettingsView 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 {user, org} = this.props.data;
  26 + return (
  27 + <div className = "enterPane-box">
  28 + <h1>Settings</h1>
  29 + </div>
  30 + );
  31 + };
  32 +
  33 +};
... ...
imports/client/views/org/admin/settings/index.js
... ... @@ -0,0 +1,48 @@
  1 +// import { InviteSignupController } from '/imports/client/views/invite/signup/index'
  2 +import _ from 'lodash';
  3 +import {
  4 + composeWithTracker,
  5 + compose,
  6 + composeAll
  7 + } from 'react-komposer';
  8 +import { Loading } from '/imports/client/components/Loading';
  9 +
  10 +import { Orgs } from '/imports/collections/orgs/index';
  11 +import { Users } from '/imports/collections/users/index';
  12 +import { AdminSettingsView } from './adminSettingsView';
  13 +
  14 +const meteorTick = (props, onData) => {
  15 +
  16 + const handles = [
  17 + Meteor.subscribe('users.current'),
  18 + Meteor.subscribe('orgs.current')
  19 + ];
  20 +
  21 + if(_.every(handles, (handle) => (handle.ready()) )) {
  22 + const user = Users.current();
  23 + const org = Orgs.current();
  24 + onData(null, {
  25 + data: {
  26 + user: user,
  27 + org: org
  28 + },
  29 + });
  30 + }
  31 +
  32 + return () => {
  33 + _.each(handles, (handle) => handle.stop() );
  34 + };
  35 +};
  36 +
  37 +
  38 +const reduxTick = (props, onData) => {
  39 + onData(null, {
  40 + data: {}
  41 + });
  42 +};
  43 +
  44 +
  45 +export const AdminSettingsController = composeAll(
  46 + composeWithTracker(meteorTick, Loading),
  47 + compose(reduxTick, Loading),
  48 +)(AdminSettingsView);
... ...
imports/client/views/org/admin/students/StudentView.js
... ... @@ -69,7 +69,7 @@ export class StudentView extends Component {
69 69 <Header/>
70 70 <StudentTable
71 71 data = {this.props.data}
72   - students = {students}
  72 + studentData = {studentData}
73 73 />
74 74 <AddStudent/>
75 75 <UploadCsv />
... ...
imports/client/views/org/admin/students/add/AddStudentFormContainer.js
... ... @@ -4,7 +4,7 @@ import StudentForm from &#39;./StudentForm&#39;
4 4 import Form from '/imports/client/views/core/Form'
5 5 import Validator from '/imports/client/views/core/Validator'
6 6 import { isRequired, isValidEmail } from '/imports/client/views/core/validations'
7   -import { addStudentManually } from '/imports/collections/students/methods';
  7 +
8 8  
9 9 export class AddStudentFormContainer extends Component {
10 10  
... ... @@ -28,14 +28,15 @@ export class AddStudentFormContainer extends Component {
28 28 }
29 29  
30 30 handleSubmit() {
  31 + self = this;
31 32 if (this.state.currentStep === 3) {
32   - addStudentManually.call(this.form.state.values, function(err, result){
  33 + Meteor.call('student.addManually',this.form.state.values, function(err, result){
33 34 console.log("err");
34 35 console.log(err);
35 36 console.log("result");
36 37 console.log(result);
37 38 if(!err){
38   - this.props.modalState();
  39 + self.props.hideModal();
39 40 }
40 41 });
41 42 }
... ... @@ -50,6 +51,31 @@ export class AddStudentFormContainer extends Component {
50 51 initialValues={{
51 52 gender: 'male',
52 53 parentGender: 'male',
  54 + admissionId: "123",
  55 + firstName: "first",
  56 + lastName: "last",
  57 + email: "deepak125.dk+21@gmail.com",
  58 + dob: "04/04/1989",
  59 + gender: "male",
  60 + rollNo: "1",
  61 + studentClass: "2",
  62 + section: "B",
  63 + community: "SC",
  64 + bloodGroup: "B+",
  65 + phone: "9876543321",
  66 + address: "address",
  67 + city: "chennai",
  68 + state: "tn",
  69 + parentName: "parentName",
  70 + parentEmail: "deepak125.dk+41@gmail.com",
  71 + relation: "father",
  72 + profession: "farmer",
  73 + parentGender: "male",
  74 + parentPhone: "987655412",
  75 + parentAddress: "parentAddress",
  76 + parentCity: "parentCity",
  77 + parentState: "parentState",
  78 + parentZipcode: "parentZipcode",
53 79 }}
54 80 >
55 81 {({ values, setValue, getValue, isSubmitted, isDirty }) => (
... ...
imports/client/views/org/admin/students/add/addStudent.js
... ... @@ -50,7 +50,7 @@ export class AddStudent extends Component {
50 50 </Modal.Header>
51 51 <Modal.Body>
52 52 <AddStudentFormContainer
53   - modalState = {this.hideModal}
  53 + hideModal = {this.hideModal}
54 54 />
55 55 </Modal.Body>
56 56 {/*
... ...
imports/client/views/org/admin/students/index.js
... ... @@ -26,16 +26,14 @@ const meteorTick = (props, onData) =&gt; {
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);
30 29 studentData = Students.find().fetch() ? Students.find().fetch() : "";
31   - var mergedData;
32   - console.log(studentData);
33   - for(var i=0; i< students.length; i++){
34   - for(var j=0; j< studentData.length; j++){
35   - if(students[i]._id == studentData[j].userId && studentData[j].admissionId){
36   - students[i].admissionId = studentData[j].admissionId;
37   - students[i].class = studentData[j].class;
38   - students[i].dob = studentData[j].dob;
  30 + for(var i=0; i< studentData.length; i++){
  31 + for(var j=0; j< students.length; j++){
  32 + if(studentData[i].userId == students[j]._id && studentData[i].admissionId){
  33 + studentData[i].firstName = students[j].firstName;
  34 + studentData[i].lastName = students[j].lastName;
  35 + }else{
  36 +
39 37 }
40 38 }
41 39 }
... ... @@ -43,7 +41,6 @@ const meteorTick = (props, onData) =&gt; {
43 41 data: {
44 42 user: user,
45 43 org: org,
46   - students: students,
47 44 studentData: studentData
48 45 },
49 46 });
... ...
imports/client/views/org/admin/students/view/StudentTable.js
... ... @@ -56,6 +56,9 @@ export class StudentTable extends Component {
56 56 }
57 57  
58 58 render() {
  59 + studentData = this.props.studentData;
  60 + console.log("this.props.studentData");
  61 + console.log(this.props.studentData);
59 62 return (
60 63 <div className="panel panel-flat">
61 64 <div className="panel-heading">
... ... @@ -67,8 +70,8 @@ export class StudentTable extends Component {
67 70 </div>
68 71 </div>
69 72 <Panel collapsible expanded={this.state.panleOpen}>
70   - <BootstrapTable data={ this.props.students } pagination={ true } options={ options } >
71   - <TableHeaderColumn dataField='admissionId' isKey={ true } dataSort={ true } filter={ { type: 'TextFilter' } }>Admission Id</TableHeaderColumn>
  73 + <BootstrapTable data={ studentData } pagination={ true } options={ options } >
  74 + <TableHeaderColumn dataField='_id' isKey={ true } dataSort={ true } filter={ { type: 'TextFilter' } }>Admission Id</TableHeaderColumn>
72 75 <TableHeaderColumn dataField='firstName' dataSort={ true } filter={ { type: 'TextFilter' } }>First Name</TableHeaderColumn>
73 76 <TableHeaderColumn dataField='lastName' dataSort={ true } filter={ { type: 'TextFilter' } }>Last Name</TableHeaderColumn>
74 77 <TableHeaderColumn dataField='class' dataSort={ true } filter={ { type: 'TextFilter' } }>Class</TableHeaderColumn>
... ...
imports/client/views/org/app/module/AppLayout.js
... ... @@ -11,9 +11,9 @@ import { Navbar,Modal, Nav, NavItem,
11 11 Glyphicon, Collapse,
12 12 NavbarToggler, NavbarBrand,
13 13 NavLink, DropdownItem, DropdownToggle, DropdownMenu,
14   - NavDropdown, MenuItem, Breadcrumb } from 'react-bootstrap';
  14 + NavDropdown, MenuItem, Breadcrumb } from 'react-bootstrap';
15 15 import { VerifyModule } from '/imports/client/views/verify/module/index'
16   -import { AdminAppLayout } from '/imports/client/views/org/admin/AdminLayout'
  16 +import { AdminAppLayout } from '/imports/client/views/org/admin/AdminLayout'
17 17  
18 18 var Accordion = require('react-bootstrap').Accordion;
19 19 var Panel = require('react-bootstrap').Panel;
... ... @@ -21,7 +21,6 @@ export class AppLayout extends Component {
21 21  
22 22 render() {
23 23 const {user, org} = this.props.data;
24   -
25 24 if(!user) {
26 25 return (
27 26 <EnterModule
... ... @@ -29,27 +28,25 @@ export class AppLayout extends Component {
29 28 location = {this.props.location}
30 29 />
31 30 );
32   - }
33   - if(!user.isEmailVerified()) {
  31 + }else if(!user.isEmailVerified()) {
34 32 return (
35 33 <VerifyModule
36 34 pane = {this.props.location.query.verify}
37 35 location = {this.props.location}
38 36 />
39 37 );
40   - }
41   - if(user.role==='ADMIN'){
  38 + }else if(user.role==='ADMIN'){
42 39 return(
43 40 <AdminAppLayout
44 41 user = {user}
45 42 org = {org}
46 43 />
47 44 );
  45 + }else{
  46 + return (
  47 + null
  48 + );
48 49 }
49   -
50   - return (
51   - null
52   - );
53 50 };
54 51  
55 52 };
... ...
imports/client/views/org/enter/ForgotPane.js
... ... @@ -13,7 +13,7 @@ export class ForgotPane extends React.Component {
13 13  
14 14 render() {
15 15 return (
16   - <Col lg={{ size: 6, pull: 2, push: 2, offset: 1 }} md={{ size: 9, pull: 1, push: 1 }} sm={{ size: 10, push: 1, pull: 1 }}>
  16 + <Col sm={{ size: 12, push: 1, pull: 1 }}>
17 17 <VelocityTransitionGroup enter={{ animation: "transition.slideRightIn"}} leave={{animation: "transition.fadeOut" }} runOnMount={true}>
18 18 <div className="enterPane__centerVerticallyWrapper">
19 19 <Link
... ...
imports/collections/students/methods.js
... ... @@ -21,88 +21,3 @@ export const studentMethods = new ValidatedMethod({
21 21 },
22 22  
23 23 });
24   -
25   -export const addStudentManually = new ValidatedMethod({
26   - name: 'student.addManually',
27   -
28   - validate: new SimpleSchema({
29   - admissionId: { type: String },
30   - firstName: { type: String },
31   - lastName: { type: String },
32   - email: { type: String },
33   - dob: { type: String },
34   - gender: { type: String },
35   - rollNo: { type: String },
36   - studentClass: { type: String },
37   - section: { type: String },
38   - community: { type: String },
39   - bloodGroup: { type: String },
40   - phone: { type: String },
41   - address: { type: String },
42   - city: { type: String },
43   - state: { type: String },
44   - parentName: { type: String },
45   - parentEmail: { type: String },
46   - relation: { type: String },
47   - profession: { type: String },
48   - parentGender: { type: String },
49   - parentPhone: { type: String },
50   - parentAddress: { type: String },
51   - parentCity: { type: String },
52   - parentState: { type: String },
53   - parentZipcode: { type: String },
54   - }).validator(),
55   -
56   - run(data) {
57   - console.log("data");
58   - console.log(data);
59   - const user = Users.findOne({_id: this.userId});
60   - orgId = user.orgId;
61   - newStudentId = Users.insert({
62   - emails: [{address:data.email, verified: false}],
63   - firstName: data.firstName,
64   - lastName: data.lastName,
65   - orgId: orgId,
66   - role: 'STUDENT'
67   - });
68   - newParentUserId = Users.insert({
69   - emails: [{address:data.parentEmail, verified: false}],
70   - firstName: data.parentName,
71   - orgId: orgId,
72   - role: 'PARENT'
73   - });
74   - if(newParentUserId){
75   - newParentId = Parents.insert({
76   - userId: newParentUserId,
77   - orgId: orgId,
78   - address: data.address,
79   - gender: data.gender,
80   - dob: data.dob,
81   - rollNo: data.rollNo,
82   - studentClass: data.studentClass,
83   - section: data.section,
84   - bloodGroup: data.bloodGroup,
85   - community: data.community,
86   - relationship: data.relation,
87   - });
88   - }
89   - if(newStudentId){
90   - Students.insert({
91   - userId: newStudentId,
92   - orgId: orgId,
93   - admissionId: data.admissionId,
94   - address: data.address,
95   - gender: data.gender,
96   - dob: data.dob,
97   - rollNo: data.rollNo,
98   - class: data.studentClass,
99   - section: data.section,
100   - bloodGroup: data.bloodGroup,
101   - community: data.community,
102   - parent: [{id: newParentUserId, relationship: data.relation}]
103   - });
104   - }
105   - return {newStudentId};
106   - },
107   -
108   -});
... ...
imports/collections/students/publications.js
... ... @@ -8,5 +8,5 @@ import { Students } from &#39;/imports/collections/students/in
8 8 Meteor.publish('student.forMyOrg', function () {
9 9 const user = Users.findOne({_id: this.userId});
10 10 if(!user) return [];
11   - return Students.find({orgId: user.orgId});
  11 + return Students.find({orgId: user.orgId,"admissionId" : {"$exists" : true, "$ne" : ""}});
12 12 });
... ...
imports/collections/students/serverMethods.js
... ... @@ -0,0 +1,108 @@
  1 +// import { } from '/imports/collections/students/methods';
  2 +import _ from 'lodash';
  3 +import { Meteor } from 'meteor/meteor';
  4 +import { ValidatedMethod } from 'meteor/mdg:validated-method';
  5 +import { SimpleSchema } from 'meteor/aldeed:simple-schema';
  6 +import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';
  7 +import { Bert } from 'meteor/themeteorchef:bert';
  8 +import { Users } from '/imports/collections/users/index';
  9 +import { Students } from '/imports/collections/students/index';
  10 +import { Parents } from '/imports/collections/parents/index';
  11 +import { Orgs } from '/imports/collections/orgs/index';
  12 +export const studentServerMethods = new ValidatedMethod({
  13 + name: 'student.serverMethod',
  14 +
  15 + validate: new SimpleSchema({
  16 + itemId: { type: String },
  17 + }).validator(),
  18 +
  19 + run({itemId}) {
  20 + return {};
  21 + },
  22 +
  23 +});
  24 +
  25 +export const addStudentManually = new ValidatedMethod({
  26 + name: 'student.addManually',
  27 +
  28 + validate: new SimpleSchema({
  29 + admissionId: { type: String },
  30 + firstName: { type: String },
  31 + lastName: { type: String },
  32 + email: { type: String },
  33 + dob: { type: String },
  34 + gender: { type: String },
  35 + rollNo: { type: String },
  36 + studentClass: { type: String },
  37 + section: { type: String },
  38 + community: { type: String },
  39 + bloodGroup: { type: String },
  40 + phone: { type: String },
  41 + address: { type: String },
  42 + city: { type: String },
  43 + state: { type: String },
  44 + parentName: { type: String },
  45 + parentEmail: { type: String },
  46 + relation: { type: String },
  47 + profession: { type: String },
  48 + parentGender: { type: String },
  49 + parentPhone: { type: String },
  50 + parentAddress: { type: String },
  51 + parentCity: { type: String },
  52 + parentState: { type: String },
  53 + parentZipcode: { type: String },
  54 + }).validator(),
  55 +
  56 + run(data) {
  57 + console.log("data");
  58 + console.log(data);
  59 + const user = Users.findOne({_id: this.userId});
  60 + orgId = user.orgId;
  61 + newStudentId = Users.insert({
  62 + emails: [{address:data.email, verified: false}],
  63 + firstName: data.firstName,
  64 + lastName: data.lastName,
  65 + orgId: orgId,
  66 + role: 'STUDENT'
  67 + });
  68 + newParentUserId = Users.insert({
  69 + emails: [{address:data.parentEmail, verified: false}],
  70 + firstName: data.parentName,
  71 + orgId: orgId,
  72 + role: 'PARENT'
  73 + });
  74 + if(newParentUserId){
  75 + newParentId = Parents.insert({
  76 + userId: newParentUserId,
  77 + orgId: orgId,
  78 + address: data.address,
  79 + gender: data.gender,
  80 + dob: data.dob,
  81 + rollNo: data.rollNo,
  82 + studentClass: data.studentClass,
  83 + section: data.section,
  84 + bloodGroup: data.bloodGroup,
  85 + community: data.community,
  86 + relationship: data.relation,
  87 + });
  88 + }
  89 + if(newStudentId){
  90 + Students.insert({
  91 + userId: newStudentId,
  92 + orgId: orgId,
  93 + admissionId: data.admissionId,
  94 + address: data.address,
  95 + gender: data.gender,
  96 + dob: data.dob,
  97 + rollNo: data.rollNo,
  98 + class: data.studentClass,
  99 + section: data.section,
  100 + bloodGroup: data.bloodGroup,
  101 + community: data.community,
  102 + parent: [{id: newParentUserId, relationship: data.relation}]
  103 + });
  104 + }
  105 + return {newStudentId};
  106 + },
  107 +
  108 +});
... ...
imports/server/collections.js
... ... @@ -6,6 +6,7 @@ import &#39;/imports/collections/users/publications&#39;;
6 6 import '/imports/collections/students/methods';
7 7 import '/imports/collections/students/publications';
8 8 import '/imports/collections/students/serverCsvUpload';
  9 +import '/imports/collections/students/serverMethods';
9 10  
10 11 import '/imports/collections/staff/methods';
11 12 import '/imports/collections/staff/publications';
... ...