Commit a2767b9f authored by Gabriel Detraz's avatar Gabriel Detraz Committed by root
Browse files

Fork de re2o pour gérer basiquement les serveurs de l'ARES

parent 5c14ac1f
from django.contrib import admin
from reversion.admin import VersionAdmin
from .models import Facture, Article, Banque, Paiement, Cotisation, Vente
class FactureAdmin(VersionAdmin):
list_display = ('user','paiement','date','valid','control')
class VenteAdmin(VersionAdmin):
list_display = ('facture','name','prix','number','iscotisation','duration')
class ArticleAdmin(VersionAdmin):
list_display = ('name','prix','iscotisation','duration')
class BanqueAdmin(VersionAdmin):
list_display = ('name',)
class PaiementAdmin(VersionAdmin):
list_display = ('moyen',)
class CotisationAdmin(VersionAdmin):
list_display = ('vente','date_start','date_end')
admin.site.register(Facture, FactureAdmin)
admin.site.register(Article, ArticleAdmin)
admin.site.register(Banque, BanqueAdmin)
admin.site.register(Paiement, PaiementAdmin)
admin.site.register(Vente, VenteAdmin)
admin.site.register(Cotisation, CotisationAdmin)
from django import forms
from django.forms import ModelForm, Form
from django import forms
from django.core.validators import MinValueValidator
from .models import Article, Paiement, Facture, Banque, Vente
class NewFactureForm(ModelForm):
def __init__(self, *args, **kwargs):
super(NewFactureForm, self).__init__(*args, **kwargs)
self.fields['cheque'].required = False
self.fields['banque'].required = False
self.fields['cheque'].label = 'Numero de chèque'
self.fields['banque'].empty_label = "Non renseigné"
self.fields['paiement'].empty_label = "Séléctionner un moyen de paiement"
class Meta:
model = Facture
fields = ['paiement','banque','cheque']
def clean(self):
cleaned_data=super(NewFactureForm, self).clean()
paiement = cleaned_data.get("paiement")
cheque = cleaned_data.get("cheque")
banque = cleaned_data.get("banque")
if not paiement:
raise forms.ValidationError("Le moyen de paiement est obligatoire")
elif paiement.moyen=="chèque" and not (cheque and banque):
raise forms.ValidationError("Le numero de chèque et la banque sont obligatoires")
return cleaned_data
class SelectArticleForm(Form):
article = forms.ModelChoiceField(queryset=Article.objects.all(), label="Article", required=True)
quantity = forms.IntegerField(label="Quantité", validators=[MinValueValidator(1)], required=True)
class NewFactureFormPdf(Form):
article = forms.ModelMultipleChoiceField(queryset=Article.objects.all(), label="Article")
number = forms.IntegerField(label="Quantité", validators=[MinValueValidator(1)])
paid = forms.BooleanField(label="Payé", required=False)
dest = forms.CharField(required=True, max_length=255, label="Destinataire")
chambre = forms.CharField(required=False, max_length=10, label="Adresse")
fid = forms.CharField(required=True, max_length=10, label="Numéro de la facture")
class EditFactureForm(NewFactureForm):
class Meta(NewFactureForm.Meta):
fields = ['paiement','banque','cheque','user']
def __init__(self, *args, **kwargs):
super(EditFactureForm, self).__init__(*args, **kwargs)
self.fields['user'].label = 'Adherent'
self.fields['user'].empty_label = "Séléctionner l'adhérent propriétaire"
class TrezEditFactureForm(EditFactureForm):
class Meta(EditFactureForm.Meta):
fields = '__all__'
def __init__(self, *args, **kwargs):
super(TrezEditFactureForm, self).__init__(*args, **kwargs)
self.fields['valid'].label = 'Validité de la facture'
self.fields['control'].label = 'Controle de la facture'
class ArticleForm(ModelForm):
class Meta:
model = Article
fields = '__all__'
def __init__(self, *args, **kwargs):
super(ArticleForm, self).__init__(*args, **kwargs)
self.fields['name'].label = "Désignation de l'article"
class DelArticleForm(ModelForm):
articles = forms.ModelMultipleChoiceField(queryset=Article.objects.all(), label="Articles actuels", widget=forms.CheckboxSelectMultiple)
class Meta:
fields = ['articles']
model = Article
class PaiementForm(ModelForm):
class Meta:
model = Paiement
fields = ['moyen']
def __init__(self, *args, **kwargs):
super(PaiementForm, self).__init__(*args, **kwargs)
self.fields['moyen'].label = 'Moyen de paiement à ajouter'
class DelPaiementForm(ModelForm):
paiements = forms.ModelMultipleChoiceField(queryset=Paiement.objects.all(), label="Moyens de paiement actuels", widget=forms.CheckboxSelectMultiple)
class Meta:
exclude = ['moyen']
model = Paiement
class BanqueForm(ModelForm):
class Meta:
model = Banque
fields = ['name']
def __init__(self, *args, **kwargs):
super(BanqueForm, self).__init__(*args, **kwargs)
self.fields['name'].label = 'Banque à ajouter'
class DelBanqueForm(ModelForm):
banques = forms.ModelMultipleChoiceField(queryset=Banque.objects.all(), label="Banques actuelles", widget=forms.CheckboxSelectMultiple)
class Meta:
exclude = ['name']
model = Banque
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('users', '0005_auto_20160702_0006'),
]
operations = [
migrations.CreateModel(
name='Article',
fields=[
('id', models.AutoField(verbose_name='ID', auto_created=True, primary_key=True, serialize=False)),
('name', models.CharField(max_length=255)),
('prix', models.DecimalField(decimal_places=2, max_digits=5)),
],
),
migrations.CreateModel(
name='Banque',
fields=[
('id', models.AutoField(verbose_name='ID', auto_created=True, primary_key=True, serialize=False)),
('name', models.CharField(max_length=255)),
],
),
migrations.CreateModel(
name='Facture',
fields=[
('id', models.AutoField(verbose_name='ID', auto_created=True, primary_key=True, serialize=False)),
('cheque', models.CharField(max_length=255)),
('number', models.IntegerField()),
('date', models.DateTimeField(auto_now_add=True)),
('name', models.CharField(max_length=255)),
('prix', models.DecimalField(decimal_places=2, max_digits=5)),
('article', models.ForeignKey(to='cotisations.Article', on_delete=django.db.models.deletion.PROTECT)),
('banque', models.ForeignKey(to='cotisations.Banque', on_delete=django.db.models.deletion.PROTECT)),
],
),
migrations.CreateModel(
name='Paiement',
fields=[
('id', models.AutoField(verbose_name='ID', auto_created=True, primary_key=True, serialize=False)),
('moyen', models.CharField(max_length=255)),
],
),
migrations.AddField(
model_name='facture',
name='paiement',
field=models.ForeignKey(to='cotisations.Paiement', on_delete=django.db.models.deletion.PROTECT),
),
migrations.AddField(
model_name='facture',
name='user',
field=models.ForeignKey(to='users.User', on_delete=django.db.models.deletion.PROTECT),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='facture',
name='article',
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0002_remove_facture_article'),
]
operations = [
migrations.AlterField(
model_name='facture',
name='banque',
field=models.ForeignKey(blank=True, to='cotisations.Banque', on_delete=django.db.models.deletion.PROTECT, null=True),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0003_auto_20160702_1448'),
]
operations = [
migrations.AlterField(
model_name='facture',
name='name',
field=models.CharField(null=True, max_length=255),
),
migrations.AlterField(
model_name='facture',
name='prix',
field=models.DecimalField(max_digits=5, null=True, decimal_places=2),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0004_auto_20160702_1528'),
]
operations = [
migrations.AlterField(
model_name='facture',
name='cheque',
field=models.CharField(max_length=255, blank=True),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0005_auto_20160702_1532'),
]
operations = [
migrations.AlterField(
model_name='facture',
name='name',
field=models.CharField(null=True, default='plop', max_length=255),
),
migrations.AlterField(
model_name='facture',
name='prix',
field=models.DecimalField(null=True, decimal_places=2, default=1, max_digits=5),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0006_auto_20160702_1534'),
]
operations = [
migrations.AlterField(
model_name='facture',
name='name',
field=models.CharField(default='plop', max_length=255),
preserve_default=False,
),
migrations.AlterField(
model_name='facture',
name='prix',
field=models.DecimalField(default=1, max_digits=5, decimal_places=2),
preserve_default=False,
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('users', '0005_auto_20160702_0006'),
('cotisations', '0007_auto_20160702_1543'),
]
operations = [
migrations.CreateModel(
name='Cotisation',
fields=[
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
('date_start', models.DateTimeField(auto_now_add=True)),
('date_end', models.DateTimeField()),
],
),
migrations.AddField(
model_name='article',
name='cotisation',
field=models.BooleanField(default=True),
preserve_default=False,
),
migrations.AddField(
model_name='article',
name='duration',
field=models.DurationField(blank=True, null=True),
),
migrations.AddField(
model_name='facture',
name='valid',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='cotisation',
name='facture',
field=models.ForeignKey(to='cotisations.Facture', on_delete=django.db.models.deletion.PROTECT),
),
migrations.AddField(
model_name='cotisation',
name='user',
field=models.ForeignKey(to='users.User', on_delete=django.db.models.deletion.PROTECT),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0008_auto_20160702_1614'),
]
operations = [
migrations.RemoveField(
model_name='cotisation',
name='user',
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0009_remove_cotisation_user'),
]
operations = [
migrations.AlterField(
model_name='article',
name='duration',
field=models.IntegerField(null=True, help_text='Durée exprimée en mois entiers', blank=True),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0010_auto_20160702_1840'),
]
operations = [
migrations.AlterField(
model_name='cotisation',
name='date_start',
field=models.DateTimeField(),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0011_auto_20160702_1911'),
]
operations = [
migrations.AlterField(
model_name='cotisation',
name='facture',
field=models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, to='cotisations.Facture'),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0012_auto_20160704_0118'),
]
operations = [
migrations.CreateModel(
name='Vente',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=255)),
('prix', models.DecimalField(decimal_places=2, max_digits=5)),
('cotisation', models.BooleanField()),
('duration', models.IntegerField(null=True, blank=True, help_text='Durée exprimée en mois entiers')),
],
),
migrations.RemoveField(
model_name='facture',
name='name',
),
migrations.RemoveField(
model_name='facture',
name='prix',
),
migrations.AddField(
model_name='vente',
name='facture',
field=models.ForeignKey(to='cotisations.Facture', on_delete=django.db.models.deletion.PROTECT),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0013_auto_20160711_2240'),
]
operations = [
migrations.RemoveField(
model_name='facture',
name='number',
),
migrations.AddField(
model_name='vente',
name='number',
field=models.IntegerField(default=1),
preserve_default=False,
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.core.validators
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0014_auto_20160712_0245'),
]
operations = [
migrations.AddField(
model_name='facture',
name='control',
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name='cotisation',
name='facture',
field=models.OneToOneField(to='cotisations.Facture'),
),
migrations.AlterField(
model_name='vente',
name='facture',
field=models.ForeignKey(to='cotisations.Facture'),
),
migrations.AlterField(
model_name='vente',
name='number',
field=models.IntegerField(validators=[django.core.validators.MinValueValidator(1)]),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cotisations', '0015_auto_20160714_2142'),
]
operations = [
migrations.Re