|
class HasGetMethodPermission(BasePermission): |
|
def has_permission(self, request, view): |
|
return self.check_permission(request) |
|
|
|
def has_object_permission(self, request, view, obj): |
|
return self.check_permission(request) |
|
|
|
def check_permission(self, request): |
|
user = request.user |
|
app_label = Topology._meta.app_label.lower() |
|
model = Topology._meta.object_name.lower() |
|
change_perm = f'{app_label}.change_{model}' |
|
view_perm = f'{app_label}.view_{model}' |
|
if user.is_authenticated: |
|
if user.is_superuser or request.method != 'GET': |
|
return True |
|
if request.method == 'GET' and ( |
|
user.has_permission(change_perm) or user.has_permission(view_perm) |
|
): |
|
return True |
|
return False |
|
|
I guess, this portion of code does the same thing as what we did recently in this PR openwisp/openwisp-users#251
So, will it not better if we simply import it from there?
openwisp-network-topology/openwisp_network_topology/api/views.py
Lines 31 to 52 in 3c34047
I guess, this portion of code does the same thing as what we did recently in this PR openwisp/openwisp-users#251
So, will it not better if we simply import it from there?