chore: format files using black (pre-commit)
This commit is contained in:
parent
fa51738fe8
commit
4159bc1209
|
@ -37,10 +37,15 @@ class Command(BaseCommand):
|
||||||
try:
|
try:
|
||||||
user = User.objects.get(username="gitpod")
|
user = User.objects.get(username="gitpod")
|
||||||
except Exception:
|
except Exception:
|
||||||
call_command("createsuperuser", username="gitpod", email="gitpod@example.com", no_input=False)
|
call_command(
|
||||||
|
"createsuperuser",
|
||||||
|
username="gitpod",
|
||||||
|
email="gitpod@example.com",
|
||||||
|
no_input=False,
|
||||||
|
)
|
||||||
user = User.objects.get(username="gitpod")
|
user = User.objects.get(username="gitpod")
|
||||||
|
|
||||||
user.set_password('gitpod')
|
user.set_password("gitpod")
|
||||||
if not user.actor:
|
if not user.actor:
|
||||||
user.create_actor()
|
user.create_actor()
|
||||||
|
|
||||||
|
@ -50,7 +55,9 @@ class Command(BaseCommand):
|
||||||
preferences.set("common__api_authentication_required", False)
|
preferences.set("common__api_authentication_required", False)
|
||||||
|
|
||||||
# Download music catalog
|
# Download music catalog
|
||||||
os.system("git clone https://dev.funkwhale.audio/funkwhale/catalog.git /tmp/catalog")
|
os.system(
|
||||||
|
"git clone https://dev.funkwhale.audio/funkwhale/catalog.git /tmp/catalog"
|
||||||
|
)
|
||||||
os.system("mv -f /tmp/catalog/music /workspace/funkwhale/data")
|
os.system("mv -f /tmp/catalog/music /workspace/funkwhale/data")
|
||||||
os.system("rm -rf /tmp/catalog/music")
|
os.system("rm -rf /tmp/catalog/music")
|
||||||
|
|
||||||
|
@ -59,7 +66,7 @@ class Command(BaseCommand):
|
||||||
"create_library",
|
"create_library",
|
||||||
"gitpod",
|
"gitpod",
|
||||||
name="funkwhale/catalog",
|
name="funkwhale/catalog",
|
||||||
privacy_level="everyone"
|
privacy_level="everyone",
|
||||||
)
|
)
|
||||||
call_command(
|
call_command(
|
||||||
"import_files",
|
"import_files",
|
||||||
|
@ -77,5 +84,8 @@ class Command(BaseCommand):
|
||||||
host="0.0.0.0",
|
host="0.0.0.0",
|
||||||
port=5000,
|
port=5000,
|
||||||
reload=True,
|
reload=True,
|
||||||
reload_dirs=["/workspace/funkwhale/api/config/", "/workspace/funkwhale/api/funkwhale_api/"],
|
reload_dirs=[
|
||||||
|
"/workspace/funkwhale/api/config/",
|
||||||
|
"/workspace/funkwhale/api/funkwhale_api/",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
|
@ -26,34 +26,44 @@ class Command(BaseCommand):
|
||||||
def add_arguments(self, parser):
|
def add_arguments(self, parser):
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"username",
|
"username",
|
||||||
nargs='*',
|
nargs="*",
|
||||||
help="Rebuild only for given users",
|
help="Rebuild only for given users",
|
||||||
)
|
)
|
||||||
|
|
||||||
@transaction.atomic
|
@transaction.atomic
|
||||||
def handle(self, *args, **options):
|
def handle(self, *args, **options):
|
||||||
actor_ids = []
|
actor_ids = []
|
||||||
if options['username']:
|
if options["username"]:
|
||||||
actors = Actor.objects.all().local(True)
|
actors = Actor.objects.all().local(True)
|
||||||
actor_ids = list(actors.filter(preferred_username__in=options['username']).values_list('id', flat=True))
|
actor_ids = list(
|
||||||
if len(actor_ids) < len(options['username']):
|
actors.filter(preferred_username__in=options["username"]).values_list(
|
||||||
raise CommandError('Invalid username')
|
"id", flat=True
|
||||||
print('Emptying permission table for specified users…')
|
)
|
||||||
qs = TrackActor.objects.all().filter(Q(actor__pk__in=actor_ids) | Q(actor=None))
|
)
|
||||||
|
if len(actor_ids) < len(options["username"]):
|
||||||
|
raise CommandError("Invalid username")
|
||||||
|
print("Emptying permission table for specified users…")
|
||||||
|
qs = TrackActor.objects.all().filter(
|
||||||
|
Q(actor__pk__in=actor_ids) | Q(actor=None)
|
||||||
|
)
|
||||||
qs._raw_delete(qs.db)
|
qs._raw_delete(qs.db)
|
||||||
else:
|
else:
|
||||||
print('Emptying permission table…')
|
print("Emptying permission table…")
|
||||||
qs = TrackActor.objects.all()
|
qs = TrackActor.objects.all()
|
||||||
qs._raw_delete(qs.db)
|
qs._raw_delete(qs.db)
|
||||||
libraries = Library.objects.all()
|
libraries = Library.objects.all()
|
||||||
objs = []
|
objs = []
|
||||||
total_libraries = len(libraries)
|
total_libraries = len(libraries)
|
||||||
for i, library in enumerate(libraries):
|
for i, library in enumerate(libraries):
|
||||||
print('[{}/{}] Populating permission table for library {}'.format(i + 1, total_libraries, library.pk))
|
print(
|
||||||
|
"[{}/{}] Populating permission table for library {}".format(
|
||||||
|
i + 1, total_libraries, library.pk
|
||||||
|
)
|
||||||
|
)
|
||||||
objs += TrackActor.get_objs(
|
objs += TrackActor.get_objs(
|
||||||
library=library,
|
library=library,
|
||||||
actor_ids=actor_ids,
|
actor_ids=actor_ids,
|
||||||
upload_and_track_ids=[],
|
upload_and_track_ids=[],
|
||||||
)
|
)
|
||||||
print('Commiting changes…')
|
print("Commiting changes…")
|
||||||
TrackActor.objects.bulk_create(objs, batch_size=5000, ignore_conflicts=True)
|
TrackActor.objects.bulk_create(objs, batch_size=5000, ignore_conflicts=True)
|
||||||
|
|
Loading…
Reference in New Issue