Пример #1
0
    def delete(self, id):
        firewall = Firewalls.first(id=id)
        msg = "The firewall could not be deleted."
        if firewall:
            if Firewalls.delete(firewall):
                msg = "Firewall deleted."

        cherrypy.session['flash'] = msg

        raise cherrypy.HTTPRedirect('/firewalls')
Пример #2
0
    def add(self, **post):
        firewall = Firewalls.new(data="", name="")
        if post:
            fields = ['data', 'name']
            data = self._get_data('firewall', fields, post)
            self._set_data(firewall, data)

            if Firewalls.add(firewall):
                cherrypy.session['flash'] = "Firewall successfully added"
                raise cherrypy.HTTPRedirect("/firewalls/index")
            cherrypy.session['flash'] = "The firewall data contains errors."

        firewalls = Firewalls.all()
        return self.render("/firewalls/add.html", crumbs=self.crumbs, firewall=firewall)
Пример #3
0
 def view(self, id):
     firewall = Firewalls.first(id=id)
     if not firewall:
         cherrypy.session['flash'] = '404 Firewall Not Found'
         raise cherrypy.HTTPRedirect('/firewalls/index')
     env = dict(
         firewall=firewall,
     )
     return self.render("/firewalls/view.html", crumbs=self.crumbs, **env)
Пример #4
0
    def edit(self, id, **post):

        firewall = Firewalls.first(id=id)
        if not firewall:
            raise cherrypy.HTTPRedirect('/firewalls')

        if post:
            fields = ['data', 'name']
            data = self._get_data('firewall', fields, post)
            firewall.update(data, fields)
            raise cherrypy.HTTPRedirect('/firewalls/view/%s' % id)

        env = dict(
            firewall=firewall,
        )
        return self.render("/firewalls/edit.html", crumbs=self.crumbs, **env)
Пример #5
0
Файл: api.py Проект: masom/Puck
 def GET(self):
     firewalls = Firewalls.all()
     return [f.to_dict() for f in firewalls]
Пример #6
0
 def index(self):
     env = dict(
         firewalls=Firewalls.all()
     )
     return self.render("/firewalls/index.html", crumbs=self.crumbs[:-1], **env)