diff --git a/.gitignore b/.gitignore index bf46288..36f9c9a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ config.js public/main.css public/emailFailures.txt sessions/ +config/db.js +.idea/workspace.xml diff --git a/.sequelizerc b/.sequelizerc new file mode 100644 index 0000000..be90232 --- /dev/null +++ b/.sequelizerc @@ -0,0 +1,7 @@ +var path=require('path'); + +//'migrations-path': 'migrations' + +module.exports = { + 'config': path.resolve('config', 'db.js') +} \ No newline at end of file diff --git a/config/database.js b/config/database.js deleted file mode 100644 index 9d8d6c6..0000000 --- a/config/database.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - - 'url' : 'postgres://PetitTeton:1qaz2wsx@localhost:5432/Petit_Teton_Apps' - -}; \ No newline at end of file diff --git a/config/db_example.js b/config/db_example.js new file mode 100644 index 0000000..59bbdd5 --- /dev/null +++ b/config/db_example.js @@ -0,0 +1,14 @@ +module.exports = { + + 'url' : 'postgres://PetitTeton:1qaz2wsx@localhost:5432/PetitTeton' + /* + "development": { + "url": "xxxxxxxxxxxxxxxx", + "dialect": "mysql" + }, + "production": { + "url": "xxxxxxxxxxxxxxxx", + "dialect": "postgres" + } + */ +}; \ No newline at end of file diff --git a/migrations/20160602030143-User.js b/migrations/20160602030143-User.js new file mode 100644 index 0000000..2235a43 --- /dev/null +++ b/migrations/20160602030143-User.js @@ -0,0 +1,27 @@ +'use strict'; + +module.exports = { + up: function (query, Sequelize) { + var DataTypes = Sequelize; //Allow for more cut and paste :) + + return query.createTable('User', { + login: { + type: DataTypes.STRING + }, + password: { + type: DataTypes.STRING + }, + admin: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true + } + }, { + charset: 'utf8' + }); + }, + + down: function (query, Sequelize) { + return query.dropTable('User'); + } +}; diff --git a/migrations/20160602030144-UserIndex.js b/migrations/20160602030144-UserIndex.js new file mode 100644 index 0000000..ef3aed0 --- /dev/null +++ b/migrations/20160602030144-UserIndex.js @@ -0,0 +1,13 @@ +'use strict'; + +module.exports = { + up: function (query, Sequelize) { + var DataTypes = Sequelize; //Allow for more cut and paste :) + + return query.addIndex('User', ['login'], {indicesType: 'UNIQUE', indexName: 'LOGIN_INDEX'}); + }, + + down: function (query, Sequelize) { + + } +}; diff --git a/migrations/20160602030145-Measure.js b/migrations/20160602030145-Measure.js new file mode 100644 index 0000000..2290b15 --- /dev/null +++ b/migrations/20160602030145-Measure.js @@ -0,0 +1,39 @@ +'use strict'; + +module.exports = { + up: function (query, Sequelize) { + var DataTypes = Sequelize; //Allow for more cut and paste :) + + return query.createTable('Measure', { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + autoIncrement: true + }, + name: { + type: DataTypes.STRING, + allowNull: false + }, + image: { + type: DataTypes.STRING, + allowNull: true + }, + postfix: { + type: DataTypes.STRING, + allowNull: false + }, + visible: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true + } + }, { + charset: 'utf8' + }); + }, + + down: function (query, Sequelize) { + return query.dropTable('Measure'); + } +}; diff --git a/migrations/20160602030146-Venue.js b/migrations/20160602030146-Venue.js new file mode 100644 index 0000000..0e58132 --- /dev/null +++ b/migrations/20160602030146-Venue.js @@ -0,0 +1,31 @@ +'use strict'; + +module.exports = { + up: function (query, Sequelize) { + var DataTypes = Sequelize; //Allow for more cut and paste :) + + return query.createTable('Venue', { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + autoIncrement: true + }, + name: { + type: DataTypes.STRING, + allowNull: false + }, + visible: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true + } + }, { + charset: 'utf8' + }); + }, + + down: function (query, Sequelize) { + return query.dropTable('Venue'); + } +}; diff --git a/migrations/20160602030147-Category.js b/migrations/20160602030147-Category.js new file mode 100644 index 0000000..4a17f64 --- /dev/null +++ b/migrations/20160602030147-Category.js @@ -0,0 +1,31 @@ +'use strict'; + +module.exports = { + up: function (query, Sequelize) { + var DataTypes = Sequelize; //Allow for more cut and paste :) + + return query.createTable('Category', { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + autoIncrement: true + }, + name: { + type: DataTypes.STRING, + allowNull: false + }, + visible: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true + } + }, { + charset: 'utf8' + }); + }, + + down: function (query, Sequelize) { + return query.dropTable('Category'); + } +}; diff --git a/migrations/20160602030148-Subcategory.js b/migrations/20160602030148-Subcategory.js new file mode 100644 index 0000000..1a58097 --- /dev/null +++ b/migrations/20160602030148-Subcategory.js @@ -0,0 +1,42 @@ +'use strict'; + +module.exports = { + up: function (query, Sequelize) { + var DataTypes = Sequelize; //Allow for more cut and paste :) + + return query.createTable('Subcategory', { + id: { + type: DataTypes.INTEGER, + field: 'id', + primaryKey: true, + allowNull: false, + autoIncrement: true + }, + name: { + type: DataTypes.STRING, + field: 'name', + allowNull: false + }, + visible: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true + }, + categoryId: { + type: Sequelize.INTEGER, + references: { + model: 'Category', + key: 'id' + }, + onUpdate: 'cascade', + onDelete: 'cascade' + } + }, { + charset: 'utf8' + }); + }, + + down: function (query, Sequelize) { + return query.dropTable('Subcategory'); + } +}; diff --git a/migrations/20160602030149-Item.js b/migrations/20160602030149-Item.js new file mode 100644 index 0000000..2eacebb --- /dev/null +++ b/migrations/20160602030149-Item.js @@ -0,0 +1,44 @@ +'use strict'; + +module.exports = { + up: function (query, Sequelize) { + var DataTypes = Sequelize; //Allow for more cut and paste :) + + return query.createTable('Item', { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + autoIncrement: true + }, + name: { + type: DataTypes.STRING, + allowNull: false + }, + counts: { + type: DataTypes.JSON, + allowNull: false + }, + visible: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true + }, + subcategoryId: { + type: Sequelize.INTEGER, + references: { + model: 'Subcategory', + key: 'id' + }, + onUpdate: 'cascade', + onDelete: 'cascade' + } + }, { + charset: 'utf8' + }); + }, + + down: function (query, Sequelize) { + return query.dropTable('Item'); + } +}; diff --git a/migrations/20160602030150-Sale.js b/migrations/20160602030150-Sale.js new file mode 100644 index 0000000..ae7fc90 --- /dev/null +++ b/migrations/20160602030150-Sale.js @@ -0,0 +1,48 @@ +'use strict'; + +module.exports = { + up: function (query, Sequelize) { + var DataTypes = Sequelize; //Allow for more cut and paste :) + + return query.createTable('Sale', { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + autoIncrement: true + }, + date: { + type: DataTypes.DATE, + allowNull: false + }, + measure: { + type: DataTypes.JSONB, + allowNull: false + }, + itemId: { + type: Sequelize.INTEGER, + references: { + model: 'Item', + key: 'id' + }, + onUpdate: 'cascade', + onDelete: 'cascade' + }, + venueId: { + type: Sequelize.INTEGER, + references: { + model: 'Venue', + key: 'id' + }, + onUpdate: 'cascade', + onDelete: 'cascade' + } + }, { + charset: 'utf8' + }); + }, + + down: function (query, Sequelize) { + return query.dropTable('Sale'); + } +}; diff --git a/migrations/20160602035027-base.js b/migrations/20160602035027-base.js new file mode 100644 index 0000000..6716f4c --- /dev/null +++ b/migrations/20160602035027-base.js @@ -0,0 +1,203 @@ +'use strict'; + +module.exports = { + up: function (query, Sequelize) { + var DataTypes = Sequelize; //Allow for more cut and paste :) + + return query.createTable('User', { + login: { + type: DataTypes.STRING + }, + password: { + type: DataTypes.STRING + }, + admin: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true + } + }, { + charset: 'utf8' + }); + query.addIndex('User', ['login'], {indicesType: 'UNIQUE', indexName: 'LOGIN_INDEX'}); + + query.createTable('Measure', { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + autoIncrement: true + }, + name: { + type: DataTypes.STRING, + allowNull: false + }, + image: { + type: DataTypes.STRING, + allowNull: true + }, + postfix: { + type: DataTypes.STRING, + allowNull: false + }, + visible: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true + } + }, { + charset: 'utf8' + }); + + query.createTable('Venue', { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + autoIncrement: true + }, + name: { + type: DataTypes.STRING, + allowNull: false + }, + visible: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true + } + }, { + charset: 'utf8' + }); + + query.createTable('Category', { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + autoIncrement: true + }, + name: { + type: DataTypes.STRING, + allowNull: false + }, + visible: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true + } + }, { + charset: 'utf8' + }); + + query.createTable('Subcategory', { + id: { + type: DataTypes.INTEGER, + field: 'id', + primaryKey: true, + allowNull: false, + autoIncrement: true + }, + name: { + type: DataTypes.STRING, + field: 'name', + allowNull: false + }, + visible: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true + }, + categoryId: { + type: Sequelize.INTEGER, + references: { + model: 'Category', + key: 'id' + }, + onUpdate: 'cascade', + onDelete: 'cascade' + } + }, { + charset: 'utf8' + }); + + query.createTable('Item', { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + autoIncrement: true + }, + name: { + type: DataTypes.STRING, + allowNull: false + }, + counts: { + type: DataTypes.JSON, + allowNull: false + }, + visible: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true + }, + subcategoryId: { + type: Sequelize.INTEGER, + references: { + model: 'Subcategory', + key: 'id' + }, + onUpdate: 'cascade', + onDelete: 'cascade' + } + }, { + charset: 'utf8' + }); + + query.createTable('Sale', { + id: { + type: DataTypes.INTEGER, + primaryKey: true, + allowNull: false, + autoIncrement: true + }, + date: { + type: DataTypes.DATE, + allowNull: false + }, + measure: { + type: DataTypes.JSONB, + allowNull: false + }, + itemId: { + type: Sequelize.INTEGER, + references: { + model: 'Item', + key: 'id' + }, + onUpdate: 'cascade', + onDelete: 'cascade' + }, + venueId: { + type: Sequelize.INTEGER, + references: { + model: 'Venue', + key: 'id' + }, + onUpdate: 'cascade', + onDelete: 'cascade' + } + }, { + charset: 'utf8' + }); + }, + + down: function (query, Sequelize) { + query.dropTable('Sale'); + query.dropTable('Item'); + query.dropTable('Subcategory'); + query.dropTable('Category'); + query.dropTable('User'); + query.dropTable('Measure'); + query.dropTable('Venue'); + } +}; diff --git a/app/models/category.js b/models/category.js similarity index 100% rename from app/models/category.js rename to models/category.js diff --git a/app/models/index.js b/models/index.js similarity index 94% rename from app/models/index.js rename to models/index.js index 5ac9948..358b5a4 100644 --- a/app/models/index.js +++ b/models/index.js @@ -5,7 +5,7 @@ var path = require("path"); var Sequelize = require("sequelize"); var env = process.env.NODE_ENV || "development"; //var config = require(__dirname + '/../config/config.json')[env]; -var configDB = require('./../../config/database.js'); +var configDB = require('./../config/database.js'); //var sequelize = new Sequelize(config.database, config.username, config.password, config); var sequelize = new Sequelize(configDB.url); var db = {}; diff --git a/app/models/item.js b/models/item.js similarity index 100% rename from app/models/item.js rename to models/item.js diff --git a/app/models/measure.js b/models/measure.js similarity index 100% rename from app/models/measure.js rename to models/measure.js diff --git a/app/models/sale.js b/models/sale.js similarity index 100% rename from app/models/sale.js rename to models/sale.js diff --git a/app/models/subcategory.js b/models/subcategory.js similarity index 100% rename from app/models/subcategory.js rename to models/subcategory.js diff --git a/app/models/user.js b/models/user.js similarity index 66% rename from app/models/user.js rename to models/user.js index dcb00c1..4add8bb 100644 --- a/app/models/user.js +++ b/models/user.js @@ -10,9 +10,22 @@ module.exports = function(sequelize, DataTypes) { }, password: { type: DataTypes.STRING - } + }, + admin: { + type: DataTypes.BOOLEAN, + allowNull: false, + defaultValue: true + }, + indexes: [ + { + unique: true, + fields: ['login'] + } + ] }, { freezeTableName: true, // Model tableName will be the same as the model name + //paranoid: true, //Keep deleted data but flag it as deleted + comment: "A system user authorized to access and manipulate the application data.", instanceMethods: { generateHash: function(password) { return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null); diff --git a/app/models/venue.js b/models/venue.js similarity index 100% rename from app/models/venue.js rename to models/venue.js diff --git a/package.json b/package.json index ad4c87b..aa5a982 100644 --- a/package.json +++ b/package.json @@ -14,20 +14,21 @@ "ejs": "~2.4.1", "express": "~4.11.1", "express-session": "~1.0.4", - "morgan": "~1.5.1", "html": "latest", "method-override": "~1.0.2", "moment": "latest", + "morgan": "~1.5.1", + "node-phantom": "latest", + "nodemailer": "~1.0", "passport": "^0.3.2", "passport-local": "^1.0.0", "pg": "^4.4.3", "pg-hstore": "^2.3.2", - "sequelize": "^3.14.2", - "stylus": "~0.42.3", - "swig": "~1.4.2", - "session-file-store": "~0.0.24", + "sequelize": "^3.0", + "sequelize-cli": "^2.4.0", "serve-favicon": "~2.2.0", - "nodemailer": "~1.0", - "node-phantom": "latest" + "session-file-store": "~0.0.24", + "stylus": "~0.42.3", + "swig": "~1.4.2" } } diff --git a/photos/Sarah.JPG b/photos/Sarah.JPG new file mode 100644 index 0000000..333b284 Binary files /dev/null and b/photos/Sarah.JPG differ diff --git a/public/VAP_Availability_List_5-2016.pdf b/public/VAP_Availability_List_5-2016.pdf new file mode 100644 index 0000000..555dabf Binary files /dev/null and b/public/VAP_Availability_List_5-2016.pdf differ diff --git a/public/farm-made-fare.html b/public/farm-made-fare.html index 10be50a..98bdd75 100644 --- a/public/farm-made-fare.html +++ b/public/farm-made-fare.html @@ -8,7 +8,7 @@

Our farm-made fare is created in our commercial kitchen from produce we grow on our farm. We purchase only what we haven't yet figured out how to grow (sugar, flour, salt, etc.). Our labels note which ingredients come from our farm. We save seeds and dry herbs, peppers, tomatoes, tomatillos and fruit for spicing and flavoring.

Production changes frequently based on the seasonal harvest, and every run is unique and small scale which means the availability changes regularly. The following PDF download is a current listing of what we offer along with prices.

-

Click to download the price list PDF.
+

Click to download the price list PDF.