Guest User

Untitled

a guest
May 13th, 2018
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. app.get('/sample-edit/:cid',
  2. setRender('dashboard/sample-edit.hbs'),
  3. setRedirect({auth: '/'}),
  4. isAuthenticated,
  5. users.getSampleEdit);
  6.  
  7. var userSchema = new mongoose.Schema({
  8. email: { type: String, unique: true, lowercase: true },
  9. password: String,
  10.  
  11. profile: {
  12. name: { type: String, default: '' },
  13. location: { type: String, default: '' }
  14. },
  15. image: {
  16. path: { type: String, default: '' },
  17. },
  18. sample:
  19. [{
  20. name: String,
  21. description: String,
  22. purchase: String,
  23. brand: String,
  24. material: String,
  25. notes: String,
  26. qty: String,
  27. imgpath: String,
  28. }],
  29. resetPasswordToken: String,
  30. resetPasswordExpires: Date
  31. });
  32.  
  33. exports.getSampleEdit = function(req, res, next){
  34. User.findById(req.user.id, { sample: { $elemMatch: { _id: ObjectId } } },
  35. function(err, user) {
  36. if (err) return next(err);
  37.  
  38. var form = {},
  39. error = null,
  40. formFlash = req.flash('form'),
  41. errorFlash = req.flash('error');
  42.  
  43. if (formFlash.length) {
  44. form.email = formFlash[0].email;
  45. }
  46. if (errorFlash.length) {
  47. error = errorFlash[0];
  48. }
  49. res.render(req.render, {user: req.user, form: form, error: error});
  50.  
  51. console.log(req.params.id)
  52.  
  53. });
  54.  
  55. };
  56.  
  57. <form action="/user/sample" method="POST" class="form-horizontal">
  58.  
  59. <div class="form-group">
  60. <label for="name" class="col-sm-3 control-label">Sample Name:</label>
  61. <div class="col-lg-offset-3 col-sm-4"><input type="text" name="name" id="name" value="{{sample.name}}" class="form-control"></div>
  62. </div>
  63.  
  64. <div class="form-group">
  65. <label for="description" class="col-sm-3 control-label">Description:</label>
  66. <div class="col-sm-4"><input type="text" name="description" id="description" value="{{sample.description}}" class="form-control"></div>
  67. </div>
  68.  
  69. <div class="form-group">
  70. <label for="description" class="col-sm-3 control-label">Where did you buy it from?</label>
  71. <div class="col-sm-4"><input type="text" name="purchase" id="purchase" value="{{sample.purchase}}" class="form-control"></div>
  72. </div>
  73.  
  74. <div class="form-group">
  75. <label for="description" class="col-sm-3 control-label">Brand:</label>
  76. <div class="col-sm-4"><input type="text" name="brand" id="brand" value="{{sample.brand}}" class="form-control"></div>
  77. </div>
  78.  
  79. <div class="form-group">
  80. <label for="description" class="col-sm-3 control-label">Material:</label>
  81. <div class="col-sm-4"><input type="text" name="material" id="material" value="{{sample.material}}" class="form-control"></div>
  82. </div>
  83.  
  84. <div class="form-group">
  85. <label for="description" class="col-sm-3 control-label">Notes:</label>
  86. <div class="col-sm-4"><input type="text" name="notes" id="notes" value="{{sample.notes}}" class="form-control"></div>
  87. </div>
  88.  
  89. <div class="form-group">
  90. <label for="description" class="col-sm-3 control-label">How much sample do you have?</label>
  91. <div class="col-sm-4"><input type="text" name="qty" id="qty" value="{{sample.qty}}" class="form-control"></div>
  92. </div>
  93.  
  94. <div class="form-group">
  95. <label for="description" class="col-sm-3 control-label">Image</label>
  96. <div class="col-sm-4"><input type="text" name="imgpath" id="imgpath" value="{{sample.imgpath}}" class="form-control"></div>
  97. </div>
  98.  
  99.  
  100.  
  101. <div class="form-group">
  102. <div class="col-sm-offset-3 col-sm-4"><button type="submit" class="btn btn-primary"><span class="ion-edit"></span>Save Sample</button></div>
  103. </div>
  104. </form>
Add Comment
Please, Sign In to add comment