mirror of
https://github.com/ansible/awx.git
synced 2026-05-14 04:47:44 -02:30
Merge branch 'devel' into migration
This commit is contained in:
@@ -1204,7 +1204,7 @@ class LabelAccess(BaseAccess):
|
||||
def can_read(self, obj):
|
||||
if self.user.is_superuser:
|
||||
return True
|
||||
return obj.organization and obj.organization.accessible_by(self.user, {'read': True})
|
||||
return obj.organization.accessible_by(self.user, {'read': True})
|
||||
|
||||
def can_add(self, data):
|
||||
if self.user.is_superuser:
|
||||
@@ -1224,7 +1224,7 @@ class LabelAccess(BaseAccess):
|
||||
if self.can_add(data) is False:
|
||||
return False
|
||||
|
||||
return obj.organization and obj.organization.accessible_by(self.user, ALL_PERMISSIONS)
|
||||
return obj.organization.accessible_by(self.user, ALL_PERMISSIONS)
|
||||
|
||||
def can_delete(self, obj):
|
||||
return self.can_change(obj, None)
|
||||
|
||||
19
awx/main/migrations/0015_v300_label_changes.py
Normal file
19
awx/main/migrations/0015_v300_label_changes.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('main', '0014_v300_invsource_cred'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='label',
|
||||
name='organization',
|
||||
field=models.ForeignKey(related_name='labels', to='main.Organization', help_text='Organization this label belongs to.'),
|
||||
),
|
||||
]
|
||||
@@ -24,11 +24,8 @@ class Label(CommonModelNameNotUnique):
|
||||
organization = models.ForeignKey(
|
||||
'Organization',
|
||||
related_name='labels',
|
||||
blank=True,
|
||||
null=True,
|
||||
default=None,
|
||||
help_text=_('Organization this label belongs to.'),
|
||||
on_delete=models.SET_NULL,
|
||||
on_delete=models.CASCADE,
|
||||
)
|
||||
|
||||
def get_absolute_url(self):
|
||||
|
||||
@@ -20,7 +20,7 @@ def test_get_activity_stream_list(monkeypatch, organization, get, user):
|
||||
@pytest.mark.django_db
|
||||
def test_basic_fields(monkeypatch, organization, get, user):
|
||||
u = user('admin', True)
|
||||
activity_stream = ActivityStream.objects.latest('pk')
|
||||
activity_stream = ActivityStream.objects.filter(organization=organization).latest('pk')
|
||||
activity_stream.actor = u
|
||||
activity_stream.save()
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ def test_custom_inv_script_access(organization, user):
|
||||
|
||||
custom_inv = CustomInventoryScript.objects.create(name='test', script='test', description='test')
|
||||
custom_inv.organization = organization
|
||||
custom_inv.save()
|
||||
assert not custom_inv.accessible_by(u, {'read':True})
|
||||
|
||||
organization.member_role.members.add(u)
|
||||
|
||||
Reference in New Issue
Block a user