Commit 05753259330e6b24c90728261fde79524c73681a

Authored by Sergio Oliveira
1 parent ff63d6ca

Allow to configure path and exclude lists in settings

colab/settings.py
@@ -243,6 +243,11 @@ MESSAGE_TAGS = { @@ -243,6 +243,11 @@ MESSAGE_TAGS = {
243 messages.ERROR: 'alert-danger', 243 messages.ERROR: 'alert-danger',
244 } 244 }
245 245
  246 +# Super Archives
  247 +SUPER_ARCHIVES_PATH = '/var/lib/mailman/archives/public'
  248 +SUPER_ARCHIVES_EXCLUDE = []
  249 +SUPER_ARCHIVES_LOCK_FILE = '/var/lock/colab/import_emails.lock'
  250 +
246 # Feedzilla (planet) 251 # Feedzilla (planet)
247 from feedzilla.settings import * # noqa (flake8 ignore) 252 from feedzilla.settings import * # noqa (flake8 ignore)
248 FEEDZILLA_PAGE_SIZE = 5 253 FEEDZILLA_PAGE_SIZE = 5
colab/super_archives/management/commands/import_emails.py
@@ -10,6 +10,7 @@ import mailbox @@ -10,6 +10,7 @@ import mailbox
10 import logging 10 import logging
11 from optparse import make_option 11 from optparse import make_option
12 12
  13 +from django.conf import settings
13 from django.db import transaction 14 from django.db import transaction
14 from django.template.defaultfilters import slugify 15 from django.template.defaultfilters import slugify
15 from django.core.management.base import BaseCommand, CommandError 16 from django.core.management.base import BaseCommand, CommandError
@@ -27,13 +28,12 @@ class Command(BaseCommand, object): @@ -27,13 +28,12 @@ class Command(BaseCommand, object):
27 28
28 help = __doc__ 29 help = __doc__
29 30
30 - default_archives_path = '/var/lib/mailman/archives/private'  
31 RE_SUBJECT_CLEAN = re.compile('((re|res|fw|fwd|en|enc):)|\[.*?\]', 31 RE_SUBJECT_CLEAN = re.compile('((re|res|fw|fwd|en|enc):)|\[.*?\]',
32 re.IGNORECASE) 32 re.IGNORECASE)
33 THREAD_CACHE = {} 33 THREAD_CACHE = {}
34 EMAIL_ADDR_CACHE = {} 34 EMAIL_ADDR_CACHE = {}
35 35
36 - lock_file = '/var/lock/colab/import_emails.lock' 36 + lock_file = settings.SUPER_ARCHIVES_LOCK_FILE
37 37
38 # A new command line option to get the dump file to parse. 38 # A new command line option to get the dump file to parse.
39 option_list = BaseCommand.option_list + ( 39 option_list = BaseCommand.option_list + (
@@ -41,8 +41,8 @@ class Command(BaseCommand, object): @@ -41,8 +41,8 @@ class Command(BaseCommand, object):
41 '--archives_path', 41 '--archives_path',
42 dest='archives_path', 42 dest='archives_path',
43 help=('Path of email archives to be imported. ' 43 help=('Path of email archives to be imported. '
44 - '(default: {})').format(default_archives_path),  
45 - default=default_archives_path), 44 + '(default: {})').format(settings.SUPER_ARCHIVES_PATH),
  45 + default=settings.SUPER_ARCHIVES_PATH),
46 46
47 make_option( 47 make_option(
48 '--exclude-list', 48 '--exclude-list',
@@ -50,7 +50,7 @@ class Command(BaseCommand, object): @@ -50,7 +50,7 @@ class Command(BaseCommand, object):
50 help=("Mailing list that won't be imported. It can be used many" 50 help=("Mailing list that won't be imported. It can be used many"
51 "times for more than one list."), 51 "times for more than one list."),
52 action='append', 52 action='append',
53 - default=None), 53 + default=settings.SUPER_ARCHIVES_EXCLUDE),
54 54
55 make_option( 55 make_option(
56 '--all', 56 '--all',