Beispiel #1
0
    def status(self, job_id):
        c.job_id = job_id
        c.job_running = daemon.job_running(job_id)
        c.job_log = daemon.job_log(job_id)

        if request.is_xhr:
            return render('job/_status.html')
        else:
            return render('job/status.html')
Beispiel #2
0
    def packages(self):
        try:
            c.packages = ckan.openspending_packages()
        except ckan.CkanApiError as e:
            log.error(e)

        return render('load/_packages.html')
Beispiel #3
0
    def diagnose(self, package):
        c.pkg = ckan.Package(package)

        c.pkg_diagnostics = {}
        for hint in ('model', 'model:mapping', 'data'):
            c.pkg_diagnostics[hint] = _url_or_error_for_package(c.pkg, hint)

        return render('load/diagnose.html')
Beispiel #4
0
    def preflight(self, package):
        c.pkg = ckan.Package(package)

        c.pkg_diagnostics = {}
        for hint in ('model', 'data'):
            c.pkg_diagnostics[hint] = _resource_or_error_for_package(c.pkg, hint)

        return render('load/preflight.html')
Beispiel #5
0
    def remove_dataset(self, dataset=None):
        if dataset is None:
            c.datasets = model.Dataset.find()
            return render('task/remove_dataset.html')

        c.job_id = 'remove_%s' % dataset
        c.job_running = daemon.job_running(c.job_id)

        if c.job_running:
            return render('task/remove_dataset.html')

        daemon.dispatch_job(
            job_id=c.job_id,
            config=config['__file__'],
            task='remove_dataset',
            args=(dataset,)
        )
        return redirect(url(controller='job', action='status', job_id=c.job_id))
Beispiel #6
0
    def drop_database(self):
        c.job_id = 'drop_database'

        if daemon.job_running(c.job_id):
            return render('task/drop_database.html')

        daemon.dispatch_job(
            job_id=c.job_id,
            config=config['__file__'],
            task='drop_collections'
        )
        return redirect(url(controller='job', action='status', job_id=c.job_id))
Beispiel #7
0
    def start(self, package):
        job_id = _job_id_for_package(package)

        if daemon.job_running(job_id):
            c.pkg_name = package
            c.job_id = job_id
            return render('load/start.html')
        else:
            daemon.dispatch_job(
                job_id=job_id,
                config=config['__file__'],
                task='ckan_import',
                args=(package,)
            )
            return redirect(url(
                controller='job',
                action='status',
                job_id=job_id
            ))
Beispiel #8
0
 def index(self):
     c.group = ckan.openspending_group
     return render('load/index.html')
 def login(self):
     return render('account/login.html')
Beispiel #10
0
                values = request.params
                data = schema.deserialize(values)
                if not data['password1'] == data['password2']:
                    raise colander.Invalid(Register.password1,
                                           _("Passwords don't match!"))

                if len(data['password1']):
                    password = data['password1']
                    data['password_hash'] = generate_password_hash(password)
                del data['password1']
                del data['password2']
                model.Account.c.update({"name": c.account_name},
                                       {"$set": data})
                h.flash_success(_("Your settings have been updated."))
            except colander.Invalid, i:
                errors = i.asdict()
        return render('account/settings.html', form_fill=values,
                form_errors=errors)

    def after_login(self):
        if c.account is not None:
            h.flash_success(_("Welcome back, %s!") % c.account.get("name"))
            redirect("/")
        else:
            h.flash_error(_("Incorrect user name or password!"))
            redirect("/login")

    def after_logout(self):
        h.flash_success(_("You have been logged out."))
        redirect("/")
Beispiel #11
0
 def index(self):
     return render('home/index.html')