def editor(request, obj=None, parent=None): form = GroupForm(request.form, prefix="perm") if request.method == 'POST' and form.validate(): name = form.name.data if parent is None: obj = Group.new(name=name, parent=parent) else: data = obj.data obj.name = name flash(u"Gespeichert.", True) return redirect(url_for("pybble.views.view_oid", oid=obj.oid)) elif request.method == 'GET': if obj: form.name.data = obj.name else: form.name.data = "" return render_template( 'edit/group.html', parent=parent, obj=obj, form=form, title_trace=["New Group" if parent else "Edit Group"])
def editor(request, obj=None, parent=None): form = MemberForm(request.form, prefix="perm") if request.method == 'POST' and form.validate(): user = Object.by_oid(form.user.data) group = Object.by_oid(form.group.data) excluded = bool(form.excluded.data) if parent: obj = Member.new(user, group) else: data = obj.data obj.owner = user obj.parent = group obj.excluded = excluded obj.record_change(data) flash(u"Gespeichert.",True) return redirect(url_for("pybble.views.view_oid", oid=user.oid)) elif request.method == 'GET': if obj: form.group.data = parent.oid if parent else obj.parent.oid form.user.data = obj.owner.oid form.excluded.data = obj.excluded else: form.user.data = request.user.oid form.group.data = parent.oid form.excluded.data = False return render_template('edit/member.html', parent=parent, obj=obj, form=form, title_trace=["New Member" if parent else "Edit Member"])
def editor(request, obj, parent=None): form = NamedTemplateForm(request.form, prefix="template") form.id = obj.id if request.method == 'POST' and form.validate(): if parent: obj = Template.new(form.name.data, form.page.data.replace("\r",""), parent=Object.by_oid(form.site.data)) obj.name = form.name.data else: obj.record_change() obj.parent = Object.by_oid(form.site.data) obj.name = form.name.data obj.data = form.page.data.replace("\r","") flash(u"Template '%s' gespeichert." % (form.name.data,), True) return redirect(url_for("pybble.admin.list_templates", oid=obj.parent.oid)) elif request.method == 'GET': form.site.data = parent.oid if parent else obj.parent.oid form.name.data = obj.name if obj else "" form.page.data = obj.data if obj else "" return render_template('edit/template.html', obj=obj, form=form, parent=parent, title_trace=[obj.name,"Template-Editor"])
def editor(request, obj=None, parent=None): form = GroupForm(request.form, prefix="perm") if request.method == 'POST' and form.validate(): name = form.name.data if parent is None: obj = Group.new(name=name, parent=parent) else: data = obj.data obj.name = name flash(u"Gespeichert.",True) return redirect(url_for("pybble.views.view_oid", oid=obj.oid)) elif request.method == 'GET': if obj: form.name.data = obj.name else: form.name.data = "" return render_template('edit/group.html', parent=parent, obj=obj, form=form, title_trace=["New Group" if parent else "Edit Group"])
def editor(request, obj=None, parent=None): form = MemberForm(request.form, prefix="perm") if request.method == 'POST' and form.validate(): user = Object.by_oid(form.user.data) group = Object.by_oid(form.group.data) excluded = bool(form.excluded.data) if parent: obj = Member.new(user, group) else: data = obj.data obj.owner = user obj.parent = group obj.excluded = excluded obj.record_change(data) flash(u"Gespeichert.", True) return redirect(url_for("pybble.views.view_oid", oid=user.oid)) elif request.method == 'GET': if obj: form.group.data = parent.oid if parent else obj.parent.oid form.user.data = obj.owner.oid form.excluded.data = obj.excluded else: form.user.data = request.user.oid form.group.data = parent.oid form.excluded.data = False return render_template( 'edit/member.html', parent=parent, obj=obj, form=form, title_trace=["New Member" if parent else "Edit Member"])
def editor(request, obj=None, parent=None): form = TemplateMatchForm(request.form, prefix="template") if not parent: form.id = obj.id if request.method == 'POST' and form.validate(): if form.inherit.data == "Yes": inherit = True elif form.inherit.data == "No": inherit = False elif form.inherit.data == "*": inherit = None else: assert False dest = Object.by_oid(form.oid.data) if parent: obj = TemplateMatch.new(parent,int(form.objtyp.data),int(form.detail.data),form.page.data.replace("\r","")) else: obj.record_change() obj.data = form.page.data.replace("\r","") obj.objtyp = int(form.objtyp.data) obj.detail = int(form.detail.data) obj.inherit = inherit db.store.flush() flash(u"Gespeichert.",True) # Now filter other templates to look for overlaps m = [ TemplateMatch.objtyp == obj.objtyp, TemplateMatch.detail == obj.detail, TemplateMatch.obj_id == obj.id ] if obj.inherit is None: m.append(TemplateMatch.inherit != None) else: m.append(TemplateMatch.inherit == None) m = db.store.find(TemplateMatch,And(*m)) if obj.inherit is None: if m.count(): flash(u"Vorherige Assoziation(en) entfernt.") for mm in m: db.store.remove(mm) else: if m.count(): flash(u"Bestehende Assoziation eingeschränkt.") for mm in m: mm.inherit = not obj.inherit return redirect(url_for("pybble.views.view_oid", oid=dest.oid)) elif request.method == 'GET': if obj: form.page.data = obj.data form.objtyp.data = str(obj.objtyp) form.detail.data = str(obj.detail) form.inherit.data = "*" if obj.inherit is None else "Yes" if obj.inherit else "No" else: form.detail.data = str(TM_DETAIL_PAGE) form.objtyp.data = str(parent.objtyp) form.inherit.data = "*" if parent: form.oid.data = parent.oid else: form.oid.data = obj.parent.oid return render_template('edit/templatematch.html', obj=obj, parent=parent, form=form, title_trace=["Template-Editor"])
def editor(request, obj=None, parent=None): form = TemplateMatchForm(request.form, prefix="template") if not parent: form.id = obj.id if request.method == 'POST' and form.validate(): if form.inherit.data == "Yes": inherit = True elif form.inherit.data == "No": inherit = False elif form.inherit.data == "*": inherit = None else: assert False dest = Object.by_oid(form.oid.data) if parent: obj = TemplateMatch.new(parent, int(form.objtyp.data), int(form.detail.data), form.page.data.replace("\r", "")) else: obj.record_change() obj.data = form.page.data.replace("\r", "") obj.objtyp = int(form.objtyp.data) obj.detail = int(form.detail.data) obj.inherit = inherit db.store.flush() flash(u"Gespeichert.", True) # Now filter other templates to look for overlaps m = [ TemplateMatch.objtyp == obj.objtyp, TemplateMatch.detail == obj.detail, TemplateMatch.obj_id == obj.id ] if obj.inherit is None: m.append(TemplateMatch.inherit != None) else: m.append(TemplateMatch.inherit == None) m = db.store.find(TemplateMatch, And(*m)) if obj.inherit is None: if m.count(): flash(u"Vorherige Assoziation(en) entfernt.") for mm in m: db.store.remove(mm) else: if m.count(): flash(u"Bestehende Assoziation eingeschränkt.") for mm in m: mm.inherit = not obj.inherit return redirect(url_for("pybble.views.view_oid", oid=dest.oid)) elif request.method == 'GET': if obj: form.page.data = obj.data form.objtyp.data = str(obj.objtyp) form.detail.data = str(obj.detail) form.inherit.data = "*" if obj.inherit is None else "Yes" if obj.inherit else "No" else: form.detail.data = str(TM_DETAIL_PAGE) form.objtyp.data = str(parent.objtyp) form.inherit.data = "*" if parent: form.oid.data = parent.oid else: form.oid.data = obj.parent.oid return render_template('edit/templatematch.html', obj=obj, parent=parent, form=form, title_trace=["Template-Editor"])