<commit_before>#! /usr/bin/env python
#-*- coding: utf-8 -*-

# ***** BEGIN LICENSE BLOCK *****
# This file is part of Shelter Database.
# Copyright (c) 2016 Luxembourg Institute of Science and Technology.
# All rights reserved.
#
#
#
# ***** END LICENSE BLOCK *****

__author__ = "<NAME>"
__version__ = "$Revision: 0.1 $"
__date__ = "$Date: 2016/06/07 $"
__revision__ = "$Date: 2016/06/07 $"
__copyright__ = "Copyright 2016 Luxembourg Institute of Science and Technology"
__license__ = ""

#
# Views generated by Flask-Admin for the database administration.
#

from flask import current_app
from flask_admin import Admin, AdminIndexView
from flask_admin.contrib.sqla import ModelView
from flask_admin.menu import MenuLink

from bootstrap import db
from web.models import User, Shelter, Value, Translation

class TranslationView(ModelView):
    column_searchable_list = ('original', 'translated')
    column_filters = ['language_code']
    column_editable_list = ['translated']

class ValueView(ModelView):
    column_searchable_list = ('name',)
    column_filters = ['attribute_id']

class UserView(ModelView):
    column_exclude_list = ['pwdhash']
    column_editable_list = ['email', 'name']

class ShelterView(ModelView):
    column_exclude_list = ['properties']
    form_excluded_columns = ['properties']

menu_link_back_dashboard = MenuLink(name='Back to dashboard',
                                url='/admin/dashboard')
menu_link_back_home = MenuLink(name='Back to home',
                                url='/')

admin = Admin(current_app,
                name='Management of data',
                template_mode='bootstrap3',
                index_view=AdminIndexView(
                        name='Home',
                        url='/admin/data_management'
                    ))<commit_msg>Check the permissions with flask_login for the views generated with Flask-Admin.<commit_after>#! /usr/bin/env python
#-*- coding: utf-8 -*-

# ***** BEGIN LICENSE BLOCK *****
# This file is part of Shelter Database.
# Copyright (c) 2016 Luxembourg Institute of Science and Technology.
# All rights reserved.
#
#
#
# ***** END LICENSE BLOCK *****

__author__ = "<NAME>"
__version__ = "$Revision: 0.1 $"
__date__ = "$Date: 2016/06/07 $"
__revision__ = "$Date: 2016/06/07 $"
__copyright__ = "Copyright 2016 Luxembourg Institute of Science and Technology"
__license__ = ""

#
# Views generated by Flask-Admin for the database administration.
#
from flask_login import current_user
from flask import current_app
from flask_admin import Admin, AdminIndexView
from flask_admin.contrib.sqla import ModelView
from flask_admin.menu import MenuLink

from bootstrap import db
from web.models import User, Shelter, Value, Translation

class TranslationView(ModelView):
    column_searchable_list = ('original', 'translated')
    column_filters = ['language_code']
    column_editable_list = ['translated']
    def is_accessible(self):
        return current_user.is_authenticated and current_user.is_admin

class ValueView(ModelView):
    column_searchable_list = ('name',)
    column_filters = ['attribute_id']
    def is_accessible(self):
        return current_user.is_authenticated and current_user.is_admin

class UserView(ModelView):
    column_exclude_list = ['pwdhash']
    column_editable_list = ['email', 'name']
    def is_accessible(self):
        return current_user.is_authenticated and current_user.is_admin

class ShelterView(ModelView):
    column_exclude_list = ['properties']
    form_excluded_columns = ['properties']
    def is_accessible(self):
        return current_user.is_authenticated and current_user.is_admin

menu_link_back_dashboard = MenuLink(name='Back to dashboard',
                                url='/admin/dashboard')
menu_link_back_home = MenuLink(name='Back to home',
                                url='/')

admin = Admin(current_app,
                name='Management of data',
                template_mode='bootstrap3',
                index_view=AdminIndexView(
                        name='Home',
                        url='/admin/data_management'
                    ))
{'fraction_non_alphanumeric': 0.10654342009243493, 'fraction_numerical': 0.013621989783507663, 'mean_word_length': 3.328421052631579, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3782973', 'n_tokens_mistral': 1248, 'n_tokens_neox': 1143, 'n_words': 306}