def by_ip_address(cls, ip_addr): """ Returns a box object based on an ip address, supports both ipv4 and ipv6 """ ip = IpAddress.by_address(ip_addr) return ip.box if ip is not None else None
def by_ip_address(cls, ip_addr): ''' Returns a box object based on an ip address, supports both ipv4 and ipv6 ''' ip = IpAddress.by_address(ip_addr) return ip.box if ip is not None else None
def edit_ip(self): """ Add ip addresses to a box (sorta edits the box object) """ try: box = Box.by_uuid(self.get_argument("box_uuid", "")) if box is None: raise ValidationError("Box does not exist") ip_addr = self.get_argument("ip_address", "") if IpAddress.by_address(ip_addr) is None: ip = IpAddress(box_id=box.id, address=ip_addr) if self.get_argument("visable", "").lower() != "true": ip.visable = False box.ip_addresses.append(ip) self.dbsession.add(ip) self.dbsession.add(box) self.dbsession.commit() self.redirect("/admin/view/game_objects#%s" % box.uuid) else: raise ValidationError("IP address is already in use") except ValidationError as error: self.render("admin/view/game_objects.html", errors=[str(error)])
def edit_ip(self): ''' Add ip addresses to a box (sorta edits the box object) ''' errors = [] box = Box.by_uuid(self.get_argument('box_uuid', '')) if box is not None: addr = self.get_argument('ip_address', '') if IpAddress.by_address(addr) is None: try: ip = IpAddress(box_id=box.id, address=addr) box.ip_addresses.append(ip) self.dbsession.add(ip) self.dbsession.add(box) self.dbsession.commit() except Exception as error: errors.append(str(error)) else: errors.append("IP address is already in use") else: errors.append("Box does not exist") self.render("admin/view/game_objects.html", errors=errors)
def edit_ip(self): ''' Add ip addresses to a box (sorta edits the box object) ''' try: box = Box.by_uuid(self.get_argument('box_uuid', '')) if box is None: raise ValidationError("Box does not exist") ip_addr = self.get_argument('ip_address', '') if IpAddress.by_address(ip_addr) is None: ip = IpAddress(box_id=box.id, address=ip_addr) if self.get_argument('visable', '').lower() != 'true': ip.visable = False box.ip_addresses.append(ip) self.dbsession.add(ip) self.dbsession.add(box) self.dbsession.commit() self.redirect("/admin/view/game_objects#%s" % box.uuid) else: raise ValidationError("IP address is already in use") except ValidationError as error: self.render("admin/view/game_objects.html", errors=[str(error), ])
def edit_ip(self): ''' Add ip addresses to a box (sorta edits the box object) ''' try: box = Box.by_uuid(self.get_argument('box_uuid', '')) if box is None: raise ValidationError("Box does not exist") ip_addr = self.get_argument('ip_address', '') if IpAddress.by_address(ip_addr) is None: ip = IpAddress(box_id=box.id, address=ip_addr) if self.get_argument('visable', '').lower() != 'true': ip.visable = False box.ip_addresses.append(ip) self.dbsession.add(ip) self.dbsession.add(box) self.dbsession.commit() self.redirect('/admin/view/game_objects') else: raise ValidationError("IP address is already in use") except ValidationError as error: self.render("admin/view/game_objects.html", errors=[ str(error), ])