<commit_before>#! /usr/bin/env python3

import datetime
import os

from odie import app, db
from api_utils import document_path, save_file
from models.documents import Document, Lecture, Examinant, Deposit

from flask import redirect
from flask_admin import Admin, BaseView, AdminIndexView, form
from flask_admin.contrib.sqla import ModelView
from flask.ext.login import current_user
from wtforms.validators import Optional

def _dateFormatter(attr_name):
    def f(v, c, m, n):
        d = getattr(m, attr_name)
        return d.date() if d else ''
    return f

_exam_allowed_roles = ['adm', 'info_protokolle', 'info_klausuren', 'mathe_protokolle', 'mathe_klausuren']

class AuthView(BaseView):
    def is_accessible(self):
        return current_user.is_authenticated() \
                and any(True for perm in self.allowed_roles if current_user.has_permission(perm))

    def _handle_view(self, name, **kwargs):
        if not self.is_accessible():
            return redirect('/')

class AuthModelView(ModelView, AuthView):<commit_msg>Increase page size in admin interface<commit_after>#! /usr/bin/env python3

import datetime
import os

from odie import app, db
from api_utils import document_path, save_file
from models.documents import Document, Lecture, Examinant, Deposit

from flask import redirect
from flask_admin import Admin, BaseView, AdminIndexView, form
from flask_admin.contrib.sqla import ModelView
from flask.ext.login import current_user
from wtforms.validators import Optional

def _dateFormatter(attr_name):
    def f(v, c, m, n):
        d = getattr(m, attr_name)
        return d.date() if d else ''
    return f

_exam_allowed_roles = ['adm', 'info_protokolle', 'info_klausuren', 'mathe_protokolle', 'mathe_klausuren']

class AuthView(BaseView):
    def is_accessible(self):
        return current_user.is_authenticated() \
                and any(True for perm in self.allowed_roles if current_user.has_permission(perm))

    def _handle_view(self, name, **kwargs):
        if not self.is_accessible():
            return redirect('/')

class AuthModelView(ModelView, AuthView):
    page_size = 50  # the default of 20 is a bit on the low side...
{'fraction_non_alphanumeric': 0.08777573529411764, 'fraction_numerical': 0.0027573529411764708, 'mean_word_length': 4.098360655737705, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6447779', 'n_tokens_mistral': 697, 'n_tokens_neox': 659, 'n_words': 209}