ruchi commited on
Commit
4a10510
·
1 Parent(s): 7100756

Modal popup result

Browse files
flask-project/app.py CHANGED
@@ -42,6 +42,7 @@ def generateProposition():
42
 
43
  @app.route("/submit-proposition", methods = ['POST'])
44
  def submitProposition():
 
45
  city = request.form['city']
46
 
47
  productType = request.form['productType']
@@ -57,9 +58,8 @@ def submitProposition():
57
  proposition = request.form['proposition']
58
 
59
  matchingTopologies, predictedSubscriberTakeOut = evaluateProposition(city, productType, proposition, moneyNeeds, customerExpNeeds, sustainabilityNeeds)
60
- val = "matching topologies = {} and predictedSubscriberTakeOut = {}".format(",".join(matchingTopologies), predictedSubscriberTakeOut)
61
- print(val)
62
- return val
63
 
64
 
65
  if __name__ == "__main__":
 
42
 
43
  @app.route("/submit-proposition", methods = ['POST'])
44
  def submitProposition():
45
+ print("Proposition submitted")
46
  city = request.form['city']
47
 
48
  productType = request.form['productType']
 
58
  proposition = request.form['proposition']
59
 
60
  matchingTopologies, predictedSubscriberTakeOut = evaluateProposition(city, productType, proposition, moneyNeeds, customerExpNeeds, sustainabilityNeeds)
61
+
62
+ return {'matchingTopologies': matchingTopologies, 'predictedSubscriberTakeOut': predictedSubscriberTakeOut, 'subscriberDiff': predictedSubscriberTakeOut-int(subcount3)}
 
63
 
64
 
65
  if __name__ == "__main__":
flask-project/scripts/__pycache__/utils.cpython-310.pyc CHANGED
Binary files a/flask-project/scripts/__pycache__/utils.cpython-310.pyc and b/flask-project/scripts/__pycache__/utils.cpython-310.pyc differ
 
flask-project/scripts/utils.py CHANGED
@@ -245,7 +245,7 @@ def evaluateProposition(selectedCity, selectedProduct, userProposal, moneyNeeds,
245
  for topology in matchingTopologies:
246
  sumTopology = 0
247
  for moneyNeed in moneyNeeds:
248
- #print(" Money need = {}, Topology is {}".format(moneyNeed, topology))
249
  sumTopology = sumTopology+int(moneyNeedsDict[moneyNeed][topology])
250
 
251
  for customerExp in customerExpNeeds:
 
245
  for topology in matchingTopologies:
246
  sumTopology = 0
247
  for moneyNeed in moneyNeeds:
248
+ print(" Money need = {}, Topology is {}".format(moneyNeed, topology))
249
  sumTopology = sumTopology+int(moneyNeedsDict[moneyNeed][topology])
250
 
251
  for customerExp in customerExpNeeds:
flask-project/templates/newGame.html CHANGED
@@ -362,26 +362,19 @@
362
 
363
 
364
 
365
- <div id="dialog-content" style="display:none;max-width:500px;">
366
- <h2>Hello, world!</h2>
367
- <p>
368
- <input type="text" value="" />
369
- </p>
370
- <p>
371
- Try hitting the tab key and notice how the focus stays within the dialog
372
- itself.
373
- </p>
374
- <p>
375
- To close dialog hit the esc button, click on the overlay or just click the
376
- close button.
377
- </p>
378
- <p>
379
- Element used to launch the modal would receive focus back after closing.
380
- </p>
381
  </div>
382
- <button data-fancybox data-src="#dialog-content">Launch Dialog</button>
383
-
384
-
385
 
386
  <!--Scroll to top-->
387
  <div class="scroll-to-top">
@@ -438,12 +431,45 @@
438
 
439
  $("#submit-proposition").unbind().click( function (e) {
440
  e.preventDefault()
441
- $.post('/submit-proposition', $('#generate-proposition-form').serialize()+"&"+$('#submit-proposition-form').serialize(), function(data){
442
-
443
- })
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
  })
445
 
446
-
 
 
 
 
 
 
 
 
447
  });
448
  </script>
449
 
 
362
 
363
 
364
 
365
+ <div id="dialog-content" class="content_block_one" style="display:none;max-width:500px;">
366
+ <div class="content-box ml_40" >
367
+ <div class="sec-title mb_20">
368
+ <h6>Result</h2>
369
+ </div>
370
+
371
+ <p class='text-box mb_40' id="result">
372
+ </p>
373
+ <p class="inner-box mb_45" id="subscriberDiff">
374
+ </p>
375
+ </div>
 
 
 
 
 
376
  </div>
377
+ <button id="modal-button" data-fancybox data-src="#dialog-content" hidden>Launch Dialog</button>
 
 
378
 
379
  <!--Scroll to top-->
380
  <div class="scroll-to-top">
 
431
 
432
  $("#submit-proposition").unbind().click( function (e) {
433
  e.preventDefault()
434
+ $.ajax({
435
+ type: 'POST',
436
+ async:false,
437
+ url: '/submit-proposition',
438
+ data: $('#generate-proposition-form').serialize()+"&"+$('#submit-proposition-form').serialize(),
439
+ success: function(data){
440
+ topologiesText = '<span>Overall your targeted demographic and proposition are focusing the three topologies below<span><br><ul>'
441
+ data['matchingTopologies'].forEach(element => {
442
+ topologiesText = topologiesText + '<li>'+element+'</li>'
443
+ });
444
+ topologiesText = topologiesText + '</ul>'
445
+ topologiesText = topologiesText + '<br> For your proposition the total predicted subscriber take out count is '+ data['predictedSubscriberTakeOut']
446
+ $('#result').html(topologiesText)
447
+
448
+ if(data['subscriberDiff'] < 0) {
449
+ $('#subscriberDiff').html('Overall there is not a close match of your proposition to the main demographic. Takeout score difference = '+data['subscriberDiff'])
450
+ }
451
+ else if(data['subscriberDiff'] == 0) {
452
+ $('#subscriberDiff').html('Amazing! Your proposition exactly match the target subscriber take oup for year 3')
453
+ }
454
+ else {
455
+ $('#subscriberDiff').html('Great Job! Your proposition exceeds the target subscriber take up for year 3. Additional takeout = '+data['subscriberDiff'])
456
+
457
+ }
458
+ $('#modal-button').fancybox().trigger('click');
459
+
460
+
461
+ }})
462
  })
463
 
464
+ /*
465
+ <div id="dialog-content" style="display:none;max-width:500px;">
466
+ <h2>Result</h2>
467
+ <p id="result">
468
+ </p>
469
+ <p id="subscriberDiff">
470
+ </p>
471
+ </div>
472
+ */
473
  });
474
  </script>
475