diff --git a/db.sqlite3 b/db.sqlite3 index cf1e8e6..288dc5f 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ diff --git a/fixtures/test_fixture.json b/fixtures/test_fixture.json index ee28046..fdb4827 100644 --- a/fixtures/test_fixture.json +++ b/fixtures/test_fixture.json @@ -23,7 +23,7 @@ "pk": 3, "fields": { "title": "Study: Skateboarding fosters 21st century, SEL skills", - "body": "

With skateboarding making its Olympic debut this year, the study contributes to a shifting perception of skateboarders from loitering youth who don\u2019t respect public property to resilient problem solvers who are eager to apply their skills to areas such as filmmaking, photography, music production and apparel design.

\r\n\r\n\u201cSkills and social connections obtained through skateboarding appear to have \u2018exchange value,\u2019\u201d the authors write. \u201cFor example, we learned of skaters receiving mentorship on school-related matters, support on class projects, and assistance on completing homework through skateboarding connections.\u201d

\r\n\r\n

One skateboard shop where that is taking place is the Garage Board Shop in East Los Angeles, where students from as many as 15 area schools skate in to complete their homework in exchange for time in the skate park behind the retail floor. And some schools are beginning to add after-school skateboarding classes and even competitive teams.

\r\n\r\n

Students, the authors write, have learned to navigate different attitudes among school leaders toward their sport.

\r\n\r\n

\u201cIn some instances, skaters had to be strategic when bringing skateboards to school; in others, skating was supported by school personnel,\u201d they write. \u201cSkaters knew which teachers would not mind if they stored their boards in their classrooms, and which teachers would hassle them.\u201d

", + "body": "

With skateboarding making its Olympic debut this year, the study contributes to a shifting perception of skateboarders from loitering youth who don\u2019t respect public property to resilient problem solvers who are eager to apply their skills to areas such as filmmaking, photography, music production and apparel design.

\r\n\r\n

\u201cSkills and social connections obtained through skateboarding appear to have \u2018exchange value,\u2019\u201d the authors write. \u201cFor example, we learned of skaters receiving mentorship on school-related matters, support on class projects, and assistance on completing homework through skateboarding connections.\u201d

\r\n\r\n

One skateboard shop where that is taking place is the Garage Board Shop in East Los Angeles, where students from as many as 15 area schools skate in to complete their homework in exchange for time in the skate park behind the retail floor. And some schools are beginning to add after-school skateboarding classes and even competitive teams.

\r\n\r\n

Students, the authors write, have learned to navigate different attitudes among school leaders toward their sport.

\r\n\r\n

\u201cIn some instances, skaters had to be strategic when bringing skateboards to school; in others, skating was supported by school personnel,\u201d they write. \u201cSkaters knew which teachers would not mind if they stored their boards in their classrooms, and which teachers would hassle them.\u201d

", "source": "https://www.educationdive.com/news/study-skateboarding-fosters-21st-century-sel-skills/573068/", "is_cover_story": false, "publish_date": "2020-02-28" diff --git a/wavepool/models.py b/wavepool/models.py index a466962..4e0620a 100644 --- a/wavepool/models.py +++ b/wavepool/models.py @@ -32,9 +32,16 @@ def teaser(self): @property def source_divesite_name(self): - return 'Industry Dive' + # Implementation based on naive assumption that URL is in a + # ://www..xyz/asdf-asdf-asdf format + hostname = self.source.split('/')[2].split('.')[1] + return DIVESITE_SOURCE_NAMES[hostname] def tags(self): return [ 'HR', 'Diversity & Inclusion', 'Culture' ] + + @property + def edit_url(self): + return reverse('admin:wavepool_newspost_change', args=[self.pk]) \ No newline at end of file diff --git a/wavepool/templates/wavepool/base.html b/wavepool/templates/wavepool/base.html index 5c0f5ce..66212c1 100644 --- a/wavepool/templates/wavepool/base.html +++ b/wavepool/templates/wavepool/base.html @@ -3,7 +3,7 @@ - Wavepool | Industry Dive + {{ newspost.title }} | Wavepool | Industry Dive diff --git a/wavepool/templates/wavepool/newspost.html b/wavepool/templates/wavepool/newspost.html index 221d811..66e91fe 100644 --- a/wavepool/templates/wavepool/newspost.html +++ b/wavepool/templates/wavepool/newspost.html @@ -19,12 +19,19 @@
- + {% if is_staff %} +
+ +
+ {% endif %}
-

{{ newspost.title }}{{newspost.publish_date}}

+

{{ newspost.title }}

+
+
+ {{newspost.publish_date}}
-
+
{{ newspost.body|safe }}
diff --git a/wavepool/tests.py b/wavepool/tests.py index 9dedce2..a5ac0cb 100644 --- a/wavepool/tests.py +++ b/wavepool/tests.py @@ -34,7 +34,7 @@ def _login_user(self): class NewsPostDetail(TestBase): def test_newspost_page_title_attribute(self): - """ Very that each newspost rendered at its unique URL displays the correct content + """ Verify that each newspost rendered at its unique URL displays the correct content """ newsposts = NewsPost.objects.all() for newspost in newsposts: @@ -45,16 +45,18 @@ def test_newspost_page_title_attribute(self): self.assertEqual(expected_title_tag_text, title_tag_text) def test_newspost_page_content(self): - """ Very that each newspost rendered at its unique URL displays the correct content + """ Verify that each newspost rendered at its unique URL displays the correct content """ newsposts = NewsPost.objects.all() for newspost in newsposts: + page = self.client.get(newspost.url) page_html = BeautifulSoup(page.content, 'html.parser') rendered_title = page_html.find('h1', {'id': 'newspost-title'}).text rendered_body = page_html.find('div', {'id': 'newspost-body'}).text + newspost_body = BeautifulSoup(newspost.body, 'html.parser').text self.assertEqual(rendered_title, newspost.title) - self.assertEqual(self._clean_text(rendered_body), self._clean_text(newspost.body)) + self.assertEqual(self._clean_text(rendered_body), self._clean_text(newspost_body)) def test_newspost_body_render(self): """ Verify that newsposts rendered at their URL do not display raw HTML to the screen diff --git a/wavepool/views.py b/wavepool/views.py index d3adb14..48c6073 100644 --- a/wavepool/views.py +++ b/wavepool/views.py @@ -30,8 +30,10 @@ def front_page(request): def newspost_detail(request, newspost_id): template = loader.get_template('wavepool/newspost.html') newspost = NewsPost.objects.get(pk=newspost_id) + # import pdb; pdb.set_trace() context = { - 'newspost': newspost + 'newspost': newspost, + 'is_staff': request.user.is_staff } return HttpResponse(template.render(context, request))