mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-14 22:33:17 +00:00
[api2] Fixed util bugs
This commit is contained in:
@@ -1,21 +1,24 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
# Utility functions for api2
|
# Utility functions for api2
|
||||||
|
|
||||||
|
import os
|
||||||
import time
|
import time
|
||||||
import urllib2
|
|
||||||
|
|
||||||
|
|
||||||
|
from django.core.paginator import EmptyPage, InvalidPage
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
from rest_framework import status
|
||||||
from seaserv import seafile_api, get_commits, server_repo_size, \
|
from seaserv import seafile_api, get_commits, server_repo_size, \
|
||||||
get_personal_groups_by_user, is_group_user, get_group
|
get_personal_groups_by_user, is_group_user, get_group
|
||||||
|
from pysearpc import SearpcError
|
||||||
|
|
||||||
from seahub.notifications.models import UserNotification
|
from seahub.base.accounts import User
|
||||||
|
from seahub.base.templatetags.seahub_tags import email2nickname
|
||||||
|
from seahub.contacts.models import Contact
|
||||||
from seahub.group.models import GroupMessage, MessageReply, \
|
from seahub.group.models import GroupMessage, MessageReply, \
|
||||||
MessageAttachment, PublicGroup
|
MessageAttachment, PublicGroup
|
||||||
from seahub.group.views import is_group_staff
|
from seahub.group.views import is_group_staff
|
||||||
from seahub.message.models import UserMessage, UserMsgAttachment
|
from seahub.message.models import UserMessage, UserMsgAttachment
|
||||||
from seahub.contacts.models import Contact
|
from seahub.notifications.models import UserNotification
|
||||||
from seahub.base.templatetags.seahub_tags import email2nickname
|
|
||||||
from seahub.utils import api_convert_desc_link, get_file_type_and_ext, \
|
from seahub.utils import api_convert_desc_link, get_file_type_and_ext, \
|
||||||
gen_file_get_url
|
gen_file_get_url
|
||||||
from seahub.utils.paginator import Paginator
|
from seahub.utils.paginator import Paginator
|
||||||
@@ -98,7 +101,7 @@ def get_groups(email):
|
|||||||
grpmsgs[g.id] = 0
|
grpmsgs[g.id] = 0
|
||||||
|
|
||||||
notes = UserNotification.objects.get_user_notifications(email, seen=False)
|
notes = UserNotification.objects.get_user_notifications(email, seen=False)
|
||||||
replynum = 0;
|
replynum = 0
|
||||||
for n in notes:
|
for n in notes:
|
||||||
if n.is_group_msg():
|
if n.is_group_msg():
|
||||||
try:
|
try:
|
||||||
@@ -230,7 +233,7 @@ def get_group_msgs(groupid, page, username):
|
|||||||
# If is top directory, use repo name instead.
|
# If is top directory, use repo name instead.
|
||||||
path = att.path
|
path = att.path
|
||||||
if path == '/':
|
if path == '/':
|
||||||
repo = get_repo(att.repo_id)
|
repo = seafile_api.get_repo(att.repo_id)
|
||||||
if not repo:
|
if not repo:
|
||||||
# TODO: what should we do here, tell user the repo
|
# TODO: what should we do here, tell user the repo
|
||||||
# is no longer exists?
|
# is no longer exists?
|
||||||
@@ -244,7 +247,7 @@ def get_group_msgs(groupid, page, username):
|
|||||||
if att.attach_type == 'file' and att.src == 'recommend':
|
if att.attach_type == 'file' and att.src == 'recommend':
|
||||||
att.filetype, att.fileext = get_file_type_and_ext(att.name)
|
att.filetype, att.fileext = get_file_type_and_ext(att.name)
|
||||||
if att.filetype == IMAGE:
|
if att.filetype == IMAGE:
|
||||||
att.obj_id = get_file_id_by_path(att.repo_id, path)
|
att.obj_id = seafile_api.get_file_id_by_path(att.repo_id, path)
|
||||||
if not att.obj_id:
|
if not att.obj_id:
|
||||||
att.err = 'File does not exist'
|
att.err = 'File does not exist'
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user