// import { } from '/imports/collections/students/methods'; import _ from 'lodash'; import { Meteor } from 'meteor/meteor'; import { ValidatedMethod } from 'meteor/mdg:validated-method'; import { SimpleSchema } from 'meteor/aldeed:simple-schema'; import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; import { Bert } from 'meteor/themeteorchef:bert'; import { Users } from '/imports/collections/users/index'; import { Students } from '/imports/collections/students/index'; import { Parents } from '/imports/collections/parents/index'; import { Orgs } from '/imports/collections/orgs/index'; export const studentMethods = new ValidatedMethod({ name: 'student.method', validate: new SimpleSchema({ itemId: { type: String }, }).validator(), run({itemId}) { return {}; }, }); export const addStudentManually = new ValidatedMethod({ name: 'student.addManually', validate: new SimpleSchema({ admissionId: { type: String }, firstName: { type: String }, lastName: { type: String }, email: { type: String }, dob: { type: String }, gender: { type: String }, rollNo: { type: String }, studentClass: { type: String }, section: { type: String }, community: { type: String }, bloodGroup: { type: String }, phone: { type: String }, address: { type: String }, city: { type: String }, state: { type: String }, parentName: { type: String }, parentEmail: { type: String }, relation: { type: String }, profession: { type: String }, parentGender: { type: String }, parentPhone: { type: String }, parentAddress: { type: String }, parentCity: { type: String }, parentState: { type: String }, parentZipcode: { type: String }, }).validator(), run(data) { console.log("data"); console.log(data); const user = Users.findOne({_id: this.userId}); orgId = user.orgId; newStudentId = Users.insert({ emails: [{address:data.email, verified: false}], firstName: data.firstName, lastName: data.lastName, orgId: orgId, role: 'STUDENT' }); newParentUserId = Users.insert({ emails: [{address:data.parentEmail, verified: false}], firstName: data.parentName, orgId: orgId, role: 'PARENT' }); if(newParentUserId){ newParentId = Parents.insert({ userId: newParentUserId, orgId: orgId, address: data.address, gender: data.gender, dob: data.dob, rollNo: data.rollNo, studentClass: data.studentClass, section: data.section, bloodGroup: data.bloodGroup, community: data.community, relationship: data.relation, }); } if(newStudentId){ Students.insert({ userId: newStudentId, orgId: orgId, admissionId: data.admissionId, address: data.address, gender: data.gender, dob: data.dob, rollNo: data.rollNo, class: data.studentClass, section: data.section, bloodGroup: data.bloodGroup, community: data.community, parent: [{id: newParentUserId, relationship: data.relation}] }); } return {newStudentId}; }, });