mirror of
https://github.com/almet/copanier.git
synced 2025-04-28 19:42:37 +02:00
Make everyone staff if not staff is on the config
This commit is contained in:
parent
fa377aa290
commit
8684e83880
2 changed files with 16 additions and 1 deletions
|
@ -84,7 +84,7 @@ class Person(Base):
|
|||
|
||||
@property
|
||||
def is_staff(self):
|
||||
return self.email in config.STAFF
|
||||
return not config.STAFF or self.email in config.STAFF
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
|
@ -2,6 +2,7 @@ from datetime import datetime, timedelta
|
|||
|
||||
import pytest
|
||||
|
||||
from copanier import config
|
||||
from copanier.models import Delivery, Product, Person, Order, ProductOrder
|
||||
|
||||
|
||||
|
@ -88,3 +89,17 @@ def test_can_load_delivery(delivery):
|
|||
delivery.persist()
|
||||
loaded = Delivery.load(delivery.id)
|
||||
assert loaded.producer == "Corto"
|
||||
|
||||
|
||||
def test_person_is_staff_if_email_is_in_config(monkeypatch):
|
||||
monkeypatch.setattr(config, 'STAFF', ["foo@bar.fr"])
|
||||
person = Person(email="foo@bar.fr")
|
||||
assert person.is_staff
|
||||
person = Person(email="foo@bar.org")
|
||||
assert not person.is_staff
|
||||
|
||||
|
||||
def test_person_is_staff_if_no_staff_in_config(monkeypatch):
|
||||
monkeypatch.setattr(config, 'STAFF', [])
|
||||
person = Person(email="foo@bar.fr")
|
||||
assert person.is_staff
|
||||
|
|
Loading…
Reference in a new issue