Piki is a minimal wiki
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

forms.py 1.5KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from django import forms
  2. from django.contrib.auth.models import Group
  3. from .models import PikiPage
  4. class EditForm(forms.ModelForm):
  5. class Meta:
  6. model = PikiPage
  7. fields = [
  8. "page_txt",
  9. "tags",
  10. "owner", "owner_perms_read", "owner_perms_write",
  11. "group", "group_perms_read", "group_perms_write",
  12. "other_perms_read", "other_perms_write",]
  13. class GroupForm(forms.Form):
  14. group = forms.ModelChoiceField(queryset=Group.objects.all(), required=False)
  15. class PermForm(forms.Form):
  16. owner_perms_read = forms.BooleanField(initial=True, required=False, label="Read (owner)")
  17. owner_perms_write = forms.BooleanField(initial=True, required=False, label="Write (owner)")
  18. group_perms_read = forms.BooleanField(initial=True, required=False, label="Read (group)")
  19. group_perms_write = forms.BooleanField(initial=True, required=False, label="Write (group)")
  20. other_perms_read = forms.BooleanField(initial=True, required=False, label="Read (other)")
  21. other_perms_write = forms.BooleanField(initial=False, required=False, label="Write (other)")
  22. class RenameForm(forms.Form): # Note that it is not inheriting from forms.ModelForm
  23. page_name = forms.CharField(max_length=500, label="Change the page name:", required=True)
  24. def __init__(self, *args, **kwargs) -> None:
  25. page_name = kwargs.pop("page_name")
  26. super().__init__(*args, **kwargs)
  27. self.fields['page_name'].initial = page_name