mirror of
https://github.com/Crocmagnon/charasheet.git
synced 2024-11-22 22:48:03 +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 = [
|
fieldsets = [
|
||||||
(
|
(
|
||||||
"Identité",
|
"Identité",
|
||||||
{"fields": ["name", "player", "profile", "level", "race"]},
|
{"fields": ["name", "player", "profile", "level", "race", "private"]},
|
||||||
),
|
),
|
||||||
("Apparence", {"fields": ["gender", "age", "height", "weight"]}),
|
("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")
|
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)()
|
objects = CharacterManager.from_queryset(CharacterQuerySet)()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
|
|
||||||
|
from character.models import Character
|
||||||
from party.models import Party
|
from party.models import Party
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,6 +9,10 @@ class PartyForm(forms.ModelForm):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.original_instance = kwargs.get("instance")
|
self.original_instance = kwargs.get("instance")
|
||||||
super().__init__(*args, **kwargs)
|
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:
|
class Meta:
|
||||||
model = Party
|
model = Party
|
||||||
|
|
Loading…
Reference in a new issue