示例#1
0
def main():
    config = Config()
    with open("/etc/uwsgi.ini", "w") as f:
        f.write(uWSGI_CONF.format(
            host=config.APP_HOST,
            port=config.APP_PORT,
        ))
示例#2
0
文件: auth.py 项目: hunkom/galloper
def is_user_part_of_the_project(project_id):
    user_data = _get_user_data()
    if Config().SUPERADMIN_GROUP in user_data["groups"]:
        return True
    else:
        # check permission
        if f"/{project_id}" in user_data["groups"]:
            return True
    return False
示例#3
0
文件: auth.py 项目: hunkom/galloper
def is_superadmin():
    user_data = _get_user_data()
    current_app.logger.info(str(user_data))
    current_app.logger.info("Is admin")
    if Config().SUPERADMIN_GROUP in user_data["groups"]:
        current_app.logger.info("True")
        return True
    current_app.logger.info("False")
    return False
示例#4
0
def is_superadmin():
    if current_app.config['DEV']:
        return True
    user_data = _get_user_data()
    current_app.logger.info(str(user_data))
    current_app.logger.info("Is admin")
    if Config().SUPERADMIN_GROUP in user_data["groups"]:
        return True
    return False
示例#5
0
文件: auth.py 项目: hunkom/galloper
class SessionUser:
    USER_CACHE_KEY = Config().USER_CACHE_KEY

    @staticmethod
    def set(user_session: dict) -> None:
        session[SessionUser.USER_CACHE_KEY] = user_session

    @staticmethod
    def pop() -> Optional[int]:
        return session.pop(SessionUser.USER_CACHE_KEY, default=None)

    @staticmethod
    def get() -> Optional[int]:
        return session.get(SessionUser.USER_CACHE_KEY)
示例#6
0
文件: auth.py 项目: hunkom/galloper
class SessionProject:
    PROJECT_CACHE_KEY = Config().PROJECT_CACHE_KEY

    @staticmethod
    def set(project_id: int) -> None:
        session[SessionProject.PROJECT_CACHE_KEY] = project_id

    @staticmethod
    def pop() -> Optional[int]:
        return session.pop(SessionProject.PROJECT_CACHE_KEY, default=None)

    @staticmethod
    def get() -> Optional[int]:
        return session.get(SessionProject.PROJECT_CACHE_KEY)
示例#7
0
文件: app.py 项目: hunkom/galloper
def main():
    config = Config()
    app.run(host=config.APP_HOST, port=config.APP_PORT, debug=True)
示例#8
0
#     You may obtain a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#     Unless required by applicable law or agreed to in writing, software
#     distributed under the License is distributed on an "AS IS" BASIS,
#     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#     See the License for the specific language governing permissions and
#     limitations under the License.

import json

from galloper.config import Config
from galloper.database.db_manager import db_session

config = Config()


class AbstractBaseMixin:
    __table__ = None
    __table_args__ = {
        "schema": config.DATABASE_SCHEMA
    } if config.DATABASE_SCHEMA else None

    def __repr__(self) -> str:
        return json.dumps(self.to_json(), indent=2)

    def to_json(self, exclude_fields: tuple = ()) -> dict:
        return {
            column.name: getattr(self, column.name)
            for column in self.__table__.columns