diff --git a/seahub/contacts/views.py b/seahub/contacts/views.py index 13cd6a9dd0..0807d68f76 100644 --- a/seahub/contacts/views.py +++ b/seahub/contacts/views.py @@ -89,9 +89,9 @@ def contact_add(request): contact.note = form.cleaned_data['note'] contact.save() - messages.success(request, _(u"Successfully added %s.") % contact_email) + messages.success(request, _(u"Successfully added %s to contacts.") % contact_email) else: - messages.error(request, _('Failed to add an contact.')) + messages.error(request, _('Failed to add %s to contacts.')) referer = request.META.get('HTTP_REFERER', None) if not referer: diff --git a/seahub/group/templates/group/group_members.html b/seahub/group/templates/group/group_members.html index f5d270cb30..3238804ca6 100644 --- a/seahub/group/templates/group/group_members.html +++ b/seahub/group/templates/group/group_members.html @@ -41,30 +41,19 @@ {{ e|email2nickname }}

{{ e }}

{% if m.can_be_contact %} - + {% endif %} {% endwith %} {% endfor %} -
{% csrf_token %} - -
-
-
-
-
-
- -
+ +{% include 'snippets/add_to_contacts_form.html' %} + {% endblock %} {% block extra_script %} - +{% include 'snippets/add_to_contacts_js.html' %} + {% endblock %} diff --git a/seahub/message/templates/message/user_msg_list.html b/seahub/message/templates/message/user_msg_list.html index 60188d8ee2..f0c88a1b39 100644 --- a/seahub/message/templates/message/user_msg_list.html +++ b/seahub/message/templates/message/user_msg_list.html @@ -11,7 +11,7 @@

{% if to_email %}{{ to_email|email2nickname }}{% else %}{% trans "No Nickname" %}{% endif %}

{% if add_to_contacts %} - + {% endif %}
@@ -109,8 +109,10 @@ {% else %}

{% trans "After login, you can post discussions and add replies." %}

{% endif %} - + +{% include 'snippets/add_to_contacts_form.html' %} + {% endblock %} @@ -132,6 +134,9 @@ function check(it){ return false; } + +{% include 'snippets/add_to_contacts_js.html' %} + {% endblock %} diff --git a/seahub/share/templates/repo/user_share_list.html b/seahub/share/templates/repo/user_share_list.html index 2b31c9eaff..2023b131db 100644 --- a/seahub/share/templates/repo/user_share_list.html +++ b/seahub/share/templates/repo/user_share_list.html @@ -11,7 +11,7 @@

{% if to_email %}{{ to_email|email2nickname }}{% else %}{% trans "No Nickname" %}{% endif %}

{% if add_to_contacts %} - + {% endif %}
@@ -63,12 +63,15 @@

{% blocktrans %}You have no library sharing with {{to_email}}.{% endblocktrans %}

{% endif %} + +{% include 'snippets/add_to_contacts_form.html' %} + {% endblock %} {% block extra_script %} - +{% include 'snippets/add_to_contacts_js.html' %} + {% endblock %} diff --git a/seahub/share/views.py b/seahub/share/views.py index 8cf62d5a68..e99683ef62 100644 --- a/seahub/share/views.py +++ b/seahub/share/views.py @@ -91,6 +91,11 @@ def share_to_user(request, repo, from_user, to_user, permission): """ repo_id = repo.id + if from_user == to_user: + msg = _(u'You can not share libray to yourself.') + messages.error(request, msg) + return + if is_registered_user(to_user): try: seafile_api.share_repo(repo_id, from_user, to_user, permission) diff --git a/seahub/templates/pubuser.html b/seahub/templates/pubuser.html index d482ee1f27..abf30b3615 100644 --- a/seahub/templates/pubuser.html +++ b/seahub/templates/pubuser.html @@ -26,7 +26,7 @@ {{ e|email2nickname }}

{{ e }}

{% if u.can_be_contact %} - + {% endif %} @@ -49,27 +49,15 @@ {% endif %} -
{% csrf_token %} - -
-
-
-
-
-
- -
{% else %}

{% trans "None"%}

{% endif %} +{% include 'snippets/add_to_contacts_form.html' %} + {% endblock %} {% block extra_script %} - +{% include 'snippets/add_to_contacts_js.html' %} + {% endblock %} diff --git a/seahub/templates/snippets/add_to_contacts_form.html b/seahub/templates/snippets/add_to_contacts_form.html new file mode 100644 index 0000000000..9200845d9e --- /dev/null +++ b/seahub/templates/snippets/add_to_contacts_form.html @@ -0,0 +1,10 @@ +{% load i18n %}
{% csrf_token %} + +
+
+
+
+
+
+ +
diff --git a/seahub/templates/snippets/add_to_contacts_js.html b/seahub/templates/snippets/add_to_contacts_js.html new file mode 100644 index 0000000000..f4c81fe924 --- /dev/null +++ b/seahub/templates/snippets/add_to_contacts_js.html @@ -0,0 +1,6 @@ +