コード例 #1
0
def hcp_login():
    if request.method == 'GET':
        return render_template("hcp_login.html")
    if request.method == 'POST':
        username = request.form.get("hcp_username")
        password = request.form.get("hcp_password")
        if system.login_registered_user(username, password, 'hcp'):
            if current_user.is_provider() == True:
                return render_template("home.html")
            elif current_user.is_provider() == False:
                return render_template("hcp_login.html")
        return render_template("hcp_login.html")
    else:
        redir = request.args.get('next')
        return redirect(redir or url_for('hcp_login'))
コード例 #2
0
    def createBooking(self, time, date, HCP, patient, HCC, current_user, pNote = "", dNote = ""):

        curr_date = datetime.strptime(datetime.now().strftime("%Y-%m-%d"),'%Y-%m-%d')
        curr_time = datetime.strptime(datetime.now().strftime("%H:%M"),'%H:%M')

        if date == "":
            raise BookingError("date", "Please select a valid date")
        if datetime.strptime(date, '%Y-%m-%d') < curr_date:
            raise BookingError("date", "Please select a date that is not in the past")
        if time == "" and date != "":
            raise BookingError("time", "Please select a valid time")
        if time != "" and date != "":
            if datetime.strptime(date, '%Y-%m-%d') == curr_date and datetime.strptime(time, '%H:%M') < curr_time:
                raise BookingError("both", "Please select a time and date that is not in the past")
        if current_user.is_provider() == True:
            raise BookingError("provider", "A provider is not allowed to make bookings. Please login as a patient to make bookings")
        if current_user.search_bookings(time, date) == False:
            raise BookingError("patient", "Sorry. You cannot book two appointments at the same time")
        if current_user._email == HCP:
            raise BookingError("provider", "Sorry. A provider is not able to make an appointment with themselves")
        if self.check_availablity(HCP, date, time) == False:
            raise BookingError("provider", "Sorry. The provider is booked at this time. Please select another time or a different provider")
        else:
            newBooking = booking(time, date, HCP, patient, HCC, pNote, dNote)
            self._bookings.append(newBooking)
            newBooking.setBookingID(len(self._bookings))
            return newBooking
コード例 #3
0
        def decorated_fn(*args, **kwargs):
            if not current_user or not current_user.is_authenticated:
                return self._to_default_page()

            if not current_user.is_provider():
                return self._to_default_page()

            return fn(*args, **kwargs)