Skip to content

Commit 64e9048

Browse files
Link to the timeslot editor when meeting has no timeslots. Fixes ietf-tools#3511. Commit ready for merge.
- Legacy-Id: 19841
1 parent 6f3fb69 commit 64e9048

3 files changed

Lines changed: 110 additions & 83 deletions

File tree

ietf/meeting/tests_views.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,23 @@ def test_unassign_session(self):
16771677
self.assertEqual(r.status_code, 200)
16781678
self.assertTrue(self._decode_json_response(r)['success'])
16791679

1680+
def test_editor_with_no_timeslots(self):
1681+
"""Schedule editor should not crash when there are no timeslots"""
1682+
meeting = MeetingFactory(
1683+
type_id='ietf',
1684+
date=datetime.date.today() + datetime.timedelta(days=7),
1685+
populate_schedule=False,
1686+
)
1687+
meeting.schedule = ScheduleFactory(meeting=meeting)
1688+
meeting.save()
1689+
SessionFactory(meeting=meeting, add_to_schedule=False)
1690+
self.assertEqual(meeting.timeslot_set.count(), 0, 'Test problem - meeting should not have any timeslots')
1691+
url = urlreverse('ietf.meeting.views.edit_meeting_schedule', kwargs={'num': meeting.number})
1692+
self.assertTrue(self.client.login(username='secretary', password='secretary+password'))
1693+
r = self.client.get(url)
1694+
self.assertEqual(r.status_code, 200)
1695+
self.assertContains(r, 'No timeslots exist')
1696+
self.assertContains(r, urlreverse('ietf.meeting.views.edit_timeslots', kwargs={'num': meeting.number}))
16801697

16811698

16821699
class EditTimeslotsTests(TestCase):

ietf/meeting/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,8 @@ def timeslot_locked(ts):
506506
min_duration = min(t.duration for t in timeslots_qs)
507507
max_duration = max(t.duration for t in timeslots_qs)
508508
else:
509-
min_duration = 1
510-
max_duration = 2
509+
min_duration = datetime.timedelta(minutes=30)
510+
max_duration = datetime.timedelta(minutes=120)
511511

512512
def timedelta_to_css_ems(timedelta):
513513
# we scale the session and slots a bit according to their

ietf/templates/meeting/edit_meeting_schedule.html

Lines changed: 91 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -75,96 +75,106 @@
7575
{% endif %}
7676
</p>
7777

78-
<div class="edit-grid {% if not can_edit %}read-only{% endif %}">
79-
80-
{# using the same markup in both room labels and the actual days ensures they are aligned #}
81-
<div class="room-label-column">
82-
{% for day_data in days.values %}
83-
<div class="day">
84-
<div class="day-label">
85-
<strong>&nbsp;</strong><br>
86-
&nbsp;
87-
</div>
88-
89-
{% for rgroup in day_data %}
90-
<div class="room-group">
91-
<div class="time-header"><div class="time-label"></div></div>
92-
{% for room_data in rgroup %}{% with room_data.room as room %}
93-
<div class="timeslots">
94-
<div class="room-name">
95-
<strong>{{ room.name }}</strong><br>
96-
{% if room.capacity %}{{ room.capacity }} <i class="fa fa-user-o"></i>{% endif %}
97-
</div>
98-
</div>
99-
{% endwith %}{% endfor %}
78+
{% if timeslot_groups|length == 0 %}
79+
<p>
80+
No timeslots exist for this meeting yet.
81+
</p>
82+
<p>
83+
<a href="{% url "ietf.meeting.views.edit_timeslots" num=meeting.number %}">
84+
Edit timeslots.
85+
</a>
86+
</p>
87+
{% else %}
88+
<div class="edit-grid {% if not can_edit %}read-only{% endif %}">
89+
{# using the same markup in both room labels and the actual days ensures they are aligned #}
90+
<div class="room-label-column">
91+
{% for day_data in days.values %}
92+
<div class="day">
93+
<div class="day-label">
94+
<strong>&nbsp;</strong><br>
95+
&nbsp;
10096
</div>
101-
{% endfor %}
102-
</div>
103-
{% endfor %}
104-
</div>
105-
106-
<div class="day-flow">
107-
{% for day, day_data in days.items %}
108-
<div class="day">
109-
<div class="day-label">
110-
<strong>{{ day|date:"l" }}</strong>
111-
<i class="fa fa-exchange swap-days"
112-
data-dayid="{{ day.isoformat }}"
113-
data-start="{{ day.isoformat }}"></i>
114-
<br>
115-
{{ day|date:"N j, Y" }}
116-
</div>
11797

118-
{% for rgroup in day_data %}
119-
<div class="room-group"
120-
data-index="{{ forloop.counter0 }}"
121-
data-rooms="{% for r in rgroup %}{{ r.room.pk }}{% if not forloop.last %},{% endif %}{% endfor %}">
122-
<div class="time-header">
123-
{# All rooms in a group have same timeslots; grab the first for the labels #}
124-
{% for t in rgroup.0.timeslots %}
125-
<div class="time-label" style="width: {{ t.layout_width }}rem">
126-
<span>
127-
{{ t.time|date:"G:i" }} - {{ t.end_time|date:"G:i" }}
128-
<i class="fa fa-exchange swap-timeslot-col"
129-
data-origin-label="{{ day|date:"l, N j" }}, {{ t.time|date:"G:i" }}-{{ t.end_time|date:"G:i" }}"
130-
data-start="{{ t.utc_start_time.isoformat }}"
131-
data-timeslot-pk="{{ t.pk }}"></i>
132-
</span>
98+
{% for rgroup in day_data %}
99+
<div class="room-group">
100+
<div class="time-header"><div class="time-label"></div></div>
101+
{% for room_data in rgroup %}{% with room_data.room as room %}
102+
<div class="timeslots">
103+
<div class="room-name">
104+
<strong>{{ room.name }}</strong><br>
105+
{% if room.capacity %}{{ room.capacity }} <i class="fa fa-user-o"></i>{% endif %}
106+
</div>
133107
</div>
134-
{% endfor %}
108+
{% endwith %}{% endfor %}
135109
</div>
136-
{% for room_data in rgroup %}{% with room_data.room as room %}
137-
<div class="timeslots" data-roomcapacity="{{ room.capacity }}">
138-
{% for t in room_data.timeslots %}
139-
<div id="timeslot{{ t.pk }}"
140-
class="timeslot {{ t.start_end_group }}"
141-
data-start="{{ t.utc_start_time.isoformat }}"
142-
data-end="{{ t.utc_end_time.isoformat }}"
143-
data-duration="{{ t.duration.total_seconds }}"
144-
data-scheduledatlabel="{{ t.time|date:"l G:i" }}-{{ t.end_time|date:"G:i" }}"
145-
data-type="{{ t.type.slug }}"
146-
style="width: {{ t.layout_width }}rem;">
147-
<div class="time-label">
148-
<div class="past-flag">&nbsp;{# blank div keeps time centered vertically #}</div>
149-
<div>{{ t.time|date:"G:i" }} - {{ t.end_time|date:"G:i" }}</div>
150-
<div class="past-flag">Past</div>
151-
</div>
110+
{% endfor %}
111+
</div>
112+
{% endfor %}
113+
</div>
152114

153-
<div class="drop-target">
154-
{% for assignment, session in t.session_assignments %}
155-
{% include "meeting/edit_meeting_schedule_session.html" %}
156-
{% endfor %}
157-
</div>
115+
<div class="day-flow">
116+
{% for day, day_data in days.items %}
117+
<div class="day">
118+
<div class="day-label">
119+
<strong>{{ day|date:"l" }}</strong>
120+
<i class="fa fa-exchange swap-days"
121+
data-dayid="{{ day.isoformat }}"
122+
data-start="{{ day.isoformat }}"></i>
123+
<br>
124+
{{ day|date:"N j, Y" }}
125+
</div>
126+
127+
{% for rgroup in day_data %}
128+
<div class="room-group"
129+
data-index="{{ forloop.counter0 }}"
130+
data-rooms="{% for r in rgroup %}{{ r.room.pk }}{% if not forloop.last %},{% endif %}{% endfor %}">
131+
<div class="time-header">
132+
{# All rooms in a group have same timeslots; grab the first for the labels #}
133+
{% for t in rgroup.0.timeslots %}
134+
<div class="time-label" style="width: {{ t.layout_width }}rem">
135+
<span>
136+
{{ t.time|date:"G:i" }} - {{ t.end_time|date:"G:i" }}
137+
<i class="fa fa-exchange swap-timeslot-col"
138+
data-origin-label="{{ day|date:"l, N j" }}, {{ t.time|date:"G:i" }}-{{ t.end_time|date:"G:i" }}"
139+
data-start="{{ t.utc_start_time.isoformat }}"
140+
data-timeslot-pk="{{ t.pk }}"></i>
141+
</span>
158142
</div>
159143
{% endfor %}
160144
</div>
161-
{% endwith %}{% endfor %}
162-
</div>
163-
{% endfor %}
164-
</div>
165-
{% endfor %}
145+
{% for room_data in rgroup %}{% with room_data.room as room %}
146+
<div class="timeslots" data-roomcapacity="{{ room.capacity }}">
147+
{% for t in room_data.timeslots %}
148+
<div id="timeslot{{ t.pk }}"
149+
class="timeslot {{ t.start_end_group }}"
150+
data-start="{{ t.utc_start_time.isoformat }}"
151+
data-end="{{ t.utc_end_time.isoformat }}"
152+
data-duration="{{ t.duration.total_seconds }}"
153+
data-scheduledatlabel="{{ t.time|date:"l G:i" }}-{{ t.end_time|date:"G:i" }}"
154+
data-type="{{ t.type.slug }}"
155+
style="width: {{ t.layout_width }}rem;">
156+
<div class="time-label">
157+
<div class="past-flag">&nbsp;{# blank div keeps time centered vertically #}</div>
158+
<div>{{ t.time|date:"G:i" }} - {{ t.end_time|date:"G:i" }}</div>
159+
<div class="past-flag">Past</div>
160+
</div>
161+
162+
<div class="drop-target">
163+
{% for assignment, session in t.session_assignments %}
164+
{% include "meeting/edit_meeting_schedule_session.html" %}
165+
{% endfor %}
166+
</div>
167+
</div>
168+
{% endfor %}
169+
</div>
170+
{% endwith %}{% endfor %}
171+
</div>
172+
{% endfor %}
173+
</div>
174+
{% endfor %}
175+
</div>
166176
</div>
167-
</div>
177+
{% endif %}
168178

169179
<div class="scheduling-panel">
170180
<div class="unassigned-container">

0 commit comments

Comments
 (0)