コード例 #1
0
ファイル: mock.py プロジェクト: jpsimons/arivale
    def get(self):
        # Clear data
        db.delete(CoachAvailability.all())
        db.delete(Appointment.all())

        # Create availability for the next couple months
        morning = datetime.time(9, 0, 0)
        afternoon = datetime.time(13, 0, 0)
        today = datetime.date.today()

        for x in range(0, 60):
            date = today + datetime.timedelta(days=x)
            # Morning availability
            if random.random() > 0.2:
                slot = CoachAvailability(date=date, start_time=morning, duration_minutes=180)
                slot.put()
                for hour in range(9, 12):
                    if random.random() > 0.5:
                        appt = Appointment(
                            date=date, start_time=datetime.time(hour, 0, 0), duration_minutes=60, client_id=SOMEONE_ELSE
                        )
                        appt.put()
            # Afternoon availability
            if random.random() > 0.2:
                duration_minutes = 90 + int(random.random() * 10) * 30
                slot = CoachAvailability(date=date, start_time=afternoon, duration_minutes=duration_minutes)
                slot.put()
                for hour in range(13, 13 + duration_minutes / 60):
                    if random.random() > 0.5:
                        appt = Appointment(
                            date=date, start_time=datetime.time(hour, 0, 0), duration_minutes=60, client_id=SOMEONE_ELSE
                        )
                        appt.put()
        self.response.write("Done")
コード例 #2
0
ファイル: schedule.py プロジェクト: jpsimons/arivale
    def post(self):
        # Parse date
        date = self.request.get('date')
        dateParts = date.split('/')
        year = int(dateParts[0])
        month = int(dateParts[1])
        day = int(dateParts[2])
        date = datetime.date(year, month, day)

        # Parse time
        hour = int(self.request.get('hour'))
        minute = int(self.request.get('minute'))
        ampm = self.request.get('ampm')
        if ampm == 'pm':
            hour += 12
        time = datetime.time(hour, minute, 0)

        # Insert to database
        appt = Appointment(date = date, start_time = time, duration_minutes = 60, client_id = 1)
        appt.put()

        self.response.write('OK')