Ejemplo n.º 1
0
def feed_rss():
    q = db.session.query(Dataset)
    if not auth.account.is_admin():
        q = q.filter_by(private=False)
    feed_items = q.order_by(Dataset.created_at.desc()).limit(20)
    items = []
    for feed_item in feed_items:
        items.append({
            'title': feed_item.label,
            'pubdate': feed_item.updated_at,
            'link': url_for('dataset.view', dataset=feed_item.name),
            'description': feed_item.description,
            'author_name': ', '.join([person.fullname for person in
                                      feed_item.managers if
                                      person.fullname]),
        })
    desc = _('Recently created datasets on %(site_title)s',
             site_title=current_app.config.get('SITE_TITLE'))
    feed = Rss201rev2Feed(_('Recently Created Datasets'),
                          url_for('home.index'), desc)
    for item in items:
        feed.add_item(**item)
    sio = StringIO()
    feed.write(sio, 'utf-8')
    return Response(sio.getvalue(), mimetype='application/xml')
Ejemplo n.º 2
0
def source_to_dict(dataset, source):
    data = dict(source.meta.items())
    data.pop('http_headers', None)
    data['data_url'] = url_for('sources_api.serve', dataset=dataset.name,
                               name=source.name)
    data['runs_url'] = url_for('runs_api.index', dataset=dataset.name,
                               source=source.name)
    data['api_url'] = url_for('sources_api.view', dataset=dataset.name,
                              name=source.name)
    return data
Ejemplo n.º 3
0
def source_to_dict(dataset, source):
    data = dict(source.meta.items())
    data.pop('http_headers', None)
    data['data_url'] = url_for('sources_api.serve',
                               dataset=dataset.name,
                               name=source.name)
    data['runs_url'] = url_for('runs_api.index',
                               dataset=dataset.name,
                               source=source.name)
    data['api_url'] = url_for('sources_api.view',
                              dataset=dataset.name,
                              name=source.name)
    return data
Ejemplo n.º 4
0
def feed_rss():
    q = db.session.query(Dataset)
    if not auth.account.is_admin():
        q = q.filter_by(private=False)
    feed_items = q.order_by(Dataset.created_at.desc()).limit(20)
    items = []
    for feed_item in feed_items:
        items.append({
            'title':
            feed_item.label,
            'pubdate':
            feed_item.updated_at,
            'link':
            '/datasets/%s' % feed_item.name,
            'description':
            feed_item.description,
            'author_name':
            ', '.join([
                person.fullname for person in feed_item.managers
                if person.fullname
            ]),
        })
    desc = gettext('Recently created datasets on %(site_title)s',
                   site_title=current_app.config.get('SITE_TITLE'))
    feed = Rss201rev2Feed(gettext('Recently Created Datasets'),
                          url_for('home.index'), desc)
    for item in items:
        feed.add_item(**item)
    sio = StringIO()
    feed.write(sio, 'utf-8')
    return Response(sio.getvalue(), mimetype='application/xml')
Ejemplo n.º 5
0
def get_reset_body(account):
    reset_link = url_for('account_api.do_reset',
                         email=account.email,
                         token=account.token)
    return _(RESET_MESSAGE,
             reset_link=reset_link,
             site_title=current_app.config.get('SITE_TITLE'))
Ejemplo n.º 6
0
 def to_dict(self):
     return {
         'id': self.id,
         'api_url': url_for('runs_api.view', dataset=self.dataset.name,
                            id=self.id),
         'operation': self.operation,
         'status': self.status,
         'source': self.source,
         'time_start': self.time_start,
         'time_end': self.time_end
     }
Ejemplo n.º 7
0
def template_context_processor():
    locale = get_locale()
    data = {
        'current_language': locale.language,
        'url_for': url_for,
        'reserved_terms': RESERVED_TERMS,
        'site_url': url_for('home.index').rstrip('/'),
        'number_symbols_group': locale.number_symbols.get('group'),
        'number_symbols_decimal': locale.number_symbols.get('decimal'),
        'site_title': current_app.config.get('SITE_TITLE')
    }
    return data
Ejemplo n.º 8
0
 def to_dict(self):
     return {
         'label': self.label,
         'name': self.name,
         'description': self.description,
         'currency': self.currency,
         'category': self.category,
         'private': self.private,
         'created_at': self.created_at,
         'updated_at': self.updated_at,
         'languages': list(self.languages),
         'territories': list(self.territories),
         'api_url': url_for('datasets_api.view', name=self.name)
     }
Ejemplo n.º 9
0
 def to_dict(self):
     return {
         'label': self.label,
         'name': self.name,
         'description': self.description,
         'currency': self.currency,
         'category': self.category,
         'private': self.private,
         'created_at': self.created_at,
         'updated_at': self.updated_at,
         'languages': list(self.languages),
         'territories': list(self.territories),
         'has_model': self.has_model,
         'api_url': url_for('datasets_api.view', name=self.name)
     }
Ejemplo n.º 10
0
def index(*a, **kw):
    from flask.ext.babel import get_locale
    from spendb.views.context import etag_cache_keygen
    etag_cache_keygen(RESERVED_TERMS)
    locale = get_locale()
    data = {
        'current_language': locale.language,
        'url_for': url_for,
        'debug': current_app.config['DEBUG'],
        'asset_link': asset_link,
        'reserved_terms': RESERVED_TERMS,
        'site_url': url_for('home.index').rstrip('/'),
        'site_title': current_app.config.get('SITE_TITLE')
    }
    return render_template('layout.html', **data)
Ejemplo n.º 11
0
def index(*a, **kw):
    from flask.ext.babel import get_locale
    from spendb.views.context import etag_cache_keygen
    etag_cache_keygen(RESERVED_TERMS)
    locale = get_locale()
    data = {
        'current_language': locale.language,
        'url_for': url_for,
        'debug': current_app.config['DEBUG'],
        'asset_link': asset_link,
        'reserved_terms': RESERVED_TERMS,
        'site_url': url_for('home.index').rstrip('/'),
        'site_title': current_app.config.get('SITE_TITLE')
    }
    return render_template('layout.html', **data)
Ejemplo n.º 12
0
def index(*a, **kw):
    from flask.ext.babel import get_locale
    from spendb.views.context import etag_cache_keygen
    etag_cache_keygen(RESERVED_TERMS)
    locale = get_locale()
    data = {
        'current_language': locale.language,
        'url_for': url_for,
        'reserved_terms': RESERVED_TERMS,
        'templates': angular_templates(current_app),
        'site_url': url_for('home.index').rstrip('/'),
        'number_symbols_group': locale.number_symbols.get('group'),
        'number_symbols_decimal': locale.number_symbols.get('decimal'),
        'site_title': current_app.config.get('SITE_TITLE')
    }
    return render_template('layout.html', **data)
Ejemplo n.º 13
0
def index(*a, **kw):
    from flask.ext.babel import get_locale
    from spendb.views.context import etag_cache_keygen
    etag_cache_keygen(RESERVED_TERMS)
    locale = get_locale()
    data = {
        'current_language': locale.language,
        'url_for': url_for,
        'reserved_terms': RESERVED_TERMS,
        'templates': angular_templates(current_app),
        'site_url': url_for('home.index').rstrip('/'),
        'number_symbols_group': locale.number_symbols.get('group'),
        'number_symbols_decimal': locale.number_symbols.get('decimal'),
        'site_title': current_app.config.get('SITE_TITLE')
    }
    return render_template('layout.html', **data)
Ejemplo n.º 14
0
 def to_dict(self):
     """ Return the dictionary representation of the account. """
     account_dict = {
         'name': self.name,
         'fullname': self.fullname,
         'display_name': self.display_name,
         'email': self.email,
         'admin': self.admin,
         'gravatar': self.gravatar,
         'twitter_handle': self.twitter_handle,
         'api_url': url_for('account_api.view', account=self.name)
     }
     if not self.public_email:
         account_dict.pop('email')
     if not self.public_twitter:
         account_dict.pop('twitter_handle')
     return account_dict
Ejemplo n.º 15
0
def template_context_processor():
    locale = get_locale()
    data = {
        'DEBUG': current_app.config.get('DEBUG'),
        'current_language': locale.language,
        'current_locale': get_locale(),
        'reserved_terms': RESERVED_TERMS,
        'url_for': url_for,
        'site_url': url_for('home.index').rstrip('/'),
        'number_symbols_group': locale.number_symbols.get('group'),
        'number_symbols_decimal': locale.number_symbols.get('decimal'),
        'site_title': current_app.config.get('SITE_TITLE'),
        'languages': languages(),
        'logged_in': auth.account.logged_in(),
        'current_user': current_user,
        'can': auth
    }
    return data
Ejemplo n.º 16
0
def get_reset_body(account):
    reset_link = url_for('account_api.do_reset',
                         email=account.email,
                         token=account.token)
    return _(RESET_MESSAGE, reset_link=reset_link,
             site_title=current_app.config.get('SITE_TITLE'))