Permalink
Browse files

The user_id and comment_id fields should no tbe primary keys.

  • Loading branch information...
jayd3e committed Nov 7, 2011
1 parent 9b39096 commit 6a7736019d38538ac66530306837169912e6fbf3
Showing with 56 additions and 8 deletions.
  1. +56 −8 liquid/models.py
View
@@ -6,17 +6,65 @@ class AclUsersModel(Base):
__tablename__ = 'acl_users'
id = Column(Integer, primary_key=True)
- username = Column(String(50))
- email = Column(String(50))
- issues = relationship(IssuesModel, backref="user")
- comments = relationship(IssueCommentsModel, backref="user")
- voted_comments = association_proxy('users_comments', 'comment')
+ parent_id = Column(Integer, ForeignKey("acl_users.id"))
+ name = Column(String)
+ left = Column(Integer)
+ right = Column(Integer)
+ parent = relationship(AclUsersModel)
+ resources = association_proxy('users_resources', 'comment')
def __init__(self, **fields):
self.__dict__.update(fields)
def __repr__(self):
- return "<Users('%s', '%s', '%s')>" % (self.id,
- self.username,
- self.email)
+ return "<Users('%s', '%s', '%s', '%s', '%s')>" % (self.id,
+ self.parent_id,
+ self.name,
+ self.left,
+ self.right)
+
+class AclUsersResourcesModel(Base):
+ __tablename__ = 'acl_resources'
+
+ user_id = Column(Integer, primary_key=True)
+ resource_id = Column(Integer, ForeignKey("acl_users.id"))
+ view = Column(Integer(1))
+ create = Column(Integer(1))
+ update = Column(Integer(1))
+ delete = Column(Integer(1))
+
+ user = relationship(UsersModel,
+ backref="users_resources")
+ resource = relationship(IssueCommentsModel,
+ backref="users_resources"
+
+ def __init__(self, **fields):
+ self.__dict__.update(fields)
+
+ def __repr__(self):
+ return "<Users('%s', '%s', '%s', '%s', '%s')>" % (self.id,
+ self.parent_id,
+ self.name,
+ self.left,
+ self.right)
+
+class AclResourcesModel(Base):
+ __tablename__ = 'acl_users'
+
+ id = Column(Integer, primary_key=True)
+ parent_id = Column(Integer, ForeignKey("acl_users.id"))
+ name = Column(String)
+ left = Column(Integer)
+ right = Column(Integer)
+ parent = relationship(AclUsersModel)
+
+ def __init__(self, **fields):
+ self.__dict__.update(fields)
+
+ def __repr__(self):
+ return "<Users('%s', '%s', '%s', '%s', '%s')>" % (self.id,
+ self.parent_id,
+ self.name,
+ self.left,
+ self.right)

0 comments on commit 6a77360

Please sign in to comment.