Skip to content

Commit 3ddda3d

Browse files
RamiroAlvarorenzon
authored andcommitted
Implemented __str__ for Cohort model
close #2889
1 parent 20e869b commit 3ddda3d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pythonpro/cohorts/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ class Cohort(models.Model):
1919
def get_absolute_url(self):
2020
return reverse('cohorts:detail', kwargs={'slug': self.slug})
2121

22+
def __str__(self):
23+
return f'Turma: {self.title}'
24+
2225
@property
2326
def recorded_webinars(self):
2427
return [w for w in self.webinars if w.vimeo_id]

pythonpro/cohorts/tests/test_cohorts.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ def test_status_code(resp):
5858
assert 200 == resp.status_code
5959

6060

61+
def test_str(cohort):
62+
assert str(cohort) == f'Turma: {cohort.title}'
63+
64+
6165
@pytest.mark.parametrize('property_name', 'title forum_post'.split())
6266
def test_cohort_properties(cohort, resp, property_name):
6367
dj_assert_contains(resp, getattr(cohort, property_name))

0 commit comments

Comments
 (0)