Exemplo n.º 1
0
    def core_edit(self, dataset, errors={}, format='html'):
        self._get_dataset(dataset)
        self._disable_cache()
        require.dataset.update(c.dataset)
        c.key_currencies = sorted(
            [(r, n) for (r, (n, k)) in CURRENCIES.items() if k],
            key=lambda k_v: k_v[1])
        c.all_currencies = sorted(
            [(r, n) for (r, (n, k)) in CURRENCIES.items() if not k],
            key=lambda k_v1: k_v1[1])
        c.languages = sorted(LANGUAGES.items(), key=lambda k_v2: k_v2[1])
        c.territories = sorted(COUNTRIES.items(), key=lambda k_v3: k_v3[1])
        c.categories = sorted(CATEGORIES.items(), key=lambda k_v4: k_v4[1])

        if 'time' in c.dataset:
            c.available_times = [m['year']
                                 for m in c.dataset['time'].members()]
            c.available_times = sorted(set(c.available_times), reverse=True)
        else:
            c.available_times = []

        errors = [(k[len('dataset.'):], v) for k, v in errors.items()]
        fill = c.dataset.as_dict()
        if errors:
            fill.update(request.params)
        return templating.render('editor/core.html', form_errors=dict(errors),
                                 form_fill=fill)
Exemplo n.º 2
0
 def core_edit(self, dataset, errors={}, format='html'):
     self._get_dataset(dataset)
     require.dataset.update(c.dataset)
     c.currencies = sorted(CURRENCIES.items(), key=lambda (k,v): v)
     c.languages = sorted(LANGUAGES.items(), key=lambda (k,v): v)
     c.territories = sorted(COUNTRIES.items(), key=lambda (k,v): v)
     errors = [(k[len('dataset.'):], v) for k, v in errors.items()]
     fill = c.dataset.as_dict()
     if errors:
         fill.update(request.params)
     return render('editor/core.html', form_errors=dict(errors), 
             form_fill=fill)
Exemplo n.º 3
0
 def core_edit(self, dataset, errors={}, format='html'):
     self._get_dataset(dataset)
     require.dataset.update(c.dataset)
     c.currencies = sorted(CURRENCIES.items(), key=lambda (k,v): v)
     c.languages = sorted(LANGUAGES.items(), key=lambda (k,v): v)
     c.territories = sorted(COUNTRIES.items(), key=lambda (k,v): v)
     errors = [(k[len('dataset.'):], v) for k, v in errors.items()]
     fill = c.dataset.as_dict()
     if errors:
         fill.update(request.params)
     return render('editor/core.html', form_errors=dict(errors), 
             form_fill=fill)
Exemplo n.º 4
0
 def new(self, errors={}):
     require.dataset.create()
     c.key_currencies = sorted([(r, n) for (r, (n, k)) in CURRENCIES.items() if k],
             key=lambda (k, v): v)
     c.all_currencies = sorted([(r, n) for (r, (n, k)) in CURRENCIES.items() if not k],
             key=lambda (k, v): v)
     c.languages = sorted(LANGUAGES.items(), key=lambda (k, v): v)
     c.territories = sorted(COUNTRIES.items(), key=lambda (k, v): v)
     errors = [(k[len('dataset.'):], v) for k, v in errors.items()]
     c.have_error = bool(errors)
     c.dataset_info_style = '' if errors else 'display: none;'
     return render('dataset/new.html', form_errors=dict(errors),
             form_fill=request.params if errors else {'currency': 'USD'})
Exemplo n.º 5
0
 def new(self, errors={}):
     self._disable_cache()
     if not has.dataset.create():
         return render("dataset/new_cta.html")
     require.dataset.create()
     c.key_currencies = sorted([(r, n) for (r, (n, k)) in CURRENCIES.items() if k], key=lambda (k, v): v)
     c.all_currencies = sorted([(r, n) for (r, (n, k)) in CURRENCIES.items() if not k], key=lambda (k, v): v)
     c.languages = sorted(LANGUAGES.items(), key=lambda (k, v): v)
     c.territories = sorted(COUNTRIES.items(), key=lambda (k, v): v)
     c.categories = sorted(CATEGORIES.items(), key=lambda (k, v): v)
     errors = [(k[len("dataset.") :], v) for k, v in errors.items()]
     return render(
         "dataset/new.html", form_errors=dict(errors), form_fill=request.params if errors else {"currency": "USD"}
     )
Exemplo n.º 6
0
 def new(self, errors={}):
     self._disable_cache()
     if not has.dataset.create():
         return templating.render('dataset/new_cta.html')
     require.dataset.create()
     c.key_currencies = sorted(
         [(r, n) for (r, (n, k)) in CURRENCIES.items() if k],
         key=lambda k_v: k_v[1])
     c.all_currencies = sorted(
         [(r, n) for (r, (n, k)) in CURRENCIES.items() if not k],
         key=lambda k_v1: k_v1[1])
     c.languages = sorted(LANGUAGES.items(), key=lambda k_v2: k_v2[1])
     c.territories = sorted(COUNTRIES.items(), key=lambda k_v3: k_v3[1])
     c.categories = sorted(CATEGORIES.items(), key=lambda k_v4: k_v4[1])
     errors = [(k[len('dataset.'):], v) for k, v in errors.items()]
     return templating.render(
         'dataset/new.html', form_errors=dict(errors),
         form_fill=request.params if errors else {'currency': 'USD'})
Exemplo n.º 7
0
    def core_edit(self, dataset, errors={}, format='html'):
        self._get_dataset(dataset)
        require.dataset.update(c.dataset)
        c.key_currencies = sorted([(r, n) for (r, (n, k)) in CURRENCIES.items() if k],
                key=lambda (k, v): v)
        c.all_currencies = sorted([(r, n) for (r, (n, k)) in CURRENCIES.items() if not k],
                key=lambda (k, v): v)
        c.languages = sorted(LANGUAGES.items(), key=lambda (k, v): v)
        c.territories = sorted(COUNTRIES.items(), key=lambda (k, v): v)

        if 'time' in c.dataset:
            c.available_times = [m['year'] for m in c.dataset['time'].members()]
        else:
            c.available_times = []

        errors = [(k[len('dataset.'):], v) for k, v in errors.items()]
        fill = c.dataset.as_dict()
        if errors:
            fill.update(request.params)
        return render('editor/core.html', form_errors=dict(errors),
                form_fill=fill)