Repository: translate/pootle

Issue:
Cannot run `revision --restore`
With the recent addition to check for the revision counter (#4545), this became a bit meta: running `revision --restore` fails because one has to run `revision --restore` before :grin: 

```
$ ./manage.py revision --restore
SystemCheckError: System check identified some issues:

CRITICALS:
?: (pootle.C016) Revision is missing or has an incorrect value.
    HINT: Run `revision --restore` to reset the revision counter.
```



Discussion:

Resolving patch:
diff --git a/pootle/apps/pootle_app/management/commands/__init__.py b/pootle/apps/pootle_app/management/commands/__init__.py
--- a/pootle/apps/pootle_app/management/commands/__init__.py
+++ b/pootle/apps/pootle_app/management/commands/__init__.py
@@ -17,6 +17,21 @@
 from pootle_translationproject.models import TranslationProject
 
 
+class SkipChecksMixin(object):
+    def check(self, app_configs=None, tags=None, display_num_errors=False,
+              include_deployment_checks=False):
+        skip_tags = getattr(self, 'skip_system_check_tags', None)
+        if skip_tags is not None:
+            from django.core.checks.registry import registry
+            tags = registry.tags_available() - set(skip_tags)
+
+        super(SkipChecksMixin, self).check(
+            app_configs=app_configs,
+            tags=tags,
+            display_num_errors=display_num_errors,
+            include_deployment_checks=include_deployment_checks)
+
+
 class PootleCommand(BaseCommand):
     """Base class for handling recursive pootle store management commands."""
 
diff --git a/pootle/apps/pootle_app/management/commands/initdb.py b/pootle/apps/pootle_app/management/commands/initdb.py
--- a/pootle/apps/pootle_app/management/commands/initdb.py
+++ b/pootle/apps/pootle_app/management/commands/initdb.py
@@ -15,10 +15,12 @@
 from django.core.management.base import BaseCommand
 
 from pootle.core.initdb import InitDB
+from . import SkipChecksMixin
 
 
-class Command(BaseCommand):
+class Command(SkipChecksMixin, BaseCommand):
     help = 'Populates the database with initial values: users, projects, ...'
+    skip_system_check_tags = ('data', )
 
     def add_arguments(self, parser):
         parser.add_argument(
@@ -30,18 +32,6 @@ def add_arguments(self, parser):
                  "projects.",
         )
 
-    def check(self, app_configs=None, tags=None, display_num_errors=False,
-              include_deployment_checks=False):
-        from django.core.checks.registry import registry
-
-        tags = registry.tags_available()
-        tags.remove('data')
-        super(Command, self).check(
-            app_configs=app_configs,
-            tags=tags,
-            display_num_errors=display_num_errors,
-            include_deployment_checks=include_deployment_checks)
-
     def handle(self, **options):
         self.stdout.write('Populating the database.')
         InitDB().init_db(options["create_projects"])
diff --git a/pootle/apps/pootle_app/management/commands/revision.py b/pootle/apps/pootle_app/management/commands/revision.py
--- a/pootle/apps/pootle_app/management/commands/revision.py
+++ b/pootle/apps/pootle_app/management/commands/revision.py
@@ -14,10 +14,12 @@
 from django.core.management.base import BaseCommand
 
 from pootle.core.models import Revision
+from . import SkipChecksMixin
 
 
-class Command(BaseCommand):
+class Command(SkipChecksMixin, BaseCommand):
     help = "Print Pootle's current revision."
+    skip_system_check_tags = ('data', )
 
     def add_arguments(self, parser):
         parser.add_argument(


Test patch: