Commit 5be82bc9 authored by Chris Lamb's avatar Chris Lamb
Browse files

Add an RSS feed for all live jobs. (Closes: #36)

parent 15aba8af
from django.contrib.syndication.views import Feed
from .models import Job
class AllJobs(Feed):
link = '/'
title = "Freenode Jobs"
title_template = 'jobs/feed/title.html'
description_template = 'jobs/feed/description.html'
def items(self):
return Job.objects.live()
def item_pubdate(self, obj):
return obj.updated
......@@ -57,3 +57,8 @@ class JobTest(TestCase):
self.job.set_state(StateEnum.REMOVED, self.user, "")
self.job.save()
self.assertStatusCode(404, self.client.get, self.job)
class FeedTest(TestCase):
def test_view(self):
self.assertGET(200, 'jobs:feed')
from django.urls import path, re_path, include
from . import views
from . import feeds, views
from .enums import JobTypeEnum
app_name = 'jobs'
......@@ -24,4 +24,7 @@ urlpatterns = [
name='view'),
re_path(r'^job/(?P<slug>[a-z]{8})$', views.job,
name='view'),
path('feed', feeds.AllJobs(),
name='feed'),
]
......@@ -14,6 +14,8 @@
<link rel="icon" href="{% static "img/f_generic_base/favicon.png" %}" type="image/x-icon">
<link rel="shortcut icon" href="{% static "img/f_generic_base/favicon.png" %}" type="image/x-icon">
<link rel="alternate" type="application/rss+xml" title="Freenode Jobs" href="{% url "jobs:feed" %}"/>
<!--[if lt IE 9]>
<script src="//oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="//oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
......
......@@ -23,6 +23,9 @@
<li>
<a href="https://twitter.com/freenodestaff"><i class="fa fa-twitter"></i></a>
</li>
<li>
<a href="{% url "jobs:feed" %}"><i class="fa fa-rss"></i></a>
</li>
</ul>
</div>
</div>
......
<h1>{{ obj.title }} ({{ obj.job_type }})</h1>
<p>
<a href="{{ obj.user.profile.url }}">
<img src="{{ obj.user.profile.image.resized.url }}" alt="{{ obj.user.profile.name }}">
</a>
</p>
<p>
<a href="{{ obj.user.profile.url }}">
<strong>{{ obj.user.profile.name }}</strong>
</a>
</p>
<p>
Location: <em>{{ obj.location }}</em>
</p>
{% if job.tags.exists %}
<p>
Tags: <em>{% for x in job.tags.all %}{{ x.title }}{% endfor %}</em>
</p>
{% endif %}
{{ obj.description|markdown }}
<p>
<a href="{{ obj.apply_url }}">Apply</a>
</p>
{{ obj.title }} ({{ obj.job_type|lower }}) &mdash; {{ obj.user.profile.name }}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment