コード例 #1
0
    def csv(self):

        rows = []
        query = ClientQuestion.query()
        for q in query:
            coach = q.coach.get()
            client = q.client.get()
            addy = client.profile.company.address
            address = '{} {}, {}, {} {}'.format(addy.street, addy.city, addy.state, addy.postal, addy.country)
            data = dict(
                Question=q.question,
                Category=q.category,
                ClientName=client.name,
                ClientEmail=coach.email,
                ClientCompanyAddress=address,
                CoachName=coach.name,
                CoachEmail=coach.email
            )
            rows.append(data)

        output = StringIO()
        writer = csv.DictWriter(output, [
            'Question', 'Category', 'ClientName', 'ClientEmail',
            'ClientCompanyAddress', 'CoachEmail', 'CoachName'
        ])
        writer.writeheader()
        writer.writerows(rows)

        now = datetime.now().strftime(SHORT_DT)
        self.send_file(output.getvalue(), 'application/csv', 'ResourcePage-{}.csv'.format(now))
コード例 #2
0
    def post_client_question(self):

        if self.service.json.get('client_question'):
            qs = ClientQuestion.post_from_json(self.service.json['client_question'])
            qs_json = qs.to_json()

            self.service.json['client_question'] = qs_json
コード例 #3
0
    def create_answer(self, entity):

        answer = self.answers[entity.week]

        if entity.week == 5:
            ans = answer(
                parent=entity.client
            )
        else:
            cq = ClientQuestion(
                id=str(uuid4()),
                client=entity.client,
                coach=entity.coach

            )
            cq.put()
            ans = answer(
                parent=entity.client,
                client_question=cq.key
            )



        ans.put()