-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jan-Olov Eriksson
authored and
Jan-Olov Eriksson
committed
Dec 9, 2019
1 parent
1b020bc
commit 62bd972
Showing
12 changed files
with
168 additions
and
14 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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
from django.contrib import admin | ||
|
||
from .models import Forum, Thread, Post, UpVote, Notification | ||
from .models import Forum, Thread, Post, UserProfile, UpVote, Notification | ||
|
||
admin.site.register(Forum) | ||
admin.site.register(Thread) | ||
admin.site.register(Post) | ||
admin.site.register(UserProfile) | ||
admin.site.register(UpVote) | ||
admin.site.register(Notification) |
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 |
---|---|---|
@@ -1,5 +1,22 @@ | ||
from django import forms | ||
|
||
from .models import UserProfile | ||
|
||
|
||
class SearchForm(forms.Form): | ||
q = forms.CharField(label='Search', max_length=200) | ||
|
||
|
||
class UserProfileForm(forms.ModelForm): | ||
class Meta: | ||
model = UserProfile | ||
fields = ( | ||
'first_name', | ||
'last_name', | ||
'bio', | ||
'location', | ||
'gender', | ||
'web_site', | ||
'github_url', | ||
'signature', | ||
) |
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 @@ | ||
# Generated by Django 2.2.8 on 2019-12-07 18:24 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('forums', '0007_auto_20191203_0820'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='UserProfile', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('bio', models.TextField(blank=True, max_length=1000)), | ||
('location', models.CharField(blank=True, max_length=50)), | ||
('gender', models.TextField(choices=[('M', 'Male'), ('F', 'Female'), ('O', 'Other')], default='N', max_length=1)), | ||
('web_site', models.URLField(blank=True)), | ||
('github_url', models.URLField(blank=True)), | ||
('signature', models.TextField(blank=True)), | ||
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
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.2.8 on 2019-12-07 18:35 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('forums', '0008_userprofile'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='userprofile', | ||
name='gender', | ||
field=models.TextField(choices=[('N', 'NotProvided'), ('M', 'Male'), ('F', 'Female'), ('O', 'Other')], default='N', max_length=1), | ||
), | ||
] |
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,20 @@ | ||
# Generated by Django 2.2.8 on 2019-12-07 19:14 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('forums', '0009_auto_20191207_1835'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='userprofile', | ||
name='user', | ||
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='profile', to=settings.AUTH_USER_MODEL), | ||
), | ||
] |
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.2.8 on 2019-12-09 16:24 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('forums', '0010_auto_20191207_1914'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='userprofile', | ||
name='first_name', | ||
field=models.CharField(blank=True, max_length=100), | ||
), | ||
migrations.AddField( | ||
model_name='userprofile', | ||
name='last_name', | ||
field=models.CharField(blank=True, max_length=100), | ||
), | ||
] |
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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
from django.views.generic.edit import UpdateView | ||
from django.urls import reverse_lazy | ||
from django.views.generic.edit import UpdateView | ||
|
||
from django.contrib.auth import get_user_model | ||
from forums.forms import UserProfileForm | ||
from forums.models import UserProfile | ||
|
||
|
||
class UserUpdate(UpdateView): | ||
model = get_user_model() | ||
fields = ['first_name', 'last_name'] | ||
class UserProfileUpdate(UpdateView): | ||
model = UserProfile | ||
success_url = reverse_lazy('home') | ||
form_class = UserProfileForm |
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