Exemple #1
0
    def create(self, username, first_name, last_name, email, access_level):
        """Creates a user (if the user doesn't already exist)
            Params:
                username: The login name of the user
                first_name: User's first name
                last_name: User's last name
                email: User's email address
                access_level: Set to 'Admin' for administrative functions
        """

        with self.transaction_scope() as session:

            user = User()
            user.username = username
            user.name = " ".join([first_name, last_name])
            user.email = email
            user.access_level = access_level
            user.first_name = first_name
            user.last_name = last_name

            session.add(user)
Exemple #2
0
def setup_app(command, conf, vars):
    """Place any commands to setup ecomaps here - currently creating db tables"""

    # Don't reload the app if it was loaded under the testing environment
    if not pylons.test.pylonsapp:
        load_environment(conf.global_conf, conf.local_conf)

    # Create the tables if they don't already exist
    Base.metadata.drop_all(bind=Session.bind)
    Base.metadata.create_all(bind=Session.bind)

    with session_scope(Session) as session:

        user = User()
        user.name = "Phil Jenkins"
        user.first_name = "Phil"
        user.last_name = "Jenkins"
        user.username = "******"
        user.email = "*****@*****.**"
        user.access_level = "Admin"

        session.add(user)

        user2 = User()
        user2.name = "Mike Wilson"
        user2.first_name = "Mike"
        user2.last_name = "Wilson"
        user2.username = "******"
        user2.email = "*****@*****.**"
        user2.access_level = "Admin"

        session.add(user2)

        # Model that provides the interface to the R code
        model = Model()
        model.name = "LCM Thredds Model"
        model.id = 1
        model.description = "LCM Thredds model written in R"
        model.code_path = "code_root"

        session.add(model)

        pointDst = DatasetType()
        pointDst.type = "Point"

        coverDst = DatasetType()
        coverDst.type = "Coverage"

        resultDst = DatasetType()
        resultDst.type = "Result"

        session.add(pointDst)
        session.add(coverDst)
        session.add(resultDst)

        # Define a datasetType lookup. This will conver the possible thredds
        # datasets into their EcoMaps equivalents.
        datasetTypes = {"GRID": coverDst, "POINT": pointDst}

        # Populate from thredds
        registerThreddsDatasets("http://thredds.ceh.ac.uk/thredds/ecomaps.xml", datasetTypes, session)