示例#1
0
文件: repos.py 项目: masom/Puck
    def add(self, **post):
        repo = YumRepositories.new(data="", environment="")
        if post:
            fields = ['data', 'environment']
            data = self._get_data('repo', fields, post)
            self._set_data(repo, data)

            if repo.validates() and YumRepositories.add(repo):
                cherrypy.session['flash'] = "Repo successfully added"
                raise cherrypy.HTTPRedirect("/repos/index")
            cherrypy.session['flash'] = "The repository data contains errors."

        # Only list environments not having a repo.
        repos = YumRepositories.all()
        environments = Environments.all()
        envs = [env.code for env in environments]
        repos = [repo.environment for repo in repos]
        available = set(envs) - set(repos)
        return self.render("/repos/add.html", crumbs=self.crumbs, environments=environments, available=available, repo=repo)
示例#2
0
文件: jails.py 项目: masom/Puck
    def add(self, **post):
        jail = Jails.new(id="", url="", name="", ip="", jail_type="", netmask="", environment="")
        if post:
            fields = ['name', 'url', 'ip', 'jail_type', 'netmask', 'environment']
            data = self._get_data('jail', fields, post)
            self._set_data(jail, data)

            if jail.validates() and Jails.add(jail):
                cherrypy.session['flash'] = "Jail successfully added"
                raise cherrypy.HTTPRedirect("/jails")
            cherrypy.session['flash'] = "The jail could not be created."

        env = dict(
                environments=Environments.all(),
                jailTypes=JailTypes.all(),
                jail=jail
        )

        return self.render("jails/add.html", crumbs=self.crumbs, **env)
示例#3
0
文件: jails.py 项目: masom/Puck
    def edit(self, id, **post):
        jail = Jails.first(id=id)
        if not jail:
            cherrpy.session['flash'] = '404 Jail Not Found'
            raise cherrypy.HTTPRedirect('/jails/index')

        if post:
            fields = ['name', 'url', 'ip', 'jail_type', 'netmask', 'environment']
            data = self._get_data('jail', fields, post)
            tmp = Jails.new()
            self._set_data(tmp, data)
            if tmp.validates() and jail.update(data, fields):
                cherrypy.session['flash'] = "Jail successfully updated."
                raise cherrypy.HTTPRedirect("/jails")
            cherrypy.session['flash'] = "The jail could not be updated."

        env = dict(
                environments=Environments.all(),
                jailTypes=JailTypes.all(),
                jail=jail
        )

        return self.render("jails/edit.html", crumbs=self.crumbs, **env)
示例#4
0
文件: api.py 项目: masom/Puck
 def GET(self):
     envs = Environments.all()
     return [e.to_dict() for e in envs]
示例#5
0
文件: repos.py 项目: masom/Puck
 def index(self):
     env = dict(
         repos=YumRepositories.all(),
         environments=Environments.all()
     )
     return self.render("/repos/index.html", crumbs=self.crumbs[:-1], **env)
示例#6
0
 def index(self):
     env = dict(environments=Environments.all())
     return self.render("/environments/index.html", crumbs=self.crumbs[:-1], **env)