diff --git a/uber/site_sections/staffing.py b/uber/site_sections/staffing.py index 39da5a97f..3e58ca905 100644 --- a/uber/site_sections/staffing.py +++ b/uber/site_sections/staffing.py @@ -215,16 +215,8 @@ def hotel(self, session, message='', decline=None, **params): } @check_shutdown - def shifts(self, session, view='', start='', all=''): - joblist = session.jobs_for_signups(all=all) - con_days = -(-c.CON_LENGTH // 24) # Equivalent to ceil(c.CON_LENGTH / 24) - + def shifts(self, session, start=''): volunteer = session.logged_in_volunteer() - assigned_dept_ids = set(volunteer.assigned_depts_ids) - has_public_jobs = False - for job in joblist: - if job.is_public and job.department_id not in assigned_dept_ids: - has_public_jobs = True has_setup = volunteer.can_work_setup or any(d.is_setup_approval_exempt for d in volunteer.assigned_depts) has_teardown = volunteer.can_work_teardown or any( @@ -260,26 +252,24 @@ def shifts(self, session, view='', start='', all=''): other_filters = [ {'id': 'public', 'title': "Public Shifts",}, ] + + requested_hotel_nights = volunteer.hotel_requests.nights_ints if volunteer.hotel_requests else [] return { - 'jobs': joblist, 'has_public_jobs': session.query(Job).filter(Job.is_public == True).count(), 'depts_with_roles': [membership.department.name for membership in volunteer.dept_memberships_with_role], 'assigned_depts_list': [(dept.id, dept.name) for dept in volunteer.assigned_depts], - 'name': volunteer.full_name, 'hours': volunteer.weighted_hours, 'assigned_depts_labels': volunteer.assigned_depts_labels, 'default_filters': default_filters, 'all_filters': default_filters + other_filters, - 'view': view, 'start': start.date(), - 'end': end.date(), 'total_duration': total_duration, 'highlighted_dates': event_dates, 'setup_duration': 0 if not has_setup else (c.EPOCH - c.SETUP_JOB_START).days, 'teardown_duration': 0 if not has_teardown else (c.TEARDOWN_JOB_END - c.ESCHATON).days, - 'start_day': c.SHIFTS_START_DAY if has_setup else c.EPOCH, - 'show_all': all, + 'requested_setup_nights': [c.NIGHTS[night] for night in requested_hotel_nights if night in c.SETUP_NIGHTS], + 'requested_teardown_nights': [c.NIGHTS[night] for night in requested_hotel_nights if night in c.TEARDOWN_NIGHTS], } @ajax_gettable @@ -344,6 +334,8 @@ def get_assigned_jobs(self, session, **params): 'weight': job.weight, 'slots': f"{job.slots_taken}/{job.slots}", 'is_public': job.is_public, + 'is_setup': job.is_setup, + 'is_teardown': job.is_teardown, 'assigned': True, } }) diff --git a/uber/templates/staffing/shifts.html b/uber/templates/staffing/shifts.html index 6fa01ac11..36f8c94f0 100644 --- a/uber/templates/staffing/shifts.html +++ b/uber/templates/staffing/shifts.html @@ -39,7 +39,9 @@ {% endblock %} -{% block content %}
{{ csrf_token() }}
+{% set requested_teardown_nights = ["Sunday"] %} +{% block content %} +
{{ csrf_token() }}

{{ c.CURRENT_VOLUNTEER.first_name }} {{ c.CURRENT_VOLUNTEER.last_name }}'s Available Shifts

@@ -74,6 +76,23 @@

You are assigned to the following department{{ assigned_depts_labels|length|pluralize }}: {{ assigned_depts_labels|join(' / ') }}.

+ + {% if requested_setup_nights or requested_teardown_nights %} +
+

+ You have requested hotel space on + {% if requested_setup_nights %}setup nights ({{ requested_setup_nights|readable_join }}) {% if requested_teardown_nights %}and {% endif %}{% endif %} + {% if requested_teardown_nights %}teardown nights ({{ requested_teardown_nights|readable_join }}){% endif %} + but you are not signed up for shifts on all requested nights. +

+

+ Please make sure to sign up for + {% if requested_setup_nights and requested_teardown_nights %}BOTH {% endif %}{% if requested_setup_nights %}setup{% if requested_teardown_nights %} and {% endif %}{% endif %} + {% if requested_teardown_nights %}teardown{% endif %} shifts. + Failure to sign up for shifts in accordance with your hotel night requests may affect your ability to request staff crash space in the future. +

+
+ {% endif %}

@@ -373,12 +392,36 @@

const eventLists = await Promise.all(responses.map((response) => response.json())); let allNewEvents = [].concat(...eventLists); fetchedEventList.push(...allNewEvents); + + {% if requested_setup_nights or requested_teardown_nights %} + checkEdgeNights(); + {% endif %} + return fetchedEventList; } catch (e) { showErrorMessage('Unable to connect to server, please try again.') } } + {% if requested_setup_nights or requested_teardown_nights %} + let checkEdgeNights = function() { + let allShifts = [] + fetchedEventList.forEach(function(el) { allShifts.push(el.extendedProps) }) + let setupShifts = allShifts.filter(function(el) { return el.is_setup == true; }); + let teardownShifts = allShifts.filter(function(el) { return el.is_teardown == true; }); + + if ({% if requested_setup_nights %}setupShifts.length > 0 + {% if requested_teardown_nights %}&& + {% endif %}{% endif %} + {% if requested_teardown_nights %}teardownShifts.length > 0 + {% endif %}) { + $('#requested-night-warning').hide(); + } else { + $('#requested-night-warning').show(); + } + } + {% endif %} + let addEvents = function(id) { fetchEventsURLS.push(possibleEventURLS[id]); fetchedEventList.length = 0; @@ -591,6 +634,7 @@

eventClick: showEventDetails, filterEventsWithResources: true, resources: {{ default_filters|safe }}, + eventClassNames: 'border border-white', dayMaxEvents: true, nowIndicator: true, selectable: false,