Skip to content

Commit

Permalink
Add rsa fields to User model. (#360)
Browse files Browse the repository at this point in the history
* Add rsa fields to User model.

* Add migration.

* Fixed build error. Took solution from 819c735

* Reorder migration after recent changes in develop.
  • Loading branch information
Ctilhs authored and arturtamborski committed Oct 23, 2019
1 parent 7aeaaca commit 3f7eac3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from django.db import migrations


Expand Down Expand Up @@ -27,4 +26,4 @@ class Migration(migrations.Migration):
operations = [
migrations.RunPython(create_groups),
migrations.RunPython(insert_to_groups),
]
]
29 changes: 29 additions & 0 deletions backend/fleet_management/migrations/0020_auto_20191023_1925.py
Original file line number Diff line number Diff line change
@@ -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)]),
),
]
5 changes: 4 additions & 1 deletion backend/fleet_management/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
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())


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}"
Expand Down

0 comments on commit 3f7eac3

Please sign in to comment.