integrations: fix re-submit of form on repo integrations.

This commit is contained in:
Marcin Kuzminski 2017-02-01 12:48:49 +01:00
parent 33ec213f25
commit adca0da138
3 changed files with 5 additions and 7 deletions

View file

@ -142,7 +142,6 @@ class IntegrationSettingsViewBase(object):
permissions=self.request.user.permissions,
no_scope=not self.admin_view)
def _form_defaults(self):
defaults = {}
@ -284,7 +283,6 @@ class IntegrationSettingsViewBase(object):
child_repos_only=scope['child_repos_only'],
)
self.integration.settings = valid_data['settings']
Session().commit()
# Display success message and redirect.
@ -293,7 +291,6 @@ class IntegrationSettingsViewBase(object):
integration_name=self.IntegrationType.display_name),
queue='success')
# if integration scope changes, we must redirect to the right place
# keeping in mind if the original view was for /repo/ or /_admin/
admin_view = not (self.repo or self.repo_group)
@ -347,8 +344,8 @@ class IntegrationSettingsViewBase(object):
assert sort_field in ('name', 'integration_type', 'enabled', 'scope')
integrations.sort(
key=lambda x: getattr(x[1], sort_field), reverse=(sort_dir=='desc'))
key=lambda x: getattr(x[1], sort_field),
reverse=(sort_dir == 'desc'))
page_url = webhelpers.paginate.PageURL(
self.request.path, self.request.GET)
@ -375,6 +372,7 @@ class IntegrationSettingsViewBase(object):
}
return template_context
class GlobalIntegrationsView(IntegrationSettingsViewBase):
def perm_check(self, user):
return auth.HasPermissionAll('hg.admin').check_permissions(user=user)

View file

@ -135,7 +135,7 @@ class IntegrationScopeType(colander.SchemaType):
return {
'repo': repo,
'repo_group': None,
'child_repos_only': None,
'child_repos_only': False,
}
elif cstruct.startswith('repogroup-recursive:'):
repo_group = RepoGroup.get_by_group_name(cstruct.split(':')[1])

View file

@ -47,7 +47,7 @@ class TestIntegrationSchema(object):
(
'repo:%s' % repo.repo_name,
{
'child_repos_only': None,
'child_repos_only': False,
'repo_group': None,
'repo': repo,
},