Skip to content
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

Formatting #77

Open
wants to merge 87 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
82207d5
Added IntelliJ ignores to .gitignore. Added lock file.
TheBeege Oct 30, 2017
084c3b5
Added IntelliJ ignores to .gitignore. Added lock file.
TheBeege Oct 30, 2017
ee984e5
Updated readme. Updated package files
TheBeege Oct 30, 2017
afd051a
Updated readme. Updated package files
TheBeege Oct 30, 2017
d589199
Fixed formatting
TheBeege Oct 30, 2017
7e347e0
Fixed formatting
TheBeege Oct 30, 2017
b93e98d
Added description of current state
TheBeege Oct 30, 2017
fbabeb7
Added description of current state
TheBeege Oct 30, 2017
14baee1
Reformatted models files
TheBeege Oct 30, 2017
88f3214
Added hashing on save and password method to user model
TheBeege Oct 30, 2017
c75c5e0
Reformatted user model tests
TheBeege Oct 30, 2017
6823dc2
Fixed model destruction test
TheBeege Oct 30, 2017
12e6457
Fixed model creation tests
TheBeege Oct 30, 2017
09313e8
Removed unnecessary requires in create and destroy tests
TheBeege Oct 30, 2017
9cc9a40
Fixed tests to show errors properly. Added name as required to User
TheBeege Oct 30, 2017
468e2dc
Merge pull request #57 from LearnTeachCodeSeoul/update_readme
mepda Oct 30, 2017
630898b
Merge pull request #57 from LearnTeachCodeSeoul/update_readme
mepda Oct 30, 2017
6fac74a
Fixed a test. Still investigating remaining tests. Using 'expect' sem…
TheBeege Oct 31, 2017
e21203a
Changed formatting in userRepository. Minor fix in test
TheBeege Oct 31, 2017
f35460e
Passed another test. userRepository needed to set password. Tests are…
TheBeege Oct 31, 2017
21c3537
Tests pass with required password field added to user.
TheBeege Oct 31, 2017
205c1d8
Intermediate commit. May not currently be working
TheBeege Oct 31, 2017
d5df26e
Updated name field to username. Added name field
TheBeege Oct 31, 2017
24c6f4c
Login and sessions work
TheBeege Oct 31, 2017
e821181
Put pages behind auth wall
TheBeege Oct 31, 2017
6c8b557
Hid edit and create buttons based on permissions. Need to check more
TheBeege Nov 1, 2017
ec04bd7
Updated gitignore. Added package lock
TheBeege Nov 1, 2017
5f8d586
Fixed readme. Recreated package-lock. Completed merge
TheBeege Nov 1, 2017
94cc27e
Some changes were missing from merge. Added here
TheBeege Nov 1, 2017
3769400
Fixes for editing users
TheBeege Nov 1, 2017
d5c2cf5
Fixed authentication. It wasn't logging in using passport. Found a tu…
TheBeege Nov 1, 2017
82c69f1
Fix for course checkin route. Need to implement checkin logic
TheBeege Nov 1, 2017
cde63d6
Merge branch 'add_passport_authentication' of github.com:LearnTeachCo…
TheBeege Nov 1, 2017
46eba00
Checkins work, but a user can checkin an infinite number of times
TheBeege Nov 1, 2017
3d3f37b
Fixed checkins better. Still need to prevent infinite checkins
TheBeege Nov 1, 2017
02212d8
Checking in multiple times for the same event has no effect. We need …
TheBeege Nov 1, 2017
ebdcb3b
Removed checkin creation from user creation
TheBeege Nov 1, 2017
aaacb93
Slight organizational change
TheBeege Nov 1, 2017
1954a1c
Changed 'Courses' to 'Events'
jhazelton1 Nov 1, 2017
5b83f92
'Changed all 'Course' and 'Courses' to 'Event' and 'Events'
jhazelton1 Nov 2, 2017
0f40d46
Bookshelf is running with SQLite. Need to fix everything to use it
TheBeege Nov 2, 2017
34bd407
Courses repo is setup. Route is working. Can't save users, apparently.
TheBeege Nov 2, 2017
e95aede
Fixed user to save properly, but displaying users on leaderboard does…
TheBeege Nov 3, 2017
b8b431a
Updated tons of stuff to reference model properties correctly. Remove…
TheBeege Nov 3, 2017
ee0094b
Doesn't error now, but password isn't matching
TheBeege Nov 3, 2017
52d5a41
Errors serializing user again. It's receiving a promise. Updated pack…
TheBeege Nov 3, 2017
b4c2420
Added type to create event
jhazelton1 Nov 4, 2017
053e131
Fixed bug where user wouldn't serialize properly
TheBeege Nov 6, 2017
27dd774
Creating courses works, but they're not tracking creator
TheBeege Nov 6, 2017
93f156f
Converted models away from class-style. Bookshelf didn't like it
TheBeege Nov 7, 2017
fdba0e7
Fix for registry plugin. Fix for course page. Relationships seem to w…
TheBeege Nov 8, 2017
55528a3
Fixed course display page
TheBeege Nov 8, 2017
c1bab94
Merge remote-tracking branch 'origin/add_event_type' into add_passpor…
TheBeege Nov 8, 2017
e460268
Merged event changes. Updated my code to reflect course -> event
TheBeege Nov 8, 2017
4579fa4
All rendering seems to work. Now to try checkins
TheBeege Nov 8, 2017
2db82aa
[BROKEN] I hate async. Trouble getting countCheckIns to work
TheBeege Nov 8, 2017
4de4580
Added request badge page on individual user profile
jhazelton1 Nov 8, 2017
e5cd5b7
Fixed checkin counts on events and users
TheBeege Nov 9, 2017
2bca14f
Trying to configure bookshelf for testing, but the helper isn't running
TheBeege Nov 9, 2017
6ca9946
Required helper manually in each test file. Now to fix tests
TheBeege Nov 9, 2017
f21862a
Tests run properly but most are failing
TheBeege Nov 9, 2017
240e09e
All hooks work except for test 28
TheBeege Nov 9, 2017
c8a0ab4
Event model create tests pass. Removed unnecessary logging elsewhere
TheBeege Nov 9, 2017
6f9baa5
Event model destroy works
TheBeege Nov 9, 2017
d034478
Event model update is good
TheBeege Nov 9, 2017
d143667
Fixes to ensure database cleanup
TheBeege Nov 9, 2017
d7558cd
Was fixing tests. Found bug in initialize method of User model. Event…
TheBeege Nov 10, 2017
f88b713
Test still failing. Troubleshooting. Made a minor fix on CheckIn model
TheBeege Nov 10, 2017
6ac1210
add gulp
jhazelton1 Nov 11, 2017
288047a
add parsley validation
jhazelton1 Nov 11, 2017
4d95b81
add parsley field validation on course create
jhazelton1 Nov 11, 2017
71bbf3b
update field validations on course create
jhazelton1 Nov 11, 2017
44b66b7
add field validation on users signup
jhazelton1 Nov 11, 2017
6b380b8
remove parsleyjs validation to use bootstrap built-in validation
jhazelton1 Nov 12, 2017
ad5fb04
Fixed update checkIns test
Nov 13, 2017
e47388f
Fixed user model update
TheBeege Nov 13, 2017
c1cfc12
Progress on passing tests
TheBeege Nov 13, 2017
c427ad1
Fixed test and attribute-setting styles. Added default value handler …
TheBeege Nov 13, 2017
4faa807
Fixed user destroy model test
TheBeege Nov 13, 2017
da4ad00
Fixed user checkin test
TheBeege Nov 13, 2017
c791099
Fixed last broken test. Updated repositories appropriately
TheBeege Nov 13, 2017
40ecc0c
Merge remote-tracking branch 'origin/add_request_badge_page' into add…
TheBeege Nov 14, 2017
efdb2e1
Updated README for sqlite-based system. Updated package-lock.json. Fi…
TheBeege Nov 14, 2017
656a506
Updated config for Travis
TheBeege Nov 14, 2017
2870f52
Merge remote-tracking branch 'origin/field_validation' into add_passp…
TheBeege Nov 14, 2017
c007f39
Updated package lock file
TheBeege Nov 14, 2017
b30cb2e
Renamed files. Minor fixes
TheBeege Dec 7, 2017
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ Session.vim
tags

# End of https://www.gitignore.io/api/node
.idea/
config/database.dev.js
config/database.prod.js
*.sqlite
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: node_js
node_js: '7'
services:
- mongodb
before_script:
- cp config/database.template.js config/database.dev.js
83 changes: 53 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,66 @@


# Learn Teach Code Attendance Tracker
## Track Attendance
This is a tool to help Learn Teach Code track and manage attendance to meetup events.

## Award Badges
See Issues for the features we're working on.

## Display Leaderboard
The application is not yet ready for production, but the core features of event creation and attendance marking are there.

## Basic live messaging
## Setup instructions

Collections ->
We'll assume you have no experience with NodeJS or the ecosystem.
### Mac
1. [Install brew](https://brew.sh/)
* `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
2. [Install NodeJS](https://nodejs.org/en/download/package-manager/#macos)
* `brew install node`
3. Update SQLite3
* `brew install sqlite3`
4. Install dependencies
* In the project directory, `npm install`
5. Setup config files
1. Copy config/database.template.js to config/database.dev.js
2. Remove HOST, USER, PASSWORD, DATABASE (Optional, but cleaner)
6. Run in dev mode
* `npm run dev`

[Users]
-_id
-email
-level
-name (optional)
The server runs on port 3000, so you can visit it at [`http://localhost:3000`](http://localhost:3000)

[UsersClasses]
-_id
-user_id
-course_id
-date
## Testing

[Lecture]
-_id
-course_id
-time
-location
-url
npm test => runs all tests once
npm run test-watch => runs all tests each time a change is saved

[Course]
-_id
-title
-description

## Testing instructions
testing database is set to mongodb://localhost/test-database
so mongo needs to be running in order to run tests

npm test => runs all tests once
npm run test-watch => runs all tests each time a change is saved
## Application Design
### Collections
#### Users
* id
* username
* password
* email
* level
* name (optional)
* website
* hometown
* description
* checkIns
* createdAt
* updatedAt

#### Event
* id
* title
* description
* instructors
* createdAt
* updatedAt

#### CheckIn
* id
* user
* event
* createdAt
* updatedAt
91 changes: 40 additions & 51 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,92 +4,81 @@ const favicon = require('serve-favicon');
const morgan = require('morgan');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const configDB = require('./config/database.js')
const passport = require('passport');
const flash = require('connect-flash');
const session = require('express-session');

const index = require('./routes/index');
const users = require('./routes/users');
const courses = require('./routes/courses');
const app = express();

// database
const mongoose = require('mongoose')

mongoose.Promise = global.Promise
mongoose.set('debug', true)

mongoose.connect(configDB.MONGO_DEV, err => {
if (err) {
console.log("# Failed to connect to MongoDB Dev:");
} else {
console.log('# Connected to MongoDB Dev:')
}
});

// mongoose.connect(configDB.MONGODB_URI, err => {
// if (err) {
// console.log("# Failed to connect to MongoDB :", configDB.MONGODB_URI);
// } else {
// console.log('# Connected to MongoDB :', configDB.MONGODB_URI)
// }
// })
const bookshelfSetup = require('./config/bookshelf');
bookshelfSetup.configureBookshelf(process.env.RUN_MODE);
if (process.env.RUN_MODE !== 'prod') {
bookshelfSetup.initializeDevDb();
}

// require('./config/passport')(passport);
const index = require('./routes/index');
const users = require('./routes/users');
const events = require('./routes/events');
const app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');

// pass passport for configuration
const configurePassport = require('./config/passport');
configurePassport(passport);

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(morgan('dev'));
app.use(express.static(path.join(__dirname, 'public')));
app.use(cookieParser());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', index);
app.use('/users', users);
app.use('/courses', courses);

// required for passport
app.use(session({ secret: 'thisneedstobehidden' }));
app.use(session({secret: 'thisneedstobehidden'}));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());

app.use('/', index);
app.use('/users', users);
app.use('/events', events);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
const err = new Error('Not Found');
err.status = 404;
next(err);
app.use(function (req, res, next) {
const err = new Error('Not Found');
err.status = 404;
next(err);
});

// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};

// render the error page
res.status(err.status || 500);
res.render('error');
app.use(function (err, req, res) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};

// render the error page
res.status(err.status || 500);
res.render('error');
});

module.exports = app;


// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};

// render the error page
res.status(err.status || 500);
res.render('error');
app.use(function (err, req, res) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};

// render the error page
res.status(err.status || 500);
res.render('error');
});

module.exports = app;
85 changes: 41 additions & 44 deletions bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,20 @@
/**
* Module dependencies.
*/

var app = require('../app');
var debug = require('debug')('ltc-attendance:server');
var http = require('http');
const app = require('../app');
const debug = require('debug')('ltc-attendance:server');
const http = require('http');

/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '3000');
const port = normalizePort(process.env.PORT || '3000');
app.set('port', port);

/**
* Create HTTP server.
*/

var server = http.createServer(app);
const server = http.createServer(app);

/**
* Listen on provided port, on all network interfaces.
Expand All @@ -34,57 +31,57 @@ server.on('listening', onListening);
*/

function normalizePort(val) {
var port = parseInt(val, 10);
const port = parseInt(val, 10);

if (isNaN(port)) {
// named pipe
return val;
}
if (isNaN(port)) {
// named pipe
return val;
}

if (port >= 0) {
// port number
return port;
}
if (port >= 0) {
// port number
return port;
}

return false;
return false;
}

/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}

var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
if (error.syscall !== 'listen') {
throw error;
}

const bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}

/**
* Event listener for HTTP server "listening" event.
*/

function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
const addr = server.address();
const bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
Loading