Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gothack329 committed Mar 5, 2018
1 parent cb9c42d commit 1cf8297
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 19 deletions.
Binary file modified db.sqlite3
Binary file not shown.
4 changes: 4 additions & 0 deletions static/bootstrap/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ div.container-fluid {
box-sizing: border-box;
}

.container {
width:80%;
}

.sidebar , .content {
margin-top:10px;
}
Expand Down
Binary file modified userpage/__pycache__/admin.cpython-36.pyc
Binary file not shown.
Binary file modified userpage/__pycache__/models.cpython-36.pyc
Binary file not shown.
Binary file modified userpage/__pycache__/views.cpython-36.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion userpage/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Register your models here.
class ProfileAdmin(admin.ModelAdmin):
list_display = ('user','location','avatar')
list_display = ('user','address','avatar','invite_code','mobile','wechat','weibo','facebook','twitter','instagram')
admin.site.register(Profile,ProfileAdmin)


Expand Down
67 changes: 67 additions & 0 deletions userpage/migrations/0008_auto_20180305_1717.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Generated by Django 2.0.2 on 2018-03-05 09:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('userpage', '0007_point'),
]

operations = [
migrations.RemoveField(
model_name='profile',
name='location',
),
migrations.AddField(
model_name='profile',
name='address',
field=models.TextField(blank=True, max_length=500),
),
migrations.AddField(
model_name='profile',
name='facebook',
field=models.CharField(blank=True, max_length=128),
),
migrations.AddField(
model_name='profile',
name='instagram',
field=models.CharField(blank=True, max_length=128),
),
migrations.AddField(
model_name='profile',
name='invite_code',
field=models.CharField(default='null', max_length=30),
),
migrations.AddField(
model_name='profile',
name='mobile',
field=models.CharField(blank=True, max_length=128),
),
migrations.AddField(
model_name='profile',
name='twitter',
field=models.CharField(blank=True, max_length=128),
),
migrations.AddField(
model_name='profile',
name='wechat',
field=models.CharField(blank=True, max_length=128),
),
migrations.AddField(
model_name='profile',
name='weibo',
field=models.CharField(blank=True, max_length=128),
),
migrations.AlterField(
model_name='point',
name='event',
field=models.CharField(choices=[('publish', '发布文章'), ('comment', '发表评论'), ('commented', '文章被评论'), ('register', '新用户注册')], max_length=16),
),
migrations.AlterField(
model_name='profile',
name='point',
field=models.IntegerField(default=0),
),
]
Binary file not shown.
10 changes: 9 additions & 1 deletion userpage/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
#bio = models.TextField(max_length=500, blank=True)
location = models.CharField(max_length=30, blank=True)
address = models.TextField(max_length=500, blank=True)
#birth_date = models.DateField(null=True, blank=True)
avatar = models.ImageField(upload_to='static/avatar/', default='static/avatar/default.png', blank=True, null=True)
point = models.IntegerField(default=0)
unread = models.IntegerField(default=0)
invite_code = models.CharField(max_length=30,default='null')
mobile = models.CharField(max_length=128, blank=True)
wechat = models.CharField(max_length=128, blank=True)
weibo = models.CharField(max_length=128, blank=True)
instagram = models.CharField(max_length=128, blank=True)
facebook = models.CharField(max_length=128, blank=True)
twitter = models.CharField(max_length=128, blank=True)


def __str__(self):
return self.user.username
Expand Down
20 changes: 3 additions & 17 deletions userpage/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ def profile(request, username):
# update profile
if request.method == 'POST':
user_form = UserForm(request.POST, instance=request.user)
profile_form = ProfileForm(request.POST, instance=request.user.profile)
profile_form = ProfileForm(request.POST, request.FILES, instance=request.user.profile)

if user_form.is_valid() and profile_form.is_valid():
user_form.save()
profile_form.save()
#messages.success(request, '用户资料更新成功!')
return redirect('.')
#return redirect('settings:profile')

else:
messages.error(request, user_form.errors)
#messages.error(request, _('Please correct the error below.'))
Expand Down Expand Up @@ -129,8 +129,7 @@ def register(request):
updatepoint = Point.objects.create(user=u,point_record=point,event="register")

user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
login(request, user)

return redirect(request.POST['referer'])
else:
Expand All @@ -149,16 +148,3 @@ def register(request):
return render(request,'userpage/register.html',{'form':obj,'referer':refer})















0 comments on commit 1cf8297

Please sign in to comment.