Esempio n. 1
0
 def test_is_manager(self):
     user_ids = [self.user_id_a, self.user_id_b]
     topic_rights = topic_domain.TopicRights(
         self.topic_id, user_ids)
     self.assertTrue(topic_rights.is_manager(self.user_id_a))
     self.assertTrue(topic_rights.is_manager(self.user_id_b))
     self.assertFalse(topic_rights.is_manager('fakeuser'))
Esempio n. 2
0
    def test_to_dict(self):
        user_ids = [self.user_id_a, self.user_id_b]
        topic_rights = topic_domain.TopicRights(self.topic_id, user_ids)
        expected_dict = {
            'topic_id': self.topic_id,
            'manager_names': ['A', 'B']
        }

        self.assertEqual(expected_dict, topic_rights.to_dict())
Esempio n. 3
0
def get_topic_rights_from_model(topic_rights_model):
    """Constructs a TopicRights object from the given topic rights model.

    Args:
        topic_rights_model: TopicRightsModel. Topic rights from the
            datastore.

    Returns:
        TopicRights. The rights object created from the model.
    """

    return topic_domain.TopicRights(topic_rights_model.id,
                                    topic_rights_model.manager_ids)
Esempio n. 4
0
    def setUp(self):
        super(TopicRightsTests, self).setUp()
        self.signup('*****@*****.**', 'A')
        self.signup('*****@*****.**', 'B')
        self.user_id_a = self.get_user_id_from_email('*****@*****.**')
        self.user_id_b = self.get_user_id_from_email('*****@*****.**')
        self.topic_summary_dict = {
            'topic_id': 'topic_id',
            'manager_names': ['A'],
            'topic_is_published': False,
        }

        self.topic_summary = topic_domain.TopicRights('topic_id',
                                                      [self.user_id_a], False)
Esempio n. 5
0
def create_new_topic_rights(topic_id, committer_id):
    """Creates a new topic rights object and saves it to the datastore.

    Args:
        topic_id: str. ID of the topic.
        committer_id: str. ID of the committer.
    """
    topic_rights = topic_domain.TopicRights(topic_id, [])
    commit_cmds = [{'cmd': topic_domain.CMD_CREATE_NEW}]

    topic_models.TopicRightsModel(id=topic_rights.id,
                                  manager_ids=topic_rights.manager_ids).commit(
                                      committer_id, 'Created new topic rights',
                                      commit_cmds)