@@ -162,6 +162,43 @@ class ManualInteractionForm(forms.Form):
162162 )
163163
164164
165+ class CustomerFollowUpForm (forms .Form ):
166+ follow_up_at = forms .DateTimeField (
167+ label = gettext_lazy ("Follow-up date" ),
168+ input_formats = ("%Y-%m-%dT%H:%M" , "%Y-%m-%d %H:%M" ),
169+ widget = forms .DateTimeInput (
170+ attrs = {"type" : "datetime-local" },
171+ format = "%Y-%m-%dT%H:%M" ,
172+ ),
173+ )
174+ follow_up_note = forms .CharField (
175+ label = gettext_lazy ("Follow-up note" ),
176+ max_length = 200 ,
177+ required = False ,
178+ widget = forms .TextInput (),
179+ )
180+
181+ def __init__ (self , * args , instance : Customer , ** kwargs ):
182+ self .instance = instance
183+ kwargs .setdefault (
184+ "initial" ,
185+ {
186+ "follow_up_at" : instance .follow_up_at ,
187+ "follow_up_note" : instance .follow_up_note ,
188+ },
189+ )
190+ super ().__init__ (* args , ** kwargs )
191+
192+ def save (self , * , commit : bool = True ) -> Customer :
193+ self .instance .follow_up_at = self .cleaned_data ["follow_up_at" ]
194+ self .instance .follow_up_note = self .cleaned_data ["follow_up_note" ]
195+ if commit :
196+ self .instance .save (
197+ update_fields = ["follow_up_at" , "follow_up_note" ],
198+ )
199+ return self .instance
200+
201+
165202class CustomerUserForm (forms .Form ):
166203 email = forms .EmailField (label = gettext_lazy ("E-mail" ))
167204 full_name = forms .CharField (label = gettext_lazy ("Full name" ), max_length = 150 )
0 commit comments