Skip to content

Commit 2c8b2ed

Browse files
committed
Fix typos and code style issues
1 parent ed48170 commit 2c8b2ed

File tree

6 files changed

+41
-22
lines changed

6 files changed

+41
-22
lines changed

jsapp/js/components/permissions/userAssetPermsEditor.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class UserAssetPermsEditor extends React.Component {
191191
stateObj.submissionsViewPartialUsers = [];
192192
}
193193

194-
// `formManage` implies every other permission (except parial permissions)
194+
// `formManage` implies every other permission (except partial permissions)
195195
if (stateObj.formManage) {
196196
stateObj.formView = true;
197197
stateObj.formEdit = true;

kpi/migrations/0028_assign_manage_asset_permissions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
def create_new_perms(apps):
99
"""
10-
The new `delete_submissions` permission does not exist when running this
10+
The new `manage_asset` permission does not exist when running this
1111
migration for the first time. Django runs migrations in a transaction and
1212
new permissions are not created until after the transaction is completed.
1313

kpi/models/asset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ class Meta:
607607
(
608608
p
609609
for p in ASSIGNABLE_PERMISSIONS
610-
if p != PERM_MANAGE_ASSET and p != PERM_PARTIAL_SUBMISSIONS
610+
if p not in (PERM_MANAGE_ASSET, PERM_PARTIAL_SUBMISSIONS)
611611
)
612612
),
613613
PERM_ADD_SUBMISSIONS: (PERM_VIEW_ASSET,),

kpi/models/object_permission.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -441,16 +441,16 @@ def _get_effective_perms(
441441

442442
# Add the calculated `delete_` permission for the owner
443443
content_type = ContentType.objects.get_for_model(self)
444-
if self.owner is not None and (
445-
user is None or user.pk == self.owner.pk) and (
446-
codename is None or codename.startswith('delete_')
444+
if (
445+
self.owner is not None
446+
and (user is None or user.pk == self.owner.pk)
447+
and (codename is None or codename.startswith('delete_'))
447448
):
448449
matching_permissions = self.__get_permissions_for_content_type(
449-
content_type.pk, codename__startswith='delete_')
450+
content_type.pk, codename__startswith='delete_'
451+
)
450452
for perm_pk, perm_codename in matching_permissions:
451-
if (codename is not None and
452-
perm_codename != codename
453-
):
453+
if codename is not None and perm_codename != codename:
454454
# If the caller specified `codename`, skip anything that
455455
# doesn't match exactly. Necessary because `Asset` has
456456
# `delete_submissions` in addition to `delete_asset`

kpi/views/v1/asset.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,28 @@ def get_serializer_class(self):
165165
def get_serializer_context(self):
166166
return super(AssetViewSetV2, self).get_serializer_context()
167167

168-
@action(detail=True, methods=["PATCH"], renderer_classes=[renderers.JSONRenderer])
168+
@action(
169+
detail=True,
170+
methods=["PATCH"],
171+
renderer_classes=[renderers.JSONRenderer],
172+
)
169173
def permissions(self, request, uid):
170174
target_asset = self.get_object()
171-
source_asset = get_object_or_404(Asset, uid=request.data.get(CLONE_ARG_NAME))
175+
source_asset = get_object_or_404(
176+
Asset, uid=request.data.get(CLONE_ARG_NAME)
177+
)
172178
user = request.user
173179
response = {}
174180
http_status = status.HTTP_204_NO_CONTENT
175181

176-
if user.has_perm(PERM_MANAGE_ASSET, target_asset) and \
177-
user.has_perm(PERM_VIEW_ASSET, source_asset):
182+
if user.has_perm(PERM_MANAGE_ASSET, target_asset) and user.has_perm(
183+
PERM_VIEW_ASSET, source_asset
184+
):
178185
if not target_asset.copy_permissions_from(source_asset):
179186
http_status = status.HTTP_400_BAD_REQUEST
180-
response = {"detail": "Source and destination objects don't seem to have the same type"}
187+
response = {
188+
"detail": "Source and destination objects don't seem to have the same type"
189+
}
181190
else:
182191
raise exceptions.PermissionDenied()
183192

kpi/views/v2/collection_permission_assignment.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,30 @@ def bulk_assignments(self, request, *args, **kwargs):
175175
# see all permissions.
176176
return self.list(request, *args, **kwargs)
177177

178-
@action(detail=False, methods=['PATCH'],
179-
renderer_classes=[renderers.JSONRenderer])
178+
@action(
179+
detail=False,
180+
methods=['PATCH'],
181+
renderer_classes=[renderers.JSONRenderer],
182+
)
180183
def clone(self, request, *args, **kwargs):
181184

182185
source_collection_uid = self.request.data[CLONE_ARG_NAME]
183-
source_collection = get_object_or_404(Collection, uid=source_collection_uid)
186+
source_collection = get_object_or_404(
187+
Collection, uid=source_collection_uid
188+
)
184189
user = request.user
185190

186-
if ObjectPermissionHelper.user_can_share(self.collection, user) and \
187-
user.has_perm(PERM_VIEW_COLLECTION, source_collection):
191+
if ObjectPermissionHelper.user_can_share(
192+
self.collection, user
193+
) and user.has_perm(PERM_VIEW_COLLECTION, source_collection):
188194
if not self.collection.copy_permissions_from(source_collection):
189195
http_status = status.HTTP_400_BAD_REQUEST
190-
response = {'detail': _("Source and destination objects don't "
191-
"seem to have the same type")}
196+
response = {
197+
'detail': _(
198+
"Source and destination objects don't "
199+
"seem to have the same type"
200+
)
201+
}
192202
return Response(response, status=http_status)
193203
else:
194204
raise exceptions.PermissionDenied()

0 commit comments

Comments
 (0)