diff --git a/scipost/management/commands/populate_db.py b/scipost/management/commands/populate_db.py index 26e2d1a3ac72011e41781b943cedfd7e015b137d..ae0f171dc7c06a291340290217697f787fc1aa61 100644 --- a/scipost/management/commands/populate_db.py +++ b/scipost/management/commands/populate_db.py @@ -1,20 +1,17 @@ from django.core.management.base import BaseCommand -from django.contrib.auth.models import User -from ...models import Contributor +from ...factories import EditorialCollegeFactory, EditorialCollegeMemberFactory class Command(BaseCommand): - def add_arguments(self, parser): - parser.add_argument( - '--username', type=str, required=True, - help='Username of user to use for contributor model') + def create_editorial_college(self): + EditorialCollegeFactory.create_batch(5) + self.stdout.write(self.style.SUCCESS('Successfully created Editorial College\'s.')) - def create_contributor(self, username): - user = User.objects.get(username=username) - contributor = Contributor(user=user, status=1, title="MR") - contributor.vetted_by = contributor - contributor.save() + def create_editorial_college_members(self): + EditorialCollegeMemberFactory.create_batch(20) + self.stdout.write(self.style.SUCCESS('Successfully created Editorial College Members.')) - def handle(self, *args, **options): - self.create_contributor(options['username']) + def handle(self, *args, **kwargs): + self.create_editorial_college() + self.create_editorial_college_members() diff --git a/scipost/management/commands/setup_contributor.py b/scipost/management/commands/setup_contributor.py new file mode 100644 index 0000000000000000000000000000000000000000..26e2d1a3ac72011e41781b943cedfd7e015b137d --- /dev/null +++ b/scipost/management/commands/setup_contributor.py @@ -0,0 +1,20 @@ +from django.core.management.base import BaseCommand +from django.contrib.auth.models import User + +from ...models import Contributor + + +class Command(BaseCommand): + def add_arguments(self, parser): + parser.add_argument( + '--username', type=str, required=True, + help='Username of user to use for contributor model') + + def create_contributor(self, username): + user = User.objects.get(username=username) + contributor = Contributor(user=user, status=1, title="MR") + contributor.vetted_by = contributor + contributor.save() + + def handle(self, *args, **options): + self.create_contributor(options['username'])