Esempio n. 1
0
    def save(self, user):
        pprint('saving to somewhere else')

        forms = self.cleaned_data
        # format fields
        forms['date_of_birth'] = forms['date_of_birth'].strftime('%d/%m/%Y')
        forms['phone'] = str(forms['phone'].national_number)
        # add email field from userModel
        forms.update({'email': user.email})
        forms.update({'codigopostal': '0000-000'})

        client_id = add_cliente(signup_forms=forms)
        user.set_client_id(client_id)
        return
Esempio n. 2
0
def edit_Tprofile(request,pk):
    if request.user.is_teacher:
        if request.user.pk == pk:
            teacher = User.objects.get(pk=pk)
            Tprofile = teacherprofile.objects.get(user = teacher)
            form = forms.edit(teacher.email,teacher.first_name,teacher.last_name,instance=Tprofile)
            form.fields['last_lecture'].widget.attrs.update({'class':'datetime'})
            form.fields['subject'].widget.attrs.update({'class':'checkbox'})
            form.fields['dob'].widget.attrs.update({'class':'date'})
            
            if request.method == 'POST':
                form=forms.edit(request.POST["email"],request.POST["first_name"],request.POST["last_name"],request.POST,request.FILES)
                if form.is_valid():
                    fo=form.update(pk)
                    if 'image' in request.FILES:
                        fs=FileSystemStorage()
                        filename=fs.save(request.FILES["image"].name,request.FILES["image"])
                    return redirect("/"+request.session["type_profile"]+"/dashboard/profile/"+str(pk)+"/")
                else:
                    return HttpResponse("OOOOO")
            else:
                return render(request,'teacher/edit.html',{"form" : form})
              
        else:
            return HttpResponse('I')
    else:
        return HttpResponse('II')
    def __init__(cls, name, bases, dct):
        """Find all subforms and collect them."""

        # scan class definition for Subform instances
        forms = {}
        ordernums_names = []  # use to sort Subforms by ordering number
        for attrname, attrval in dct.items():
            if isinstance(attrval, Subform):
                forms[attrname] = attrval.formclass
                ordernums_names.append((attrval._ordering, attrname))

        # keep track of subform declaration order
        formnames = [name for _, name in sorted(ordernums_names)]

        # anticipate inheritence; `cls` might be a derived class whose parent
        # class is also a CombinedForm; if so, the parent class' forms should
        # be included in the derived class' forms

        # get the next parent (which will have accumulated its parent, etc)
        is_formclass = lambda a: hasattr(a, '_forms')
        try:
            parent = next(base for base in bases if is_formclass(base))
        except StopIteration:
            pass
        else:

            # get all forms from parent class
            forms.update(parent._forms)

            # preserve form order from parent class
            formnames = parent._formnames + formnames

        # TODO: delete the `_forms` attribute, it is unneeded and prevents
        # users from overriding form factories if they need to
        cls._forms = forms
        cls._formnames = formnames
        super(CombinedFormMetaclass, cls).__init__(name, bases, dct)