From 2d4ed7d888727e1b973c2581b694d900e30c2ebd Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 7 Jan 2015 13:53:27 -0500 Subject: plan/subscription schemas --- server/lib/schemas/Plan.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 server/lib/schemas/Plan.js (limited to 'server/lib/schemas/Plan.js') diff --git a/server/lib/schemas/Plan.js b/server/lib/schemas/Plan.js new file mode 100644 index 0000000..3e74997 --- /dev/null +++ b/server/lib/schemas/Plan.js @@ -0,0 +1,36 @@ +/* jshint node: true */ + +var mongoose = require('mongoose'), + _ = require('lodash'), + crypto = require('crypto'), + config = require('../../../config.json'), + util = require('../util'); + +var PlanSchema = new mongoose.Schema({ + name: { type: String }, + slug: { type: String }, + + monthly_price: { type: Number }, + yearly_price: { type: Number }, + + basic_layout_limit: { type: Number }, + pro_layout_limit: { type: Number }, + + stock_layout_project_limit: { type: Number }, + basic_layout_project_limit: { type: Number }, + pro_layout_project_limit: { type: Number }, + + permissions: { + basic_editor: { type: Boolean, default: false }, + pro_editor: { type: Boolean, default: false }, + solids: { type: Boolean, default: false }, + collaborators: { type: Boolean, default: false }, + no_logo: { type: Boolean, default: false }, + }, + + created_at: { type: Date, default: Date.now }, + updated_at: { type: Date, default: Date.now }, +}) + +module.exports = exports = mongoose.model('plan', PlanSchema); +exports.schema = PlanSchema; -- cgit v1.2.3-70-g09d2 From 9c6f8f8568d20d75eb22955dbf2752ea777e59f8 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 7 Jan 2015 14:34:41 -0500 Subject: stub in brochure page --- public/assets/stylesheets/app.css | 14 +++++++ server/lib/schemas/Plan.js | 6 +++ server/lib/schemas/Subscription.js | 2 +- server/lib/views/index.js | 5 +++ server/lib/views/subscription.js | 1 - views/about/_blank.ejs | 2 +- views/about/about.ejs | 16 +------- views/about/brochure.ejs | 79 ++++++++++++++++++++++++++++++++++++++ views/about/howto.ejs | 2 +- views/builder.ejs | 2 +- views/docs.ejs | 2 +- views/editor.ejs | 2 +- views/home.ejs | 2 +- views/modal.ejs | 2 +- views/profile.ejs | 2 +- views/reader.ejs | 2 +- views/staff/_header.ejs | 2 +- 17 files changed, 116 insertions(+), 27 deletions(-) create mode 100644 views/about/brochure.ejs (limited to 'server/lib/schemas/Plan.js') diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index aecd6be..0463e26 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -673,7 +673,21 @@ iframe.embed { font-weight: 300; } +.aboutintro { + text-align: center; + line-height: 43px; + font-size: 24px; + padding: 5% 0; + font-weight: 300; +} +.aboutintro .inner { + max-width: 800px; + margin: 0 auto; + text-align: center; +} + /* PROFILE PAGE */ + .profilePic { background-size: cover; background-position: center; diff --git a/server/lib/schemas/Plan.js b/server/lib/schemas/Plan.js index 3e74997..1057bb2 100644 --- a/server/lib/schemas/Plan.js +++ b/server/lib/schemas/Plan.js @@ -13,6 +13,12 @@ var PlanSchema = new mongoose.Schema({ monthly_price: { type: Number }, yearly_price: { type: Number }, + basic_layout_monthly_price: { type: Number }, + basic_layout_yearly_price: { type: Number }, + + pro_layout_monthly_price: { type: Number }, + pro_layout_yearly_price: { type: Number }, + basic_layout_limit: { type: Number }, pro_layout_limit: { type: Number }, diff --git a/server/lib/schemas/Subscription.js b/server/lib/schemas/Subscription.js index 8d0b10e..8315009 100644 --- a/server/lib/schemas/Subscription.js +++ b/server/lib/schemas/Subscription.js @@ -15,7 +15,7 @@ var SubscriptionSchema = new mongoose.Schema({ plans: [{ tier: { type: String }, monthly: { type: Boolean }, - }] + }], created_at: { type: Date, default: Date.now }, updated_at: { type: Date, default: Date.now }, diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 3326499..5f9088b 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -111,6 +111,11 @@ var views = module.exports = { res.render('about/' + name) return } + if (name == "brochure") { + // TODO: fetch plans + res.render('about/' + name) + return + } if (name == "about" || name == "index") { res.render('about/' + name) return diff --git a/server/lib/views/subscription.js b/server/lib/views/subscription.js index 77db1a0..ba54bb4 100644 --- a/server/lib/views/subscription.js +++ b/server/lib/views/subscription.js @@ -12,7 +12,6 @@ var subscription = module.exports = { fields: { user: "_id username displayName photo created_at updated_at last_seen created_ip last_ip", - project: "_id name slug user_id privacy created_at updated_at", }, defaults: { diff --git a/views/about/_blank.ejs b/views/about/_blank.ejs index 0e9ea7e..3c23fa7 100644 --- a/views/about/_blank.ejs +++ b/views/about/_blank.ejs @@ -1,7 +1,7 @@ - vvalls + VValls [[ include ../partials/meta ]] diff --git a/views/about/about.ejs b/views/about/about.ejs index dd536be..2aec982 100644 --- a/views/about/about.ejs +++ b/views/about/about.ejs @@ -1,7 +1,7 @@ - vvalls + About VValls [[ include ../partials/meta ]] @@ -50,17 +50,3 @@ [[ include ../partials/scripts ]] - \ No newline at end of file diff --git a/views/about/brochure.ejs b/views/about/brochure.ejs new file mode 100644 index 0000000..00083cf --- /dev/null +++ b/views/about/brochure.ejs @@ -0,0 +1,79 @@ + + + + VValls Subscriptions + [[ include ../partials/meta ]] + + +
+ [[ include ../partials/header ]] + +

Subscriptions

+ +
+
+ Want to get more out of VValls? Consider becoming a subscription user. +
+
+ +
+

[[- plans.free.name ]]

+
    +
  • One exhibition with pre-designed template floor plan +
+
+ +
+

[[- plans.premium.name ]]

+
    +
  • $[[- plans.premium.monthly_price ]]/mo or $[[- plans.premium.yearly_price ]]/year +
  • [[- plans.premium.stock_layout_project_limit ]] exhibitions included with pre-designed template floor plans +
  • Each new basic floor plan costs $[[- plans.premium.basic_layout_monthly_price ]]/mo + or $[[- plans.premium.basic_layout_yearly_price ]]/year, minimum 3 months +
  • Each new basic floor plan can have up to [[- plans.premium.basic_layout_project_limit ]] exhibitions +
  • VValls logo appears when embedding an exhibition on a web page +
+
+ +
+

[[- plans.pro.name ]]

+
    +
  • $[[- plans.pro.monthly_price ]]/mo or $[[- plans.pro.yearly_price ]]/year +
  • Comes with [[- plans.premium.pro_layout_limit ]] pro floor plan and [[- plans.premium.pro_layout_project_limit ]] exhibitions +
  • Each new pro floor plan costs $[[- plans.pro.pro_layout_monthly_price ]]/mo + or $[[- plans.pro.pro_layout_yearly_price ]]/year, minimum 3 months +
  • Each new pro floor plan can have up to [[- plans.pro.pro_layout_project_limit ]] exhibitions +
  • Includes planning for 3D objects in the room +
  • No VValls logo on embed +
+
+ +
+ Buying any extra floor plan unlocks collaboration. Invite an artist or curator to work on the exhibition with you. +
+ +
+ Basic Floor plan: Rectangle-based design of any dimension. +
+ +
+ Pro Floor plan: Trace an arbitrary floorplan. +
+ + +
+

Custom

+ We offer many types of customizations and white-label options for business and educational uses. + Contact us for more information +
+ + + [[ include ../partials/confirm-modal ]] + [[ include ../projects/layouts-modal ]] + [[ include ../partials/sign-in ]] + [[ include ../partials/footer ]] + +
+ +[[ include ../partials/scripts ]] + diff --git a/views/about/howto.ejs b/views/about/howto.ejs index 5278a40..914c3b3 100644 --- a/views/about/howto.ejs +++ b/views/about/howto.ejs @@ -1,7 +1,7 @@ - vvalls + How to Use VValls [[ include ../partials/meta ]] diff --git a/views/builder.ejs b/views/builder.ejs index afb8c66..0ba4238 100644 --- a/views/builder.ejs +++ b/views/builder.ejs @@ -1,7 +1,7 @@ - vvalls + VValls [[ include partials/meta ]] diff --git a/views/docs.ejs b/views/docs.ejs index b3ead82..a1f081f 100644 --- a/views/docs.ejs +++ b/views/docs.ejs @@ -1,7 +1,7 @@ - vvalls + VValls [[ include partials/meta ]] diff --git a/views/editor.ejs b/views/editor.ejs index 656615c..74e4d6d 100755 --- a/views/editor.ejs +++ b/views/editor.ejs @@ -1,7 +1,7 @@ - vvalls + VValls [[ include partials/meta ]] diff --git a/views/home.ejs b/views/home.ejs index 36fc2fc..ffb0976 100755 --- a/views/home.ejs +++ b/views/home.ejs @@ -1,7 +1,7 @@ - vvalls + VValls [[ include partials/meta ]] diff --git a/views/modal.ejs b/views/modal.ejs index 7ca869c..732953d 100644 --- a/views/modal.ejs +++ b/views/modal.ejs @@ -1,7 +1,7 @@ - vvalls + VValls [[ include partials/meta ]] diff --git a/views/profile.ejs b/views/profile.ejs index a62652c..88af6b0 100644 --- a/views/profile.ejs +++ b/views/profile.ejs @@ -1,7 +1,7 @@ - vvalls + VValls | [[- profile.displayName ]] [[ include partials/meta ]] diff --git a/views/reader.ejs b/views/reader.ejs index 6c9856a..7035356 100644 --- a/views/reader.ejs +++ b/views/reader.ejs @@ -1,7 +1,7 @@ - vvalls + VValls [[ include partials/meta ]] diff --git a/views/staff/_header.ejs b/views/staff/_header.ejs index 3bbf4f1..a73c12e 100644 --- a/views/staff/_header.ejs +++ b/views/staff/_header.ejs @@ -1,7 +1,7 @@ - vvalls | staff + VValls | staff [[ include ../partials/meta ]] -- cgit v1.2.3-70-g09d2 From 5dd9742da846e8db863a951f1502d0edf5a3f90b Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 7 Jan 2015 18:02:13 -0500 Subject: forms for editing plans --- server/lib/schemas/Plan.js | 6 +-- server/lib/views/staff.js | 22 ++++++++ views/about/brochure.ejs | 4 +- views/staff/_nav.ejs | 6 +++ views/staff/media/index.ejs | 7 +-- views/staff/media/show.ejs | 7 +-- views/staff/media/show_404.ejs | 9 +--- views/staff/plans/_form.ejs | 109 ++++++++++++++++++++++++++++++++++++++ views/staff/plans/edit.ejs | 13 +++++ views/staff/plans/index.ejs | 54 +++++++++++++++++++ views/staff/plans/new.ejs | 15 ++++++ views/staff/projects/index.ejs | 7 +-- views/staff/projects/show.ejs | 9 +--- views/staff/projects/show_404.ejs | 7 +-- views/staff/users/index.ejs | 7 +-- views/staff/users/media.ejs | 13 ++--- views/staff/users/show.ejs | 7 +-- views/staff/users/show_404.ejs | 16 +++--- 18 files changed, 244 insertions(+), 74 deletions(-) create mode 100644 views/staff/_nav.ejs create mode 100644 views/staff/plans/_form.ejs create mode 100644 views/staff/plans/edit.ejs create mode 100644 views/staff/plans/index.ejs create mode 100644 views/staff/plans/new.ejs (limited to 'server/lib/schemas/Plan.js') diff --git a/server/lib/schemas/Plan.js b/server/lib/schemas/Plan.js index 1057bb2..1208672 100644 --- a/server/lib/schemas/Plan.js +++ b/server/lib/schemas/Plan.js @@ -22,9 +22,9 @@ var PlanSchema = new mongoose.Schema({ basic_layout_limit: { type: Number }, pro_layout_limit: { type: Number }, - stock_layout_project_limit: { type: Number }, - basic_layout_project_limit: { type: Number }, - pro_layout_project_limit: { type: Number }, + stock_project_limit: { type: Number }, + basic_project_limit: { type: Number }, + pro_project_limit: { type: Number }, permissions: { basic_editor: { type: Boolean, default: false }, diff --git a/server/lib/views/staff.js b/server/lib/views/staff.js index 49f492b..c3739e9 100644 --- a/server/lib/views/staff.js +++ b/server/lib/views/staff.js @@ -4,6 +4,8 @@ var User = require('../schemas/User'), Project = require('../schemas/Project'), Media = require('../schemas/Media'), Collaborator = require('../schemas/Collaborator'), + Plan = require('../schemas/Plan'), + Subscription = require('../schemas/Subscription'), config = require('../../../config'), middleware = require('../middleware'), util = require('../util'), @@ -540,6 +542,26 @@ var staff = module.exports = { res.render('staff/media/show_404') } }, + }, + + plans: { + index: function(req, res){ + res.locals.fields = ( + "monthly_price yearly_price basic_layout_monthly_price basic_layout_yearly_price " + + "pro_layout_monthly_price pro_layout_yearly_price " + + "basic_layout_limit pro_layout_limit stock_project_limit basic_project_limit pro_project_limit" + ).split(" ") + + res.locals.permissions = "basic_editor pro_editor solids collaborators no_logo".split(" ") + + res.render('staff/plans/index') + }, + new: function(req, res){ + res.render('staff/plans/new') + }, + edit: function(req, res){ + res.render('staff/plans/edit') + }, } } diff --git a/views/about/brochure.ejs b/views/about/brochure.ejs index 00083cf..d816dc4 100644 --- a/views/about/brochure.ejs +++ b/views/about/brochure.ejs @@ -35,7 +35,7 @@ -
+

[[- plans.pro.name ]]

  • $[[- plans.pro.monthly_price ]]/mo or $[[- plans.pro.yearly_price ]]/year @@ -57,7 +57,7 @@
- Pro Floor plan: Trace an arbitrary floorplan. + Pro Floor plan: Trace an arbitrary floor plan.
diff --git a/views/staff/_nav.ejs b/views/staff/_nav.ejs new file mode 100644 index 0000000..2115e9f --- /dev/null +++ b/views/staff/_nav.ejs @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/views/staff/media/index.ejs b/views/staff/media/index.ejs index 516af2d..3805c8e 100644 --- a/views/staff/media/index.ejs +++ b/views/staff/media/index.ejs @@ -2,12 +2,7 @@

Media

- +[[ include ../_nav ]]
diff --git a/views/staff/media/show.ejs b/views/staff/media/show.ejs index 76dcd32..9d05cb9 100644 --- a/views/staff/media/show.ejs +++ b/views/staff/media/show.ejs @@ -2,12 +2,7 @@

Media: [[- media.type ]]

- +[[ include ../_nav ]]
diff --git a/views/staff/media/show_404.ejs b/views/staff/media/show_404.ejs index f07cef2..c6bac6f 100644 --- a/views/staff/media/show_404.ejs +++ b/views/staff/media/show_404.ejs @@ -2,13 +2,8 @@

Media not found

- - +[[ include ../_nav ]] +
[[ include ../_footer ]] diff --git a/views/staff/plans/_form.ejs b/views/staff/plans/_form.ejs new file mode 100644 index 0000000..b97716f --- /dev/null +++ b/views/staff/plans/_form.ejs @@ -0,0 +1,109 @@ + +
+ + +
+ +
+ + +
+ + + +
+ + +
+ +
+ + +
+ + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + + +
+ + +
+ +
+ + +
+ + + +
+ + +
+ +
+ + +
+ +
+ + +
+ + + +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ + + + diff --git a/views/staff/plans/edit.ejs b/views/staff/plans/edit.ejs new file mode 100644 index 0000000..503c97d --- /dev/null +++ b/views/staff/plans/edit.ejs @@ -0,0 +1,13 @@ +[[ include ../_header ]] + +

Edit Plan

+ +[[ include ../_nav ]] + +
+ +
+[[- include form ]] +
+ +[[ include ../_footer ]] diff --git a/views/staff/plans/index.ejs b/views/staff/plans/index.ejs new file mode 100644 index 0000000..aa6c35a --- /dev/null +++ b/views/staff/plans/index.ejs @@ -0,0 +1,54 @@ +[[ include ../_header ]] + +

Plans

+ +[[ include ../_nav ]] + +
+ + + + + [[ plans.forEach(function(plan){ ]] + + [[ }) ]] + + + + + [[ plans.forEach(function(plan){ ]] + + [[ }) ]] + + + [[ fields.forEach(function(field){ ]] + + + [[ plans.forEach(function(plan){ ]] + + [[ }) ]] + + [[ }) ]] + + [[ permissions.forEach(function(permission){ ]] + + + [[ plans.forEach(function(plan){ ]] + + [[ }) ]] + + [[ }) ]] + +
+ [[- plan.name ]] +
+ edit +
[[- field.replace(/_/," ") ]] + [[- plan[field] ]] +
[[- permission.replace(/_/," ") ]] + [[- plan.permissions[permission] ? "x" : " " ]] +
+ +
+ +[[ include ../_footer ]] diff --git a/views/staff/plans/new.ejs b/views/staff/plans/new.ejs new file mode 100644 index 0000000..d56a1c3 --- /dev/null +++ b/views/staff/plans/new.ejs @@ -0,0 +1,15 @@ +[[ include ../_header ]] + +

New Plan

+ +[[ include ../_nav ]] + +
+ +
+[[- include form ]] +
+ +[[ include ../_footer ]] + + diff --git a/views/staff/projects/index.ejs b/views/staff/projects/index.ejs index 482ea25..e4ba469 100644 --- a/views/staff/projects/index.ejs +++ b/views/staff/projects/index.ejs @@ -2,12 +2,7 @@

Projects

- +[[ include ../_nav ]]
diff --git a/views/staff/projects/show.ejs b/views/staff/projects/show.ejs index 1034b31..b090a41 100644 --- a/views/staff/projects/show.ejs +++ b/views/staff/projects/show.ejs @@ -2,13 +2,8 @@

[[- project.name ]]

- - +[[ include ../_nav ]] +
diff --git a/views/staff/projects/show_404.ejs b/views/staff/projects/show_404.ejs index 70320c0..f5e1658 100644 --- a/views/staff/projects/show_404.ejs +++ b/views/staff/projects/show_404.ejs @@ -2,12 +2,7 @@

Project not found

- +[[ include ../_nav ]]
diff --git a/views/staff/users/index.ejs b/views/staff/users/index.ejs index f14d666..1795dde 100644 --- a/views/staff/users/index.ejs +++ b/views/staff/users/index.ejs @@ -2,12 +2,7 @@

Users

- +[[ include ../_nav ]]
diff --git a/views/staff/users/media.ejs b/views/staff/users/media.ejs index c1097dd..8927c00 100644 --- a/views/staff/users/media.ejs +++ b/views/staff/users/media.ejs @@ -1,15 +1,10 @@ [[ include ../_header ]] -

User Media: [[- profile.username ]]

+

User Media: [[- profile.username ]]

- - -
+[[ include ../_nav ]] + +
[[ include ../_pagination ]] [[ include ../_gallery ]] diff --git a/views/staff/users/show.ejs b/views/staff/users/show.ejs index 8e9b447..4ce1d9a 100644 --- a/views/staff/users/show.ejs +++ b/views/staff/users/show.ejs @@ -1,12 +1,7 @@ [[ include ../_header ]]

User: [[- profile.username ]]

- +[[ include ../_nav ]]
diff --git a/views/staff/users/show_404.ejs b/views/staff/users/show_404.ejs index bcd0271..11663fa 100644 --- a/views/staff/users/show_404.ejs +++ b/views/staff/users/show_404.ejs @@ -1,13 +1,9 @@ [[ include ../_header ]] -

User not found

- - - -
+ +

User not found

+ +[[ include ../_nav ]] + +
[[ include ../_footer ]] -- cgit v1.2.3-70-g09d2 From 3eee6a15ee44a75f6deedd073f60b88d342d56ef Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 22 Jan 2015 16:54:08 -0500 Subject: recurly links on brochure --- server/lib/schemas/Plan.js | 2 ++ server/lib/schemas/User.js | 1 + server/lib/webhook/index.js | 1 + views/about/brochure.ejs | 19 +++++++++++++++---- 4 files changed, 19 insertions(+), 4 deletions(-) (limited to 'server/lib/schemas/Plan.js') diff --git a/server/lib/schemas/Plan.js b/server/lib/schemas/Plan.js index 1208672..8a19b99 100644 --- a/server/lib/schemas/Plan.js +++ b/server/lib/schemas/Plan.js @@ -10,6 +10,8 @@ var PlanSchema = new mongoose.Schema({ name: { type: String }, slug: { type: String }, + level: { type: Number }, + monthly_price: { type: Number }, yearly_price: { type: Number }, diff --git a/server/lib/schemas/User.js b/server/lib/schemas/User.js index ae1d912..867939e 100644 --- a/server/lib/schemas/User.js +++ b/server/lib/schemas/User.js @@ -56,6 +56,7 @@ var UserSchema = new mongoose.Schema({ }, plan_level: { type: Number, default: 0 }, + subscription_id: { type: mongoose.Schema.ObjectId }, location: { type: String, default: "" }, photo: { type: String, default: "" }, diff --git a/server/lib/webhook/index.js b/server/lib/webhook/index.js index c4b4b76..ebbd01a 100644 --- a/server/lib/webhook/index.js +++ b/server/lib/webhook/index.js @@ -33,6 +33,7 @@ var subscription = module.exports = { callbacks: { // accounts new_account_notification: function(data){ + // }, canceled_account_notification: function(data){ }, diff --git a/views/about/brochure.ejs b/views/about/brochure.ejs index e75f8c6..cffa51f 100644 --- a/views/about/brochure.ejs +++ b/views/about/brochure.ejs @@ -33,8 +33,14 @@
  • Each new floor plan can have up to [[- plans.basic.basic_project_limit ]] exhibitions
  • VValls logo appears when embedding an exhibition on a web page
  • - - + [[ if (! logged_in) { ]] + + [[ } else if (! profile.plan_level || profile.plan_level < plan.level) { ]] + + [[ } else if (profile.plan_level == plan.level) { ]] + Current Level + [[ } else { ]] + [[ } ]] @@ -49,8 +55,13 @@
  • Includes planning for 3D objects in the room
  • No VValls logo on embed
  • - - + [[ if (! logged_in) { ]] + + [[ } else if (! profile.plan_level || profile.plan_level < plan.level) { ]] + + [[ } else if (profile.plan_level == plan.level) { ]] + Current Level + [[ } ]] -- cgit v1.2.3-70-g09d2 From 33e5644226649d277c6b84dc37fccdd5b7c6e86c Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 7 Aug 2015 12:23:35 -0400 Subject: more accurate counts --- public/assets/javascripts/ui/site/LayoutsModal.js | 10 ++-- server/lib/api/layouts.js | 4 +- server/lib/middleware.js | 60 +++++++++++++++++++++-- server/lib/schemas/Plan.js | 2 +- server/lib/schemas/Project.js | 1 + server/lib/views/staff.js | 45 ++++++++++++++++- views/staff/_nav.ejs | 1 + views/staff/plans/_form.ejs | 6 +-- views/staff/projects/index.ejs | 2 +- 9 files changed, 113 insertions(+), 18 deletions(-) (limited to 'server/lib/schemas/Plan.js') diff --git a/public/assets/javascripts/ui/site/LayoutsModal.js b/public/assets/javascripts/ui/site/LayoutsModal.js index 639d55c..f69b38f 100644 --- a/public/assets/javascripts/ui/site/LayoutsModal.js +++ b/public/assets/javascripts/ui/site/LayoutsModal.js @@ -16,13 +16,15 @@ var LayoutsIndex = View.extend({ populate: function(data){ /* - if (data.layoutCount > data.plan.basic_layout_limit) { + if (data.layoutCounts.basic > data.plan.basic_layout_limit) { } - if (data.projectCount > data.plan.stock_project_limit) { + if (data.layoutCounts.pro > data.plan.pro_layout_limit) { } - if (data.projectCount > data.plan.basic_project_limit) { + if (data.projectCounts.stock > data.plan.stock_project_limit) { } - if (data.projectCount > data.plan.pro_project_limit) { + if (data.projectCounts.basic > data.plan.basic_project_limit) { + } + if (data.projectCounts.pro > data.plan.pro_project_limit) { } */ if (! data.layouts.length) { diff --git a/server/lib/api/layouts.js b/server/lib/api/layouts.js index 7e7976c..1c87fae 100644 --- a/server/lib/api/layouts.js +++ b/server/lib/api/layouts.js @@ -16,8 +16,8 @@ var layouts = { layouts: docs, plan: middleware.plans[ res.locals.user.plan_level || 0 ], user: res.locals.user, - layoutCount: res.locals.layoutCount, - projectCount: res.locals.projectCount, + layoutCounts: res.locals.layoutCounts, + projectCounts: res.locals.projectCounts, }) }) }, diff --git a/server/lib/middleware.js b/server/lib/middleware.js index 9d09a10..fe4dc49 100644 --- a/server/lib/middleware.js +++ b/server/lib/middleware.js @@ -60,20 +60,48 @@ var middleware = { res.locals.ogUrl = "http://vvalls.com/" res.locals.ogDescription = "3D gallery space, fully customizable" res.locals.ogAuthor = "VValls" - res.locals.plans = plans + res.locals.plans = middleware.plans res.locals.opt = {} next() }, ensureUserProjectsCount: function(req, res, next){ - Project.count({ user_id: req.user.id }, function(err, count){ - res.locals.projectCount = count || 0 + var counts = { stock: 0, basic: 0, pro: 0 } + res.locals.projectCounts = counts + Project.count({ user_id: req.user.id, layout_type: 0 }, function(err, count){ + res.locals.projectCounts.stock = count || 0 + if (req.user.plan_level > 0) { return middleware.ensureBasicProjectsCount(req, res, next) } + else next() + }) + }, + ensureBasicProjectsCount: function(req, res, next){ + Project.count({ user_id: req.user.id, layout_type: 1 }, function(err, count){ + res.locals.projectCounts.basic = count || 0 + if (req.user.plan_level > 1) { return middleware.ensureProProjectsCount(req, res, next) } + else next() + }) + }, + ensureProProjectsCount: function(req, res, next){ + Project.count({ user_id: req.user.id, layout_type: 2 }, function(err, count){ + res.locals.projectCounts.pro = count || 0 next() }) }, + ensureUserLayoutsCount: function(req, res, next){ - Layout.count({ user_id: req.user.id }, function(err, count){ - res.locals.layoutCount = count || 0 + var counts = { basic: 0, pro: 0 } + res.locals.layoutCounts = counts + if (req.user.plan_level == 0) { return next() } + + Layout.count({ user_id: req.user.id, layout_type: 1 }, function(err, count){ + res.locals.layoutCounts.basic = count || 0 + if (req.user.plan_level > 1) { return middleware.ensureProLayoutsCount(req, res, next) } + else next() + }) + }, + ensureProLayoutsCount: function(req, res, next){ + Project.count({ user_id: req.user.id, layout_type: 2 }, function(err, count){ + res.locals.layoutCounts.pro = count || 0 next() }) }, @@ -100,6 +128,28 @@ var middleware = { } }, + ensureLayout: function (req, res, next) { + if (req.params.slug) { + Layout.findOne({ slug: req.params.slug }, function(err, layout){ + if (err) { + console.error(err) + req.layout = null + } + else if (! project) { + req.layout = null + } + else { + req.layout = layout + } + next() + }) + } + else { + req.layout = null + next() + } + }, + ensureIsCollaborator: function(req, res, next) { req.isCollaborator = false req.isOwner = false diff --git a/server/lib/schemas/Plan.js b/server/lib/schemas/Plan.js index 8a19b99..388ce69 100644 --- a/server/lib/schemas/Plan.js +++ b/server/lib/schemas/Plan.js @@ -31,7 +31,7 @@ var PlanSchema = new mongoose.Schema({ permissions: { basic_editor: { type: Boolean, default: false }, pro_editor: { type: Boolean, default: false }, - solids: { type: Boolean, default: false }, + sculpture: { type: Boolean, default: false }, collaborators: { type: Boolean, default: false }, no_logo: { type: Boolean, default: false }, }, diff --git a/server/lib/schemas/Project.js b/server/lib/schemas/Project.js index e9501fc..855d95a 100644 --- a/server/lib/schemas/Project.js +++ b/server/lib/schemas/Project.js @@ -39,6 +39,7 @@ var ProjectSchema = new mongoose.Schema({ created_at: { type: Date }, updated_at: { type: Date }, featured: { type: Boolean, default: false }, + layout_type: { type: Number, default: 0 }, }); module.exports = exports = mongoose.model('project', ProjectSchema); diff --git a/server/lib/views/staff.js b/server/lib/views/staff.js index 19b361d..6c97bbd 100644 --- a/server/lib/views/staff.js +++ b/server/lib/views/staff.js @@ -21,7 +21,7 @@ var staff = module.exports = { plans: "monthly_price yearly_price basic_layout_monthly_price basic_layout_yearly_price " + "pro_layout_monthly_price pro_layout_yearly_price " + "basic_layout_limit pro_layout_limit stock_project_limit basic_project_limit pro_project_limit", - plans_permissions: "basic_editor pro_editor solids collaborators no_logo", + plans_permissions: "basic_editor pro_editor sculpture collaborators no_logo", }, defaults: { @@ -401,6 +401,13 @@ var staff = module.exports = { return project }, + layout: function(layout){ + layout = layout.toObject() + layout.date = moment( layout.updated_at || layout.created_at ).format("M/DD/YYYY hh:mm a") + layout.user = {} + return layout + }, + media: function(media){ media = media.toObject() media.date = moment( media.updated_at || media.created_at ).format("M/DD/YYYY hh:mm a") @@ -520,7 +527,41 @@ var staff = module.exports = { staff.projects.feature ); - + + // + // layouts + + app.get('/staff/layouts', + middleware.ensureAuthenticated, + middleware.ensureIsStaff, + + staff.middleware.ensureLayoutsCount, + + staff.middleware.ensureLayouts, + staff.middleware.ensureLayoutsUsers, + + staff.layouts.index + ); + app.get('/staff/layouts/:slug', + middleware.ensureAuthenticated, + middleware.ensureIsStaff, + + middleware.ensureLayout, + staff.middleware.ensureLayout, + staff.middleware.ensureLayoutUser, + + staff.layouts.show + ); + app.put('/staff/layouts/:slug/feature', + middleware.ensureAuthenticated, + middleware.ensureIsStaff, + + middleware.ensureLayout, + staff.middleware.ensureLayout, + + staff.layouts.make_stock + ); + // // media diff --git a/views/staff/_nav.ejs b/views/staff/_nav.ejs index a607638..3bb3b08 100644 --- a/views/staff/_nav.ejs +++ b/views/staff/_nav.ejs @@ -2,6 +2,7 @@ home users projects + layouts media plans diff --git a/views/staff/plans/_form.ejs b/views/staff/plans/_form.ejs index 61be7e8..85375fa 100644 --- a/views/staff/plans/_form.ejs +++ b/views/staff/plans/_form.ejs @@ -124,9 +124,9 @@
  • - - - + + +
  • diff --git a/views/staff/projects/index.ejs b/views/staff/projects/index.ejs index e4ba469..1d309ce 100644 --- a/views/staff/projects/index.ejs +++ b/views/staff/projects/index.ejs @@ -7,7 +7,7 @@
    [[ include ../_pagination ]] -[[ include ../_projects ]] +[[ include ../_layouts ]] [[ include ../_pagination ]] [[ include ../_footer ]] -- cgit v1.2.3-70-g09d2