3
0
Fork 0
mirror of https://github.com/nanoy42/coope synced 2024-11-22 03:13:12 +00:00
This commit is contained in:
Yoann Pétri 2019-02-27 08:59:41 +01:00
parent eabf4cdb2b
commit 84e2a529c6
9 changed files with 617 additions and 60 deletions

View file

@ -3,12 +3,63 @@ from simple_history.admin import SimpleHistoryAdmin
from .models import Reload, Refund, Product, Keg, ConsumptionHistory, KegHistory, Consumption, Menu, MenuHistory from .models import Reload, Refund, Product, Keg, ConsumptionHistory, KegHistory, Consumption, Menu, MenuHistory
admin.site.register(Reload, SimpleHistoryAdmin) class ConsumptionAdmin(SimpleHistoryAdmin):
admin.site.register(Refund, SimpleHistoryAdmin) list_display = ('customer', 'product', 'quantity')
admin.site.register(Product, SimpleHistoryAdmin) ordering = ('-quantity', )
admin.site.register(Keg, SimpleHistoryAdmin) search_fields = ('customer', 'product')
admin.site.register(ConsumptionHistory, SimpleHistoryAdmin)
admin.site.register(KegHistory, SimpleHistoryAdmin) class ConsumptionHistoryAdmin(SimpleHistoryAdmin):
admin.site.register(Consumption, SimpleHistoryAdmin) list_display = ('customer', 'product', 'quantity', 'paymentMethod', 'date', 'amount')
admin.site.register(Menu, SimpleHistoryAdmin) ordering = ('-date', )
admin.site.register(MenuHistory, SimpleHistoryAdmin) search_fields = ('customer', 'product')
list_filter = ('paymentMethod',)
class KegAdmin(SimpleHistoryAdmin):
list_display = ('name', 'stockHold', 'capacity', 'is_active')
ordering = ('name', )
search_fields = ('name',)
list_filter = ('capacity', 'is_active')
class KegHistoryAdmin(SimpleHistoryAdmin):
list_display = ('keg', 'openingDate', 'closingDate', 'isCurrentKegHistory', 'quantitySold')
ordering = ('-openingDate', 'quantitySold')
search_fields = ('keg',)
list_filter = ('isCurrentKegHistory', 'keg')
class MenuHistoryAdmin(SimpleHistoryAdmin):
list_display = ('customer', 'menu', 'paymentMethod', 'date', 'quantity', 'amount')
ordering = ('-date',)
search_fields = ('customer', 'menu')
class MenuAdmin(SimpleHistoryAdmin):
list_display = ('name', 'amount', 'is_active')
ordering = ('name', 'amount')
search_fields = ('name',)
list_filter = ('is_active', )
class ProductAdmin(SimpleHistoryAdmin):
list_display = ('name', 'amount', 'is_active', 'category', 'adherentRequired', 'stockHold', 'stockBar', 'volume', 'deg')
ordering = ('name', 'amount', 'stockHold', 'stockBar', 'deg')
search_fields = ('name',)
list_filter = ('is_active', 'adherentRequired', 'category')
class ReloadAdmin(SimpleHistoryAdmin):
list_display = ('customer', 'amount', 'date', 'PaymentMethod')
ordering = ('-date', 'amount', 'customer')
search_fields = ('customer',)
list_filter = ('PaymentMethod', )
class RefundAdmin(SimpleHistoryAdmin):
list_display = ('customer', 'amount', 'date')
ordering = ('-date', 'amount', 'customer')
search_fields = ('customer',)
admin.site.register(Reload, ReloadAdmin)
admin.site.register(Refund, RefundAdmin)
admin.site.register(Product, ProductAdmin)
admin.site.register(Keg, KegAdmin)
admin.site.register(ConsumptionHistory, ConsumptionHistoryAdmin)
admin.site.register(KegHistory, KegHistoryAdmin)
admin.site.register(Consumption, ConsumptionAdmin)
admin.site.register(Menu, MenuAdmin)
admin.site.register(MenuHistory, MenuHistoryAdmin)

View file

@ -0,0 +1,165 @@
# Generated by Django 2.1 on 2019-02-27 07:59
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('gestion', '0005_auto_20190106_0018'),
]
operations = [
migrations.AlterField(
model_name='consumption',
name='customer',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='consumption_global_taken', to=settings.AUTH_USER_MODEL, verbose_name='Client'),
),
migrations.AlterField(
model_name='consumption',
name='product',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='gestion.Product', verbose_name='Produit'),
),
migrations.AlterField(
model_name='consumption',
name='quantity',
field=models.PositiveIntegerField(default=0, verbose_name='Quantité'),
),
migrations.AlterField(
model_name='consumptionhistory',
name='amount',
field=models.DecimalField(decimal_places=2, default=0, max_digits=7, verbose_name='Montant'),
),
migrations.AlterField(
model_name='consumptionhistory',
name='customer',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='consumption_taken', to=settings.AUTH_USER_MODEL, verbose_name='Client'),
),
migrations.AlterField(
model_name='consumptionhistory',
name='paymentMethod',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='preferences.PaymentMethod', verbose_name='Moyen de paiement'),
),
migrations.AlterField(
model_name='consumptionhistory',
name='product',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='gestion.Product', verbose_name='Produit'),
),
migrations.AlterField(
model_name='consumptionhistory',
name='quantity',
field=models.PositiveIntegerField(default=0, verbose_name='Quantité'),
),
migrations.AlterField(
model_name='historicalconsumption',
name='quantity',
field=models.PositiveIntegerField(default=0, verbose_name='Quantité'),
),
migrations.AlterField(
model_name='historicalconsumptionhistory',
name='amount',
field=models.DecimalField(decimal_places=2, default=0, max_digits=7, verbose_name='Montant'),
),
migrations.AlterField(
model_name='historicalconsumptionhistory',
name='quantity',
field=models.PositiveIntegerField(default=0, verbose_name='Quantité'),
),
migrations.AlterField(
model_name='historicalkeghistory',
name='amountSold',
field=models.DecimalField(decimal_places=2, default=0, max_digits=5, verbose_name='Somme vendue'),
),
migrations.AlterField(
model_name='historicalkeghistory',
name='closingDate',
field=models.DateTimeField(blank=True, null=True, verbose_name='Date fermeture'),
),
migrations.AlterField(
model_name='historicalkeghistory',
name='isCurrentKegHistory',
field=models.BooleanField(default=True, verbose_name='Actuel'),
),
migrations.AlterField(
model_name='historicalkeghistory',
name='openingDate',
field=models.DateTimeField(blank=True, editable=False, verbose_name='Date ouverture'),
),
migrations.AlterField(
model_name='historicalkeghistory',
name='quantitySold',
field=models.DecimalField(decimal_places=2, default=0, max_digits=5, verbose_name='Quantité vendue'),
),
migrations.AlterField(
model_name='historicalmenuhistory',
name='amount',
field=models.DecimalField(decimal_places=2, default=0, max_digits=7, verbose_name='Montant'),
),
migrations.AlterField(
model_name='historicalmenuhistory',
name='quantity',
field=models.PositiveIntegerField(default=0, verbose_name='Quantité'),
),
migrations.AlterField(
model_name='historicalproduct',
name='category',
field=models.CharField(choices=[('PP', 'Pinte Pression'), ('DP', 'Demi Pression'), ('GP', 'Galopin pression'), ('BT', 'Bouteille'), ('SO', 'Soft'), ('FO', 'En-cas'), ('PA', 'Ingredients panini')], default='FO', max_length=2, verbose_name='Catégorie'),
),
migrations.AlterField(
model_name='keghistory',
name='amountSold',
field=models.DecimalField(decimal_places=2, default=0, max_digits=5, verbose_name='Somme vendue'),
),
migrations.AlterField(
model_name='keghistory',
name='closingDate',
field=models.DateTimeField(blank=True, null=True, verbose_name='Date fermeture'),
),
migrations.AlterField(
model_name='keghistory',
name='isCurrentKegHistory',
field=models.BooleanField(default=True, verbose_name='Actuel'),
),
migrations.AlterField(
model_name='keghistory',
name='keg',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='gestion.Keg', verbose_name='Fût'),
),
migrations.AlterField(
model_name='keghistory',
name='openingDate',
field=models.DateTimeField(auto_now_add=True, verbose_name='Date ouverture'),
),
migrations.AlterField(
model_name='keghistory',
name='quantitySold',
field=models.DecimalField(decimal_places=2, default=0, max_digits=5, verbose_name='Quantité vendue'),
),
migrations.AlterField(
model_name='menuhistory',
name='amount',
field=models.DecimalField(decimal_places=2, default=0, max_digits=7, verbose_name='Montant'),
),
migrations.AlterField(
model_name='menuhistory',
name='customer',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='menu_taken', to=settings.AUTH_USER_MODEL, verbose_name='Client'),
),
migrations.AlterField(
model_name='menuhistory',
name='paymentMethod',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='preferences.PaymentMethod', verbose_name='Moyen de paiement'),
),
migrations.AlterField(
model_name='menuhistory',
name='quantity',
field=models.PositiveIntegerField(default=0, verbose_name='Quantité'),
),
migrations.AlterField(
model_name='product',
name='category',
field=models.CharField(choices=[('PP', 'Pinte Pression'), ('DP', 'Demi Pression'), ('GP', 'Galopin pression'), ('BT', 'Bouteille'), ('SO', 'Soft'), ('FO', 'En-cas'), ('PA', 'Ingredients panini')], default='FO', max_length=2, verbose_name='Catégorie'),
),
]

View file

@ -23,8 +23,8 @@ class Product(models.Model):
(G_PRESSION, "Galopin pression"), (G_PRESSION, "Galopin pression"),
(BOTTLE, "Bouteille"), (BOTTLE, "Bouteille"),
(SOFT, "Soft"), (SOFT, "Soft"),
(FOOD, "Bouffe autre que panini"), (FOOD, "En-cas"),
(PANINI, "Bouffe pour panini"), (PANINI, "Ingredients panini"),
) )
class Meta: class Meta:
verbose_name = "Produit" verbose_name = "Produit"
@ -118,12 +118,12 @@ class KegHistory(models.Model):
class Meta: class Meta:
verbose_name = "Historique de fût" verbose_name = "Historique de fût"
keg = models.ForeignKey(Keg, on_delete=models.PROTECT) keg = models.ForeignKey(Keg, on_delete=models.PROTECT, verbose_name="Fût")
openingDate = models.DateTimeField(auto_now_add=True) openingDate = models.DateTimeField(auto_now_add=True, verbose_name="Date ouverture")
quantitySold = models.DecimalField(decimal_places=2, max_digits=5, default=0) quantitySold = models.DecimalField(decimal_places=2, max_digits=5, default=0, verbose_name="Quantité vendue")
amountSold = models.DecimalField(decimal_places=2, max_digits=5, default=0) amountSold = models.DecimalField(decimal_places=2, max_digits=5, default=0, verbose_name="Somme vendue")
closingDate = models.DateTimeField(null=True, blank=True) closingDate = models.DateTimeField(null=True, blank=True, verbose_name="Date fermeture")
isCurrentKegHistory = models.BooleanField(default=True) isCurrentKegHistory = models.BooleanField(default=True, verbose_name="Actuel")
history = HistoricalRecords() history = HistoricalRecords()
def __str__(self): def __str__(self):
@ -196,12 +196,12 @@ class MenuHistory(models.Model):
class Meta: class Meta:
verbose_name = "Historique de menu" verbose_name = "Historique de menu"
customer = models.ForeignKey(User, on_delete=models.PROTECT, related_name="menu_taken") customer = models.ForeignKey(User, on_delete=models.PROTECT, related_name="menu_taken", verbose_name="Client")
quantity = models.PositiveIntegerField(default=0) quantity = models.PositiveIntegerField(default=0, verbose_name="Quantité")
paymentMethod = models.ForeignKey(PaymentMethod, on_delete=models.PROTECT) paymentMethod = models.ForeignKey(PaymentMethod, on_delete=models.PROTECT, verbose_name="Moyen de paiement")
date = models.DateTimeField(auto_now_add=True) date = models.DateTimeField(auto_now_add=True)
menu = models.ForeignKey(Menu, on_delete=models.PROTECT) menu = models.ForeignKey(Menu, on_delete=models.PROTECT)
amount = models.DecimalField(max_digits=7, decimal_places=2, default=0) amount = models.DecimalField(max_digits=7, decimal_places=2, default=0, verbose_name="Montant")
coopeman = models.ForeignKey(User, on_delete=models.PROTECT, related_name="menu_selled") coopeman = models.ForeignKey(User, on_delete=models.PROTECT, related_name="menu_selled")
history = HistoricalRecords() history = HistoricalRecords()
@ -215,12 +215,12 @@ class ConsumptionHistory(models.Model):
class Meta: class Meta:
verbose_name = "Consommation" verbose_name = "Consommation"
customer = models.ForeignKey(User, on_delete=models.PROTECT, related_name="consumption_taken") customer = models.ForeignKey(User, on_delete=models.PROTECT, related_name="consumption_taken", verbose_name="Client")
quantity = models.PositiveIntegerField(default=0) quantity = models.PositiveIntegerField(default=0, verbose_name="Quantité")
paymentMethod = models.ForeignKey(PaymentMethod, on_delete=models.PROTECT) paymentMethod = models.ForeignKey(PaymentMethod, on_delete=models.PROTECT, verbose_name="Moyen de paiement")
date = models.DateTimeField(auto_now_add=True) date = models.DateTimeField(auto_now_add=True)
product = models.ForeignKey(Product, on_delete=models.PROTECT) product = models.ForeignKey(Product, on_delete=models.PROTECT, verbose_name="Produit")
amount = models.DecimalField(max_digits=7, decimal_places=2, default=0) amount = models.DecimalField(max_digits=7, decimal_places=2, default=0, verbose_name="Montant")
coopeman = models.ForeignKey(User, on_delete=models.PROTECT, related_name="consumption_selled") coopeman = models.ForeignKey(User, on_delete=models.PROTECT, related_name="consumption_selled")
history = HistoricalRecords() history = HistoricalRecords()
@ -234,9 +234,9 @@ class Consumption(models.Model):
class Meta: class Meta:
verbose_name = "Consommation totale" verbose_name = "Consommation totale"
customer = models.ForeignKey(User, on_delete=models.PROTECT, related_name="consumption_global_taken") customer = models.ForeignKey(User, on_delete=models.PROTECT, related_name="consumption_global_taken", verbose_name="Client")
product = models.ForeignKey(Product, on_delete=models.PROTECT) product = models.ForeignKey(Product, on_delete=models.PROTECT, verbose_name="Produit")
quantity = models.PositiveIntegerField(default=0) quantity = models.PositiveIntegerField(default=0, verbose_name="Quantité")
history = HistoricalRecords() history = HistoricalRecords()
def __str__(self): def __str__(self):

View file

@ -2,6 +2,19 @@ from django.contrib import admin
from simple_history.admin import SimpleHistoryAdmin from simple_history.admin import SimpleHistoryAdmin
from .models import PaymentMethod, GeneralPreferences, Cotisation from .models import PaymentMethod, GeneralPreferences, Cotisation
admin.site.register(PaymentMethod, SimpleHistoryAdmin) class CotisationAdmin(SimpleHistoryAdmin):
admin.site.register(GeneralPreferences, SimpleHistoryAdmin) list_display = ('__str__', 'amount', 'duration')
admin.site.register(Cotisation, SimpleHistoryAdmin) ordering = ('-duration', '-amount')
class GeneralPreferencesAdmin(SimpleHistoryAdmin):
list_display = ('is_active', 'president', 'vice_president', 'treasurer', 'secretary', 'brewer', 'grocer', 'use_pinte_monitoring', 'lost_pintes_allowed', 'floating_buttons', 'automatic_logout_time')
class PaymentMethodAdmin(SimpleHistoryAdmin):
list_display = ('name', 'is_active', 'is_usable_in_cotisation', 'is_usable_in_reload', 'affect_balance')
ordering = ('name',)
search_fields = ('name',)
list_filter = ('is_active', 'is_usable_in_cotisation', 'is_usable_in_reload', 'affect_balance')
admin.site.register(PaymentMethod, PaymentMethodAdmin)
admin.site.register(GeneralPreferences, GeneralPreferencesAdmin)
admin.site.register(Cotisation, CotisationAdmin)

View file

@ -0,0 +1,199 @@
# Generated by Django 2.1 on 2019-02-27 07:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('preferences', '0008_auto_20190218_1802'),
]
operations = [
migrations.AlterModelOptions(
name='generalpreferences',
options={'verbose_name': 'Préférences générales', 'verbose_name_plural': 'Préférences générales'},
),
migrations.AlterModelOptions(
name='historicalgeneralpreferences',
options={'get_latest_by': 'history_date', 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical Préférences générales'},
),
migrations.AlterModelOptions(
name='historicalpaymentmethod',
options={'get_latest_by': 'history_date', 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical Moyen de paiement'},
),
migrations.AlterModelOptions(
name='paymentmethod',
options={'verbose_name': 'Moyen de paiement', 'verbose_name_plural': 'Moyens de paiement'},
),
migrations.AlterField(
model_name='generalpreferences',
name='active_message',
field=models.TextField(blank=True, verbose_name='Message non actif'),
),
migrations.AlterField(
model_name='generalpreferences',
name='automatic_logout_time',
field=models.PositiveIntegerField(null=True, verbose_name='Temps de déconnexion automatique'),
),
migrations.AlterField(
model_name='generalpreferences',
name='brewer',
field=models.CharField(blank=True, max_length=255, verbose_name='Maître Brasseur'),
),
migrations.AlterField(
model_name='generalpreferences',
name='floating_buttons',
field=models.BooleanField(default=False, verbose_name='Boutons flottants'),
),
migrations.AlterField(
model_name='generalpreferences',
name='global_message',
field=models.TextField(blank=True, verbose_name='Message global'),
),
migrations.AlterField(
model_name='generalpreferences',
name='grocer',
field=models.CharField(blank=True, max_length=255, verbose_name='Épic Épicier'),
),
migrations.AlterField(
model_name='generalpreferences',
name='home_text',
field=models.TextField(blank=True, verbose_name="Message d'accueil"),
),
migrations.AlterField(
model_name='generalpreferences',
name='is_active',
field=models.BooleanField(default=True, verbose_name='Site actif'),
),
migrations.AlterField(
model_name='generalpreferences',
name='lost_pintes_allowed',
field=models.PositiveIntegerField(default=0, verbose_name='Nombre de pintes perdus admises'),
),
migrations.AlterField(
model_name='generalpreferences',
name='menu',
field=models.FileField(blank=True, null=True, upload_to='', verbose_name='Menu'),
),
migrations.AlterField(
model_name='generalpreferences',
name='president',
field=models.CharField(blank=True, max_length=255, verbose_name='Président'),
),
migrations.AlterField(
model_name='generalpreferences',
name='rules',
field=models.FileField(blank=True, null=True, upload_to='', verbose_name='Règlement intérieur'),
),
migrations.AlterField(
model_name='generalpreferences',
name='secretary',
field=models.CharField(blank=True, max_length=255, verbose_name='Secrétaire'),
),
migrations.AlterField(
model_name='generalpreferences',
name='statutes',
field=models.FileField(blank=True, null=True, upload_to='', verbose_name='Statuts'),
),
migrations.AlterField(
model_name='generalpreferences',
name='treasurer',
field=models.CharField(blank=True, max_length=255, verbose_name='Trésorier'),
),
migrations.AlterField(
model_name='generalpreferences',
name='use_pinte_monitoring',
field=models.BooleanField(default=False, verbose_name='Suivi de pintes'),
),
migrations.AlterField(
model_name='generalpreferences',
name='vice_president',
field=models.CharField(blank=True, max_length=255, verbose_name='Vice Président'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='active_message',
field=models.TextField(blank=True, verbose_name='Message non actif'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='automatic_logout_time',
field=models.PositiveIntegerField(null=True, verbose_name='Temps de déconnexion automatique'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='brewer',
field=models.CharField(blank=True, max_length=255, verbose_name='Maître Brasseur'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='floating_buttons',
field=models.BooleanField(default=False, verbose_name='Boutons flottants'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='global_message',
field=models.TextField(blank=True, verbose_name='Message global'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='grocer',
field=models.CharField(blank=True, max_length=255, verbose_name='Épic Épicier'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='home_text',
field=models.TextField(blank=True, verbose_name="Message d'accueil"),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='is_active',
field=models.BooleanField(default=True, verbose_name='Site actif'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='lost_pintes_allowed',
field=models.PositiveIntegerField(default=0, verbose_name='Nombre de pintes perdus admises'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='menu',
field=models.TextField(blank=True, max_length=100, null=True, verbose_name='Menu'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='president',
field=models.CharField(blank=True, max_length=255, verbose_name='Président'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='rules',
field=models.TextField(blank=True, max_length=100, null=True, verbose_name='Règlement intérieur'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='secretary',
field=models.CharField(blank=True, max_length=255, verbose_name='Secrétaire'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='statutes',
field=models.TextField(blank=True, max_length=100, null=True, verbose_name='Statuts'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='treasurer',
field=models.CharField(blank=True, max_length=255, verbose_name='Trésorier'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='use_pinte_monitoring',
field=models.BooleanField(default=False, verbose_name='Suivi de pintes'),
),
migrations.AlterField(
model_name='historicalgeneralpreferences',
name='vice_president',
field=models.CharField(blank=True, max_length=255, verbose_name='Vice Président'),
),
]

View file

@ -7,6 +7,10 @@ class PaymentMethod(models.Model):
""" """
Stores payment methods Stores payment methods
""" """
class Meta:
verbose_name="Moyen de paiement"
verbose_name_plural = "Moyens de paiement"
name = models.CharField(max_length=255, verbose_name="Nom") name = models.CharField(max_length=255, verbose_name="Nom")
is_active = models.BooleanField(default=True, verbose_name="Actif") is_active = models.BooleanField(default=True, verbose_name="Actif")
is_usable_in_cotisation = models.BooleanField(default=True, verbose_name="Cotisations ?") is_usable_in_cotisation = models.BooleanField(default=True, verbose_name="Cotisations ?")
@ -22,23 +26,27 @@ class GeneralPreferences(models.Model):
""" """
Stores a unique line of general preferences Stores a unique line of general preferences
""" """
is_active = models.BooleanField(default=True) class Meta:
active_message = models.TextField(blank=True) verbose_name="Préférences générales"
global_message = models.TextField(blank=True) verbose_name_plural = "Préférences générales"
president = models.CharField(max_length=255, blank=True)
vice_president = models.CharField(max_length=255, blank=True) is_active = models.BooleanField(default=True, verbose_name="Site actif")
treasurer = models.CharField(max_length=255, blank=True) active_message = models.TextField(blank=True, verbose_name="Message non actif")
secretary = models.CharField(max_length=255, blank=True) global_message = models.TextField(blank=True, verbose_name="Message global")
brewer = models.CharField(max_length=255, blank=True) president = models.CharField(max_length=255, blank=True, verbose_name="Président")
grocer = models.CharField(max_length=255, blank=True) vice_president = models.CharField(max_length=255, blank=True, verbose_name="Vice Président")
use_pinte_monitoring = models.BooleanField(default=False) treasurer = models.CharField(max_length=255, blank=True, verbose_name="Trésorier")
lost_pintes_allowed = models.PositiveIntegerField(default=0) secretary = models.CharField(max_length=255, blank=True, verbose_name="Secrétaire")
floating_buttons = models.BooleanField(default=False) brewer = models.CharField(max_length=255, blank=True, verbose_name="Maître Brasseur")
home_text = models.TextField(blank=True) grocer = models.CharField(max_length=255, blank=True, verbose_name="Épic Épicier")
automatic_logout_time = models.PositiveIntegerField(null=True) use_pinte_monitoring = models.BooleanField(default=False, verbose_name="Suivi de pintes")
statutes = models.FileField(blank=True, null=True) lost_pintes_allowed = models.PositiveIntegerField(default=0, verbose_name="Nombre de pintes perdus admises")
rules = models.FileField(blank=True, null=True) floating_buttons = models.BooleanField(default=False, verbose_name="Boutons flottants")
menu = models.FileField(blank=True, null=True) home_text = models.TextField(blank=True, verbose_name="Message d'accueil")
automatic_logout_time = models.PositiveIntegerField(null=True, verbose_name="Temps de déconnexion automatique")
statutes = models.FileField(blank=True, null=True, verbose_name="Statuts")
rules = models.FileField(blank=True, null=True, verbose_name="Règlement intérieur")
menu = models.FileField(blank=True, null=True, verbose_name="Menu")
history = HistoricalRecords() history = HistoricalRecords()
class Cotisation(models.Model): class Cotisation(models.Model):

View file

@ -1,13 +1,49 @@
from django.contrib import admin from django.contrib import admin
from django.contrib.auth.models import Permission from django.contrib.auth.models import Permission
from simple_history.admin import SimpleHistoryAdmin from simple_history.admin import SimpleHistoryAdmin
from django.db.models import F
from .models import School, Profile, CotisationHistory, WhiteListHistory
class CotisationHistoryAdmin(SimpleHistoryAdmin):
list_display = ('user', 'amount', 'duration', 'paymentDate', 'endDate', 'paymentMethod')
ordering = ('user', 'amount', 'duration', 'paymentDate', 'endDate')
search_fields = ('user',)
list_filter = ('paymentMethod', )
class BalanceFilter(admin.SimpleListFilter):
title = 'Solde'
parameter_name = 'solde'
def lookups(self, request, model_admin):
return (
('po', '>0'),
('nu', '=0'),
('ne', '<0'),
)
def queryset(self, request, queryset):
if self.value() == 'po':
return queryset.filter(credit__gt=F('debit'))
elif self.value() == 'nu':
return queryset.filter(credit=F('debit'))
elif self.value() == 'ne':
return queryset.filter(credit__lt=F('debit'))
from .models import School, Profile, CotisationHistory
class ProfileAdmin(SimpleHistoryAdmin): class ProfileAdmin(SimpleHistoryAdmin):
search_fields = ('user__username', 'user__first_name', 'user__last_name') list_display = ('user', 'credit', 'debit', 'balance', 'school', 'cotisationEnd', 'is_adherent')
ordering = ('user', '-credit', '-debit')
search_fields = ('user',)
list_filter = ('school', BalanceFilter)
class WhiteListHistoryAdmin(SimpleHistoryAdmin):
list_display = ('user', 'paymentDate', 'endDate', 'duration')
ordering = ('user', 'duration', 'paymentDate', 'endDate')
search_fields = ('user',)
admin.site.register(Permission, SimpleHistoryAdmin) admin.site.register(Permission, SimpleHistoryAdmin)
admin.site.register(School, SimpleHistoryAdmin) admin.site.register(School, SimpleHistoryAdmin)
admin.site.register(WhiteListHistory, WhiteListHistoryAdmin)
admin.site.register(Profile, ProfileAdmin) admin.site.register(Profile, ProfileAdmin)
admin.site.register(CotisationHistory, SimpleHistoryAdmin) admin.site.register(CotisationHistory, CotisationHistoryAdmin)

View file

@ -0,0 +1,84 @@
# Generated by Django 2.1 on 2019-02-27 07:59
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('users', '0004_auto_20190226_2313'),
]
operations = [
migrations.AlterModelOptions(
name='whitelisthistory',
options={'verbose_name': 'Historique accès gracieux', 'verbose_name_plural': 'Historique accès gracieux'},
),
migrations.AlterField(
model_name='historicalprofile',
name='cotisationEnd',
field=models.DateTimeField(blank=True, null=True, verbose_name='Fin de cotisation'),
),
migrations.AlterField(
model_name='historicalprofile',
name='credit',
field=models.DecimalField(decimal_places=2, default=0, max_digits=7, verbose_name='Crédit'),
),
migrations.AlterField(
model_name='historicalprofile',
name='debit',
field=models.DecimalField(decimal_places=2, default=0, max_digits=7, verbose_name='Débit'),
),
migrations.AlterField(
model_name='historicalwhitelisthistory',
name='endDate',
field=models.DateTimeField(verbose_name='Date de fin'),
),
migrations.AlterField(
model_name='historicalwhitelisthistory',
name='paymentDate',
field=models.DateTimeField(blank=True, editable=False, verbose_name='Date de début'),
),
migrations.AlterField(
model_name='profile',
name='cotisationEnd',
field=models.DateTimeField(blank=True, null=True, verbose_name='Fin de cotisation'),
),
migrations.AlterField(
model_name='profile',
name='credit',
field=models.DecimalField(decimal_places=2, default=0, max_digits=7, verbose_name='Crédit'),
),
migrations.AlterField(
model_name='profile',
name='debit',
field=models.DecimalField(decimal_places=2, default=0, max_digits=7, verbose_name='Débit'),
),
migrations.AlterField(
model_name='profile',
name='school',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='users.School', verbose_name='École'),
),
migrations.AlterField(
model_name='profile',
name='user',
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Utilisateur'),
),
migrations.AlterField(
model_name='whitelisthistory',
name='endDate',
field=models.DateTimeField(verbose_name='Date de fin'),
),
migrations.AlterField(
model_name='whitelisthistory',
name='paymentDate',
field=models.DateTimeField(auto_now_add=True, verbose_name='Date de début'),
),
migrations.AlterField(
model_name='whitelisthistory',
name='user',
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL, verbose_name='Client'),
),
]

View file

@ -42,10 +42,11 @@ class WhiteListHistory(models.Model):
""" """
class Meta: class Meta:
verbose_name = "Historique accès gracieux" verbose_name = "Historique accès gracieux"
verbose_name_plural = "Historique accès gracieux"
user = models.ForeignKey(User, on_delete=models.PROTECT) user = models.ForeignKey(User, on_delete=models.PROTECT, verbose_name="Client")
paymentDate = models.DateTimeField(auto_now_add=True) paymentDate = models.DateTimeField(auto_now_add=True, verbose_name="Date de début")
endDate = models.DateTimeField() endDate = models.DateTimeField(verbose_name="Date de fin")
duration = models.PositiveIntegerField(verbose_name="Durée", help_text="Durée de l'accès gracieux en jour") duration = models.PositiveIntegerField(verbose_name="Durée", help_text="Durée de l'accès gracieux en jour")
coopeman = models.ForeignKey(User, on_delete=models.PROTECT, related_name="whitelist_made") coopeman = models.ForeignKey(User, on_delete=models.PROTECT, related_name="whitelist_made")
history = HistoricalRecords() history = HistoricalRecords()
@ -57,11 +58,11 @@ class Profile(models.Model):
class Meta: class Meta:
verbose_name = "Profil" verbose_name = "Profil"
user = models.OneToOneField(User, on_delete=models.CASCADE) user = models.OneToOneField(User, on_delete=models.CASCADE, verbose_name="Utilisateur")
credit = models.DecimalField(max_digits=7, decimal_places=2, default=0) credit = models.DecimalField(max_digits=7, decimal_places=2, default=0, verbose_name="Crédit")
debit = models.DecimalField(max_digits=7, decimal_places=2, default=0) debit = models.DecimalField(max_digits=7, decimal_places=2, default=0, verbose_name="Débit")
school = models.ForeignKey(School, on_delete=models.PROTECT, blank=True, null=True) school = models.ForeignKey(School, on_delete=models.PROTECT, blank=True, null=True, verbose_name="École")
cotisationEnd = models.DateTimeField(blank=True, null=True) cotisationEnd = models.DateTimeField(blank=True, null=True, verbose_name="Fin de cotisation")
history = HistoricalRecords() history = HistoricalRecords()
@property @property