コード例 #1
0
ファイル: root.py プロジェクト: jonmasters/equity
    def create(self, **kw):
	"""Create a new drivertype and save it to the database."""
	user = request.environ.get('repoze.who.identity')['user']
	name = kw['name']
	comment = kw['comment']
	owner = User.by_user_name(kw['owner'])
	if comment == "":
		comment = name
	drivertype = DriverType()
	drivertype.name = name
	drivertype.state.creator = user
	drivertype.state.owner = owner
	drivertype.comments.append(Comment(comment=comment))
	DBSession.add(drivertype)
	DBSession.flush()
	redirect("index")
コード例 #2
0
ファイル: root.py プロジェクト: jonmasters/equity
    def default(self, *args):
	admin=False
	if predicates.not_anonymous():
		if predicates.has_permission('admin'):
			admin=True
	drivertype_name = args[0]
	drivertype = DriverType.by_drivertype_name(drivertype_name)
	return dict(drivertype=drivertype,
		    admin=admin)
コード例 #3
0
ファイル: root.py プロジェクト: jonmasters/equity
    def create(self, **kw):
	"""Create a new driver and save it to the database."""
	user = request.environ.get('repoze.who.identity')['user']
	name = kw['name']
	drivertype = DriverType.by_drivertype_name(kw['type'])
	license = License.by_license_name(kw['license'])
	vendor = Vendor.by_vendor_name(kw['vendor'])
	version = kw['version']
	comment = kw['comment']
	owner = User.by_user_name(kw['owner'])
	if comment == "":
		comment = name
	driver = Driver()
	driver.name = name
	driver.drivertype = drivertype
	driver.license = license
	driver.vendor = vendor
	driver.version = version
	driver.state.creator = user
	driver.state.owner = owner
	driver.comments.append(Comment(comment=comment))
	DBSession.add(driver)
	DBSession.flush()
	redirect("index")