1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-11-10 04:02:17 +00:00

Reworked imports

This commit is contained in:
spl0k 2014-03-04 22:56:53 +01:00
parent 6ed86f544f
commit 4ce3958cbb
9 changed files with 70 additions and 45 deletions

View File

@ -190,3 +190,13 @@ def get_entity(req, ent, param = 'id'):
return True, entity return True, entity
from .system import *
from .browse import *
from .user import *
from .albums_songs import *
from .media import *
from .annotation import *
from .chat import *
from .search import *
from .playlists import *

View File

@ -22,7 +22,7 @@ import time
import uuid import uuid
from flask import request from flask import request
from web import app from web import app
from api import get_entity from . import get_entity
from lastfm import LastFm from lastfm import LastFm
from db import * from db import *

View File

@ -21,7 +21,7 @@
from flask import request from flask import request
from web import app from web import app
from db import Folder, Artist, Album, Track from db import Folder, Artist, Album, Track
from api import get_entity from . import get_entity
import uuid, time, string import uuid, time, string
@app.route('/rest/getMusicFolders.view', methods = [ 'GET', 'POST' ]) @app.route('/rest/getMusicFolders.view', methods = [ 'GET', 'POST' ])

View File

@ -29,7 +29,7 @@ from xml.etree import ElementTree
import config, scanner import config, scanner
from web import app from web import app
from db import Track, Album, Artist, Folder, User, ClientPrefs, now, session from db import Track, Album, Artist, Folder, User, ClientPrefs, now, session
from api import get_entity from . import get_entity
from sqlalchemy import func from sqlalchemy import func

55
frontend/__init__.py Normal file
View File

@ -0,0 +1,55 @@
# coding: utf-8
# This file is part of Supysonic.
#
# 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
# it under the terms of the GNU Affero General Public License as published by
# 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,
# 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 web import app
from managers.user import UserManager
app.add_template_filter(str)
@app.before_request
def login_check():
if request.path.startswith('/rest/'):
return
if request.endpoint != 'login':
should_login = False
if not session.get('userid'):
should_login = True
elif UserManager.get(session.get('userid'))[0] != UserManager.SUCCESS:
session.clear()
should_login = True
if should_login:
flash('Please login')
return redirect(url_for('login', returnUrl = request.script_root + request.url[len(request.url_root)-1:]))
@app.route('/')
def index():
stats = {
'artists': db.Artist.query.count(),
'albums': db.Album.query.count(),
'tracks': db.Track.query.count()
}
return render_template('home.html', stats = stats, admin = UserManager.get(session.get('userid'))[1].admin)
from .user import *
from .folder import *
from .playlist import *

44
web.py
View File

@ -23,33 +23,9 @@ from flask import Flask, request, session, flash, render_template, redirect, url
import config import config
def login_check():
if request.path.startswith('/rest/'):
return
if request.endpoint != 'login':
should_login = False
if not session.get('userid'):
should_login = True
elif UserManager.get(session.get('userid'))[0] != UserManager.SUCCESS:
session.clear()
should_login = True
if should_login:
flash('Please login')
return redirect(url_for('login', returnUrl = request.script_root + request.url[len(request.url_root)-1:]))
def teardown(exception): def teardown(exception):
db.session.remove() db.session.remove()
def index():
stats = {
'artists': db.Artist.query.count(),
'albums': db.Album.query.count(),
'tracks': db.Track.query.count()
}
return render_template('home.html', stats = stats, admin = UserManager.get(session.get('userid'))[1].admin)
def create_application(): def create_application():
global app, db, UserManager global app, db, UserManager
@ -72,26 +48,10 @@ def create_application():
handler.setLevel(logging.WARNING) handler.setLevel(logging.WARNING)
app.logger.addHandler(handler) app.logger.addHandler(handler)
from managers.user import UserManager
app.before_request(login_check)
app.teardown_request(teardown) app.teardown_request(teardown)
app.add_template_filter(str)
app.add_url_rule('/', view_func = index)
import user import frontend
import folder import api
import playlist
import api.system
import api.browse
import api.user
import api.albums_songs
import api.media
import api.annotation
import api.chat
import api.search
import api.playlists
return app return app