Beispiel #1
0
    def setUp(self):
        create_engine('sqlite:///:memory:?check_same_thread=False', echo=True)
        create_schema()
        time = datetime.now()
        self.timeStr = time.strftime('%Y-%m-%d %H:%M:%S')

        session = Session()
        self.appointment = Appointment(1, 'Test Appointment 1', self.timeStr,
                                       self.timeStr)
        session.add(self.appointment)
        session.commit()
Beispiel #2
0
def matches():
    if request.method == 'POST':
        teams = get_teams_db()
        match = Match(request.form['team_home'], request.form['team_away'])
        match_id = insert_match_db(match)
        stadiums = get_stadiums_db()
        stadium_id = get_stad_id_with_stad_name(request.form['stadium_name'])
        appointment = Appointment(request.form['appointment_name'], match_id, stadium_id, request.form['start_time'], request.form['end_time'], request.form['match_date'])
        if not request.form['appointment_name']:
            matchs = get_appointments_db()
            return render_template("matches.html", matchs=matchs, teams=teams, stadiums=stadiums, error="Appointment name can not be empty!")
        try:
            insert_appointments_db(appointment)
            flash("Appointment successfully created!")
            matchs = get_appointments_db()
        except psycopg2.errors.UniqueViolation:
            matchs = get_appointments_db()
            return render_template("matches.html", matchs=matchs, teams=teams, stadiums=stadiums, error="Appointment name already exists!")
        return render_template("matches.html", matchs=matchs, teams=teams, stadiums=stadiums)
    if request.method == 'GET':
        teams = get_teams_db()
        matchs = get_appointments_db()
        stadiums = get_stadiums_db()
        return render_template("matches.html", matchs=matchs, teams=teams, stadiums=stadiums)
Beispiel #3
0
    def make_appt_and_add_appointment_to_manager(self, patient_email,
                                                 provider_email, centre_id,
                                                 date, time_slot, reason):
        try:
            date_and_time_valid(time_slot, date)
        except DateTimeValidityError as e:
            raise e

        if patient_email.lower() == provider_email.lower():
            raise BookingError(
                "Provider can't book an appointment with themselves")

        if not any(appt.provider_email == provider_email and appt.date == date
                   and appt.time_slot == time_slot
                   for appt in self._appointments):
            appointment = Appointment(self.__get_appt_id(), patient_email,
                                      provider_email, centre_id, date,
                                      time_slot, reason)
            # self._get_information(self, appointments)
            self._appointments.append(appointment)
            return appointment  # successful.
        else:
            raise BookingError(
                "Booking taken")  # Fail. Already in appointment list.