diff --git a/scipost/management/commands/populate_db.py b/scipost/management/commands/populate_db.py new file mode 100644 index 0000000000000000000000000000000000000000..26e2d1a3ac72011e41781b943cedfd7e015b137d --- /dev/null +++ b/scipost/management/commands/populate_db.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'])