mail: make it possible to specify a category when feeding mails
This commit is contained in:
parent
95714fe50d
commit
bd0185bb6e
|
@ -14,6 +14,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from optparse import make_option
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from django.core.files import File
|
from django.core.files import File
|
||||||
|
@ -22,7 +23,13 @@ from django.core.management.base import BaseCommand, CommandError
|
||||||
from ...models import Mail
|
from ...models import Mail
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
args = ['...']
|
args = ['category', '...']
|
||||||
|
|
||||||
|
option_list = BaseCommand.option_list + (
|
||||||
|
make_option('--category',
|
||||||
|
dest='category',
|
||||||
|
default=None),
|
||||||
|
)
|
||||||
|
|
||||||
def handle(self, *args, **kwargs):
|
def handle(self, *args, **kwargs):
|
||||||
count = 0
|
count = 0
|
||||||
|
@ -30,6 +37,7 @@ class Command(BaseCommand):
|
||||||
if not os.path.exists(filepath):
|
if not os.path.exists(filepath):
|
||||||
continue
|
continue
|
||||||
mail = Mail(content=File(open(filepath)))
|
mail = Mail(content=File(open(filepath)))
|
||||||
|
mail.scanner_category = kwargs.get('category')
|
||||||
mail.save()
|
mail.save()
|
||||||
count += 1
|
count += 1
|
||||||
if count == 0:
|
if count == 0:
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('mail', '0008_remove_mail_mail_number'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='mail',
|
||||||
|
name='scanner_category',
|
||||||
|
field=models.CharField(max_length=100, null=True, blank=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -40,6 +40,8 @@ class Mail(models.Model):
|
||||||
null=True, max_length=50)
|
null=True, max_length=50)
|
||||||
note = models.TextField(_('Note'), null=True)
|
note = models.TextField(_('Note'), null=True)
|
||||||
|
|
||||||
|
scanner_category = models.CharField(max_length=100, blank=True, null=True)
|
||||||
|
|
||||||
# common to all source types:
|
# common to all source types:
|
||||||
status = models.CharField(_('Status'), blank=True, max_length=50)
|
status = models.CharField(_('Status'), blank=True, max_length=50)
|
||||||
contact_id = models.CharField(max_length=50, null=True)
|
contact_id = models.CharField(max_length=50, null=True)
|
||||||
|
|
Loading…
Reference in New Issue