mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-03 16:10:26 +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.note = form.cleaned_data['note']
|
||||||
contact.save()
|
contact.save()
|
||||||
|
|
||||||
messages.success(request, _(u"Successfully added %s.") % contact_email)
|
messages.success(request, _(u"Successfully added %s to contacts.") % contact_email)
|
||||||
else:
|
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)
|
referer = request.META.get('HTTP_REFERER', None)
|
||||||
if not referer:
|
if not referer:
|
||||||
|
@@ -41,30 +41,19 @@
|
|||||||
<a class="name" href="{% url 'user_msg_list' id %}">{{ e|email2nickname }}</a>
|
<a class="name" href="{% url 'user_msg_list' id %}">{{ e|email2nickname }}</a>
|
||||||
<p>{{ e }}</p>
|
<p>{{ e }}</p>
|
||||||
{% if m.can_be_contact %}
|
{% 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 %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</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" />
|
{% include 'snippets/add_to_contacts_form.html' %}
|
||||||
<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>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_script %}
|
{% block extra_script %}
|
||||||
<script type="text/javascript">
|
{% include 'snippets/add_to_contacts_js.html' %}
|
||||||
$('.add-as-contact').click(function() {
|
|
||||||
$('#contact_email').val($(this).data('email'));
|
|
||||||
$('#add-as-contact-form').submit();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
<div class="txt fright">
|
<div class="txt fright">
|
||||||
<p>{% if to_email %}{{ to_email|email2nickname }}{% else %}{% trans "No Nickname" %}{% endif %}</p>
|
<p>{% if to_email %}{{ to_email|email2nickname }}{% else %}{% trans "No Nickname" %}{% endif %}</p>
|
||||||
{% if add_to_contacts %}
|
{% 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 %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -109,8 +109,10 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<p>{% trans "After login, you can post discussions and add replies." %}</p>
|
<p>{% trans "After login, you can post discussions and add replies." %}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% include 'snippets/add_to_contacts_form.html' %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
@@ -132,6 +134,9 @@ function check(it){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{% include 'snippets/add_to_contacts_js.html' %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
<div class="txt fright">
|
<div class="txt fright">
|
||||||
<p>{% if to_email %}{{ to_email|email2nickname }}{% else %}{% trans "No Nickname" %}{% endif %}</p>
|
<p>{% if to_email %}{{ to_email|email2nickname }}{% else %}{% trans "No Nickname" %}{% endif %}</p>
|
||||||
{% if add_to_contacts %}
|
{% 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 %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -63,12 +63,15 @@
|
|||||||
<h2 class="center-contents">{% blocktrans %}You have no library sharing with {{to_email}}.{% endblocktrans %}</h2>
|
<h2 class="center-contents">{% blocktrans %}You have no library sharing with {{to_email}}.{% endblocktrans %}</h2>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% include 'snippets/add_to_contacts_form.html' %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% block extra_script %}
|
{% block extra_script %}
|
||||||
<script type="text/javascript">
|
{% include 'snippets/add_to_contacts_js.html' %}
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -91,6 +91,11 @@ def share_to_user(request, repo, from_user, to_user, permission):
|
|||||||
"""
|
"""
|
||||||
repo_id = repo.id
|
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):
|
if is_registered_user(to_user):
|
||||||
try:
|
try:
|
||||||
seafile_api.share_repo(repo_id, from_user, to_user, permission)
|
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>
|
<a class="name" href="{% url 'user_msg_list' id %}">{{ e|email2nickname }}</a>
|
||||||
<p>{{ e }}</p>
|
<p>{{ e }}</p>
|
||||||
{% if u.can_be_contact %}
|
{% 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 %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@@ -49,27 +49,15 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</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 %}
|
{% else %}
|
||||||
<p>{% trans "None"%}</p>
|
<p>{% trans "None"%}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% include 'snippets/add_to_contacts_form.html' %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_script %}
|
{% block extra_script %}
|
||||||
<script type="text/javascript">
|
{% include 'snippets/add_to_contacts_js.html' %}
|
||||||
$('.add-as-contact').click(function() {
|
|
||||||
$('#contact_email').val($(this).data('email'));
|
|
||||||
$('#add-as-contact-form').submit();
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% 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