diff --git a/src/fellchensammlung/management/commands/populate_db.py b/src/fellchensammlung/management/commands/populate_db.py index caf6b5d..2b40076 100644 --- a/src/fellchensammlung/management/commands/populate_db.py +++ b/src/fellchensammlung/management/commands/populate_db.py @@ -7,7 +7,7 @@ from fellchensammlung import baker_recipes from model_bakery import baker from fellchensammlung.models import AdoptionNotice, Species, Animal, Image, ModerationAction, User, Rule, \ - Report, Comment, ReportAdoptionNotice + Report, Comment, ReportAdoptionNotice, TrustLevel class Command(BaseCommand): @@ -101,10 +101,10 @@ class Command(BaseCommand): User.objects.create_user('test', password='foobar') admin1 = User.objects.create_superuser(username="admin", password="admin", email="admin1@example.org", - trust_level=User.TRUST_LEVEL[User.ADMIN]) + trust_level=TrustLevel.ADMIN) mod1 = User.objects.create_user(username="mod1", password="mod", email="mod1@example.org", - trust_level=User.TRUST_LEVEL[User.MODERATOR]) + trust_level=TrustLevel.MODERATOR) comment1 = baker.make(Comment, user=admin1, text="This is a comment", adoption_notice=adoption1) comment2 = baker.make(Comment, diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index 88ac516..23b7e82 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -210,7 +210,7 @@ def add_adoption_notice(request): add_adoption_notice_location.delay_on_commit(instance.pk) # Set correct status - if request.user.trust_level >= User.TRUST_LEVEL[User.COORDINATOR]: + if request.user.trust_level >= TrustLevel.MODERATOR: instance.set_active() else: instance.set_unchecked() @@ -484,7 +484,7 @@ def updatequeue(request): if action == "checked_active": adoption_notice.set_active() - if user_is_trust_level_or_above(request.user, User.MODERATOR): + if user_is_trust_level_or_above(request.user, TrustLevel.MODERATOR): last_checked_adoption_list = AdoptionNotice.objects.order_by("last_checked") else: last_checked_adoption_list = AdoptionNotice.objects.filter(owner=request.user).order_by("last_checked") diff --git a/src/tests/test_models.py b/src/tests/test_models.py index 5a47850..38b0a55 100644 --- a/src/tests/test_models.py +++ b/src/tests/test_models.py @@ -4,7 +4,7 @@ from django.utils import timezone from django.test import TestCase from model_bakery import baker -from fellchensammlung.models import Announcement, Language, User +from fellchensammlung.models import Announcement, Language, User, TrustLevel class UserTest(TestCase): @@ -12,7 +12,7 @@ class UserTest(TestCase): test_user_1 = User.objects.create(username="Testuser1", password="SUPERSECRET", email="test@example.org") self.assertTrue(test_user_1.trust_level == 1) - self.assertTrue(test_user_1.trust_level == User.TRUST_LEVEL[User.MEMBER]) + self.assertTrue(test_user_1.trust_level == TrustLevel.MEMBER) class AnnouncementTest(TestCase): diff --git a/src/tests/test_views.py b/src/tests/test_views.py index fcd4004..9365257 100644 --- a/src/tests/test_views.py +++ b/src/tests/test_views.py @@ -4,7 +4,7 @@ from django.urls import reverse from model_bakery import baker -from fellchensammlung.models import Animal, Species, AdoptionNotice, User, Location, AdoptionNoticeStatus +from fellchensammlung.models import Animal, Species, AdoptionNotice, User, Location, AdoptionNoticeStatus, TrustLevel from fellchensammlung.views import add_adoption_notice @@ -20,7 +20,7 @@ class AnimalAndAdoptionTest(TestCase): first_name="Max", last_name="Müller", password='12345') - test_user0.trust_level = User.TRUST_LEVEL[User.ADMIN] + test_user0.trust_level = TrustLevel.ADMIN test_user0.save() adoption1 = baker.make(AdoptionNotice, name="TestAdoption1") @@ -133,7 +133,7 @@ class UpdateQueueTest(TestCase): first_name="Admin", last_name="BOFH", password='12345', - trust_level=User.TRUST_LEVEL[User.MODERATOR]) + trust_level=TrustLevel.MODERATOR) test_user0.is_superuser = True test_user0.save()