1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-06 17:33:18 +00:00

Add repo last modify time

This commit is contained in:
xiez
2012-06-28 16:58:09 +08:00
parent ad9ce0e10b
commit 05a4cc9d0a
6 changed files with 57 additions and 9 deletions

View File

@@ -45,12 +45,15 @@ def translate_commit_desc(value):
@register.filter(name='translate_commit_time') @register.filter(name='translate_commit_time')
def translate_commit_time(value): def translate_commit_time(value):
"""Translate commit time to human frindly format instead of timestamp""" """Translate commit time to human frindly format instead of timestamp"""
limit = 14 * 24 * 60 * 60 # Timestamp with in two weeks will be translated
if hasattr(value, 'strftime'): if type(value) == type(1): # check whether value is int
val = datetime.fromtimestamp(value)
elif isinstance(value, dt):
val = datetime.fromtimestamp(int(value.strftime("%s"))) val = datetime.fromtimestamp(int(value.strftime("%s")))
else: else:
val = datetime.fromtimestamp(value) return value
limit = 14 * 24 * 60 * 60 # Timestamp with in two weeks will be translated
now = datetime.now() now = datetime.now()
delta = now - (val - dt.timedelta(0, 0, val.microsecond)) delta = now - (val - dt.timedelta(0, 0, val.microsecond))

View File

@@ -43,7 +43,8 @@
<table> <table>
<tr> <tr>
<th width="20%">名字</th> <th width="20%">名字</th>
<th width="48%">描述</th> <th width="28%">描述</th>
<th width="20">最后更新时间</th>
<th width="22%">共享来源</th> <th width="22%">共享来源</th>
<th width="10%">操作</th> <th width="10%">操作</th>
</tr> </tr>
@@ -52,6 +53,11 @@
<tr> <tr>
<td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/">{{ repo.props.name }}</a></td> <td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/">{{ repo.props.name }}</a></td>
<td>{{ repo.props.desc }}</td> <td>{{ repo.props.desc }}</td>
{% if repo.latest_modify %}
<td>{{ repo.latest_modify|translate_commit_time }}</td>
{% else %}
<td>—— ——</td>
{% endif %}
<td>{{ repo.share_from }}</td> <td>{{ repo.share_from }}</td>
<td> <td>
<img src="{{ MEDIA_URL }}img/download-20.png" class="download vh" data="{{ SITE_ROOT }}seafile_access_check/?repo_id={{ repo.props.id }}" alt="下载" title="下载" /> <img src="{{ MEDIA_URL }}img/download-20.png" class="download vh" data="{{ SITE_ROOT }}seafile_access_check/?repo_id={{ repo.props.id }}" alt="下载" title="下载" />

View File

@@ -7,7 +7,7 @@ from django.template import RequestContext
from auth.decorators import login_required from auth.decorators import login_required
from seaserv import ccnet_rpc, ccnet_threaded_rpc, seafserv_threaded_rpc, get_repo, \ from seaserv import ccnet_rpc, ccnet_threaded_rpc, seafserv_threaded_rpc, get_repo, \
get_group_repoids, check_group_staff get_group_repoids, check_group_staff, get_commits
from pysearpc import SearpcError from pysearpc import SearpcError
from models import GroupMessage, MessageReply from models import GroupMessage, MessageReply
@@ -139,6 +139,12 @@ def render_group_info(request, group_id, form):
repo.share_from_me = True repo.share_from_me = True
else: else:
repo.share_from_me = False repo.share_from_me = False
try:
repo.latest_modify = get_commits(repo.id, 0, 1)[0].ctime
except:
repo.latest_modify = None
continue
repos.append(repo) repos.append(repo)
# remove user notifications # remove user notifications

View File

@@ -1,5 +1,5 @@
{% extends "myhome_base.html" %} {% extends "myhome_base.html" %}
{% load avatar_tags %} {% load seahub_tags avatar_tags %}
{% block nav_myhome_class %}class="cur"{% endblock %} {% block nav_myhome_class %}class="cur"{% endblock %}
{% block left_panel %} {% block left_panel %}
@@ -94,7 +94,8 @@
<table> <table>
<tr> <tr>
<th width="34%">名字</th> <th width="34%">名字</th>
<th width="54%">描述</th> <th width="34%">描述</th>
<th width="20%">最后更新时间</th>
<th width="12%">操作</th> <th width="12%">操作</th>
</tr> </tr>
@@ -102,6 +103,11 @@
<tr> <tr>
<td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/">{{ repo.props.name }}</a></td> <td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/">{{ repo.props.name }}</a></td>
<td>{{ repo.props.desc }}</td> <td>{{ repo.props.desc }}</td>
{% if repo.latest_modify %}
<td>{{ repo.latest_modify|translate_commit_time }}</td>
{% else %}
<td>—— ——</td>
{% endif %}
<td> <td>
<img src="{{ MEDIA_URL }}img/download-20.png" data="{{ repo.props.id }}" class="download-btn vh" title="下载" alt="下载" /> <img src="{{ MEDIA_URL }}img/download-20.png" data="{{ repo.props.id }}" class="download-btn vh" title="下载" alt="下载" />
<img src="{{ MEDIA_URL }}img/share-20.png" data="{{ repo.props.id }}" class="repo-share-btn vh" title="共享" alt="共享" /> <img src="{{ MEDIA_URL }}img/share-20.png" data="{{ repo.props.id }}" class="repo-share-btn vh" title="共享" alt="共享" />
@@ -120,7 +126,8 @@
<tr> <tr>
<th width="25%">名字</th> <th width="25%">名字</th>
<th width="20%">共享来源</th> <th width="20%">共享来源</th>
<th width="45%">描述</th> <th width="25%">描述</th>
<th width="20%">最后更新时间</th>
<th width="10%">操作</th> <th width="10%">操作</th>
</tr> </tr>
@@ -129,6 +136,11 @@
<td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}">{{ repo.props.name }}</a></td> <td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}">{{ repo.props.name }}</a></td>
<td>{{ repo.props.shared_email }}</td> <td>{{ repo.props.shared_email }}</td>
<td>{{ repo.props.desc }}</td> <td>{{ repo.props.desc }}</td>
{% if repo.latest_modify %}
<td>{{ repo.latest_modify|translate_commit_time }}</td>
{% else %}
<td>—— ——</td>
{% endif %}
<td> <td>
<img src="{{ MEDIA_URL }}img/download-20.png" data="{{ repo.props.id }}" class="download-btn vh" title="下载" alt="下载" /> <img src="{{ MEDIA_URL }}img/download-20.png" data="{{ repo.props.id }}" class="download-btn vh" title="下载" alt="下载" />
<img src="{{ MEDIA_URL }}img/delete-20.png" data="{{ SITE_ROOT }}shareadmin/removeshare/?repo_id={{ repo.id }}&from={{ repo.shared_email }}&to={{ request.user }}" class="unshare-btn vh" title="取消共享" alt="取消共享" /> <img src="{{ MEDIA_URL }}img/delete-20.png" data="{{ SITE_ROOT }}shareadmin/removeshare/?repo_id={{ repo.id }}&from={{ repo.shared_email }}&to={{ request.user }}" class="unshare-btn vh" title="取消共享" alt="取消共享" />

View File

@@ -7,6 +7,8 @@ from django.shortcuts import render_to_response
from django.template import RequestContext from django.template import RequestContext
from django.utils.hashcompat import sha_constructor from django.utils.hashcompat import sha_constructor
from seaserv import get_commits
def go_permission_error(request, msg=None): def go_permission_error(request, msg=None):
""" """
Return permisson error page. Return permisson error page.
@@ -72,3 +74,16 @@ def validate_group_name(group_name):
""" """
return re.match('^\w+$', group_name, re.U) return re.match('^\w+$', group_name, re.U)
def calculate_repo_last_modify(repo_list):
"""
Get last modify time for repo.
"""
for repo in repo_list:
try:
repo.latest_modify = get_commits(repo.id, 0, 1)[0].ctime
except:
repo.latest_modify = None
continue

View File

@@ -29,7 +29,8 @@ from seahub.contacts.models import Contact
from seahub.notifications.models import UserNotification from seahub.notifications.models import UserNotification
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, \
calculate_repo_last_modify
from seahub.profile.models import Profile from seahub.profile.models import Profile
@login_required @login_required
@@ -536,11 +537,15 @@ def myhome(request):
email = request.user.username email = request.user.username
quota_usage = seafserv_threaded_rpc.get_user_quota_usage(email) quota_usage = seafserv_threaded_rpc.get_user_quota_usage(email)
# Repos that I own
owned_repos = seafserv_threaded_rpc.list_owned_repos(email) owned_repos = seafserv_threaded_rpc.list_owned_repos(email)
calculate_repo_last_modify(owned_repos)
# Repos that are share to me # Repos that are share to me
in_repos = seafserv_threaded_rpc.list_share_repos(request.user.username, in_repos = seafserv_threaded_rpc.list_share_repos(request.user.username,
'to_email', -1, -1) 'to_email', -1, -1)
calculate_repo_last_modify(in_repos)
# my contacts # my contacts
contacts = Contact.objects.filter(user_email=email) contacts = Contact.objects.filter(user_email=email)
@@ -1133,3 +1138,4 @@ def org_info(request):
'org_users': org_members, 'org_users': org_members,
'groups': groups, 'groups': groups,
}, context_instance=RequestContext(request)) }, context_instance=RequestContext(request))