1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 17:06:17 +00:00

Retab and change header to frontend __init__.py

This commit is contained in:
Óscar García Amor 2017-08-07 13:10:06 +02:00
parent 32e3cce954
commit d9d90ffacf
7 changed files with 72 additions and 51 deletions

View File

@ -33,5 +33,6 @@ setup(
parse_requirements('requirements.txt', session=PipSession())], parse_requirements('requirements.txt', session=PipSession())],
scripts=['bin/supysonic-cli', 'bin/supysonic-watcher'], scripts=['bin/supysonic-cli', 'bin/supysonic-watcher'],
zip_safe=False, zip_safe=False,
include_package_data=True include_package_data=True,
test_suite="tests.suite"
) )

View File

@ -1,22 +1,13 @@
# coding: utf-8 # -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# This file is part of Supysonic. # This file is part of Supysonic.
#
# Supysonic is a Python implementation of the Subsonic server API. # Supysonic is a Python implementation of the Subsonic server API.
# Copyright (C) 2014 Alban 'spl0k' Féron
# #
# This program is free software: you can redistribute it and/or modify # Copyright (C) 2013-2017 Alban 'spl0k' Féron
# it under the terms of the GNU Affero General Public License as published by # 2017 Óscar García Amor
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # Distributed under terms of the GNU AGPLv3 license.
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from flask import session from flask import session
from supysonic.web import app, store from supysonic.web import app, store
@ -27,32 +18,32 @@ app.add_template_filter(str)
@app.before_request @app.before_request
def login_check(): def login_check():
if request.path.startswith('/rest/'): if request.path.startswith('/rest/'):
return return
if request.path.startswith('/static/'): if request.path.startswith('/static/'):
return return
if request.endpoint != 'login': if request.endpoint != 'login':
should_login = False should_login = False
if not session.get('userid'): if not session.get('userid'):
should_login = True should_login = True
elif UserManager.get(store, session.get('userid'))[0] != UserManager.SUCCESS: elif UserManager.get(store, session.get('userid'))[0] != UserManager.SUCCESS:
session.clear() session.clear()
should_login = True should_login = True
if should_login: if should_login:
flash('Please login') flash('Please login')
return redirect(url_for('login', returnUrl = request.script_root + request.url[len(request.url_root)-1:])) return redirect(url_for('login', returnUrl = request.script_root + request.url[len(request.url_root)-1:]))
@app.route('/') @app.route('/')
def index(): def index():
stats = { stats = {
'artists': store.find(Artist).count(), 'artists': store.find(Artist).count(),
'albums': store.find(Album).count(), 'albums': store.find(Album).count(),
'tracks': store.find(Track).count() 'tracks': store.find(Track).count()
} }
return render_template('home.html', stats = stats, admin = UserManager.get(store, session.get('userid'))[1].admin) return render_template('home.html', stats = stats, admin = UserManager.get(store, session.get('userid'))[1].admin)
from .user import * from .user import *
from .folder import * from .folder import *

View File

@ -1,12 +1,25 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim:fenc=utf-8 # vim:fenc=utf-8
# #
# Copyright © 2017 Óscar García Amor <ogarcia@connectical.com> # This file is part of Supysonic.
# Supysonic is a Python implementation of the Subsonic server API.
# #
# Distributed under terms of the GNU GPLv3 license. # Copyright (C) 2013-2017 Alban 'spl0k' Féron
# 2017 Óscar García Amor
#
# Distributed under terms of the GNU AGPLv3 license.
import unittest
from .test_manager_folder import FolderManagerTestCase from .test_manager_folder import FolderManagerTestCase
from .test_manager_user import UserManagerTestCase from .test_manager_user import UserManagerTestCase
from .test_api import ApiTestCase from .test_api import ApiTestCase
from .test_frontend import FrontendTestCase from .test_frontend import FrontendTestCase
def suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(FolderManagerTestCase))
suite.addTest(unittest.makeSuite(UserManagerTestCase))
suite.addTest(unittest.makeSuite(ApiTestCase))
suite.addTest(unittest.makeSuite(FrontendTestCase))
return suite

View File

@ -1,10 +1,14 @@
#! /usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim:fenc=utf-8 # vim:fenc=utf-8
# #
# Copyright © 2017 Óscar García Amor <ogarcia@connectical.com> # This file is part of Supysonic.
# Supysonic is a Python implementation of the Subsonic server API.
# #
# Distributed under terms of the GNU GPLv3 license. # Copyright (C) 2013-2017 Alban 'spl0k' Féron
# 2017 Óscar García Amor
#
# Distributed under terms of the GNU AGPLv3 license.
from supysonic import db from supysonic import db
from supysonic.managers.user import UserManager from supysonic.managers.user import UserManager

View File

@ -1,10 +1,14 @@
#! /usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim:fenc=utf-8 # vim:fenc=utf-8
# #
# Copyright © 2017 Óscar García Amor <ogarcia@connectical.com> # This file is part of Supysonic.
# Supysonic is a Python implementation of the Subsonic server API.
# #
# Distributed under terms of the GNU GPLv3 license. # Copyright (C) 2013-2017 Alban 'spl0k' Féron
# 2017 Óscar García Amor
#
# Distributed under terms of the GNU AGPLv3 license.
from supysonic import db from supysonic import db
from supysonic.managers.user import UserManager from supysonic.managers.user import UserManager

View File

@ -1,10 +1,14 @@
#! /usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim:fenc=utf-8 # vim:fenc=utf-8
# #
# Copyright © 2017 Óscar García Amor <ogarcia@connectical.com> # This file is part of Supysonic.
# Supysonic is a Python implementation of the Subsonic server API.
# #
# Distributed under terms of the GNU GPLv3 license. # Copyright (C) 2013-2017 Alban 'spl0k' Féron
# 2017 Óscar García Amor
#
# Distributed under terms of the GNU AGPLv3 license.
from supysonic import db from supysonic import db
from supysonic.managers.folder import FolderManager from supysonic.managers.folder import FolderManager

View File

@ -1,10 +1,14 @@
#! /usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vim:fenc=utf-8 # vim:fenc=utf-8
# #
# Copyright © 2017 Óscar García Amor <ogarcia@connectical.com> # This file is part of Supysonic.
# Supysonic is a Python implementation of the Subsonic server API.
# #
# Distributed under terms of the GNU GPLv3 license. # Copyright (C) 2013-2017 Alban 'spl0k' Féron
# 2017 Óscar García Amor
#
# Distributed under terms of the GNU AGPLv3 license.
from supysonic import db from supysonic import db
from supysonic.managers.user import UserManager from supysonic.managers.user import UserManager