Skip to content

Commit ba78c2c

Browse files
committed
add motions integration
1 parent 0e3039c commit ba78c2c

4 files changed

Lines changed: 51 additions & 11 deletions

File tree

mittab/apps/tab/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@
7272
"subtitle": "Published ballots and detailed round results.",
7373
"url_path": "/public/ballots/",
7474
},
75+
{
76+
"slug": "public_motions",
77+
"title": "Motions",
78+
"subtitle": "View debate motions and info slides.",
79+
"url_path": "/public/motions/",
80+
},
7581
)
7682

7783
PUBLIC_HOME_SHORTCUT_DEFAULTS = (

mittab/libs/tests/views/test_post_operations.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def test_public_home_shortcuts_update(self):
134134
{
135135
"tournament_name": "MIT Invitational",
136136
"slot_1": "public_team_results",
137-
"slot_2": "public_speaker_results",
137+
"slot_2": "public_motions",
138138
"slot_3": "public_ballots",
139139
"slot_4": "released_pairings",
140140
"slot_5": "missing_ballots",
@@ -148,6 +148,10 @@ def test_public_home_shortcuts_update(self):
148148
PublicHomeShortcut.objects.get(position=1).nav_item,
149149
"public_team_results",
150150
)
151+
self.assertEqual(
152+
PublicHomeShortcut.objects.get(position=2).nav_item,
153+
"public_motions",
154+
)
151155
self.assertEqual(
152156
PublicHomeShortcut.objects.get(position=3).nav_item,
153157
"public_ballots",

mittab/libs/tests/views/test_public_views.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,46 @@ def test_public_home_falls_back_to_defaults_when_shortcuts_missing(self):
279279
self.assertIn(reverse("pretty_pair"), content)
280280
self.assertIn(reverse("missing_ballots"), content)
281281

282+
def test_public_home_shows_only_seven_shortcuts_when_motions_enabled(self):
283+
client = Client()
284+
TabSettings.set("motions_enabled", 1)
285+
286+
defaults = PublicHomeShortcut.default_slot_mapping()
287+
for position, nav_item in defaults.items():
288+
PublicHomeShortcut.objects.update_or_create(
289+
position=position,
290+
defaults={"nav_item": nav_item},
291+
)
292+
293+
caches["public"].clear()
294+
response = client.get(reverse("public_home"))
295+
self.assertEqual(response.status_code, 200)
296+
content = response.content.decode()
297+
298+
self.assertEqual(content.count('class="tile shadow-sm"'), 7)
299+
self.assertNotIn('<span class="title">Motions</span>', content)
300+
301+
def test_public_home_can_show_motions_when_selected_as_shortcut(self):
302+
client = Client()
303+
TabSettings.set("motions_enabled", 1)
304+
305+
defaults = PublicHomeShortcut.default_slot_mapping()
306+
defaults[1] = "public_motions"
307+
for position, nav_item in defaults.items():
308+
PublicHomeShortcut.objects.update_or_create(
309+
position=position,
310+
defaults={"nav_item": nav_item},
311+
)
312+
313+
caches["public"].clear()
314+
response = client.get(reverse("public_home"))
315+
self.assertEqual(response.status_code, 200)
316+
content = response.content.decode()
317+
318+
self.assertEqual(content.count('class="tile shadow-sm"'), 7)
319+
self.assertIn('<span class="title">Motions</span>', content)
320+
self.assertIn(reverse("public_motions"), content)
321+
282322
def test_public_rankings_control_updates_display_settings(self):
283323
client = Client()
284324
user = get_user_model().objects.create_superuser(

mittab/templates/public/home.html

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,6 @@ <h2 class="status-title mb-2">Status:</h2>
9595
<span class="chevron"><i class="fas fa-arrow-right"></i></span>
9696
</a>
9797
{% endfor %}
98-
{% motions_enabled as show_motions %}
99-
{% if show_motions %}
100-
<a class="tile shadow-sm" href="{% url 'public_motions' %}">
101-
<span class="body">
102-
<span class="title">Motions</span>
103-
<span class="subtitle">View debate motions and info slides.</span>
104-
</span>
105-
<span class="chevron"><i class="fas fa-arrow-right"></i></span>
106-
</a>
107-
{% endif %}
10898
</nav>
10999
</aside>
110100
</div>

0 commit comments

Comments
 (0)