Ejemplo n.º 1
0
 def setUp(self):
     try:
         moderated_content = ModeratedContent.objects.get(content_type = ContentType.objects.get_for_model(User))
     except ObjectDoesNotExist:
         moderated_content = ModeratedContent(content_type = ContentType.objects.get_for_model(User),
                                              accept_threshold = 100,
                                              reject_threshold = 100)
         moderated_content.save()
         
     try:
         test_user = User.objects.get(username = '******')
     except ObjectDoesNotExist:
         test_user = test_user = User.objects.create_user(username = '******',
                                                          email = '*****@*****.**',
                                                          password = None)
     self.test_user = test_user
     self.user = test_user
     self.moderated_content = moderated_content
     self.moderated_contents = ModeratedContent.objects.all()
     
     try:
         accept_flag = ContentFlag.objects.get(name = ContentFlag.ACCEPT_FLAG)
     except ObjectDoesNotExist:
         accept_flag = ContentFlag(name = ContentFlag.ACCEPT_FLAG,
                                   active = True,
                                   description = '')
         accept_flag.save()
     self.accept_flag = accept_flag
 
     try:
         hidden_flag = ContentFlag.objects.get(name = ContentFlag.HIDDEN_FLAG)
     except ObjectDoesNotExist:
         hidden_flag = ContentFlag(name = ContentFlag.HIDDEN_FLAG,
                                   active = True,
                                   description = '')
         hidden_flag.save() 
     self.hidden_flag = hidden_flag
Ejemplo n.º 2
0
 def setUp(self):
     try:
         test_user = User.objects.get(username = '******')
     except ObjectDoesNotExist:
         test_user = test_user = User.objects.create_user(username = '******',
                                                          email = '*****@*****.**',
                                                          password = None)
     self.test_user = test_user
     self.user = test_user
     
     try:
         moderation_flag = ContentFlag.objects.get(name = ContentFlag.MODERATE_FLAG)
     except ObjectDoesNotExist:
         moderation_flag = ContentFlag(name = ContentFlag.MODERATE_FLAG,
                                       active = True,
                                       description = '')
         moderation_flag.save()
     self.moderation_flag = moderation_flag
     
     try:
         accept_flag = ContentFlag.objects.get(name = ContentFlag.ACCEPT_FLAG)
     except ObjectDoesNotExist:
         accept_flag = ContentFlag(name = ContentFlag.ACCEPT_FLAG,
                                   active = True,
                                   description = '')
         accept_flag.save()
     self.accept_flag = accept_flag
     
     try:
         reject_flag = ContentFlag.objects.get(name = ContentFlag.REJECT_FLAG)
     except ObjectDoesNotExist:
         reject_flag = ContentFlag(name = ContentFlag.REJECT_FLAG,
                                   active = True,
                                   description = '')
         reject_flag.save()
     self.reject_flag = reject_flag
     
     self.flags = [moderation_flag, accept_flag, reject_flag]
     
     try:
         moderation_flag_set = ContentFlagSet.objects.get(name = 'moderation')
     except ObjectDoesNotExist:
         moderation_flag_set = ContentFlagSet(name = 'moderation',
                                              exclusive = True,
                                              active = True)
         moderation_flag_set.save()
     self.moderation_flag_set = moderation_flag_set
     
     for flag in self.flags:
         flag_member_instance = ContentFlagSetMember(set = moderation_flag_set,
                                                     flag = flag)
         flag_member_instance.save()
     
     try:
         test_flag = ContentFlag.objects.get(name = 'test')
     except ObjectDoesNotExist:
         test_flag = ContentFlag(name = 'test',
                                 active = True,
                                 description = '')
         test_flag.save()
     self.test_flag = test_flag