def setup(self): self.u1 = UserFactory.create() self.g1 = GroupFactory.create() self.u1.groups.add(self.g1) # Permission handler self.perm_handler = PermissionHandler() # Set up a top-level category self.top_level_cat = create_category_forum() # Set up some forums self.forum_1 = create_forum(parent=self.top_level_cat) self.forum_2 = create_forum(parent=self.top_level_cat) self.forum_3 = create_link_forum(parent=self.top_level_cat) # Set up a top-level forum link self.top_level_link = create_link_forum() # Set up some topics self.forum_1_topic = create_topic(forum=self.forum_1, poster=self.u1) self.forum_3_topic = create_topic(forum=self.forum_3, poster=self.u1) self.forum_3_topic_2 = create_topic( forum=self.forum_3, poster=self.u1, status=Topic.TOPIC_LOCKED) # Set up some posts self.post_1 = PostFactory.create(topic=self.forum_1_topic, poster=self.u1) self.post_2 = PostFactory.create(topic=self.forum_3_topic, poster=self.u1) # Assign some permissions assign_perm('can_see_forum', self.u1, self.top_level_cat) assign_perm('can_see_forum', self.u1, self.forum_1) assign_perm('can_read_forum', self.g1, self.forum_3)
def setup(self): self.u1 = UserFactory.create() # Set up top-level forums: a category, a default forum and a link forum self.top_level_cat = create_category_forum() self.top_level_forum = create_forum() self.top_level_link = create_link_forum()
def setup(self): # Create a basic user self.user = UserFactory.create() # Permission handler self.perm_handler = PermissionHandler() # Set up a top-level forum self.cat = create_category_forum() self.top_level_forum = create_forum() self.other_forum = create_forum() self.link = create_link_forum() # Set up a topic and some posts self.topic = create_topic(forum=self.top_level_forum, poster=self.user) self.first_post = PostFactory.create(topic=self.topic, poster=self.user) self.post = PostFactory.create(topic=self.topic, poster=self.user) # Mark the forum as read ForumReadTrackFactory.create(forum=self.top_level_forum, user=self.user) # Assign some permissions assign_perm('can_read_forum', self.user, self.top_level_forum) assign_perm('can_reply_to_topics', self.user, self.top_level_forum) assign_perm('can_edit_own_posts', self.user, self.top_level_forum) assign_perm('can_delete_own_posts', self.user, self.top_level_forum) assign_perm('can_lock_topics', self.user, self.top_level_forum)
def setup(self): # Permission handler self.perm_handler = PermissionHandler() # Set up a top-level forum and a link forum self.top_level_forum = create_forum() self.top_level_link = create_link_forum(link_redirects=True) # Assign some permissions assign_perm('can_read_forum', self.user, self.top_level_forum) assign_perm('can_read_forum', self.user, self.top_level_link)
def test_can_not_be_associated_with_a_forum_link_or_a_forum_category(self): # Setup top_level_cat = create_category_forum() top_level_link = create_link_forum() # Run & check with pytest.raises(ValidationError): new_topic = build_topic(forum=top_level_cat, poster=self.u1) new_topic.full_clean() with pytest.raises(ValidationError): new_topic = build_topic(forum=top_level_link, poster=self.u1) new_topic.full_clean()
def setup(self): self.u1 = UserFactory.create() # Set up a top-level category self.top_level_cat = create_category_forum() # Set up some forums self.forum_1 = create_forum(parent=self.top_level_cat) self.forum_2 = create_forum(parent=self.top_level_cat) self.forum_3 = create_link_forum(parent=self.top_level_cat) # Set up a top-level forum link self.top_level_link = create_link_forum() # Set up some topics self.forum_1_topic = create_topic(forum=self.forum_1, poster=self.u1) self.forum_3_topic = create_topic(forum=self.forum_3, poster=self.u1) self.forum_3_topic_2 = create_topic(forum=self.forum_3, poster=self.u1, approved=False) # Set up some posts self.post_1 = PostFactory.create(topic=self.forum_1_topic, poster=self.u1) self.post_2 = PostFactory.create(topic=self.forum_3_topic, poster=self.u1) self.post_3 = PostFactory.create(topic=self.forum_3_topic, poster=self.u1, approved=False)
def setup(self): # Set up the following forum tree: # # top_level_cat # forum_1 # forum_2 # forum_2_child_1 # forum_2_child_2 # forum_2_child_2_1 # forum_2_child_2_2 # top_level_forum_1 # top_level_forum_2 # sub_cat # sub_sub_forum # top_level_forum_3 # forum_3 # forum_3_child_1 # forum_3_child_1_1 # deep_forum # last_forum # self.top_level_cat = create_category_forum() self.forum_1 = create_forum(parent=self.top_level_cat) self.forum_2 = create_forum(parent=self.top_level_cat) self.forum_2_child_1 = create_link_forum(parent=self.forum_2) self.forum_2_child_2 = create_forum(parent=self.forum_2) self.forum_2_child_2_1 = create_forum(parent=self.forum_2_child_2) self.forum_2_child_2_2 = create_forum(parent=self.forum_2_child_2) self.top_level_forum_1 = create_forum() self.top_level_forum_2 = create_forum() self.sub_cat = create_category_forum(parent=self.top_level_forum_2) self.sub_sub_forum = create_forum(parent=self.sub_cat) self.top_level_forum_3 = create_forum() self.forum_3 = create_forum(parent=self.top_level_forum_3) self.forum_3_child_1 = create_forum(parent=self.forum_3) self.forum_3_child_1_1 = create_forum(parent=self.forum_3_child_1) self.deep_forum = create_forum(parent=self.forum_3_child_1_1) self.last_forum = create_forum()
def setup(self): self.u1 = UserFactory.create() self.u2 = UserFactory.create() self.top_level_cat_1 = create_category_forum() self.top_level_cat_2 = create_category_forum() self.forum_1 = create_forum(parent=self.top_level_cat_1) self.forum_2 = create_forum(parent=self.top_level_cat_1) self.forum_2_child_1 = create_link_forum(parent=self.forum_2) self.forum_2_child_2 = create_forum(parent=self.forum_2) self.forum_3 = create_forum(parent=self.top_level_cat_1) self.forum_4 = create_forum(parent=self.top_level_cat_2) self.topic = create_topic(forum=self.forum_2, poster=self.u1) PostFactory.create(topic=self.topic, poster=self.u1) # Initially u2 read the previously created topic ForumReadTrackFactory.create(forum=self.forum_2, user=self.u2)
def setup(self): self.u1 = UserFactory.create() self.u2 = UserFactory.create() self.g1 = GroupFactory.create() self.u1.groups.add(self.g1) self.u2.groups.add(self.g1) # Permission handler self.perm_handler = PermissionHandler() # Tracking handler self.tracks_handler = TrackingHandler() self.top_level_cat_1 = create_category_forum() self.top_level_cat_2 = create_category_forum() self.forum_1 = create_forum(parent=self.top_level_cat_1) self.forum_2 = create_forum(parent=self.top_level_cat_1) self.forum_2_child_1 = create_link_forum(parent=self.forum_2) self.forum_2_child_2 = create_forum(parent=self.forum_2) self.forum_3 = create_forum(parent=self.top_level_cat_1) self.forum_4 = create_forum(parent=self.top_level_cat_2) self.topic = create_topic(forum=self.forum_2, poster=self.u1) PostFactory.create(topic=self.topic, poster=self.u1) # Initially u2 read the previously created topic ForumReadTrackFactory.create(forum=self.forum_2, user=self.u2) # Assign some permissions assign_perm('can_read_forum', self.g1, self.top_level_cat_1) assign_perm('can_read_forum', self.g1, self.top_level_cat_2) assign_perm('can_read_forum', self.g1, self.forum_1) assign_perm('can_read_forum', self.g1, self.forum_2) assign_perm('can_read_forum', self.g1, self.forum_2_child_2)