# HG changeset patch # User Mads Kiilerich # Date 1670801122 -3600 # Node ID f2dc57c123cf448cca9dc6cfb9cc1054ff491035 # Parent d00371a768c91915cab2afd6b49f620e97f53e87 repo: introduce enable_downloads and enable_statistics when creating repos These booleans were not shown in the normal repo creation form, so the form validation applied the "default" values of False. These values were however not used by the model when creating repos - it just unconditionally used the real global defaults. The API already exposed some of this, but it wasn't implemented. The web form for creating repos lacked these fields, but it was present in the repo edit form. Just make these fields mandatory. There will thus not be any defaults to apply in the model for creating repos. diff -r d00371a768c9 -r f2dc57c123cf kallithea/controllers/api/api.py --- a/kallithea/controllers/api/api.py Sun Dec 11 02:05:08 2022 +0100 +++ b/kallithea/controllers/api/api.py Mon Dec 12 00:25:22 2022 +0100 @@ -1230,8 +1230,8 @@ clone_uri=clone_uri, repo_group=group_name, repo_landing_rev=landing_rev, - enable_statistics=enable_statistics, - enable_downloads=enable_downloads, + repo_enable_statistics=enable_statistics, + repo_enable_downloads=enable_downloads, repo_copy_permissions=copy_permissions, ) diff -r d00371a768c9 -r f2dc57c123cf kallithea/model/repo.py --- a/kallithea/model/repo.py Sun Dec 11 02:05:08 2022 +0100 +++ b/kallithea/model/repo.py Mon Dec 12 00:25:22 2022 +0100 @@ -711,13 +711,10 @@ copy_fork_permissions = form_data.get('copy_permissions') copy_group_permissions = form_data.get('repo_copy_permissions') fork_of = form_data.get('fork_parent_id') + enable_statistics = form_data['repo_enable_statistics'] + enable_downloads = form_data['repo_enable_downloads'] state = form_data.get('repo_state', db.Repository.STATE_PENDING) - # repo creation defaults, private and repo_type are filled in form - defs = db.Setting.get_default_repo_settings(strip_prefix=True) - enable_statistics = defs.get('repo_enable_statistics') - enable_downloads = defs.get('repo_enable_downloads') - try: db_repo = RepoModel()._create_repo( repo_name=repo_name_full, diff -r d00371a768c9 -r f2dc57c123cf kallithea/templates/admin/repos/repo_add_base.html --- a/kallithea/templates/admin/repos/repo_add_base.html Sun Dec 11 02:05:08 2022 +0100 +++ b/kallithea/templates/admin/repos/repo_add_base.html Mon Dec 12 00:25:22 2022 +0100 @@ -58,6 +58,20 @@
+ +
+ ${h.checkbox('repo_enable_statistics',value="True")} + ${_('Enable statistics window on summary page.')} +
+
+
+ +
+ ${h.checkbox('repo_enable_downloads',value="True")} + ${_('Enable download menu on summary page.')} +
+
+
${h.submit('add',_('Add'),class_="btn btn-default")}
diff -r d00371a768c9 -r f2dc57c123cf kallithea/tests/api/api_base.py --- a/kallithea/tests/api/api_base.py Sun Dec 11 02:05:08 2022 +0100 +++ b/kallithea/tests/api/api_base.py Mon Dec 12 00:25:22 2022 +0100 @@ -792,8 +792,8 @@ ('clone_uri', {'clone_uri': None}), ('landing_rev', {'landing_rev': 'branch:master'}), ('private', {'private': True}), - #('enable_statistics', {'enable_statistics': True}), # currently broken - #('enable_downloads', {'enable_downloads': True}), # currently broken + ('enable_statistics', {'enable_statistics': True}), + ('enable_downloads', {'enable_downloads': True}), ('repo_group', {'group': 'test_group_for_update'}), ]) def test_api_create_repo(self, changing_attr, updates): diff -r d00371a768c9 -r f2dc57c123cf kallithea/tests/fixture.py --- a/kallithea/tests/fixture.py Sun Dec 11 02:05:08 2022 +0100 +++ b/kallithea/tests/fixture.py Mon Dec 12 00:25:22 2022 +0100 @@ -95,6 +95,8 @@ repo_group='-1', repo_description='DESC', repo_private=False, + repo_enable_statistics=False, + repo_enable_downloads=False, repo_landing_rev='rev:tip', repo_copy_permissions=False, repo_state=db.Repository.STATE_CREATED,