Commit 108cf5c2 authored by Philipp Sebastian Sommer's avatar Philipp Sebastian Sommer
Browse files

add --names option to makedummyusers

parent 7dea2806
Pipeline #101397 failed with stage
in 45 seconds
......@@ -45,7 +45,9 @@ Quick start for development
8. Populate the database with dummy users (note that this is for development
purposes only!)::
python makedummyusers
python makedummyusers -n "Beate Geyer" "Burkhardt Rockel"
The password for these user accounts will be ``admin``.
9. Run the local development server via::
import operator
from functools import reduce
from import BaseCommand, CommandError
import datetime as dt
......@@ -39,15 +42,34 @@ class Command(BaseCommand):
def add_arguments(self, parser):
"""Add connection arguments to the parser."""
"User name to create (must match one person in the database, "
"e.g. `Beate Geyer`."
def handle(self, *args, **options):
"""Migrate the database."""
from django.db.models import Q
from clm_members.models import CommunityMember
from django.contrib.auth.models import User
for member in log_progress(CommunityMember.objects.all()):
if options.get("names"):
names = map(lambda s: s.split(maxsplit=1), options["names"])
query = reduce(
(Q(first_name=fn, last_name=ln) for fn, ln in names))
members = CommunityMember.objects.filter(query)
members = CommunityMember.objects.all()
for member in log_progress(members):
first = member.first_name
last = member.last_name
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment