Skip to content

Instantly share code, notes, and snippets.

@salami-art
Created January 27, 2017 10:01
Show Gist options
  • Save salami-art/f560b3a2b0938f214b7dc8a5d350128a to your computer and use it in GitHub Desktop.
Save salami-art/f560b3a2b0938f214b7dc8a5d350128a to your computer and use it in GitHub Desktop.
#
# Here we manage the action of creating a new question.
#
angular.module('pazienti_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","Si è verificato un problema durante l'invio della domanda. Contatta il team di pazienti se il problema persiste." )
)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment