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/5] 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 bddbf8ff666e5f3f53b7157d6ab2cd50c890ecc8 Mon Sep 17 00:00:00 2001 From: somaniarushi Date: Mon, 20 Jul 2020 17:39:09 -0700 Subject: [PATCH 2/5] collapsing names for huge navbars --- oh_queue/static/js/components/navbar.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/oh_queue/static/js/components/navbar.js b/oh_queue/static/js/components/navbar.js index 9009dd1..af38dcf 100644 --- a/oh_queue/static/js/components/navbar.js +++ b/oh_queue/static/js/components/navbar.js @@ -55,7 +55,7 @@ let Navbar = ({ state, mode }) => { {currentUser ?
  • {currentUser.name} + role="button">{getDisplayName(currentUser.name, currentUser && currentUser.isStaff, isGroup)}
      {state.config.online_active && currentUser.isStaff && (
    • Online Setup
    • @@ -73,3 +73,20 @@ let Navbar = ({ state, mode }) => { ); } + +/* +Function to take in a username, and boolean values for whether the user is a staff member and +currently in a group. If both of those are true, then the user's name is reduced to their +initials. Else, their name is returned. +*/ +function getDisplayName(usrname, isStaff, myGroup) { + if (isStaff && myGroup) { + var display = "" + var names = (usrname.split(" ")); + names.forEach(name => { + display = display + name.charAt(0) + }); + return display; + } + return usrname +} \ No newline at end of file From dd77b2b3bdf01c25963c3a400ce8e22f0c2bbf9d Mon Sep 17 00:00:00 2001 From: somaniarushi Date: Mon, 20 Jul 2020 17:47:33 -0700 Subject: [PATCH 3/5] isGroup -> myGroup --- oh_queue/static/js/components/navbar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oh_queue/static/js/components/navbar.js b/oh_queue/static/js/components/navbar.js index af38dcf..e30a8fc 100644 --- a/oh_queue/static/js/components/navbar.js +++ b/oh_queue/static/js/components/navbar.js @@ -55,7 +55,7 @@ let Navbar = ({ state, mode }) => { {currentUser ?
    • {getDisplayName(currentUser.name, currentUser && currentUser.isStaff, isGroup)} + role="button">{getDisplayName(currentUser.name, currentUser && currentUser.isStaff, myGroup)}
        {state.config.online_active && currentUser.isStaff && (
      • Online Setup
      • From 5bb0e25d12882ed071c92aa1092edf428ab667c0 Mon Sep 17 00:00:00 2001 From: somaniarushi Date: Mon, 20 Jul 2020 18:11:04 -0700 Subject: [PATCH 4/5] move activity log to under user dropdown --- oh_queue/static/js/components/navbar.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/oh_queue/static/js/components/navbar.js b/oh_queue/static/js/components/navbar.js index e30a8fc..46c3760 100644 --- a/oh_queue/static/js/components/navbar.js +++ b/oh_queue/static/js/components/navbar.js @@ -46,9 +46,6 @@ let Navbar = ({ state, mode }) => { {currentUser && JSON.parse(state.config.appointments_open) &&
      • Appointments
      • } - {currentUser && currentUser.isStaff && -
      • Activity Log
      • } - {currentUser && currentUser.isStaff &&
      • Admin
      • } @@ -61,6 +58,8 @@ let Navbar = ({ state, mode }) => {
      • Online Setup
      • )}
      • Ticket History
      • + {currentUser && currentUser.isStaff && +
      • Activity Log
      • }
      • Log out
    • From 5beb5953bfe1077a1bf51f7c685095503406f287 Mon Sep 17 00:00:00 2001 From: somaniarushi Date: Mon, 20 Jul 2020 18:20:00 -0700 Subject: [PATCH 5/5] removing initials, adding admin dropdown --- oh_queue/static/js/components/navbar.js | 33 +++++++++---------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/oh_queue/static/js/components/navbar.js b/oh_queue/static/js/components/navbar.js index 46c3760..8211bae 100644 --- a/oh_queue/static/js/components/navbar.js +++ b/oh_queue/static/js/components/navbar.js @@ -45,21 +45,27 @@ let Navbar = ({ state, mode }) => { {currentUser && JSON.parse(state.config.appointments_open) &&
    • Appointments
    • } - + {currentUser && currentUser.isStaff && -
    • Admin
    • } +
    • + Admin +
        +
      • Settings
      • +
      • Activity Log
      • +
      +
    • + } {currentUser ?
    • {getDisplayName(currentUser.name, currentUser && currentUser.isStaff, myGroup)} + role="button">{currentUser.name}
        {state.config.online_active && currentUser.isStaff && (
      • Online Setup
      • )}
      • Ticket History
      • - {currentUser && currentUser.isStaff && -
      • Activity Log
      • }
      • Log out
    • @@ -71,21 +77,4 @@ let Navbar = ({ state, mode }) => { ); -} - -/* -Function to take in a username, and boolean values for whether the user is a staff member and -currently in a group. If both of those are true, then the user's name is reduced to their -initials. Else, their name is returned. -*/ -function getDisplayName(usrname, isStaff, myGroup) { - if (isStaff && myGroup) { - var display = "" - var names = (usrname.split(" ")); - names.forEach(name => { - display = display + name.charAt(0) - }); - return display; - } - return usrname } \ No newline at end of file