Added Entry model

This commit is contained in:
Julien Malka 2020-02-16 18:37:16 +01:00
parent 494cd5ddc1
commit df0dd6cedc
9 changed files with 78 additions and 0 deletions

View file

10
journaldecaisse/admin.py Normal file
View file

@ -0,0 +1,10 @@
from django.contrib import admin
from .models import JournalEntry
class JournalAdmin(admin.ModelAdmin):
list_display = ('entry_text', 'cofeux_id', 'payment_type')
admin.site.register(JournalEntry, JournalAdmin)

5
journaldecaisse/apps.py Normal file
View file

@ -0,0 +1,5 @@
from django.apps import AppConfig
class JournaldecaisseConfig(AppConfig):
name = 'journaldecaisse'

View file

@ -0,0 +1,25 @@
# Generated by Django 2.2.9 on 2020-02-16 17:14
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='JournalEntry',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('entry_text', models.CharField(max_length=500)),
('entry_date', models.DateTimeField(verbose_name='date published')),
('cofeux_id', models.CharField(max_length=8)),
('entry_amount', models.FloatField()),
('payment_type', models.CharField(choices=[('cash', 'Espèces'), ('cb', 'CB'), ('check', 'Chèque')], max_length=20, verbose_name='Niveau')),
],
),
]

View file

23
journaldecaisse/models.py Normal file
View file

@ -0,0 +1,23 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _
PAYMENTS_CHOICES = (
("cash", _("Espèces")),
("cb", _("CB")),
("check", _("Chèque")),
)
class JournalEntry(models.Model):
entry_text = models.CharField(max_length=500)
entry_date = models.DateTimeField('Date')
cofeux_id = models.CharField("Trigramme", max_length=8)
entry_amount = models.FloatField()
payment_type = models.CharField(
_("Moyen de paiement"), choices=PAYMENTS_CHOICES, max_length=20
)
def __str__(self):
return self.entry_text

3
journaldecaisse/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

7
journaldecaisse/urls.py Normal file
View file

@ -0,0 +1,7 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]

5
journaldecaisse/views.py Normal file
View file

@ -0,0 +1,5 @@
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the polls index.")