Skip to content

Commit

Permalink
is_db_sqlite3
Browse files Browse the repository at this point in the history
  • Loading branch information
SkywalkerSpace committed Aug 24, 2023
1 parent 68e53b3 commit 5db8555
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 9 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/main-side-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Utils } from '../utils/utils';
import toaster from './toast';
import Group from '../models/group';

import { canViewOrg, isDocs, isPro, customNavItems } from '../utils/constants';
import { canViewOrg, isDocs, isPro, isDBSqlite3, customNavItems } from '../utils/constants';

const propTypes = {
currentTab: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
Expand Down Expand Up @@ -180,7 +180,7 @@ class MainSideNav extends React.Component {
}

render() {
let showActivity = isDocs || isPro;
let showActivity = isDocs || !isDBSqlite3;
return (
<div className="side-nav">
<div className="side-nav-con">
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/sys-admin/side-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { gettext, siteRoot, isPro, otherPermission, canViewSystemInfo, canViewSt
canConfigSystem, canManageLibrary, canManageUser, canManageGroup, canViewUserLog,
canViewAdminLog, constanceEnabled, multiTenancy, multiInstitution, sysadminExtraEnabled,
enableGuestInvitation, enableTermsAndConditions, enableFileScan, enableWorkWeixin, enableDingtalk,
enableShareLinkReportAbuse } from '../../utils/constants';
enableShareLinkReportAbuse, isDBSqlite3 } from '../../utils/constants';

const propTypes = {
isSidePanelClosed: PropTypes.bool.isRequired,
Expand Down Expand Up @@ -44,7 +44,7 @@ class SidePanel extends React.Component {
</Link>
</li>
}
{isPro && canViewStatistic &&
{!isDBSqlite3 && canViewStatistic &&
<li className="nav-item">
<Link className={`nav-link ellipsis ${this.getActiveClass('statistic')}`}
to={siteRoot + 'sys/statistics/file/'}
Expand Down
1 change: 1 addition & 0 deletions frontend/src/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const siteName = window.app.config.siteName;
export const logoWidth = window.app.config.logoWidth;
export const logoHeight = window.app.config.logoHeight;
export const isPro = window.app.config.isPro === 'True';
export const isDBSqlite3 = window.app.config.isDBSqlite3;
export const isDocs = window.app.config.isDocs === 'True';
export const lang = window.app.config.lang;
export const fileServerRoot = window.app.config.fileServerRoot;
Expand Down
4 changes: 2 additions & 2 deletions seahub/api2/endpoints/activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from rest_framework.authentication import SessionAuthentication

from seahub.base.templatetags.seahub_tags import email2contact_email
from seahub.utils import EVENTS_ENABLED, get_user_activities
from seahub.utils import EVENTS_ENABLED, get_user_activities, is_db_sqlite3
from seahub.utils.timeutils import utc_datetime_to_isoformat_timestr
from seahub.api2.utils import api_error
from seahub.api2.throttling import UserRateThrottle
Expand All @@ -27,7 +27,7 @@ class ActivitiesView(APIView):
throttle_classes = (UserRateThrottle, )

def get(self, request, format=None):
if not EVENTS_ENABLED:
if not EVENTS_ENABLED or is_db_sqlite3():
events = None
return api_error(status.HTTP_404_NOT_FOUND, 'Events not enabled.')

Expand Down
4 changes: 2 additions & 2 deletions seahub/api2/endpoints/admin/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from seaserv import ccnet_api

from seahub.utils import get_file_ops_stats_by_day, \
from seahub.utils import get_file_ops_stats_by_day, is_db_sqlite3, \
get_total_storage_stats_by_day, get_user_activity_stats_by_day, \
is_pro_version, EVENTS_ENABLED, get_system_traffic_by_day, \
get_all_users_traffic_by_month, get_all_orgs_traffic_by_month
Expand All @@ -34,7 +34,7 @@

def check_parameter(func):
def _decorated(view, request, *args, **kwargs):
if not is_pro_version() or not EVENTS_ENABLED:
if not EVENTS_ENABLED or is_db_sqlite3():
return api_error(status.HTTP_404_NOT_FOUND, 'Events not enabled.')
start_time = request.GET.get("start", "")
end_time = request.GET.get("end", "")
Expand Down
4 changes: 3 additions & 1 deletion seahub/base/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
from seahub.avatar.templatetags.avatar_tags import api_avatar_url


from seahub.utils import HAS_FILE_SEARCH, EVENTS_ENABLED, is_pro_version, ENABLE_REPO_AUTO_DEL
from seahub.utils import HAS_FILE_SEARCH, EVENTS_ENABLED, is_pro_version, ENABLE_REPO_AUTO_DEL, \
is_db_sqlite3

try:
from seahub.settings import MULTI_TENANCY
Expand Down Expand Up @@ -151,6 +152,7 @@ def base(request):
'enable_terms_and_conditions': config.ENABLE_TERMS_AND_CONDITIONS,
'show_logout_icon': SHOW_LOGOUT_ICON,
'is_pro': True if is_pro_version() else False,
'is_db_sqlite3': is_db_sqlite3(),
'is_docs': ENABLE_SEAFILE_DOCS,
'enable_upload_folder': dj_settings.ENABLE_UPLOAD_FOLDER,
'enable_resumable_fileupload': dj_settings.ENABLE_RESUMABLE_FILEUPLOAD,
Expand Down
1 change: 1 addition & 0 deletions seahub/templates/base_for_react.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
siteRoot: '{{ SITE_ROOT }}',
loginUrl: '{{ LOGIN_URL }}',
isPro: '{{ is_pro }}',
isDBSqlite3: {% if is_db_sqlite3 %} true {% else %} false {% endif %},
isDocs: '{{ is_docs }}',
lang: '{{ LANGUAGE_CODE }}',
fileServerRoot: '{{ FILE_SERVER_ROOT }}',
Expand Down
9 changes: 9 additions & 0 deletions seahub/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ def is_cluster_mode():

CLUSTER_MODE = is_cluster_mode()

def is_db_sqlite3():
is_db_sqlite3 = False
try:
if 'sqlite3' in seahub.settings.DATABASES['default']['ENGINE']:
is_db_sqlite3 = True
except:
pass
return is_db_sqlite3

try:
from seahub.settings import OFFICE_CONVERTOR_ROOT
except ImportError:
Expand Down

0 comments on commit 5db8555

Please sign in to comment.