update sanity check for remove-group
This commit is contained in:
parent
f4435d4a9c
commit
fb292aeca1
1 changed files with 14 additions and 5 deletions
|
|
@ -137,14 +137,23 @@ def handle_remove_group(goptions, session, args):
|
||||||
if not (session.hasPerm('admin') or session.hasPerm('tag')):
|
if not (session.hasPerm('admin') or session.hasPerm('tag')):
|
||||||
parser.error("This action requires tag or admin privileges")
|
parser.error("This action requires tag or admin privileges")
|
||||||
|
|
||||||
dsttag = session.getTag(tag)
|
taginfo = session.getTag(tag)
|
||||||
if not dsttag:
|
if not taginfo:
|
||||||
error("No such tag: %s" % tag)
|
error("No such tag: %s" % tag)
|
||||||
|
|
||||||
groups = dict([(p['name'], p['group_id']) for p in session.getTagGroups(tag, inherit=False)])
|
# sanity checks
|
||||||
group_id = groups.get(group, None)
|
groups = session.getTagGroups(taginfo['id'], incl_pkgs=False, incl_reqs=False, incl_blocked=True)
|
||||||
if group_id is None:
|
for ginfo in groups:
|
||||||
|
if ginfo['name'] == group:
|
||||||
|
break
|
||||||
|
else:
|
||||||
error("Group %s doesn't exist within tag %s" % (group, tag))
|
error("Group %s doesn't exist within tag %s" % (group, tag))
|
||||||
|
if ginfo['blocked']:
|
||||||
|
error("Group %s is blocked in this tag. You could use unblock-group to unblock it" % group)
|
||||||
|
if ginfo['tag_id'] != taginfo['id']:
|
||||||
|
# listing is inherited
|
||||||
|
srctag = session.getTag(ginfo['tag_id'])
|
||||||
|
error("The entry for group %s is inherited from %s. You could use block-group to prevent this" % (group, srctag['name']))
|
||||||
|
|
||||||
session.groupListRemove(tag, group)
|
session.groupListRemove(tag, group)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue