Skip to content

Commit

Permalink
delete: allow disabling multiple features at once, comma-separated
Browse files Browse the repository at this point in the history
for #1593
  • Loading branch information
snarfed committed Nov 1, 2023
1 parent f6f708a commit 42e9235
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,20 @@ def delete_finish():
if not parts or 'feature' not in parts or 'source' not in parts:
error('state query parameter must include "feature" and "source"')

feature = parts['feature']
if feature not in (Source.FEATURES):
error(f'cannot delete unknown feature {feature}')
features = parts['feature'].split(',')
for feature in features:
if feature not in (Source.FEATURES):
error(f'cannot delete unknown feature {feature}')

logged_in_as = ndb.Key(urlsafe=request.args['auth_entity']).get()
source = ndb.Key(urlsafe=parts['source']).get()

logins = None
if logged_in_as and logged_in_as.is_authority_for(source.auth_entity):
if feature in source.features:
source.features.remove(feature)
existing = set(source.features)
remaining = existing - set(features)
if remaining != existing:
source.features = list(remaining)
source.put()

# remove login cookie
Expand Down

0 comments on commit 42e9235

Please sign in to comment.