mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-06 09:57:57 +00:00

This allows all models inherited from PgModel to specify which URLs to purge by either setting a field or defining a function called purge_urls, at which point they will be purged whenever the save signal is fired. Also implements a form under /admin/purge/ that allows for manual purging. This should probably be extended in the future to show the status of the pgq slaves, but that will come later. Includes a SQL function that posts the expires to a pgq queue. For a local deployment, this can be replaced with a simple void function to turn off varnish purging.
32 lines
758 B
Python
32 lines
758 B
Python
from django.db import models
|
|
|
|
from pgweb.util.bases import PgModel
|
|
|
|
from datetime import date
|
|
|
|
class PwnPost(PgModel, models.Model):
|
|
date = models.DateField(null=False, blank=False, default=date.today, unique=True)
|
|
intro = models.TextField(null=False, blank=False)
|
|
content = models.TextField(null=False, blank=False)
|
|
|
|
markdown_fields = ('intro', 'content',)
|
|
|
|
def purge_urls(self):
|
|
yield 'community/weeklynews/$'
|
|
yield 'community/weeklynews/pwn%s/' % self.linkdate()
|
|
yield 'weeklynews.rss'
|
|
|
|
def __unicode__(self):
|
|
return "PostgreSQL Weekly News %s" % self.date
|
|
|
|
@property
|
|
def linkdate(self):
|
|
return self.date.strftime("%Y%m%d")
|
|
|
|
@property
|
|
def nicedate(self):
|
|
return self.date.strftime("%B %d, %Y")
|
|
|
|
class Meta:
|
|
ordering = ('-date',)
|