예제 #1
0
 def check_HasGroupMembership(self):
     self.test_stmt("HasGroupMembership()")
     g = HasGroupMembership()
     staff = UserGroup()
     staff.set_group_id('staff')
     admin = UserGroup()
     admin.set_group_id('admin')
     other = UserGroup()
     other.set_group_id('other')
     
     self.test_exc("g.is_member_of_group('staff')", TypeError)
     self.test_exc("g.add_to_group('staff')", TypeError)
     self.test_exc("g.remove_from_group('staff')", TypeError)
     
     
     self.test_stmt("g.add_to_group(staff)")
     self.test_true("g.is_member_of_group(staff)")
     self.test_true("staff in g.group_list()")
     
     self.test_stmt("g.add_to_group(admin)")
     self.test_true("g.is_member_of_group(admin)")
     self.test_true("admin in g.group_list()")
     
     self.test_false("g.is_member_of_group(other)")
     self.test_stmt("g.remove_from_group(staff)")
     self.test_false("g.is_member_of_group(staff)")
     self.test_stmt("g.remove_from_all_groups()")
     self.test_false("g.is_member_of_group(admin)")
     self.test_exc("g.remove_from_group([other, staff])", TypeError)  # can't remove list
     
     g.remove_from_all_groups()
     self.test_stmt("g.add_to_group([staff, admin])")
     self.test_true("g.is_member_of_group(staff)")
     self.test_true("g.is_member_of_group(admin)")
     self.test_false("g.is_member_of_group(other)")
예제 #2
0
파일: group.py 프로젝트: mrmaple/open_qon
    def __init__(self, user_id, name, owner):
        HasUserID.__init__(self)
        HasGroupMembership.__init__(self)
        Sponsored.__init__(self, self._min_sponsors)
        HasMembership.__init__(self)
        HasAccessPolicy.__init__(self)
        Watchable.__init__(self)
        qon.tags.HasTags.__init__(self)
        self.user_id = user_id
        self.name = name
        self.description = ''
        self.date = datetime.utcnow()
        self.__karma_score = 0
        self.__deferrals = qon.defer.DeferralList()
        
        # set owner, so other modules like Wiki, Blog, etc., will have it
        self.add_owner(owner)

        self.wiki = qon.wiki.Wiki(self)
        self.blog = qon.blog.Blog(self)
        self.file_db = FileDB(self)
        self.polls = PollContainer(self)
        self.trackers = PersistentList()

        # track the number of PMs sent to members of this group
        self.total_group_pms = 0