mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-10 13:44:02 +00:00
[contact] fixed bug, improved code, translation
This commit is contained in:
parent
d2b0680436
commit
404b97ce9d
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2012-11-09 21:31+0800\n"
|
||||
"POT-Creation-Date: 2013-01-05 19:46+0800\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -17,22 +17,37 @@ msgstr ""
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0\n"
|
||||
|
||||
#: views.py:68 views.py:93
|
||||
#, python-format
|
||||
msgid "Successfully adding %s to contacts."
|
||||
msgstr "你已成功添加 %s 为联系人"
|
||||
#: models.py:25 templates/contacts/contact_list.html:133
|
||||
msgid "Email is required."
|
||||
msgstr "邮箱为必填项。"
|
||||
|
||||
#: models.py:30 templates/contacts/contact_list.html:137
|
||||
msgid "You can't add yourself."
|
||||
msgstr "不能添加自己。"
|
||||
|
||||
#: models.py:33
|
||||
msgid "It is already your contact."
|
||||
msgstr "该邮箱已在列表中。"
|
||||
|
||||
#: views.py:68
|
||||
msgid "Successfully added %s to contacts."
|
||||
msgstr "你已成功添加 %s 为联系人。"
|
||||
|
||||
#: views.py:93
|
||||
msgid "Successfully added %s."
|
||||
msgstr "你已成功添加 %s 为联系人。"
|
||||
|
||||
#: views.py:95
|
||||
msgid "Failed to add an contact."
|
||||
msgstr "添加联系人失败"
|
||||
msgstr "添加失败"
|
||||
|
||||
#: views.py:120
|
||||
msgid "Editting Successfully"
|
||||
msgstr "编辑成功"
|
||||
msgid "Successfully edited %s."
|
||||
msgstr "编辑 %s 成功。"
|
||||
|
||||
#: views.py:133
|
||||
msgid "Deleting Successfully"
|
||||
msgstr "删除成功"
|
||||
msgid "Successfully Deleted"
|
||||
msgstr "成功删除 %s 。"
|
||||
|
||||
#: templates/contacts/contact_list.html:8
|
||||
msgid "Tips"
|
||||
@ -88,42 +103,52 @@ msgid ""
|
||||
"link."
|
||||
msgstr "联系人用来在共享资料库和发送文件外链时的快速补全。"
|
||||
|
||||
#: templates/contacts/contact_list.html:49
|
||||
#: templates/contacts/contact_list.html:59
|
||||
#: templates/contacts/contact_list.html:48
|
||||
#: templates/contacts/contact_list.html:57
|
||||
msgid "Email"
|
||||
msgstr "邮箱"
|
||||
|
||||
#: templates/contacts/contact_list.html:51
|
||||
#: templates/contacts/contact_list.html:61
|
||||
#: templates/contacts/contact_list.html:50
|
||||
#: templates/contacts/contact_list.html:59
|
||||
msgid "Name(optional)"
|
||||
msgstr "名字(可选)"
|
||||
|
||||
#: templates/contacts/contact_list.html:52
|
||||
#: templates/contacts/contact_list.html:62
|
||||
#: templates/contacts/contact_list.html:51
|
||||
#: templates/contacts/contact_list.html:60
|
||||
msgid "Note(optional)"
|
||||
msgstr "备注(可选)"
|
||||
|
||||
#: templates/contacts/contact_list.html:53
|
||||
msgid "Please input email address"
|
||||
msgstr "请输入邮箱地址。"
|
||||
|
||||
#: templates/contacts/contact_list.html:54
|
||||
#: templates/contacts/contact_list.html:64
|
||||
#: templates/contacts/contact_list.html:62
|
||||
msgid "Submit"
|
||||
msgstr "提交"
|
||||
|
||||
#: templates/contacts/contact_list.html:57
|
||||
#: templates/contacts/contact_list.html:56
|
||||
msgid "Edit Contact"
|
||||
msgstr "编辑联系人"
|
||||
|
||||
#: templates/contacts/contact_list.html:114
|
||||
#: templates/contacts/contact_list.html:107
|
||||
#: templates/contacts/contact_list.html:168
|
||||
msgid "Failed."
|
||||
msgstr "提交失败。"
|
||||
|
||||
#: templates/contacts/contact_list.html:115
|
||||
msgid "Delete Contact"
|
||||
msgstr "删除联系人"
|
||||
|
||||
#: templates/contacts/contact_list.html:114
|
||||
#: templates/contacts/contact_list.html:115
|
||||
msgid "Are you sure you want to delete"
|
||||
msgstr "确定要删除"
|
||||
|
||||
#~ msgid "Editting Successfully"
|
||||
#~ msgstr "编辑成功"
|
||||
|
||||
#~ msgid "Deleting Successfully"
|
||||
#~ msgstr "删除成功"
|
||||
|
||||
#~ msgid "Please input email address"
|
||||
#~ msgstr "请输入邮箱地址。"
|
||||
|
||||
#~ msgid "Tip"
|
||||
#~ msgstr "小提示"
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
from django import forms
|
||||
from django.db import models
|
||||
from django.forms import ModelForm
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
class Contact(models.Model):
|
||||
"""Record user's contacts."""
|
||||
@ -21,15 +22,15 @@ class ContactAddForm(ModelForm):
|
||||
|
||||
def clean(self):
|
||||
if not 'contact_email' in self.cleaned_data:
|
||||
raise forms.ValidationError('请输入邮箱地址。')
|
||||
raise forms.ValidationError(_('Email is required.'))
|
||||
|
||||
user_email = self.cleaned_data['user_email']
|
||||
contact_email = self.cleaned_data['contact_email']
|
||||
if user_email == contact_email:
|
||||
raise forms.ValidationError('不能添加自己为联系人')
|
||||
raise forms.ValidationError(_("You can't add yourself."))
|
||||
elif Contact.objects.filter(user_email=user_email,
|
||||
contact_email=contact_email).count() > 0:
|
||||
raise forms.ValidationError('联系人列表中已有该用户')
|
||||
raise forms.ValidationError(_("It is already your contact."))
|
||||
else:
|
||||
return self.cleaned_data
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
<td>{{ contact.contact_email }}</td>
|
||||
<td>{{ contact.contact_name }}</td>
|
||||
<td>{{ contact.note }}</td>
|
||||
<td>
|
||||
<td data-email="{{ contact.contact_email }}" data-name="{{ contact.contact_name }}" data-note="{{ contact.note }}">
|
||||
<a href="#" data="{{ SITE_ROOT }}contacts/edit/?email={{ contact.contact_email }}" class="contact-edit op">{% trans "Edit"%}</a>
|
||||
<a href="#" data-url="{{ SITE_ROOT }}contacts/delete/?email={{ contact.contact_email|quote}}" data-target="{{ contact.contact_email}}" class="contact-delete op">{% trans "Delete"%}</a>
|
||||
</td>
|
||||
@ -43,24 +43,22 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<form action="{% url contact_add_post %}" method="post" id="contact-add-form" class="hide">
|
||||
<form action="" method="post" id="contact-add-form" class="hide">
|
||||
<h3>{% trans "Add Contacts"%}</h3>
|
||||
{{ form.user_email.as_hidden }}
|
||||
<label>{% trans "Email"%}</label><br />
|
||||
{{ form.contact_email }}<br />
|
||||
<label>{% trans "Name(optional)"%}</label><br />{{ form.contact_name }}<br />
|
||||
<label>{% trans "Note(optional)"%}</label><br />{{ form.note }}<br />
|
||||
<p class="error hide" id="contact-add-error">{% trans "Please input email address"%}</p>
|
||||
<p class="error hide"></p>
|
||||
<input type="submit" value="{% trans "Submit"%}" class="submit" />
|
||||
</form>
|
||||
<form action="{% url contact_edit %}" method="post" id="contact-edit-form" class="hide">
|
||||
<form action="" method="post" id="contact-edit-form" class="hide">
|
||||
<h3>{% trans "Edit Contact"%}</h3>
|
||||
{{ edit_form.user_email.as_hidden }}
|
||||
<label>{% trans "Email"%}</label><br />
|
||||
{{ edit_form.contact_email }}<br />
|
||||
<label>{% trans "Name(optional)"%}</label><br />{{ edit_form.contact_name }}<br />
|
||||
<label>{% trans "Note(optional)"%}</label><br />{{ edit_form.note }}<br />
|
||||
<p class="error hide" id="contact-edit-error"></p>
|
||||
<p class="error hide"></p>
|
||||
<input type="submit" value="{% trans "Submit"%}" class="submit" />
|
||||
</form>
|
||||
|
||||
@ -69,42 +67,45 @@
|
||||
{% block extra_script %}
|
||||
<script type="text/javascript">
|
||||
$('.contact-edit').click(function() {
|
||||
var note_container = $(this).parent().prev(),
|
||||
contact_note = note_container.html(),
|
||||
contact_name = note_container.prev().html(),
|
||||
contact_email = note_container.prev().prev().html();
|
||||
$('#contact-edit-form [name="contact_email"]').val(contact_email);
|
||||
$('#contact-edit-form [name="contact_name"]').val(contact_name);
|
||||
$('#contact-edit-form [name="note"]').val(contact_note);
|
||||
$('#contact-edit-form').modal({appendTo: '#main'});
|
||||
var contact = $(this).parent();
|
||||
var form = $('#contact-edit-form');
|
||||
form.find('[name="contact_email"]').val(contact.data('email'));
|
||||
form.find('[name="contact_name"]').val(contact.data('name'));
|
||||
form.find('[name="note"]').val(contact.data('note'));
|
||||
form.modal({appendTo: '#main'});
|
||||
return false;
|
||||
});
|
||||
$('#contact-edit-form').submit(function() {
|
||||
var form = $(this);
|
||||
$.ajax({
|
||||
url: $('#contact-edit-form').attr('action'),
|
||||
url: '{% url contact_edit %}',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
cache: 'false',
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
beforeSend: prepareCSRFToken,
|
||||
data: {
|
||||
'user_email': $('#contact-edit-form input[name="user_email"]').val(),
|
||||
'contact_email': $('#contact-edit-form input[name="contact_email"]').val(),
|
||||
'contact_name': $('#contact-edit-form input[name="contact_name"]').val(),
|
||||
'note': $('#contact-edit-form input[name="note"]').val()
|
||||
'user_email': '{{request.user.username}}',
|
||||
'contact_email': form.find('input[name="contact_email"]').val(),
|
||||
'contact_name': form.find('input[name="contact_name"]').val(),
|
||||
'note': form.find('input[name="note"]').val()
|
||||
},
|
||||
success: function(data) {
|
||||
if (data['success']) {
|
||||
location.reload(true);
|
||||
} else {
|
||||
apply_form_error('contact-edit-form', data['error']);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(data, textStatus, jqXHR) {
|
||||
var errors = $.parseJSON(data.responseText);
|
||||
$.each(errors, function(index, value) {
|
||||
apply_form_error('contact-edit-form', value[0]);
|
||||
});
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
if (jqXHR.responseText) {
|
||||
var errors = $.parseJSON(jqXHR.responseText);
|
||||
var str = '';
|
||||
for (var i in errors) {
|
||||
str += errors[i].join();
|
||||
}
|
||||
apply_form_error('contact-edit-form', str);
|
||||
} else {
|
||||
apply_form_error('contact-edit-form', '{% trans "Failed." %}');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -126,38 +127,46 @@ $('#contact-add')
|
||||
}
|
||||
);
|
||||
$('#contact-add-form').submit(function() {
|
||||
|
||||
if(!$.trim($('#contact-add-form input[name="contact_email"]').val())) {
|
||||
$('#contact-add-error').removeClass('hide')
|
||||
$('#simplemodal-container').css('height', $(this).height());
|
||||
var form = $(this);
|
||||
var email = $.trim(form.find('input[name="contact_email"]').val());
|
||||
if(!email) {
|
||||
apply_form_error('contact-add-form', '{% trans "Email is required." %}');
|
||||
return false;
|
||||
}
|
||||
if (email == '{{request.user.username}}') {
|
||||
apply_form_error('contact-add-form', "{% trans "You can't add yourself." %}");
|
||||
return false;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: $('#contact-add-form').attr('action'),
|
||||
url: '{% url contact_add_post %}',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
cache: 'false',
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
beforeSend: prepareCSRFToken,
|
||||
data: {
|
||||
'user_email': $('#contact-add-form input[name="user_email"]').val(),
|
||||
'contact_email': $('#contact-add-form input[name="contact_email"]').val(),
|
||||
'contact_name': $('#contact-add-form input[name="contact_name"]').val(),
|
||||
'note': $('#contact-add-form input[name="note"]').val()
|
||||
'user_email': '{{request.user.username}}',
|
||||
'contact_email': email,
|
||||
'contact_name': form.find('input[name="contact_name"]').val(),
|
||||
'note': form.find('input[name="note"]').val()
|
||||
},
|
||||
success: function(data) {
|
||||
if (data['success']) {
|
||||
location.reload(true);
|
||||
} else {
|
||||
apply_form_error('contact-add-form', data['error']);
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(data, textStatus, jqXHR) {
|
||||
var errors = $.parseJSON(data.responseText);
|
||||
$.each(errors, function(index, value) {
|
||||
apply_form_error('contact-add-form', value[0]);
|
||||
});
|
||||
error: function(jqXHR, textStatus, errorThrown) {
|
||||
if (jqXHR.responseText) {
|
||||
var errors = $.parseJSON(jqXHR.responseText);
|
||||
var str = '';
|
||||
for (var i in errors) {
|
||||
str += errors[i].join();
|
||||
}
|
||||
apply_form_error('contact-add-form', str);
|
||||
} else {
|
||||
apply_form_error('contact-add-form', '{% trans "Failed." %}');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -65,7 +65,7 @@ def contact_add_post(request):
|
||||
contact.save()
|
||||
|
||||
result['success'] = True
|
||||
messages.success(request, _(u"Successfully adding %s to contacts.") % contact_email)
|
||||
messages.success(request, _(u"Successfully added %s to contacts.") % contact_email)
|
||||
return HttpResponse(json.dumps(result), content_type=content_type)
|
||||
else:
|
||||
return HttpResponseBadRequest(json.dumps(form.errors),
|
||||
@ -90,7 +90,7 @@ def contact_add(request):
|
||||
contact.note = form.cleaned_data['note']
|
||||
contact.save()
|
||||
|
||||
messages.success(request, _(u"Successfully adding %s to contacts.") % contact_email)
|
||||
messages.success(request, _(u"Successfully added %s.") % contact_email)
|
||||
else:
|
||||
messages.error(request, _('Failed to add an contact.'))
|
||||
|
||||
@ -117,7 +117,7 @@ def contact_edit(request):
|
||||
contact.note = note
|
||||
contact.save()
|
||||
result['success'] = True
|
||||
messages.success(request, _(u'Editting Successfully'))
|
||||
messages.success(request, _(u'Successfully edited %s.') % contact_email)
|
||||
return HttpResponse(json.dumps(result), content_type=content_type)
|
||||
else:
|
||||
return HttpResponseBadRequest(json.dumps(form.errors),
|
||||
@ -130,6 +130,6 @@ def contact_delete(request):
|
||||
contact_email = request.GET.get('email')
|
||||
|
||||
Contact.objects.filter(user_email=user_email, contact_email=contact_email).delete()
|
||||
messages.success(request, _(u'Deleting Successfully'))
|
||||
messages.success(request, _(u'Successfully Deleted %s') % contact_email)
|
||||
|
||||
return HttpResponseRedirect(reverse("contact_list"))
|
||||
|
Loading…
Reference in New Issue
Block a user