mirror of
https://github.com/haiwen/seahub.git
synced 2025-04-28 11:15:58 +00:00
parent
99c858e273
commit
4f888be82c
@ -12,7 +12,7 @@ from seaserv import seafile_api, ccnet_api
|
|||||||
from constance import config
|
from constance import config
|
||||||
|
|
||||||
from seahub import settings
|
from seahub import settings
|
||||||
from seahub.api2.utils import api_error
|
from seahub.api2.utils import api_error, is_wiki_repo
|
||||||
from seahub.api2.throttling import UserRateThrottle
|
from seahub.api2.throttling import UserRateThrottle
|
||||||
from seahub.api2.authentication import TokenAuthentication
|
from seahub.api2.authentication import TokenAuthentication
|
||||||
from seahub.api2.endpoints.utils import api_check_group
|
from seahub.api2.endpoints.utils import api_check_group
|
||||||
@ -85,6 +85,7 @@ class GroupLibraries(APIView):
|
|||||||
group_repos = seafile_api.get_repos_by_group(group_id)
|
group_repos = seafile_api.get_repos_by_group(group_id)
|
||||||
|
|
||||||
group_repos.sort(key=lambda x: x.last_modified, reverse=True)
|
group_repos.sort(key=lambda x: x.last_modified, reverse=True)
|
||||||
|
group_repos = [gr for gr in group_repos if not is_wiki_repo(gr)]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
current_page = int(request.GET.get('page', '1'))
|
current_page = int(request.GET.get('page', '1'))
|
||||||
|
@ -13,7 +13,7 @@ from rest_framework import status
|
|||||||
from seaserv import seafile_api, ccnet_api
|
from seaserv import seafile_api, ccnet_api
|
||||||
from pysearpc import SearpcError
|
from pysearpc import SearpcError
|
||||||
|
|
||||||
from seahub.api2.utils import api_error
|
from seahub.api2.utils import api_error, is_wiki_repo
|
||||||
from seahub.api2.authentication import TokenAuthentication
|
from seahub.api2.authentication import TokenAuthentication
|
||||||
from seahub.api2.throttling import UserRateThrottle
|
from seahub.api2.throttling import UserRateThrottle
|
||||||
from seahub.api2.endpoints.group_owned_libraries import get_group_id_by_repo_owner
|
from seahub.api2.endpoints.group_owned_libraries import get_group_id_by_repo_owner
|
||||||
@ -181,6 +181,9 @@ class Groups(APIView):
|
|||||||
|
|
||||||
repos = []
|
repos = []
|
||||||
for r in group_repos:
|
for r in group_repos:
|
||||||
|
if is_wiki_repo(r):
|
||||||
|
continue
|
||||||
|
|
||||||
repo_owner = repo_id_owner_dict.get(r.id, r.user)
|
repo_owner = repo_id_owner_dict.get(r.id, r.user)
|
||||||
repo = {
|
repo = {
|
||||||
"id": r.id,
|
"id": r.id,
|
||||||
|
@ -10,7 +10,7 @@ from rest_framework import status
|
|||||||
|
|
||||||
from seahub.api2.throttling import UserRateThrottle
|
from seahub.api2.throttling import UserRateThrottle
|
||||||
from seahub.api2.authentication import TokenAuthentication
|
from seahub.api2.authentication import TokenAuthentication
|
||||||
from seahub.api2.utils import api_error
|
from seahub.api2.utils import api_error, is_wiki_repo
|
||||||
|
|
||||||
from seahub.api2.endpoints.group_owned_libraries import get_group_id_by_repo_owner
|
from seahub.api2.endpoints.group_owned_libraries import get_group_id_by_repo_owner
|
||||||
|
|
||||||
@ -114,6 +114,10 @@ class ReposView(APIView):
|
|||||||
if r.is_virtual:
|
if r.is_virtual:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if is_wiki_repo(r):
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
repo_info = {
|
repo_info = {
|
||||||
"type": "mine",
|
"type": "mine",
|
||||||
"repo_id": r.id,
|
"repo_id": r.id,
|
||||||
@ -171,6 +175,9 @@ class ReposView(APIView):
|
|||||||
shared_repos.sort(key=lambda x: x.last_modify, reverse=True)
|
shared_repos.sort(key=lambda x: x.last_modify, reverse=True)
|
||||||
for r in shared_repos:
|
for r in shared_repos:
|
||||||
|
|
||||||
|
if is_wiki_repo(r):
|
||||||
|
continue
|
||||||
|
|
||||||
owner_email = r.user
|
owner_email = r.user
|
||||||
|
|
||||||
group_name = ''
|
group_name = ''
|
||||||
@ -238,6 +245,11 @@ class ReposView(APIView):
|
|||||||
monitored_repo_id_list = []
|
monitored_repo_id_list = []
|
||||||
|
|
||||||
for r in group_repos:
|
for r in group_repos:
|
||||||
|
|
||||||
|
if is_wiki_repo(r):
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
repo_info = {
|
repo_info = {
|
||||||
"type": "group",
|
"type": "group",
|
||||||
"group_id": r.group_id,
|
"group_id": r.group_id,
|
||||||
@ -282,6 +294,10 @@ class ReposView(APIView):
|
|||||||
nickname_dict[e] = email2nickname(e)
|
nickname_dict[e] = email2nickname(e)
|
||||||
|
|
||||||
for r in public_repos:
|
for r in public_repos:
|
||||||
|
|
||||||
|
if is_wiki_repo(r):
|
||||||
|
continue
|
||||||
|
|
||||||
repo_owner = repo_id_owner_dict[r.repo_id]
|
repo_owner = repo_id_owner_dict[r.repo_id]
|
||||||
repo_info = {
|
repo_info = {
|
||||||
"type": "public",
|
"type": "public",
|
||||||
|
@ -21,6 +21,7 @@ from django.utils.translation import gettext as _
|
|||||||
from seahub.api2.authentication import TokenAuthentication
|
from seahub.api2.authentication import TokenAuthentication
|
||||||
from seahub.api2.throttling import UserRateThrottle
|
from seahub.api2.throttling import UserRateThrottle
|
||||||
from seahub.api2.utils import api_error, to_python_boolean
|
from seahub.api2.utils import api_error, to_python_boolean
|
||||||
|
from seahub.utils.db_api import SeafileDB
|
||||||
from seahub.wiki2.models import Wiki2 as Wiki
|
from seahub.wiki2.models import Wiki2 as Wiki
|
||||||
from seahub.wiki2.utils import is_valid_wiki_name, can_edit_wiki, get_wiki_dirs_by_path, \
|
from seahub.wiki2.utils import is_valid_wiki_name, can_edit_wiki, get_wiki_dirs_by_path, \
|
||||||
get_wiki_config, WIKI_PAGES_DIR, WIKI_CONFIG_PATH, WIKI_CONFIG_FILE_NAME, is_group_wiki, \
|
get_wiki_config, WIKI_PAGES_DIR, WIKI_CONFIG_PATH, WIKI_CONFIG_FILE_NAME, is_group_wiki, \
|
||||||
@ -183,6 +184,8 @@ class Wikis2View(APIView):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
wiki = Wiki.objects.add(wiki_name=wiki_name, owner=wiki_owner, repo_id=repo_id)
|
wiki = Wiki.objects.add(wiki_name=wiki_name, owner=wiki_owner, repo_id=repo_id)
|
||||||
|
seafile_db_api = SeafileDB()
|
||||||
|
seafile_db_api.set_repo_type(repo_id, 'wiki')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
msg = 'Internal Server Error'
|
msg = 'Internal Server Error'
|
||||||
|
@ -21,6 +21,7 @@ from pysearpc import SearpcError
|
|||||||
|
|
||||||
from seahub.base.templatetags.seahub_tags import email2nickname, \
|
from seahub.base.templatetags.seahub_tags import email2nickname, \
|
||||||
translate_seahub_time, file_icon_filter, email2contact_email
|
translate_seahub_time, file_icon_filter, email2contact_email
|
||||||
|
from seahub.constants import REPO_TYPE_WIKI
|
||||||
from seahub.group.views import is_group_staff
|
from seahub.group.views import is_group_staff
|
||||||
from seahub.group.utils import is_group_member
|
from seahub.group.utils import is_group_member
|
||||||
from seahub.api2.models import Token, TokenV2, DESKTOP_PLATFORMS
|
from seahub.api2.models import Token, TokenV2, DESKTOP_PLATFORMS
|
||||||
@ -278,3 +279,7 @@ def is_web_request(request):
|
|||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def is_wiki_repo(repo):
|
||||||
|
return repo.repo_type == REPO_TYPE_WIKI
|
||||||
|
|
||||||
|
@ -33,3 +33,5 @@ HASH_URLS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
REPO_SHARE_LINK_COUNT_LIMIT = 500000
|
REPO_SHARE_LINK_COUNT_LIMIT = 500000
|
||||||
|
|
||||||
|
REPO_TYPE_WIKI = 'wiki'
|
||||||
|
@ -357,3 +357,13 @@ class SeafileDB:
|
|||||||
"""
|
"""
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
|
|
||||||
|
def set_repo_type(self, repo_id, repo_type):
|
||||||
|
sql = f"""
|
||||||
|
UPDATE `{self.db_name}`. `RepoInfo`
|
||||||
|
SET `type`= '%s'
|
||||||
|
WHERE `repo_id`='%s'
|
||||||
|
""" % (repo_type, repo_id)
|
||||||
|
|
||||||
|
with connection.cursor() as cursor:
|
||||||
|
cursor.execute(sql)
|
||||||
|
Loading…
Reference in New Issue
Block a user