Update post serializer fields

This commit is contained in:
Sonny 2020-01-31 21:29:11 +01:00
parent c3b087e004
commit e1e6571bb0
11 changed files with 71 additions and 68 deletions

View file

@ -8,7 +8,7 @@ django-celery-beat==1.5.0
djangorestframework==3.9.4 djangorestframework==3.9.4
django-rest-swagger==2.2.0 django-rest-swagger==2.2.0
django-registration-redux==2.6 django-registration-redux==2.6
lxml==4.3.4 lxml==4.4.2
feedparser==5.2.1 feedparser==5.2.1
idna==2.8 idna==2.8
pytz==2018.9 pytz==2018.9

View file

@ -28,7 +28,7 @@ class PostModal extends React.Component {
render() { render() {
const post = this.props.post; 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'; const titleClassName = post.read ? 'post__title post__title--read' : 'post__title';
return ( return (

View file

@ -8,7 +8,7 @@ import { formatDatetime } from '../../../../utils.js';
class PostItem extends React.Component { class PostItem extends React.Component {
render() { render() {
const post = this.props.post; const post = this.props.post;
const publicationDate = formatDatetime(post.publication_date); const publicationDate = formatDatetime(post.publicationDate);
const titleClassName = post.read const titleClassName = post.read
? 'posts-header__title posts-header__title--read' ? 'posts-header__title posts-header__title--read'
: 'posts-header__title'; : 'posts-header__title';

View file

@ -5,7 +5,7 @@ import PostItem from './PostItem.js';
class RuleItem extends React.Component { class RuleItem extends React.Component {
render() { render() {
const posts = Object.values(this.props.posts).sort((firstEl, secondEl) => { 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 => { const postItems = posts.map(post => {

View file

@ -22,13 +22,13 @@ describe('rule actions', () => {
it('should create an action receive a post', () => { it('should create an action receive a post', () => {
const post = { const post = {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 5, rule: 5,
read: false, read: false,
@ -45,13 +45,13 @@ describe('rule actions', () => {
it('should create an action to select a post', () => { it('should create an action to select a post', () => {
const post = { const post = {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 5, rule: 5,
read: false, read: false,
@ -74,13 +74,13 @@ describe('rule actions', () => {
it('should create an action mark a post read', () => { it('should create an action mark a post read', () => {
const post = { const post = {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 5, rule: 5,
read: false, read: false,
@ -107,13 +107,13 @@ describe('rule actions', () => {
it('should create multiple actions to mark post read', () => { it('should create multiple actions to mark post read', () => {
const post = { const post = {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 5, rule: 5,
read: false, read: false,
@ -166,25 +166,25 @@ describe('rule actions', () => {
const posts = { const posts = {
2067: { 2067: {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 4, rule: 4,
read: false, read: false,
}, },
2141: { 2141: {
id: 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 flys “connectome”', title: 'The most complete brain map ever is here: A flys “connectome”',
body: body:
'It took 12 years and at least $40 million to chart a region about 250µm across.', 'It took 12 years and at least $40 million to chart a region about 250µm across.',
author: 'WIRED', author: 'WIRED',
publication_date: '2020-01-25T11:06:46Z', publicationDate: '2020-01-25T11:06:46Z',
url: 'https://arstechnica.com/?p=1648757', url: 'https://arstechnica.com/?p=1648757',
rule: 4, rule: 4,
read: false, read: false,
@ -236,25 +236,25 @@ describe('rule actions', () => {
const posts = { const posts = {
2067: { 2067: {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 4, rule: 4,
read: false, read: false,
}, },
2141: { 2141: {
id: 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 flys “connectome”', title: 'The most complete brain map ever is here: A flys “connectome”',
body: body:
'It took 12 years and at least $40 million to chart a region about 250µm across.', 'It took 12 years and at least $40 million to chart a region about 250µm across.',
author: 'WIRED', author: 'WIRED',
publication_date: '2020-01-25T11:06:46Z', publicationDate: '2020-01-25T11:06:46Z',
url: 'https://arstechnica.com/?p=1648757', url: 'https://arstechnica.com/?p=1648757',
rule: 4, rule: 4,
read: false, read: false,

View file

@ -67,12 +67,12 @@ describe('category reducer', () => {
const post = { const post = {
id: 2091, 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', title: 'China coronavirus spread is accelerating, Xi Jinping warns',
body: body:
'China\'s president tells a high-level meeting that the country faces a "grave situation".', 'China\'s president tells a high-level meeting that the country faces a "grave situation".',
author: null, 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', url: 'https://www.bbc.co.uk/news/world-asia-china-51249208',
rule: 4, rule: 4,
read: false, read: false,
@ -117,12 +117,12 @@ describe('category reducer', () => {
const post = { const post = {
id: 2182, 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', title: 'Tesla needs to fix Autopilot safety flaws, demands Senator Markey',
body: body:
'It should be renamed and fitted with a real driver-monitoring system, he says.', 'It should be renamed and fitted with a real driver-monitoring system, he says.',
author: 'Jonathan M. Gitlin', author: 'Jonathan M. Gitlin',
publication_date: '2020-01-25T18:34:20Z', publicationDate: '2020-01-25T18:34:20Z',
url: 'https://arstechnica.com/?p=1648871', url: 'https://arstechnica.com/?p=1648871',
rule: 1, rule: 1,
read: false, read: false,

View file

@ -18,13 +18,13 @@ describe('post actions', () => {
it('should return state after receiving a post', () => { it('should return state after receiving a post', () => {
const post = { const post = {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 4, rule: 4,
read: false, read: false,
@ -48,25 +48,25 @@ describe('post actions', () => {
const posts = { const posts = {
2067: { 2067: {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 4, rule: 4,
read: false, read: false,
}, },
2141: { 2141: {
id: 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 flys “connectome”', title: 'The most complete brain map ever is here: A flys “connectome”',
body: body:
'It took 12 years and at least $40 million to chart a region about 250µm across.', 'It took 12 years and at least $40 million to chart a region about 250µm across.',
author: 'WIRED', author: 'WIRED',
publication_date: '2020-01-25T11:06:46Z', publicationDate: '2020-01-25T11:06:46Z',
url: 'https://arstechnica.com/?p=1648757', url: 'https://arstechnica.com/?p=1648757',
rule: 4, rule: 4,
read: false, read: false,
@ -92,49 +92,49 @@ describe('post actions', () => {
const posts = { const posts = {
2067: { 2067: {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 5, rule: 5,
read: false, read: false,
}, },
2141: { 2141: {
id: 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 flys “connectome”', title: 'The most complete brain map ever is here: A flys “connectome”',
body: body:
'It took 12 years and at least $40 million to chart a region about 250µm across.', 'It took 12 years and at least $40 million to chart a region about 250µm across.',
author: 'WIRED', author: 'WIRED',
publication_date: '2020-01-25T11:06:46Z', publicationDate: '2020-01-25T11:06:46Z',
url: 'https://arstechnica.com/?p=1648757', url: 'https://arstechnica.com/?p=1648757',
rule: 5, rule: 5,
read: false, read: false,
}, },
4637: { 4637: {
id: 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", title: "Coronavirus: Whole world 'must take action', warns WHO",
body: body:
'The World Health Organization will hold a further emergency meeting on the coronavirus on Thursday.', 'The World Health Organization will hold a further emergency meeting on the coronavirus on Thursday.',
author: null, 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', url: 'https://www.bbc.co.uk/news/world-asia-china-51299195',
rule: 4, rule: 4,
read: false, read: false,
}, },
4638: { 4638: {
id: 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'", title: "Coronavirus: French Asians hit back at racism with 'I'm not a virus'",
body: body:
'The coronavirus outbreak in Wuhan prompts French Asians to complain of a backlash against them.', 'The coronavirus outbreak in Wuhan prompts French Asians to complain of a backlash against them.',
author: null, 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', url: 'https://www.bbc.co.uk/news/world-europe-51294305',
rule: 4, rule: 4,
read: false, read: false,
@ -174,61 +174,61 @@ describe('post actions', () => {
const posts = { const posts = {
2067: { 2067: {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 5, rule: 5,
read: false, read: false,
}, },
2141: { 2141: {
id: 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 flys “connectome”', title: 'The most complete brain map ever is here: A flys “connectome”',
body: body:
'It took 12 years and at least $40 million to chart a region about 250µm across.', 'It took 12 years and at least $40 million to chart a region about 250µm across.',
author: 'WIRED', author: 'WIRED',
publication_date: '2020-01-25T11:06:46Z', publicationDate: '2020-01-25T11:06:46Z',
url: 'https://arstechnica.com/?p=1648757', url: 'https://arstechnica.com/?p=1648757',
rule: 5, rule: 5,
read: false, read: false,
}, },
4637: { 4637: {
id: 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", title: "Coronavirus: Whole world 'must take action', warns WHO",
body: body:
'The World Health Organization will hold a further emergency meeting on the coronavirus on Thursday.', 'The World Health Organization will hold a further emergency meeting on the coronavirus on Thursday.',
author: null, 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', url: 'https://www.bbc.co.uk/news/world-asia-china-51299195',
rule: 4, rule: 4,
read: false, read: false,
}, },
4638: { 4638: {
id: 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'", title: "Coronavirus: French Asians hit back at racism with 'I'm not a virus'",
body: body:
'The coronavirus outbreak in Wuhan prompts French Asians to complain of a backlash against them.', 'The coronavirus outbreak in Wuhan prompts French Asians to complain of a backlash against them.',
author: null, 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', url: 'https://www.bbc.co.uk/news/world-europe-51294305',
rule: 4, rule: 4,
read: false, read: false,
}, },
4589: { 4589: {
id: 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', title: 'Analyse: Nintendo verdiende miljard dollar aan mobiele games',
body: 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.<img alt="" src="http://feeds.feedburner.com/~r/tweakers/mixed/~4/Yn_we8WaUeA">', '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.<img alt="" src="http://feeds.feedburner.com/~r/tweakers/mixed/~4/Yn_we8WaUeA">',
author: 'Arnoud Wokke', author: 'Arnoud Wokke',
publication_date: '2020-01-29T19:03:01Z', publicationDate: '2020-01-29T19:03:01Z',
url: url:
'https://tweakers.net/nieuws/162878/analyse-nintendo-verdiende-miljard-dollar-aan-mobiele-games.html', 'https://tweakers.net/nieuws/162878/analyse-nintendo-verdiende-miljard-dollar-aan-mobiele-games.html',
rule: 7, rule: 7,
@ -236,12 +236,12 @@ describe('post actions', () => {
}, },
4594: { 4594: {
id: 4594, id: 4594,
remote_identifier: 'https://tweakers.net/nieuws/162870', remoteIdentifier: 'https://tweakers.net/nieuws/162870',
title: 'Samsung kondigt eerste tablet met 5g aan', title: 'Samsung kondigt eerste tablet met 5g aan',
body: 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.<img alt="" src="http://feeds.feedburner.com/~r/tweakers/mixed/~4/IfEYe00sm3U">', '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.<img alt="" src="http://feeds.feedburner.com/~r/tweakers/mixed/~4/IfEYe00sm3U">',
author: 'Arnoud Wokke', author: 'Arnoud Wokke',
publication_date: '2020-01-29T16:29:40Z', publicationDate: '2020-01-29T16:29:40Z',
url: url:
'https://tweakers.net/nieuws/162870/samsung-kondigt-eerste-tablet-met-5g-aan.html', 'https://tweakers.net/nieuws/162870/samsung-kondigt-eerste-tablet-met-5g-aan.html',
rule: 7, rule: 7,

View file

@ -87,12 +87,12 @@ describe('category reducer', () => {
const post = { const post = {
id: 2182, 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', title: 'Tesla needs to fix Autopilot safety flaws, demands Senator Markey',
body: body:
'It should be renamed and fitted with a real driver-monitoring system, he says.', 'It should be renamed and fitted with a real driver-monitoring system, he says.',
author: 'Jonathan M. Gitlin', author: 'Jonathan M. Gitlin',
publication_date: '2020-01-25T18:34:20Z', publicationDate: '2020-01-25T18:34:20Z',
url: 'https://arstechnica.com/?p=1648871', url: 'https://arstechnica.com/?p=1648871',
rule: 1, rule: 1,
read: false, read: false,

View file

@ -214,25 +214,25 @@ describe('selected reducer', () => {
const posts = { const posts = {
2067: { 2067: {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 4, rule: 4,
read: false, read: false,
}, },
2141: { 2141: {
id: 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 flys “connectome”', title: 'The most complete brain map ever is here: A flys “connectome”',
body: body:
'It took 12 years and at least $40 million to chart a region about 250µm across.', 'It took 12 years and at least $40 million to chart a region about 250µm across.',
author: 'WIRED', author: 'WIRED',
publication_date: '2020-01-25T11:06:46Z', publicationDate: '2020-01-25T11:06:46Z',
url: 'https://arstechnica.com/?p=1648757', url: 'https://arstechnica.com/?p=1648757',
rule: 4, rule: 4,
read: false, read: false,
@ -257,13 +257,13 @@ describe('selected reducer', () => {
it('should return state after receiving a post', () => { it('should return state after receiving a post', () => {
const post = { const post = {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 4, rule: 4,
read: false, read: false,
@ -283,13 +283,13 @@ describe('selected reducer', () => {
it('should return state after selecting a post', () => { it('should return state after selecting a post', () => {
const post = { const post = {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 4, rule: 4,
read: false, read: false,
@ -308,13 +308,13 @@ describe('selected reducer', () => {
it('should return state after unselecting a post', () => { it('should return state after unselecting a post', () => {
const post = { const post = {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 4, rule: 4,
read: false, read: false,
@ -334,13 +334,13 @@ describe('selected reducer', () => {
it('should return state after marking a post read', () => { it('should return state after marking a post read', () => {
const post = { const post = {
id: 2067, id: 2067,
remote_identifier: 'https://arstechnica.com/?p=1648607', remoteIdentifier: 'https://arstechnica.com/?p=1648607',
title: title:
'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge', 'This amazing glitch puts Star Fox 64 ships in an unmodified Zelda cartridge',
body: body:
'"Stale-reference manipulation," 300-character file names, and a clash between worlds.', '"Stale-reference manipulation," 300-character file names, and a clash between worlds.',
author: 'Kyle Orland', author: 'Kyle Orland',
publication_date: '2020-01-24T19:50:12Z', publicationDate: '2020-01-24T19:50:12Z',
url: 'https://arstechnica.com/?p=1648607', url: 'https://arstechnica.com/?p=1648607',
rule: 4, rule: 4,
read: false, read: false,

View file

@ -5,18 +5,21 @@ from newsreader.news.core.models import Category, Post
class PostSerializer(serializers.ModelSerializer): class PostSerializer(serializers.ModelSerializer):
publicationDate = serializers.DateTimeField(source="publication_date", required=False)
remoteIdentifier = serializers.CharField(source="remote_identifier", required=False)
class Meta: class Meta:
model = Post model = Post
fields = ( fields = (
"id", "id",
"remote_identifier",
"title", "title",
"body", "body",
"author", "author",
"publication_date",
"url", "url",
"rule", "rule",
"read", "read",
"publicationDate",
"remoteIdentifier",
) )

View file

@ -28,10 +28,10 @@ class PostDetailViewTestCase(TestCase):
self.assertTrue("title" in data) self.assertTrue("title" in data)
self.assertTrue("body" in data) self.assertTrue("body" in data)
self.assertTrue("author" 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("url" in data)
self.assertTrue("rule" in data) self.assertTrue("rule" in data)
self.assertTrue("remote_identifier" in data) self.assertTrue("remoteIdentifier" in data)
def test_not_known(self): def test_not_known(self):
response = self.client.get(reverse("api:posts-detail", args=[100])) response = self.client.get(reverse("api:posts-detail", args=[100]))