mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-13 13:12:42 +00:00
Implement basic varnish purging
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.
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
from django.db import models
|
||||
|
||||
from pgweb.util.bases import PgModel
|
||||
|
||||
choices_map = {
|
||||
0: {'str': 'No', 'class': 'no', 'bgcolor': '#ffdddd'},
|
||||
1: {'str': 'Yes', 'class': 'yes', 'bgcolor': '#ddffdd'},
|
||||
@ -8,10 +10,12 @@ choices_map = {
|
||||
}
|
||||
choices = [(k, v['str']) for k,v in choices_map.items()]
|
||||
|
||||
class FeatureGroup(models.Model):
|
||||
class FeatureGroup(PgModel, models.Model):
|
||||
groupname = models.CharField(max_length=100, null=False, blank=False)
|
||||
groupsort = models.IntegerField(null=False, blank=False)
|
||||
|
||||
purge_urls = ('about/featurematrix/', )
|
||||
|
||||
def __unicode__(self):
|
||||
return self.groupname
|
||||
|
||||
@ -20,7 +24,7 @@ class FeatureGroup(models.Model):
|
||||
# Return a list of all the columns for the matrix
|
||||
return [b for a,b in versions]
|
||||
|
||||
class Feature(models.Model):
|
||||
class Feature(PgModel, models.Model):
|
||||
group = models.ForeignKey(FeatureGroup, null=False, blank=False)
|
||||
featurename = models.CharField(max_length=100, null=False, blank=False)
|
||||
featuredescription = models.TextField(null=False, blank=True)
|
||||
@ -33,6 +37,8 @@ class Feature(models.Model):
|
||||
v84 = models.IntegerField(null=False, blank=False, default=0, verbose_name="8.4", choices=choices)
|
||||
v85 = models.IntegerField(null=False, blank=False, default=0, verbose_name="8.5a3", choices=choices)
|
||||
|
||||
purge_urls = ('about/featurematrix/.*', )
|
||||
|
||||
def __unicode__(self):
|
||||
# To make it look good in the admin interface, just don't render it
|
||||
return ''
|
||||
|
Reference in New Issue
Block a user