mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-05 06:13:55 +01:00
Add private profile
This commit is contained in:
parent
35205a9524
commit
ee2caf8a2f
5 changed files with 37 additions and 2 deletions
|
@ -119,7 +119,7 @@ class CharacterAdmin(admin.ModelAdmin):
|
|||
fieldsets = [
|
||||
(
|
||||
"Identité",
|
||||
{"fields": ["name", "player", "profile", "level", "race"]},
|
||||
{"fields": ["name", "player", "profile", "level", "race", "private"]},
|
||||
),
|
||||
("Apparence", {"fields": ["gender", "age", "height", "weight"]}),
|
||||
(
|
||||
|
|
23
src/character/migrations/0037_character_private.py
Normal file
23
src/character/migrations/0037_character_private.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 4.1.2 on 2022-11-09 17:13
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("character", "0036_delete_party"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="character",
|
||||
name="private",
|
||||
field=models.BooleanField(
|
||||
blank=True,
|
||||
default=False,
|
||||
help_text="Empêche toute invitation dans un groupe.",
|
||||
verbose_name="privé",
|
||||
),
|
||||
),
|
||||
]
|
|
@ -1 +1 @@
|
|||
0036_delete_party
|
||||
0037_character_private
|
||||
|
|
|
@ -202,6 +202,13 @@ class Character(models.Model):
|
|||
|
||||
states = models.ManyToManyField(HarmfulState, blank=True, related_name="characters")
|
||||
|
||||
private = models.BooleanField(
|
||||
"privé",
|
||||
help_text="Empêche toute invitation dans un groupe.",
|
||||
default=False,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
objects = CharacterManager.from_queryset(CharacterQuerySet)()
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from django import forms
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
from character.models import Character
|
||||
from party.models import Party
|
||||
|
||||
|
||||
|
@ -8,6 +9,10 @@ class PartyForm(forms.ModelForm):
|
|||
def __init__(self, *args, **kwargs):
|
||||
self.original_instance = kwargs.get("instance")
|
||||
super().__init__(*args, **kwargs)
|
||||
qs = Character.objects.filter(private=False)
|
||||
if self.original_instance:
|
||||
qs = qs.union(self.original_instance.invited_characters.all())
|
||||
self.fields["invited_characters"].queryset = qs
|
||||
|
||||
class Meta:
|
||||
model = Party
|
||||
|
|
Loading…
Reference in a new issue