mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-31 14:42:10 +00:00
Fixed add to contacts bug
This commit is contained in:
@@ -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:
|
||||
|
@@ -41,30 +41,19 @@
|
||||
<a class="name" href="{% url 'user_msg_list' id %}">{{ e|email2nickname }}</a>
|
||||
<p>{{ e }}</p>
|
||||
{% if m.can_be_contact %}
|
||||
<button class="add-as-contact" data-email="{{ e }}">{% trans "Add to Contacts" %}</button>
|
||||
<button class="add-to-contacts" data-email="{{ e }}">{% trans "Add to Contacts" %}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</li>
|
||||
{% endwith %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<form id="add-as-contact-form" class="hide" action="{{ SITE_ROOT }}contacts/add/" method="post">{% csrf_token %}
|
||||
<input type="hidden" name="user_email" value="{{ request.user.username }}" id="id_user_email" />
|
||||
<label>{% trans "Email" %}</label><br />
|
||||
<input id="contact_email" type="text" name="contact_email" maxlength="255" value="" /><br />
|
||||
<label>{% trans "Name(optional)" %}</label><br />
|
||||
<input id="id_contact_name" type="text" name="contact_name" maxlength="255" /><br />
|
||||
<label>{% trans "Note(optional)" %}</label><br />
|
||||
<input id="id_note" type="text" name="note" maxlength="255" /><br />
|
||||
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
||||
</form>
|
||||
|
||||
{% include 'snippets/add_to_contacts_form.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
<script type="text/javascript">
|
||||
$('.add-as-contact').click(function() {
|
||||
$('#contact_email').val($(this).data('email'));
|
||||
$('#add-as-contact-form').submit();
|
||||
});
|
||||
</script>
|
||||
{% include 'snippets/add_to_contacts_js.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<div class="txt fright">
|
||||
<p>{% if to_email %}{{ to_email|email2nickname }}{% else %}{% trans "No Nickname" %}{% endif %}</p>
|
||||
{% if add_to_contacts %}
|
||||
<button id="add">{% trans "Add to contacts" %}</button>
|
||||
<button class="add-to-contacts" data-email="{{to_email}}">{% trans "Add to contacts" %}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -109,8 +109,10 @@
|
||||
{% else %}
|
||||
<p>{% trans "After login, you can post discussions and add replies." %}</p>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
{% include 'snippets/add_to_contacts_form.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -132,6 +134,9 @@ function check(it){
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
|
||||
{% include 'snippets/add_to_contacts_js.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<div class="txt fright">
|
||||
<p>{% if to_email %}{{ to_email|email2nickname }}{% else %}{% trans "No Nickname" %}{% endif %}</p>
|
||||
{% if add_to_contacts %}
|
||||
<button id="add">{% trans "Add to contacts" %}</button>
|
||||
<button class="add-to-contacts" data-email="{{to_email}}">{% trans "Add to contacts" %}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -63,12 +63,15 @@
|
||||
<h2 class="center-contents">{% blocktrans %}You have no library sharing with {{to_email}}.{% endblocktrans %}</h2>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% include 'snippets/add_to_contacts_form.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block extra_script %}
|
||||
<script type="text/javascript">
|
||||
</script>
|
||||
{% include 'snippets/add_to_contacts_js.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -26,7 +26,7 @@
|
||||
<a class="name" href="{% url 'user_msg_list' id %}">{{ e|email2nickname }}</a>
|
||||
<p>{{ e }}</p>
|
||||
{% if u.can_be_contact %}
|
||||
<button class="add-as-contact" data-email="{{e}}">{% trans "Add to Contacts" %}</button>
|
||||
<button class="add-to-contacts" data-email="{{e}}">{% trans "Add to Contacts" %}</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</li>
|
||||
@@ -49,27 +49,15 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<form id="add-as-contact-form" class="hide" action="{{ SITE_ROOT }}contacts/add/" method="post">{% csrf_token %}
|
||||
<input type="hidden" name="user_email" value="{{ request.user.username }}" id="id_user_email" />
|
||||
<label>{% trans "Email" %}</label><br />
|
||||
<input id="contact_email" type="text" name="contact_email" maxlength="255" value="" /><br />
|
||||
<label>{% trans "Name(optional)" %}</label><br />
|
||||
<input id="id_contact_name" type="text" name="contact_name" maxlength="255" /><br />
|
||||
<label>{% trans "Note(optional)" %}</label><br />
|
||||
<input id="id_note" type="text" name="note" maxlength="255" /><br />
|
||||
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
||||
</form>
|
||||
{% else %}
|
||||
<p>{% trans "None"%}</p>
|
||||
{% endif %}
|
||||
|
||||
{% include 'snippets/add_to_contacts_form.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
<script type="text/javascript">
|
||||
$('.add-as-contact').click(function() {
|
||||
$('#contact_email').val($(this).data('email'));
|
||||
$('#add-as-contact-form').submit();
|
||||
});
|
||||
</script>
|
||||
{% include 'snippets/add_to_contacts_js.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
10
seahub/templates/snippets/add_to_contacts_form.html
Normal file
10
seahub/templates/snippets/add_to_contacts_form.html
Normal file
@@ -0,0 +1,10 @@
|
||||
{% load i18n %}<form id="add-to-contacts-form" class="hide" action="{% url 'contact_add' %}" method="post">{% csrf_token %}
|
||||
<input type="hidden" name="user_email" value="{{ request.user.username }}" id="id_user_email" />
|
||||
<label>{% trans "Email" %}</label><br />
|
||||
<input id="contact_email" type="text" name="contact_email" maxlength="255" value="" /><br />
|
||||
<label>{% trans "Name(optional)" %}</label><br />
|
||||
<input id="id_contact_name" type="text" name="contact_name" maxlength="255" /><br />
|
||||
<label>{% trans "Note(optional)" %}</label><br />
|
||||
<input id="id_note" type="text" name="note" maxlength="255" /><br />
|
||||
<input type="submit" value="{% trans "Submit" %}" class="submit" />
|
||||
</form>
|
6
seahub/templates/snippets/add_to_contacts_js.html
Normal file
6
seahub/templates/snippets/add_to_contacts_js.html
Normal file
@@ -0,0 +1,6 @@
|
||||
<script type="text/javascript">
|
||||
$('.add-to-contacts').click(function() {
|
||||
$('#contact_email').val($(this).data('email'));
|
||||
$('#add-to-contacts-form').submit();
|
||||
});
|
||||
</script>
|
Reference in New Issue
Block a user