mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-07 18:36:26 +00:00
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
|
# -*- coding: utf-8 -*-
|
||
|
# Generated by Django 1.10.7 on 2019-01-03 16:48
|
||
|
from __future__ import unicode_literals
|
||
|
import os
|
||
|
|
||
|
from django.db import migrations, models
|
||
|
from django.core.files import File
|
||
|
from django.conf import settings
|
||
|
import re2o.mixins
|
||
|
|
||
|
|
||
|
def create_default_templates(apps, schema_editor):
|
||
|
DocumentTemplate = apps.get_model('cotisations', 'DocumentTemplate')
|
||
|
invoice_path = os.path.join(
|
||
|
settings.BASE_DIR,
|
||
|
"cotisations",
|
||
|
"templates",
|
||
|
"cotisations",
|
||
|
"factures.tex"
|
||
|
)
|
||
|
with open(invoice_path) as f:
|
||
|
tpl, _ = DocumentTemplate.objects.get_or_create(
|
||
|
name="Re2o default invoice",
|
||
|
)
|
||
|
tpl.template.save('default_invoice.tex', File(f))
|
||
|
tpl.save()
|
||
|
|
||
|
|
||
|
class Migration(migrations.Migration):
|
||
|
|
||
|
dependencies = [
|
||
|
('cotisations', '0038_auto_20181231_1657'),
|
||
|
]
|
||
|
|
||
|
operations = [
|
||
|
migrations.CreateModel(
|
||
|
name='DocumentTemplate',
|
||
|
fields=[
|
||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||
|
('template', models.FileField(upload_to='templates/', verbose_name='template')),
|
||
|
('name', models.CharField(max_length=255, verbose_name='name')),
|
||
|
],
|
||
|
options={
|
||
|
'verbose_name_plural': 'document templates',
|
||
|
'verbose_name': 'document template',
|
||
|
},
|
||
|
bases=(re2o.mixins.RevMixin, re2o.mixins.AclMixin, models.Model),
|
||
|
),
|
||
|
migrations.RunPython(create_default_templates),
|
||
|
]
|