# HG changeset patch # User Mads Kiilerich # Date 1437605549 -7200 # Node ID 82ea8d67fc622ad1d9b9795a53c78a113aa340a9 # Parent fa8b8df51ad0cc8ee82361ccbe2e892596726af2 validators: cleanup of message wording NotReviewedRevisions was unused and could thus got the big cleanup ... diff -r fa8b8df51ad0 -r 82ea8d67fc62 kallithea/model/user.py --- a/kallithea/model/user.py Thu Jul 23 00:52:29 2015 +0200 +++ b/kallithea/model/user.py Thu Jul 23 00:52:29 2015 +0200 @@ -255,8 +255,8 @@ if user.username == User.DEFAULT_USER: raise DefaultUserException( - _("You can't remove this user since it's" - " crucial for entire application")) + _("You can't remove this user since it is" + " crucial for the entire application")) if user.repositories: repos = [x.repo_name for x in user.repositories] raise UserOwnsReposException( diff -r fa8b8df51ad0 -r 82ea8d67fc62 kallithea/model/validators.py --- a/kallithea/model/validators.py Thu Jul 23 00:52:29 2015 +0200 +++ b/kallithea/model/validators.py Thu Jul 23 00:52:29 2015 +0200 @@ -95,11 +95,11 @@ messages = { 'username_exists': _('Username "%(username)s" already exists'), 'system_invalid_username': - _('Username "%(username)s" is forbidden'), + _('Username "%(username)s" cannot be used'), 'invalid_username': _('Username may only contain alphanumeric characters ' - 'underscores, periods or dashes and must begin with ' - 'alphanumeric character or underscore') + 'underscores, periods or dashes and must begin with an ' + 'alphanumeric character or underscore') } def validate_python(self, value, state): @@ -300,9 +300,9 @@ def ValidAuth(): class _validator(formencode.validators.FancyValidator): messages = { - 'invalid_password': _('invalid password'), - 'invalid_username': _('invalid user name'), - 'disabled_account': _('Your account is disabled') + 'invalid_password': _('Invalid password'), + 'invalid_username': _('Invalid username'), + 'disabled_account': _('Account has been disabled') } def validate_python(self, value, state): @@ -346,7 +346,7 @@ class _validator(formencode.validators.FancyValidator): messages = { 'invalid_repo_name': - _('Repository name %(repo)s is disallowed'), + _('Repository name %(repo)s is not allowed'), 'repository_exists': _('Repository named %(repo)s already exists'), 'repository_in_group_exists': _('Repository "%(repo)s" already ' @@ -468,7 +468,7 @@ messages = { 'clone_uri': _('Invalid repository URL'), 'invalid_clone_uri': _('Invalid repository URL. It must be a ' - 'valid http, https, ssh, svn+http or svn+https URL'), + 'valid http, https, ssh, svn+http or svn+https URL'), } def validate_python(self, value, state): @@ -706,7 +706,7 @@ def UniqSystemEmail(old_data={}): class _validator(formencode.validators.FancyValidator): messages = { - 'email_taken': _('This e-mail address is already taken') + 'email_taken': _('This e-mail address is already in use') } def _to_python(self, value, state): @@ -726,7 +726,7 @@ def ValidSystemEmail(): class _validator(formencode.validators.FancyValidator): messages = { - 'non_existing_email': _('e-mail "%(email)s" does not exist.') + 'non_existing_email': _('E-mail address "%(email)s" not found') } def _to_python(self, value, state): @@ -772,39 +772,6 @@ return _validator -def NotReviewedRevisions(repo_id): - class _validator(formencode.validators.FancyValidator): - messages = { - 'rev_already_reviewed': - _('Revisions %(revs)s are already part of pull request ' - 'or have set status') - } - - def validate_python(self, value, state): - # check revisions if they are not reviewed, or a part of another - # pull request - statuses = ChangesetStatus.query()\ - .filter(ChangesetStatus.revision.in_(value))\ - .filter(ChangesetStatus.repo_id == repo_id)\ - .all() - - errors = [] - for cs in statuses: - if cs.pull_request_id: - errors.append(['pull_req', cs.revision[:12]]) - elif cs.status: - errors.append(['status', cs.revision[:12]]) - - if errors: - revs = ','.join([x[1] for x in errors]) - msg = M(self, 'rev_already_reviewed', state, revs=revs) - raise formencode.Invalid(msg, value, state, - error_dict=dict(revisions=revs) - ) - - return _validator - - def ValidIp(): class _validator(CIDR): messages = dict( diff -r fa8b8df51ad0 -r 82ea8d67fc62 kallithea/tests/functional/test_login.py --- a/kallithea/tests/functional/test_login.py Thu Jul 23 00:52:29 2015 +0200 +++ b/kallithea/tests/functional/test_login.py Thu Jul 23 00:52:29 2015 +0200 @@ -129,8 +129,8 @@ {'username': 'error', 'password': 'test12'}) - response.mustcontain('invalid user name') - response.mustcontain('invalid password') + response.mustcontain('Invalid username') + response.mustcontain('Invalid password') # verify that get arguments are correctly passed along login redirection @@ -187,8 +187,8 @@ {'username': 'error', 'password': 'test12'}) - response.mustcontain('invalid user name') - response.mustcontain('invalid password') + response.mustcontain('Invalid username') + response.mustcontain('Invalid password') for encoded in args_encoded: self.assertIn(encoded, response.form.action) @@ -260,7 +260,7 @@ response.mustcontain('An email address must contain a single @') response.mustcontain('Username may only contain ' 'alphanumeric characters underscores, ' - 'periods or dashes and must begin with ' + 'periods or dashes and must begin with an ' 'alphanumeric character') def test_register_err_case_sensitive(self): diff -r fa8b8df51ad0 -r 82ea8d67fc62 kallithea/tests/functional/test_my_account.py --- a/kallithea/tests/functional/test_my_account.py Thu Jul 23 00:52:29 2015 +0200 +++ b/kallithea/tests/functional/test_my_account.py Thu Jul 23 00:52:29 2015 +0200 @@ -51,7 +51,7 @@ response.mustcontain('No additional emails specified') response = self.app.post(url('my_account_emails'), {'new_email': TEST_USER_REGULAR_EMAIL, '_authentication_token': self.authentication_token()}) - self.checkSessionFlash(response, 'This e-mail address is already taken') + self.checkSessionFlash(response, 'This e-mail address is already in use') def test_my_account_my_emails_add_mising_email_in_form(self): self.log_user() @@ -161,7 +161,7 @@ _authentication_token=self.authentication_token()) ) - response.mustcontain('This e-mail address is already taken') + response.mustcontain('This e-mail address is already in use') def test_my_account_update_err(self): self.log_user(TEST_USER_REGULAR2_LOGIN, TEST_USER_REGULAR2_PASS) diff -r fa8b8df51ad0 -r 82ea8d67fc62 kallithea/tests/other/test_validators.py --- a/kallithea/tests/other/test_validators.py Thu Jul 23 00:52:29 2015 +0200 +++ b/kallithea/tests/other/test_validators.py Thu Jul 23 00:52:29 2015 +0200 @@ -231,30 +231,3 @@ def test_AttrLoginValidator(self): validator = v.AttrLoginValidator() self.assertEqual('DN_attr', validator.to_python('DN_attr')) - - def test_NotReviewedRevisions(self): - user = ChangesetStatusModel()._get_user(TEST_USER_ADMIN_LOGIN) - repo = Repository.get_by_repo_name(HG_REPO) - validator = v.NotReviewedRevisions(repo.repo_id) - rev = '0' * 40 - # add status for a rev, that should throw an error because it is already - # reviewed - new_comment = ChangesetComment() - new_comment.repo = repo - new_comment.author = user - new_comment.text = u'' - Session().add(new_comment) - Session().flush() - new_status = ChangesetStatus() - new_status.author = user - new_status.repo = repo - new_status.status = ChangesetStatus.STATUS_APPROVED - new_status.comment = new_comment - new_status.revision = rev - Session().add(new_status) - Session().commit() - try: - self.assertRaises(formencode.Invalid, validator.to_python, [rev]) - finally: - Session().delete(new_status) - Session().commit()