فهرست منبع

Merge branch 'master' of https://github.com/sharelatex/web-sharelatex

Henry Oswald 11 سال پیش
والد
کامیت
e9ab77351a

+ 2 - 1
services/web/app/coffee/Features/Subscription/SubscriptionController.coffee

@@ -62,7 +62,8 @@ module.exports = SubscriptionController =
 								recurlyConfig: JSON.stringify
 									currency: currency
 									subdomain: Settings.apis.recurly.subdomain
-								showCouponField:req.query.scf
+								showCouponField: req.query.scf
+								couponCode:      req.query.cc or ""
 								subscriptionFormOptions: JSON.stringify
 									acceptedCards: ['discover', 'mastercard', 'visa']
 									target      : "#subscribeForm"

+ 9 - 0
services/web/app/coffee/infrastructure/Server.coffee

@@ -106,6 +106,15 @@ app.use (req, res, next) ->
 app.get "/status", (req, res)->
 	res.send("web sharelatex is alive")
 	req.session.destroy()
+	
+profiler = require "v8-profiler"
+app.get "/profile", (req, res) ->
+	time = parseInt(req.query.time || "1000")
+	profiler.startProfiling("test")
+	setTimeout () ->
+		profile = profiler.stopProfiling("test")
+		res.json(profile)
+	, time
 
 logger.info ("creating HTTP server").yellow
 server = require('http').createServer(app)

+ 2 - 3
services/web/app/views/subscriptions/new.jade

@@ -8,7 +8,7 @@ block scripts
 		window.countryCode = '#{countryCode}'
 		window.plan_code = '#{plan_code}'
 		window.recurlyApiKey = "!{settings.apis.recurly.publicKey}"
-
+		window.couponCode = "#{couponCode}"
 
 block content
 	- locals.supressDefaultJs = true
@@ -148,11 +148,10 @@ block content
 													mixin countries_options()
 									.row
 										.col-md-8
-											if showCouponField == 'true'
+											if (showCouponField)
 												.form-group
 													input.form-control(type='text', ng-blur="applyCoupon()", ng-model="data.coupon", placeholder="#{translate('coupon')}")
 
-
 									.row
 										.col-xs-7
 											.form-group

+ 1 - 0
services/web/package.json

@@ -41,6 +41,7 @@
     "translations-sharelatex": "git+https://github.com/sharelatex/translations-sharelatex.git#master",
     "underscore": "1.6.0",
     "underscore.string": "^3.0.2",
+    "v8-profiler": "^5.2.3",
     "xml2js": "0.2.0"
   },
   "devDependencies": {

+ 8 - 1
services/web/public/coffee/main/new-subscription.coffee

@@ -27,6 +27,7 @@ define [
 			state:""
 			city:""
 			country:window.countryCode
+			coupon: window.couponCode
 
 
 		$scope.validation =
@@ -41,7 +42,13 @@ define [
 		pricing = recurly.Pricing()
 		window.pricing = pricing
 
-		pricing.plan(window.plan_code, { quantity: 1 }).address({country: $scope.data.country}).tax({tax_code: 'digital', vat_number: ''}).currency($scope.currencyCode).done()
+		initialPricing = pricing
+			.plan(window.plan_code, { quantity: 1 })
+			.address({country: $scope.data.country})
+			.tax({tax_code: 'digital', vat_number: ''})
+			.currency($scope.currencyCode)
+			.coupon($scope.data.coupon)
+			.done()
 
 		pricing.on "change", =>
 			$scope.planName = pricing.items.plan.name