Over the years, contributors come and go and we have many cases now where
the contributor's email address which we have is not valid. As we really
don't want to show incorrect information on the webpage, allow contributor
email addresses to be blank for cases where we've discovered that the email
address is no longer valid.
We were already using signals for everything except delete, and even
in our old version of django the delete signal exists (it didn't exist
when this code was first written).
Django doesn't really like models to be OOP like this, so keeping PgModel
would cause issues with upcoming changes in django 1.8. Using simple functions
is easier, and the actual functionality is replicated straight off.
Only for users that are already listed under /community/contributors/,
make it possible to edit this data, so we don't have to track it manually.
For obvious reasons, we don't allow editing of the "contributor level"
field...
This also changes the contributors model to send a notification to
the slaves list whenever a contributor record is changed, so we can do
post-moderation if necessary.
This will be used to allow users to edit their own contributor records.
Requires SQL:
ALTER TABLE contributors_contributor add column "user_id" integer REFERENCES "auth_user" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "contributors_contributor_user_id" ON "contributors_contributor" ("user_id");
UPDATE contributors_contributor set user_id=(select id from auth_user where auth_user.email=contributors_contributor.email) where contributors_contributor.email is not null;
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.