def test_approval_terms(self): r = self.client.get(reverse('latest_terms'), follow=True) self.assertEqual(r.status_code, 200) self.assertContains(r, _(astakos_messages.NO_APPROVAL_TERMS)) r = self.client.post(reverse('latest_terms'), follow=True) self.assertEqual(r.status_code, 200) self.assertContains(r, _(astakos_messages.NO_APPROVAL_TERMS)) # add terms f = open('terms', 'w+') f.write('This are some terms') f.close() terms = ApprovalTerms(location='terms') terms.save() self.user = get_local_user('*****@*****.**', has_signed_terms=False, date_signed_terms=None) self.assertTrue(not self.user.signed_terms) self.assertTrue(self.user.date_signed_terms is None) self.user_client = get_user_client(self.user.username) r = self.client.get(reverse('latest_terms')) self.assertEqual(r.status_code, 200) self.assertTemplateUsed(r, 'im/approval_terms.html') # assert there is no form self.assertNotContains(r, 'I agree with the terms') r = self.client.post(reverse('latest_terms'), follow=False) self.assertEqual(r.status_code, 302) # assert redirect to login self.assertTrue('Location' in r) self.assertTrue(r['Location'].find(reverse('login')) != -1) r = self.user_client.get(reverse('latest_terms'), follow=True) self.assertEqual(r.status_code, 200) self.assertTemplateUsed(r, 'im/approval_terms.html') # assert there is form self.assertContains(r, 'I agree with the terms') r = self.user_client.post(reverse('latest_terms'), follow=True) self.assertEqual(r.status_code, 200) self.assertFormError(r, 'approval_terms_form', 'has_signed_terms', _(astakos_messages.SIGN_TERMS)) r = self.user_client.post(reverse('latest_terms'), {'has_signed_terms': True}, follow=True) self.assertEqual(r.status_code, 200) user = AstakosUser.objects.get(username=self.user.username) self.assertTrue(user.signed_terms)
def handle(self, *args, **options): if len(args) != 1: raise CommandError("Invalid number of arguments") location = abspath(args[0].decode('utf8')) try: open(location, 'r') except IOError: raise CommandError("Invalid location") terms = ApprovalTerms(location=location) terms.save() msg = "Created term id %d" % (terms.id, ) self.stdout.write(msg + '\n')
def handle(self, *args, **options): if len(args) != 1: raise CommandError("Invalid number of arguments") location = abspath(args[0].decode('utf8')) try: open(location, 'r') except IOError: raise CommandError("Invalid location") terms = ApprovalTerms(location=location) terms.save() msg = "Created term id %d" % (terms.id,) self.stdout.write(msg + '\n')
def handle(self, *args, **options): if len(args) != 1: raise CommandError("Invalid number of arguments") location = abspath(args[0].decode('utf8')) try: open(location, 'r') except IOError: raise CommandError("Invalid location") terms = ApprovalTerms(location=location) terms.save() AstakosUser.objects.select_for_update().\ filter(has_signed_terms=True).\ update(has_signed_terms=False, date_signed_terms=None) msg = "Created term id %d" % (terms.id,) self.stdout.write(msg + '\n')
def handle(self, *args, **options): if len(args) != 1: raise CommandError("Invalid number of arguments") location = abspath(args[0].decode('utf8')) try: open(location, 'r') except IOError: raise CommandError("Invalid location") terms = ApprovalTerms(location=location) terms.save() AstakosUser.objects.select_for_update().\ filter(has_signed_terms=True).\ update(has_signed_terms=False, date_signed_terms=None) msg = "Created term id %d" % (terms.id, ) self.stdout.write(msg + '\n')