from sqlalchemy import UniqueConstraint
from infosystem.common.subsystem import entity
from infosystem.database import db


class Route(entity.Entity, db.Model):

    # TODO(samueldmq): recheck string lengths for below attributes
    # TODO(samueldmq): add an 'active' attribute
    attributes = ['id', 'name', 'url', 'method', 'admin', 'bypass']
    name = db.Column(db.String(20), nullable=False)
    url = db.Column(db.String(80), nullable=False)
    method = db.Column(db.String(10), nullable=False)
    admin = db.Column(db.Boolean(), nullable=False)
    bypass = db.Column(db.Boolean(), nullable=False)
    __table_args__ = (UniqueConstraint('url', 'method', name='route_uk'),)

    def __init__(self, id, name, url, method, admin=False, bypass=False):
        self.id = id
        self.name = name
        self.url = url
        self.method = method
        self.method = method
        self.bypass = bypass
        self.admin = admin

@@ -322,16 +322,19 @@
 thod', '
+sys
 admin', 
@@ -343,16 +343,16 @@
 ypass'%5D%0A
-
     name
@@ -504,16 +504,19 @@
 se)%0A    
+sys
 admin = 
@@ -730,16 +730,19 @@
 method, 
+sys
 admin=Fa
@@ -930,22 +930,25 @@
    self.
+sys
 admin = 
 admin%0A
@@ -941,14 +941,17 @@
 admin = 
+sys
 admin%0A

Change admin attribute to sysadmin