mirror of https://gitlab.crans.org/bde/nk20
Merge branch 'make_the_ci_pass' into 'master'
Make the ci pass See merge request bde/nk20!1
This commit is contained in:
commit
ab616b3f64
15
.coveragerc
15
.coveragerc
|
@ -1,10 +1,11 @@
|
||||||
[run]
|
[run]
|
||||||
source =
|
source =
|
||||||
note_kfet
|
adherents
|
||||||
note_theme
|
note
|
||||||
note_adherents
|
theme
|
||||||
omit =
|
omit =
|
||||||
note_theme/tests/*.py
|
adherents/tests/*.py
|
||||||
note_theme/migrations/*.py
|
adherents/migrations/*.py
|
||||||
note_adherents/tests/*.py
|
note/tests/*.py
|
||||||
note_adherents/migrations/*.py
|
note/migrations/*.py
|
||||||
|
theme/tests/*.py
|
|
@ -11,7 +11,9 @@ from .models import Profile
|
||||||
|
|
||||||
|
|
||||||
class ProfileInline(admin.StackedInline):
|
class ProfileInline(admin.StackedInline):
|
||||||
"""Inline user profile in user admin"""
|
"""
|
||||||
|
Inline user profile in user admin
|
||||||
|
"""
|
||||||
model = Profile
|
model = Profile
|
||||||
can_delete = False
|
can_delete = False
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 2.2.3 on 2019-07-08 11:48
|
# Generated by Django 2.2.3 on 2019-07-16 07:17
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -18,8 +18,14 @@ class Migration(migrations.Migration):
|
||||||
name='Profile',
|
name='Profile',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('phone_number', models.CharField(max_length=255, verbose_name='phone number')),
|
('avatar', models.ImageField(blank=True, max_length=255, upload_to='', verbose_name='profile picture')),
|
||||||
|
('phone_number', models.CharField(blank=True, default='', max_length=50, null=True, verbose_name='phone number')),
|
||||||
('section', models.CharField(help_text='e.g. "1A0", "9A♥", "SAPHIRE"', max_length=255, verbose_name='section')),
|
('section', models.CharField(help_text='e.g. "1A0", "9A♥", "SAPHIRE"', max_length=255, verbose_name='section')),
|
||||||
|
('genre', models.CharField(blank=True, choices=[(None, 'ND'), ('M', 'M'), ('F', 'F')], max_length=1, null=True)),
|
||||||
|
('address', models.TextField(blank=True, null=True)),
|
||||||
|
('paid', models.BooleanField(default=False, verbose_name='paid')),
|
||||||
|
('is_active', models.BooleanField(default=True, verbose_name='is active')),
|
||||||
|
('is_deleted', models.BooleanField(default=False, verbose_name='is deleted')),
|
||||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
|
|
|
@ -17,7 +17,6 @@ class Profile(models.Model):
|
||||||
We do not want to patch the Django Contrib Auth User class
|
We do not want to patch the Django Contrib Auth User class
|
||||||
so this model add an user profile with additional information.
|
so this model add an user profile with additional information.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
GENRES = [
|
GENRES = [
|
||||||
(None, "ND"),
|
(None, "ND"),
|
||||||
("M", "M"),
|
("M", "M"),
|
||||||
|
@ -31,13 +30,12 @@ class Profile(models.Model):
|
||||||
avatar = models.ImageField(
|
avatar = models.ImageField(
|
||||||
max_length=255,
|
max_length=255,
|
||||||
blank=True,
|
blank=True,
|
||||||
verbose_name=_('profile picture')
|
verbose_name=_('profile picture'),
|
||||||
)
|
)
|
||||||
|
|
||||||
phone_number = models.CharField(
|
phone_number = models.CharField(
|
||||||
max_length=50,
|
max_length=50,
|
||||||
blank=True,
|
blank=True,
|
||||||
null=False,
|
null=True,
|
||||||
default='',
|
default='',
|
||||||
verbose_name=_('phone number'),
|
verbose_name=_('phone number'),
|
||||||
)
|
)
|
||||||
|
@ -46,33 +44,33 @@ class Profile(models.Model):
|
||||||
verbose_name=_('section'),
|
verbose_name=_('section'),
|
||||||
help_text=_('e.g. "1A0", "9A♥", "SAPHIRE"'),
|
help_text=_('e.g. "1A0", "9A♥", "SAPHIRE"'),
|
||||||
)
|
)
|
||||||
genre = models.CharField(max_length=1,
|
genre = models.CharField(
|
||||||
blank=False,
|
max_length=1,
|
||||||
null=False,
|
blank=True,
|
||||||
choices=GENRES
|
null=True,
|
||||||
|
choices=GENRES,
|
||||||
)
|
)
|
||||||
address = models.TextField(
|
address = models.TextField(
|
||||||
blank=True,
|
blank=True,
|
||||||
null=False,
|
null=True,
|
||||||
default=''
|
|
||||||
)
|
)
|
||||||
remunere = models.BooleanField(verbose_name=_("rémunéré"),
|
paid = models.BooleanField(
|
||||||
|
verbose_name=_("paid"),
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
is_active = models.BooleanField(verbose_name=_("compte actif"),
|
is_active = models.BooleanField(
|
||||||
default=True
|
verbose_name=_("is active"),
|
||||||
|
default=True,
|
||||||
)
|
)
|
||||||
is_deleted = models.BooleanField(verbose_name=_("compte supprimé"),
|
is_deleted = models.BooleanField(
|
||||||
default=False
|
verbose_name=_("is deleted"),
|
||||||
|
default=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _('user profile')
|
verbose_name = _('user profile')
|
||||||
verbose_name_plural = _('user profile')
|
verbose_name_plural = _('user profile')
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.user.get_username()
|
|
||||||
|
|
||||||
|
|
||||||
class MembershipFee(models.Model):
|
class MembershipFee(models.Model):
|
||||||
"""
|
"""
|
||||||
|
@ -96,12 +94,9 @@ class MembershipFee(models.Model):
|
||||||
verbose_name = _('membership fee')
|
verbose_name = _('membership fee')
|
||||||
verbose_name_plural = _('membership fees')
|
verbose_name_plural = _('membership fees')
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.user.get_username()
|
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_save, sender=User)
|
@receiver(post_save, sender=User)
|
||||||
def save_user_profile(sender, instance, created, **_kwargs):
|
def save_user_profile(instance, created, **_kwargs):
|
||||||
"""
|
"""
|
||||||
Hook to save an user profile when an user is updated
|
Hook to save an user profile when an user is updated
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2018-2019 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
default_app_config = 'note.apps.NoteConfig'
|
|
@ -2,6 +2,7 @@ from django.contrib import admin
|
||||||
|
|
||||||
from .models import NoteClub, NoteSpec, NoteUser
|
from .models import NoteClub, NoteSpec, NoteUser
|
||||||
from .models import Alias
|
from .models import Alias
|
||||||
|
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
admin.site.register(NoteClub)
|
admin.site.register(NoteClub)
|
||||||
admin.site.register(NoteSpec)
|
admin.site.register(NoteSpec)
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
|
# -*- mode: python; coding: utf-8 -*-
|
||||||
|
# Copyright (C) 2018-2019 by BDE ENS Paris-Saclay
|
||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from django.apps import AppConfig
|
from django.apps import AppConfig
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
|
||||||
class NoteConfig(AppConfig):
|
class NoteConfig(AppConfig):
|
||||||
name = 'note'
|
name = 'note'
|
||||||
|
verbose_name = _('note')
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 2.2.3 on 2019-07-08 14:08
|
# Generated by Django 2.2.3 on 2019-07-16 07:17
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
@ -19,8 +19,8 @@ class Migration(migrations.Migration):
|
||||||
name='NoteClub',
|
name='NoteClub',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('solde', models.IntegerField(help_text="en centime, l' argent crédité pour cette instance", verbose_name='solde du compte')),
|
('balance', models.DecimalField(decimal_places=2, default=0, help_text='money credited for this instance', max_digits=8, verbose_name='account balance')),
|
||||||
('active', models.BooleanField(default=True, verbose_name='etat du compte')),
|
('is_active', models.BooleanField(default=True, verbose_name='is active')),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'abstract': False,
|
'abstract': False,
|
||||||
|
@ -30,9 +30,9 @@ class Migration(migrations.Migration):
|
||||||
name='NoteSpec',
|
name='NoteSpec',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('solde', models.IntegerField(help_text="en centime, l' argent crédité pour cette instance", verbose_name='solde du compte')),
|
('balance', models.DecimalField(decimal_places=2, default=0, help_text='money credited for this instance', max_digits=8, verbose_name='account balance')),
|
||||||
('active', models.BooleanField(default=True, verbose_name='etat du compte')),
|
('is_active', models.BooleanField(default=True, verbose_name='is active')),
|
||||||
('account_type', models.CharField(choices=[('CH', 'chèques'), ('CB', 'Carte Bancaire'), ('VB', 'Virement Bancaire'), ('CA', 'Cash'), ('RB', 'Remboursement')], max_length=2, unique=True)),
|
('account_type', models.CharField(choices=[('CH', 'bank check'), ('CB', 'credit card'), ('VB', 'bank transfer'), ('CA', 'cash'), ('RB', 'refund')], max_length=2, unique=True)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'abstract': False,
|
'abstract': False,
|
||||||
|
@ -42,13 +42,13 @@ class Migration(migrations.Migration):
|
||||||
name='NoteUser',
|
name='NoteUser',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('solde', models.IntegerField(help_text="en centime, l' argent crédité pour cette instance", verbose_name='solde du compte')),
|
('balance', models.DecimalField(decimal_places=2, default=0, help_text='money credited for this instance', max_digits=8, verbose_name='account balance')),
|
||||||
('active', models.BooleanField(default=True, verbose_name='etat du compte')),
|
('is_active', models.BooleanField(default=True, verbose_name='is active')),
|
||||||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'verbose_name': "One's Note",
|
'verbose_name': "one's note",
|
||||||
'verbose_name_plural': 'Users Note',
|
'verbose_name_plural': 'users note',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
|
|
|
@ -21,67 +21,69 @@ class Alias(models.Model):
|
||||||
blank=False,
|
blank=False,
|
||||||
null=False,
|
null=False,
|
||||||
)
|
)
|
||||||
limit = models.Q(app_label="note", model="NoteUser") | models.Q(app_label="note",model="NoteClub")
|
|
||||||
|
|
||||||
|
# Owner can be linked to an user note or a club note
|
||||||
|
limit = models.Q(app_label="note", model="NoteUser") | models.Q(app_label="note", model="NoteClub")
|
||||||
owner_id = models.PositiveIntegerField()
|
owner_id = models.PositiveIntegerField()
|
||||||
owner_type = models.ForeignKey(ContentType,
|
owner_type = models.ForeignKey(
|
||||||
|
ContentType,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
limit_choices_to=limit)
|
limit_choices_to=limit
|
||||||
|
)
|
||||||
owner = GenericForeignKey('owner_type', 'owner_id')
|
owner = GenericForeignKey('owner_type', 'owner_id')
|
||||||
|
|
||||||
|
|
||||||
class Note(models.Model):
|
class Note(models.Model):
|
||||||
"""
|
"""
|
||||||
An abstract model, use to add transactions capabilities to a user
|
An abstract model, use to add transactions capabilities to a user
|
||||||
"""
|
"""
|
||||||
|
balance = models.DecimalField(
|
||||||
solde = models.IntegerField(
|
verbose_name=_('account balance'),
|
||||||
verbose_name=_('solde du compte'),
|
help_text=_("money credited for this instance"),
|
||||||
help_text=_("en centime, l' argent crédité pour cette instance")
|
decimal_places=2, # Limit to centimes
|
||||||
|
max_digits=8, # Limit to 999999,99€
|
||||||
|
default=0,
|
||||||
)
|
)
|
||||||
active = models.BooleanField(
|
is_active = models.BooleanField(
|
||||||
default=True,
|
default=True,
|
||||||
verbose_name=_('etat du compte')
|
verbose_name=_('is active')
|
||||||
)
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
|
|
||||||
class NoteUser(Note):
|
class NoteUser(Note):
|
||||||
"""
|
"""
|
||||||
A Note associated to a User
|
A Note associated to an User
|
||||||
"""
|
"""
|
||||||
user = models.OneToOneField(
|
user = models.OneToOneField(
|
||||||
settings.AUTH_USER_MODEL,
|
settings.AUTH_USER_MODEL,
|
||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
)
|
)
|
||||||
class Meta:
|
|
||||||
verbose_name = _("One's Note")
|
|
||||||
verbose_name_plural = _("Users Note")
|
|
||||||
|
|
||||||
def __str__(self):
|
class Meta:
|
||||||
return self.user.get_username()
|
verbose_name = _("one's note")
|
||||||
|
verbose_name_plural = _("users note")
|
||||||
|
|
||||||
|
|
||||||
class NoteSpec(Note):
|
class NoteSpec(Note):
|
||||||
"""
|
"""
|
||||||
A Note for special Account, where real money enter or leave the system.
|
A Note for special account, where real money enter or leave the system
|
||||||
- Cash
|
|
||||||
- Credit Card
|
|
||||||
- Bank Transfert
|
|
||||||
- Bank Check
|
|
||||||
- Refund
|
|
||||||
"""
|
"""
|
||||||
account_type = models.CharField(
|
account_type = models.CharField(
|
||||||
max_length=2,
|
max_length=2,
|
||||||
choices = (("CH","chèques"),
|
choices=(
|
||||||
("CB","Carte Bancaire"),
|
("CH", _("bank check")),
|
||||||
("VB","Virement Bancaire"),
|
("CB", _("credit card")),
|
||||||
("CA","Cash"),
|
("VB", _("bank transfer")),
|
||||||
("RB","Remboursement")
|
("CA", _("cash")),
|
||||||
|
("RB", _("refund")),
|
||||||
),
|
),
|
||||||
unique = True
|
unique=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class NoteClub(Note):
|
class NoteClub(Note):
|
||||||
# to be added
|
# to be added
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
|
@ -1,3 +0,0 @@
|
||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
|
Loading…
Reference in New Issue