Commit 3ce1e10a authored by Alexandre Lanceart's avatar Alexandre Lanceart
Browse files

Currencies fonctionnel

parent 8127422f
from django.contrib import admin
from reversion_compare.admin import CompareVersionAdmin
from backend_app.models.abstract.versionedEssentialModule import (
VersionedEssentialModule,
)
from external_data.models import externalDatainfoDate
from external_data.models import ExternalDataInfoDate
ALL_MODELS = [
externalDatainfoDate,
]
CLASSIC_MODELS = filter(
lambda m: not issubclass(m, VersionedEssentialModule), ALL_MODELS
)
VERSIONED_MODELS = filter(lambda m: issubclass(m, VersionedEssentialModule), ALL_MODELS)
#######
# Register the models
#######
for Model in CLASSIC_MODELS:
# Register the model in the admin in a standard way
admin.site.register(Model)
for Model in VERSIONED_MODELS:
# Register the model in the admin with versioning
admin.site.register(Model, CompareVersionAdmin)
admin.site.register(ExternalDataInfoDate)
......@@ -4,7 +4,7 @@ import requests
from datetime import date
from backend_app.models.currency import Currency
from external_data.models import externalDatainfoDate
from external_data.models import ExternalDataInfoDate
from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
......@@ -32,10 +32,10 @@ class Command(BaseCommand):
code=k,
defaults={"one_EUR_in_this_currency": v
})
externalDatainfoDate.objects.update_or_create(
update_date = date.today()
)
#
# ExternalDataInfoDate.objects.create(
# update_date=date.today()
# )
for currency in Currency.objects.all():
logger.info(currency.code + " " + str(currency.one_EUR_in_this_currency))
# Generated by Django 2.1.7 on 2019-05-30 12:12
# Generated by Django 2.1.7 on 2019-05-30 13:29
from django.db import migrations, models
......@@ -12,7 +12,7 @@ class Migration(migrations.Migration):
operations = [
migrations.CreateModel(
name='externalDatainfoDate',
name='ExternalDatainfoDate',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('update_date', models.DateField()),
......
......@@ -2,6 +2,6 @@ from django.db import models
from backend_app.models.abstract.base import BaseModel
# TODO change name
class externalDatainfoDate(BaseModel):
class ExternalDataInfoDate(BaseModel):
update_date = models.DateField()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment