Skip to content

Instantly share code, notes, and snippets.

@salami-art
Created January 27, 2017 10:04
Show Gist options
  • Save salami-art/5cd54bde89004fc0c77cdb56a57f0214 to your computer and use it in GitHub Desktop.
Save salami-art/5cd54bde89004fc0c77cdb56a57f0214 to your computer and use it in GitHub Desktop.
#
# Here we manage the action of creating a new question.
#
angular.module('mymodule_light').controller "QuestionsNewCtrl", ['$scope', '$modal', '$http', 'current_session', ($scope, $modal, $http, current_session)->
$scope.question =
description: ""
$scope.ask = (question)->
current_session.options.prevent_redirect = true
unless current_session.present()
$modal.open("login.patient_form") # $('#login_choices_modal').modal('show')
current_session.onLogin((user, location, options)->
$modal.closeAll()
$scope.ask(question)
,0)
else
$scope.processingQuestion = true
data = { question: question }
# CREATING A NEW QUESTION
$http.post("/api/v1/risposte/", data).success(
(send_response)->
window.location.href = "/congratulazioni-domanda-gratis"
).error(
(r)->
console.error "Error while asking question... LOG: " + r
Flashing.setMessage("bad"," Error ( ... ) ." )
)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment