1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-01 15:23:05 +00:00

Merge branch 'lj'

This commit is contained in:
xiez 2012-05-09 15:47:54 +08:00
commit be5954a669
6 changed files with 89 additions and 65 deletions

View File

@ -192,7 +192,12 @@ div.home-page h2 { font-style: italic; }
span.small-action-link { font-size: 9px; }
input.ccnet_id { width: 400px; }
.notification { background:#FDF; width:580px; margin:10px 0; border:1px solid #faf; padding:10px; }
.notification {
padding:5px;
width:580px;
background:#FDF;
margin:10px 0;
}
.repo-list {
margin-bottom: 12px;
}
@ -239,9 +244,13 @@ input.ccnet_id { width: 400px; }
width:260px;
height:80px;
}
.text-core {
width:272px;
#repo-share-form .ui-autocomplete {
background:#fff;
}
.text-suggestion {
background:none;
#repo-share-form .ui-menu-item {
background-image:none;
}
#repo-share-form a {
color:#e83;
font-weight:normal;
}

File diff suppressed because one or more lines are too long

View File

@ -94,7 +94,6 @@
<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.simplemodal.1.4.1.min.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.cookie.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}js/jquery.textext.js"></script>
<script type="text/javascript" src="{{ MEDIA_URL }}js/utils.js"></script>
{% block extra_script %}{% endblock %}
</body>

View File

@ -9,14 +9,14 @@
{% block right_panel %}
{% if output_msg %}
{% for key, value in output_msg.items %}
{% if key == 'info_msg' %}
<span class="info-msg" style="background-color:lightgreen">{{ value }} 前往<a href="{{ SITE_ROOT }}shareadmin/">共享管理</a>查看</span><br />
{% endif %}
{% if key == 'err_msg' %}
<span class="err-msg" style="background-color:pink">{{ value }}</span><br />
{% endif %}
{% endfor %}
{% for key, value in output_msg.items %}
{% if key == 'info_msg' %}
<p class="notification">{{ value }} 请前往<a href="{{ SITE_ROOT }}shareadmin/">共享管理</a>查看</p>
{% endif %}
{% if key == 'err_msg' %}
<p class="error">{{ value }}</p>
{% endif %}
{% endfor %}
{% endif %}
<h3>我拥有的同步目录</h3>
@ -70,48 +70,74 @@
{% endif %}
<form id="repo-share-form" action="{{ SITE_ROOT }}home/my/" method="post" name="repo-share-form" class="hide">
<label>邮箱(多个邮箱以;分隔)</label><br />
<textarea id="to_email" name="to_email"></textarea>
<label>邮箱</label><br />
<textarea id="to_email" name="to_email"></textarea><br />
<input id="share_repo_id" type="hidden" name="share_repo_id" value="" />
<input type="submit" value="提交" />
<p class="error hide">输入不能为空。</p>
<input type="submit" value="提交" id="share-submit-btn" />
</form>
{% endblock %}
{% block extra_script %}
<script type="text/javascript">
$(".repo-share-btn").click(function() {
repo_id = $(this).attr("data");
$("#share_repo_id").val(repo_id);
$("#repo-share-form").modal({appendTo: "#main", containerCss:{padding:18}});
});
addConfirmTo($('.repo-delete-btn'));
//repo-share-form email autocomplete
$('#to_email').textext({
plugins: 'autocomplete',
autocomplete: {
dropdownPosition: 'below',
render: function(suggestion) {
return suggestion;
}
},
html: {
dropdown: '<div class="text-dropdown"><ul class="text-list"></ul></div>',
suggestion: '<li class="text-suggestion"><span class="text-label"></span></li>'
}
})
.bind('getSuggestions', function(e, data) {
var list = [],
textext = $(e.target).textext()[0],
query = (data ? data.query : '') || '';
$(function() {
//repo-share-form email autocomplete
var contact_list = [];
{% for contact in contacts %}
list.push('{{ contact.contact_email }}');
contact_list.push('{{ contact.contact_email }}');
{% endfor %}
$(this).trigger('setSuggestions', { result: textext.itemManager().filter(list, query) });
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}
$("#to_email")
.bind("keydown", function(event) {
if (event.keyCode === $.ui.keyCode.TAB &&
$(this).data("autocomplete").menu.active) {
event.preventDefault();
}
})
.autocomplete({
appendTo: '#repo-share-form',
autoFocus: true,
delay: 100,
minLength: 0,
source: function(request, response) {
response($.ui.autocomplete.filter(contact_list, extractLast(request.term)));
},
focus: function() {
return false;
},
select: function(event, ui) {
var terms = split(this.value);
terms.pop();
terms.push(ui.item.value);
terms.push("");
this.value = terms.join(", ");
return false;
}
});
$(".repo-share-btn").click(function() {
$("#share_repo_id").val($(this).attr("data"));
$("#repo-share-form").modal({appendTo: "#main", containerCss:{padding:18}});
});
//check before post
$('#share-submit-btn').click(function() {
if (!$.trim($('#to_email').attr('value'))) {
$('#repo-share-form .error').removeClass('hide');
return false;
}
return true;
});
addConfirmTo($('.repo-delete-btn'));
});
</script>
{% endblock %}

View File

@ -7,10 +7,10 @@
{% if out_repos %}
<table class="repo-list">
<tr>
<th width="12%">名字</th>
<th width="33%">共享给</th>
<th width="40%">描述</th>
<th width="15%">操作</th>
<th width="20%">名字</th>
<th width="25%">共享给</th>
<th width="45%">描述</th>
<th width="10%">操作</th>
</tr>
{% for repo in out_repos %}
<tr>

View File

@ -29,7 +29,7 @@ import settings
def list_to_string(l):
tmp_str = ''
for e in l[:-1]:
tmp_str = tmp_str + e + ','
tmp_str = tmp_str + e + ', '
tmp_str = tmp_str + l[-1]
return tmp_str
@ -426,15 +426,14 @@ def repo_add_share(request):
if request.method == 'POST':
from_email = request.user.username
repo_id = request.POST.get('share_repo_id', '')
to_emails = request.POST.get('to_email', '')
to_email_list = to_emails.split(';')
to_email_list = request.POST.get('to_email', '').split(',')
info_emails = []
err_emails = []
for to_email in to_email_list:
to_email = to_email.strip(' ')
if not to_email:
continue
to_email = to_email.strip('" ')
if validate_emailuser(to_email) and validate_owner(request, repo_id):
seafserv_threaded_rpc.add_share(repo_id, from_email, to_email, 'rw')
info_emails.append(to_email)
@ -442,9 +441,9 @@ def repo_add_share(request):
err_emails.append(to_email)
if info_emails:
output_msg['info_msg'] = u'共享给%s成功,' % list_to_string(info_emails)
output_msg['info_msg'] = u'共享给%s成功' % list_to_string(info_emails)
if err_emails:
output_msg['err_msg'] = u'共享给%s失败: 用户不存在' % list_to_string(err_emails)
output_msg['err_msg'] = u'共享给%s失败用户不存在' % list_to_string(err_emails)
return output_msg