mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-31 22:54:11 +00:00
show 'profile' in home;add profile-modify in setting
This commit is contained in:
@@ -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; }
|
ul > li { list-style:none; }
|
||||||
a { color:#ee8833; text-decoration:none; font-weight:bold; }
|
a { color:#ee8833; text-decoration:none; font-weight:bold; }
|
||||||
a:hover { color: #ff9933; text-decoration: underline; }
|
a:hover { color: #ff9933; text-decoration: underline; }
|
||||||
@@ -185,7 +185,7 @@ p.path, p.access-notice { margin: 12px 0 6px 0; }
|
|||||||
line-height:20px;
|
line-height:20px;
|
||||||
background: #fff url('../img/li.gif') no-repeat scroll left 6px;
|
background: #fff url('../img/li.gif') no-repeat scroll left 6px;
|
||||||
}
|
}
|
||||||
/* profile */
|
/* avatar */
|
||||||
.avatar-op {
|
.avatar-op {
|
||||||
width:321px;
|
width:321px;
|
||||||
margin:45px 0 0 300px;
|
margin:45px 0 0 300px;
|
||||||
@@ -199,13 +199,34 @@ p.path, p.access-notice { margin: 12px 0 6px 0; }
|
|||||||
.avatar-op-con {
|
.avatar-op-con {
|
||||||
padding-left:5px;
|
padding-left:5px;
|
||||||
}
|
}
|
||||||
.avatar-op .avatar {
|
.avatar-op .avatar,
|
||||||
|
.home-profile .avatar {
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
-moz-border-radius: 10px;
|
-moz-border-radius: 10px;
|
||||||
}
|
}
|
||||||
.upload-new-avatar-hd {
|
.upload-new-avatar-hd {
|
||||||
margin-top:15px;
|
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: for form pages*/
|
||||||
.narrow-panel {
|
.narrow-panel {
|
||||||
width:25em;
|
width:25em;
|
||||||
@@ -279,6 +300,13 @@ p.path, p.access-notice { margin: 12px 0 6px 0; }
|
|||||||
background-image:none;
|
background-image:none;
|
||||||
}
|
}
|
||||||
/*myhome*/
|
/*myhome*/
|
||||||
|
.home-profile {
|
||||||
|
margin:3px 0 15px;
|
||||||
|
}
|
||||||
|
.home-profile .avatar {
|
||||||
|
float:left;
|
||||||
|
margin-right:20px;
|
||||||
|
}
|
||||||
.mygroup {
|
.mygroup {
|
||||||
display:inline-block;
|
display:inline-block;
|
||||||
width:70px;
|
width:70px;
|
||||||
|
@@ -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)
|
||||||
|
|
||||||
|
@@ -1,16 +1,21 @@
|
|||||||
{% extends "profile/profile_base.html" %}
|
{% 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 %}
|
{% block right_panel %}
|
||||||
<h2>绑定个人 ID</h2>
|
<div id="user-basic-info">
|
||||||
|
<h2>个人基本信息修改</h2>
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
{% if error_msg %}
|
<label>昵称:</label><input type="text" name="nickname" value="{{ nickname }}" class="text-input" /><br/>
|
||||||
<p class="error">{{ error_msg }}</p>
|
<label>自我介绍:</label><textarea name="intro">{{ intro }}</textarea><br />
|
||||||
{% endif %}
|
<input type="submit" value="提交" class="submit" />
|
||||||
<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="提交" />
|
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -3,8 +3,9 @@
|
|||||||
{% block left_panel %}
|
{% block left_panel %}
|
||||||
<h3>操作</h3>
|
<h3>操作</h3>
|
||||||
<ul class="with-bg">
|
<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 }}avatar/add/">上传头像</a></li>
|
||||||
|
<li><a href="{{ SITE_ROOT }}accounts/password/change/">修改网站帐号密码</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
from django.conf.urls.defaults import *
|
from django.conf.urls.defaults import *
|
||||||
|
|
||||||
urlpatterns = patterns('profile.views',
|
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"),
|
url(r'^logout/$', 'logout_relay', name="logout_relay"),
|
||||||
)
|
)
|
||||||
|
@@ -8,6 +8,7 @@ from seaserv import ccnet_rpc, get_binding_peerids
|
|||||||
from pysearpc import SearpcError
|
from pysearpc import SearpcError
|
||||||
|
|
||||||
from utils import go_error
|
from utils import go_error
|
||||||
|
from models import Profile
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def list_userids(request):
|
def list_userids(request):
|
||||||
@@ -30,3 +31,30 @@ def logout_relay(request):
|
|||||||
return go_error(request, e.msg)
|
return go_error(request, e.msg)
|
||||||
|
|
||||||
return HttpResponseRedirect(reverse('list_userids'))
|
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))
|
||||||
|
@@ -4,14 +4,20 @@
|
|||||||
{% block nav_myhome_class %}class="cur"{% endblock %}
|
{% block nav_myhome_class %}class="cur"{% endblock %}
|
||||||
{% block left_panel %}
|
{% 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 %}
|
{% if request.user.org %}
|
||||||
<h3>所属企业</h3>
|
<h3>所属企业</h3>
|
||||||
<p>{{ request.user.org.org_name }}</p>
|
<p>{{ request.user.org.org_name }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<h3>已用空间</h3>
|
|
||||||
<p>{{ quota_usage|filesizeformat }} / 2 GB</p>
|
|
||||||
|
|
||||||
<h3>我管理的小组</h3>
|
<h3>我管理的小组</h3>
|
||||||
{% if groups_manage %}
|
{% if groups_manage %}
|
||||||
<ul>
|
<ul>
|
||||||
|
12
views.py
12
views.py
@@ -29,6 +29,7 @@ from seahub.contacts.models import Contact
|
|||||||
from forms import AddUserForm
|
from forms import AddUserForm
|
||||||
from utils import go_permission_error, go_error, list_to_string, \
|
from utils import go_permission_error, go_error, list_to_string, \
|
||||||
get_httpserver_root, get_ccnetapplet_root, gen_token
|
get_httpserver_root, get_ccnetapplet_root, gen_token
|
||||||
|
from seahub.profile.models import Profile
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def root(request):
|
def root(request):
|
||||||
@@ -552,8 +553,19 @@ def myhome(request):
|
|||||||
groups_manage.append(group)
|
groups_manage.append(group)
|
||||||
else:
|
else:
|
||||||
groups_join.append(group)
|
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', {
|
return render_to_response('myhome.html', {
|
||||||
|
"myname": email,
|
||||||
|
"nickname": nickname,
|
||||||
"owned_repos": owned_repos,
|
"owned_repos": owned_repos,
|
||||||
"quota_usage": quota_usage,
|
"quota_usage": quota_usage,
|
||||||
"in_repos": in_repos,
|
"in_repos": in_repos,
|
||||||
|
Reference in New Issue
Block a user