Esempio n. 1
0
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"])
Esempio n. 2
0
def copy_oid(oid, parent):
	"""Create a copy of <oid> which lives beyond / controls / whatever <parent>."""
	obj=Object.by_oid(oid)
	parent=Object.by_oid(parent)

	request.user.will_add(parent,new_objtyp=obj.type)
	ed = ObjEditor(obj,parent)
	return ed.editor()
Esempio n. 3
0
def editor(obj=None, parent=None):
	form = PermissionForm(request.form, prefix="perm")
	form.for_objtyp.choices = tuple((str(x.id),x.name) for x in ObjType.q.all())
	form.new_objtyp.choices = (('-','–'),) + form.for_objtyp.choices
	form.new_mimetyp.choices = (('-','–'),) + tuple((str(x.id),x.name) for x in MIMEtype.q.all())
	if request.method == 'POST' and form.validate():
		user = Object.by_oid(form.user.data)
		dest = Object.by_oid(form.target.data)
		for_objtyp = int(form.for_objtyp.data)
		new_objtyp = ObjType.get(int(form.new_objtyp.data)) if form.new_objtyp.data != "-" else None
		new_mimetyp = MIMEtype.id.get_by(form.new_mimetyp.data) if form.new_mimetyp.data != "-" else None
		right = int(form.right.data)

		if form.inherit.data == "Yes": inherit = True
		elif form.inherit.data == "No": inherit = False
		elif form.inherit.data == "*": inherit = None
		else: assert False

		if parent:
			obj = Permission.new(user, dest, for_objtyp,new_objtyp=new_objtyp,new_mimetyp=new_mimetyp, right=right, inherit=inherit)
		else:
			obj.owner = user
			obj.parent = dest
			obj.for_objtyp = for_objtyp
			obj.right = right
			obj.inherit = inherit
			obj.new_objtyp = new_objtyp
			obj.new_mimetyp = new_mimetyp

		flash(u"Gespeichert.",True)

		return redirect(url_for("pybble.views.view_oid", oid=dest.oid))

	
	elif request.method == 'GET':
		if obj:
			form.target.data = parent.oid if parent else obj.parent.oid
			form.user.data = obj.owner.oid
			form.for_objtyp.data = str(obj.for_objtyp.id)
			form.new_objtyp.data = str(obj.new_objtyp.id) if obj.new_objtyp else "-"
			form.new_mimetyp.data = str(obj.new_mimetyp.id) if obj.new_mimetyp else "-"
			form.inherit.data = "*" if obj.inherit is None else "Yes" if obj.inherit else "No"
			form.right.data = str(obj.right)
		else:
			form.target.data = parent.oid
			form.user.data = request.user.oid
			form.right.data = str(PERM_NONE)
			form.for_objtyp.data = str(parent.type_id)
			form.new_objtyp.data = "-"
			form.new_mimetyp.data = "-"
			form.inherit.data = "*"

	return render_template('edit/permission.html', parent=parent, obj=obj, form=form, title_trace=["New permission" if parent else "Edit permission"])
Esempio n. 4
0
def edit_oid(oid):
	from .part import ObjEditor
	obj=Object.by_oid(oid)
	if not getattr(obj,"no_check_perm",None):
		request.user.will_write(obj)
	ed = ObjEditor(obj)
	return ed.editor()
Esempio n. 5
0
def editor(obj=None, parent=None):
	form = WantTrackingForm(request.form, prefix="perm")
	if request.method == 'POST' and form.validate():
		user = Object.by_oid(form.user.data)
		dest = Object.by_oid(form.object.data)
		objtyp = None if form.objtyp.data == "-" else int(form.objtyp.data)
		email = bool(form.email.data)
		track_new = bool(form.track_new.data)
		track_mod = bool(form.track_mod.data)
		track_del = bool(form.track_del.data)

		if parent:
			obj = WantTracking.new(user, dest, objtyp)
		else:
			obj.record_change()
			obj.owner = user
			obj.parent = dest
			obj.objtyp = objtyp

		obj.track_new=track_new
		obj.track_mod=track_mod
		obj.track_del=track_del
		obj.email=email

		flash(u"Gespeichert.",True)

		return redirect(url_for("pybble.views.view_oid", oid=(parent or dest).oid))

	elif request.method == 'GET':
		if obj: # bearbeiten / kopieren
			form.object.data = parent.oid if parent else obj.parent.oid
			form.user.data = obj.owner.oid
			form.objtyp.data = str(obj.objtyp)
			form.track_new.data = obj.track_new
			form.track_mod.data = obj.track_mod
			form.track_del.data = obj.track_del
			form.email.data = obj.email
		else:
			form.object.data = parent.oid
			form.user.data = request.user.oid
			form.objtyp.data = "-"
			form.track_new.data = True
			form.track_mod.data = False
			form.track_del.data = False
			form.email.data = False

	return render_template('edit/wanttracking.html', obj=obj, parent=parent or obj.parent, form=form, title_trace=["Beobachten"])
Esempio n. 6
0
def edit_wanttracking(oid=None):
	"""Sub-list below the current object"""
	obj = Object.by_oid(oid)
	if isinstance(obj,WantTracking):
		return editor(obj)
	else:
		# show list of tracks for that object
		return render_template('wanttrackinglist.html', obj=obj, title_trace=["Beobachtungsliste"])
Esempio n. 7
0
def list_templates(oid=None):
	"""List all named templates"""
	obj = Object.by_oid(oid) if oid else current_site
	s = obj
	t = []
	while s:
		t.extend(Template.q.filter_by(target=s).order_by(Template.name))
		s = s.parent
	return render_template('templates.html', templates=t, obj=obj, title_trace=["Templates",current_site.name])
Esempio n. 8
0
def newer(parent, name=None):
	from pybble.core.models.site import App
	form = SiteEditForm(request.form, prefix="site", app=current_site.app.oid, parent=parent.oid if parent else current_site.oid)
	form.app.choices = tuple((o.oid,str(o)) for o in App.q.all())
	form.parent.choices = tuple((o.oid,str(o)) for o in Site.q.all())
	if request.method == 'POST' and form.validate():
		obj = Site.new(form.domain.data, form.name.data, parent=Object.by_oid(form.parent.data), app=Object.by_oid(form.app.data))
		return redirect(url_for("pybble.views.view_oid", oid=obj.oid))
	
	return render_template('edit/site.html', obj=None, form=form, title_trace=["neue Website"])
Esempio n. 9
0
def known_name(form, field):
	site = Object.by_oid(form.site.data)
	m = [ Template.parent_id == site.id, Template.name == field.data ]

	id = getattr(form,"id",None)
	if id:
		m.append(Template.id != id)

	if db.store.find(Template,And(*m)).count():
		raise ValidationError("Diese Vorlage existiert bereits.")
Esempio n. 10
0
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"])
Esempio n. 11
0
def list_templates(oid=None):
    """List all named templates"""
    obj = Object.by_oid(oid) if oid else current_site
    s = obj
    t = []
    while s:
        t.extend(Template.q.filter_by(target=s).order_by(Template.name))
        s = s.parent
    return render_template('templates.html',
                           templates=t,
                           obj=obj,
                           title_trace=["Templates", current_site.name])
Esempio n. 12
0
def view_tree(oid=None):
	if oid is None:
		obj = current_site
	else:
		obj = Object.by_oid(oid)

	request.user.will_admin(obj)
	if obj == current_site:
		title_trace=["Objects"]
	else:
		title_trace=[unicode(obj),"Objects"]

	return render_template('tree.html', obj=obj, title_trace=title_trace)
Esempio n. 13
0
def editor(obj, name=None, parent=None):
	assert parent is None
	from pybble.core.models.site import App

	import pdb;pdb.set_trace()
	form = SiteEditForm(request.form, obj, prefix="site", app=current_site.app.oid, parent=parent.oid if parent else current_site.oid)
	form.id = obj.id
	form.app.choices = tuple((o.oid,str(o)) for o in App.q.all())
	kids = set(obj.all_sites)
	form.parent.choices = tuple((o.oid,str(o)) for o in Site.q.all() if o not in kids)
	if request.method == 'POST' and form.validate():
		obj.name = form.name.data
		obj.domain = form.domain.data
		obj.app = Object.by_oid(form.app.data)
		obj.parent = Object.by_oid(form.parent.data)
		return redirect(url_for("pybble.views.view_oid", oid=obj.oid))
	
	elif request.method == 'GET':
		form.name.data = obj.name
		form.domain.data = obj.domain
		form.app.data = obj.app.oid
		form.parent.data = obj.parent.oid
	return render_template('edit/site.html', obj=obj, form=form, name=form.name.data, title_trace=["globale Einstellungen"])
Esempio n. 14
0
def known_match(form, field):
	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)

	m = [ TemplateMatch.inherit == inherit, TemplateMatch.objtyp == int(form.objtyp.data), TemplateMatch.detail == int(form.detail.data), TemplateMatch.parent_id == dest.id ]
	id = getattr(form,"id",None)
	if id:
		m.append(TemplateMatch.id != id)

	if db.store.find(TemplateMatch, And(*m)).count():
		raise ValidationError("Diese Vorlage existiert dort bereits.")
Esempio n. 15
0
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"])
Esempio n. 16
0
def new_oid(oid, objtyp=None, name=None):
	obj=Object.by_oid(oid)
	if objtyp is None:
		objtyp = obj.type
	else:
		try: objtyp = int(objtyp)
		except ValueError: pass
		objtyp = ObjType.get(objtyp)
	request.user.will_add(obj,new_objtyp=objtyp)

	ed = ObjEditor(objtyp,obj)
	args = {}
	if name is not None: args["name"]=name
	args["parent"]=obj
	return ed.editor(**args)
Esempio n. 17
0
def delete_oid(oid):
 	obj=Object.by_oid(oid)
 	request.user.will_delete(obj)
 
	form = DeleteForm(request.form, prefix='delete')
	if request.method == 'POST' and form.validate():
		Delete.new(obj, comment=form.comment.data)

		flash(u"%s (%s) has been deleted" % (unicode(obj),obj.oid), True)
		if form.next.data:
			return redirect(form.next.data)
		elif obj.parent:
			return redirect(url_for("pybble.views.view_oid", oid=obj.parent.oid))
		else:
			return redirect(url_for("pybble.views.mainpage"))

	return render_template('delete.html', form=form, title_trace=["Delete"], obj=obj)
Esempio n. 18
0
def known_match(form, field):
    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)

    m = [
        TemplateMatch.inherit == inherit,
        TemplateMatch.objtyp == int(form.objtyp.data),
        TemplateMatch.detail == int(form.detail.data),
        TemplateMatch.parent_id == dest.id
    ]
    id = getattr(form, "id", None)
    if id:
        m.append(TemplateMatch.id != id)

    if db.store.find(TemplateMatch, And(*m)).count():
        raise ValidationError("Diese Vorlage existiert dort bereits.")
Esempio n. 19
0
def download(request,oid,name=None):
	obj = Object.by_oid(oid)
	r = Response(obj.content, mimetype=obj.mimetype)
	if name:
		n = obj.name
		if obj.mime.ext:
			n += "."+obj.mime.ext
		assert n == name

	if parse_etags(request.environ.get('HTTP_IF_NONE_MATCH')).contains(obj.hash):
		r = Response("", mimetype=obj.mimetype)
		r.status_code = 304
		remove_entity_headers(r.headers)
	else:
		r = Response(obj.content, mimetype=obj.mimetype)

	r.set_etag(obj.hash)
	r.headers['Cache-Control']='public'
	r.headers['Expiry']=http_date(datetime.utcnow()+timedelta(999))
	r.headers['Last-Modified']=http_date(obj.timestamp)
	return r
Esempio n. 20
0
def download(request, oid, name=None):
    obj = Object.by_oid(oid)
    r = Response(obj.content, mimetype=obj.mimetype)
    if name:
        n = obj.name
        if obj.mime.ext:
            n += "." + obj.mime.ext
        assert n == name

    if parse_etags(request.environ.get('HTTP_IF_NONE_MATCH')).contains(
            obj.hash):
        r = Response("", mimetype=obj.mimetype)
        r.status_code = 304
        remove_entity_headers(r.headers)
    else:
        r = Response(obj.content, mimetype=obj.mimetype)

    r.set_etag(obj.hash)
    r.headers['Cache-Control'] = 'public'
    r.headers['Expiry'] = http_date(datetime.utcnow() + timedelta(999))
    r.headers['Last-Modified'] = http_date(obj.timestamp)
    return r
Esempio n. 21
0
def view_oid(oid, **args):
	obj = Object.by_oid(oid)
	request.user.will_read(obj)

	if "details" not in args:
		## The purpose of this code is to get any comments added since the
		## last visit on this page. Does not work well, and comments are
		## not yet ported anyway.
		#dv = [ Comment.superparent_id == obj.id ]
		#try:
		#	bc = Breadcrumb.q.get_by(parent=obj, owner=request.user)
		#except NoData:
		#	pass
		#else:
		#	if bc.last_visited:
		#		dv.append(Comment.added > bc.last_visited)
		#d = Comment.q.get(*dv)
		#d,a = split_details_aux(obj,d)
		#args["details"] = d
		#args["aux"] = a
		args["details"] = ()
		args["aux"] = ()

	return render_my_template(obj=obj, detail=TM_DETAIL_PAGE, **args);
Esempio n. 22
0
def showpage(oid):
	obj = Object.by_oid(oid)
	request.user.will_read(obj)
	return obj.render_content()
Esempio n. 23
0
 def deserialize(self):
     obj = self.params.getone(self.name)
     if obj in ("", "-"):
         return None
     return Object.by_oid(obj)
Esempio n. 24
0
def show_templates(oid):
    """show list of templates for that object"""
    obj = Object.by_oid(oid)
    return render_template('templatelist.html',
                           obj=obj,
                           title_trace=["Template list", obj.oid])
Esempio n. 25
0
	def deserialize(self):
		obj = self.params.getone(self.name)
		if obj in ("","-"):
			return None
		return Object.by_oid(obj)
Esempio n. 26
0
def show_permission(permission=None):
    p = Object.by_oid(permission)
    return render_template('permissionlist.html',
                           obj=p,
                           title_trace=["Permissions"])
Esempio n. 27
0
def editor(obj=None, parent=None):
    form = PermissionForm(request.form, prefix="perm")
    form.for_objtyp.choices = tuple(
        (str(x.id), x.name) for x in ObjType.q.all())
    form.new_objtyp.choices = (('-', '–'), ) + form.for_objtyp.choices
    form.new_mimetyp.choices = (('-', '–'), ) + tuple(
        (str(x.id), x.name) for x in MIMEtype.q.all())
    if request.method == 'POST' and form.validate():
        user = Object.by_oid(form.user.data)
        dest = Object.by_oid(form.target.data)
        for_objtyp = int(form.for_objtyp.data)
        new_objtyp = ObjType.get(int(
            form.new_objtyp.data)) if form.new_objtyp.data != "-" else None
        new_mimetyp = MIMEtype.id.get_by(
            form.new_mimetyp.data) if form.new_mimetyp.data != "-" else None
        right = int(form.right.data)

        if form.inherit.data == "Yes": inherit = True
        elif form.inherit.data == "No": inherit = False
        elif form.inherit.data == "*": inherit = None
        else: assert False

        if parent:
            obj = Permission.new(user,
                                 dest,
                                 for_objtyp,
                                 new_objtyp=new_objtyp,
                                 new_mimetyp=new_mimetyp,
                                 right=right,
                                 inherit=inherit)
        else:
            obj.owner = user
            obj.parent = dest
            obj.for_objtyp = for_objtyp
            obj.right = right
            obj.inherit = inherit
            obj.new_objtyp = new_objtyp
            obj.new_mimetyp = new_mimetyp

        flash(u"Gespeichert.", True)

        return redirect(url_for("pybble.views.view_oid", oid=dest.oid))

    elif request.method == 'GET':
        if obj:
            form.target.data = parent.oid if parent else obj.parent.oid
            form.user.data = obj.owner.oid
            form.for_objtyp.data = str(obj.for_objtyp.id)
            form.new_objtyp.data = str(
                obj.new_objtyp.id) if obj.new_objtyp else "-"
            form.new_mimetyp.data = str(
                obj.new_mimetyp.id) if obj.new_mimetyp else "-"
            form.inherit.data = "*" if obj.inherit is None else "Yes" if obj.inherit else "No"
            form.right.data = str(obj.right)
        else:
            form.target.data = parent.oid
            form.user.data = request.user.oid
            form.right.data = str(PERM_NONE)
            form.for_objtyp.data = str(parent.type_id)
            form.new_objtyp.data = "-"
            form.new_mimetyp.data = "-"
            form.inherit.data = "*"

    return render_template(
        'edit/permission.html',
        parent=parent,
        obj=obj,
        form=form,
        title_trace=["New permission" if parent else "Edit permission"])
Esempio n. 28
0
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"])
Esempio n. 29
0
def confirmed(oid):
    obj = Object.by_oid(oid)
    if isinstance(obj, Verifier):
        return obj.confirmed()
    raise NotFound()
Esempio n. 30
0
def do_confirm(oid):
    if request.method == 'POST':
        obj = Object.by_oid(oid)
        if isinstance(obj, Verifier) and request.user.can_admin(obj.parent):
            return obj.entered()
    raise NotFound()
Esempio n. 31
0
def view_oid_exp(oid, details):
	obj = Object.by_oid(oid)
	d,a = split_details_aux(obj,details)
	logger.debug("D A",obj,details,d,a)
	return view_oid(oid, details=d, aux=a)
Esempio n. 32
0
def view_snippet2(oid, objtyp,k):
	obj = Object.by_oid(oid)
	objtyp = ObjType.get(objtyp)
	
	sub=list(obj.get_refs(objtyp,k))
	return render_template("snippet2.html", cls=objtyp, obj=obj, sub=sub, k=k, count=len(sub), _root=current_site)
Esempio n. 33
0
def view_snippet(oid,k=None):
	"""Return a list of fields in this object, and references to it"""
	obj = Object.by_oid(oid)
	return render_template("snippet1.html", obj=obj, key=k, sub=list(obj.count_refs()), _root=current_site)
Esempio n. 34
0
def show_templates(oid):
	"""show list of templates for that object"""
	obj = Object.by_oid(oid)
	return render_template('templatelist.html', obj=obj, title_trace=["Template list",obj.oid])
Esempio n. 35
0
def showpage(oid):
    obj = Object.by_oid(oid)
    request.user.will_read(obj)
    return obj.render_content()
Esempio n. 36
0
def do_confirm(oid):
    if request.method == "POST":
        obj = Object.by_oid(oid)
        if isinstance(obj, Verifier) and request.user.can_admin(obj.parent):
            return obj.entered()
    raise NotFound()
Esempio n. 37
0
def show_permission(permission=None):
	p = Object.by_oid(permission)
	return render_template('permissionlist.html', obj=p, title_trace=["Permissions"])
Esempio n. 38
0
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"])
Esempio n. 39
0
def detail_oid(oid):
	obj = Object.by_oid(oid)
	request.user.will_read(obj)
	title_trace=[unicode(obj),"Info"]
	return render_template("detail.html", obj=obj, title_trace=title_trace, _root=current_site)
Esempio n. 40
0
def confirmed(oid):
    obj = Object.by_oid(oid)
    if isinstance(obj, Verifier):
        return obj.confirmed()
    raise NotFound()