Skip to content

Commit

Permalink
Déplace le formulaire relatif à l'aide avec sa vue
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud-D committed Mar 9, 2024
1 parent fc6c873 commit e6de79d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
13 changes: 0 additions & 13 deletions zds/tutorialv2/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from zds.utils.forms import CommonLayoutEditor, CommonLayoutVersionEditor
from zds.utils.models import SubCategory
from zds.tutorialv2.models import TYPE_CHOICES
from zds.tutorialv2.models.help_requests import HelpWriting
from zds.tutorialv2.models.database import PublishableContent
from django.utils.translation import gettext_lazy as _
from zds.member.models import Profile
Expand Down Expand Up @@ -1126,15 +1125,3 @@ def clean(self):
raise forms.ValidationError(_("Vous devez choisir des URL a comparer"))
if len(urls) < 2:
raise forms.ValidationError(_("Il faut au minimum 2 urls à comparer"))


class ToggleHelpForm(forms.Form):
help_wanted = forms.CharField()
activated = forms.BooleanField(required=False)

def clean(self):
clean_data = super().clean()
clean_data["help_wanted"] = HelpWriting.objects.filter(title=(self.data["help_wanted"] or "").strip()).first()
if not clean_data["help_wanted"]:
self.add_error("help_wanted", _("Inconnu"))
return clean_data
14 changes: 13 additions & 1 deletion zds/tutorialv2/views/help.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import json

from django import forms
from django.conf import settings
from django.db.models import Count, Q
from django.http import HttpResponse, JsonResponse
from django.utils.translation import gettext_lazy as _

from zds.member.decorator import LoggedWithReadWriteHability
from zds.tutorialv2 import signals
from zds.tutorialv2.forms import ToggleHelpForm
from zds.tutorialv2.mixins import SingleContentFormViewMixin

from zds.tutorialv2.models.database import PublishableContent
Expand All @@ -16,6 +16,18 @@
from zds.utils.paginator import ZdSPagingListView


class ToggleHelpForm(forms.Form):
help_wanted = forms.CharField()
activated = forms.BooleanField(required=False)

def clean(self):
clean_data = super().clean()
clean_data["help_wanted"] = HelpWriting.objects.filter(title=(self.data["help_wanted"] or "").strip()).first()
if not clean_data["help_wanted"]:
self.add_error("help_wanted", _("Inconnu"))
return clean_data


class ContentsWithHelps(ZdSPagingListView):
"""List all tutorial that needs help, i.e registered as needing at least one HelpWriting or is in beta
for more documentation, have a look to ZEP 03 specification (fr)"""
Expand Down

0 comments on commit e6de79d

Please sign in to comment.