Commit 1c4a8cc5d44c7966a03345de5f99fa1a0927958a

Authored by Deepak
1 parent d197619130
Exists in master

added parents data insertion when new student is added

imports/client/views/org/admin/students/addStudentForm.js
... ... @@ -15,33 +15,33 @@ export class AddStudentForm extends Component {
15 15 constructor(props) {
16 16 super(props);
17 17 this.state = {
18   - admissionId: "",
19   - firstName: "",
20   - lastName: "",
21   - middleName: "",
22   - email: "",
  18 + admissionId: "123",
  19 + firstName: "first",
  20 + lastName: "last",
  21 + middleName: "middle",
  22 + email: "deepak125.dk+21@gmail.com",
23 23 dob: "",
24 24 formattedDob: "",
25   - gender: "",
26   - rollNo: "",
27   - class: "",
28   - section: "",
29   - community: "",
30   - bloodGroup: "",
31   - phone: "",
32   - address: "",
33   - city: "",
34   - state: "",
35   - parentName: "",
36   - parentEmail: "",
37   - relation: "",
38   - profession: "",
39   - parentGender: "",
40   - parentPhone: "",
41   - parentAddress: "",
42   - parentCity: "",
43   - parentState: "",
44   - parentZipcode: "",
  25 + gender: "male",
  26 + rollNo: "1",
  27 + class: "2",
  28 + section: "B",
  29 + community: "SC",
  30 + bloodGroup: "B+",
  31 + phone: "9876543321",
  32 + address: "address",
  33 + city: "chennai",
  34 + state: "tn",
  35 + parentName: "parentName",
  36 + parentEmail: "deepak125.dk+41@gmail.com",
  37 + relation: "father",
  38 + profession: "farmer",
  39 + parentGender: "male",
  40 + parentPhone: "987655412",
  41 + parentAddress: "parentAddress",
  42 + parentCity: "parentCity",
  43 + parentState: "parentState",
  44 + parentZipcode: "parentZipcode",
45 45 };
46 46 this.onUpdate = this.onUpdate.bind(this);
47 47 this.handleDob = this.handleDob.bind(this);
... ...
imports/collections/students/index.js
... ... @@ -95,16 +95,16 @@ Students.schema = new SimpleSchema({
95 95 parent: {
96 96 type: [new SimpleSchema({
97 97 id: { type: String, },
98   - relatinship: { type: Boolean, },
  98 + relatinship: { type: String, },
99 99 })],
100 100 optional: true
101 101 },
102 102 prevInstitute: {
103 103 type: [new SimpleSchema({
104 104 name: { type: String, },
105   - fromYear: { type: Boolean, },
106   - toYear: { type: Boolean, },
107   - ydId: { type: Boolean, },
  105 + fromYear: { type: String, },
  106 + toYear: { type: String, },
  107 + ydId: { type: String, },
108 108 })],
109 109 optional: true
110 110 },
... ...
imports/collections/students/methods.js
... ... @@ -7,6 +7,7 @@ import { DDPRateLimiter } from 'meteor/ddp-rate-limiter';
7 7 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 +import { Parents } from '/imports/collections/parents/index';
10 11 import { Orgs } from '/imports/collections/orgs/index';
11 12 export const studentMethods = new ValidatedMethod({
12 13 name: 'student.method',
... ... @@ -60,26 +61,42 @@ export const addStudentManually = new ValidatedMethod({
60 61 const user = Users.findOne({_id: this.userId});
61 62 orgId = user.orgId;
62 63 newStudentId = Users.insert({
63   - emails: [data.email],
64   - username: firstName,
65   - firstName: firstName,
66   - middleName: middleName,
67   - lastName: lastName,
  64 + emails: [{address:data.email, verified: false}],
  65 + username: data.firstName,
  66 + firstName: data.firstName,
  67 + middleName: data.middleName,
  68 + lastName: data.lastName,
68 69 orgId: orgId,
69 70 role: 'STUDENT'
70 71 });
71   - newParentId = Users.insert({
72   - emails: [data.parentEmail],
73   - username: parentName,
74   - firstName: parentName,
  72 + newParentUserId = Users.insert({
  73 + emails: [{address:data.parentEmail, verified: false}],
  74 + username: data.parentName,
  75 + firstName: data.parentName,
75 76 orgId: orgId,
76 77 role: 'PARENT'
77 78 });
  79 + if(newParentUserId){
  80 + newParentId = Parents.insert({
  81 + userId: newParentUserId,
  82 + orgId: orgId,
  83 + address: data.address,
  84 + gender: data.gender,
  85 + dob: data.dob,
  86 + rollNo: data.rollNo,
  87 + class: data.studentclass,
  88 + section: data.section,
  89 + bloodGroup: data.bloodGroup,
  90 + community: data.community,
  91 + });
  92 + console.log("newParentUserId");
  93 + console.log(newParentUserId);
  94 + }
78 95 console.log("newUserId");
79   - console.log(newUserId);
80   - if(newUserId){
  96 + console.log(newStudentId);
  97 + if(newStudentId){
81 98 Students.insert({
82   - userId: newUserId,
  99 + userId: newStudentId,
83 100 orgId: orgId,
84 101 admissionId: data.admissionId,
85 102 address: data.address,
... ... @@ -90,10 +107,10 @@ export const addStudentManually = new ValidatedMethod({
90 107 section: data.section,
91 108 bloodGroup: data.bloodGroup,
92 109 community: data.community,
93   -
  110 + parent: [{id: newParentUserId, relatinship: data.relation}]
94 111 });
95 112 }
96   - return {newUserId};
  113 + return {newStudentId};
97 114 },
98 115  
99 116 });
... ...