def post(self):
        newUser = Responder(name = self.request.get('name'), email = self.request.get('email'), company = self.request.get('company'))
        newUser.put()

        set = ResponseSet(product = 'ADSync', responder = newUser)
        set.put()

        adQuestions = Question.gql('WHERE product = :1', 'ADSync')

        htmlBody = '<h2>Response to ADSync Questionnaire</h2><p><i>Submitted by ' + newUser.name +', ' + newUser.email + '</i></p>'

        for adQuestion in adQuestions:
            responseText = self.request.get('response' + str(adQuestion.key().id()))
            response = Response(text = responseText, question = adQuestion, responseSet = set)
            response.put()
            htmlBody += '<h3>' + adQuestion.text + '</h3>' + '<p>' + response.text + '</p>'

        #send email notification
        sender = '*****@*****.**'
        recipients = ['*****@*****.**', '*****@*****.**', '*****@*****.**']
        sub = newUser.name + ' from ' + newUser.company + ' responded to the ADSync Questionnaire'
        plainBody = 'Get response here: http://yammerie.appspot.com/responsesets?id=' + str(set.key().id())

        mail.send_mail(sender, recipients, sub, plainBody, html = htmlBody)

        self.redirect('/adsuccess')
    def get(self):
        qId = int(self.request.get('id'))
        responseSet = ResponseSet.get_by_id(qId)
        responses = Response.all()
        responses.filter('responseSet =', responseSet)

        values = {'responseSet': responseSet, 'responses': responses}
        self.response.out.write(template.render('templates/responseSet.html', values))
    def get(self):
        id = int(self.request.get('id'))
        responseSet = ResponseSet.get_by_id(id)

        #First, need to delete all the responses that are associated with the response set that I'm deleting
        responses = Response.all()
        responses.filter('responseSet =', responseSet)
        
        for response in responses:
            response.delete()

        responseSet.delete()

        self.redirect('/qadmin')
    def get(self):
        questions = Question.all()
        responseSets = ResponseSet.all()

        values = {'questions': questions, 'responseSets': responseSets}
        self.response.out.write(template.render('templates/questionAdmin.html', values))