diff --git a/accounting/migrations/0001_initial.py b/accounting/migrations/0001_initial.py index a49e4914..19b967bc 100644 --- a/accounting/migrations/0001_initial.py +++ b/accounting/migrations/0001_initial.py @@ -2,53 +2,58 @@ from __future__ import unicode_literals from django.db import migrations, models +import django.core.validators import accounting.models class Migration(migrations.Migration): dependencies = [ - ('core', '0001_initial'), - ('club', '0001_initial'), ] operations = [ migrations.CreateModel( name='AccountingType', fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)), - ('code', models.CharField(verbose_name='code', max_length=16)), - ('label', models.CharField(verbose_name='label', max_length=60)), - ('movement_type', models.CharField(verbose_name='movement type', choices=[('credit', 'Credit'), ('debit', 'Debit'), ('neutral', 'Neutral')], max_length=12)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('code', models.CharField(max_length=16, verbose_name='code', validators=[django.core.validators.RegexValidator('^[0-9]*$', 'An accounting type code contains only numbers')])), + ('label', models.CharField(max_length=128, verbose_name='label')), + ('movement_type', models.CharField(choices=[('CREDIT', 'Credit'), ('DEBIT', 'Debit'), ('NEUTRAL', 'Neutral')], max_length=12, verbose_name='movement type')), ], options={ 'verbose_name': 'accounting type', + 'ordering': ['movement_type', 'code'], }, ), migrations.CreateModel( name='BankAccount', fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)), - ('name', models.CharField(verbose_name='name', max_length=30)), - ('iban', models.CharField(blank=True, verbose_name='iban', max_length=255)), - ('number', models.CharField(blank=True, verbose_name='account number', max_length=255)), - ('club', models.ForeignKey(related_name='bank_accounts', to='club.Club')), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('name', models.CharField(max_length=30, verbose_name='name')), + ('iban', models.CharField(max_length=255, blank=True, verbose_name='iban')), + ('number', models.CharField(max_length=255, blank=True, verbose_name='account number')), ], + options={ + 'verbose_name': 'Bank account', + 'ordering': ['club', 'name'], + }, ), migrations.CreateModel( name='ClubAccount', fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)), - ('name', models.CharField(verbose_name='name', max_length=30)), - ('bank_account', models.ForeignKey(related_name='club_accounts', to='accounting.BankAccount')), - ('club', models.OneToOneField(related_name='club_account', to='club.Club')), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('name', models.CharField(max_length=30, verbose_name='name')), ], + options={ + 'verbose_name': 'Club account', + 'ordering': ['bank_account', 'name'], + }, ), migrations.CreateModel( name='Company', fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)), - ('name', models.CharField(verbose_name='name', max_length=60)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('name', models.CharField(max_length=60, verbose_name='name')), ], options={ 'verbose_name': 'company', @@ -57,41 +62,49 @@ class Migration(migrations.Migration): migrations.CreateModel( name='GeneralJournal', fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('start_date', models.DateField(verbose_name='start date')), - ('end_date', models.DateField(default=None, null=True, verbose_name='end date', blank=True)), - ('name', models.CharField(verbose_name='name', max_length=30)), - ('closed', models.BooleanField(default=False, verbose_name='is closed')), - ('amount', accounting.models.CurrencyField(default=0, decimal_places=2, max_digits=12, verbose_name='amount')), - ('effective_amount', accounting.models.CurrencyField(default=0, decimal_places=2, max_digits=12, verbose_name='effective_amount')), - ('club_account', models.ForeignKey(related_name='journals', to='accounting.ClubAccount')), + ('end_date', models.DateField(null=True, verbose_name='end date', default=None, blank=True)), + ('name', models.CharField(max_length=40, verbose_name='name')), + ('closed', models.BooleanField(verbose_name='is closed', default=False)), + ('amount', accounting.models.CurrencyField(decimal_places=2, default=0, verbose_name='amount', max_digits=12)), + ('effective_amount', accounting.models.CurrencyField(decimal_places=2, default=0, verbose_name='effective_amount', max_digits=12)), ], + options={ + 'verbose_name': 'General journal', + 'ordering': ['-start_date'], + }, ), migrations.CreateModel( name='Operation', fields=[ - ('id', models.AutoField(serialize=False, auto_created=True, verbose_name='ID', primary_key=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('number', models.IntegerField(verbose_name='number')), ('amount', accounting.models.CurrencyField(decimal_places=2, max_digits=12, verbose_name='amount')), ('date', models.DateField(verbose_name='date')), - ('label', models.CharField(verbose_name='label', max_length=50)), - ('remark', models.TextField(verbose_name='remark', max_length=255)), - ('mode', models.CharField(verbose_name='payment method', choices=[('CHEQUE', 'Check'), ('CASH', 'Cash'), ('TRANSFert', 'Transfert'), ('CARD', 'Credit card')], max_length=255)), - ('cheque_number', models.IntegerField(default=-1, verbose_name='cheque number')), - ('done', models.BooleanField(default=False, verbose_name='is done')), - ('target_type', models.CharField(verbose_name='target type', choices=[('USER', 'User'), ('CLUB', 'Club'), ('ACCOUNT', 'Account'), ('COMPANY', 'Company'), ('OTHER', 'Other')], max_length=10)), + ('remark', models.CharField(max_length=128, verbose_name='comment')), + ('mode', models.CharField(choices=[('CHECK', 'Check'), ('CASH', 'Cash'), ('TRANSFERT', 'Transfert'), ('CARD', 'Credit card')], max_length=255, verbose_name='payment method')), + ('cheque_number', models.CharField(max_length=32, null=True, verbose_name='cheque number', default='', blank=True)), + ('done', models.BooleanField(verbose_name='is done', default=False)), + ('target_type', models.CharField(choices=[('USER', 'User'), ('CLUB', 'Club'), ('ACCOUNT', 'Account'), ('COMPANY', 'Company'), ('OTHER', 'Other')], max_length=10, verbose_name='target type')), ('target_id', models.IntegerField(null=True, verbose_name='target id', blank=True)), - ('target_label', models.CharField(default='', blank=True, verbose_name='target label', max_length=32)), - ('accounting_type', models.ForeignKey(verbose_name='accounting type', related_name='operations', to='accounting.AccountingType')), - ('invoice', models.ForeignKey(verbose_name='invoice', related_name='operations', blank=True, null=True, to='core.SithFile')), - ('journal', models.ForeignKey(related_name='operations', to='accounting.GeneralJournal')), + ('target_label', models.CharField(max_length=32, blank=True, verbose_name='target label', default='')), + ('accounting_type', models.ForeignKey(null=True, related_name='operations', verbose_name='accounting type', to='accounting.AccountingType', blank=True)), ], options={ 'ordering': ['-number'], }, ), - migrations.AlterUniqueTogether( - name='operation', - unique_together=set([('number', 'journal')]), + migrations.CreateModel( + name='SimplifiedAccountingType', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('label', models.CharField(max_length=128, verbose_name='label')), + ('accounting_type', models.ForeignKey(verbose_name='simplified accounting types', to='accounting.AccountingType', related_name='simplified_types')), + ], + options={ + 'verbose_name': 'simplified type', + 'ordering': ['accounting_type__movement_type', 'accounting_type__code'], + }, ), ] diff --git a/accounting/migrations/0002_auto_20160824_2152.py b/accounting/migrations/0002_auto_20160824_2152.py new file mode 100644 index 00000000..b44310ff --- /dev/null +++ b/accounting/migrations/0002_auto_20160824_2152.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('club', '0001_initial'), + ('accounting', '0001_initial'), + ('core', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='operation', + name='invoice', + field=models.ForeignKey(null=True, related_name='operations', verbose_name='invoice', to='core.SithFile', blank=True), + ), + migrations.AddField( + model_name='operation', + name='journal', + field=models.ForeignKey(verbose_name='journal', to='accounting.GeneralJournal', related_name='operations'), + ), + migrations.AddField( + model_name='operation', + name='linked_operation', + field=models.OneToOneField(blank=True, to='accounting.Operation', null=True, related_name='operation_linked_to', verbose_name='linked operation', default=None), + ), + migrations.AddField( + model_name='operation', + name='simpleaccounting_type', + field=models.ForeignKey(null=True, related_name='operations', verbose_name='simple type', to='accounting.SimplifiedAccountingType', blank=True), + ), + migrations.AddField( + model_name='generaljournal', + name='club_account', + field=models.ForeignKey(verbose_name='club account', to='accounting.ClubAccount', related_name='journals'), + ), + migrations.AddField( + model_name='clubaccount', + name='bank_account', + field=models.ForeignKey(verbose_name='bank account', to='accounting.BankAccount', related_name='club_accounts'), + ), + migrations.AddField( + model_name='clubaccount', + name='club', + field=models.ForeignKey(verbose_name='club', to='club.Club', related_name='club_account'), + ), + migrations.AddField( + model_name='bankaccount', + name='club', + field=models.ForeignKey(verbose_name='club', to='club.Club', related_name='bank_accounts'), + ), + migrations.AlterUniqueTogether( + name='operation', + unique_together=set([('number', 'journal')]), + ), + ] diff --git a/accounting/migrations/0003_auto_20160824_2203.py b/accounting/migrations/0003_auto_20160824_2203.py new file mode 100644 index 00000000..57bd9e22 --- /dev/null +++ b/accounting/migrations/0003_auto_20160824_2203.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import phonenumber_field.modelfields + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounting', '0002_auto_20160824_2152'), + ] + + operations = [ + migrations.AddField( + model_name='company', + name='city', + field=models.CharField(blank=True, verbose_name='city', max_length=60), + ), + migrations.AddField( + model_name='company', + name='country', + field=models.CharField(blank=True, verbose_name='country', max_length=32), + ), + migrations.AddField( + model_name='company', + name='email', + field=models.EmailField(blank=True, verbose_name='email', max_length=254), + ), + migrations.AddField( + model_name='company', + name='phone', + field=phonenumber_field.modelfields.PhoneNumberField(blank=True, verbose_name='phone', max_length=128), + ), + migrations.AddField( + model_name='company', + name='postcode', + field=models.CharField(blank=True, verbose_name='postcode', max_length=10), + ), + migrations.AddField( + model_name='company', + name='street', + field=models.CharField(blank=True, verbose_name='street', max_length=60), + ), + migrations.AddField( + model_name='company', + name='website', + field=models.CharField(blank=True, verbose_name='website', max_length=64), + ), + ] diff --git a/accounting/models.py b/accounting/models.py index c4ee8614..05918095 100644 --- a/accounting/models.py +++ b/accounting/models.py @@ -7,6 +7,8 @@ from django.conf import settings from django.utils.translation import ugettext_lazy as _ from django.template import defaultfilters +from phonenumber_field.modelfields import PhoneNumberField + from decimal import Decimal from core.models import User, SithFile from club.models import Club @@ -32,6 +34,13 @@ class CurrencyField(models.DecimalField): class Company(models.Model): name = models.CharField(_('name'), max_length=60) + street = models.CharField(_('street'), max_length=60, blank=True) + city = models.CharField(_('city'), max_length=60, blank=True) + postcode = models.CharField(_('postcode'), max_length=10, blank=True) + country = models.CharField(_('country'), max_length=32, blank=True) + phone = PhoneNumberField(_('phone'), blank=True) + email = models.EmailField(_('email'), blank=True) + website = models.CharField(_('website'), max_length=64, blank=True) class Meta: verbose_name = _("company") diff --git a/club/migrations/0001_initial.py b/club/migrations/0001_initial.py index 7f804a58..d93ac4c8 100644 --- a/club/migrations/0001_initial.py +++ b/club/migrations/0001_initial.py @@ -3,40 +3,32 @@ from __future__ import unicode_literals from django.db import migrations, models import django.core.validators -from django.conf import settings class Migration(migrations.Migration): dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('core', '0001_initial'), ] operations = [ migrations.CreateModel( name='Club', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), - ('name', models.CharField(verbose_name='name', max_length=30)), - ('unix_name', models.CharField(verbose_name='unix name', unique=True, error_messages={'unique': 'A club with that unix name already exists.'}, max_length=30, validators=[django.core.validators.RegexValidator('^[a-z0-9][a-z0-9._-]*[a-z0-9]$', 'Enter a valid unix name. This value may contain only letters, numbers ./-/_ characters.')])), - ('address', models.CharField(verbose_name='address', max_length=254)), - ('edit_groups', models.ManyToManyField(to='core.Group', related_name='editable_club', blank=True)), - ('owner_group', models.ForeignKey(related_name='owned_club', default=1, to='core.Group')), - ('parent', models.ForeignKey(blank=True, null=True, to='club.Club', related_name='children')), - ('view_groups', models.ManyToManyField(to='core.Group', related_name='viewable_club', blank=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('name', models.CharField(max_length=64, verbose_name='name')), + ('unix_name', models.CharField(unique=True, max_length=30, error_messages={'unique': 'A club with that unix name already exists.'}, verbose_name='unix name', validators=[django.core.validators.RegexValidator('^[a-z0-9][a-z0-9._-]*[a-z0-9]$', 'Enter a valid unix name. This value may contain only letters, numbers ./-/_ characters.')])), + ('address', models.CharField(max_length=254, verbose_name='address')), ], ), migrations.CreateModel( name='Membership', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('start_date', models.DateField(verbose_name='start date', auto_now=True)), - ('end_date', models.DateField(verbose_name='end date', null=True, blank=True)), - ('role', models.IntegerField(default=0, verbose_name='role', choices=[(0, 'Curious'), (1, 'Active member'), (2, 'Board member'), (3, 'IT supervisor'), (4, 'Secretary'), (5, 'Communication supervisor'), (7, 'Treasurer'), (9, 'Vice-President'), (10, 'President')])), - ('description', models.CharField(verbose_name='description', max_length=30, blank=True)), - ('club', models.ForeignKey(verbose_name='club', related_name='members', to='club.Club')), - ('user', models.ForeignKey(verbose_name='user', related_name='membership', to=settings.AUTH_USER_MODEL)), + ('end_date', models.DateField(null=True, verbose_name='end date', blank=True)), + ('role', models.IntegerField(choices=[(0, 'Curious'), (1, 'Active member'), (2, 'Board member'), (3, 'IT supervisor'), (4, 'Secretary'), (5, 'Communication supervisor'), (7, 'Treasurer'), (9, 'Vice-President'), (10, 'President')], default=0, verbose_name='role')), + ('description', models.CharField(max_length=128, blank=True, verbose_name='description')), + ('club', models.ForeignKey(verbose_name='club', to='club.Club', related_name='members')), ], ), ] diff --git a/club/migrations/0002_auto_20160824_2152.py b/club/migrations/0002_auto_20160824_2152.py new file mode 100644 index 00000000..8c8a0fc8 --- /dev/null +++ b/club/migrations/0002_auto_20160824_2152.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +from django.conf import settings + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('club', '0001_initial'), + ('core', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='membership', + name='user', + field=models.ForeignKey(verbose_name='user', to=settings.AUTH_USER_MODEL, related_name='membership'), + ), + migrations.AddField( + model_name='club', + name='edit_groups', + field=models.ManyToManyField(to='core.Group', blank=True, related_name='editable_club'), + ), + migrations.AddField( + model_name='club', + name='home', + field=models.OneToOneField(blank=True, null=True, related_name='home_of_club', verbose_name='home', to='core.SithFile'), + ), + migrations.AddField( + model_name='club', + name='owner_group', + field=models.ForeignKey(default=1, to='core.Group', related_name='owned_club'), + ), + migrations.AddField( + model_name='club', + name='parent', + field=models.ForeignKey(null=True, to='club.Club', related_name='children', blank=True), + ), + migrations.AddField( + model_name='club', + name='view_groups', + field=models.ManyToManyField(to='core.Group', blank=True, related_name='viewable_club'), + ), + ] diff --git a/core/migrations/0001_initial.py b/core/migrations/0001_initial.py index d5e0a33c..4f611246 100644 --- a/core/migrations/0001_initial.py +++ b/core/migrations/0001_initial.py @@ -3,9 +3,10 @@ from __future__ import unicode_literals from django.db import migrations, models import django.contrib.auth.models -import core.models import django.db.models.deletion import django.core.validators +import core.models +import phonenumber_field.modelfields from django.conf import settings @@ -19,19 +20,36 @@ class Migration(migrations.Migration): migrations.CreateModel( name='User', fields=[ - ('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)), - ('password', models.CharField(verbose_name='password', max_length=128)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('password', models.CharField(max_length=128, verbose_name='password')), ('last_login', models.DateTimeField(null=True, verbose_name='last login', blank=True)), - ('username', models.CharField(verbose_name='username', error_messages={'unique': 'A user with that username already exists.'}, unique=True, max_length=254, help_text='Required. 254 characters or fewer. Letters, digits and @/./+/-/_ only.', validators=[django.core.validators.RegexValidator('^[\\w.@+-]+$', 'Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.')])), - ('first_name', models.CharField(verbose_name='first name', max_length=30)), - ('last_name', models.CharField(verbose_name='last name', max_length=30)), - ('email', models.EmailField(max_length=254, verbose_name='email address', unique=True)), + ('username', models.CharField(help_text='Required. 254 characters or fewer. Letters, digits and @/./+/-/_ only.', unique=True, max_length=254, error_messages={'unique': 'A user with that username already exists.'}, verbose_name='username', validators=[django.core.validators.RegexValidator('^[\\w.@+-]+$', 'Enter a valid username. This value may contain only letters, numbers and @/./+/-/_ characters.')])), + ('first_name', models.CharField(max_length=64, verbose_name='first name')), + ('last_name', models.CharField(max_length=64, verbose_name='last name')), + ('email', models.EmailField(unique=True, max_length=254, verbose_name='email address')), ('date_of_birth', models.DateField(null=True, verbose_name='date of birth', blank=True)), - ('nick_name', models.CharField(max_length=30, blank=True)), - ('is_staff', models.BooleanField(verbose_name='staff status', default=False, help_text='Designates whether the user can log into this admin site.')), - ('is_active', models.BooleanField(verbose_name='active', default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.')), - ('date_joined', models.DateField(verbose_name='date joined', auto_now_add=True)), - ('is_superuser', models.BooleanField(verbose_name='superuser', default=False, help_text='Designates whether this user is a superuser. ')), + ('nick_name', models.CharField(max_length=64, null=True, verbose_name='nick name', blank=True)), + ('is_staff', models.BooleanField(help_text='Designates whether the user can log into this admin site.', verbose_name='staff status', default=False)), + ('is_active', models.BooleanField(help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active', default=True)), + ('date_joined', models.DateField(auto_now_add=True, verbose_name='date joined')), + ('last_update', models.DateField(verbose_name='last update', auto_now=True)), + ('is_superuser', models.BooleanField(help_text='Designates whether this user is a superuser. ', verbose_name='superuser', default=False)), + ('sex', models.CharField(choices=[('MAN', 'Man'), ('WOMAN', 'Woman')], max_length=10, default='MAN', verbose_name='sex')), + ('tshirt_size', models.CharField(choices=[('-', '-'), ('XS', 'XS'), ('S', 'S'), ('M', 'M'), ('L', 'L'), ('XL', 'XL'), ('XXL', 'XXL'), ('XXXL', 'XXXL')], max_length=5, default='-', verbose_name='tshirt size')), + ('role', models.CharField(choices=[('STUDENT', 'Student'), ('ADMINISTRATIVE', 'Administrative agent'), ('TEACHER', 'Teacher'), ('AGENT', 'Agent'), ('DOCTOR', 'Doctor'), ('FORMER STUDENT', 'Former student'), ('SERVICE', 'Service')], max_length=15, blank=True, verbose_name='role', default='')), + ('department', models.CharField(choices=[('TC', 'TC'), ('IMSI', 'IMSI'), ('IMAP', 'IMAP'), ('INFO', 'INFO'), ('GI', 'GI'), ('E', 'E'), ('EE', 'EE'), ('GESC', 'GESC'), ('GMC', 'GMC'), ('MC', 'MC'), ('EDIM', 'EDIM'), ('HUMA', 'Humanities'), ('NA', 'N/A')], max_length=15, blank=True, verbose_name='department', default='NA')), + ('dpt_option', models.CharField(max_length=32, blank=True, verbose_name='dpt option', default='')), + ('semester', models.CharField(max_length=5, blank=True, verbose_name='semester', default='')), + ('quote', models.CharField(max_length=256, blank=True, verbose_name='quote', default='')), + ('school', models.CharField(max_length=80, blank=True, verbose_name='school', default='')), + ('promo', models.IntegerField(null=True, verbose_name='promo', validators=[core.models.validate_promo], blank=True)), + ('forum_signature', models.TextField(max_length=256, blank=True, verbose_name='forum signature', default='')), + ('second_email', models.EmailField(max_length=254, null=True, verbose_name='second email address', blank=True)), + ('phone', phonenumber_field.modelfields.PhoneNumberField(max_length=128, null=True, verbose_name='phone', blank=True)), + ('parent_phone', phonenumber_field.modelfields.PhoneNumberField(max_length=128, null=True, verbose_name='parent phone', blank=True)), + ('address', models.CharField(max_length=128, blank=True, verbose_name='address', default='')), + ('parent_address', models.CharField(max_length=128, blank=True, verbose_name='parent address', default='')), + ('is_subscriber_viewable', models.BooleanField(verbose_name='is subscriber viewable', default=True)), ], options={ 'abstract': False, @@ -43,22 +61,22 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Group', fields=[ - ('group_ptr', models.OneToOneField(serialize=False, auto_created=True, to='auth.Group', primary_key=True, parent_link=True)), - ('is_meta', models.BooleanField(verbose_name='meta group status', default=False, help_text='Whether a group is a meta group or not')), - ('description', models.CharField(verbose_name='description', max_length=60)), + ('group_ptr', models.OneToOneField(primary_key=True, parent_link=True, serialize=False, to='auth.Group', auto_created=True)), + ('is_meta', models.BooleanField(help_text='Whether a group is a meta group or not', verbose_name='meta group status', default=False)), + ('description', models.CharField(max_length=60, verbose_name='description')), ], bases=('auth.group',), ), migrations.CreateModel( name='Page', fields=[ - ('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)), - ('name', models.CharField(verbose_name='page name', max_length=30)), - ('_full_name', models.CharField(verbose_name='page name', max_length=255, blank=True)), - ('edit_groups', models.ManyToManyField(to='core.Group', verbose_name='edit group', related_name='editable_page', blank=True)), - ('owner_group', models.ForeignKey(to='core.Group', default=1, related_name='owned_page', verbose_name='owner group')), - ('parent', models.ForeignKey(to='core.Page', null=True, related_name='children', verbose_name='parent', blank=True, on_delete=django.db.models.deletion.SET_NULL)), - ('view_groups', models.ManyToManyField(to='core.Group', verbose_name='view group', related_name='viewable_page', blank=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('name', models.CharField(max_length=30, verbose_name='page name')), + ('_full_name', models.CharField(max_length=255, blank=True, verbose_name='page name')), + ('edit_groups', models.ManyToManyField(related_name='editable_page', to='core.Group', blank=True, verbose_name='edit group')), + ('owner_group', models.ForeignKey(default=1, related_name='owned_page', verbose_name='owner group', to='core.Group')), + ('parent', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, null=True, related_name='children', verbose_name='parent', to='core.Page', blank=True)), + ('view_groups', models.ManyToManyField(related_name='viewable_page', to='core.Group', blank=True, verbose_name='view group')), ], options={ 'permissions': (('change_prop_page', "Can change the page's properties (groups, ...)"), ('view_page', 'Can view the page')), @@ -67,10 +85,10 @@ class Migration(migrations.Migration): migrations.CreateModel( name='PageRev', fields=[ - ('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('revision', models.IntegerField(verbose_name='revision')), - ('title', models.CharField(verbose_name='page title', max_length=255, blank=True)), - ('content', models.TextField(verbose_name='page content', blank=True)), + ('title', models.CharField(max_length=255, blank=True, verbose_name='page title')), + ('content', models.TextField(blank=True, verbose_name='page content')), ('date', models.DateTimeField(verbose_name='date', auto_now=True)), ('author', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='page_rev')), ('page', models.ForeignKey(to='core.Page', related_name='revisions')), @@ -82,30 +100,50 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Preferences', fields=[ - ('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)), - ('show_my_stats', models.BooleanField(verbose_name='define if we show a users stats', default=False, help_text='Show your account statistics to others')), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('show_my_stats', models.BooleanField(help_text='Show your account statistics to others', verbose_name='define if we show a users stats', default=False)), ('user', models.OneToOneField(to=settings.AUTH_USER_MODEL, related_name='preferences')), ], ), migrations.CreateModel( name='SithFile', fields=[ - ('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)), - ('name', models.CharField(verbose_name='file name', max_length=30)), - ('file', models.FileField(null=True, upload_to=core.models.get_directory, verbose_name='file', blank=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('name', models.CharField(max_length=30, verbose_name='file name')), + ('file', models.FileField(upload_to=core.models.get_directory, null=True, verbose_name='file', blank=True)), ('is_folder', models.BooleanField(verbose_name='is folder', default=True)), - ('mime_type', models.CharField(verbose_name='mime type', max_length=30)), - ('size', models.IntegerField(verbose_name='size', default=0)), + ('mime_type', models.CharField(max_length=30, verbose_name='mime type')), + ('size', models.IntegerField(default=0, verbose_name='size')), ('date', models.DateTimeField(verbose_name='date', auto_now=True)), - ('edit_groups', models.ManyToManyField(to='core.Group', verbose_name='edit group', related_name='editable_files', blank=True)), - ('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='owned_files', verbose_name='owner')), - ('parent', models.ForeignKey(to='core.SithFile', null=True, related_name='children', verbose_name='parent', blank=True)), - ('view_groups', models.ManyToManyField(to='core.Group', verbose_name='view group', related_name='viewable_files', blank=True)), + ('edit_groups', models.ManyToManyField(related_name='editable_files', to='core.Group', blank=True, verbose_name='edit group')), + ('owner', models.ForeignKey(verbose_name='owner', to=settings.AUTH_USER_MODEL, related_name='owned_files')), + ('parent', models.ForeignKey(null=True, related_name='children', verbose_name='parent', to='core.SithFile', blank=True)), + ('view_groups', models.ManyToManyField(related_name='viewable_files', to='core.Group', blank=True, verbose_name='view group')), ], options={ 'verbose_name': 'file', }, ), + migrations.AddField( + model_name='user', + name='avatar_pict', + field=models.OneToOneField(blank=True, on_delete=django.db.models.deletion.SET_NULL, null=True, related_name='avatar_of', verbose_name='avatar', to='core.SithFile'), + ), + migrations.AddField( + model_name='user', + name='home', + field=models.OneToOneField(blank=True, null=True, related_name='home_of', verbose_name='home', to='core.SithFile'), + ), + migrations.AddField( + model_name='user', + name='profile_pict', + field=models.OneToOneField(blank=True, on_delete=django.db.models.deletion.SET_NULL, null=True, related_name='profile_of', verbose_name='profile', to='core.SithFile'), + ), + migrations.AddField( + model_name='user', + name='scrub_pict', + field=models.OneToOneField(blank=True, on_delete=django.db.models.deletion.SET_NULL, null=True, related_name='scrub_of', verbose_name='scrub', to='core.SithFile'), + ), migrations.CreateModel( name='MetaGroup', fields=[ @@ -137,6 +175,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='user', name='groups', - field=models.ManyToManyField(to='core.RealGroup', related_name='users', blank=True), + field=models.ManyToManyField(to='core.RealGroup', blank=True, related_name='users'), ), ] diff --git a/counter/migrations/0001_initial.py b/counter/migrations/0001_initial.py index ca3f0781..d35ef1c1 100644 --- a/counter/migrations/0001_initial.py +++ b/counter/migrations/0001_initial.py @@ -3,26 +3,28 @@ from __future__ import unicode_literals from django.db import migrations, models import accounting.models +import django.db.models.deletion from django.conf import settings class Migration(migrations.Migration): dependencies = [ + ('subscription', '0001_initial'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('core', '0001_initial'), - ('club', '0001_initial'), + ('club', '0002_auto_20160824_2152'), ] operations = [ migrations.CreateModel( name='Counter', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), - ('name', models.CharField(verbose_name='name', max_length=30)), - ('type', models.CharField(verbose_name='subscription type', max_length=255, choices=[('BAR', 'Bar'), ('OFFICE', 'Office'), ('EBOUTIC', 'Eboutic')])), - ('club', models.ForeignKey(related_name='counters', to='club.Club')), - ('edit_groups', models.ManyToManyField(to='core.Group', related_name='editable_counters', blank=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('name', models.CharField(max_length=30, verbose_name='name')), + ('type', models.CharField(choices=[('BAR', 'Bar'), ('OFFICE', 'Office'), ('EBOUTIC', 'Eboutic')], max_length=255, verbose_name='counter type')), + ('club', models.ForeignKey(to='club.Club', related_name='counters')), + ('edit_groups', models.ManyToManyField(to='core.Group', blank=True, related_name='editable_counters')), ], options={ 'verbose_name': 'counter', @@ -32,23 +34,23 @@ class Migration(migrations.Migration): name='Customer', fields=[ ('user', models.OneToOneField(primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)), - ('account_id', models.CharField(verbose_name='account id', unique=True, max_length=10)), - ('amount', accounting.models.CurrencyField(verbose_name='amount', decimal_places=2, max_digits=12)), + ('account_id', models.CharField(unique=True, max_length=10, verbose_name='account id')), + ('amount', accounting.models.CurrencyField(decimal_places=2, max_digits=12, verbose_name='amount')), ], options={ 'verbose_name': 'customer', - 'verbose_name_plural': 'customers', 'ordering': ['account_id'], + 'verbose_name_plural': 'customers', }, ), migrations.CreateModel( name='Permanency', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('start', models.DateTimeField(verbose_name='start date')), ('end', models.DateTimeField(verbose_name='end date')), - ('counter', models.ForeignKey(related_name='permanencies', to='counter.Counter')), - ('user', models.ForeignKey(related_name='permanencies', to=settings.AUTH_USER_MODEL)), + ('counter', models.ForeignKey(to='counter.Counter', related_name='permanencies')), + ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='permanencies')), ], options={ 'verbose_name': 'permanency', @@ -57,15 +59,19 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Product', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), - ('name', models.CharField(verbose_name='name', max_length=30)), - ('description', models.TextField(verbose_name='description', blank=True)), - ('code', models.CharField(verbose_name='code', max_length=10)), - ('purchase_price', accounting.models.CurrencyField(verbose_name='purchase price', decimal_places=2, max_digits=12)), - ('selling_price', accounting.models.CurrencyField(verbose_name='selling price', decimal_places=2, max_digits=12)), - ('special_selling_price', accounting.models.CurrencyField(verbose_name='special selling price', decimal_places=2, max_digits=12)), - ('icon', models.ImageField(upload_to='products', null=True, blank=True)), - ('club', models.ForeignKey(related_name='products', to='club.Club')), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('name', models.CharField(max_length=64, verbose_name='name')), + ('description', models.TextField(blank=True, verbose_name='description')), + ('code', models.CharField(max_length=16, blank=True, verbose_name='code')), + ('purchase_price', accounting.models.CurrencyField(decimal_places=2, max_digits=12, verbose_name='purchase price')), + ('selling_price', accounting.models.CurrencyField(decimal_places=2, max_digits=12, verbose_name='selling price')), + ('special_selling_price', accounting.models.CurrencyField(decimal_places=2, max_digits=12, verbose_name='special selling price')), + ('icon', models.ImageField(upload_to='products', null=True, verbose_name='icon', blank=True)), + ('limit_age', models.IntegerField(default=0, verbose_name='limit age')), + ('tray', models.BooleanField(verbose_name='tray price', default=False)), + ('buying_groups', models.ManyToManyField(related_name='products', to='core.Group', verbose_name='buying groups')), + ('club', models.ForeignKey(verbose_name='club', to='club.Club', related_name='products')), + ('parent_product', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, null=True, related_name='children_products', verbose_name='parent product', to='counter.Product', blank=True)), ], options={ 'verbose_name': 'product', @@ -74,9 +80,9 @@ class Migration(migrations.Migration): migrations.CreateModel( name='ProductType', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), - ('name', models.CharField(verbose_name='name', max_length=30)), - ('description', models.TextField(verbose_name='description', null=True, blank=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('name', models.CharField(max_length=30, verbose_name='name')), + ('description', models.TextField(null=True, verbose_name='description', blank=True)), ('icon', models.ImageField(upload_to='products', null=True, blank=True)), ], options={ @@ -86,15 +92,15 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Refilling', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), - ('amount', accounting.models.CurrencyField(verbose_name='amount', decimal_places=2, max_digits=12)), - ('date', models.DateTimeField(verbose_name='date', auto_now=True)), - ('payment_method', models.CharField(default='cash', verbose_name='payment method', max_length=255, choices=[('CHEQUE', 'Check'), ('CASH', 'Cash')])), - ('bank', models.CharField(default='other', verbose_name='bank', max_length=255, choices=[('OTHER', 'Autre'), ('LA-POSTE', 'La Poste'), ('CREDIT-AGRICOLE', 'Credit Agricole'), ('CREDIT-MUTUEL', 'Credit Mutuel')])), - ('is_validated', models.BooleanField(default=False, verbose_name='is validated')), - ('counter', models.ForeignKey(related_name='refillings', to='counter.Counter')), - ('customer', models.ForeignKey(related_name='refillings', to='counter.Customer')), - ('operator', models.ForeignKey(related_name='refillings_as_operator', to=settings.AUTH_USER_MODEL)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('amount', accounting.models.CurrencyField(decimal_places=2, max_digits=12, verbose_name='amount')), + ('date', models.DateTimeField(verbose_name='date')), + ('payment_method', models.CharField(choices=[('CHECK', 'Check'), ('CASH', 'Cash'), ('CARD', 'Credit card')], max_length=255, default='CASH', verbose_name='payment method')), + ('bank', models.CharField(choices=[('OTHER', 'Autre'), ('SOCIETE-GENERALE', 'Société générale'), ('BANQUE-POPULAIRE', 'Banque populaire'), ('BNP', 'BNP'), ('CAISSE-EPARGNE', "Caisse d'épargne"), ('CIC', 'CIC'), ('CREDIT-AGRICOLE', 'Crédit Agricole'), ('CREDIT-MUTUEL', 'Credit Mutuel'), ('CREDIT-LYONNAIS', 'Credit Lyonnais'), ('LA-POSTE', 'La Poste')], max_length=255, default='OTHER', verbose_name='bank')), + ('is_validated', models.BooleanField(verbose_name='is validated', default=False)), + ('counter', models.ForeignKey(to='counter.Counter', related_name='refillings')), + ('customer', models.ForeignKey(to='counter.Customer', related_name='refillings')), + ('operator', models.ForeignKey(to=settings.AUTH_USER_MODEL, related_name='refillings_as_operator')), ], options={ 'verbose_name': 'refilling', @@ -103,16 +109,18 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Selling', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), - ('label', models.CharField(verbose_name='label', max_length=30)), - ('unit_price', accounting.models.CurrencyField(verbose_name='unit price', decimal_places=2, max_digits=12)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('label', models.CharField(max_length=64, verbose_name='label')), + ('unit_price', accounting.models.CurrencyField(decimal_places=2, max_digits=12, verbose_name='unit price')), ('quantity', models.IntegerField(verbose_name='quantity')), - ('date', models.DateTimeField(verbose_name='date', auto_now=True)), - ('is_validated', models.BooleanField(default=False, verbose_name='is validated')), - ('counter', models.ForeignKey(related_name='sellings', to='counter.Counter')), - ('customer', models.ForeignKey(related_name='buyings', to='counter.Customer')), - ('product', models.ForeignKey(blank=True, null=True, to='counter.Product', related_name='sellings')), - ('seller', models.ForeignKey(related_name='sellings_as_operator', to=settings.AUTH_USER_MODEL)), + ('date', models.DateTimeField(verbose_name='date')), + ('payment_method', models.CharField(choices=[('SITH_ACCOUNT', 'Sith account'), ('CARD', 'Credit card')], max_length=255, default='SITH_ACCOUNT', verbose_name='payment method')), + ('is_validated', models.BooleanField(verbose_name='is validated', default=False)), + ('club', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, null=True, to='club.Club', related_name='sellings')), + ('counter', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, null=True, to='counter.Counter', related_name='sellings')), + ('customer', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, null=True, to='counter.Customer', related_name='buyings')), + ('product', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, null=True, to='counter.Product', related_name='sellings', blank=True)), + ('seller', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, null=True, to=settings.AUTH_USER_MODEL, related_name='sellings_as_operator')), ], options={ 'verbose_name': 'selling', @@ -121,11 +129,21 @@ class Migration(migrations.Migration): migrations.AddField( model_name='product', name='product_type', - field=models.ForeignKey(blank=True, null=True, to='counter.ProductType', related_name='products'), + field=models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, null=True, related_name='products', verbose_name='product type', to='counter.ProductType', blank=True), ), migrations.AddField( model_name='counter', name='products', - field=models.ManyToManyField(to='counter.Product', related_name='counters', blank=True), + field=models.ManyToManyField(to='counter.Product', blank=True, related_name='counters'), + ), + migrations.AddField( + model_name='counter', + name='sellers', + field=models.ManyToManyField(related_name='counters', to='subscription.Subscriber', blank=True, verbose_name='sellers'), + ), + migrations.AddField( + model_name='counter', + name='view_groups', + field=models.ManyToManyField(to='core.Group', blank=True, related_name='viewable_counters'), ), ] diff --git a/eboutic/migrations/0001_initial.py b/eboutic/migrations/0001_initial.py index 684cee8e..820f5344 100644 --- a/eboutic/migrations/0001_initial.py +++ b/eboutic/migrations/0001_initial.py @@ -16,21 +16,21 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Basket', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('date', models.DateTimeField(verbose_name='date', auto_now=True)), - ('user', models.ForeignKey(verbose_name='user', related_name='baskets', to=settings.AUTH_USER_MODEL)), + ('user', models.ForeignKey(verbose_name='user', to=settings.AUTH_USER_MODEL, related_name='baskets')), ], ), migrations.CreateModel( name='BasketItem', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('product_id', models.IntegerField(verbose_name='product id')), - ('product_name', models.CharField(verbose_name='product name', max_length=255)), - ('type', models.CharField(verbose_name='product type', max_length=255)), - ('product_unit_price', accounting.models.CurrencyField(verbose_name='unit price', decimal_places=2, max_digits=12)), + ('product_name', models.CharField(max_length=255, verbose_name='product name')), + ('type_id', models.IntegerField(verbose_name='product type id')), + ('product_unit_price', accounting.models.CurrencyField(decimal_places=2, max_digits=12, verbose_name='unit price')), ('quantity', models.IntegerField(verbose_name='quantity')), - ('basket', models.ForeignKey(verbose_name='basket', related_name='items', to='eboutic.Basket')), + ('basket', models.ForeignKey(verbose_name='basket', to='eboutic.Basket', related_name='items')), ], options={ 'abstract': False, @@ -39,23 +39,22 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Invoice', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('date', models.DateTimeField(verbose_name='date', auto_now=True)), - ('payment_method', models.CharField(verbose_name='payment method', max_length=20, choices=[('CREDIT_CARD', 'Credit card'), ('SITH_ACCOUNT', 'Sith account')])), - ('validated', models.BooleanField(default=False, verbose_name='validated')), - ('user', models.ForeignKey(verbose_name='user', related_name='invoices', to=settings.AUTH_USER_MODEL)), + ('validated', models.BooleanField(verbose_name='validated', default=False)), + ('user', models.ForeignKey(verbose_name='user', to=settings.AUTH_USER_MODEL, related_name='invoices')), ], ), migrations.CreateModel( name='InvoiceItem', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('product_id', models.IntegerField(verbose_name='product id')), - ('product_name', models.CharField(verbose_name='product name', max_length=255)), - ('type', models.CharField(verbose_name='product type', max_length=255)), - ('product_unit_price', accounting.models.CurrencyField(verbose_name='unit price', decimal_places=2, max_digits=12)), + ('product_name', models.CharField(max_length=255, verbose_name='product name')), + ('type_id', models.IntegerField(verbose_name='product type id')), + ('product_unit_price', accounting.models.CurrencyField(decimal_places=2, max_digits=12, verbose_name='unit price')), ('quantity', models.IntegerField(verbose_name='quantity')), - ('invoice', models.ForeignKey(verbose_name='invoice', related_name='items', to='eboutic.Invoice')), + ('invoice', models.ForeignKey(verbose_name='invoice', to='eboutic.Invoice', related_name='items')), ], options={ 'abstract': False, diff --git a/launderette/migrations/0001_initial.py b/launderette/migrations/0001_initial.py index ba9f35b1..82d661a7 100644 --- a/launderette/migrations/0001_initial.py +++ b/launderette/migrations/0001_initial.py @@ -7,14 +7,17 @@ from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ + ('subscription', '0001_initial'), + ('counter', '0001_initial'), ] operations = [ migrations.CreateModel( name='Launderette', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), - ('name', models.CharField(verbose_name='name', max_length=30)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('name', models.CharField(max_length=30, verbose_name='name')), + ('counter', models.OneToOneField(related_name='launderette', verbose_name='counter', to='counter.Counter')), ], options={ 'verbose_name': 'Launderette', @@ -23,10 +26,11 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Machine', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), - ('name', models.CharField(verbose_name='name', max_length=30)), - ('type', models.CharField(verbose_name='type', max_length=10, choices=[('WASHING', 'Washing'), ('DRYING', 'Drying')])), - ('is_working', models.BooleanField(default=True, verbose_name='is working')), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('name', models.CharField(max_length=30, verbose_name='name')), + ('type', models.CharField(choices=[('WASHING', 'Washing'), ('DRYING', 'Drying')], max_length=10, verbose_name='type')), + ('is_working', models.BooleanField(verbose_name='is working', default=True)), + ('launderette', models.ForeignKey(verbose_name='launderette', to='launderette.Launderette', related_name='machines')), ], options={ 'verbose_name': 'Machine', @@ -35,9 +39,10 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Slot', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), ('start_date', models.DateTimeField(verbose_name='start date')), - ('type', models.CharField(verbose_name='type', max_length=10, choices=[('WASHING', 'Washing'), ('DRYING', 'Drying')])), + ('type', models.CharField(choices=[('WASHING', 'Washing'), ('DRYING', 'Drying')], max_length=10, verbose_name='type')), + ('machine', models.ForeignKey(verbose_name='machine', to='launderette.Machine', related_name='slots')), ], options={ 'verbose_name': 'Slot', @@ -47,15 +52,30 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Token', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), - ('name', models.CharField(verbose_name='name', max_length=5)), - ('type', models.CharField(verbose_name='type', max_length=10, choices=[('WASHING', 'Washing'), ('DRYING', 'Drying')])), - ('borrow_date', models.DateTimeField(verbose_name='borrow date', null=True, blank=True)), - ('launderette', models.ForeignKey(verbose_name='launderette', related_name='tokens', to='launderette.Launderette')), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('name', models.CharField(max_length=5, verbose_name='name')), + ('type', models.CharField(choices=[('WASHING', 'Washing'), ('DRYING', 'Drying')], max_length=10, verbose_name='type')), + ('borrow_date', models.DateTimeField(null=True, verbose_name='borrow date', blank=True)), + ('launderette', models.ForeignKey(verbose_name='launderette', to='launderette.Launderette', related_name='tokens')), + ('user', models.ForeignKey(null=True, related_name='tokens', verbose_name='user', to='subscription.Subscriber', blank=True)), ], options={ 'verbose_name': 'Token', 'ordering': ['type', 'name'], }, ), + migrations.AddField( + model_name='slot', + name='token', + field=models.ForeignKey(null=True, related_name='slots', verbose_name='token', to='launderette.Token', blank=True), + ), + migrations.AddField( + model_name='slot', + name='user', + field=models.ForeignKey(verbose_name='user', to='subscription.Subscriber', related_name='slots'), + ), + migrations.AlterUniqueTogether( + name='token', + unique_together=set([('name', 'launderette', 'type')]), + ), ] diff --git a/migrate.py b/migrate.py index f86bcf03..10adda45 100644 --- a/migrate.py +++ b/migrate.py @@ -604,6 +604,32 @@ def migrate_permanencies(): ### Accounting +def migrate_companies(): + cur = db.cursor(MySQLdb.cursors.SSDictCursor) + cur.execute(""" + SELECT * + FROM entreprise + """) + Company.objects.all().delete() + print("Company deleted") + for r in cur: + try: + new = Company( + id=r['id_ent'], + name=to_unicode(r['nom_entreprise']), + street=to_unicode(r['rue_entreprise']), + city=to_unicode(r['ville_entreprise']), + postcode=to_unicode(r['cpostal_entreprise']), + country=to_unicode(r['pays_entreprise']), + phone=to_unicode(r['telephone_entreprise']), + email=to_unicode(r['email_entreprise']), + website=to_unicode(r['siteweb_entreprise']), + ) + new.save() + except Exception as e: + print("FAIL to migrate company: %s" % (repr(e))) + cur.close() + def migrate_bank_accounts(): cur = db.cursor(MySQLdb.cursors.SSDictCursor) cur.execute(""" @@ -838,6 +864,7 @@ def main(): migrate_refillings() migrate_sellings() # Accounting + migrate_companies() migrate_accounting_types() migrate_simpleaccounting_types() migrate_bank_accounts() diff --git a/subscription/migrations/0001_initial.py b/subscription/migrations/0001_initial.py index e8cd0dd1..deaefccf 100644 --- a/subscription/migrations/0001_initial.py +++ b/subscription/migrations/0001_initial.py @@ -15,12 +15,12 @@ class Migration(migrations.Migration): migrations.CreateModel( name='Subscription', fields=[ - ('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)), - ('subscription_type', models.CharField(verbose_name='subscription type', max_length=255, choices=[('cursus-branche', 'Branch cursus'), ('cursus-tronc-commun', 'Common core cursus'), ('deux-semestres', 'Two semesters'), ('un-semestre', 'One semester')])), + ('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)), + ('subscription_type', models.CharField(choices=[('amicale/doceo', 'Amicale/DOCEO member'), ('assidu', 'Assidu member'), ('crous', 'CROUS member'), ('cursus-alternant', 'Branch cursus'), ('cursus-branche', 'Branch cursus'), ('cursus-tronc-commun', 'Common core cursus'), ('deux-semestres', 'Two semesters'), ('membre-honoraire', 'Honorary member'), ('reseau-ut', 'UT network member'), ('sbarro/esta', 'Sbarro/ESTA member'), ('un-semestre', 'One semester')], max_length=255, verbose_name='subscription type')), ('subscription_start', models.DateField(verbose_name='subscription start')), ('subscription_end', models.DateField(verbose_name='subscription end')), - ('payment_method', models.CharField(verbose_name='payment method', max_length=255, choices=[('CHEQUE', 'Check'), ('CASH', 'Cash'), ('OTHER', 'Other')])), - ('location', models.CharField(verbose_name='location', max_length=20, choices=[('BELFORT', 'Belfort'), ('SEVENANS', 'Sevenans'), ('MONTBELIARD', 'Montbéliard')])), + ('payment_method', models.CharField(choices=[('CHECK', 'Check'), ('CARD', 'Credit card'), ('CASH', 'Cash'), ('EBOUTIC', 'Eboutic'), ('OTHER', 'Other')], max_length=255, verbose_name='payment method')), + ('location', models.CharField(choices=[('BELFORT', 'Belfort'), ('SEVENANS', 'Sevenans'), ('MONTBELIARD', 'Montbéliard')], max_length=20, verbose_name='location')), ], options={ 'ordering': ['subscription_start'], @@ -41,6 +41,6 @@ class Migration(migrations.Migration): migrations.AddField( model_name='subscription', name='member', - field=models.ForeignKey(related_name='subscriptions', to='subscription.Subscriber'), + field=models.ForeignKey(to='subscription.Subscriber', related_name='subscriptions'), ), ]