Command line interface for force update

This commit is contained in:
Michal Čihař 2012-02-28 15:25:30 +01:00
parent ee76af5ff4
commit da32675f35

View File

@ -1,11 +1,20 @@
from django.core.management.base import BaseCommand, CommandError
from trans.models import SubProject
from optparse import make_option
class Command(BaseCommand):
help = '(re)loads translations from disk'
args = '<project/subproject>'
option_list = BaseCommand.option_list + (
make_option('--force',
action='store_true',
dest='force',
default=False,
help='Force rereading files even when they should be up to date'),
)
def handle(self, *args, **options):
for arg in args:
prj, subprj = arg.split('/')
SubProject.objects.get(slug = subprj, project__slug = prj).create_translations()
s = SubProject.objects.get(slug = subprj, project__slug = prj)
s.create_translations(options['force'])