From 9b5e129c369b7c134c466e7411a7c2d69cfd4902 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Mon, 4 Apr 2016 21:46:55 +0200 Subject: [PATCH] Add first RSS feed for latest comments --- scipost/feeds.py | 27 +++++++++++++++++++ .../scipost/registration_invitations.html | 4 +-- scipost/urls.py | 4 +++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 scipost/feeds.py diff --git a/scipost/feeds.py b/scipost/feeds.py new file mode 100644 index 000000000..fc905841d --- /dev/null +++ b/scipost/feeds.py @@ -0,0 +1,27 @@ +from django.contrib.syndication.views import Feed +from django.core.urlresolvers import reverse + +from comments.models import Comment + +class LatestCommentFeed(Feed): + title = "SciPost Latest Comments" + link = "/" + + def items(self): + return Comment.objects.filter(status__gte=0).order_by('-date_submitted')[:5] + + def item_title(self, item): + return item.comment_text[:50] + +# def item_description(self, item): +# return item.description + + def item_link(self, item): + if item.commentary: + return reverse('commentaries:commentary', kwargs={'arxiv_or_DOI_string': item.commentary.arxiv_or_DOI_string}) + elif item.submission: + return reverse('submissions:submission', kwargs={'submission_id': item.submission.id}) + elif item.thesislink: + return reverse('theses:thesis', kwargs={'thesislink_id': item.thesislink.id}) + else: + return reverse('scipost:index') diff --git a/scipost/templates/scipost/registration_invitations.html b/scipost/templates/scipost/registration_invitations.html index b3ba15a6f..464a4f553 100644 --- a/scipost/templates/scipost/registration_invitations.html +++ b/scipost/templates/scipost/registration_invitations.html @@ -26,7 +26,7 @@ <hr class="hr12"/> <section> <div class="flex-greybox"> - <h2>Invitations sent (response pending):</h2> + <h2>Invitations sent (response pending) EF ({{ nr_sent_reg_inv_fellows }}), C ({{ nr_sent_reg_inv_contrib }}):</h2> </div> <hr class="hr6"/> <h3>Editorial Fellows ({{ nr_sent_reg_inv_fellows }})</h3> @@ -62,7 +62,7 @@ <hr class="hr12"/> <section> <div class="flex-greybox"> - <h2>Invitations sent (responded):</h2> + <h2>Invitations sent (responded) EF ({{ nr_resp_reg_inv_fellows }}), C ({{ nr_resp_reg_inv_contrib }}):</h2> </div> <hr class="hr6"/> <h3>Editorial Fellows ({{ nr_resp_reg_inv_fellows }})</h3> diff --git a/scipost/urls.py b/scipost/urls.py index cb7294f37..adcc02176 100644 --- a/scipost/urls.py +++ b/scipost/urls.py @@ -2,6 +2,7 @@ from django.conf.urls import include, patterns, url from django.views.generic import TemplateView from . import views +from .feeds import LatestCommentFeed urlpatterns = [ url(r'^$', views.index, name='index'), @@ -56,4 +57,7 @@ urlpatterns = [ url(r'^claim_thesis_authorship/(?P<thesis_id>[0-9]+)/(?P<claim>[0-1])$', views.claim_thesis_authorship, name='claim_thesis_authorship'), url(r'^vet_authorship_claims$', views.vet_authorship_claims, name="vet_authorship_claims"), url(r'^vet_authorship_claim/(?P<claim_id>[0-9]+)/(?P<claim>[0-1])$', views.vet_authorship_claim, name='vet_authorship_claim'), + + # Feeds + url(r'^latest_comment/feed/$', LatestCommentFeed()), ] -- GitLab