mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-22 06:28:03 +01:00
Add link to CO website
This commit is contained in:
parent
e3522a9d61
commit
9471b8c70b
12 changed files with 107 additions and 9 deletions
|
@ -8,6 +8,13 @@ class CapabilityAdmin(admin.ModelAdmin):
|
|||
list_display = ["name", "path", "rank", "limited", "spell"]
|
||||
list_filter = ["path", "path__profile", "path__race", "rank", "limited", "spell"]
|
||||
search_fields = ["name", "description"]
|
||||
fieldsets = [
|
||||
(None, {"fields": ["name"]}),
|
||||
("Path", {"fields": [("path", "rank")]}),
|
||||
("Type", {"fields": [("limited", "spell")]}),
|
||||
("Description", {"fields": ["description"]}),
|
||||
("Documentation", {"fields": ["url"]}),
|
||||
]
|
||||
|
||||
|
||||
@admin.register(models.Path)
|
||||
|
@ -19,6 +26,7 @@ class PathAdmin(admin.ModelAdmin):
|
|||
(None, {"fields": ["name"]}),
|
||||
("Related to", {"fields": ["category", ("profile", "race")]}),
|
||||
("Notes", {"fields": ["notes"]}),
|
||||
("Documentation", {"fields": ["url"]}),
|
||||
]
|
||||
|
||||
def related_to(self, instance: models.Path) -> str:
|
||||
|
@ -50,6 +58,11 @@ class ProfileAdmin(admin.ModelAdmin):
|
|||
list_filter = ["life_dice", "magical_strength"]
|
||||
search_fields = ["name"]
|
||||
inlines = [PathInline]
|
||||
fieldsets = [
|
||||
(None, {"fields": ["name", ("magical_strength", "life_dice")]}),
|
||||
("Notes", {"fields": ["notes"]}),
|
||||
("Documentation", {"fields": ["url"]}),
|
||||
]
|
||||
|
||||
|
||||
class RacialCapabilityInline(admin.TabularInline):
|
||||
|
|
|
@ -52,6 +52,7 @@ class Command(BaseCommand):
|
|||
"path": path,
|
||||
"limited": limited,
|
||||
"spell": spell,
|
||||
"url": "https://www.co-drs.org/fr/jeu/capacites",
|
||||
},
|
||||
)
|
||||
self.stdout.write(self.style.SUCCESS(f"Created/updated cap {capability}"))
|
||||
|
|
|
@ -48,6 +48,7 @@ class Command(BaseCommand):
|
|||
"profile": profile,
|
||||
"race": race,
|
||||
"notes": notes,
|
||||
"url": url,
|
||||
},
|
||||
)
|
||||
self.stdout.write(self.style.SUCCESS(f"Created/updated path {path}"))
|
||||
|
|
|
@ -32,6 +32,7 @@ class Command(BaseCommand):
|
|||
"life_dice": dice,
|
||||
"magical_strength": magical_strength,
|
||||
"notes": notes,
|
||||
"url": url,
|
||||
},
|
||||
)
|
||||
self.stdout.write(self.style.SUCCESS(f"Created/updated profile {profile}"))
|
||||
|
|
|
@ -23,7 +23,7 @@ class Command(BaseCommand):
|
|||
self.selenium.get(url)
|
||||
name = self.selenium.find_element(By.TAG_NAME, "h1").text.strip()
|
||||
name = self.fix_name(name)
|
||||
race, _ = Race.objects.update_or_create(name=name, defaults={})
|
||||
race, _ = Race.objects.update_or_create(name=name, defaults={"url": url})
|
||||
self.stdout.write(self.style.SUCCESS(f"Created/updated race {race}"))
|
||||
|
||||
def fix_name(self, name: str) -> str:
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
# Generated by Django 4.1.2 on 2022-10-30 08:34
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("character", "0007_alter_capability_limited_alter_capability_spell"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="capability",
|
||||
name="url",
|
||||
field=models.URLField(blank=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="path",
|
||||
name="url",
|
||||
field=models.URLField(blank=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="profile",
|
||||
name="url",
|
||||
field=models.URLField(blank=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="race",
|
||||
name="url",
|
||||
field=models.URLField(blank=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="racialcapability",
|
||||
name="url",
|
||||
field=models.URLField(blank=True),
|
||||
),
|
||||
]
|
17
src/character/migrations/0009_remove_racialcapability_url.py
Normal file
17
src/character/migrations/0009_remove_racialcapability_url.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 4.1.2 on 2022-10-30 08:43
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("character", "0008_capability_url_path_url_profile_url_race_url_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name="racialcapability",
|
||||
name="url",
|
||||
),
|
||||
]
|
18
src/character/migrations/0010_racialcapability_url.py
Normal file
18
src/character/migrations/0010_racialcapability_url.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 4.1.2 on 2022-10-30 08:44
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("character", "0009_remove_racialcapability_url"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="racialcapability",
|
||||
name="url",
|
||||
field=models.URLField(blank=True),
|
||||
),
|
||||
]
|
|
@ -1 +1 @@
|
|||
0007_alter_capability_limited_alter_capability_spell
|
||||
0010_racialcapability_url
|
||||
|
|
|
@ -2,10 +2,10 @@ from django.core.validators import MaxValueValidator, MinValueValidator
|
|||
from django.db import models
|
||||
from django_extensions.db.models import TimeStampedModel
|
||||
|
||||
from common.models import UniquelyNamedModel
|
||||
from common.models import DocumentedModel, UniquelyNamedModel
|
||||
|
||||
|
||||
class Path(UniquelyNamedModel, TimeStampedModel, models.Model):
|
||||
class Path(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model):
|
||||
profile = models.ForeignKey(
|
||||
"character.Profile",
|
||||
on_delete=models.CASCADE,
|
||||
|
@ -31,7 +31,7 @@ class Path(UniquelyNamedModel, TimeStampedModel, models.Model):
|
|||
notes = models.TextField(blank=True)
|
||||
|
||||
|
||||
class Capability(UniquelyNamedModel, TimeStampedModel, models.Model):
|
||||
class Capability(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model):
|
||||
path = models.ForeignKey("character.Path", on_delete=models.CASCADE)
|
||||
rank = models.PositiveSmallIntegerField(
|
||||
validators=[MinValueValidator(1), MaxValueValidator(5)]
|
||||
|
@ -45,7 +45,9 @@ class Capability(UniquelyNamedModel, TimeStampedModel, models.Model):
|
|||
verbose_name_plural = "Capabilities"
|
||||
|
||||
|
||||
class RacialCapability(UniquelyNamedModel, TimeStampedModel, models.Model):
|
||||
class RacialCapability(
|
||||
DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model
|
||||
):
|
||||
race = models.ForeignKey("character.Race", on_delete=models.CASCADE)
|
||||
description = models.TextField()
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@ from django.db.models.functions import Lower
|
|||
from django_extensions.db.models import TimeStampedModel
|
||||
|
||||
from character.models.dice import Dice
|
||||
from common.models import UniquelyNamedModel
|
||||
from common.models import DocumentedModel, UniquelyNamedModel
|
||||
|
||||
|
||||
class Profile(UniquelyNamedModel, TimeStampedModel, models.Model):
|
||||
class Profile(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model):
|
||||
class MagicalStrength(models.TextChoices):
|
||||
NONE = "NON", "None"
|
||||
INTELLIGENCE = "INT", "Intelligence"
|
||||
|
@ -20,7 +20,7 @@ class Profile(UniquelyNamedModel, TimeStampedModel, models.Model):
|
|||
notes = models.TextField(blank=True)
|
||||
|
||||
|
||||
class Race(UniquelyNamedModel, TimeStampedModel, models.Model):
|
||||
class Race(DocumentedModel, UniquelyNamedModel, TimeStampedModel, models.Model):
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -25,3 +25,10 @@ class UniquelyNamedModel(models.Model):
|
|||
|
||||
def natural_key(self):
|
||||
return (self.name,)
|
||||
|
||||
|
||||
class DocumentedModel(models.Model):
|
||||
url = models.URLField(blank=True, null=False)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
|
Loading…
Reference in a new issue