Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
1d584b6
setup npm and express
jareddaniel95 Aug 6, 2022
58797b0
Update README.md
ms13380 Aug 6, 2022
6d205b1
Merge pull request #1 from ms13380/jared
jareddaniel95 Aug 6, 2022
2c299cb
Added poll_results.sql
AmartinVT Aug 6, 2022
0317aa3
Update README.md
ms13380 Aug 6, 2022
5967307
Test commit
AmartinVT Aug 6, 2022
4ad43d3
Flesh out readme, add server.js
jareddaniel95 Aug 11, 2022
b6f197f
Merge branch 'main' into jared
jareddaniel95 Aug 11, 2022
668b440
Merge pull request #2 from ms13380/jared
jareddaniel95 Aug 11, 2022
12dcdf3
Merged to main branch
AmartinVT Aug 11, 2022
260fa7d
Created helper function for random 6-digit ID
AmartinVT Aug 11, 2022
5adb827
Merge pull request #3 from ms13380/MartinVT
jareddaniel95 Aug 13, 2022
a88f89e
Add Answer and User tables
jareddaniel95 Aug 13, 2022
a5ea9d0
Created /models/polls.js
AmartinVT Aug 13, 2022
1472f3a
Merge pull request #4 from ms13380/jared
jareddaniel95 Aug 13, 2022
40d74b2
Merge pull request #5 from ms13380/MartinVT
AmartinVT Aug 13, 2022
f80fa17
Merge pull request #6 from ms13380/Michael
ms13380 Aug 13, 2022
4c2f9ca
change file structure
jareddaniel95 Aug 13, 2022
28f0b83
Merge pull request #7 from ms13380/jared
jareddaniel95 Aug 13, 2022
13e0706
adjust file structure again
jareddaniel95 Aug 13, 2022
0fbfa15
Merge pull request #8 from ms13380/jared
jareddaniel95 Aug 13, 2022
2898e14
Created polls.js model
AmartinVT Aug 13, 2022
94d48d6
Add home controller
jareddaniel95 Aug 13, 2022
3943530
Merge pull request #9 from ms13380/jared
jareddaniel95 Aug 13, 2022
fb6732c
Merge pull request #11 from ms13380/MartinVT
AmartinVT Aug 13, 2022
fd5d566
Merge pull request #12 from ms13380/Michael
ms13380 Aug 13, 2022
25d3c46
Delete user-examples.html
ms13380 Aug 13, 2022
fc0a16c
Update home route to match poll schema
jareddaniel95 Aug 13, 2022
0019c84
Merge pull request #13 from ms13380/jared
jareddaniel95 Aug 13, 2022
720b2a1
Get basic homepage working
jareddaniel95 Aug 13, 2022
6edc29f
Merge pull request #14 from ms13380/jared
jareddaniel95 Aug 13, 2022
2ba2857
Add seed data
jareddaniel95 Aug 13, 2022
051be9d
Merge pull request #15 from ms13380/jared
jareddaniel95 Aug 13, 2022
628c6db
Add get poll route
jareddaniel95 Aug 13, 2022
fcf631d
Merge pull request #16 from ms13380/jared
jareddaniel95 Aug 13, 2022
a0733f9
Update main.handlebars
ms13380 Aug 14, 2022
e689708
Update main.handlebars
ms13380 Aug 14, 2022
2a7d8ce
Add chart.js poll view
jareddaniel95 Aug 15, 2022
6c6616d
Added login.js > built login.js
AmartinVT Aug 15, 2022
f5b48db
Added logout.js > built logout.js
AmartinVT Aug 15, 2022
d572337
Merge pull request #17 from ms13380/MartinVT
AmartinVT Aug 15, 2022
607ebdb
Added routes and .js for logging in and logging out
AmartinVT Aug 15, 2022
eeb499a
Merge pull request #18 from ms13380/MartinVT
AmartinVT Aug 15, 2022
e9e22a2
Add create-poll page (not working yet)
jareddaniel95 Aug 16, 2022
08826b5
Merge branch 'main' of github.com:ms13380/PollTogether into test_chartjs
jareddaniel95 Aug 16, 2022
9e2d72d
Add poll creation flow
jareddaniel95 Aug 16, 2022
bbebe27
Merge pull request #19 from ms13380/test_chartjs
jareddaniel95 Aug 16, 2022
34aa36d
Add search field functionality, add option to remove extra options in…
jareddaniel95 Aug 16, 2022
f19ac92
Merge pull request #20 from ms13380/jared
jareddaniel95 Aug 16, 2022
f271302
Hooks: add hash password before update
Aug 17, 2022
4f23632
password validation msg
Aug 17, 2022
c03d2bb
user linked to the poll by adding references
Aug 17, 2022
83377d9
Poll linked to the Answer by adding references
Aug 17, 2022
fb0fdd5
User linked to Answer by adding references
Aug 17, 2022
290c830
onDelete: CASCADE,for user
Aug 17, 2022
6f2d0af
Get all users with their polls and answers
Aug 17, 2022
9ca92a0
Get a single user by his id
Aug 17, 2022
c0b6283
Get a poll with the pollar and his answer
Aug 17, 2022
c427ca6
Get all the polls with their pollars and answers
Aug 17, 2022
741aa56
Update homepage
jareddaniel95 Aug 17, 2022
d273f77
Merge pull request #21 from ms13380/jared
jareddaniel95 Aug 17, 2022
f2258e9
Added model config for poll expiration date
AmartinVT Aug 17, 2022
34435dc
Update main.handlebars
ms13380 Aug 17, 2022
49db059
Added expiration date functionality
AmartinVT Aug 17, 2022
c2e7bab
Merge pull request #22 from ms13380/MartinVT
AmartinVT Aug 17, 2022
9ad90e1
Merge branch 'main' into bob
jareddaniel95 Aug 17, 2022
e8a6343
Merge pull request #23 from ms13380/bob
jareddaniel95 Aug 17, 2022
ba30740
Hompage has 6 polls
jareddaniel95 Aug 17, 2022
4a95051
Merge branch 'main' of github.com:ms13380/PollTogether into jared
jareddaniel95 Aug 17, 2022
b931044
Fix broken connection.js
jareddaniel95 Aug 17, 2022
484e5e6
Merge pull request #24 from ms13380/jared
jareddaniel95 Aug 17, 2022
b6bb231
Update main.handlebars
ms13380 Aug 17, 2022
aa3caf8
Update main.handlebars
ms13380 Aug 18, 2022
c38e370
Update main.handlebars
ms13380 Aug 18, 2022
b529997
throwaway
jareddaniel95 Aug 18, 2022
5956f7b
Revert "Merge pull request #23 from ms13380/bob"
jareddaniel95 Aug 18, 2022
1f91aea
Merge pull request #25 from ms13380/jared
jareddaniel95 Aug 18, 2022
be8a8eb
Update homepage.handlebars
ms13380 Aug 18, 2022
2db3bbd
Merge pull request #26 from ms13380/ms13380
ms13380 Aug 18, 2022
2fdc249
Update homepage.handlebars
ms13380 Aug 18, 2022
9d77b60
Merge pull request #27 from ms13380/main
ms13380 Aug 18, 2022
0bc1532
Merge pull request #28 from ms13380/ms13380
ms13380 Aug 18, 2022
ba12890
Update style.css
ms13380 Aug 18, 2022
271c710
Merge pull request #29 from ms13380/ms13380
ms13380 Aug 18, 2022
4421ede
Added functionality for dashboard
AmartinVT Aug 18, 2022
c0373e4
Merge pull request #30 from ms13380/MartinVT
AmartinVT Aug 18, 2022
10ea21e
added files
AmartinVT Aug 18, 2022
9263e38
Merge pull request #31 from ms13380/MartinVT
AmartinVT Aug 18, 2022
f612ce3
Add ability to vote
jareddaniel95 Aug 18, 2022
87dd29a
BUG WITH DASHBOARD EDIT: Added edit route, partial view, and function
AmartinVT Aug 18, 2022
ad97794
BUG WITH DASHBOARD EDIT: Added edit route, partial view, and function
AmartinVT Aug 18, 2022
d5431c8
Voting completed and check poll_expire before allowing vote
jareddaniel95 Aug 18, 2022
bc8acd2
Merge pull request #32 from ms13380/jared
jareddaniel95 Aug 18, 2022
a90dbcf
Answer post route now validates expiration date, hide expiration date…
jareddaniel95 Aug 18, 2022
60121c5
Merge pull request #33 from ms13380/jared
jareddaniel95 Aug 18, 2022
de67402
Add styling
jareddaniel95 Aug 19, 2022
4b98503
Merge pull request #34 from ms13380/jared
jareddaniel95 Aug 19, 2022
03f52ef
Edit functionality progress
AmartinVT Aug 19, 2022
5577710
Merge pull request #35 from ms13380/MartinVT
AmartinVT Aug 19, 2022
7f2ea83
Add ability to edit poll descriptions, make chartjs only show whole n…
jareddaniel95 Aug 19, 2022
678cffb
Merge pull request #36 from ms13380/jared
jareddaniel95 Aug 19, 2022
2a959c1
Add length limits to inputs, make poll_options a TEXT datatype, fix b…
jareddaniel95 Aug 19, 2022
d9524b1
Merge pull request #37 from ms13380/jared
jareddaniel95 Aug 19, 2022
82e18d1
More styling
jareddaniel95 Aug 19, 2022
94ce68d
Merge pull request #38 from ms13380/jared
jareddaniel95 Aug 19, 2022
6291a28
limit display of descriptions in card view, enable linebreaks to work…
jareddaniel95 Aug 19, 2022
551d6e1
Add user pages, update about us page
jareddaniel95 Aug 20, 2022
f7aad9d
Merge pull request #39 from ms13380/jared
jareddaniel95 Aug 20, 2022
4df3cb0
Fix issue with voting in heroku
jareddaniel95 Aug 20, 2022
cb7dc4d
styling for login/register pages, update create poll page, stop forci…
jareddaniel95 Aug 20, 2022
29ac674
Merge pull request #40 from ms13380/jared
jareddaniel95 Aug 20, 2022
c3f0ffe
Fix bug that caused links to be unusable on dashboard/user pages, Adj…
jareddaniel95 Aug 20, 2022
e5e5711
Merge pull request #41 from ms13380/jared
jareddaniel95 Aug 20, 2022
b267f1f
Add seeds, show poll results when able to vote
jareddaniel95 Aug 20, 2022
c1b8e11
Merge pull request #42 from ms13380/jared
jareddaniel95 Aug 20, 2022
97229e2
Changing the title and font in the md
EdoubleL Aug 20, 2022
8dcbdc8
Creating User Story
EdoubleL Aug 20, 2022
708e78a
Restructure the layout
EdoubleL Aug 20, 2022
b995b7f
Revamp heading
EdoubleL Aug 20, 2022
9f44cd7
Insertion of emojis
EdoubleL Aug 20, 2022
2f0162f
Title Change and font change
EdoubleL Aug 20, 2022
0604f1a
README Repository
EdoubleL Aug 20, 2022
9da25fc
Picture of website
EdoubleL Aug 20, 2022
ec5a8e8
Customize how to
EdoubleL Aug 20, 2022
9a44b20
Description of site functionality
EdoubleL Aug 20, 2022
7ab76e8
Technology used
EdoubleL Aug 20, 2022
a59721e
Style changes
EdoubleL Aug 20, 2022
1bbec4f
Final edits
EdoubleL Aug 20, 2022
b41e1e2
Update README.md
EdoubleL Aug 20, 2022
e1592a0
Review and correction of edits
EdoubleL Aug 20, 2022
b0e7a8e
Merge pull request #43 from ms13380/EdoubleL-patch-1
EdoubleL Aug 20, 2022
cde7a41
Add link to user's profile on poll page
jareddaniel95 Aug 20, 2022
add257f
Merge pull request #44 from ms13380/jared
jareddaniel95 Aug 20, 2022
efa331b
Update README.md
jareddaniel95 Aug 20, 2022
22dc9f6
Update README.md
jareddaniel95 Aug 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
.env
.DS_Store
152 changes: 149 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,149 @@
# Project
Together or together? For that is the question
### https://ms13380.github.io/PollTogether/
# PollTogether
Together or together? For THAT is the question
### https://poll-together.herokuapp.com/

## Made by the Polars

## How PollTogether Came to Be

```md
OUR INSPIRATION was simple - To CREATE an easy, fun, and graphical way to get your "Fist-of-Five"!
IT SOLVES - HOW can you gauge what your students are thinking or what do they want to do instantly? 🤔
AS A bootcamp instructor, or for anyone who cares to easily create a poll, PollTogether is here for you!

THE QUESTION is, "Together or together?"
The SOLUTION is PollTogether 👍
```
![image](https://user-images.githubusercontent.com/103905661/185743118-751bf828-f95e-4e09-8ab9-a10704058d2c.png)

## How-To: Polling made fun and easy

```md

WHEN you first visit our site you're given 6 examples of polls
REGISTER to start your journey - Upper Right hand corner, middle option, click to register
LOGIN the fun begins. ❤️ Once you login current page will now show the most recent polls
CLICK TO SEARCH Now you're in the driver seat. Find past polls you've conducted to see the results or use the polls again
BUTTONS of creative fun. 😀 We've made creating a poll easy.
YOUR CHOICE OF:
WHAT you want to take a poll on. Create exactly what you will be taking a poll on
WHO can take the poll
WHAT options of answers your users can have
SHARE your poll. Your users will now have a poll's ID that you shared with them so they can answer
NO FIST-OF-TEN ✊✊❌ We've got you covered because we coded it in such a way that your user can only answer once per their credentials
THEN an answer is recorded in the database 💽
SEE the results. 📊 Once the polling is comnplete, you now have a graphical representation of what your users chose


```
### Technology Utilized

```md

Javascript
NODE.JS
Bootstrap
Express
Handlebars
SQL
Sequelize
Chart.js
jQuery

```


### Database Models

Your database should contain the following four models, including the requirements listed for each model:

* `User`

* `id`

* Integer.

* Doesn't allow null values.

* Set as primary key.

* Uses auto increment.

* `username`

* String.

* Doesn't allow null values.

* `email`

* String.

* Doesn't allow null values.

* `password`

* String.

* Doesn't allow null values.

* `Poll`

* `id`

* Integer.

* Doesn't allow null values.

* Set as primary key.

* Generated 6 diget code

* `poll_name`

* String.

* Allow null values.

* `description`

* String.

* Allow null values.

* `created_by`

* Integer.

* Doesn't allow null values.

* References the `User` model's `id`.

* `poll_expire`

* Date.

* Allow null values.

* `Answer`

* `poll_id`

* Integer.

* Doesn't allow null values.

* References the `Poll` model's `id`.

* `answer`

* String.

* Doesn't allow null values.


### Associations

* `Poll` belongs to `User`, and `User` has many `Poll` models.

* `Answer` belongs to `Poll` model, and `Poll` has many `Answer` models.
21 changes: 21 additions & 0 deletions config/connection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const Sequelize = require('sequelize');
require('dotenv').config();

let sequelize;

if (process.env.JAWSDB_URL) {
sequelize = new Sequelize(process.env.JAWSDB_URL);
} else {
sequelize = new Sequelize(
process.env.DB_NAME,
process.env.DB_USER,
process.env.DB_PASSWORD,
{
host: 'localhost',
dialect: 'mysql',
port: 3306,
}
);
}

module.exports = sequelize;
25 changes: 25 additions & 0 deletions controllers/api/answer-routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const router = require('express').Router();
const { Answer, Poll } = require('../../models');
const withAuth = require('../../utils/auth');

router.post('/', withAuth, async (req, res) => {
try {
const poll = await Poll.findByPk(req.body.poll_id, {
});
const expiration = poll.poll_expire ? new Date(new Date(poll.poll_expire).toUTCString()) : null;
const today = new Date(new Date().toUTCString());
if (expiration && expiration < today) {
throw 'Poll expired.';
}
const data = await Answer.create({
poll_id: req.body.poll_id,
user_id: req.session.user_id,
option: req.body.option
});
res.json(data);
} catch (err) {
res.status(500).json(err);
}
});

module.exports = router;
12 changes: 12 additions & 0 deletions controllers/api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

const router = require('express').Router();

const userRoutes = require('./user-routes');
const pollRoutes = require('./poll-routes');
const answerRoutes = require('./answer-routes');

router.use('/users', userRoutes);
router.use('/polls', pollRoutes);
router.use('/answers', answerRoutes);

module.exports = router;
73 changes: 73 additions & 0 deletions controllers/api/poll-routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const router = require('express').Router();
const { Poll } = require('../../models');
const withAuth = require('../../utils/auth');

router.post('/', withAuth, async (req, res) => {
try {
const data = await Poll.create({
id: req.body.poll_id,
poll_title: req.body.poll_title,
poll_desc: req.body.poll_desc,
poll_options: req.body.poll_options,
user_id: req.session.user_id,
poll_expire: req.body.poll_expire
});
res.status(200).json(data);
} catch (err) {
res.status(500).json(err);
}
});

router.put('/:id', withAuth, async (req, res) => {
try {
const data = await Poll.update({
poll_desc: req.body.poll_desc
},
{
where: {
id: req.params.id
}
});
if (!data) {
res.status(404).json({message: 'No post with this ID'});
return;
}
res.json(data);
} catch (err) {
res.status(500).json(err);
}
});

router.delete('/:id', withAuth, async (req, res) => {
try {
const data = await Post.destroy({
where: {
id: req.params.id
}
});
if (!data) {
res.status(404).json({message: 'No post with this ID'});
return;
}
res.json(data);
} catch (err) {
res.status(500).json(err);
}
});

router.get('/:id', async (req, res) => {
try {
const pollData = await Poll.findByPk(req.params.id, {
attributes: ['id'],
});
if (pollData) {
res.status(200).json(pollData);
} else {
res.status(404).json(pollData);
}
} catch (err) {
res.status(500).json(err);
}
});

module.exports = router;
78 changes: 78 additions & 0 deletions controllers/api/user-routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const router = require('express').Router();
const { User } = require('../../models');

router.post('/', async (req, res) => {
try {
const data = await User.create({
username: req.body.username,
email: req.body.email,
password: req.body.password.toString(),
});

req.session.save(() => {
req.session.loggedIn = true;
req.session.user_id = data.id;
req.session.username = data.username;

res.status(200).json(data);
});
} catch (err) {
console.log(err);
res.status(500).json(err);
}
});

router.post('/login', async (req, res) => {
try {
const data = await User.findOne({
where: {
email: req.body.email,
},
});

if (!data) {
res
.status(400)
.json({ message: 'Incorrect email. Please try again!' });
return;
}

const validPassword = await data.checkPassword(req.body.password.toString());

if (!validPassword) {
res
.status(400)
.json({ message: 'Incorrect password. Please try again!' });
return;
}

req.session.save(() => {
req.session.loggedIn = true;
req.session.user_id = data.id;
req.session.username = data.username;

res
.status(200)
.json({ user: data, message: 'You are now logged in!' });
});
} catch (err) {
console.log(err);
res.status(500).json(err);
}
});

router.post('/logout', (req, res) => {
if (req.session.loggedIn) {
req.session.destroy(() => {
res.status(204).end();
});
} else {
res.status(404).end();
}
});

module.exports = router;




Loading