Exemplo n.º 1
0
 def import_outline_element(o):
     for f in o:
         if hasattr(f,'xmlUrl'):
             s = Source(f.title,'feed',f.xmlUrl)
             db_session.add(s)
         else:
             import_outline_element(f)
Exemplo n.º 2
0
def add(source_name, item_name, content, url=None, attributes=None):
    if not attributes: attributes = {}
    source = db_session.query(Source).filter(Source.name==source_name).first() or Source(name=source_name, source_type='cmdline', address='/query/_%s' % source_name)
    item = Item(item_name, content, url=url, attributes=attributes)
    db_session.add(source)
    source.items.append(item)
    db_session.commit()
    return item
Exemplo n.º 3
0
def add_source():
    form = SourceForm(request.form)
    if request.method == 'POST' and form.validate():
        s = Source(form.name.data, form.source_type.data, form.address.data)
        db_session.add(s)
        db_session.commit()
        flash('Source "%s" added' % form.name.data)
        return redirect(request.referrer or '/')
    return render_template('add_source.html', form=form)
Exemplo n.º 4
0
def add(source_name, item_name, content, url=None, attributes=None):
    if not attributes: attributes = {}
    source = db_session.query(Source).filter(
        Source.name == source_name).first() or Source(
            name=source_name,
            source_type='cmdline',
            address='/query/_%s' % source_name)
    item = Item(item_name, content, url=url, attributes=attributes)
    db_session.add(source)
    source.items.append(item)
    db_session.commit()
    return item
Exemplo n.º 5
0
def sources():
    form = SourceForm(request.form)
    if request.method == 'POST' and form.validate():
        try:
            s = Source(form.name.data, form.source_type.data, form.address.data)
            db_session.add(s)
            db_session.commit()
        except Exception, e:
            flash('[!] Insertion error: %r' % e)
            db_session.rollback()
            return redirect('/sources')
        flash('Source "%s" added' % form.name.data)
        return redirect(request.referrer or '/')
Exemplo n.º 6
0
def source_modify(s_id=0):
    source=Source.query.get(s_id)
    form=SourceForm(obj=source)
    if request.method == 'POST' and form.validate():
        source.name=form.name.data
        source.source_type=form.source_type.data
        source.address=form.address.data
        db_session.add(source)
        db_session.commit()
        flash('Source "%s" modified' % form.name.data)
        return redirect('/sources')
    return render_template('sources.html'
                          ,form     = form
                          ,sources  = Source.query.all()
                          ,mode     = 'modify'
                          ,menu_path= '/sources' #preserve menu highlight when paging
                          )