allow also removing extra for sidetags
This commit is contained in:
parent
d61e345dee
commit
c63b7fee54
1 changed files with 10 additions and 7 deletions
|
|
@ -41,7 +41,6 @@ def is_sidetag_owner(taginfo, user, raise_error=False):
|
|||
"""Check, that given user is owner of the sidetag"""
|
||||
result = (taginfo['extra'].get('sidetag') and
|
||||
(taginfo['extra'].get('sidetag_user_id') == user['id'] or
|
||||
context.session.hasPerm('sidetag_edit') or
|
||||
context.session.hasPerm('admin')))
|
||||
if not result and raise_error:
|
||||
raise koji.ActionNotAllowed("This is not your sidetag")
|
||||
|
|
@ -231,7 +230,8 @@ def listSideTags(basetag=None, user=None, queryOpts=None):
|
|||
|
||||
|
||||
@export
|
||||
def editSideTag(sidetag, debuginfo=None, rpm_macros=None, remove_rpm_macros=None, extra=None):
|
||||
def editSideTag(sidetag, debuginfo=None, rpm_macros=None, remove_rpm_macros=None, extra=None,
|
||||
remove_extra=None):
|
||||
"""Restricted ability to modify sidetags, parent tag must have:
|
||||
sidetag_debuginfo_allowed: 1
|
||||
sidetag_rpm_macros_allowed: 1
|
||||
|
|
@ -256,12 +256,15 @@ def editSideTag(sidetag, debuginfo=None, rpm_macros=None, remove_rpm_macros=None
|
|||
is_sidetag(sidetag, raise_error=True)
|
||||
is_sidetag_owner(sidetag, user, raise_error=True)
|
||||
|
||||
if extra is not None and not (context.session.hasPerm('sidetag_admin') or
|
||||
context.session.hasPerm('admin')):
|
||||
if ((extra is not None or remove_extra is not None) and
|
||||
not (context.session.hasPerm('sidetag_admin') or context.session.hasPerm('admin'))):
|
||||
raise koji.GenericError(
|
||||
"Extra can be modified only with sidetag_admin or admin permissions.")
|
||||
else:
|
||||
|
||||
if extra is None:
|
||||
extra = {}
|
||||
if remove_extra is None:
|
||||
remove_extra = []
|
||||
|
||||
parent_id = readInheritanceData(sidetag['id'])[0]['parent_id']
|
||||
parent = get_tag(parent_id)
|
||||
|
|
@ -273,7 +276,7 @@ def editSideTag(sidetag, debuginfo=None, rpm_macros=None, remove_rpm_macros=None
|
|||
and not parent['extra'].get('sidetag_rpm_macros_allowed'):
|
||||
raise koji.GenericError("RPM macros change is not allowed in parent tag.")
|
||||
|
||||
kwargs = {'extra': extra}
|
||||
kwargs = {'extra': extra, 'remove_extra': remove_extra}
|
||||
if debuginfo is not None:
|
||||
kwargs['extra']['with_debuginfo'] = bool(debuginfo)
|
||||
if rpm_macros is not None:
|
||||
|
|
@ -282,7 +285,7 @@ def editSideTag(sidetag, debuginfo=None, rpm_macros=None, remove_rpm_macros=None
|
|||
kwargs['extra']['rpm.macro.%s' % macro] = value
|
||||
if remove_rpm_macros is not None:
|
||||
convert_value(remove_rpm_macros, cast=list, check_only=True)
|
||||
kwargs['remove_extra'] = ['rpm.macro.%s' % m for m in remove_rpm_macros]
|
||||
kwargs['remove_extra'] += ['rpm.macro.%s' % m for m in remove_rpm_macros]
|
||||
|
||||
_edit_tag(sidetag['id'], **kwargs)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue