-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from brunoamaral/add-rss-feeds
Add rss feeds via Django
- Loading branch information
Showing
9 changed files
with
112 additions
and
13 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class RssConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'rss' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from django.shortcuts import render | ||
|
||
# Create your views here. | ||
from django.contrib.syndication.views import Feed | ||
from django.urls import reverse | ||
from gregory.models import Articles, Trials | ||
|
||
class LatestArticlesFeed(Feed): | ||
title = "Gregory MS - latest research articles" | ||
link = "/articles/" | ||
description = "Real time results for research on Multiple Sclerosis." | ||
|
||
def items(self): | ||
return Articles.objects.order_by('-discovery_date')[:5] | ||
|
||
def item_title(self, item): | ||
return item.title | ||
|
||
def item_description(self, item): | ||
return item.summary | ||
|
||
# # item_link is only needed if NewsItem has no get_absolute_url method. | ||
def item_link(self, item): | ||
return 'https://gregory-ms.com/articles/' + str(item.pk) + '/' | ||
|
||
class LatestTrialsFeed(Feed): | ||
title = "Gregory MS - latest clinical trials" | ||
link = "/trials/" | ||
description = "Real time results for research on Multiple Sclerosis." | ||
|
||
def items(self): | ||
return Trials.objects.order_by('-discovery_date')[:5] | ||
|
||
def item_title(self, item): | ||
return item.title | ||
|
||
def item_description(self, item): | ||
return item.summary | ||
|
||
# # item_link is only needed if NewsItem has no get_absolute_url method. | ||
def item_link(self, item): | ||
return 'https://gregory-ms.com/trials/' + str(item.pk) + '/' | ||
|
||
class MachineLearningFeed(Feed): | ||
title = "Gregory MS - Relevant articles by machine learning" | ||
link = "/articles/" | ||
description = "Real time results for research on Multiple Sclerosis." | ||
|
||
def items(self): | ||
return Articles.objects.filter(ml_prediction_gnb=True)[:20] | ||
|
||
def item_title(self, item): | ||
return item.title | ||
|
||
def item_description(self, item): | ||
return item.summary | ||
|
||
# # item_link is only needed if NewsItem has no get_absolute_url method. | ||
def item_link(self, item): | ||
return 'https://gregory-ms.com/articles/' + str(item.pk) + '/' | ||
|
||
class ToPredictFeed(Feed): | ||
title = "Gregory MS - Relevant articles by machine learning" | ||
link = "/articles/" | ||
description = "Real time results for research on Multiple Sclerosis." | ||
|
||
def items(self): | ||
return Articles.objects.filter(ml_prediction_gnb=None)[:20] | ||
|
||
def item_title(self, item): | ||
return item.title | ||
|
||
def item_description(self, item): | ||
return item.summary | ||
|
||
# # item_link is only needed if NewsItem has no get_absolute_url method. | ||
def item_link(self, item): | ||
return 'https://gregory-ms.com/articles/' + str(item.pk) + '/' |