Exemplo n.º 1
0
 def test_user_role_examiner_does_not_need_to_be_anonymized_assignment_semi_anonymous(
         self):
     testassignment = mommy.make_recipe(
         'devilry.apps.core.assignment_activeperiod_start',
         anonymizationmode=core_models.Assignment.
         ANONYMIZATIONMODE_SEMI_ANONYMOUS)
     testgroup = mommy.make('core.AssignmentGroup',
                            parentnode=testassignment)
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     test_examineruser = mommy.make(settings.AUTH_USER_MODEL,
                                    fullname='Test Examiner',
                                    shortname='*****@*****.**')
     mommy.make('core.RelatedExaminer',
                user=test_examineruser,
                period=testassignment.parentnode,
                automatic_anonymous_id='Some anonymous name')
     group_user_lookup = GroupUserLookup(
         assignment=testassignment,
         group=testgroup,
         requestuser=testuser,
         requestuser_devilryrole=self.viewrole)
     self.assertEqual(
         group_user_lookup.get_long_name_from_user(user=test_examineruser,
                                                   user_role='examiner'),
         'Test Examiner ([email protected])')
Exemplo n.º 2
0
 def test_user_role_student_user_is_student_and_examiner_is_not_anonymized_to_themselves(
         self):
     testassignment = mommy.make_recipe(
         'devilry.apps.core.assignment_activeperiod_start',
         anonymizationmode=core_models.Assignment.
         ANONYMIZATIONMODE_SEMI_ANONYMOUS)
     testgroup = mommy.make('core.AssignmentGroup',
                            parentnode=testassignment)
     testuser = mommy.make(settings.AUTH_USER_MODEL,
                           fullname='Test Student',
                           shortname='*****@*****.**')
     mommy.make(
         'core.Candidate',
         assignment_group=testgroup,
         relatedstudent__user=testuser,
         relatedstudent__automatic_anonymous_id='Some anonymous name',
         relatedstudent__period=testassignment.parentnode)
     group_user_lookup = GroupUserLookup(
         assignment=testassignment,
         group=testgroup,
         requestuser=testuser,
         requestuser_devilryrole=self.viewrole)
     self.assertEqual(
         group_user_lookup.get_long_name_from_user(user=testuser,
                                                   user_role='student'),
         'Test Student ([email protected])')
Exemplo n.º 3
0
 def test_user_role_student_get_anonymized_longname_for_assignment_uses_custom_candidate_ids(
         self):
     testassignment = mommy.make_recipe(
         'devilry.apps.core.assignment_activeperiod_start',
         anonymizationmode=core_models.Assignment.
         ANONYMIZATIONMODE_SEMI_ANONYMOUS,
         uses_custom_candidate_ids=True)
     testgroup = mommy.make('core.AssignmentGroup',
                            parentnode=testassignment)
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     test_studentuser = mommy.make(settings.AUTH_USER_MODEL,
                                   fullname='Test Student',
                                   shortname='*****@*****.**')
     mommy.make('core.Candidate',
                assignment_group=testgroup,
                relatedstudent__user=test_studentuser,
                candidate_id='1234',
                relatedstudent__period=testassignment.parentnode)
     group_user_lookup = GroupUserLookup(
         assignment=testassignment,
         group=testgroup,
         requestuser=testuser,
         requestuser_devilryrole=self.viewrole)
     self.assertEqual(
         group_user_lookup.get_long_name_from_user(user=test_studentuser,
                                                   user_role='student'),
         '1234')
 def test_user_role_examiner_get_unanonymized_longname(self):
     testassignment = mommy.make_recipe('devilry.apps.core.assignment_activeperiod_start')
     testgroup = mommy.make('core.AssignmentGroup', parentnode=testassignment)
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     test_examineruser = mommy.make(settings.AUTH_USER_MODEL, fullname='Test Examiner', shortname='*****@*****.**')
     mommy.make('core.RelatedExaminer', user=test_examineruser, period=testassignment.parentnode)
     group_user_lookup = GroupUserLookup(assignment=testassignment, group=testgroup,
                                         requestuser=testuser, requestuser_devilryrole=self.viewrole)
     self.assertEqual(group_user_lookup.get_long_name_from_user(user=test_examineruser, user_role='examiner'),
                      'Test Examiner ([email protected])')
 def test_user_role_student_get_anonymized_longname_no_candidate_or_relatedstudent(self):
     testassignment = mommy.make_recipe('devilry.apps.core.assignment_activeperiod_start',
                                        anonymizationmode=core_models.Assignment.ANONYMIZATIONMODE_SEMI_ANONYMOUS)
     testgroup = mommy.make('core.AssignmentGroup', parentnode=testassignment)
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     test_studentuser = mommy.make(settings.AUTH_USER_MODEL, fullname='Test Student', shortname='*****@*****.**')
     group_user_lookup = GroupUserLookup(assignment=testassignment, group=testgroup,
                                         requestuser=testuser, requestuser_devilryrole=self.viewrole)
     self.assertEqual(group_user_lookup.get_long_name_from_user(user=test_studentuser, user_role='student'),
                      'User removed from semester')
 def test_user_role_admin_get_unanonymized_longname_assignment_semi_anonymized(self):
     testassignment = mommy.make_recipe('devilry.apps.core.assignment_activeperiod_start',
                                        anonymizationmode=core_models.Assignment.ANONYMIZATIONMODE_SEMI_ANONYMOUS)
     testgroup = mommy.make('core.AssignmentGroup', parentnode=testassignment)
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     test_adminuser = mommy.make(settings.AUTH_USER_MODEL, fullname='Test Admin',
                                 shortname='*****@*****.**')
     group_user_lookup = GroupUserLookup(assignment=testassignment, group=testgroup,
                                         requestuser=testuser, requestuser_devilryrole=self.viewrole)
     self.assertEqual(group_user_lookup.get_long_name_from_user(user=test_adminuser, user_role='admin'),
                      'Test Admin ([email protected])')
 def test_user_role_examiner_get_anonymized_longname(self):
     testassignment = mommy.make_recipe('devilry.apps.core.assignment_activeperiod_start',
                                        anonymizationmode=core_models.Assignment.ANONYMIZATIONMODE_SEMI_ANONYMOUS)
     testgroup = mommy.make('core.AssignmentGroup', parentnode=testassignment)
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     test_examineruser = mommy.make(settings.AUTH_USER_MODEL, fullname='Test Examiner', shortname='*****@*****.**')
     mommy.make('core.RelatedExaminer', user=test_examineruser, period=testassignment.parentnode,
                automatic_anonymous_id='Some anonymous name')
     group_user_lookup = GroupUserLookup(assignment=testassignment, group=testgroup,
                                         requestuser=testuser, requestuser_devilryrole=self.viewrole)
     self.assertEqual(group_user_lookup.get_long_name_from_user(user=test_examineruser, user_role='examiner'),
                      'Some anonymous name')
 def test_user_role_student_get_unanonymized_shortname(self):
     testassignment = mommy.make_recipe('devilry.apps.core.assignment_activeperiod_start')
     testgroup = mommy.make('core.AssignmentGroup', parentnode=testassignment)
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     test_studentuser = mommy.make(settings.AUTH_USER_MODEL, fullname='Test Student', shortname='*****@*****.**')
     mommy.make('core.Candidate', assignment_group=testgroup, relatedstudent__user=test_studentuser,
                relatedstudent__period=testassignment.parentnode)
     group_user_lookup = GroupUserLookup(assignment=testassignment, group=testgroup,
                                         requestuser=testuser, requestuser_devilryrole=self.viewrole)
     self.assertEqual(
         group_user_lookup.get_plaintext_short_name_from_user(user=test_studentuser, user_role='student'),
         '*****@*****.**')
 def test_user_role_student_does_not_need_to_be_anonymized_for_other_students_assignment_semi_anonymous(self):
     testassignment = mommy.make_recipe('devilry.apps.core.assignment_activeperiod_start',
                                        anonymizationmode=core_models.Assignment.ANONYMIZATIONMODE_SEMI_ANONYMOUS)
     testgroup = mommy.make('core.AssignmentGroup', parentnode=testassignment)
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     test_studentuser = mommy.make(settings.AUTH_USER_MODEL, fullname='Test Student',
                                   shortname='*****@*****.**')
     mommy.make('core.Candidate', assignment_group=testgroup, relatedstudent__user=test_studentuser)
     group_user_lookup = GroupUserLookup(assignment=testassignment, group=testgroup,
                                         requestuser=testuser, requestuser_devilryrole=self.viewrole)
     self.assertEqual(group_user_lookup.get_long_name_from_user(user=test_studentuser, user_role='student'),
                      'Test Student ([email protected])')
Exemplo n.º 10
0
 def test_user_role_admin_get_unanonymized_longname(self):
     testassignment = mommy.make_recipe(
         'devilry.apps.core.assignment_activeperiod_start')
     testgroup = mommy.make('core.AssignmentGroup',
                            parentnode=testassignment)
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     test_adminuser = mommy.make(settings.AUTH_USER_MODEL,
                                 fullname='Test Admin',
                                 shortname='*****@*****.**')
     group_user_lookup = GroupUserLookup(
         assignment=testassignment,
         group=testgroup,
         requestuser=testuser,
         requestuser_devilryrole=self.viewrole)
     self.assertEqual(
         group_user_lookup.get_long_name_from_user(user=test_adminuser,
                                                   user_role='admin'),
         'Test Admin ([email protected])')
Exemplo n.º 11
0
 def test_user_role_examiner_get_unanonymized_shortname(self):
     testassignment = mommy.make_recipe(
         'devilry.apps.core.assignment_activeperiod_start')
     testgroup = mommy.make('core.AssignmentGroup',
                            parentnode=testassignment)
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     test_examineruser = mommy.make(settings.AUTH_USER_MODEL,
                                    fullname='Test Examiner',
                                    shortname='*****@*****.**')
     mommy.make('core.RelatedExaminer',
                user=test_examineruser,
                period=testassignment.parentnode)
     group_user_lookup = GroupUserLookup(
         assignment=testassignment,
         group=testgroup,
         requestuser=testuser,
         requestuser_devilryrole=self.viewrole)
     self.assertEqual(
         group_user_lookup.get_plaintext_short_name_from_user(
             user=test_examineruser, user_role='examiner'),
         '*****@*****.**')
Exemplo n.º 12
0
 def test_user_role_examiner_get_anonymized_longname_relatedexaminer_does_not_exist(
         self):
     testassignment = mommy.make_recipe(
         'devilry.apps.core.assignment_activeperiod_start',
         anonymizationmode=core_models.Assignment.
         ANONYMIZATIONMODE_SEMI_ANONYMOUS)
     testgroup = mommy.make('core.AssignmentGroup',
                            parentnode=testassignment)
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     test_examineruser = mommy.make(settings.AUTH_USER_MODEL,
                                    fullname='Test Examiner',
                                    shortname='*****@*****.**')
     group_user_lookup = GroupUserLookup(
         assignment=testassignment,
         group=testgroup,
         requestuser=testuser,
         requestuser_devilryrole=self.viewrole)
     self.assertEqual(
         group_user_lookup.get_long_name_from_user(user=test_examineruser,
                                                   user_role='examiner'),
         'User removed from semester')
 def __init__(self, feedbackset, group, assignment, requestuser,
              devilryrole):
     self.feedbackset = feedbackset
     self.assignment = assignment
     self.requestuser = requestuser
     self.devilryrole = devilryrole
     self.group = group
     self.group_user_lookup = GroupUserLookup(
         group=group,
         assignment=assignment,
         requestuser=requestuser,
         requestuser_devilryrole=devilryrole)
     super(FeedbackSetTimelineListBuilderList, self).__init__()
Exemplo n.º 14
0
 def test_user_role_student_get_unanonymized_longname(self):
     testassignment = mommy.make_recipe(
         'devilry.apps.core.assignment_activeperiod_start')
     testgroup = mommy.make('core.AssignmentGroup',
                            parentnode=testassignment)
     testuser = mommy.make(settings.AUTH_USER_MODEL)
     test_studentuser = mommy.make(settings.AUTH_USER_MODEL,
                                   fullname='Test Student',
                                   shortname='*****@*****.**')
     mommy.make('core.Candidate',
                assignment_group=testgroup,
                relatedstudent__user=test_studentuser,
                relatedstudent__period=testassignment.parentnode)
     group_user_lookup = GroupUserLookup(
         assignment=testassignment,
         group=testgroup,
         requestuser=testuser,
         requestuser_devilryrole=self.viewrole)
     self.assertEqual(
         group_user_lookup.get_long_name_from_user(user=test_studentuser,
                                                   user_role='student'),
         'Test Student ([email protected])')
Exemplo n.º 15
0
 def get_current_group_comment_renderable(self):
     group = self.request.cradmin_role
     assignment = self.request.cradmin_role.parentnode
     devilry_viewrole = self.request.cradmin_instance.get_devilryrole_for_requestuser(
     )
     group_user_lookup = GroupUserLookup(
         group=group,
         assignment=assignment,
         requestuser=self.request.user,
         requestuser_devilryrole=devilry_viewrole)
     group_comment_value_item_class = self.get_current_group_comment_value_item_class(
     )
     return self.get_frame_renderer_class()(
         inneritem=group_comment_value_item_class(
             value=self.group_comment,
             devilry_viewrole=devilry_viewrole,
             assignment=assignment,
             requestuser=self.request.user,
             group_user_lookup=group_user_lookup))
 def __model_setup(self, anonymizationmode=core_models.Assignment.ANONYMIZATIONMODE_OFF, request_devilryrole='student'):
     self.testassignment = mommy.make_recipe(
         'devilry.apps.core.assignment_activeperiod_start',
         anonymizationmode=anonymizationmode)
     self.testgroup = mommy.make(
         'core.AssignmentGroup',
         parentnode=self.testassignment)
     self.relatedexaminer = mommy.make(
         'core.RelatedExaminer',
         user__fullname='Test User',
         user__shortname='*****@*****.**',
         period=self.testassignment.parentnode,
         automatic_anonymous_id='Anonymous examiner')
     self.comment = mommy.make(
         'devilry_group.GroupComment',
         user=self.relatedexaminer.user,
         user_role='examiner',
         feedback_set__group=self.testgroup)
     self.group_user_lookup = GroupUserLookup(
         group=self.testgroup,
         assignment=self.testassignment,
         requestuser=mommy.make(settings.AUTH_USER_MODEL),
         requestuser_devilryrole=request_devilryrole)