[damned-lies] Move maintenance tasks in a management command
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Move maintenance tasks in a management command
- Date: Tue, 21 Dec 2010 09:24:43 +0000 (UTC)
commit 6004f011b1c6d81e712f5b5029662f8119394791
Author: Claude Paroz <claude 2xlibre net>
Date: Tue Dec 21 10:24:37 2010 +0100
Move maintenance tasks in a management command
README | 7 +++++++
common/views.py | 4 ----
stats/management/commands/run-maintenance.py | 12 ++++++++++++
3 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/README b/README
index a6e80bd..fbc5552 100644
--- a/README
+++ b/README
@@ -63,6 +63,13 @@ Installation
4 - Download jQuery and tablesorter .min.js files and copy them in
/media/js directory. Rename jquery-x.y.z.min.js into jquery.min.js
+Maintenance tasks
+=================
+
+There is a management command to run maintenance tasks (clean never-activated
+accounts, inactivate unused roles, ...):
+./manage.py run-maintenance
+It might be useful to add the command in a cron schedule.
OpenID support
==============
diff --git a/common/views.py b/common/views.py
index 02034e4..1898b88 100644
--- a/common/views.py
+++ b/common/views.py
@@ -118,8 +118,4 @@ def activate_account(request, key):
except Person.DoesNotExist:
return render_to_response('error.html', {'error':"Sorry, the key you provided is not valid."})
person.activate()
- #TODO: Here does not seem to be a good place for this.
- # We should move this in a cron-like system
- Person.clean_unactivated_accounts()
- Role.inactivate_unused_roles()
return site_login(request, msgs=[_("Your account has been activated.")])
diff --git a/stats/management/commands/run-maintenance.py b/stats/management/commands/run-maintenance.py
new file mode 100644
index 0000000..71ed2f3
--- /dev/null
+++ b/stats/management/commands/run-maintenance.py
@@ -0,0 +1,12 @@
+from django.core.management.base import BaseCommand
+
+from people.models import Person
+from teams.models import Role
+
+class Command(BaseCommand):
+ help = "Run maintenance tasks"
+
+ def handle(self, *args, **options):
+ Person.clean_unactivated_accounts()
+ Role.inactivate_unused_roles()
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]