From 3f7eac352e43a053247e3ad0125b9467fee61c85 Mon Sep 17 00:00:00 2001 From: Ctilhs Date: Wed, 23 Oct 2019 21:45:53 +0200 Subject: [PATCH] Add rsa fields to User model. (#360) * Add rsa fields to User model. * Add migration. * Fixed build error. Took solution from https://github.com/CodeForPoznan/pah-fm/commit/819c7354340434c5e38578dce5083ba7b76d359f * Reorder migration after recent changes in develop. --- .../migrations/0011_add_default_groups.py | 3 +- .../migrations/0020_auto_20191023_1925.py | 29 +++++++++++++++++++ backend/fleet_management/models.py | 5 +++- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 backend/fleet_management/migrations/0020_auto_20191023_1925.py diff --git a/backend/fleet_management/migrations/0011_add_default_groups.py b/backend/fleet_management/migrations/0011_add_default_groups.py index 052b222b..57dcb8bd 100644 --- a/backend/fleet_management/migrations/0011_add_default_groups.py +++ b/backend/fleet_management/migrations/0011_add_default_groups.py @@ -1,4 +1,3 @@ - from django.db import migrations @@ -27,4 +26,4 @@ class Migration(migrations.Migration): operations = [ migrations.RunPython(create_groups), migrations.RunPython(insert_to_groups), - ] + ] \ No newline at end of file diff --git a/backend/fleet_management/migrations/0020_auto_20191023_1925.py b/backend/fleet_management/migrations/0020_auto_20191023_1925.py new file mode 100644 index 00000000..aff53dde --- /dev/null +++ b/backend/fleet_management/migrations/0020_auto_20191023_1925.py @@ -0,0 +1,29 @@ +# Generated by Django 2.1.2 on 2019-10-23 19:25 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('fleet_management', '0019_remove_passenger_model'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='rsa_modulus_n', + field=models.CharField(default='', max_length=6, validators=[django.core.validators.MinLengthValidator(6)]), + ), + migrations.AddField( + model_name='user', + name='rsa_priv_d', + field=models.CharField(default='', max_length=6, validators=[django.core.validators.MinLengthValidator(6)]), + ), + migrations.AddField( + model_name='user', + name='rsa_pub_e', + field=models.CharField(default='', max_length=6, validators=[django.core.validators.MinLengthValidator(6)]), + ), + ] diff --git a/backend/fleet_management/models.py b/backend/fleet_management/models.py index faa6b7e1..793e44b6 100644 --- a/backend/fleet_management/models.py +++ b/backend/fleet_management/models.py @@ -5,7 +5,7 @@ from django.contrib.auth.models import AbstractUser from django.utils.timezone import now from django_countries.fields import CountryField - +from django.core.validators import MinLengthValidator def get_current_timestamp_in_gmt(): return calendar.timegm(time.gmtime()) @@ -13,6 +13,9 @@ def get_current_timestamp_in_gmt(): class User(AbstractUser): country = CountryField(blank_label="(select country)", null=False) + rsa_modulus_n = models.CharField(max_length=6, validators=[MinLengthValidator(6)], null=False, default='') + rsa_pub_e = models.CharField(max_length=6, validators=[MinLengthValidator(6)], null=False, default='') + rsa_priv_d = models.CharField(max_length=6, validators=[MinLengthValidator(6)], null=False, default='') def __str__(self): return f"{self.first_name} {self.last_name}"