-
Notifications
You must be signed in to change notification settings - Fork 949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Protect/unprotect #1273
base: master
Are you sure you want to change the base?
Protect/unprotect #1273
Changes from all commits
b3e2a37
04077d0
c156e58
3b6fe40
15c9887
ca422f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1910,6 +1910,7 @@ def add_protected_range( | |
description=None, | ||
warning_only=False, | ||
requesting_user_can_edit=False, | ||
domain_users_can_edit=False, | ||
): | ||
"""Add protected range to the sheet. Only the editors can edit | ||
the protected range. | ||
|
@@ -1962,6 +1963,7 @@ def add_protected_range( | |
"editors": { | ||
"users": editor_users_emails, | ||
"groups": editor_groups_emails, | ||
"domainUsersCanEdit": domain_users_can_edit, | ||
}, | ||
} | ||
} | ||
|
@@ -2964,3 +2966,26 @@ def cut_range( | |
} | ||
|
||
return self.spreadsheet.batch_update(body) | ||
|
||
def column_count(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I separated this out into #1274. It can be removed from here |
||
"""Full English alias for .col_count""" | ||
return self.col_count() | ||
|
||
def list_protected_ranges(self): | ||
"""List protected ranges in current Worksheet""" | ||
return self.spreadsheet.list_protected_ranges(self.id) | ||
|
||
def protect(self): | ||
"""Protect all ranges in current Worksheet""" | ||
email = get_email_from_somewhere_tbd() # TODO ? | ||
last_cell = rowcol_to_a1(self.row_count, self.col_count) | ||
self.add_protected_range( | ||
f"A1:{last_cell}", | ||
email, | ||
description="LOCKED by gspread user", | ||
) | ||
Comment on lines
+2978
to
+2986
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did we try to call the API to add a new protected range but with no actual range. Something like, instead of giving: |
||
|
||
def unprotect(self): | ||
"""Unprotect all ranges in current Worksheet""" | ||
for range in self.list_protected_ranges(): | ||
self.delete_protected_range(range) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be added to the Sphinx docs below (in function docstring)