Integrate django-scopes (#1319)

* Install django-scopes

* Fix tests.api

* Update tasks and cronjobs

* Fix remaining tests

* Remove unused import

* Fix tests after rebase

* Disable scopes for get_Events_with_any_permission

* Disable scopes for a management command
This commit is contained in:
Raphael Michel
2019-06-17 10:46:55 +02:00
committed by GitHub
parent b1db5dbb3e
commit d85ddb5bda
130 changed files with 6253 additions and 4509 deletions

View File

@@ -3,6 +3,7 @@ from decimal import Decimal
import pytest
from django.utils.timezone import now
from django_scopes import scope
from pretix.base.models import (
Event, Item, ItemCategory, Order, OrderPosition, Organizer, Question,
@@ -167,18 +168,19 @@ def logged_in_client(client, event):
])
@pytest.mark.django_db
def test_one_view(logged_in_client, url, expected, event, item, item_category, order, question, quota, voucher):
payment = order.payments.first()
refund = order.refunds.first()
url = url.format(
event=event.slug, orga=event.organizer.slug,
category=item_category.pk,
item=item.pk,
order_code=order.code,
question=question.pk,
quota=quota.pk,
voucher=voucher.pk,
payment=payment.pk,
refund=refund.pk
)
with scope(organizer=event.organizer):
payment = order.payments.first()
refund = order.refunds.first()
url = url.format(
event=event.slug, orga=event.organizer.slug,
category=item_category.pk,
item=item.pk,
order_code=order.code,
question=question.pk,
quota=quota.pk,
voucher=voucher.pk,
payment=payment.pk,
refund=refund.pk
)
response = logged_in_client.get(url)
assert response.status_code == expected