🚚 Rename app main to bbs

🚚 Move settings into main
➕ Add django-rename-app
This commit is contained in:
nikolark committed 2022-02-20 00:39:16 +01:00
1 parent e1eaf3df98
commit 9b903f42d6
39 files changed
+82 -73

No files matched your search

+1
View File
@@ -0,0 +1 @@
__author__ = "Nikolai"
+1
View File
@@ -0,0 +1 @@
__author__ = "Nikolai"
+23
View File
@@ -0,0 +1,23 @@
from pathlib import Path
from django.conf import settings
from django.core.management import BaseCommand, CommandParser
from strawberry.printer import print_schema
from bbs.api.schema import schema as schema_symbol
class Command(BaseCommand):
help = " Write graphql schema to file or stdout"
def add_arguments(self, parser: CommandParser):
parser.add_argument("--filename", default="schema.graphql", help="`-` prints to stdout")
def handle(self, *args, filename=None, **options):
schema_output = print_schema(schema_symbol)
if filename != "-":
with Path(settings.BASE_DIR, filename).open("w+") as fp:
fp.write(schema_output)
self.stdout.write(self.style.SUCCESS("OK"))
else:
print(schema_output)
+20
View File
@@ -0,0 +1,20 @@
from django.core.management.base import BaseCommand, CommandParser
from bbs.models import UserProfile
class Command(BaseCommand):
"""Set profile image URL for all users"""
def add_arguments(self, parser: CommandParser):
parser.add_argument("--dry-run", action="store_true")
parser.add_argument("--force", action="store_true")
def handle(self, *args, dry_run=False, force=False, **options):
for profile in UserProfile.objects.all().order_by("id"):
if dry_run:
print(profile.user.email, profile.image_url())
else:
if force or not profile.image:
profile.image = profile.image_url()
profile.save()