Beispiel #1
0
def create_view(dataset, view_config):
    """
    Create view for a provided dataset from a view provided as dict
    """

    # Check if it exists (if not we create it)
    existing = View.by_name(dataset, view_config['name'])
    if existing is None:
        # Create the view
        view = View()

        # Set saved configurations
        view.widget = view_config['widget']
        view.state = view_config['state']
        view.name = view_config['name']
        view.label = view_config['label']
        view.description = view_config['description']
        view.public = view_config['public']
        
        # Set the dataset as the current dataset
        view.dataset = dataset

        # Try and set the account provided but if it doesn't exist
        # revert to shell account
        view.account = Account.by_name(view_config['account'])
        if view.account is None:
            view.account = shell_account()

        # Commit view to database
        db.session.add(view)
        db.session.commit()
Beispiel #2
0
def create_view(dataset, view_config):
    """
    Create view for a provided dataset from a view provided as dict
    """

    # Check if it exists (if not we create it)
    existing = View.by_name(dataset, view_config['name'])
    if existing is None:
        # Create the view
        view = View()

        # Set saved configurations
        view.widget = view_config['widget']
        view.state = view_config['state']
        view.name = view_config['name']
        view.label = view_config['label']
        view.description = view_config['description']
        view.public = view_config['public']

        # Set the dataset as the current dataset
        view.dataset = dataset

        # Try and set the account provided but if it doesn't exist
        # revert to shell account
        view.account = Account.by_name(view_config['account'])
        if view.account is None:
            view.account = shell_account()

        # Commit view to database
        db.session.add(view)
        db.session.commit()
Beispiel #3
0
 def create(self, dataset):
     self._get_dataset(dataset)
     require.view.create(c.dataset)
     handle_request(request, c, c.dataset)
     try:
         data = CreateView().deserialize(request.params)
         view = View()
         view.dataset = c.dataset
         view.account = c.account
         view.widget = data['widget']
         view.state = data['state']
         view.name = make_name(c.dataset, data['label'])
         view.label = data['label']
         view.description = data['description']
         view.public = True
         db.session.add(view)
         db.session.commit()
         redirect(h.url_for(controller='view', action='view',
             dataset=c.dataset.name, name=view.name))
     except colander.Invalid as inv:
         return self.new(dataset, errors=inv.asdict())
Beispiel #4
0
 def create(self, dataset):
     self._get_dataset(dataset)
     require.view.create(c.dataset)
     handle_request(request, c, c.dataset)
     try:
         data = CreateView().deserialize(request.params)
         view = View()
         view.dataset = c.dataset
         view.account = c.account
         view.widget = data['widget']
         view.state = data['state']
         view.name = make_name(c.dataset, data['label'])
         view.label = data['label']
         view.description = data['description']
         view.public = True
         db.session.add(view)
         db.session.commit()
         redirect(h.url_for(controller='view', action='view',
                            dataset=c.dataset.name, name=view.name))
     except colander.Invalid as inv:
         return self.new(dataset, errors=inv.asdict())