app.py 1.68 KB
Newer Older
LE GAC Renaud's avatar
LE GAC Renaud committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
"""User Interface for the  App tables

"""
from gluon import current
from plugin_dbui import StoreModifier


class AppUI(object):

    @staticmethod
    def configure(db, T):
        """Configure the user interface for the history table and
        its foreign tables,

        Args:
            db (pyDAL.DAL): database connection
            T (gluon.languages.translator): language translator

        """
LE GAC Renaud's avatar
LE GAC Renaud committed
20
        AppUI.preferences(db, T)
LE GAC Renaud's avatar
LE GAC Renaud committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

    @staticmethod
    def preferences(db, T):
        """UI for the preferences table

        Args:
            db (pyDAL.DAL): database connection
            T (gluon.languages.translator): language translator

        """
        year = current.request.now.year

        # ....................................................................
        #
        # Grid
        # configuration of the grid property use to show preference values
        #
        current.app.cfgPreferences = \
            dict(dbtable="preferences",
                 height=200,
                 nameColumnWidth=150,
                 source={
                     "authorize_harvester_scan": False,
                     "authorize_user_login": False,
                     "harvester_start_year": year},
                 sourceConfig={
                     "authorize_harvester_scan": {"type": "boolean"},
                     "authorize_user_login": {"type": "boolean"},
                     "harvester_start_year": {"type": "number"}},
                 width=250,
                 xtype="xpreferences")

        # ....................................................................
        #
        # Store
        #
        StoreModifier("preferences").orderby(db.preferences.property)