コード例 #1
0
ファイル: admin.py プロジェクト: pajju/eventframe
def website_edit(website):
    g.website = website
    form = WebsiteForm(obj=website)
    themes = [(t.identifier, t.name) for t in get_themes_list()]
    form.theme.choices = themes
    if form.validate_on_submit():
        form.populate_obj(website)
        db.session.commit()
        return render_redirect(url_for('website', website=website.name), code=303)
    return render_form(form=form, title=u"Edit website", submit=u"Save",
        cancel_url=url_for('website', website=website.name), ajax=True)
コード例 #2
0
ファイル: admin.py プロジェクト: pajju/eventframe
def website_new():
    form = WebsiteForm()
    themes = [(t.identifier, t.name) for t in get_themes_list()]
    form.theme.choices = themes
    if form.validate_on_submit():
        website = Website()
        form.populate_obj(website)
        db.session.add(website)
        db.session.commit()
        return render_redirect(url_for('website', website=website.name), code=303)
    return render_form(form=form, title=u"New website", submit=u"Create",
        cancel_url=url_for('index'), ajax=True)
コード例 #3
0
ファイル: admin.py プロジェクト: pajju/eventframe
def folder_new(website):
    g.website = website
    form = FolderForm()
    themes = [('', 'Website Default')] + [(t.identifier, t.name) for t in get_themes_list()]
    form.theme.choices = themes
    if form.validate_on_submit():
        folder = Folder(website=website)
        form.populate_obj(folder)
        db.session.add(folder)
        db.session.commit()
        return render_redirect(url_for('folder', website=website.name, folder=folder.name), code=303)
    return render_form(form=form, title=u"New folder", submit=u"Create",
        cancel_url=url_for('website', website=website.name), ajax=True)
コード例 #4
0
ファイル: admin.py プロジェクト: pajju/eventframe
def folder_edit(website, folder):
    g.website = website
    g.folder = folder
    form = FolderForm(obj=folder)
    if request.method == 'GET':
        form.theme.data = folder._theme
    themes = [('', 'Website Default')] + [(t.identifier, t.name) for t in get_themes_list()]
    form.theme.choices = themes
    if form.validate_on_submit():
        form.populate_obj(folder)
        db.session.commit()
        return render_redirect(url_for('folder', website=website.name, folder=folder.name), code=303)
    return render_form(form=form, title=u"Edit folder", submit=u"Save",
        cancel_url=url_for('folder', website=website.name, folder=folder.name), ajax=True)
コード例 #5
0
ファイル: participant_list.py プロジェクト: pajju/eventframe
    def sync(self):
        self.action = 'sync'
        self.form = ConfirmForm()

        if self.form.validate_on_submit():
            return Response(stream_template('stream.html',
                stream=stream_with_context(self._sync()),
                tabs=self.edit_tabs(),
                node=self.node,
                title="Syncing participants..."))

        return render_form(form=self.form, title="Sync participant list", submit=u"Sync", tabs=self.edit_tabs(),
        cancel_url=url_for('folder', website=self.node.folder.website.name, folder=self.node.folder.name),
        node=self.node)
コード例 #6
0
ファイル: content.py プロジェクト: pajju/eventframe
def node_unpublish(website, folder, node):
    g.website = website
    g.folder = folder
    if not (hasattr(node, 'unpublish') and callable(node.unpublish)):
        abort(404)
    form = ConfirmForm(obj=node)
    if form.validate_on_submit():
        node.unpublish()
        db.session.commit()
        flash(u"Unpublished '%s'" % node.title, 'success')
        return render_redirect(url_for('folder', website=folder.website.name, folder=folder.name), code=303)
    return render_form(form=form, title="Unpublish node", submit=u"Unpublish",
        cancel_url=url_for('folder', website=folder.website.name, folder=folder.name),
        node=node)
コード例 #7
0
ファイル: admin.py プロジェクト: pajju/eventframe
def folder_import(website, folder):
    g.website = website
    g.folder = folder
    import_count = 0
    create_count = 0
    form = ImportForm()
    internal_imports = []
    if form.validate_on_submit():
        data = json.loads(request.files['import_file'].getvalue(), use_decimal=True)
        for inode in data['nodes']:
            mtime = parse_isoformat(inode.get('revision_updated_at', inode['updated_at']))
            node = Node.query.filter_by(folder=folder, uuid=inode['uuid']).first()
            if node is None:
                nreg = node_registry.get(inode['type'])
                if nreg is None:
                    flash("Could not import node of unknown type '%s'" % inode['type'], "error")
                    continue
                node = nreg.model(folder=folder)
                user = User.query.filter_by(userid=inode['userid']).first()
                node.user = user or g.user
                db.session.add(node)
                create_count += 1
            else:
                if form.import_updated.data and mtime <= node.updated_at:
                    continue
            node.import_from(inode)
            internal_imports.append(inode)
            import_count += 1
        db.session.commit()
        # Second pass for internal data of nodes
        for inode in internal_imports:
            node = Node.query.filter_by(folder=folder, uuid=inode['uuid']).first()
            node.import_from_internal(inode)
        db.session.commit()
        flash("%d nodes were imported and %d new nodes were created" % (import_count, create_count), "success")
        return render_redirect(url_for('folder', website=website.name, folder=folder.name), code=303)
    return render_form(form=form, title=u"Import to folder", submit=u"Upload",
        cancel_url=url_for('folder', website=website.name, folder=folder.name))
コード例 #8
0
ファイル: content.py プロジェクト: pajju/eventframe
 def render_form(self):
     return render_form(form=self.form, title=self.title_edit if self.node else self.title_new, submit=u"Save",
         cancel_url=url_for('folder', website=self.website.name, folder=self.folder.name),
         tabs=self.edit_tabs(), node=self.node, ajax=True)