1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 07:01:12 +00:00

show 'profile' in home;add profile-modify in setting

This commit is contained in:
llj
2012-06-20 14:18:23 +08:00
parent bd54b31a0a
commit 473cf33b97
8 changed files with 106 additions and 17 deletions

View File

@@ -1,4 +1,4 @@
body,h1,h2,h3,h4,h5,h6,p,ul,ol,li,dl,dt,dd,blockquote,form,input,button,img { margin:0; padding:0; }
body,h1,h2,h3,h4,h5,h6,p,ul,ol,li,dl,dt,dd,blockquote,form,input,textarea,button,img { margin:0; padding:0; }
ul > li { list-style:none; }
a { color:#ee8833; text-decoration:none; font-weight:bold; }
a:hover { color: #ff9933; text-decoration: underline; }
@@ -185,7 +185,7 @@ p.path, p.access-notice { margin: 12px 0 6px 0; }
line-height:20px;
background: #fff url('../img/li.gif') no-repeat scroll left 6px;
}
/* profile */
/* avatar */
.avatar-op {
width:321px;
margin:45px 0 0 300px;
@@ -199,13 +199,34 @@ p.path, p.access-notice { margin: 12px 0 6px 0; }
.avatar-op-con {
padding-left:5px;
}
.avatar-op .avatar {
.avatar-op .avatar,
.home-profile .avatar {
border-radius: 10px;
-moz-border-radius: 10px;
}
.upload-new-avatar-hd {
margin-top:15px;
}
/*user-basic-info*/
#user-basic-info h2 {
margin:12px 0 15px;
}
#user-basic-info label {
width:5em;
}
#user-basic-info .text-input,
#user-basic-info textarea {
width:260px;
margin-bottom:5px;
}
#user-basic-info textarea {
vertical-align:text-top;
height:150px;
}
#user-basic-info .submit {
margin-left:5em;
}
/*narrow-panel: for form pages*/
.narrow-panel {
width:25em;
@@ -279,6 +300,13 @@ p.path, p.access-notice { margin: 12px 0 6px 0; }
background-image:none;
}
/*myhome*/
.home-profile {
margin:3px 0 15px;
}
.home-profile .avatar {
float:left;
margin-right:20px;
}
.mygroup {
display:inline-block;
width:70px;

View File

@@ -0,0 +1,8 @@
from django.db import models
from django.contrib.auth.models import User
class Profile(models.Model):
user = models.EmailField(unique=True)
nickname = models.CharField(max_length=256, blank=True)
intro = models.TextField(max_length=256, blank=True)

View File

@@ -1,16 +1,21 @@
{% extends "profile/profile_base.html" %}
{% block left_panel %}
<h3>操作</h3>
<ul class="with-bg">
<li><a href="{{ SITE_ROOT }}avatar/add/">上传头像</a></li>
<li><a href="{{ SITE_ROOT }}accounts/password/change/">修改网站帐号密码</a></li>
<li><a href="{{ SITE_ROOT }}profile/list_user/">所有已登录的计算机</a></li>
</ul>
{% endblock %}
{% block right_panel %}
<h2>绑定个人 ID</h2>
<div id="user-basic-info">
<h2>个人基本信息修改</h2>
<form action="" method="post">
{% if error_msg %}
<p class="error">{{ error_msg }}</p>
{% endif %}
<label>个人 ID:</label><br/>
<input id="id_ccnet_user_id" class="ccnet_id" type="text" name="ccnet_user_id" value="{{ origin_id }}" /><br/>
<input type="submit" value="提交" />
<label>昵称:</label><input type="text" name="nickname" value="{{ nickname }}" class="text-input" /><br/>
<label>自我介绍:</label><textarea name="intro">{{ intro }}</textarea><br />
<input type="submit" value="提交" class="submit" />
</form>
</div>
{% endblock %}

View File

@@ -3,8 +3,9 @@
{% block left_panel %}
<h3>操作</h3>
<ul class="with-bg">
<li><a href="{{ SITE_ROOT }}accounts/password/change/">修改网站帐号密码</a></li>
<li><a href="{{ SITE_ROOT }}profile/">修改昵称等基本信息</a></li>
<li><a href="{{ SITE_ROOT }}avatar/add/">上传头像</a></li>
<li><a href="{{ SITE_ROOT }}accounts/password/change/">修改网站帐号密码</a></li>
</ul>
{% endblock %}

View File

@@ -1,6 +1,7 @@
from django.conf.urls.defaults import *
urlpatterns = patterns('profile.views',
url(r'^$', 'list_userids', name="list_userids"),
url(r'^list_user/$', 'list_userids', name="list_userids"),
url(r'^$', 'edit_profile', name="edit_profile"),
url(r'^logout/$', 'logout_relay', name="logout_relay"),
)

View File

@@ -8,6 +8,7 @@ from seaserv import ccnet_rpc, get_binding_peerids
from pysearpc import SearpcError
from utils import go_error
from models import Profile
@login_required
def list_userids(request):
@@ -30,3 +31,30 @@ def logout_relay(request):
return go_error(request, e.msg)
return HttpResponseRedirect(reverse('list_userids'))
def edit_profile(request):
profile = Profile.objects.filter(user=request.user.username)
if not profile:
Profile.objects.create(user=request.user.username, nickname='', intro='')
profile = Profile.objects.filter(user=request.user.username)[0]
if request.method == 'GET':
pass
if request.method == 'POST':
new_nickname = request.POST.get('nickname', '')
new_intro = request.POST.get('intro', '')
if new_nickname != profile.nickname:
profile.nickname = new_nickname
profile.save()
if new_intro != profile.intro:
profile.intro = new_intro
profile.save()
return render_to_response('profile/set_profile.html', {
'nickname':profile.nickname,
'intro':profile.intro,
},
context_instance=RequestContext(request))

View File

@@ -4,14 +4,20 @@
{% block nav_myhome_class %}class="cur"{% endblock %}
{% block left_panel %}
<h3>我的基本信息</h3>
<div class="home-profile w100 ovhd">
{% avatar myname 80 %}
<p class="fleft">昵称:{{ nickname }}</p>
</div>
<h3>已用空间</h3>
<p>{{ quota_usage|filesizeformat }} / 2 GB</p>
{% if request.user.org %}
<h3>所属企业</h3>
<p>{{ request.user.org.org_name }}</p>
{% endif %}
<h3>已用空间</h3>
<p>{{ quota_usage|filesizeformat }} / 2 GB</p>
<h3>我管理的小组</h3>
{% if groups_manage %}
<ul>

View File

@@ -29,6 +29,7 @@ from seahub.contacts.models import Contact
from forms import AddUserForm
from utils import go_permission_error, go_error, list_to_string, \
get_httpserver_root, get_ccnetapplet_root, gen_token
from seahub.profile.models import Profile
@login_required
def root(request):
@@ -553,7 +554,18 @@ def myhome(request):
else:
groups_join.append(group)
#get nickname
if not Profile.objects.filter(user=request.user.username):
nickname = '暂无'
else:
profile = Profile.objects.filter(user=request.user.username)[0]
nickname = profile.nickname
if not nickname:
nickname = '暂无'
return render_to_response('myhome.html', {
"myname": email,
"nickname": nickname,
"owned_repos": owned_repos,
"quota_usage": quota_usage,
"in_repos": in_repos,