mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-01 23:38:37 +00:00
[api] remove more unused group/user messages code
This commit is contained in:
parent
af0ab3e221
commit
115bcfb54c
@ -1,92 +0,0 @@
|
|||||||
{% extends "api2/base.html" %}
|
|
||||||
|
|
||||||
{% load seahub_tags avatar_tags i18n %}
|
|
||||||
{% load url from future %}
|
|
||||||
|
|
||||||
{% block sub_title %}{{group.group_name}} - {% endblock %}
|
|
||||||
|
|
||||||
{% block extra_style %}
|
|
||||||
{% if not group_msgs.has_next %}
|
|
||||||
<style type="text/css">
|
|
||||||
.msg:last-child {
|
|
||||||
border-bottom:0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block main_panel %}
|
|
||||||
<ul class="msg-list" id="msg-list">
|
|
||||||
{% if group_msgs %}
|
|
||||||
{% include "api2/discussions_body.html" %}
|
|
||||||
{% else %}
|
|
||||||
<div id="placeholder" style="margin-top:20%;">
|
|
||||||
<p style="text-align:center">{% trans "No discussions." %}</p>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
|
||||||
{% if group_msgs and group_msgs.has_next %}
|
|
||||||
<div id="loading-icon" data-next="{{ group_msgs.next_page_number }}"><img src="{{MEDIA_URL}}img/loading-icon.gif" alt="{% trans 'Loading...' %}" /></div>
|
|
||||||
<p id="loading-error" class="error hide"></p>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block extra_script %}
|
|
||||||
<script type="text/javascript">
|
|
||||||
function msgClick() {
|
|
||||||
window.open($(this).data('url'));
|
|
||||||
}
|
|
||||||
$('.msg').click(msgClick);
|
|
||||||
|
|
||||||
var g_token = "TOKEN";
|
|
||||||
function setToken(token) {
|
|
||||||
g_token = token;
|
|
||||||
}
|
|
||||||
function getToken() {
|
|
||||||
return g_token;
|
|
||||||
}
|
|
||||||
|
|
||||||
{% if group_msgs.has_next %}
|
|
||||||
var g_loading = false;
|
|
||||||
$(document).scroll(function() {
|
|
||||||
var loading_icon = $('#loading-icon');
|
|
||||||
if (loading_icon.data('next') && $(window).height() + $(window).scrollTop() == $(document).height() && !g_loading) {
|
|
||||||
loading_icon.show();
|
|
||||||
g_loading = true;
|
|
||||||
$.ajax({
|
|
||||||
url:'{% url 'more_discussions' group.id %}?page=' + e(loading_icon.data('next')),
|
|
||||||
dataType: 'json',
|
|
||||||
cache: false,
|
|
||||||
headers:{Authorization:'Token '+g_token},
|
|
||||||
success: function(data) {
|
|
||||||
loading_icon.data('next', data['next_page']);
|
|
||||||
$('.msg-list').append(data['html']);
|
|
||||||
$('.msg').unbind().click(msgClick);
|
|
||||||
if (!data['next_page']) {
|
|
||||||
loading_icon.hide();
|
|
||||||
$('.msg:last-child').css({'border-bottom':0});
|
|
||||||
}
|
|
||||||
g_loading = false;
|
|
||||||
},
|
|
||||||
error: function(jqXHR, textStatus, errorThrown) {
|
|
||||||
loading_icon.hide();
|
|
||||||
g_loading = false;
|
|
||||||
if (!jqXHR.responseText) {
|
|
||||||
$('#loading-error').html("{% trans "Failed. Please check the network." %}").removeClass('hide');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
function addMessage(html) {
|
|
||||||
if (!$('#placeholder').hasClass('hide')) {
|
|
||||||
$('#placeholder').addClass('hide');
|
|
||||||
}
|
|
||||||
var msg_list = $('#msg-list')
|
|
||||||
msg_list.prepend(html)
|
|
||||||
msg_list.children().eq(0).click(msgClick);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
@ -1,68 +0,0 @@
|
|||||||
{% load seahub_tags avatar_tags i18n %}
|
|
||||||
{% load url from future %}
|
|
||||||
|
|
||||||
{% if group_msgs %}
|
|
||||||
{% for msg in group_msgs.object_list %}
|
|
||||||
<li class="msg ovhd" data-url="{% url 'api_discussion' msg.id %}">
|
|
||||||
{% avatar msg.from_email 48 %}
|
|
||||||
<div class="txt">
|
|
||||||
<div class="msg-main">
|
|
||||||
<div class="msg-hd ovhd">
|
|
||||||
<span class="author">{{ msg.from_email|email2nickname }}</span>
|
|
||||||
<span class="time">{{ msg.timestamp|translate_seahub_time }}</span>
|
|
||||||
</div>
|
|
||||||
<p class="msg-con">{{ msg.message|seahub_urlize|find_at|linebreaksbr }}</p>
|
|
||||||
{% if msg.attachment %}
|
|
||||||
{% with ma=msg.attachment %}
|
|
||||||
<div class="msg-attachment">
|
|
||||||
{% if ma.src == 'recommend' %}
|
|
||||||
{% if ma.attach_type == 'file' %}
|
|
||||||
{% if ma.filetype != 'Image'%}
|
|
||||||
<img src="{{ MEDIA_URL }}img/file/{{ ma.name|file_icon_filter }}" alt="{% trans "File"%}" height="18" class="vam" />
|
|
||||||
<span class="name vam">{{ ma.name }}</span>
|
|
||||||
{% else %}
|
|
||||||
{% if ma.err %}
|
|
||||||
<p class="error">{{ma.err}}</p>
|
|
||||||
{% else %}
|
|
||||||
<img src="{{ma.img_url}}" alt="{{ma.name}}" class="img" />
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
{% else %}
|
|
||||||
<img src="{{ MEDIA_URL }}img/folder-icon-24.png" alt="{% trans "Directory icon"%}" height="20" class="vam" />
|
|
||||||
<span class="name vam">{{ ma.name }}</span>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if ma.src == 'filecomment' %} {# compatible with comments already exist #}
|
|
||||||
<img src="{{ MEDIA_URL }}img/file/{{ ma.name|file_icon_filter }}" alt="{% trans "File"%}" height="18" class="vam" />
|
|
||||||
<span class="name vam">{{ ma.name }}</span>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% endwith %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if msg.reply_cnt > 0 %}
|
|
||||||
<div class="msg-op">
|
|
||||||
{% if msg.reply_cnt > 3 %}
|
|
||||||
<span class="replies-num">{% blocktrans with amount=msg.reply_cnt %}{{ amount }} replies{% endblocktrans %}</span>
|
|
||||||
{% endif %}
|
|
||||||
<ul class="reply-list">
|
|
||||||
{% for r in msg.replies %}
|
|
||||||
<li class="reply w100 ovhd reply-at">
|
|
||||||
{% avatar r.from_email 28 %}
|
|
||||||
<div class="txt">
|
|
||||||
<span class="author">{{ r.from_email|email2nickname }}</span>
|
|
||||||
<span class="time">{{ r.timestamp|translate_seahub_time }}</span>
|
|
||||||
<p class="reply-con">{{ r.message|seahub_urlize|find_at }}</p>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
<div class="outer-caret"><div class="inner-caret"></div></div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
@ -1,84 +0,0 @@
|
|||||||
{% extends "api2/base.html" %}
|
|
||||||
|
|
||||||
{% load seahub_tags avatar_tags i18n %}
|
|
||||||
{% load url from future %}
|
|
||||||
|
|
||||||
{% block sub_title %}{% trans "Messages" %} - {% endblock %}
|
|
||||||
|
|
||||||
{% block main_panel %}
|
|
||||||
|
|
||||||
<h3 class="hd">{% blocktrans with name=to_email|email2nickname%}Messages with {{name}}{% endblocktrans %}</h3>
|
|
||||||
|
|
||||||
<div id="personal-msg-panel" class="msg-panel personal-msg-panel">
|
|
||||||
|
|
||||||
<ul class="msg-list">
|
|
||||||
{% if person_msgs %}
|
|
||||||
{% include "api2/user_msg_body.html" %}
|
|
||||||
{% else %}
|
|
||||||
<div id="placeholder" style="margin-top:20%;">
|
|
||||||
<p style="text-align:center">{% trans "No messages." %}</p>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
{% if person_msgs.has_other_pages %}
|
|
||||||
<div id="loading-icon" data-next="{{ person_msgs.next_page_number }}"><img src="{{MEDIA_URL}}img/loading-icon.gif" alt="{% trans 'Loading...' %}" /></div>
|
|
||||||
<p id="loading-error" class="error hide"></p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
|
|
||||||
{% block extra_script %}{{block.super}}
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
var g_token = "TOKEN";
|
|
||||||
function setToken(token) {
|
|
||||||
g_token = token;
|
|
||||||
}
|
|
||||||
function getToken() {
|
|
||||||
return g_token;
|
|
||||||
}
|
|
||||||
|
|
||||||
function addMessage(html) {
|
|
||||||
$('.msg-list').prepend(html);
|
|
||||||
}
|
|
||||||
|
|
||||||
{% if person_msgs.has_next %}
|
|
||||||
var g_loading = false;
|
|
||||||
$(document).scroll(function() {
|
|
||||||
var loading_icon = $('#loading-icon');
|
|
||||||
if (loading_icon.data('next') && $(window).height() + $(window).scrollTop() == $(document).height() && !g_loading) {
|
|
||||||
g_loading = true;
|
|
||||||
loading_icon.show();
|
|
||||||
$.ajax({
|
|
||||||
url:'{% url 'api_more_usermsgs' to_email %}?page=' + e(loading_icon.data('next')),
|
|
||||||
dataType: 'json',
|
|
||||||
cache: false,
|
|
||||||
headers:{Authorization:'Token '+g_token},
|
|
||||||
success: function(data) {
|
|
||||||
loading_icon.data('next', data['next_page']);
|
|
||||||
$('.msg-list').append(data['html']);
|
|
||||||
if (!data['next_page']) {
|
|
||||||
loading_icon.hide();
|
|
||||||
$('.msg:last-child').css({'border-bottom':0});
|
|
||||||
}
|
|
||||||
g_loading = false;
|
|
||||||
},
|
|
||||||
error: function(jqXHR, textStatus, errorThrown) {
|
|
||||||
loading_icon.hide();
|
|
||||||
g_loading = false;
|
|
||||||
if (!jqXHR.responseText) {
|
|
||||||
$('#loading-error').html("{% trans "Failed. Please check the network." %}").removeClass('hide');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
|||||||
import json
|
import json
|
||||||
import unittest
|
|
||||||
import pytest
|
import pytest
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
@ -7,7 +6,7 @@ from django.test import TestCase
|
|||||||
|
|
||||||
from seahub import settings
|
from seahub import settings
|
||||||
from tests.api.apitestbase import ApiTestBase
|
from tests.api.apitestbase import ApiTestBase
|
||||||
from tests.api.urls import LIST_GROUP_AND_CONTACTS_URL, SERVER_INFO_URL
|
from tests.api.urls import SERVER_INFO_URL
|
||||||
|
|
||||||
class MiscApiTest(ApiTestBase, TestCase):
|
class MiscApiTest(ApiTestBase, TestCase):
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
from tests.common.common import USERNAME
|
|
||||||
from tests.common.utils import apiurl
|
from tests.common.utils import apiurl
|
||||||
|
|
||||||
PING_URL = apiurl('/api2/ping/')
|
PING_URL = apiurl('/api2/ping/')
|
||||||
@ -16,10 +15,7 @@ GET_REPO_TOKENS_URL = apiurl('/api2/repo-tokens/')
|
|||||||
|
|
||||||
GROUPS_URL = apiurl(u'/api2/groups/')
|
GROUPS_URL = apiurl(u'/api2/groups/')
|
||||||
|
|
||||||
USERMSGS_URL = apiurl('/api2/user/msgs/', USERNAME)
|
|
||||||
USERMSGS_COUNT_URL = apiurl('/api2/unseen_messages/')
|
USERMSGS_COUNT_URL = apiurl('/api2/unseen_messages/')
|
||||||
GROUPMSGS_URL = apiurl('/api2/group/msgs/')
|
|
||||||
GROUPMSGS_NREPLY_URL = apiurl('/api2/new_replies/')
|
|
||||||
|
|
||||||
STARREDFILES_URL = apiurl('/api2/starredfiles/')
|
STARREDFILES_URL = apiurl('/api2/starredfiles/')
|
||||||
SHARED_LINKS_URL = apiurl('/api2/shared-links/')
|
SHARED_LINKS_URL = apiurl('/api2/shared-links/')
|
||||||
@ -29,7 +25,6 @@ SHARED_FILES_URL = apiurl('/api2/shared-files/')
|
|||||||
F_URL = apiurl('/api2/f/')
|
F_URL = apiurl('/api2/f/')
|
||||||
S_F_URL = apiurl('/api2/s/f/')
|
S_F_URL = apiurl('/api2/s/f/')
|
||||||
|
|
||||||
LIST_GROUP_AND_CONTACTS_URL = apiurl('/api2/groupandcontacts/')
|
|
||||||
DOWNLOAD_REPO_URL = apiurl('api2/repos/%s/download-info/')
|
DOWNLOAD_REPO_URL = apiurl('api2/repos/%s/download-info/')
|
||||||
LOGOUT_DEVICE_URL = apiurl('api2/logout-device/')
|
LOGOUT_DEVICE_URL = apiurl('api2/logout-device/')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user