Skip to content

Commit

Permalink
Merge pull request #248 from winged/feat_make_compatible
Browse files Browse the repository at this point in the history
feat(models): make user model compatible with django
  • Loading branch information
Jean-Louis Fuchs authored Jul 22, 2021
2 parents 7d525de + cb04f81 commit 5398dca
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 14 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## v0.2.0 (22 July 2021)

Various bugfixes to make Emeis usable as a Django app


## v0.1.0 (22 July 2021)

Initial release
26 changes: 26 additions & 0 deletions emeis/core/migrations/0004_use_abstract_base_user.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 2.2.24 on 2021-07-22 12:02

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("emeis_core", "0003_localized_city"),
]

operations = [
migrations.AddField(
model_name="user",
name="last_login",
field=models.DateTimeField(
blank=True, null=True, verbose_name="last login"
),
),
migrations.AddField(
model_name="user",
name="password",
field=models.CharField(default="", max_length=128, verbose_name="password"),
preserve_default=False,
),
]
3 changes: 2 additions & 1 deletion emeis/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from django.conf import settings
from django.contrib.auth.base_user import BaseUserManager
from django.contrib.auth.models import AbstractBaseUser
from django.contrib.auth.validators import UnicodeUsernameValidator
from django.contrib.postgres.fields import JSONField
from django.core.exceptions import ImproperlyConfigured
Expand Down Expand Up @@ -105,7 +106,7 @@ class Meta:
abstract = True


class User(UUIDModel):
class User(UUIDModel, AbstractBaseUser):
username_validator = UnicodeUsernameValidator()

username = models.CharField(
Expand Down
19 changes: 18 additions & 1 deletion emeis/core/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,24 @@ class UserSerializer(BaseSerializer):

class Meta:
model = User
fields = "__all__"
fields = [
"username",
"first_name",
"last_name",
"email",
"phone",
"language",
"address",
"city",
"zip",
"acls",
"is_active",
"date_joined",
"modified_at",
"created_at",
"created_by_user",
"meta",
]


class ScopeSerializer(BaseSerializer):
Expand Down
Loading

0 comments on commit 5398dca

Please sign in to comment.