Commits

Anonymous committed ff44653

Links to exercises within workout tables.

Comments (0)

Files changed (2)

workouts/templatetags/workout.py

             else:
                 output.append("<tr class='odd'>")
 
-            output.append("<td>%s</td>" % esc(execution.exercise))
+            exercise = (esc(execution.exercise.get_absolute_url()),
+                        esc(execution.exercise),)
+            output.append("<td><a href='%s'>%s</a></td>" % exercise)
             for j, series in enumerate(all_series[i]):
                 serie = (esc(series.repetitions),
                          esc(series.weight_with_unit()))

workouts/tests/templatetags.py

 
     def test_should_display_series_with_its_execution_in_the_same_row(self):
         table = workout_table(self.dylan_today).split("\n")[13:]
-        assert table[0] == "<td>Over-head Press</td>"
+        td = "<td><a href='/exercises/over-head-press/'>" + \
+             "Over-head Press</a></td>"
+        assert table[0] == td
         assert table[1] == "<td class='series'>5 &#215; 122.25kg</td>"
         assert table[2] == "<td class='series'>5 &#215; 132.25kg</td>"
         assert table[3] == "<td class='series'>5 &#215; 142.25kg</td>"
         assert table[4] == "<td class='series'>5 &#215; 152.25kg</td>"
         assert table[5] == "<td class='series'>5 &#215; 162.25kg</td>"
 
-        assert table[10] == "<td>Bench Press</td>"
+        td = "<td><a href='/exercises/bench-press/'>" + \
+             "Bench Press</a></td>"
+        assert table[10] == td
         assert table[11] == "<td class='series'>5 &#215; 80.5kg</td>"
         assert table[12] == "<td class='series'>5 &#215; 90.5kg</td>"
 
     def test_should_display_series_with_its_weight_unit(self):
         table = workout_table(self.dylan_today).split("\n")[13:]
-        assert table[0] == "<td>Over-head Press</td>"
+        td = "<td><a href='/exercises/over-head-press/'>" + \
+             "Over-head Press</a></td>"
+        assert table[0] == td
         assert table[1] == "<td class='series'>5 &#215; 122.25kg</td>"
 
-        assert table[10] == "<td>Bench Press</td>"
+        td = "<td><a href='/exercises/bench-press/'>" + \
+             "Bench Press</a></td>"
+        assert table[10] == td
         assert table[11] == "<td class='series'>5 &#215; 80.5kg</td>"
 
     def test_should_label_its_rows_with_odd_and_even(self):
         assert re.search('^<td>&nbsp', table[7])
         assert re.search('^<td><form', table[17])
 
+    def test_should_provide_link_to_the_exercise(self):
+        table = workout_table(self.dylan_today)
+        assert re.search("<a href='/exercises/over-head-press/'", table)
+
+
 class WorkoutStaticTableTemplatetagTestCase(MultipleSeriesModelSetup):
 
     def test_should_return_warning_when_the_workout_lacks_executions(self):
 
     def test_should_not_display_edit_link(self):
         table = static_workout_table(self.dylan_today)
-        assert not re.search('<a', table)
+        assert not re.search('Edit', table)
+        assert not re.search('/edit/', table)
 
     def test_should_display_as_many_numbered_th_as_executions(self):
         table = static_workout_table(self.dylan_today)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.