def create(self, **kw): """Create a new devicetype 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 devicetype = DeviceType() devicetype.name = name devicetype.state.creator = user devicetype.state.owner = owner devicetype.comments.append(Comment(comment=comment)) DBSession.add(devicetype) DBSession.flush() redirect("index")
def default(self, *args): admin=False if predicates.not_anonymous(): if predicates.has_permission('admin'): admin=True devicetype_name = args[0] devicetype = DeviceType.by_devicetype_name(devicetype_name) return dict(devicetype=devicetype, admin=admin)