#pgFrontNewsEventsContainer h3 img {
margin-bottom: 10px;
}
+
+/*
+ * News items tag list
+ */
+span.newstag {
+ background-color: #336791;
+ color: white;
+ padding: 4px;
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 6px;
+}
+
+span.newstag a {
+ color: white;
+ text-decoration: none;
+}
from pgweb.util.sitestruct import get_all_pages_struct
# models needed for the pieces on the frontpage
-from pgweb.news.models import NewsArticle
+from pgweb.news.models import NewsArticle, NewsTag
from pgweb.events.models import Event
from pgweb.quotes.models import Quote
from models import Version, ImportedRSSItem
return render_to_response('index.html', {
'title': 'The world\'s most advanced open source database',
'news': news,
+ 'newstags': NewsTag.objects.all(),
'community_events': community_events,
'other_events': other_events,
'traininginfo': traininginfo,
from django.contrib import admin
from pgweb.util.admin import PgwebAdmin
-from models import NewsArticle
+from models import NewsArticle, NewsTag
class NewsArticleAdmin(PgwebAdmin):
list_display = ('title', 'org', 'date', 'approved', )
list_filter = ('approved', )
+ filter_horizontal = ('tags', )
search_fields = ('content', 'title', )
change_form_template = 'admin/news/newsarticle/change_form.html'
return super(NewsArticleAdmin, self).change_view(request, object_id, extra_context=my_context)
admin.site.register(NewsArticle, NewsArticleAdmin)
+admin.site.register(NewsTag)
description_template = 'news/rss_description.html'
title_template = 'news/rss_title.html'
- def items(self):
- return NewsArticle.objects.filter(approved=True)[:10]
+ def get_object(self, request, tagurl=None):
+ return tagurl
+
+ def items(self, obj):
+ if obj:
+ return NewsArticle.objects.filter(approved=True, tags__urlname=obj)[:10]
+ else:
+ return NewsArticle.objects.filter(approved=True)[:10]
def item_link(self, obj):
return "https://www.postgresql.org/about/news/%s/" % obj.id
from django.forms import ValidationError
from pgweb.core.models import Organisation
-from models import NewsArticle
+from models import NewsArticle, NewsTag
class NewsArticleForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
raise ValidationError("You cannot change the date on an article that has been approved")
return self.cleaned_data['date']
+ @property
+ def described_checkboxes(self):
+ return {
+ 'tags': [(t.id, t.description) for t in NewsTag.objects.all()]
+ }
+
class Meta:
model = NewsArticle
exclude = ('submitter', 'approved', 'tweeted')
+ widgets = {
+ 'tags': forms.CheckboxSelectMultiple,
+ }
--- /dev/null
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('news', '0002_news_tweet'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='NewsTag',
+ fields=[
+ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+ ('urlname', models.CharField(unique=True, max_length=20)),
+ ('name', models.CharField(max_length=32)),
+ ('description', models.CharField(max_length=200)),
+ ],
+ ),
+ migrations.AlterField(
+ model_name='newsarticle',
+ name='tweeted',
+ field=models.BooleanField(default=False),
+ ),
+ migrations.AddField(
+ model_name='newsarticle',
+ name='tags',
+ field=models.ManyToManyField(help_text=b'Hover mouse over tags to view full description', to='news.NewsTag'),
+ ),
+ ]
from datetime import date
from pgweb.core.models import Organisation
+class NewsTag(models.Model):
+ urlname = models.CharField(max_length=20, null=False, blank=False, unique=True)
+ name = models.CharField(max_length=32, null=False, blank=False)
+ description = models.CharField(max_length=200, null=False, blank=False)
+
+ def __unicode__(self):
+ return self.name
+
class NewsArticle(models.Model):
org = models.ForeignKey(Organisation, null=False, blank=False, verbose_name="Organisation", help_text="If no organisations are listed, please check the <a href=\"/account/orglist/\">organisation list</a> and contact the organisation manager or webmaster@postgresql.org if none are listed.")
approved = models.BooleanField(null=False, blank=False, default=False)
title = models.CharField(max_length=200, null=False, blank=False)
content = models.TextField(null=False, blank=False)
tweeted = models.BooleanField(null=False, blank=False, default=False)
+ tags = models.ManyToManyField(NewsTag, blank=False, help_text="Hover mouse over tags to view full description")
send_notification = True
+ send_m2m_notification = True
markdown_fields = ('content',)
def purge_urls(self):
yield '/about/news/%s/' % self.pk
yield '/about/newsarchive/'
yield '/news.rss'
+ yield '/news/.*.rss'
# FIXME: when to expire the front page?
yield '/$'
from pgweb.util.contexts import NavContext
from pgweb.util.helpers import simple_form
-from models import NewsArticle
+from models import NewsArticle, NewsTag
from forms import NewsArticleForm
-def archive(request, paging=None):
- news = NewsArticle.objects.filter(approved=True)
+def archive(request, tag=None, paging=None):
+ if tag:
+ tag = get_object_or_404(NewsTag,urlname=tag.strip('/'))
+ news = NewsArticle.objects.filter(approved=True, tags=tag)
+ else:
+ tag = None
+ news = NewsArticle.objects.filter(approved=True)
return render_to_response('news/newsarchive.html', {
'news': news,
+ 'tag': tag,
+ 'newstags': NewsTag.objects.all(),
}, NavContext(request, 'about'))
def item(request, itemid, throwaway=None):
raise Http404
return render_to_response('news/item.html', {
'obj': news,
+ 'newstags': NewsTag.objects.all(),
}, NavContext(request, 'about'))
@login_required
(r'^$', 'pgweb.core.views.home'),
(r'^dyncss/(?P<css>base|docs).css$', 'pgweb.core.views.dynamic_css'),
- (r'^about/newsarchive/$', 'pgweb.news.views.archive'),
+ (r'^about/newsarchive/([^/]+/)?$', 'pgweb.news.views.archive'),
(r'^about/news/(\d+)(-.*)?/$', 'pgweb.news.views.item'),
(r'^about/events/$', 'pgweb.events.views.main'),
(r'^about/eventarchive/$', 'pgweb.events.views.archive'),
# RSS feeds
###
(r'^versions.rss$', VersionFeed()),
- (r'^news.rss$', NewsFeed()),
+ (r'^news(/(?P<tagurl>[^/]+))?.rss$', NewsFeed()),
(r'^events.rss$', EventFeed()),
###
<meta name="copyright" content="The PostgreSQL Global Development Group" />
<style type="text/css" media="screen" title="Normal Text">@import url("/dyncss/base.css?{{gitrev}}");</style>
<link rel="shortcut icon" href="/favicon.ico" />
- <link rel="alternate" type="application/rss+xml" title="PostgreSQL News" href="{{link_root}}/news.rss" />
+{%if newstags %}
+{%comment%}Default RSS links are only shown on pages that have newstags set{%endcomment%}
+ <link rel="alternate" type="application/rss+xml" title="All PostgreSQL News" href="{{link_root}}/news.rss" />
+{%for t in newstags%}
+ <link rel="alternate" type="application/rss+xml" title="PostgreSQL News about {{t.name}}" href="{{link_root}}/news/{{t.urlname}}.rss" />
+{%endfor%}
<link rel="alternate" type="application/rss+xml" title="PostgreSQL Events" href="{{link_root}}/events.rss" />
+{%endif%}
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1345454-1']);
<p><i>This post has been migrated from a previous version of the PostgreSQL
website. We apologise for any formatting issues caused by the migration.</i></p>
{%endif%}
+{%for t in obj.tags.all%}
+<span class="newstag"><a href="/about/newsarchive/{{t.urlname}}/">{{t.name}}</a></span>
+{%endfor%}
{%endblock%}
{%extends "base/page.html"%}
{%load markup%}
-{%block title%}News archive{%endblock%}
+{%block title%}News archive{%if tag%} - {{tag.name}}{%endif%}{%endblock%}
{%block contents%}
-<h1>News archive</h1>
+<h1>News archive{%if tag%} - {{tag.name}}{%endif%}</h1>
+
+<p>
+{%for t in newstags%}<span class="newstag"><a href="/about/newsarchive/{{t.urlname}}/">{{t.name}}</a></span> {%endfor%}
+</p>
+
{%for obj in news %}
<h2><a href="/about/news/{{obj.id}}/">{{obj.title}}</a></h2>
<div class="newsdate">Posted on <b>{{obj.displaydate}}</b></div>