-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from andela/ft-user-profiles-159082310
#159082310 Add profile update
- Loading branch information
Showing
24 changed files
with
423 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,6 @@ omit = | |
*admin* | ||
*articles/models* | ||
*/migrations/* | ||
|
||
*/venv/* | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
authors/apps/authentication/migrations/0002_auto_20180731_0734.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 2.0.7 on 2018-07-31 07:34 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('authentication', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='user', | ||
name='bio', | ||
field=models.CharField(default=' ', max_length=255), | ||
), | ||
migrations.AddField( | ||
model_name='user', | ||
name='image', | ||
field=models.CharField(default=' ', max_length=255), | ||
), | ||
] |
23 changes: 23 additions & 0 deletions
23
authors/apps/authentication/migrations/0003_auto_20180731_1252.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 2.0.7 on 2018-07-31 12:52 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('authentication', '0002_auto_20180731_0734'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='user', | ||
name='bio', | ||
field=models.CharField(blank=True, max_length=255), | ||
), | ||
migrations.AlterField( | ||
model_name='user', | ||
name='image', | ||
field=models.ImageField(upload_to=''), | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
authors/apps/authentication/migrations/0004_auto_20180731_1657.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 2.0.7 on 2018-07-31 16:57 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('authentication', '0003_auto_20180731_1252'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='user', | ||
name='image', | ||
field=models.ImageField(blank=True, upload_to='profile_image'), | ||
), | ||
] |
24 changes: 24 additions & 0 deletions
24
authors/apps/authentication/migrations/0005_auto_20180801_0714.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 2.0.7 on 2018-08-01 07:14 | ||
|
||
from django.db import migrations, models | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('authentication', '0004_auto_20180731_1657'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='user', | ||
name='created_at', | ||
field=models.DateTimeField(default=django.utils.timezone.now), | ||
), | ||
migrations.AlterField( | ||
model_name='user', | ||
name='updated_at', | ||
field=models.DateTimeField(default=django.utils.timezone.now), | ||
), | ||
] |
24 changes: 24 additions & 0 deletions
24
authors/apps/authentication/migrations/0006_auto_20180801_0717.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 2.0.7 on 2018-08-01 07:17 | ||
|
||
from django.db import migrations, models | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('authentication', '0005_auto_20180801_0714'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='user', | ||
name='created_at', | ||
field=models.DateField(default=django.utils.timezone.now), | ||
), | ||
migrations.AlterField( | ||
model_name='user', | ||
name='updated_at', | ||
field=models.DateField(default=django.utils.timezone.now), | ||
), | ||
] |
23 changes: 23 additions & 0 deletions
23
authors/apps/authentication/migrations/0007_auto_20180801_0730.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 2.0.7 on 2018-08-01 07:30 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('authentication', '0006_auto_20180801_0717'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='user', | ||
name='created_at', | ||
field=models.DateTimeField(auto_now_add=True), | ||
), | ||
migrations.AlterField( | ||
model_name='user', | ||
name='updated_at', | ||
field=models.DateTimeField(auto_now=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from django.contrib.auth import authenticate | ||
from authors.apps.authentication.models import User | ||
from rest_framework import serializers | ||
from django.utils import timezone | ||
|
||
|
||
class UpdateSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = User | ||
fields = '__all__' | ||
|
||
def update(self,instance,validated_data): | ||
instance.username = validated_data.get('username',instance.username) | ||
instance.bio = validated_data.get('bio', instance.bio) | ||
instance.image = validated_data.get('file',instance.image) | ||
instance.updated_at = timezone.now | ||
instance.save() | ||
return instance | ||
|
||
|
||
class ProfileSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = User | ||
fields = '__all__' | ||
|
||
def retrieve(self,instance): | ||
return instance | ||
|
||
|
Empty file.
Oops, something went wrong.