Skip to content

Commit

Permalink
maintainers display in edit collection url
Browse files Browse the repository at this point in the history
  • Loading branch information
quimmrc committed Feb 3, 2025
1 parent d5fed09 commit 04ba23d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 7 additions & 6 deletions fscollections/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#

from django import forms
from django.forms import ModelForm, Textarea, TextInput
from django.forms import ModelForm, Textarea, TextInput, SelectMultiple
from fscollections.models import Collection, CollectionSound
from utils.forms import HtmlCleaningCharField

Expand Down Expand Up @@ -104,24 +104,25 @@ def clean(self):

class CollectionEditForm(forms.ModelForm):

# description = HtmlCleaningCharField(widget=forms.Textarea(attrs={'cols': 80, 'rows': 10}),
# help_text=HtmlCleaningCharField.make_help_text(), required=False)

class Meta():
model = Collection
fields = ('name', 'description',)
fields = ('name', 'description','maintainers')
widgets = {
'name': TextInput(),
'description': Textarea(attrs={'rows': 5, 'cols': 50})
'description': Textarea(attrs={'rows': 5, 'cols': 50}),
'maintainers': forms.CheckboxSelectMultiple()
}

def __init__(self, *args, **kwargs):
is_owner = kwargs.pop('is_owner', True)
super().__init__(*args, **kwargs)
self.fields['maintainers'].queryset = self.instance.maintainers.all().values_list('username', flat=True)

if not is_owner:
for field in self.fields:
self.fields[field].widget.attrs['readonly'] = 'readonly'


class CollectionMaintainerForm(forms.Form):
collection = forms.ChoiceField(
label=False,
Expand Down
8 changes: 8 additions & 0 deletions templates/collections/edit_collection.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ <h2 class="v-spacing-3">{{ collection.name }}</h2>
{{ form.description.errors }}
{{ form.description.label_tag }}
{{ form.description }}
{% for maintainer in form.maintainers%}
<div class="checkbox-item">
<label class="username" style="display: flex;align-items: center;">
{{ maintainer.choice_label }}
{{ maintainer.tag }}
</label>
</div>
{% endfor %}
<!--<span class="helptext">{{ form.description.help_text|safe }}</span>-->
<!--<div class="select-sounds-field v-spacing-5">
{{ form.pack_sounds }}
Expand Down

0 comments on commit 04ba23d

Please sign in to comment.