Final Update From Caleb
Incorporated all Caleb's changes
This commit is contained in:
53
imports/api/ContactUsMessages.js
Normal file
53
imports/api/ContactUsMessages.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Mongo } from 'meteor/mongo';
|
||||
import { check } from 'meteor/check';
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
|
||||
let ContactUsMessages = new Mongo.Collection('ContactUsMessages');
|
||||
|
||||
ContactUsMessages.attachSchema(new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
label: "Name",
|
||||
optional: false,
|
||||
trim: false,
|
||||
},
|
||||
email: {
|
||||
type: String,
|
||||
label: "Email",
|
||||
optional: false,
|
||||
trim: false
|
||||
},
|
||||
message: {
|
||||
type: String,
|
||||
label: "Message",
|
||||
optional: false,
|
||||
trim: false
|
||||
},
|
||||
createdAt: {
|
||||
type: Date,
|
||||
label: "Created On",
|
||||
optional: true
|
||||
}
|
||||
}));
|
||||
|
||||
if(Meteor.isServer) Meteor.publish('contactUsMessages', function() {
|
||||
return ContactUsMessages.find({});
|
||||
});
|
||||
|
||||
if(Meteor.isServer) {
|
||||
Meteor.methods({
|
||||
submitContactForm: function(name, email, message) {
|
||||
check(name, String);
|
||||
check(email, String);
|
||||
check(message, String);
|
||||
|
||||
if(Roles.userIsInRole(this.userId, [Meteor.UserRoles.ROLE_UPDATE])) {
|
||||
ContactUsMessages.insert({name, email, message, createdAt: new Date()});
|
||||
}
|
||||
else throw new Meteor.Error(403, "Not authorized.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default ContactUsMessages;
|
||||
@@ -2,9 +2,10 @@
|
||||
import Users from "./User.js";
|
||||
import UserRoles from "./Roles.js";
|
||||
import Pages from "./Page.js";
|
||||
import ContactUsMessages from "./ContactUsMessages.js";
|
||||
|
||||
//Save the collections in the Meteor.collections property for easy access without name conflicts.
|
||||
Meteor.collections = {Users, UserRoles, Pages};
|
||||
Meteor.collections = {Users, UserRoles, Pages, ContactUsMessages};
|
||||
|
||||
//If this is the server then setup the default admin user if none exist.
|
||||
if(Meteor.isServer) {
|
||||
|
||||
Reference in New Issue
Block a user