diff --git a/.gitignore b/.gitignore index b2d3c5b..7a0a341 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ db.sqlite3 .idea/ .venv/ .hidden_notes.txt +env/ +*pyc +__pycache__/ +xxxthemexxx/ diff --git a/.run/django_gurps.run.xml b/.run/django_gurps.run.xml new file mode 100644 index 0000000..e80fdeb --- /dev/null +++ b/.run/django_gurps.run.xml @@ -0,0 +1,39 @@ + + + + + \ No newline at end of file diff --git a/django_gurps/__pycache__/settings.cpython-312.pyc b/django_gurps/__pycache__/settings.cpython-312.pyc deleted file mode 100644 index 5dae058..0000000 Binary files a/django_gurps/__pycache__/settings.cpython-312.pyc and /dev/null differ diff --git a/django_gurps/__pycache__/urls.cpython-312.pyc b/django_gurps/__pycache__/urls.cpython-312.pyc deleted file mode 100644 index e73fb39..0000000 Binary files a/django_gurps/__pycache__/urls.cpython-312.pyc and /dev/null differ diff --git a/django_gurps/settings.py b/django_gurps/settings.py index 04ce47d..2e29cbc 100644 --- a/django_gurps/settings.py +++ b/django_gurps/settings.py @@ -36,6 +36,15 @@ CSRF_TRUSTED_ORIGINS = [ "https://gcs.neill.id.au", ] +AUTHENTICATION_BACKENDS = [ + + # Needed to log in by username in Django admin, regardless of `allauth` + 'django.contrib.auth.backends.ModelBackend', + + # `allauth` specific authentication methods, such as login by email + 'allauth.account.auth_backends.AuthenticationBackend', + +] # Application definition @@ -46,10 +55,20 @@ INSTALLED_APPS = [ "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", + + 'allauth', + 'allauth.account', + 'allauth.socialaccount', + # ... include the providers you want to enable: + 'allauth.socialaccount.providers.amazon', + 'allauth.socialaccount.providers.apple', + 'allauth.socialaccount.providers.google', + "django.contrib.staticfiles", - "tailwind", - "theme", + # "tailwind", + # "theme", "django_browser_reload", + 'django_bootstrap_icons', ] MIDDLEWARE = [ @@ -61,6 +80,8 @@ MIDDLEWARE = [ "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", "django_browser_reload.middleware.BrowserReloadMiddleware", + # Add the account middleware: + "allauth.account.middleware.AccountMiddleware", ] ROOT_URLCONF = "django_gurps.urls" @@ -76,6 +97,7 @@ TEMPLATES = [ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", + 'django.template.context_processors.request', ], }, }, @@ -87,12 +109,12 @@ WSGI_APPLICATION = "django_gurps.wsgi.application" # Database # https://docs.djangoproject.com/en/5.0/ref/settings/#databases -DATABASES = { - "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": BASE_DIR / "db.sqlite3", - } -} +# DATABASES = { +# "default": { +# "ENGINE": "django.db.backends.sqlite3", +# "NAME": BASE_DIR / "db.sqlite3", +# } +# } # Password validation @@ -155,3 +177,11 @@ INTERNAL_IPS = [ LOGIN_REDIRECT_URL = "home" LOGOUT_REDIRECT_URL = "home" + +EMAIL_HOST = os.environ["GURPS_SMTP_HOST"] +EMAIL_HOST_USER = os.environ["GURPS_SMTP_USER"] +EMAIL_PORT = os.environ["GURPS_SMTP_PORT"] +EMAIL_HOST_PASSWORD = os.environ["GURPS_EMAIL_PASSWORD"] +EMAIL_USE_SSL = os.environ["GURPS_SMTP_SSL"] == "Y" +DEFAULT_FROM_EMAIL = os.environ["GURPS_EMAIL_ADDRESS"] +ACCOUNT_LOGIN_BY_CODE_ENABLED = True diff --git a/django_gurps/urls.py b/django_gurps/urls.py index 438814d..834034b 100644 --- a/django_gurps/urls.py +++ b/django_gurps/urls.py @@ -23,7 +23,8 @@ urlpatterns = [ path("gurps/", include("gurps_character.urls")), path("admin/", admin.site.urls), path("__reload__/", include("django_browser_reload.urls")), - path("accounts/", include("django.contrib.auth.urls")), - path("", TemplateView.as_view(template_name="home.html"), name="home"), + # path("accounts/", include("django.contrib.auth.urls")), + path('accounts/', include('allauth.urls')), + path("", TemplateView.as_view(template_name="home.html"), name="home"), path('logout/', views.LogoutView.as_view(), name='logout'), ] diff --git a/django_gurps/views.py b/django_gurps/views.py index 8ebfb7f..7f8e428 100644 --- a/django_gurps/views.py +++ b/django_gurps/views.py @@ -1 +1,2 @@ def logout(request): + pass diff --git a/gurps_character/TestData/characters.py b/gurps_character/TestData/characters.py new file mode 100644 index 0000000..d501fe7 --- /dev/null +++ b/gurps_character/TestData/characters.py @@ -0,0 +1,19 @@ +from django.contrib.auth.models import User + + +def create_users(): + User.objects.create( + username="neill", + is_superuser=True, + first_name="Neill", + last_name="Cox", + email="neill@neill.id.au", + is_staff=True, + is_active=True, + date_joined="2024-07-31T00:00:00.000Z", + + ) + + +if __name__ == "__main__": + create_users() diff --git a/gurps_character/__pycache__/admin.cpython-312.pyc b/gurps_character/__pycache__/admin.cpython-312.pyc deleted file mode 100644 index 32c2897..0000000 Binary files a/gurps_character/__pycache__/admin.cpython-312.pyc and /dev/null differ diff --git a/gurps_character/__pycache__/models.cpython-312.pyc b/gurps_character/__pycache__/models.cpython-312.pyc deleted file mode 100644 index 30c54f8..0000000 Binary files a/gurps_character/__pycache__/models.cpython-312.pyc and /dev/null differ diff --git a/gurps_character/__pycache__/urls.cpython-312.pyc b/gurps_character/__pycache__/urls.cpython-312.pyc deleted file mode 100644 index 39ad717..0000000 Binary files a/gurps_character/__pycache__/urls.cpython-312.pyc and /dev/null differ diff --git a/gurps_character/__pycache__/views.cpython-312.pyc b/gurps_character/__pycache__/views.cpython-312.pyc deleted file mode 100644 index 1d91d59..0000000 Binary files a/gurps_character/__pycache__/views.cpython-312.pyc and /dev/null differ diff --git a/gurps_character/admin.py b/gurps_character/admin.py index 8c7741d..bf5197e 100644 --- a/gurps_character/admin.py +++ b/gurps_character/admin.py @@ -1,7 +1,8 @@ from django.contrib import admin # Register your models here. -from .models import GURPSCharacter, GameSystem +from .models import GURPSCharacter, GameSystem, Campaign admin.site.register(GURPSCharacter) admin.site.register(GameSystem) +admin.site.register(Campaign) diff --git a/theme/__init__.py b/gurps_character/management/__init__.py similarity index 100% rename from theme/__init__.py rename to gurps_character/management/__init__.py diff --git a/gurps_character/management/commands/__init__.py b/gurps_character/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gurps_character/management/commands/clear_data.py b/gurps_character/management/commands/clear_data.py new file mode 100644 index 0000000..358f7c7 --- /dev/null +++ b/gurps_character/management/commands/clear_data.py @@ -0,0 +1,24 @@ +from django.contrib.auth.models import User +from django.core.management import BaseCommand + + +def create_users(): + user = User.objects.create_user( + username="neill", + is_superuser=True, + first_name="Neill", + last_name="Cox", + email="neill@neill.id.au", + is_staff=True, + is_active=True, + date_joined="2024-07-31T00:00:00.000Z", + password="password", + ) + # user.save() + + +class Command(BaseCommand): + help = "Load some initial data" + + def handle(self, *args, **options): + create_users() diff --git a/gurps_character/management/commands/load_data.py b/gurps_character/management/commands/load_data.py new file mode 100644 index 0000000..358f7c7 --- /dev/null +++ b/gurps_character/management/commands/load_data.py @@ -0,0 +1,24 @@ +from django.contrib.auth.models import User +from django.core.management import BaseCommand + + +def create_users(): + user = User.objects.create_user( + username="neill", + is_superuser=True, + first_name="Neill", + last_name="Cox", + email="neill@neill.id.au", + is_staff=True, + is_active=True, + date_joined="2024-07-31T00:00:00.000Z", + password="password", + ) + # user.save() + + +class Command(BaseCommand): + help = "Load some initial data" + + def handle(self, *args, **options): + create_users() diff --git a/gurps_character/migrations/0004_gurpscharacter_player_campaign_and_more.py b/gurps_character/migrations/0004_gurpscharacter_player_campaign_and_more.py new file mode 100644 index 0000000..e89b49f --- /dev/null +++ b/gurps_character/migrations/0004_gurpscharacter_player_campaign_and_more.py @@ -0,0 +1,57 @@ +# Generated by Django 5.0.6 on 2024-07-14 09:14 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("gurps_character", "0003_gamesystem"), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.AddField( + model_name="gurpscharacter", + name="player", + field=models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + to=settings.AUTH_USER_MODEL, + ), + ), + migrations.CreateModel( + name="Campaign", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=255, unique=True)), + ("description", models.TextField(null=True)), + ( + "game_system", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="gurps_character.gamesystem", + ), + ), + ], + ), + migrations.AddField( + model_name="gurpscharacter", + name="campaign", + field=models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="gurps_character.campaign", + ), + ), + ] diff --git a/gurps_character/migrations/0005_campaign_gm.py b/gurps_character/migrations/0005_campaign_gm.py new file mode 100644 index 0000000..c9d8a19 --- /dev/null +++ b/gurps_character/migrations/0005_campaign_gm.py @@ -0,0 +1,20 @@ +# Generated by Django 5.0.6 on 2024-07-14 09:25 + +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("gurps_character", "0004_gurpscharacter_player_campaign_and_more"), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.AddField( + model_name="campaign", + name="gm", + field=models.ManyToManyField(to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/gurps_character/models.py b/gurps_character/models.py index cb70807..8b04fe6 100644 --- a/gurps_character/models.py +++ b/gurps_character/models.py @@ -1,49 +1,83 @@ from django.db import models - +from django.contrib.auth.models import User # Create your models here. + class GameSystem(models.Model): name = models.CharField(max_length=255, unique=True) description = models.TextField(null=True) + def __str__(self): + return self.name + + +class GM(models.Model): + gm = models.ForeignKey(User, on_delete=models.CASCADE) + campaign = models.ForeignKey("Campaign", null=True, on_delete=models.CASCADE, related_name='campaign') + + +class Player(models.Model): + user = models.OneToOneField(User, on_delete=models.CASCADE) + status = models.CharField(max_length=255, unique=True) + +# +# class Players(models.Model): +# player = models.ForeignKey(User, on_delete=models.CASCADE) +# status = models.CharField(max_length=255, unique=True) + + +class Campaign(models.Model): + name = models.CharField(max_length=255, unique=True) + description = models.TextField(null=True) + game_system = models.ForeignKey(GameSystem, on_delete=models.CASCADE) + gm = models.ManyToManyField('GM', related_name='GM') + player = models.ManyToManyField('Player') + + def __str__(self): + return self.name class GURPSCharacter(models.Model): uuid = models.CharField(max_length=128, unique=True) name = models.CharField(max_length=255, unique=True) + player = models.ForeignKey(Player, null=True, on_delete=models.CASCADE) + campaign = models.ForeignKey(Campaign, null=True, on_delete=models.CASCADE) details = models.JSONField() # owner => user # campaign => campaign + def __str__(self): + return self.name + " Player " + str(self.player) + " Campaign " + str(self.campaign) + def adv_points(self): - return sum([ a['calc']['points'] for a in self.details.get('advantages',[]) if a['calc']['points'] > 0 ]) + return sum([a['calc']['points'] for a in self.details.get('advantages', []) if a['calc']['points'] > 0]) def disadv_points(self): - return sum([ a['calc']['points'] for a in self.details.get('advantages', []) if a['calc']['points'] < -1 ]) + return sum([a['calc']['points'] for a in self.details.get('advantages', []) if a['calc']['points'] < -1]) def quirks_points(self): - return sum([ a['calc']['points'] for a in self.details.get('advantages',[]) if a['calc']['points'] == -1 ]) + return sum([a['calc']['points'] for a in self.details.get('advantages', []) if a['calc']['points'] == -1]) def attr_points(self): - return sum([ a['calc']['points'] for a in self.details['attributes'] ]) + return sum([a['calc']['points'] for a in self.details['attributes']]) def skills_points(self): - return sum([ s['points'] for s in self.details.get('skills',[]) ]) + return sum([s['points'] for s in self.details.get('skills', [])]) def spells_points(self): - return 0 + return sum([s['points'] for s in self.details.get('spells', [])]) def race_points(self): - return 0 + return sum([s['points'] for s in self.details.get('race', [])]) # Are we sure? def unspent_points(self): - return self.details['total_points'] - self.adv_points() - \ + return self.details['total_points'] - self.adv_points() - \ self.disadv_points() - self.attr_points() - \ self.skills_points() - self.spells_points() - \ self.race_points() - self.quirks_points() def get_primary_attr(self, attr_id): - return [ a['calc'] for a in self.details['attributes'] if a['attr_id'] == attr_id ][0] + return [a['calc'] for a in self.details['attributes'] if a['attr_id'] == attr_id][0] def st(self): return self.get_primary_attr('st') @@ -91,7 +125,7 @@ class GURPSCharacter(models.Model): return self.get_primary_attr('fp') def weight_carried(self): - items = [ i['calc']['extended_weight'] for i in self.details['equipment'] ] + items = [i['calc']['extended_weight'] for i in self.details['equipment']] total_weight = 0 for i in items: @@ -116,11 +150,36 @@ class GURPSCharacter(models.Model): dodge = self.details["calc"]["dodge"][0] basic_move = self.basic_move()["value"] return [ - { "max_load": round(self.basic_lift()), "move": basic_move, "dodge": dodge, "current": "current" * (enc_level == 0) }, - { "max_load": round(self.basic_lift()) * 2, "move": basic_move -2, "dodge": dodge -1, "current": "current" * (enc_level == 1) }, - { "max_load": round(self.basic_lift()) * 3, "move": basic_move -3, "dodge": dodge -2, "current": "current" * (enc_level == 2) }, - { "max_load": round(self.basic_lift()) * 6, "move": basic_move -4, "dodge": dodge -3, "current": "current" * (enc_level == 3) }, - { "max_load": round(self.basic_lift()) * 10, "move": basic_move -5, "dodge": dodge -4, "current": "current" * (enc_level == 4) }, + { + "max_load": round(self.basic_lift()), + "move": basic_move, + "dodge": dodge, + "current": "current" * (enc_level == 0) + }, + { + "max_load": round(self.basic_lift()) * 2, + "move": basic_move - 2, + "dodge": dodge - 1, + "current": "current" * (enc_level == 1) + }, + { + "max_load": round(self.basic_lift()) * 3, + "move": basic_move - 3, + "dodge": dodge - 2, + "current": "current" * (enc_level == 2) + }, + { + "max_load": round(self.basic_lift()) * 6, + "move": basic_move - 4, + "dodge": dodge - 3, + "current": "current" * (enc_level == 3) + }, + { + "max_load": round(self.basic_lift()) * 10, + "move": basic_move - 5, + "dodge": dodge - 4, + "current": "current" * (enc_level == 4) + }, ] def basic_lift(self): @@ -131,25 +190,26 @@ class GURPSCharacter(models.Model): def lift_table(self): return [ - {"value": round(self.basic_lift()), "label":"Basic Lift"}, - {"value": round(self.basic_lift()) * 2, "label": "One-Handed Lift" }, - {"value": round(self.basic_lift()) * 8, "label":"Two-Handed Lift"}, - {"value": round(self.basic_lift()) * 12, "label":"Shove &ersand; Knock Over"}, - {"value": round(self.basic_lift()) * 24, "label":"Running Shove & Knock Over"}, - {"value": round(self.basic_lift()) * 15, "label":"Carry on Back"}, - {"value": round(self.basic_lift()) * 50, "label":"Shift Slightly"}, + {"value": round(self.basic_lift()), "label": "Basic Lift"}, + {"value": round(self.basic_lift()) * 2, "label": "One-Handed Lift"}, + {"value": round(self.basic_lift()) * 8, "label": "Two-Handed Lift"}, + {"value": round(self.basic_lift()) * 12, "label": "Shove &ersand; Knock Over"}, + {"value": round(self.basic_lift()) * 24, "label": "Running Shove & Knock Over"}, + {"value": round(self.basic_lift()) * 15, "label": "Carry on Back"}, + {"value": round(self.basic_lift()) * 50, "label": "Shift Slightly"}, ] def reaction_modifiers(self): modifiers = [] - for a in self.details.get('advantages',[]): + for a in self.details.get('advantages', []): if "features" in a: for f in a["features"]: if f["type"] == "reaction_bonus": modifiers.append(f) return modifiers + def conditional_modifiers(self): modifiers = [] @@ -162,10 +222,10 @@ class GURPSCharacter(models.Model): return modifiers def weapons(self): - return [ w for w in self.details['equipment'] if "weapons" in w] + \ - [ a for a in self.details.get("advantages",[]) if "weapons" in a ] + \ - [ a for a in self.details.get("traits",[]) if "weapons" in a ] + \ - [ s for s in self.details.get("spells", []) if "weapons" in s ] + return [w for w in self.details['equipment'] if "weapons" in w] + \ + [a for a in self.details.get("advantages", []) if "weapons" in a] + \ + [a for a in self.details.get("traits", []) if "weapons" in a] + \ + [s for s in self.details.get("spells", []) if "weapons" in s] def melee_weapons(self): mw = [] @@ -178,14 +238,14 @@ class GURPSCharacter(models.Model): name = item["name"] mw.append( { - "name":name, + "name": name, "usage": weapon["usage"], - "skill_level":weapon["calc"].get("level", 0), - "parry":weapon["calc"].get("parry", "No"), - "block":weapon["calc"].get("block", "No"), - "damage":weapon["calc"]["damage"], - "reach":weapon["calc"].get("reach", ""), - "strength":weapon.get("strength", " ") + "skill_level": weapon["calc"].get("level", 0), + "parry": weapon["calc"].get("parry", "No"), + "block": weapon["calc"].get("block", "No"), + "damage": weapon["calc"]["damage"], + "reach": weapon["calc"].get("reach", ""), + "strength": weapon.get("strength", " ") } ) @@ -207,7 +267,6 @@ class GURPSCharacter(models.Model): else: return wpn_range - rw = [] for item in self.weapons(): for weapon in item["weapons"]: @@ -218,13 +277,13 @@ class GURPSCharacter(models.Model): name = item["name"] rw.append( { - "name":name, + "name": name, "bulk": weapon.get("bulk", " "), "usage": weapon.get("usage", " "), - "skill_level":weapon["calc"]["level"], - "damage":weapon["calc"]["damage"], - "strength":weapon.get("strength", " "), - "acc":weapon.get("accuracy", 0), + "skill_level": weapon["calc"]["level"], + "damage": weapon["calc"]["damage"], + "strength": weapon.get("strength", " "), + "acc": weapon.get("accuracy", 0), "range": muscle_range(weapon.get("range", " ")), "rof": weapon.get("rate_of_fire", " "), "shots": weapon.get("shots", " "), @@ -236,12 +295,12 @@ class GURPSCharacter(models.Model): def traits(self): traits = [] - for advantage in self.details.get("advantages",[]): + for advantage in self.details.get("advantages", []): cost = advantage["calc"]["points"] name = advantage["name"] if "categories" in advantage and "Language" in advantage["categories"]: - levels = [ m for m in advantage['modifiers'] if "disabled" not in m ] + levels = [m for m in advantage['modifiers'] if "disabled" not in m] notes = "" for level in levels: @@ -256,24 +315,24 @@ class GURPSCharacter(models.Model): elif "notes" in advantage: notes = advantage["notes"] elif "modifiers" in advantage: - notes = [ m for m in advantage['modifiers'] if m["cost"] == cost ][0]["name"] + notes = [m for m in advantage['modifiers'] if m["cost"] == cost][0]["name"] else: notes = "" - traits.append({"name":name, "notes":notes, "points":cost, "reference":advantage["reference"]}) + traits.append({"name": name, "notes": notes, "points": cost, "reference": advantage["reference"]}) return traits def spells(self): - def get_casting_details(spell): - level = spell['calc']['level'] + def get_casting_details(spell_details): + level = spell_details['calc']['level'] if level < 10: descr = ( "Ritual: Need both hands and both feet " "free, and must speak .Time: 2x." ) - elif level <15: + elif level < 15: descr = ( "Ritual: Must speak a few quiet words " "and make a gesture." @@ -287,13 +346,13 @@ class GURPSCharacter(models.Model): elif level < 25: descr = "Ritual: None. Time: / 2 (round up). Cost: -2." elif level < 30: - descr = ( + descr = ( "Ritual: None. Time: / 4 (round up). Cost: -3." ) else: delta = int((level - 25) / 5) power = 2 + delta - divisor = 2**power + # divisor = 2**power cost = 3 + delta descr = ( f"Ritual: None. Time: / {power} round up. Cost: " @@ -302,56 +361,62 @@ class GURPSCharacter(models.Model): return descr - spells = [] - for spell in self.details.get('spells',[]): + for spell in self.details.get('spells', []): notes = ( f"{get_casting_details(spell)}
Class: {spell['spell_class']}; " - f"Cost: {spell['casting_cost']}; Maintain: {spell['maintenance_cost']}; Time: {spell['casting_time']}; Duration: {spell['duration']}; " + f"Cost: {spell['casting_cost']}; Maintain: {spell['maintenance_cost']};" + f" Time: {spell['casting_time']}; Duration: {spell['duration']}; " ) spells.append( { 'name': spell["name"], - "college":", ".join(spell["college"]), + "college": ", ".join(spell["college"]), "level": spell["calc"]["level"], - "rsl":spell["calc"]["rsl"], - "points":spell["points"], - "reference":spell["reference"], - "notes":notes + "rsl": spell["calc"]["rsl"], + "points": spell["points"], + "reference": spell["reference"], + "notes": notes } ) return spells def skills(self): skills = [] - for skill in self.details.get('skills',[]): - skills.append({'name': skill["name"], "level": skill["calc"]["level"], "rsl":skill["calc"]["rsl"], "points":skill["points"], "reference":skill["reference"] }) + for skill in self.details.get('skills', []): + skills.append({ + 'name': skill["name"], + "level": skill["calc"]["level"], + "rsl": skill["calc"]["rsl"], + "points": skill["points"], + "reference": skill["reference"] + }) return skills def equipment(self): def get_children(parent, level=1): children = [] - for item in parent["children"]: - equipment = { - "name": item["description"], - "uses":"", - "tech_level":item["tech_level"], - "lc":"", - "value":item["value"], - "weight":item["weight"], - "quantity":item.get("quantity",1), - "ref":item["reference"], - "ext_weight": item["calc"]["extended_weight"], - "ext_value": item["calc"]["extended_value"], - "notes": item.get("notes",""), - "equipped": item["equipped"], + for item_details in parent["children"]: + equipment_details = { + "name": item_details["description"], + "uses": "", + "tech_level": item_details["tech_level"], + "lc": "", + "value": item_details["value"], + "weight": item_details["weight"], + "quantity": item_details.get("quantity", 1), + "ref": item_details["reference"], + "ext_weight": item_details["calc"]["extended_weight"], + "ext_value": item_details["calc"]["extended_value"], + "notes": item_details.get("notes", ""), + "equipped": item_details["equipped"], "level": level } - children.append(equipment) + children.append(equipment_details) - if "children" in item: - children += get_children(item, level +1) + if "children" in item_details: + children += get_children(item_details, level + 1) return children equipment = self.details['equipment'] @@ -361,17 +426,17 @@ class GURPSCharacter(models.Model): equipment_list.append( { "name": item["description"], - "uses":"", - "tech_level":item["tech_level"], - "lc":"", + "uses": "", + "tech_level": item["tech_level"], + "lc": "", "level": 0, - "value":item["value"], - "weight":item["weight"], - "quantity":item.get("quantity",1), - "ref":item.get("reference",""), + "value": item["value"], + "weight": item["weight"], + "quantity": item.get("quantity", 1), + "ref": item.get("reference", ""), "ext_weight": item["calc"]["extended_weight"], "ext_value": item["calc"]["extended_value"], - "notes": item.get("notes",""), + "notes": item.get("notes", ""), "equipped": item["equipped"] } ) @@ -388,4 +453,3 @@ class GURPSCharacter(models.Model): except KeyError: # v4 return self.details["settings"]["body_type"]["locations"] - diff --git a/gurps_character/templates/allauth/layouts/base.html b/gurps_character/templates/allauth/layouts/base.html new file mode 100644 index 0000000..472583e --- /dev/null +++ b/gurps_character/templates/allauth/layouts/base.html @@ -0,0 +1,89 @@ +{% load i18n %} +{% load bootstrap_icons %} + + + + + + + {% block head_title %} + {% endblock head_title %} + + {% block extra_head %} + {% endblock extra_head %} + + + +... + + + {% block body %} + {% include "navbar.html" %} + {% if messages %} +
+ {% trans "Messages:" %} + +
+ {% endif %} +
+
+ Modified template + {% trans "Menu:" %} + + {% block content %} + {% endblock content %} +
+
+ {% endblock body %} + {% block extra_body %} + {% endblock extra_body %} + + diff --git a/theme/templates/base.html b/gurps_character/templates/base.html similarity index 100% rename from theme/templates/base.html rename to gurps_character/templates/base.html diff --git a/gurps_character/templates/home.html b/gurps_character/templates/home.html index f10f8d5..9668191 100644 --- a/gurps_character/templates/home.html +++ b/gurps_character/templates/home.html @@ -1,8 +1,37 @@ {% extends "base.html" %} +{% load bootstrap_icons %} {% block content %} -

Welcome to the character store

+

Welcome to the character store

- +

This is a webapp for storing characters.

+ + {% if user.is_authenticated %} +

Welcome {% if user.first_name %}{{ user.first_name }}{% else %}{{ user.username }}{% endif %}

+ + {% if user.campaign_set.all %} +

Campaigns you run

+ + {% endif %} + +

Characters you play

+ + {% else %} +

Please sign in to see your characters and campaigns

+ {% endif %} + Add a character? -

Currently it works with GURPS, specifically characters created by GCS

{% endblock %} diff --git a/gurps_character/templates/navbar.html b/gurps_character/templates/navbar.html index 3e018b3..fb7425e 100644 --- a/gurps_character/templates/navbar.html +++ b/gurps_character/templates/navbar.html @@ -1,17 +1,18 @@