mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-15 06:44:16 +00:00
[event]show events in myhome
This commit is contained in:
@@ -12,12 +12,6 @@ try:
|
||||
except ImportError:
|
||||
BUSINESS_MODE = False
|
||||
|
||||
try:
|
||||
from settings import EVENTS_CONFIG_FILE
|
||||
SHOW_EVENTS = True
|
||||
except ImportError:
|
||||
SHOW_EVENTS = False
|
||||
|
||||
def base(request):
|
||||
"""
|
||||
Add seahub base configure to the context.
|
||||
@@ -38,6 +32,5 @@ def base(request):
|
||||
'cloud_mode': request.cloud_mode,
|
||||
'org': org,
|
||||
'base_template': base_template,
|
||||
'show_events': SHOW_EVENTS,
|
||||
}
|
||||
|
||||
|
@@ -610,6 +610,19 @@ ul.with-bg li {
|
||||
width:262px;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
.event-item {
|
||||
padding:2px 0 10px;
|
||||
border-bottom:1px solid #eee;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
.event-item .time {
|
||||
color:#888;
|
||||
}
|
||||
.event-item .avatar {
|
||||
border-radius:2px;
|
||||
margin-right:5px;
|
||||
vertical-align:middle;
|
||||
}
|
||||
/* avatar */
|
||||
.avatar-op .avatar,
|
||||
.home-profile .avatar,
|
||||
|
@@ -1,64 +0,0 @@
|
||||
{% extends base_template %}
|
||||
{% load seahub_tags avatar_tags%}
|
||||
{% load url from future %}
|
||||
|
||||
{% block extra_style %}
|
||||
<style type="text/css">
|
||||
|
||||
.event-item {
|
||||
padding-top: 5px;
|
||||
margin-top: 10px;
|
||||
border-top: 1px dashed gray;
|
||||
}
|
||||
|
||||
#events {
|
||||
width: 600px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block main_panel %}
|
||||
<h2>最近事件</h2>
|
||||
<ul id="events">
|
||||
{% for ev in events %}
|
||||
<li class="event-item">
|
||||
{% if ev.etype == 'repo-update' %}
|
||||
{% with author=ev.commit.creator_name commit=ev.commit repo=ev.repo %}
|
||||
{% avatar author 24 %}<a href="{% url 'user_profile' author %}" class="name" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a>
|
||||
在 {{ commit.ctime|translate_commit_time }} 更新了目录
|
||||
<a href="{{SITE_ROOT}}repo/{{repo.id}}">{{ repo.name }}</a>
|
||||
<a class="lsch" href="{{ SITE_ROOT }}repo/history/changes/{{ repo.id }}/?commit_id={{ commit.id }}" data="{{ commit.props.ctime|tsstr_sec }}">详情</a>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
{% if ev.etype == 'repo-create' %}
|
||||
{% with author=ev.creator repo_id=ev.repo_id repo_name=ev.repo_name %}
|
||||
{% avatar author 24 %}<a href="{% url 'user_profile' author %}" class="name" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a>
|
||||
在 {{ ev.timestamp|translate_commit_time }} 创建了目录
|
||||
<a href="{{SITE_ROOT}}repo/{{repo_id}}">{{ repo_name }}</a>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
{% if ev.etype == 'repo-delete' %}
|
||||
{% with author=ev.repo_owner repo_name=ev.repo_name %}
|
||||
{% avatar author 24 %}<a href="{% url 'user_profile' author %}" class="name" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a>
|
||||
在 {{ ev.timestamp|translate_commit_time }} 删除了目录
|
||||
<span>{{ repo_name }}</span>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div id="ls-ch" class="hide"></div><!--list modification details of a commit-->
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
<script type="text/javascript">
|
||||
{% include 'snippets/list_commit_detail.html' %}
|
||||
$('#back').click(function() {
|
||||
location.href = $(this).attr('data');
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
@@ -3,8 +3,8 @@
|
||||
{% load url from future %}
|
||||
|
||||
{% block nav_myhome_class %}class="cur"{% endblock %}
|
||||
{% block left_panel %}
|
||||
|
||||
{% block left_panel %}
|
||||
<h3>我的基本信息</h3>
|
||||
<div class="home-profile w100 ovhd">
|
||||
<a href="{{ SITE_ROOT }}profile/" class="no-deco">{% avatar myname 48 %}</a>
|
||||
@@ -52,6 +52,40 @@
|
||||
<!-- 共享给我的同步目录 -->
|
||||
{% include "snippets/shared_in_repos.html" %}
|
||||
|
||||
{% if events %}
|
||||
<h3>最近事件</h3>
|
||||
<ul id="events">
|
||||
{% for ev in events %}
|
||||
<li class="event-item">
|
||||
{% if ev.etype == 'repo-update' %}
|
||||
{% with author=ev.commit.creator_name commit=ev.commit repo=ev.repo %}
|
||||
<p class="time">{{ commit.ctime|translate_commit_time }}</p>
|
||||
<p>{% avatar author 24 %}<a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a>
|
||||
更新了目录
|
||||
<a href="{{SITE_ROOT}}repo/{{repo.id}}">{{ repo.name }}</a>
|
||||
<a class="lsch" href="{{ SITE_ROOT }}repo/history/changes/{{ repo.id }}/?commit_id={{ commit.id }}" data="{{ commit.props.ctime|tsstr_sec }}">详情</a></P>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
{% if ev.etype == 'repo-create' %}
|
||||
{% with author=ev.creator repo_id=ev.repo_id repo_name=ev.repo_name %}
|
||||
<p class="time">{{ ev.timestamp|translate_commit_time }}</p>
|
||||
<p>{% avatar author 24 %}<a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a> 创建了目录 <a href="{{SITE_ROOT}}repo/{{repo_id}}">{{ repo_name }}</a></p>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
{% if ev.etype == 'repo-delete' %}
|
||||
{% with author=ev.repo_owner repo_name=ev.repo_name %}
|
||||
<p class="time">{{ ev.timestamp|translate_commit_time }}</p>
|
||||
<p>{% avatar author 24 %}<a href="{% url 'user_profile' author %}" title="{{ author|email2nickname}}">{{ author|email2nickname }}</a> 删除了目录 {{ repo_name }}</p>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div id="ls-ch" class="hide"></div><!--list modification details of a commit-->
|
||||
{% endif %}
|
||||
|
||||
{% url 'share_repo' as repo_share_url %}
|
||||
{% with post_url=repo_share_url tips='' %}
|
||||
{% include "snippets/repo_share_form.html" %}
|
||||
@@ -68,5 +102,9 @@
|
||||
{% with post_url=repo_create_url %}
|
||||
{% include "snippets/repo_create_js.html" %}
|
||||
{% endwith %}
|
||||
|
||||
{% if events %}
|
||||
{% include 'snippets/list_commit_detail.html' %}
|
||||
{% endif %}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
@@ -29,10 +29,5 @@
|
||||
<li>
|
||||
<a href="{{ SITE_ROOT }}contacts/" {% block nav_contacts_class %}{% endblock %}>通讯录</a>
|
||||
</li>
|
||||
{% if show_events %}
|
||||
<li>
|
||||
<a href="{{ SITE_ROOT }}events/">事件流</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
2
urls.py
2
urls.py
@@ -99,8 +99,6 @@ urlpatterns = patterns('',
|
||||
url(r'^sys/useradmin/$', sys_useradmin, name='sys_useradmin'),
|
||||
url(r'^sys/orgadmin/$', sys_org_admin, name='sys_org_admin'),
|
||||
url(r'^sys/groupadmin/$', sys_group_admin, name='sys_group_admin'),
|
||||
|
||||
url(r'^events/$', show_events, name='show_events'),
|
||||
)
|
||||
|
||||
if settings.DEBUG:
|
||||
|
17
views.py
17
views.py
@@ -819,6 +819,19 @@ def myhome(request):
|
||||
|
||||
allow_public_share = True if not CLOUD_MODE else False
|
||||
|
||||
# events
|
||||
if EVENTS_CONFIG_FILE:
|
||||
ev_session = get_seafevents_session()
|
||||
events = seafevents.get_user_events(ev_session, request.user.username, 0, 10)
|
||||
ev_session.close()
|
||||
for ev in events:
|
||||
if ev.etype == 'repo-update':
|
||||
ev.repo = get_repo(ev.repo_id)
|
||||
ev.commit = seafserv_threaded_rpc.get_commit(ev.commit_id)
|
||||
else:
|
||||
events = None
|
||||
|
||||
|
||||
return render_to_response('myhome.html', {
|
||||
"myname": email,
|
||||
"nickname": nickname,
|
||||
@@ -834,6 +847,7 @@ def myhome(request):
|
||||
"orgmsg_list": orgmsg_list,
|
||||
"create_shared_repo": False,
|
||||
"allow_public_share": allow_public_share,
|
||||
"events": events,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
@@ -2424,7 +2438,7 @@ def use_flash_for_pdf(request):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
'''
|
||||
@login_required
|
||||
def show_events(request):
|
||||
ev_session = get_seafevents_session()
|
||||
@@ -2438,3 +2452,4 @@ def show_events(request):
|
||||
return render_to_response ('events.html', {
|
||||
'events': events,
|
||||
}, context_instance=RequestContext(request))
|
||||
'''
|
||||
|
Reference in New Issue
Block a user