##// END OF EJS Templates
follow Python conventions for boolean values...
Mads Kiilerich -
r3625:260a7a01 beta
parent child Browse files
Show More
@@ -159,7 +159,7 class NotificationsController(BaseContro
159 # if this association to user is not valid, we don't want to show
159 # if this association to user is not valid, we don't want to show
160 # this message
160 # this message
161 if unotification:
161 if unotification:
162 if unotification.read is False:
162 if not unotification.read:
163 unotification.mark_as_read()
163 unotification.mark_as_read()
164 Session().commit()
164 Session().commit()
165 c.notification = no
165 c.notification = no
@@ -348,7 +348,7 class ReposGroupsController(BaseControll
348 .filter(RepoGroup.group_parent_id == c.group.group_id).all()
348 .filter(RepoGroup.group_parent_id == c.group.group_id).all()
349 c.groups = self.scm_model.get_repos_groups(groups)
349 c.groups = self.scm_model.get_repos_groups(groups)
350
350
351 if c.visual.lightweight_dashboard is False:
351 if not c.visual.lightweight_dashboard:
352 c.repos_list = self.scm_model.get_repos(all_repos=gr_filter)
352 c.repos_list = self.scm_model.get_repos(all_repos=gr_filter)
353 ## lightweight version of dashboard
353 ## lightweight version of dashboard
354 else:
354 else:
@@ -416,7 +416,7 class FilesController(BaseRepoController
416
416
417 try:
417 try:
418 dbrepo = RepoModel().get_by_repo_name(repo_name)
418 dbrepo = RepoModel().get_by_repo_name(repo_name)
419 if dbrepo.enable_downloads is False:
419 if not dbrepo.enable_downloads:
420 return _('downloads disabled')
420 return _('downloads disabled')
421
421
422 if c.rhodecode_repo.alias == 'hg':
422 if c.rhodecode_repo.alias == 'hg':
@@ -52,7 +52,7 class HomeController(BaseController):
52 c.groups = self.scm_model.get_repos_groups()
52 c.groups = self.scm_model.get_repos_groups()
53 c.group = None
53 c.group = None
54
54
55 if c.visual.lightweight_dashboard is False:
55 if not c.visual.lightweight_dashboard:
56 c.repos_list = self.scm_model.get_repos()
56 c.repos_list = self.scm_model.get_repos()
57 ## lightweight version of dashboard
57 ## lightweight version of dashboard
58 else:
58 else:
@@ -76,7 +76,7 class LoginController(BaseController):
76 Session().commit()
76 Session().commit()
77
77
78 # If they want to be remembered, update the cookie
78 # If they want to be remembered, update the cookie
79 if c.form_result['remember'] is not False:
79 if c.form_result['remember']:
80 _year = (datetime.datetime.now() +
80 _year = (datetime.datetime.now() +
81 datetime.timedelta(seconds=60 * 60 * 24 * 365))
81 datetime.timedelta(seconds=60 * 60 * 24 * 365))
82 session._set_cookie_expires(_year)
82 session._set_cookie_expires(_year)
@@ -381,7 +381,7 class AuthUser(object):
381
381
382 if not is_user_loaded:
382 if not is_user_loaded:
383 # if we cannot authenticate user try anonymous
383 # if we cannot authenticate user try anonymous
384 if self.anonymous_user.active is True:
384 if self.anonymous_user.active:
385 user_model.fill_data(self, user_id=self.anonymous_user.user_id)
385 user_model.fill_data(self, user_id=self.anonymous_user.user_id)
386 # then we set this user is logged in
386 # then we set this user is logged in
387 self.is_authenticated = True
387 self.is_authenticated = True
@@ -124,7 +124,7 def dbsession(func):
124 ret = func(*fargs, **fkwargs)
124 ret = func(*fargs, **fkwargs)
125 return ret
125 return ret
126 finally:
126 finally:
127 if CELERY_ON and CELERY_EAGER is False:
127 if CELERY_ON and not CELERY_EAGER:
128 meta.Session.remove()
128 meta.Session.remove()
129
129
130 return decorator(__wrapper, func)
130 return decorator(__wrapper, func)
@@ -69,9 +69,9 class DbManage(object):
69 self.init_db()
69 self.init_db()
70 global ask_ok
70 global ask_ok
71
71
72 if self.cli_args.get('force_ask') is True:
72 if self.cli_args.get('force_ask'):
73 ask_ok = lambda *args, **kwargs: True
73 ask_ok = lambda *args, **kwargs: True
74 elif self.cli_args.get('force_ask') is False:
74 elif not self.cli_args.get('force_ask'):
75 ask_ok = lambda *args, **kwargs: False
75 ask_ok = lambda *args, **kwargs: False
76
76
77 def init_db(self):
77 def init_db(self):
@@ -589,7 +589,7 class DbManage(object):
589
589
590 if retries == 0:
590 if retries == 0:
591 sys.exit('max retries reached')
591 sys.exit('max retries reached')
592 if path_ok is False:
592 if not path_ok:
593 retries -= 1
593 retries -= 1
594 return self.config_prompt(test_repo_path, retries)
594 return self.config_prompt(test_repo_path, retries)
595
595
@@ -421,7 +421,7 class DiffProcessor(object):
421
421
422 sorter = lambda info: {'A': 0, 'M': 1, 'D': 2}.get(info['operation'])
422 sorter = lambda info: {'A': 0, 'M': 1, 'D': 2}.get(info['operation'])
423
423
424 if inline_diff is False:
424 if not inline_diff:
425 return diff_container(sorted(_files, key=sorter))
425 return diff_container(sorted(_files, key=sorter))
426
426
427 # highlight inline changes
427 # highlight inline changes
@@ -143,7 +143,7 def log_pull_action(ui, repo, **kwargs):
143 kw.update(ex)
143 kw.update(ex)
144 callback(**kw)
144 callback(**kw)
145
145
146 if ex.make_lock is True:
146 if ex.make_lock:
147 Repository.lock(Repository.get_by_repo_name(ex.repository), user.user_id)
147 Repository.lock(Repository.get_by_repo_name(ex.repository), user.user_id)
148 #msg = 'Made lock on repo `%s`' % repository
148 #msg = 'Made lock on repo `%s`' % repository
149 #sys.stdout.write(msg)
149 #sys.stdout.write(msg)
@@ -202,7 +202,7 def log_push_action(ui, repo, **kwargs):
202 kw.update(ex)
202 kw.update(ex)
203 callback(**kw)
203 callback(**kw)
204
204
205 if ex.make_lock is False:
205 if not ex.make_lock:
206 Repository.unlock(Repository.get_by_repo_name(ex.repository))
206 Repository.unlock(Repository.get_by_repo_name(ex.repository))
207 msg = 'Released lock on repo `%s`\n' % ex.repository
207 msg = 'Released lock on repo `%s`\n' % ex.repository
208 sys.stdout.write(msg)
208 sys.stdout.write(msg)
@@ -126,7 +126,7 class SimpleGit(BaseVCSController):
126 return HTTPInternalServerError()(environ, start_response)
126 return HTTPInternalServerError()(environ, start_response)
127
127
128 # quick check if that dir exists...
128 # quick check if that dir exists...
129 if is_valid_repo(repo_name, self.basepath, 'git') is False:
129 if not is_valid_repo(repo_name, self.basepath, 'git'):
130 return HTTPNotFound()(environ, start_response)
130 return HTTPNotFound()(environ, start_response)
131
131
132 #======================================================================
132 #======================================================================
@@ -143,11 +143,11 class SimpleGit(BaseVCSController):
143 anonymous_perm = self._check_permission(action, anonymous_user,
143 anonymous_perm = self._check_permission(action, anonymous_user,
144 repo_name, ip_addr)
144 repo_name, ip_addr)
145
145
146 if anonymous_perm is not True or anonymous_user.active is False:
146 if not anonymous_perm or not anonymous_user.active:
147 if anonymous_perm is not True:
147 if not anonymous_perm:
148 log.debug('Not enough credentials to access this '
148 log.debug('Not enough credentials to access this '
149 'repository as anonymous user')
149 'repository as anonymous user')
150 if anonymous_user.active is False:
150 if not anonymous_user.active:
151 log.debug('Anonymous access is disabled, running '
151 log.debug('Anonymous access is disabled, running '
152 'authentication')
152 'authentication')
153 #==============================================================
153 #==============================================================
@@ -184,7 +184,7 class SimpleGit(BaseVCSController):
184
184
185 #check permissions for this repository
185 #check permissions for this repository
186 perm = self._check_permission(action, user, repo_name, ip_addr)
186 perm = self._check_permission(action, user, repo_name, ip_addr)
187 if perm is not True:
187 if not perm:
188 return HTTPForbidden()(environ, start_response)
188 return HTTPForbidden()(environ, start_response)
189
189
190 # extras are injected into UI object and later available
190 # extras are injected into UI object and later available
@@ -89,7 +89,7 class SimpleHg(BaseVCSController):
89 return HTTPInternalServerError()(environ, start_response)
89 return HTTPInternalServerError()(environ, start_response)
90
90
91 # quick check if that dir exists...
91 # quick check if that dir exists...
92 if is_valid_repo(repo_name, self.basepath, 'hg') is False:
92 if not is_valid_repo(repo_name, self.basepath, 'hg'):
93 return HTTPNotFound()(environ, start_response)
93 return HTTPNotFound()(environ, start_response)
94
94
95 #======================================================================
95 #======================================================================
@@ -106,11 +106,11 class SimpleHg(BaseVCSController):
106 anonymous_perm = self._check_permission(action, anonymous_user,
106 anonymous_perm = self._check_permission(action, anonymous_user,
107 repo_name, ip_addr)
107 repo_name, ip_addr)
108
108
109 if anonymous_perm is not True or anonymous_user.active is False:
109 if not anonymous_perm or not anonymous_user.active:
110 if anonymous_perm is not True:
110 if not anonymous_perm:
111 log.debug('Not enough credentials to access this '
111 log.debug('Not enough credentials to access this '
112 'repository as anonymous user')
112 'repository as anonymous user')
113 if anonymous_user.active is False:
113 if not anonymous_user.active:
114 log.debug('Anonymous access is disabled, running '
114 log.debug('Anonymous access is disabled, running '
115 'authentication')
115 'authentication')
116 #==============================================================
116 #==============================================================
@@ -147,7 +147,7 class SimpleHg(BaseVCSController):
147
147
148 #check permissions for this repository
148 #check permissions for this repository
149 perm = self._check_permission(action, user, repo_name, ip_addr)
149 perm = self._check_permission(action, user, repo_name, ip_addr)
150 if perm is not True:
150 if not perm:
151 return HTTPForbidden()(environ, start_response)
151 return HTTPForbidden()(environ, start_response)
152
152
153 # extras are injected into mercurial UI object and later available
153 # extras are injected into mercurial UI object and later available
@@ -444,7 +444,7 def properly_encode_header(value, encode
444 try:
444 try:
445 return value.encode("ascii")
445 return value.encode("ascii")
446 except UnicodeEncodeError:
446 except UnicodeEncodeError:
447 if not_email is False and VALUE_IS_EMAIL_ADDRESS(value):
447 if not not_email and VALUE_IS_EMAIL_ADDRESS(value):
448 # this could have an email address, make sure we don't screw it up
448 # this could have an email address, make sure we don't screw it up
449 name, address = parseaddr(value)
449 name, address = parseaddr(value)
450 return '"%s" <%s>' % (
450 return '"%s" <%s>' % (
@@ -1698,7 +1698,7 class CacheInvalidation(Base, BaseModel)
1698 cache_key = cls._get_cache_key(key)
1698 cache_key = cls._get_cache_key(key)
1699 inv = cls._get_or_create_inv_obj(cache_key, repo_name)
1699 inv = cls._get_or_create_inv_obj(cache_key, repo_name)
1700
1700
1701 if inv and inv.cache_active is False:
1701 if inv and not inv.cache_active:
1702 return inv
1702 return inv
1703
1703
1704 @classmethod
1704 @classmethod
@@ -100,7 +100,7 class NotificationModel(BaseModel):
100 body=body, recipients=recipients_objs, type_=type_
100 body=body, recipients=recipients_objs, type_=type_
101 )
101 )
102
102
103 if with_email is False:
103 if not with_email:
104 return notif
104 return notif
105
105
106 #don't send email to person who created this comment
106 #don't send email to person who created this comment
@@ -120,7 +120,7 class PermissionModel(BaseModel):
120 .all():
120 .all():
121
121
122 #don't reset PRIVATE repositories
122 #don't reset PRIVATE repositories
123 if r2p.repository.private is False:
123 if not r2p.repository.private:
124 r2p.permission = _def
124 r2p.permission = _def
125 self.sa.add(r2p)
125 self.sa.add(r2p)
126
126
@@ -132,7 +132,7 class UserModel(BaseModel):
132 new_user.username = username
132 new_user.username = username
133 new_user.admin = admin
133 new_user.admin = admin
134 # set password only if creating an user or password is changed
134 # set password only if creating an user or password is changed
135 if edit is False or user.password != password:
135 if not edit or user.password != password:
136 new_user.password = get_crypt_password(password)
136 new_user.password = get_crypt_password(password)
137 new_user.api_key = generate_api_key(username)
137 new_user.api_key = generate_api_key(username)
138 new_user.email = email
138 new_user.email = email
@@ -102,7 +102,7 class UserGroupModel(BaseModel):
102 assigned_groups = UserGroupRepoToPerm.query()\
102 assigned_groups = UserGroupRepoToPerm.query()\
103 .filter(UserGroupRepoToPerm.users_group == users_group).all()
103 .filter(UserGroupRepoToPerm.users_group == users_group).all()
104
104
105 if assigned_groups and force is False:
105 if assigned_groups and not force:
106 raise UserGroupsAssignedException('RepoGroup assigned to %s' %
106 raise UserGroupsAssignedException('RepoGroup assigned to %s' %
107 assigned_groups)
107 assigned_groups)
108
108
@@ -280,7 +280,7 def ValidAuth():
280
280
281 if not authenticate(username, password):
281 if not authenticate(username, password):
282 user = User.get_by_username(username)
282 user = User.get_by_username(username)
283 if user and user.active is False:
283 if user and not user.active:
284 log.warning('user %s is disabled' % username)
284 log.warning('user %s is disabled' % username)
285 msg = M(self, 'disabled_account', state)
285 msg = M(self, 'disabled_account', state)
286 raise formencode.Invalid(msg, value, state,
286 raise formencode.Invalid(msg, value, state,
@@ -503,7 +503,7 def CanWriteGroup(old_data=None):
503 error_dict=dict(repo_type=msg)
503 error_dict=dict(repo_type=msg)
504 )
504 )
505 ## check if we can write to root location !
505 ## check if we can write to root location !
506 elif gr is None and can_create_repos() is False:
506 elif gr is None and not can_create_repos():
507 msg = M(self, 'permission_denied_root', state)
507 msg = M(self, 'permission_denied_root', state)
508 raise formencode.Invalid(msg, value, state,
508 raise formencode.Invalid(msg, value, state,
509 error_dict=dict(repo_type=msg)
509 error_dict=dict(repo_type=msg)
@@ -533,7 +533,7 def CanCreateGroup(can_create_in_root=Fa
533 #we can create in root, we're fine no validations required
533 #we can create in root, we're fine no validations required
534 return
534 return
535
535
536 forbidden_in_root = gr is None and can_create_in_root is False
536 forbidden_in_root = gr is None and not can_create_in_root
537 val = HasReposGroupPermissionAny('group.admin')
537 val = HasReposGroupPermissionAny('group.admin')
538 forbidden = not val(gr_name, 'can create group validator')
538 forbidden = not val(gr_name, 'can create group validator')
539 if forbidden_in_root or forbidden:
539 if forbidden_in_root or forbidden:
@@ -25,7 +25,7
25 ${h.link_to(_('show as raw'),h.url('files_raw_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
25 ${h.link_to(_('show as raw'),h.url('files_raw_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
26 ${h.link_to(_('download as raw'),h.url('files_rawfile_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
26 ${h.link_to(_('download as raw'),h.url('files_rawfile_home',repo_name=c.repo_name,revision=c.file_changeset.raw_id,f_path=c.f_path),class_="ui-btn")}
27 % if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name):
27 % if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name):
28 % if c.on_branch_head and c.changeset.branch and c.file.is_binary is False:
28 % if c.on_branch_head and c.changeset.branch and not c.file.is_binary:
29 ${h.link_to(_('edit on branch:%s') % c.changeset.branch,h.url('files_edit_home',repo_name=c.repo_name,revision=c.changeset.branch,f_path=c.f_path),class_="ui-btn")}
29 ${h.link_to(_('edit on branch:%s') % c.changeset.branch,h.url('files_edit_home',repo_name=c.repo_name,revision=c.changeset.branch,f_path=c.f_path),class_="ui-btn")}
30 %else:
30 %else:
31 ${h.link_to(_('edit on branch:?'), '#', class_="ui-btn disabled tooltip", title=_('Editing files allowed only when on branch head revision'))}
31 ${h.link_to(_('edit on branch:?'), '#', class_="ui-btn disabled tooltip", title=_('Editing files allowed only when on branch head revision'))}
@@ -72,7 +72,7
72 </div>
72 </div>
73 <%cnt=0%>
73 <%cnt=0%>
74 <%namespace name="dt" file="/data_table/_dt_elements.html"/>
74 <%namespace name="dt" file="/data_table/_dt_elements.html"/>
75 % if c.visual.lightweight_dashboard is False:
75 % if not c.visual.lightweight_dashboard:
76 ## old full detailed version
76 ## old full detailed version
77 <div id='repos_list_wrap' class="yui-skin-sam">
77 <div id='repos_list_wrap' class="yui-skin-sam">
78 <table id="repos_list">
78 <table id="repos_list">
@@ -131,7 +131,7
131 % endif
131 % endif
132 </div>
132 </div>
133 </div>
133 </div>
134 % if c.visual.lightweight_dashboard is False:
134 % if not c.visual.lightweight_dashboard:
135 <script>
135 <script>
136 YUD.get('repo_count').innerHTML = ${cnt+1 if cnt else 0};
136 YUD.get('repo_count').innerHTML = ${cnt+1 if cnt else 0};
137
137
@@ -146,7 +146,7
146 <div class="input ${summary(c.show_stats)}">
146 <div class="input ${summary(c.show_stats)}">
147 %if len(c.rhodecode_repo.revisions) == 0:
147 %if len(c.rhodecode_repo.revisions) == 0:
148 ${_('There are no downloads yet')}
148 ${_('There are no downloads yet')}
149 %elif c.enable_downloads is False:
149 %elif not c.enable_downloads:
150 ${_('Downloads are disabled for this repository')}
150 ${_('Downloads are disabled for this repository')}
151 %if h.HasPermissionAll('hg.admin')('enable downloads on from summary'):
151 %if h.HasPermissionAll('hg.admin')('enable downloads on from summary'):
152 ${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name),class_="ui-btn")}
152 ${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name),class_="ui-btn")}
@@ -183,7 +183,7 def test_clone_with_credentials(no_error
183 else:
183 else:
184 stdout, stderr = Command(cwd).execute(backend, method, clone_url, dest)
184 stdout, stderr = Command(cwd).execute(backend, method, clone_url, dest)
185 print stdout,'sdasdsadsa'
185 print stdout,'sdasdsadsa'
186 if no_errors is False:
186 if not no_errors:
187 if backend == 'hg':
187 if backend == 'hg':
188 assert """adding file changes""" in stdout, 'no messages about cloning'
188 assert """adding file changes""" in stdout, 'no messages about cloning'
189 assert """abort""" not in stderr , 'got error from clone'
189 assert """abort""" not in stderr , 'got error from clone'
General Comments 0
You need to be logged in to leave comments. Login now