From b2ace0759bb704ba1eb15db012ad4f1b1b61b002 Mon Sep 17 00:00:00 2001 From: amanshah2711 <36978283+amanshah2711@users.noreply.github.com> Date: Tue, 14 Jul 2020 22:53:39 -0400 Subject: [PATCH 1/4] updating oh appts so pending appoints can be restricted by time (#219) --- .../components/admin_appointments_manager.js | 5 +++- oh_queue/views.py | 23 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/oh_queue/static/js/components/admin_appointments_manager.js b/oh_queue/static/js/components/admin_appointments_manager.js index cd3001f..382cc3b 100644 --- a/oh_queue/static/js/components/admin_appointments_manager.js +++ b/oh_queue/static/js/components/admin_appointments_manager.js @@ -61,8 +61,11 @@ function AdminAppointmentsManager({ state }) {

- How many appointments should a student have be pending simultaneously? + How many appointments should a student have be pending simultaneously?

+ (by + + ) = daily_threshold: return socket_error("You have already signed up for {} OH slots for the same day".format(daily_threshold)) - num_pending = AppointmentSignup.query.join(AppointmentSignup.appointment).filter( Appointment.status == AppointmentStatus.pending, AppointmentSignup.user_id == current_user.id, - ).count() - if num_pending >= pending_threshold: - return socket_error("You have already signed up for {} OH slots that have not yet occurred.".format(pending_threshold)) + ) + if pending_metric != 'false': + start = appointment.duration + num_pend = [appt.appointment.duration for appt in list(num_pending)] + threshold = datetime.timedelta(minutes=pending_threshold) + for item in num_pend: + start += item + if start > threshold: + return socket_error("You cannot sign up for more than {} minutes of OH that have not yet occurred.".format(pending_threshold)) + else: + if num_pending.count() >= pending_threshold: + return socket_error("You have already signed up for {} OH slots that have not yet occurred.".format(pending_threshold)) old_signup = AppointmentSignup.query.filter_by( appointment_id=data["appointment_id"], From 954d8c9b4c00fc62e36f3170640389a6eceaf49e Mon Sep 17 00:00:00 2001 From: Laryn Qi Date: Sat, 1 Aug 2020 04:14:43 -0700 Subject: [PATCH 2/4] require appointment fields --- .../js/components/appointment_overlay.js | 24 +++++++++++-------- oh_queue/static/js/components/slots_form.js | 2 ++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/oh_queue/static/js/components/appointment_overlay.js b/oh_queue/static/js/components/appointment_overlay.js index 5347869..adb24be 100644 --- a/oh_queue/static/js/components/appointment_overlay.js +++ b/oh_queue/static/js/components/appointment_overlay.js @@ -38,15 +38,19 @@ function AppointmentOverlay({ staffMode, appointment, assignments, signup, onSub }; const handleSubmit = () => { - app.makeRequest( - 'assign_appointment', { - appointment_id: appointment, - assignment_id: parseInt(assignment), - question: question, - description: description, - email: signup ? signup.user.email : email, - }); - onSubmit(); + if (assignment && question && description) { + app.makeRequest( + 'assign_appointment', { + appointment_id: appointment, + assignment_id: parseInt(assignment), + question: question, + description: description, + email: signup ? signup.user.email : email, + }); + onSubmit(); + } else { + alert("Please fill out all fields.") + } }; return ReactDOM.createPortal( @@ -64,7 +68,7 @@ function AppointmentOverlay({ staffMode, appointment, assignments, signup, onSub
{!staffMode && (

- Leave fields blank if you aren't yet sure what you want to ask about. + Please fill out all fields to the best of your ability. You can always come back and edit them later.

)}

+