Commit cee90634 authored by GuiΩ's avatar GuiΩ
Browse files

Update database: add field nom_latex for users

parent 49a4a86d
# Generated by Django 4.0.4 on 2022-05-03 14:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('am', '0036_auto_20210311_1617'),
]
operations = [
migrations.AddField(
model_name='utilisateur',
name='nom_latex',
field=models.CharField(null=True, max_length=100, verbose_name='nom LaTeX'),
),
]
# Generated by Django 4.0.4 on 2022-05-03 15:14
from django.db import migrations
def defaut_nom_latex(apps, schema_editor):
Utilisateur = apps.get_model('am', 'Utilisateur')
for utilisateur in Utilisateur.objects.all():
print(utilisateur.username, utilisateur.date_joined)
if len(utilisateur.first_name) and len(utilisateur.last_name):
utilisateur.nom_latex = '%s.%s' % (utilisateur.first_name[0], utilisateur.last_name)
elif len(utilisateur.first_name):
utilisateur.nom_latex = utilisateur.first_name
else:
utilisateur.nom_latex = utilisateur.last_name
utilisateur.save()
class Migration(migrations.Migration):
dependencies = [
('am', '0037_utilisateur_nom_latex'),
]
operations = [
migrations.RunPython(defaut_nom_latex, migrations.RunPython.noop),
]
# Generated by Django 4.0.4 on 2022-05-03 15:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('am', '0038_auto_20220503_1714'),
]
operations = [
migrations.AlterField(
model_name='utilisateur',
name='nom_latex',
field=models.CharField(max_length=100, verbose_name='nom LaTeX'),
),
]
......@@ -12,9 +12,8 @@ from pdf2image import pdf2image
class Utilisateur(AbstractUser):
pass
nom_latex = models.CharField("nom LaTeX", max_length=100)
# add additional fields in here
def __str__(self):
return self.username
......
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