mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-25 10:34:21 +00:00
Fix tests
This commit is contained in:
parent
e5c085c706
commit
b4c3f2f4dc
@ -2,32 +2,41 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import accounting.models
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
import accounting.models
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('club', '__first__'),
|
|
||||||
('core', '0001_initial'),
|
('core', '0001_initial'),
|
||||||
|
('club', '0001_initial'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='AccountingType',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
|
||||||
|
('code', models.CharField(max_length=16, verbose_name='code')),
|
||||||
|
('label', models.CharField(max_length=60, verbose_name='label')),
|
||||||
|
('movement_type', models.CharField(max_length=12, verbose_name='movement type', choices=[('credit', 'Credit'), ('debit', 'Debit'), ('neutral', 'Neutral')])),
|
||||||
|
],
|
||||||
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='BankAccount',
|
name='BankAccount',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, verbose_name='ID', serialize=False, primary_key=True)),
|
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
|
||||||
('name', models.CharField(verbose_name='name', max_length=30)),
|
('name', models.CharField(max_length=30, verbose_name='name')),
|
||||||
('rib', models.CharField(verbose_name='rib', max_length=255)),
|
('rib', models.CharField(max_length=255, verbose_name='rib', blank=True)),
|
||||||
('number', models.CharField(verbose_name='account number', max_length=255)),
|
('number', models.CharField(max_length=255, verbose_name='account number', blank=True)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='ClubAccount',
|
name='ClubAccount',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, verbose_name='ID', serialize=False, primary_key=True)),
|
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
|
||||||
('name', models.CharField(verbose_name='name', max_length=30)),
|
('name', models.CharField(max_length=30, verbose_name='name')),
|
||||||
('bank_account', models.ForeignKey(related_name='club_accounts', to='accounting.BankAccount')),
|
('bank_account', models.ForeignKey(related_name='club_accounts', to='accounting.BankAccount')),
|
||||||
('club', models.OneToOneField(related_name='club_accounts', to='club.Club')),
|
('club', models.OneToOneField(related_name='club_accounts', to='club.Club')),
|
||||||
],
|
],
|
||||||
@ -35,8 +44,8 @@ class Migration(migrations.Migration):
|
|||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Customer',
|
name='Customer',
|
||||||
fields=[
|
fields=[
|
||||||
('user', models.OneToOneField(primary_key=True, to=settings.AUTH_USER_MODEL, serialize=False)),
|
('user', models.OneToOneField(to=settings.AUTH_USER_MODEL, primary_key=True, serialize=False)),
|
||||||
('account_id', models.CharField(verbose_name='account id', unique=True, max_length=10)),
|
('account_id', models.CharField(max_length=10, verbose_name='account id', unique=True)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'verbose_name_plural': 'customers',
|
'verbose_name_plural': 'customers',
|
||||||
@ -46,10 +55,10 @@ class Migration(migrations.Migration):
|
|||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='GeneralJournal',
|
name='GeneralJournal',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, verbose_name='ID', serialize=False, primary_key=True)),
|
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
|
||||||
('start_date', models.DateField(verbose_name='start date')),
|
('start_date', models.DateField(verbose_name='start date')),
|
||||||
('end_date', models.DateField(default=None, verbose_name='end date', null=True, blank=True)),
|
('end_date', models.DateField(null=True, default=None, verbose_name='end date', blank=True)),
|
||||||
('name', models.CharField(verbose_name='name', max_length=30)),
|
('name', models.CharField(max_length=30, verbose_name='name')),
|
||||||
('closed', models.BooleanField(default=False, verbose_name='is closed')),
|
('closed', models.BooleanField(default=False, verbose_name='is closed')),
|
||||||
('club_account', models.ForeignKey(related_name='journals', to='accounting.ClubAccount')),
|
('club_account', models.ForeignKey(related_name='journals', to='accounting.ClubAccount')),
|
||||||
],
|
],
|
||||||
@ -57,36 +66,42 @@ class Migration(migrations.Migration):
|
|||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Operation',
|
name='Operation',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, verbose_name='ID', serialize=False, primary_key=True)),
|
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
|
||||||
('name', models.CharField(verbose_name='name', max_length=100)),
|
('date', models.DateField(verbose_name='date')),
|
||||||
|
('remark', models.TextField(max_length=255, verbose_name='remark')),
|
||||||
|
('mode', models.CharField(max_length=255, verbose_name='payment method', choices=[('cheque', 'Chèque'), ('cash', 'Espèce'), ('transfert', 'Virement'), ('card', 'Carte banquaire')])),
|
||||||
|
('cheque_number', models.IntegerField(verbose_name='cheque number')),
|
||||||
|
('invoice', models.FileField(null=True, upload_to='invoices', blank=True)),
|
||||||
|
('done', models.BooleanField(default=False, verbose_name='is done')),
|
||||||
('journal', models.ForeignKey(related_name='invoices', to='accounting.GeneralJournal')),
|
('journal', models.ForeignKey(related_name='invoices', to='accounting.GeneralJournal')),
|
||||||
|
('type', models.ForeignKey(related_name='operations', to='accounting.AccountingType')),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Product',
|
name='Product',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, verbose_name='ID', serialize=False, primary_key=True)),
|
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
|
||||||
('name', models.CharField(verbose_name='name', max_length=30)),
|
('name', models.CharField(max_length=30, verbose_name='name')),
|
||||||
('description', models.TextField(blank=True, verbose_name='description')),
|
('description', models.TextField(verbose_name='description', blank=True)),
|
||||||
('code', models.CharField(verbose_name='code', max_length=10)),
|
('code', models.CharField(max_length=10, verbose_name='code')),
|
||||||
('purchase_price', accounting.models.CurrencyField(verbose_name='purchase price', decimal_places=2, max_digits=12)),
|
('purchase_price', accounting.models.CurrencyField(max_digits=12, decimal_places=2, verbose_name='purchase price')),
|
||||||
('selling_price', accounting.models.CurrencyField(verbose_name='selling price', decimal_places=2, max_digits=12)),
|
('selling_price', accounting.models.CurrencyField(max_digits=12, decimal_places=2, verbose_name='selling price')),
|
||||||
('special_selling_price', accounting.models.CurrencyField(verbose_name='special selling price', decimal_places=2, max_digits=12)),
|
('special_selling_price', accounting.models.CurrencyField(max_digits=12, decimal_places=2, verbose_name='special selling price')),
|
||||||
('icon', models.ImageField(blank=True, null=True, upload_to='products')),
|
('icon', models.ImageField(null=True, upload_to='products', blank=True)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='ProductType',
|
name='ProductType',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, verbose_name='ID', serialize=False, primary_key=True)),
|
('id', models.AutoField(primary_key=True, auto_created=True, serialize=False, verbose_name='ID')),
|
||||||
('name', models.CharField(verbose_name='name', max_length=30)),
|
('name', models.CharField(max_length=30, verbose_name='name')),
|
||||||
('description', models.TextField(blank=True, verbose_name='description', null=True)),
|
('description', models.TextField(null=True, verbose_name='description', blank=True)),
|
||||||
('icon', models.ImageField(blank=True, null=True, upload_to='products')),
|
('icon', models.ImageField(null=True, upload_to='products', blank=True)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='product',
|
model_name='product',
|
||||||
name='product_type',
|
name='product_type',
|
||||||
field=models.ForeignKey(blank=True, related_name='products', null=True, to='accounting.ProductType'),
|
field=models.ForeignKey(null=True, to='accounting.ProductType', related_name='products', blank=True),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('accounting', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='bankaccount',
|
|
||||||
name='number',
|
|
||||||
field=models.CharField(max_length=255, blank=True, verbose_name='account number'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='bankaccount',
|
|
||||||
name='rib',
|
|
||||||
field=models.CharField(max_length=255, blank=True, verbose_name='rib'),
|
|
||||||
),
|
|
||||||
]
|
|
@ -40,7 +40,6 @@ Welcome to the wiki page!
|
|||||||
|
|
||||||
# Here we add a lot of test datas, that are not necessary for the Sith, but that provide a basic development environment
|
# Here we add a lot of test datas, that are not necessary for the Sith, but that provide a basic development environment
|
||||||
if not options['prod']:
|
if not options['prod']:
|
||||||
print("Dev mode, adding some test data")
|
|
||||||
# Adding user Skia
|
# Adding user Skia
|
||||||
s = User(username='skia', last_name="Kia", first_name="S'",
|
s = User(username='skia', last_name="Kia", first_name="S'",
|
||||||
email="skia@git.an",
|
email="skia@git.an",
|
||||||
@ -95,14 +94,14 @@ Cette page vise à documenter la syntaxe *Markdown* utilisée sur le site.
|
|||||||
guyut = Club(name="Guy'UT", unix_name="guyut",
|
guyut = Club(name="Guy'UT", unix_name="guyut",
|
||||||
address="42 de la Boustifaille", parent=ae)
|
address="42 de la Boustifaille", parent=ae)
|
||||||
guyut.save()
|
guyut.save()
|
||||||
troll = Club(name="Troll Penché", unix_name="troll",
|
|
||||||
address="Terre Du Milieu", parent=ae)
|
|
||||||
troll.save()
|
|
||||||
Club(name="Woenzel'UT", unix_name="woenzel",
|
Club(name="Woenzel'UT", unix_name="woenzel",
|
||||||
address="Woenzel", parent=guyut).save()
|
address="Woenzel", parent=guyut).save()
|
||||||
Club(name="BdF", unix_name="bdf",
|
Club(name="BdF", unix_name="bdf",
|
||||||
address="Guyéuéyuéyuyé").save()
|
address="Guyéuéyuéyuyé").save()
|
||||||
Membership(user=s, club=ae, role=3, description="").save()
|
Membership(user=s, club=ae, role=3, description="").save()
|
||||||
|
troll = Club(name="Troll Penché", unix_name="troll",
|
||||||
|
address="Terre Du Milieu", parent=ae)
|
||||||
|
troll.save()
|
||||||
|
|
||||||
# Accounting test values:
|
# Accounting test values:
|
||||||
Customer(user=s, account_id="6568j").save()
|
Customer(user=s, account_id="6568j").save()
|
||||||
|
@ -128,24 +128,25 @@ class User(AbstractBaseUser, PermissionsMixin):
|
|||||||
if group_name == settings.SITH_GROUPS['public']['name']:
|
if group_name == settings.SITH_GROUPS['public']['name']:
|
||||||
return True
|
return True
|
||||||
if group_name == settings.SITH_MAIN_MEMBERS_GROUP: # We check the subscription if asked
|
if group_name == settings.SITH_MAIN_MEMBERS_GROUP: # We check the subscription if asked
|
||||||
try: # TODO: change for a test in settings.INSTALLED_APP
|
if 'subscription' in settings.INSTALLED_APPS:
|
||||||
from subscription import Subscriber
|
from subscription import Subscriber
|
||||||
s = Subscriber.objects.filter(pk=self.pk).first()
|
s = Subscriber.objects.filter(pk=self.pk).first()
|
||||||
if s is not None and s.is_subscribed():
|
if s is not None and s.is_subscribed():
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
except Exception as e:
|
else:
|
||||||
print(e)
|
|
||||||
return False
|
return False
|
||||||
if group_name[-6:] == settings.SITH_BOARD_SUFFIX:
|
if group_name[-6:] == settings.SITH_BOARD_SUFFIX:
|
||||||
try: # TODO: change for a test in settings.INSTALLED_APP
|
if 'club' in settings.INSTALLED_APPS:
|
||||||
from club.models import Club
|
from club.models import Club
|
||||||
name = group_name[:-6]
|
name = group_name[:-6]
|
||||||
c = Club.objects.filter(unix_name=name).first()
|
c = Club.objects.filter(unix_name=name).first()
|
||||||
return c.get_membership_for(self).role >= 2
|
mem = c.get_membership_for(self)
|
||||||
except Exception as e:
|
if mem:
|
||||||
print(e)
|
return mem.role >= 2
|
||||||
|
return False
|
||||||
|
else:
|
||||||
return False
|
return False
|
||||||
return self.groups.filter(name=group_name).exists()
|
return self.groups.filter(name=group_name).exists()
|
||||||
|
|
||||||
|
@ -8,21 +8,21 @@ class Migration(migrations.Migration):
|
|||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('club', '0001_initial'),
|
('club', '0001_initial'),
|
||||||
('accounting', '0001_initial'),
|
|
||||||
('core', '0001_initial'),
|
('core', '0001_initial'),
|
||||||
|
('accounting', '0001_initial'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Counter',
|
name='Counter',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(primary_key=True, serialize=False, verbose_name='ID', auto_created=True)),
|
('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True, serialize=False)),
|
||||||
('name', models.CharField(max_length=30, verbose_name='name')),
|
('name', models.CharField(max_length=30, verbose_name='name')),
|
||||||
('type', models.CharField(max_length=255, verbose_name='subscription type', choices=[('BAR', 'Bar'), ('OFFICE', 'Office')])),
|
('type', models.CharField(max_length=255, verbose_name='subscription type', choices=[('BAR', 'Bar'), ('OFFICE', 'Office')])),
|
||||||
('club', models.ForeignKey(to='club.Club', related_name='counters')),
|
('club', models.ForeignKey(to='club.Club', related_name='counters')),
|
||||||
('edit_groups', models.ManyToManyField(to='core.Group', blank=True, related_name='editable_counters')),
|
('edit_groups', models.ManyToManyField(blank=True, related_name='editable_counters', to='core.Group')),
|
||||||
('products', models.ManyToManyField(to='accounting.Product', blank=True, related_name='counters')),
|
('products', models.ManyToManyField(blank=True, related_name='counters', to='accounting.Product')),
|
||||||
('view_groups', models.ManyToManyField(to='core.Group', blank=True, related_name='viewable_counters')),
|
('view_groups', models.ManyToManyField(blank=True, related_name='viewable_counters', to='core.Group')),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user