diff --git a/requirements/base.txt b/requirements/base.txt index b5a6858..033f18c 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -8,7 +8,7 @@ django-celery-beat==1.5.0 djangorestframework==3.9.4 django-rest-swagger==2.2.0 django-registration-redux==2.6 -lxml==4.3.4 +lxml==4.4.2 feedparser==5.2.1 idna==2.8 pytz==2018.9 diff --git a/src/newsreader/js/pages/homepage/components/PostModal.js b/src/newsreader/js/pages/homepage/components/PostModal.js index 75650fb..b077230 100644 --- a/src/newsreader/js/pages/homepage/components/PostModal.js +++ b/src/newsreader/js/pages/homepage/components/PostModal.js @@ -28,7 +28,7 @@ class PostModal extends React.Component { render() { const post = this.props.post; - const publicationDate = formatDatetime(post.publication_date); + const publicationDate = formatDatetime(post.publicationDate); const titleClassName = post.read ? 'post__title post__title--read' : 'post__title'; return ( diff --git a/src/newsreader/js/pages/homepage/components/feedlist/PostItem.js b/src/newsreader/js/pages/homepage/components/feedlist/PostItem.js index 865af41..47d4832 100644 --- a/src/newsreader/js/pages/homepage/components/feedlist/PostItem.js +++ b/src/newsreader/js/pages/homepage/components/feedlist/PostItem.js @@ -8,7 +8,7 @@ import { formatDatetime } from '../../../../utils.js'; class PostItem extends React.Component { render() { const post = this.props.post; - const publicationDate = formatDatetime(post.publication_date); + const publicationDate = formatDatetime(post.publicationDate); const titleClassName = post.read ? 'posts-header__title posts-header__title--read' : 'posts-header__title'; diff --git a/src/newsreader/js/pages/homepage/components/feedlist/RuleItem.js b/src/newsreader/js/pages/homepage/components/feedlist/RuleItem.js index f7a8a9b..608e8a1 100644 --- a/src/newsreader/js/pages/homepage/components/feedlist/RuleItem.js +++ b/src/newsreader/js/pages/homepage/components/feedlist/RuleItem.js @@ -5,7 +5,7 @@ import PostItem from './PostItem.js'; class RuleItem extends React.Component { render() { const posts = Object.values(this.props.posts).sort((firstEl, secondEl) => { - return new Date(secondEl.publication_date) - new Date(firstEl.publication_date); + return new Date(secondEl.publicationDate) - new Date(firstEl.publicationDate); }); const postItems = posts.map(post => { diff --git a/src/newsreader/js/tests/homepage/actions/post.test.js b/src/newsreader/js/tests/homepage/actions/post.test.js index b9bdddf..31bb666 100644 --- a/src/newsreader/js/tests/homepage/actions/post.test.js +++ b/src/newsreader/js/tests/homepage/actions/post.test.js @@ -22,13 +22,13 @@ describe('rule actions', () => { it('should create an action receive a post', () => { const post = { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 5, read: false, @@ -45,13 +45,13 @@ describe('rule actions', () => { it('should create an action to select a post', () => { const post = { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 5, read: false, @@ -74,13 +74,13 @@ describe('rule actions', () => { it('should create an action mark a post read', () => { const post = { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 5, read: false, @@ -107,13 +107,13 @@ describe('rule actions', () => { it('should create multiple actions to mark post read', () => { const post = { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 5, read: false, @@ -166,25 +166,25 @@ describe('rule actions', () => { const posts = { 2067: { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 4, read: false, }, 2141: { id: 2141, - remote_identifier: 'https://arstechnica.com/?p=1648757', + remoteIdentifier: 'https://arstechnica.com/?p=1648757', title: 'The most complete brain map ever is here: A fly’s “connectome”', body: 'It took 12 years and at least $40 million to chart a region about 250µm across.', author: 'WIRED', - publication_date: '2020-01-25T11:06:46Z', + publicationDate: '2020-01-25T11:06:46Z', url: 'https://arstechnica.com/?p=1648757', rule: 4, read: false, @@ -236,25 +236,25 @@ describe('rule actions', () => { const posts = { 2067: { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 4, read: false, }, 2141: { id: 2141, - remote_identifier: 'https://arstechnica.com/?p=1648757', + remoteIdentifier: 'https://arstechnica.com/?p=1648757', title: 'The most complete brain map ever is here: A fly’s “connectome”', body: 'It took 12 years and at least $40 million to chart a region about 250µm across.', author: 'WIRED', - publication_date: '2020-01-25T11:06:46Z', + publicationDate: '2020-01-25T11:06:46Z', url: 'https://arstechnica.com/?p=1648757', rule: 4, read: false, diff --git a/src/newsreader/js/tests/homepage/reducers/category.test.js b/src/newsreader/js/tests/homepage/reducers/category.test.js index 4211ad2..2eeed65 100644 --- a/src/newsreader/js/tests/homepage/reducers/category.test.js +++ b/src/newsreader/js/tests/homepage/reducers/category.test.js @@ -67,12 +67,12 @@ describe('category reducer', () => { const post = { id: 2091, - remote_identifier: 'https://www.bbc.co.uk/news/world-asia-china-51249208', + remoteIdentifier: 'https://www.bbc.co.uk/news/world-asia-china-51249208', title: 'China coronavirus spread is accelerating, Xi Jinping warns', body: 'China\'s president tells a high-level meeting that the country faces a "grave situation".', author: null, - publication_date: '2020-01-26T05:54:14Z', + publicationDate: '2020-01-26T05:54:14Z', url: 'https://www.bbc.co.uk/news/world-asia-china-51249208', rule: 4, read: false, @@ -117,12 +117,12 @@ describe('category reducer', () => { const post = { id: 2182, - remote_identifier: 'https://arstechnica.com/?p=1648871', + remoteIdentifier: 'https://arstechnica.com/?p=1648871', title: 'Tesla needs to fix Autopilot safety flaws, demands Senator Markey', body: 'It should be renamed and fitted with a real driver-monitoring system, he says.', author: 'Jonathan M. Gitlin', - publication_date: '2020-01-25T18:34:20Z', + publicationDate: '2020-01-25T18:34:20Z', url: 'https://arstechnica.com/?p=1648871', rule: 1, read: false, diff --git a/src/newsreader/js/tests/homepage/reducers/post.test.js b/src/newsreader/js/tests/homepage/reducers/post.test.js index fe72ce0..b54c3a1 100644 --- a/src/newsreader/js/tests/homepage/reducers/post.test.js +++ b/src/newsreader/js/tests/homepage/reducers/post.test.js @@ -18,13 +18,13 @@ describe('post actions', () => { it('should return state after receiving a post', () => { const post = { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 4, read: false, @@ -48,25 +48,25 @@ describe('post actions', () => { const posts = { 2067: { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 4, read: false, }, 2141: { id: 2141, - remote_identifier: 'https://arstechnica.com/?p=1648757', + remoteIdentifier: 'https://arstechnica.com/?p=1648757', title: 'The most complete brain map ever is here: A fly’s “connectome”', body: 'It took 12 years and at least $40 million to chart a region about 250µm across.', author: 'WIRED', - publication_date: '2020-01-25T11:06:46Z', + publicationDate: '2020-01-25T11:06:46Z', url: 'https://arstechnica.com/?p=1648757', rule: 4, read: false, @@ -92,49 +92,49 @@ describe('post actions', () => { const posts = { 2067: { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 5, read: false, }, 2141: { id: 2141, - remote_identifier: 'https://arstechnica.com/?p=1648757', + remoteIdentifier: 'https://arstechnica.com/?p=1648757', title: 'The most complete brain map ever is here: A fly’s “connectome”', body: 'It took 12 years and at least $40 million to chart a region about 250µm across.', author: 'WIRED', - publication_date: '2020-01-25T11:06:46Z', + publicationDate: '2020-01-25T11:06:46Z', url: 'https://arstechnica.com/?p=1648757', rule: 5, read: false, }, 4637: { id: 4637, - remote_identifier: 'https://www.bbc.co.uk/news/world-asia-china-51299195', + remoteIdentifier: 'https://www.bbc.co.uk/news/world-asia-china-51299195', title: "Coronavirus: Whole world 'must take action', warns WHO", body: 'The World Health Organization will hold a further emergency meeting on the coronavirus on Thursday.', author: null, - publication_date: '2020-01-29T19:08:25Z', + publicationDate: '2020-01-29T19:08:25Z', url: 'https://www.bbc.co.uk/news/world-asia-china-51299195', rule: 4, read: false, }, 4638: { id: 4638, - remote_identifier: 'https://www.bbc.co.uk/news/world-europe-51294305', + remoteIdentifier: 'https://www.bbc.co.uk/news/world-europe-51294305', title: "Coronavirus: French Asians hit back at racism with 'I'm not a virus'", body: 'The coronavirus outbreak in Wuhan prompts French Asians to complain of a backlash against them.', author: null, - publication_date: '2020-01-29T18:27:56Z', + publicationDate: '2020-01-29T18:27:56Z', url: 'https://www.bbc.co.uk/news/world-europe-51294305', rule: 4, read: false, @@ -174,61 +174,61 @@ describe('post actions', () => { const posts = { 2067: { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 5, read: false, }, 2141: { id: 2141, - remote_identifier: 'https://arstechnica.com/?p=1648757', + remoteIdentifier: 'https://arstechnica.com/?p=1648757', title: 'The most complete brain map ever is here: A fly’s “connectome”', body: 'It took 12 years and at least $40 million to chart a region about 250µm across.', author: 'WIRED', - publication_date: '2020-01-25T11:06:46Z', + publicationDate: '2020-01-25T11:06:46Z', url: 'https://arstechnica.com/?p=1648757', rule: 5, read: false, }, 4637: { id: 4637, - remote_identifier: 'https://www.bbc.co.uk/news/world-asia-china-51299195', + remoteIdentifier: 'https://www.bbc.co.uk/news/world-asia-china-51299195', title: "Coronavirus: Whole world 'must take action', warns WHO", body: 'The World Health Organization will hold a further emergency meeting on the coronavirus on Thursday.', author: null, - publication_date: '2020-01-29T19:08:25Z', + publicationDate: '2020-01-29T19:08:25Z', url: 'https://www.bbc.co.uk/news/world-asia-china-51299195', rule: 4, read: false, }, 4638: { id: 4638, - remote_identifier: 'https://www.bbc.co.uk/news/world-europe-51294305', + remoteIdentifier: 'https://www.bbc.co.uk/news/world-europe-51294305', title: "Coronavirus: French Asians hit back at racism with 'I'm not a virus'", body: 'The coronavirus outbreak in Wuhan prompts French Asians to complain of a backlash against them.', author: null, - publication_date: '2020-01-29T18:27:56Z', + publicationDate: '2020-01-29T18:27:56Z', url: 'https://www.bbc.co.uk/news/world-europe-51294305', rule: 4, read: false, }, 4589: { id: 4589, - remote_identifier: 'https://tweakers.net/nieuws/162878', + remoteIdentifier: 'https://tweakers.net/nieuws/162878', title: 'Analyse: Nintendo verdiende miljard dollar aan mobiele games', body: 'Nintendo heeft tot nu toe een miljard dollar verdiend aan mobiele games, zo heeft SensorTower becijferd. Daarbij gaat het om inkomsten uit de App Store van Apple en Play Store van Google. De game die het meeste opbracht is Fire Emblem Heroes.', author: 'Arnoud Wokke', - publication_date: '2020-01-29T19:03:01Z', + publicationDate: '2020-01-29T19:03:01Z', url: 'https://tweakers.net/nieuws/162878/analyse-nintendo-verdiende-miljard-dollar-aan-mobiele-games.html', rule: 7, @@ -236,12 +236,12 @@ describe('post actions', () => { }, 4594: { id: 4594, - remote_identifier: 'https://tweakers.net/nieuws/162870', + remoteIdentifier: 'https://tweakers.net/nieuws/162870', title: 'Samsung kondigt eerste tablet met 5g aan', body: 'Samsung heef zijn eerste tablet met 5g aangekondigd. Het gaat om een variant op de al bestaande Galaxy Tab S6, maar dan voorzien van Qualcomm X50-modem. Er gingen al maanden geruchten over de release van de tablet.', author: 'Arnoud Wokke', - publication_date: '2020-01-29T16:29:40Z', + publicationDate: '2020-01-29T16:29:40Z', url: 'https://tweakers.net/nieuws/162870/samsung-kondigt-eerste-tablet-met-5g-aan.html', rule: 7, diff --git a/src/newsreader/js/tests/homepage/reducers/rule.test.js b/src/newsreader/js/tests/homepage/reducers/rule.test.js index 0332a51..67e1f4c 100644 --- a/src/newsreader/js/tests/homepage/reducers/rule.test.js +++ b/src/newsreader/js/tests/homepage/reducers/rule.test.js @@ -87,12 +87,12 @@ describe('category reducer', () => { const post = { id: 2182, - remote_identifier: 'https://arstechnica.com/?p=1648871', + remoteIdentifier: 'https://arstechnica.com/?p=1648871', title: 'Tesla needs to fix Autopilot safety flaws, demands Senator Markey', body: 'It should be renamed and fitted with a real driver-monitoring system, he says.', author: 'Jonathan M. Gitlin', - publication_date: '2020-01-25T18:34:20Z', + publicationDate: '2020-01-25T18:34:20Z', url: 'https://arstechnica.com/?p=1648871', rule: 1, read: false, diff --git a/src/newsreader/js/tests/homepage/reducers/selected.test.js b/src/newsreader/js/tests/homepage/reducers/selected.test.js index 365143a..22a5e7e 100644 --- a/src/newsreader/js/tests/homepage/reducers/selected.test.js +++ b/src/newsreader/js/tests/homepage/reducers/selected.test.js @@ -214,25 +214,25 @@ describe('selected reducer', () => { const posts = { 2067: { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 4, read: false, }, 2141: { id: 2141, - remote_identifier: 'https://arstechnica.com/?p=1648757', + remoteIdentifier: 'https://arstechnica.com/?p=1648757', title: 'The most complete brain map ever is here: A fly’s “connectome”', body: 'It took 12 years and at least $40 million to chart a region about 250µm across.', author: 'WIRED', - publication_date: '2020-01-25T11:06:46Z', + publicationDate: '2020-01-25T11:06:46Z', url: 'https://arstechnica.com/?p=1648757', rule: 4, read: false, @@ -257,13 +257,13 @@ describe('selected reducer', () => { it('should return state after receiving a post', () => { const post = { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 4, read: false, @@ -283,13 +283,13 @@ describe('selected reducer', () => { it('should return state after selecting a post', () => { const post = { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 4, read: false, @@ -308,13 +308,13 @@ describe('selected reducer', () => { it('should return state after unselecting a post', () => { const post = { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 4, read: false, @@ -334,13 +334,13 @@ describe('selected reducer', () => { it('should return state after marking a post read', () => { const post = { id: 2067, - remote_identifier: 'https://arstechnica.com/?p=1648607', + remoteIdentifier: 'https://arstechnica.com/?p=1648607', title: 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', body: '"Stale-reference manipulation," 300-character file names, and a clash between worlds.', author: 'Kyle Orland', - publication_date: '2020-01-24T19:50:12Z', + publicationDate: '2020-01-24T19:50:12Z', url: 'https://arstechnica.com/?p=1648607', rule: 4, read: false, diff --git a/src/newsreader/news/core/serializers.py b/src/newsreader/news/core/serializers.py index 791d873..e18070f 100644 --- a/src/newsreader/news/core/serializers.py +++ b/src/newsreader/news/core/serializers.py @@ -5,18 +5,21 @@ from newsreader.news.core.models import Category, Post class PostSerializer(serializers.ModelSerializer): + publicationDate = serializers.DateTimeField(source="publication_date", required=False) + remoteIdentifier = serializers.CharField(source="remote_identifier", required=False) + class Meta: model = Post fields = ( "id", - "remote_identifier", "title", "body", "author", - "publication_date", "url", "rule", "read", + "publicationDate", + "remoteIdentifier", ) diff --git a/src/newsreader/news/core/tests/endpoints/post/detail/tests.py b/src/newsreader/news/core/tests/endpoints/post/detail/tests.py index acc4bd1..bc184a3 100644 --- a/src/newsreader/news/core/tests/endpoints/post/detail/tests.py +++ b/src/newsreader/news/core/tests/endpoints/post/detail/tests.py @@ -28,10 +28,10 @@ class PostDetailViewTestCase(TestCase): self.assertTrue("title" in data) self.assertTrue("body" in data) self.assertTrue("author" in data) - self.assertTrue("publication_date" in data) + self.assertTrue("publicationDate" in data) self.assertTrue("url" in data) self.assertTrue("rule" in data) - self.assertTrue("remote_identifier" in data) + self.assertTrue("remoteIdentifier" in data) def test_not_known(self): response = self.client.get(reverse("api:posts-detail", args=[100]))