Skip to content

Commit

Permalink
[frontend][python][cli] --enable-net option added for create/modify c…
Browse files Browse the repository at this point in the history
…ommands of copr-cli

Currently, there is no way to test that this works.
  • Loading branch information
clime committed Jun 23, 2016
1 parent f57d76f commit 033194f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
14 changes: 12 additions & 2 deletions cli/copr_cli/main.py
Expand Up @@ -263,7 +263,10 @@ def action_create(self, args):
result = self.client.create_project(
username=username, projectname=copr, description=args.description,
instructions=args.instructions, chroots=args.chroots,
repos=args.repos, initial_pkgs=args.initial_pkgs, unlisted_on_hp=(args.unlisted_on_hp == 'on'))
repos=args.repos, initial_pkgs=args.initial_pkgs,
unlisted_on_hp=(args.unlisted_on_hp == 'on'),
enable_net=(args.enable_net == 'on')
)
print(result.message)

@requires_api_auth
Expand All @@ -277,7 +280,10 @@ def action_modify_project(self, args):
result = self.client.modify_project(
username=username, projectname=copr,
description=args.description, instructions=args.instructions,
repos=args.repos, disable_createrepo=args.disable_createrepo, unlisted_on_hp=(args.unlisted_on_hp == 'on' if args.unlisted_on_hp else None))
repos=args.repos, disable_createrepo=args.disable_createrepo,
unlisted_on_hp=(args.unlisted_on_hp == 'on' if args.unlisted_on_hp else None),
enable_net=(args.enable_net == 'on' if args.enable_net else None)
)

@requires_api_auth
def action_delete(self, args):
Expand Down Expand Up @@ -533,6 +539,8 @@ def setup_parser():
help="Description of the copr")
parser_create.add_argument("--instructions",
help="Instructions for the copr")
parser_create.add_argument("--enable-net", choices=["on", "off"], default="on",
help="If net should be enabled for builds in this project (default is on)")
parser_create.add_argument("--unlisted-on-hp", choices=["on", "off"],
help="The project will not be shown on COPR home page")
parser_create.set_defaults(func="action_create")
Expand All @@ -549,6 +557,8 @@ def setup_parser():
help="Repository to add to this copr")
parser_modify.add_argument("--disable_createrepo",
help="Disable metadata auto generation")
parser_modify.add_argument("--enable-net", choices=["on", "off"],
help="If net should be enabled for builds in this project (default is on)")
parser_modify.add_argument("--unlisted-on-hp", choices=["on", "off"],
help="The project will not be shown on COPR home page")
parser_modify.set_defaults(func="action_modify_project")
Expand Down
12 changes: 12 additions & 0 deletions cli/man/copr-cli.1.asciidoc
Expand Up @@ -95,6 +95,7 @@ usage: copr-cli create [-h] --chroot CHROOTS [--repo REPOS]
[--initial-pkgs PKGS]
[--description DESCRIPTION]
[--instructions INSTRUCTIONS]
[--enable-net {on,off}]
[--unlisted-on-hp {on,off}]
name

Expand All @@ -113,6 +114,9 @@ Description of the project.
--instructions::
Instructions for the project.

--enable-net::
If net should be enabled for builds in this project.

--unlisted-on-hp::
This project will not be listed on COPR home page.

Expand All @@ -124,6 +128,8 @@ usage: copr-cli modify [-h] [--repo REPOS]
[--description DESCRIPTION]
[--instructions INSTRUCTIONS]
[--disable_createrepo DISABLE_CREATEREPO]
[--enable-net {on,off}]
[--unlisted-on-hp {on,off}]
name

Alters only specified project property.
Expand All @@ -140,6 +146,12 @@ Instructions for the project.
--disable_createrepo::
Disables automatic repository metadata generation. Accepted values for DISABLE_CREATEREPO: true/false.

--enable-net::
If net should be enabled for builds in this project.

--unlisted-on-hp::
This project will not be listed on COPR home page.


BUILD ACTIONS
-------------
Expand Down
1 change: 1 addition & 0 deletions frontend/coprs_frontend/coprs/forms.py
Expand Up @@ -634,6 +634,7 @@ class CoprModifyForm(wtf.Form):

disable_createrepo = wtforms.BooleanField(validators=[wtforms.validators.Optional()])
unlisted_on_hp = wtforms.BooleanField(validators=[wtforms.validators.Optional()])
build_enable_net = wtforms.BooleanField(validators=[wtforms.validators.Optional()])


class CoprForkFormFactory(object):
Expand Down
3 changes: 3 additions & 0 deletions frontend/coprs_frontend/coprs/views/api_ns/api_general.py
Expand Up @@ -117,6 +117,7 @@ def api_new_copr(username):
check_for_duplicates=True,
auto_createrepo=True,
unlisted_on_hp=form.unlisted_on_hp.data,
build_enable_net=form.build_enable_net.data,
group=group,
)
infos.append("New project was successfully created.")
Expand Down Expand Up @@ -526,6 +527,8 @@ def copr_modify(copr):

if "unlisted_on_hp" in flask.request.form != None:
copr.unlisted_on_hp = form.unlisted_on_hp.data
if "build_enable_net" in flask.request.form != None:
copr.build_enable_net = form.build_enable_net.data

try:
CoprsLogic.update(flask.g.user, copr)
Expand Down
7 changes: 5 additions & 2 deletions python/copr/client/client.py
Expand Up @@ -956,7 +956,7 @@ def fork_project(self, source, projectname, username=None, confirm=False):
def create_project(
self, username, projectname, chroots,
description=None, instructions=None,
repos=None, initial_pkgs=None, unlisted_on_hp=False
repos=None, initial_pkgs=None, unlisted_on_hp=False, enable_net=True
):
""" Creates a new copr project
Auth required.
Expand Down Expand Up @@ -1000,6 +1000,7 @@ def create_project(
"description": description,
"instructions": instructions,
"unlisted_on_hp": "y" if unlisted_on_hp else "",
"build_enable_net": "y" if enable_net else "",
}
for chroot in chroots:
request_data[chroot] = "y"
Expand All @@ -1021,7 +1022,7 @@ def create_project(

def modify_project(self, projectname, username=None,
description=None, instructions=None,
repos=None, disable_createrepo=None, unlisted_on_hp=None):
repos=None, disable_createrepo=None, unlisted_on_hp=None, enable_net=None):
""" Modifies main project configuration.
Auth required.
Expand Down Expand Up @@ -1057,6 +1058,8 @@ def modify_project(self, projectname, username=None,
data["disable_createrepo"] = disable_createrepo
if unlisted_on_hp != None:
data["unlisted_on_hp"] = "y" if unlisted_on_hp else ""
if enable_net != None:
data["build_enable_net"] = "y" if enable_net else ""

result_data = self._fetch(url, data=data, method="post")

Expand Down

0 comments on commit 033194f

Please sign in to comment.