-
Notifications
You must be signed in to change notification settings - Fork 0
Worked on email templete #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Santan24
wants to merge
19
commits into
master
Choose a base branch
from
santan
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
e4769bf
commit
55b2ca8
survey recipient models added
3009f9f
Added middleware
08f0559
comments removed
89081f2
removed extra spaces
27d5070
utils added
5e13288
corret user in app.js
b455df2
Activation link correction
71be255
feedback retrieving
de15739
get survey and updated profile
4de8d8d
Updated mail
221b653
Added logo in mail
9db0fe7
changed spellings of please
1e7b685
Fixed bugs
9bb471e
Dockerfile created
ffec875
Changes in docker
57aaa7a
changes in docker file
9c4bf8d
docker file changes
f67023e
Docker new image pushed
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,12 @@ const cors = require("cors"); | |
const bcryptjs = require("bcryptjs"); | ||
require("dotenv").config(); | ||
require("./db/connectionDB"); | ||
require('./models/User') | ||
require('./models/Survey') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be /survey. Filename case should match always. |
||
const authRoutes = require("./routes/auth"); | ||
const surveyRoutes = require("./routes/survey"); | ||
|
||
const app = express(); | ||
|
||
app.use(express.urlencoded({ extended: true })); | ||
app.use(express.json()); | ||
app.use(cors()); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = (req, res, next) => { | ||
if (!req.user.credits <1) { | ||
return res.status(403).send({ error: " You do Not have enough Credits!" }); | ||
} | ||
next(); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = (req, res, next) => { | ||
if (!req.user) { | ||
return res.status(401).send({ error: 'You must log in!' }); | ||
} | ||
|
||
next(); | ||
}; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const mongoose = require("mongoose"); | ||
const { Schema } = mongoose; | ||
const recipientSchema = new Schema({ | ||
email: String, | ||
responded: { type: Boolean, default: false }, | ||
}); | ||
|
||
module.exports = recipientSchema; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,35 @@ | ||
|
||
const mongoose=require('mongoose') | ||
|
||
const surveySchema=mongoose.Schema({ | ||
title:{ | ||
type:String | ||
}, | ||
type:{ | ||
type:String | ||
}, | ||
|
||
questionsSet:[ | ||
{ | ||
ques:{ | ||
type: String | ||
}, | ||
ans:{ | ||
type: [Boolean] | ||
} | ||
} | ||
] | ||
|
||
}) | ||
//created the survey api now | ||
const Survey = mongoose.model("Survey",surveySchema) | ||
module.exports={Survey} | ||
const mongoose = require("mongoose"); | ||
const recipientSchema= require('./recipient') | ||
const surveySchema = mongoose.Schema({ | ||
title: { | ||
type: String, | ||
}, | ||
category: { | ||
type: String, | ||
}, | ||
body: { | ||
type: String, | ||
}, | ||
subject: { | ||
type: String, | ||
}, | ||
recipients:[ | ||
recipientSchema | ||
], | ||
yes: { | ||
type: Number, | ||
default: 0, | ||
}, | ||
No: { | ||
type: Number, | ||
default: 0, | ||
}, | ||
_user:{ | ||
type:mongoose.Schema.Types.ObjectId, | ||
ref:'User' | ||
}, | ||
dateSent: Date, | ||
lastResponded: Date | ||
}); | ||
const Survey = mongoose.models.Survey||mongoose.model("Survey", surveySchema); | ||
module.exports = { Survey }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,23 @@ | ||
const express = require("express"); | ||
const { createSurvey } = require("../controllers/survey"); | ||
const router = express.Router(); | ||
const mongoose = require("mongoose"); | ||
const requireLogin = require("../middlewares/requireLogin"); | ||
const requireCredits = require("../middlewares/requireCredits"); | ||
const { Survey } = require("../models/survey"); | ||
|
||
router.post("/createsurvey", createSurvey); | ||
|
||
module.exports = router; | ||
module.exports = (app) => { | ||
app.post("api/surveys", requireLogin, requireCredits, (req, res) => { | ||
const { title, category, body, recipients } = req.body; | ||
const survey = new Survey({ | ||
title, | ||
category, | ||
subject, | ||
body, | ||
recipients: recipients | ||
.split(",") | ||
.map((email) => ({ email: email.trim() })), | ||
_user: req.user.id, | ||
dateSent: Date.now(), | ||
}); | ||
survey.save(); | ||
}); | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.