示例#1
0
    def post(request):
        email = request.POST.get('email')
        sender = request.POST.get('sender')
        message = request.POST.get('message')

        ctx = {
            'sender': sender,
            'email': email,
            'message': message
        }

        send_email(
            subject='email/subjects/contact.txt',
            body='email/contact_team.html',
            from_email="Emma - Contacto <postmaster@%s>" % (
                settings.MAILGUN_SERVER_NAME
            ),
            to_email=[settings.DEFAULT_EMAIL_TO],
            context=ctx
        )

        customer = PotentialClient(
            name=sender,
            email=email,
            source='Contacto'
        )
        customer.save()

        return redirect(reverse('landing:success'))
示例#2
0
    def post(request):
        email = request.user.email
        name = request.user.first_name
        last_name = request.user.get_full_last_name

        number = request.POST.get('number')
        minute = request.POST.get('minute')
        hour = request.POST.get('hour')
        tempo = request.POST.get('morning')
        time = '%s:%s' % (hour, minute)
        datet = request.POST.get('date_input')
        tz = request.POST.get('timezone')

        ctx = {
            'name': name,
            'last_name': last_name,
            'email': email,
            'number': number,
            'tempo': tempo,
            'time': time,
            'date': datet,
            'tz': tz,
        }

        send_email(subject='email/subjects/call_schedule.txt',
                   body='email/call_schedule.html',
                   from_email="Emma - Ventas <postmaster@%s>" %
                   (settings.MAILGUN_SERVER_NAME),
                   to_email=[settings.DEFAULT_EMAIL_TO],
                   context=ctx)

        send_email(subject='email/subjects/notification_call.txt',
                   body='email/notification_call.html',
                   from_email="Emma - Notificaciones <postmaster@%s>" %
                   (settings.MAILGUN_SERVER_NAME),
                   to_email=[email],
                   context=ctx)

        call = ScheduledCall(name="%s %s" % (name, last_name),
                             email=email,
                             date_time="%s %s:%s" % (datet, hour, minute),
                             number=number)
        call.save()

        customer = PotentialClient(name="%s %s" % (name, last_name),
                                   email=email,
                                   source='Agendar una Cita')
        customer.save()

        return redirect(reverse('landing:success'))
示例#3
0
 def form_valid(self, form):
     form.save()
     uid = urlsafe_base64_encode(str(form.user_cache.id))
     current_site = get_current_site(self.request)
     domain = current_site.domain
     send_email(
         subject='email/subjects/notification_welcome.txt',
         body='email/notification_welcome.html',
         context={
             'uid':uid,
             'domain':domain,
             'name': form.user_cache.first_name,
         },
         to_email=[form.user_cache.email],
     )
     return super(SignupView, self).form_valid(form)
示例#4
0
文件: views.py 项目: miemma21/emma
 def form_valid(self, form):
     form.save()
     uid = urlsafe_base64_encode(str(form.user_cache.id))
     current_site = get_current_site(self.request)
     domain = current_site.domain
     send_email(
         subject='email/subjects/notification_welcome.txt',
         body='email/notification_welcome.html',
         context={
             'uid': uid,
             'domain': domain,
             'name': form.user_cache.first_name,
         },
         to_email=[form.user_cache.email],
     )
     return super(SignupView, self).form_valid(form)
示例#5
0
    def post(self, request):
        kwargs = {'request':request}
        if 'user_information' in request.POST:
            user_form = UserInformationForm(request.POST, **kwargs)
            if user_form.is_valid():
                user_form.save()
                send_email(
                    subject='email/subjects/notification_edit_profile.txt',
                    body='email/notification_edit_profile.html',
                    context={
                        'full_name': request.user.get_full_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                ctx = {
                    'password_form': UpdatePasswordForm(),
                    'user_form': self.get_user_initial_form(request),
                    'adult': self.get_adult(request),
                    'success': 'La información del usuario ha sido actualizado'
                }
            else:
                ctx = {
                    'password_form': UpdatePasswordForm(),
                    'adult': self.get_adult(request),
                    'user_form': user_form,
                }

            return TemplateResponse(request, self.template_name, ctx)
        elif 'user_password' in request.POST:
            password_form = UpdatePasswordForm(request.POST, **kwargs)
            if password_form.is_valid():
                password_form.save()
                ctx = {
                    'password_form': UpdatePasswordForm(),
                    'user_form': self.get_user_initial_form(request),
                    'success': 'La contraseña ha sido actualizada',
                    'adult': self.get_adult(request),
                }
            else:
                ctx = {
                    'password_form': password_form,
                    'user_form': self.get_user_initial_form(request),
                    'adult': self.get_adult(request),
                }
            return TemplateResponse(request, self.template_name, ctx)
        else:
            raise Http404("No se encontró la pagina")
示例#6
0
文件: views.py 项目: miemma21/emma
    def post(self, request):
        kwargs = {'request': request}
        if 'user_information' in request.POST:
            user_form = UserInformationForm(request.POST, **kwargs)
            if user_form.is_valid():
                user_form.save()
                send_email(
                    subject='email/subjects/notification_edit_profile.txt',
                    body='email/notification_edit_profile.html',
                    context={
                        'full_name': request.user.get_full_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                ctx = {
                    'password_form': UpdatePasswordForm(),
                    'user_form': self.get_user_initial_form(request),
                    'adult': self.get_adult(request),
                    'success': 'La información del usuario ha sido actualizado'
                }
            else:
                ctx = {
                    'password_form': UpdatePasswordForm(),
                    'adult': self.get_adult(request),
                    'user_form': user_form,
                }

            return TemplateResponse(request, self.template_name, ctx)
        elif 'user_password' in request.POST:
            password_form = UpdatePasswordForm(request.POST, **kwargs)
            if password_form.is_valid():
                password_form.save()
                ctx = {
                    'password_form': UpdatePasswordForm(),
                    'user_form': self.get_user_initial_form(request),
                    'success': 'La contraseña ha sido actualizada',
                    'adult': self.get_adult(request),
                }
            else:
                ctx = {
                    'password_form': password_form,
                    'user_form': self.get_user_initial_form(request),
                    'adult': self.get_adult(request),
                }
            return TemplateResponse(request, self.template_name, ctx)
        else:
            raise Http404("No se encontró la pagina")
示例#7
0
    def post(self, request):
        name = request.POST.get('name')
        phone = request.POST.get('phone')
        email = request.POST.get('email')
        service = request.POST.get('service')
        description = request.POST.get('description')
        date = request.POST.get('date')
        hour = request.POST.get('hour')
        minute = request.POST.get('minute')
        morning = request.POST.get('morning')

        ctx = {
            'name': name,
            'email': email,
            'phone': phone,
            'morning': morning,
            'hour': hour,
            'minute': minute,
            'date': date,
            'service': service,
            'description': description,

        }

        send_email(
            subject='email/subjects/date_schedule.txt',
            body='email/home_date_schedule.html',
            from_email="Emma - Ventas <postmaster@%s>" % (
                settings.MAILGUN_SERVER_NAME
            ),
            to_email=[settings.DEFAULT_EMAIL_TO],
            context=ctx
        )

        send_email(
            subject='email/subjects/notification_date.txt',
            body='email/notification_call.html',
            from_email="Emma - Notificaciones <postmaster@%s>" % (
                settings.MAILGUN_SERVER_NAME
            ),
            to_email=[email],
            context=ctx
        )

        return redirect(reverse('landing:success'))
示例#8
0
    def post(request):
        email = request.POST.get('email')
        sender = request.POST.get('sender')
        message = request.POST.get('message')

        ctx = {'sender': sender, 'email': email, 'message': message}

        send_email(subject='email/subjects/contact.txt',
                   body='email/contact.html',
                   from_email="Emma - Contacto <postmaster@%s>" %
                   (settings.MAILGUN_SERVER_NAME),
                   to_email=[settings.DEFAULT_EMAIL_TO],
                   context=ctx)

        customer = PotentialClient(name=sender, email=email, source='Contacto')
        customer.save()

        return redirect(reverse('landing:success'))
示例#9
0
    def post(self, request):
        name = request.POST.get('name')
        phone = request.POST.get('phone')
        email = request.POST.get('email')
        service = request.POST.get('service')
        description = request.POST.get('description')
        date = request.POST.get('date')
        hour = request.POST.get('hour')
        minute = request.POST.get('minute')
        morning = request.POST.get('morning')

        ctx = {
            'name': name,
            'email': email,
            'phone': phone,
            'morning': morning,
            'hour': hour,
            'minute': minute,
            'date': date,
            'service': service,
            'description': description,
        }

        send_email(subject='email/subjects/date_schedule.txt',
                   body='email/home_date_schedule.html',
                   from_email="Emma - Ventas <postmaster@%s>" %
                   (settings.MAILGUN_SERVER_NAME),
                   to_email=[settings.DEFAULT_EMAIL_TO],
                   context=ctx)

        send_email(subject='email/subjects/notification_date.txt',
                   body='email/notification_call.html',
                   from_email="Emma - Notificaciones <postmaster@%s>" %
                   (settings.MAILGUN_SERVER_NAME),
                   to_email=[email],
                   context=ctx)

        return redirect(reverse('landing:success'))
示例#10
0
    def post(self, request, id, **kwargs):
        kwargs = {'request': request, 'adult_id': id}
        if 'medicalbasic_form' in request.POST:
            medicalbasicform = MedicalInformationBasic(request.POST, **kwargs)

            if medicalbasicform.is_valid():
                medicalbasicform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult_med.txt',
                    body='email/notification_edit_adult_med.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información médica actualizada')
                return redirect(reverse_lazy('adults:dashboard_adult',
                                             kwargs={'id': id}))
            else:
                ctx = {
                    'adultform': self.get_initial_adult_form(
                        request, self.get_adult(request)
                    ),
                    'preferenceform': self.get_initial_preferences_form(
                        request, self.get_adult(request)
                    ),
                    'medicalbasicform': medicalbasicform,
                    'medicalcontactsform': self.get_initial_medical_contacts_form(
                        request, self.get_adult(request)
                    ),
                    'medicalpdaform': self.get_initial_medical_pda_form(
                        request, self.get_adult(request)
                    ),
                    'medicalinsuranceform': self.get_initial_medical_insurance_form(
                        request, self.get_adult(request)
                    ),
                    'medicalssform': self.get_initial_medical_ss_form(
                        request, self.get_adult(request)
                    ),
                    'medicaldoctorform': self.get_initial_medical_doctor_form(
                        request, self.get_adult(request)
                    ),
                    'medicaldiseasesform': self.get_initial_medical_diseases_form(
                        request, self.get_adult(request)
                    ),
                    'adult': self.get_adult(request),
                    'hobbieform': AdultHobbieAdd()
                }
                return render(request, self.template_name, ctx)

        elif 'adult_hobbie_edit' in request.POST:
            for x in request.POST:
                if x.startswith('hobbie'):
                    hobbie_tuple = x.split('-')
                    print hobbie_tuple
                    hobbie = AdultHobbie.objects.get(id=hobbie_tuple[1], adult=self.get_adult(request))
                    hobbie.hobbie = request.POST.get(x)
                    hobbie.save()

            messages.info(self.request, 'Hobbies Actualizados')
            return redirect(reverse_lazy('adults:dashboard_adult',
                                         kwargs={'id': id}))

        elif 'hobbie_form' in request.POST:
            hobbieform = AdultHobbieAdd(request.POST, **kwargs)
            if hobbieform.is_valid():
                hobbieform.save()
                messages.info(self.request, 'Hobbie añadido')
                return redirect(reverse_lazy('adults:dashboard_adult',
                                             kwargs={'id': id}))
            else:
                ctx = {
                    'adultform': self.get_initial_adult_form(
                        request, self.get_adult(request)
                    ),
                    'preferenceform': self.get_initial_preferences_form(
                        request, self.get_adult(request)
                    ),
                    'adult': self.get_adult(request),
                    'hobbieform': AdultHobbieAdd()
                }

                if self.get_adult(request).medical_information:
                    ctx.update({
                        'medicalbasicform': self.get_initial_medical_basic_form(
                            request, self.get_adult(request)
                        ),
                        'medicalcontactsform': self.get_initial_medical_contacts_form(
                            request, self.get_adult(request)
                        ),
                        'medicalpdaform': self.get_initial_medical_pda_form(
                            request, self.get_adult(request)
                        ),
                        'medicalinsuranceform': self.get_initial_medical_insurance_form(
                            request, self.get_adult(request)
                        ),
                        'medicalssform': self.get_initial_medical_ss_form(
                            request, self.get_adult(request)
                        ),
                        'medicaldoctorform': self.get_initial_medical_doctor_form(
                            request, self.get_adult(request)
                        ),
                        'medicaldiseasesform': self.get_initial_medical_diseases_form(
                            request, self.get_adult(request)
                        ),
                    })

                return render(request, self.template_name, ctx)


        elif 'medicalcontacts_form' in request.POST:
            medicalcontactsform = MedicalInformationContacts(request.POST, **kwargs)

            if medicalcontactsform.is_valid():
                medicalcontactsform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult_med.txt',
                    body='email/notification_edit_adult_med.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información médica actualizada')
                return redirect(reverse_lazy('adults:dashboard_adult',
                                             kwargs={'id': id}))
            else:
                ctx = {
                    'adultform': self.get_initial_adult_form(
                        request, self.get_adult(request)
                    ),
                    'preferenceform': self.get_initial_preferences_form(
                        request, self.get_adult(request)
                    ),
                    'medicalbasicform': self.get_initial_medical_basic_form(
                        request, self.get_adult(request)
                    ),
                    'medicalcontactsform': medicalcontactsform,
                    'medicalpdaform': self.get_initial_medical_pda_form(
                        request, self.get_adult(request)
                    ),
                    'medicalinsuranceform': self.get_initial_medical_insurance_form(
                        request, self.get_adult(request)
                    ),
                    'medicalssform': self.get_initial_medical_ss_form(
                        request, self.get_adult(request)
                    ),
                    'medicaldoctorform': self.get_initial_medical_doctor_form(
                        request, self.get_adult(request)
                    ),
                    'medicaldiseasesform': self.get_initial_medical_diseases_form(
                        request, self.get_adult(request)
                    ),
                    'adult': self.get_adult(request),
                    'hobbieform': AdultHobbieAdd()
                }
                return render(request, self.template_name, ctx)

        elif 'medicalpda_form' in request.POST:
            medicalpdaform = MedicalInformationPDA(request.POST, **kwargs)

            if medicalpdaform.is_valid():
                medicalpdaform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult_med.txt',
                    body='email/notification_edit_adult_med.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información médica actualizada')
                return redirect(reverse_lazy('adults:dashboard_adult',
                                             kwargs={'id': id}))
            else:
                ctx = {
                    'adultform': self.get_initial_adult_form(
                        request, self.get_adult(request)
                    ),
                    'preferenceform': self.get_initial_preferences_form(
                        request, self.get_adult(request)
                    ),
                    'medicalbasicform': self.get_initial_medical_basic_form(
                        request, self.get_adult(request)
                    ),
                    'medicalcontactsform': self.get_initial_medical_contacts_form(
                        request, self.get_adult(request)
                    ),
                    'medicalpdaform': medicalpdaform,
                    'medicalinsuranceform': self.get_initial_medical_insurance_form(
                        request, self.get_adult(request)
                    ),
                    'medicalssform': self.get_initial_medical_ss_form(
                        request, self.get_adult(request)
                    ),
                    'medicaldoctorform': self.get_initial_medical_doctor_form(
                        request, self.get_adult(request)
                    ),
                    'medicaldiseasesform': self.get_initial_medical_diseases_form(
                        request, self.get_adult(request)
                    ),
                    'adult': self.get_adult(request),
                    'hobbieform': AdultHobbieAdd()
                }
                return render(request, self.template_name, ctx)

        elif 'medicalinsurance_form' in request.POST:
            medicalinsuranceform = MedicalInformationInsurance(request.POST, **kwargs)

            if medicalinsuranceform.is_valid():
                medicalinsuranceform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult_med.txt',
                    body='email/notification_edit_adult_med.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información médica actualizada')
                return redirect(reverse_lazy('adults:dashboard_adult',
                                             kwargs={'id': id}))
            else:
                ctx = {
                    'adultform': self.get_initial_adult_form(
                        request, self.get_adult(request)
                    ),
                    'preferenceform': self.get_initial_preferences_form(
                        request, self.get_adult(request)
                    ),
                    'medicalbasicform': self.get_initial_medical_basic_form(
                        request, self.get_adult(request)
                    ),
                    'medicalcontactsform': self.get_initial_medical_contacts_form(
                        request, self.get_adult(request)
                    ),
                    'medicalpdaform': self.get_initial_medical_pda_form(
                        request, self.get_adult(request)
                    ),
                    'medicalinsuranceform': medicalinsuranceform,
                    'medicalssform': self.get_initial_medical_ss_form(
                        request, self.get_adult(request)
                    ),
                    'medicaldoctorform': self.get_initial_medical_doctor_form(
                        request, self.get_adult(request)
                    ),
                    'medicaldiseasesform': self.get_initial_medical_diseases_form(
                        request, self.get_adult(request)
                    ),
                    'adult': self.get_adult(request),
                    'hobbieform': AdultHobbieAdd()
                }
                return render(request, self.template_name, ctx)

        elif 'medicalss_form' in request.POST:
            medicalssform = MedicalInformationSS(request.POST, **kwargs)

            if medicalssform.is_valid():
                medicalssform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult_med.txt',
                    body='email/notification_edit_adult_med.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información médica actualizada')
                return redirect(reverse_lazy('adults:dashboard_adult',
                                             kwargs={'id': id}))
            else:
                ctx = {
                    'adultform': self.get_initial_adult_form(
                        request, self.get_adult(request)
                    ),
                    'preferenceform': self.get_initial_preferences_form(
                        request, self.get_adult(request)
                    ),
                    'medicalbasicform': self.get_initial_medical_basic_form(
                        request, self.get_adult(request)
                    ),
                    'medicalcontactsform': self.get_initial_medical_contacts_form(
                        request, self.get_adult(request)
                    ),
                    'medicalpdaform': self.get_initial_medical_pda_form(
                        request, self.get_adult(request)
                    ),
                    'medicalinsuranceform': self.get_initial_medical_insurance_form(
                        request, self.get_adult(request)
                    ),
                    'medicalssform': medicalssform,
                    'medicaldoctorform': self.get_initial_medical_doctor_form(
                        request, self.get_adult(request)
                    ),
                    'medicaldiseasesform': self.get_initial_medical_diseases_form(
                        request, self.get_adult(request)
                    ),
                    'adult': self.get_adult(request),
                    'hobbieform': AdultHobbieAdd()
                }
                return render(request, self.template_name, ctx)

        elif 'medicaldoctor_form' in request.POST:
            medicaldoctorform = MedicalInformationDoctor(request.POST, **kwargs)

            if medicaldoctorform.is_valid():
                medicaldoctorform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult_med.txt',
                    body='email/notification_edit_adult_med.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información médica actualizada')
                return redirect(reverse_lazy('adults:dashboard_adult',
                                             kwargs={'id': id}))
            else:
                ctx = {
                    'adultform': self.get_initial_adult_form(
                        request, self.get_adult(request)
                    ),
                    'preferenceform': self.get_initial_preferences_form(
                        request, self.get_adult(request)
                    ),
                    'medicalbasicform': self.get_initial_medical_basic_form(
                        request, self.get_adult(request)
                    ),
                    'medicalcontactsform': self.get_initial_medical_contacts_form(
                        request, self.get_adult(request)
                    ),
                    'medicalpdaform': self.get_initial_medical_pda_form(
                        request, self.get_adult(request)
                    ),
                    'medicalinsuranceform': self.get_initial_medical_insurance_form(
                        request, self.get_adult(request)
                    ),
                    'medicalssform': self.get_initial_medical_ss_form(
                        request, self.get_adult(request)
                    ),
                    'medicaldoctorform': medicaldoctorform,
                    'medicaldiseasesform': self.get_initial_medical_diseases_form(
                        request, self.get_adult(request)
                    ),
                    'adult': self.get_adult(request),
                    'hobbieform': AdultHobbieAdd()
                }
                return render(request, self.template_name, ctx)

        elif 'medicaldiseases_form' in request.POST:
            medicaldiseasesform = MedicaInformationDiseases(request.POST, **kwargs)

            if medicaldiseasesform.is_valid():
                medicaldiseasesform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult_med.txt',
                    body='email/notification_edit_adult_med.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información médica actualizada')
                return redirect(reverse_lazy('adults:dashboard_adult',
                                             kwargs={'id': id}))
            else:
                ctx = {
                    'adultform': self.get_initial_adult_form(
                        request, self.get_adult(request)
                    ),
                    'preferenceform': self.get_initial_preferences_form(
                        request, self.get_adult(request)
                    ),
                    'medicalbasicform': self.get_initial_medical_basic_form(
                        request, self.get_adult(request)
                    ),
                    'medicalcontactsform': self.get_initial_medical_contacts_form(
                        request, self.get_adult(request)
                    ),
                    'medicalpdaform': self.get_initial_medical_pda_form(
                        request, self.get_adult(request)
                    ),
                    'medicalinsuranceform': self.get_initial_medical_insurance_form(
                        request, self.get_adult(request)
                    ),
                    'medicalssform': self.get_initial_medical_ss_form(
                        request, self.get_adult(request)
                    ),
                    'medicaldoctorform': self.get_initial_medical_doctor_form(
                        request, self.get_adult(request)
                    ),
                    'medicaldiseasesform': medicaldiseasesform,
                    'adult': self.get_adult(request),
                    'hobbieform': AdultHobbieAdd()
                }
                return render(request, self.template_name, ctx)

        elif 'adult_form' in request.POST:

            adultform = AdultInfo(request.POST, request.FILES, **kwargs)

            if adultform.is_valid():
                adultform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult.txt',
                    body='email/notification_edit_adult.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': 'dadas',
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información del adulto actualizda')
                return redirect(reverse_lazy('adults:dashboard_adult',
                                             kwargs={'id': id}))

            else:
                ctx = {
                    'adultform': self.get_initial_adult_form(
                        request, self.get_adult(request)
                    ),
                    'preferenceform': self.get_initial_preferences_form(
                        request, self.get_adult(request)
                    ),
                    'adult': self.get_adult(request),
                    'hobbieform': AdultHobbieAdd()
                }

                if self.get_adult(request).medical_information:
                    ctx.update({
                        'medicalbasicform': self.get_initial_medical_basic_form(
                            request, self.get_adult(request)
                        ),
                        'medicalcontactsform': self.get_initial_medical_contacts_form(
                            request, self.get_adult(request)
                        ),
                        'medicalpdaform': self.get_initial_medical_pda_form(
                            request, self.get_adult(request)
                        ),
                        'medicalinsuranceform': self.get_initial_medical_insurance_form(
                            request, self.get_adult(request)
                        ),
                        'medicalssform': self.get_initial_medical_ss_form(
                            request, self.get_adult(request)
                        ),
                        'medicaldoctorform': self.get_initial_medical_doctor_form(
                            request, self.get_adult(request)
                        ),
                        'medicaldiseasesform': self.get_initial_medical_diseases_form(
                            request, self.get_adult(request)
                        ),
                    })

                return render(request, self.template_name, ctx)

        elif 'preference_form' in request.POST:

            preferenceform = AdultPreferences(request.POST, **kwargs)
            if preferenceform.is_valid():
                preferenceform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult.txt',
                    body='email/notification_edit_adult.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información del adulto actualizda')
                return redirect(reverse_lazy('adults:dashboard_adult',
                                             kwargs={'id': id}))
            else:
                ctx = {
                    'adultform': self.get_initial_adult_form(
                        request, self.get_adult(request)
                    ),
                    'preferenceform': self.get_initial_preferences_form(
                        request, self.get_adult(request)
                    ),
                    'adult': self.get_adult(request),
                    'hobbieform': AdultHobbieAdd()
                }

                if self.get_adult(request).medical_information:
                    ctx.update({
                        'medicalbasicform': self.get_initial_medical_basic_form(
                            request, self.get_adult(request)
                        ),
                        'medicalcontactsform': self.get_initial_medical_contacts_form(
                            request, self.get_adult(request)
                        ),
                        'medicalpdaform': self.get_initial_medical_pda_form(
                            request, self.get_adult(request)
                        ),
                        'medicalinsuranceform': self.get_initial_medical_insurance_form(
                            request, self.get_adult(request)
                        ),
                        'medicalssform': self.get_initial_medical_ss_form(
                            request, self.get_adult(request)
                        ),
                        'medicaldoctorform': self.get_initial_medical_doctor_form(
                            request, self.get_adult(request)
                        ),
                        'medicaldiseasesform': self.get_initial_medical_diseases_form(
                            request, self.get_adult(request)
                        ),
                    })

                return render(request, self.template_name, ctx)

        else:
            raise Http404("No se encontró la pagina")
示例#11
0
    def post(request):
        email = request.user.email
        name = request.user.first_name
        last_name = request.user.get_full_last_name

        number = request.POST.get('number')
        minute = request.POST.get('minute')
        hour = request.POST.get('hour')
        tempo = request.POST.get('morning')
        time = '%s:%s' % (hour, minute)
        datet = request.POST.get('date_input')
        tz = request.POST.get('timezone')

        ctx = {
            'name': name,
            'last_name': last_name,
            'email': email,
            'number': number,
            'tempo': tempo,
            'time': time,
            'date': datet,
            'tz': tz,

        }

        send_email(
            subject='email/subjects/call_schedule.txt',
            body='email/call_schedule.html',
            from_email="Emma - Ventas <postmaster@%s>" % (
                settings.MAILGUN_SERVER_NAME
            ),
            to_email=[settings.DEFAULT_EMAIL_TO],
            context=ctx
        )

        send_email(
            subject='email/subjects/notification_call.txt',
            body='email/notification_call.html',
            from_email="Emma - Notificaciones <postmaster@%s>" % (
                settings.MAILGUN_SERVER_NAME
            ),
            to_email=[email],
            context=ctx
        )

        call = ScheduledCall(
            name="%s %s" % (name, last_name),
            email=email,
            date_time="%s %s:%s" % (datet, hour, minute),
            number=number

        )
        call.save()

        customer = PotentialClient(
            name="%s %s" % (name, last_name),
            email=email,
            source='Agendar una Cita'
        )
        customer.save()

        return redirect(reverse('landing:success'))
示例#12
0
    def post(request):
        last_name = request.POST.get('last_name')
        name = request.POST.get('name')
        age = request.POST.get('age')
        email = request.POST.get('email')
        phone_movile = request.POST.get('phone_movile')
        phone = request.POST.get('phone')
        education = request.POST.get('join-education-value')
        city = request.POST.get('city')
        state = request.POST.get('state')
        litte_city = request.POST.get('litte_city')
        colony = request.POST.get('colony')
        postal_code = request.POST.get('postal_code')
        know = request.POST.getlist('join-source-value')
        xknow = ''
        for x in know:
            xknow += '%s, ' % str(x)
        xknow = xknow[:-1]
        facebook = request.POST.get('join-facebook-value')
        if facebook == 'si':
            bool_facebook = True
        else:
            bool_facebook = False
        smartphone = request.POST.get('join-smartphone-value')
        if smartphone == 'si':
            bool_smartphone = True
        else:
            bool_smartphone = False

        ctx = {
            'name': name,
            'last_name': last_name,
            'email': email,
            'age': age,
            'phone_movile': phone_movile,
            'phone': phone,
            'education': education,
            'city': city,
            'state': state,
            'litte_city': litte_city,
            'colony': colony,
            'postal_code': postal_code,
            'xknow': xknow,
            'facebook': facebook,
            'smartphone': smartphone,
        }

        potential_emma = PotentialEmma(
            first_name=name,
            last_name=last_name,
            age=age,
            movile_phone=phone_movile,
            phone=phone_movile,
            school_grade=education,
            address='%s %s %s %s %s' % (
                city, state, litte_city, colony, postal_code
            ),
            how_met_emma=xknow,
            has_facebook=bool_facebook,
            has_smathphone=bool_smartphone
        )
        potential_emma.save()

        send_email(
            subject='email/subjects/join_emma.txt',
            body='email/join_emma.html',
            from_email="Emma - Reclutamiento <postmaster@%s>" % (
                settings.MAILGUN_SERVER_NAME
            ),
            to_email=[settings.DEFAULT_EMAIL_TO,
                      settings.DEFAULT_JOIN_EMAIL_TO],
            context=ctx
        )

        return redirect(reverse('landing:success'))
示例#13
0
    def post(request):
        last_name = request.POST.get('last_name')
        name = request.POST.get('name')
        age = request.POST.get('age')
        email = request.POST.get('email')
        phone_movile = request.POST.get('phone_movile')
        phone = request.POST.get('phone')
        education = request.POST.get('join-education-value')
        city = request.POST.get('city')
        state = request.POST.get('state')
        litte_city = request.POST.get('litte_city')
        colony = request.POST.get('colony')
        postal_code = request.POST.get('postal_code')
        know = request.POST.getlist('join-source-value')
        xknow = ''
        for x in know:
            xknow += '%s, ' % str(x)
        xknow = xknow[:-1]
        facebook = request.POST.get('join-facebook-value')
        if facebook == 'si':
            bool_facebook = True
        else:
            bool_facebook = False
        smartphone = request.POST.get('join-smartphone-value')
        if smartphone == 'si':
            bool_smartphone = True
        else:
            bool_smartphone = False

        ctx = {
            'name': name,
            'last_name': last_name,
            'email': email,
            'age': age,
            'phone_movile': phone_movile,
            'phone': phone,
            'education': education,
            'city': city,
            'state': state,
            'litte_city': litte_city,
            'colony': colony,
            'postal_code': postal_code,
            'xknow': xknow,
            'facebook': facebook,
            'smartphone': smartphone,
        }

        potential_emma = PotentialEmma(
            first_name=name,
            last_name=last_name,
            age=age,
            movile_phone=phone_movile,
            phone=phone_movile,
            school_grade=education,
            address='%s %s %s %s %s' %
            (city, state, litte_city, colony, postal_code),
            how_met_emma=xknow,
            has_facebook=bool_facebook,
            has_smathphone=bool_smartphone)
        potential_emma.save()

        send_email(subject='email/subjects/join_emma.txt',
                   body='email/join_emma.html',
                   from_email="Emma - Reclutamiento <postmaster@%s>" %
                   (settings.MAILGUN_SERVER_NAME),
                   to_email=[
                       settings.DEFAULT_EMAIL_TO,
                       settings.DEFAULT_JOIN_EMAIL_TO
                   ],
                   context=ctx)

        return redirect(reverse('landing:success'))
示例#14
0
文件: views.py 项目: miemma21/emma
    def post(self, request, id, **kwargs):
        kwargs = {'request': request, 'adult_id': id}
        if 'medicalbasic_form' in request.POST:
            medicalbasicform = MedicalInformationBasic(request.POST, **kwargs)

            if medicalbasicform.is_valid():
                medicalbasicform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult_med.txt',
                    body='email/notification_edit_adult_med.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información médica actualizada')
                return redirect(
                    reverse_lazy('adults:dashboard_adult', kwargs={'id': id}))
            else:
                ctx = {
                    'adultform':
                    self.get_initial_adult_form(request,
                                                self.get_adult(request)),
                    'preferenceform':
                    self.get_initial_preferences_form(request,
                                                      self.get_adult(request)),
                    'medicalbasicform':
                    medicalbasicform,
                    'medicalcontactsform':
                    self.get_initial_medical_contacts_form(
                        request, self.get_adult(request)),
                    'medicalpdaform':
                    self.get_initial_medical_pda_form(request,
                                                      self.get_adult(request)),
                    'medicalinsuranceform':
                    self.get_initial_medical_insurance_form(
                        request, self.get_adult(request)),
                    'medicalssform':
                    self.get_initial_medical_ss_form(request,
                                                     self.get_adult(request)),
                    'medicaldoctorform':
                    self.get_initial_medical_doctor_form(
                        request, self.get_adult(request)),
                    'medicaldiseasesform':
                    self.get_initial_medical_diseases_form(
                        request, self.get_adult(request)),
                    'adult':
                    self.get_adult(request),
                    'hobbieform':
                    AdultHobbieAdd()
                }
                return render(request, self.template_name, ctx)

        elif 'adult_hobbie_edit' in request.POST:
            for x in request.POST:
                if x.startswith('hobbie'):
                    hobbie_tuple = x.split('-')
                    print hobbie_tuple
                    hobbie = AdultHobbie.objects.get(
                        id=hobbie_tuple[1], adult=self.get_adult(request))
                    hobbie.hobbie = request.POST.get(x)
                    hobbie.save()

            messages.info(self.request, 'Hobbies Actualizados')
            return redirect(
                reverse_lazy('adults:dashboard_adult', kwargs={'id': id}))

        elif 'hobbie_form' in request.POST:
            hobbieform = AdultHobbieAdd(request.POST, **kwargs)
            if hobbieform.is_valid():
                hobbieform.save()
                messages.info(self.request, 'Hobbie añadido')
                return redirect(
                    reverse_lazy('adults:dashboard_adult', kwargs={'id': id}))
            else:
                ctx = {
                    'adultform':
                    self.get_initial_adult_form(request,
                                                self.get_adult(request)),
                    'preferenceform':
                    self.get_initial_preferences_form(request,
                                                      self.get_adult(request)),
                    'adult':
                    self.get_adult(request),
                    'hobbieform':
                    AdultHobbieAdd()
                }

                if self.get_adult(request).medical_information:
                    ctx.update({
                        'medicalbasicform':
                        self.get_initial_medical_basic_form(
                            request, self.get_adult(request)),
                        'medicalcontactsform':
                        self.get_initial_medical_contacts_form(
                            request, self.get_adult(request)),
                        'medicalpdaform':
                        self.get_initial_medical_pda_form(
                            request, self.get_adult(request)),
                        'medicalinsuranceform':
                        self.get_initial_medical_insurance_form(
                            request, self.get_adult(request)),
                        'medicalssform':
                        self.get_initial_medical_ss_form(
                            request, self.get_adult(request)),
                        'medicaldoctorform':
                        self.get_initial_medical_doctor_form(
                            request, self.get_adult(request)),
                        'medicaldiseasesform':
                        self.get_initial_medical_diseases_form(
                            request, self.get_adult(request)),
                    })

                return render(request, self.template_name, ctx)

        elif 'medicalcontacts_form' in request.POST:
            medicalcontactsform = MedicalInformationContacts(
                request.POST, **kwargs)

            if medicalcontactsform.is_valid():
                medicalcontactsform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult_med.txt',
                    body='email/notification_edit_adult_med.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información médica actualizada')
                return redirect(
                    reverse_lazy('adults:dashboard_adult', kwargs={'id': id}))
            else:
                ctx = {
                    'adultform':
                    self.get_initial_adult_form(request,
                                                self.get_adult(request)),
                    'preferenceform':
                    self.get_initial_preferences_form(request,
                                                      self.get_adult(request)),
                    'medicalbasicform':
                    self.get_initial_medical_basic_form(
                        request, self.get_adult(request)),
                    'medicalcontactsform':
                    medicalcontactsform,
                    'medicalpdaform':
                    self.get_initial_medical_pda_form(request,
                                                      self.get_adult(request)),
                    'medicalinsuranceform':
                    self.get_initial_medical_insurance_form(
                        request, self.get_adult(request)),
                    'medicalssform':
                    self.get_initial_medical_ss_form(request,
                                                     self.get_adult(request)),
                    'medicaldoctorform':
                    self.get_initial_medical_doctor_form(
                        request, self.get_adult(request)),
                    'medicaldiseasesform':
                    self.get_initial_medical_diseases_form(
                        request, self.get_adult(request)),
                    'adult':
                    self.get_adult(request),
                    'hobbieform':
                    AdultHobbieAdd()
                }
                return render(request, self.template_name, ctx)

        elif 'medicalpda_form' in request.POST:
            medicalpdaform = MedicalInformationPDA(request.POST, **kwargs)

            if medicalpdaform.is_valid():
                medicalpdaform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult_med.txt',
                    body='email/notification_edit_adult_med.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información médica actualizada')
                return redirect(
                    reverse_lazy('adults:dashboard_adult', kwargs={'id': id}))
            else:
                ctx = {
                    'adultform':
                    self.get_initial_adult_form(request,
                                                self.get_adult(request)),
                    'preferenceform':
                    self.get_initial_preferences_form(request,
                                                      self.get_adult(request)),
                    'medicalbasicform':
                    self.get_initial_medical_basic_form(
                        request, self.get_adult(request)),
                    'medicalcontactsform':
                    self.get_initial_medical_contacts_form(
                        request, self.get_adult(request)),
                    'medicalpdaform':
                    medicalpdaform,
                    'medicalinsuranceform':
                    self.get_initial_medical_insurance_form(
                        request, self.get_adult(request)),
                    'medicalssform':
                    self.get_initial_medical_ss_form(request,
                                                     self.get_adult(request)),
                    'medicaldoctorform':
                    self.get_initial_medical_doctor_form(
                        request, self.get_adult(request)),
                    'medicaldiseasesform':
                    self.get_initial_medical_diseases_form(
                        request, self.get_adult(request)),
                    'adult':
                    self.get_adult(request),
                    'hobbieform':
                    AdultHobbieAdd()
                }
                return render(request, self.template_name, ctx)

        elif 'medicalinsurance_form' in request.POST:
            medicalinsuranceform = MedicalInformationInsurance(
                request.POST, **kwargs)

            if medicalinsuranceform.is_valid():
                medicalinsuranceform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult_med.txt',
                    body='email/notification_edit_adult_med.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información médica actualizada')
                return redirect(
                    reverse_lazy('adults:dashboard_adult', kwargs={'id': id}))
            else:
                ctx = {
                    'adultform':
                    self.get_initial_adult_form(request,
                                                self.get_adult(request)),
                    'preferenceform':
                    self.get_initial_preferences_form(request,
                                                      self.get_adult(request)),
                    'medicalbasicform':
                    self.get_initial_medical_basic_form(
                        request, self.get_adult(request)),
                    'medicalcontactsform':
                    self.get_initial_medical_contacts_form(
                        request, self.get_adult(request)),
                    'medicalpdaform':
                    self.get_initial_medical_pda_form(request,
                                                      self.get_adult(request)),
                    'medicalinsuranceform':
                    medicalinsuranceform,
                    'medicalssform':
                    self.get_initial_medical_ss_form(request,
                                                     self.get_adult(request)),
                    'medicaldoctorform':
                    self.get_initial_medical_doctor_form(
                        request, self.get_adult(request)),
                    'medicaldiseasesform':
                    self.get_initial_medical_diseases_form(
                        request, self.get_adult(request)),
                    'adult':
                    self.get_adult(request),
                    'hobbieform':
                    AdultHobbieAdd()
                }
                return render(request, self.template_name, ctx)

        elif 'medicalss_form' in request.POST:
            medicalssform = MedicalInformationSS(request.POST, **kwargs)

            if medicalssform.is_valid():
                medicalssform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult_med.txt',
                    body='email/notification_edit_adult_med.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información médica actualizada')
                return redirect(
                    reverse_lazy('adults:dashboard_adult', kwargs={'id': id}))
            else:
                ctx = {
                    'adultform':
                    self.get_initial_adult_form(request,
                                                self.get_adult(request)),
                    'preferenceform':
                    self.get_initial_preferences_form(request,
                                                      self.get_adult(request)),
                    'medicalbasicform':
                    self.get_initial_medical_basic_form(
                        request, self.get_adult(request)),
                    'medicalcontactsform':
                    self.get_initial_medical_contacts_form(
                        request, self.get_adult(request)),
                    'medicalpdaform':
                    self.get_initial_medical_pda_form(request,
                                                      self.get_adult(request)),
                    'medicalinsuranceform':
                    self.get_initial_medical_insurance_form(
                        request, self.get_adult(request)),
                    'medicalssform':
                    medicalssform,
                    'medicaldoctorform':
                    self.get_initial_medical_doctor_form(
                        request, self.get_adult(request)),
                    'medicaldiseasesform':
                    self.get_initial_medical_diseases_form(
                        request, self.get_adult(request)),
                    'adult':
                    self.get_adult(request),
                    'hobbieform':
                    AdultHobbieAdd()
                }
                return render(request, self.template_name, ctx)

        elif 'medicaldoctor_form' in request.POST:
            medicaldoctorform = MedicalInformationDoctor(
                request.POST, **kwargs)

            if medicaldoctorform.is_valid():
                medicaldoctorform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult_med.txt',
                    body='email/notification_edit_adult_med.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información médica actualizada')
                return redirect(
                    reverse_lazy('adults:dashboard_adult', kwargs={'id': id}))
            else:
                ctx = {
                    'adultform':
                    self.get_initial_adult_form(request,
                                                self.get_adult(request)),
                    'preferenceform':
                    self.get_initial_preferences_form(request,
                                                      self.get_adult(request)),
                    'medicalbasicform':
                    self.get_initial_medical_basic_form(
                        request, self.get_adult(request)),
                    'medicalcontactsform':
                    self.get_initial_medical_contacts_form(
                        request, self.get_adult(request)),
                    'medicalpdaform':
                    self.get_initial_medical_pda_form(request,
                                                      self.get_adult(request)),
                    'medicalinsuranceform':
                    self.get_initial_medical_insurance_form(
                        request, self.get_adult(request)),
                    'medicalssform':
                    self.get_initial_medical_ss_form(request,
                                                     self.get_adult(request)),
                    'medicaldoctorform':
                    medicaldoctorform,
                    'medicaldiseasesform':
                    self.get_initial_medical_diseases_form(
                        request, self.get_adult(request)),
                    'adult':
                    self.get_adult(request),
                    'hobbieform':
                    AdultHobbieAdd()
                }
                return render(request, self.template_name, ctx)

        elif 'medicaldiseases_form' in request.POST:
            medicaldiseasesform = MedicaInformationDiseases(
                request.POST, **kwargs)

            if medicaldiseasesform.is_valid():
                medicaldiseasesform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult_med.txt',
                    body='email/notification_edit_adult_med.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request, 'Información médica actualizada')
                return redirect(
                    reverse_lazy('adults:dashboard_adult', kwargs={'id': id}))
            else:
                ctx = {
                    'adultform':
                    self.get_initial_adult_form(request,
                                                self.get_adult(request)),
                    'preferenceform':
                    self.get_initial_preferences_form(request,
                                                      self.get_adult(request)),
                    'medicalbasicform':
                    self.get_initial_medical_basic_form(
                        request, self.get_adult(request)),
                    'medicalcontactsform':
                    self.get_initial_medical_contacts_form(
                        request, self.get_adult(request)),
                    'medicalpdaform':
                    self.get_initial_medical_pda_form(request,
                                                      self.get_adult(request)),
                    'medicalinsuranceform':
                    self.get_initial_medical_insurance_form(
                        request, self.get_adult(request)),
                    'medicalssform':
                    self.get_initial_medical_ss_form(request,
                                                     self.get_adult(request)),
                    'medicaldoctorform':
                    self.get_initial_medical_doctor_form(
                        request, self.get_adult(request)),
                    'medicaldiseasesform':
                    medicaldiseasesform,
                    'adult':
                    self.get_adult(request),
                    'hobbieform':
                    AdultHobbieAdd()
                }
                return render(request, self.template_name, ctx)

        elif 'adult_form' in request.POST:

            adultform = AdultInfo(request.POST, request.FILES, **kwargs)

            if adultform.is_valid():
                adultform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult.txt',
                    body='email/notification_edit_adult.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': 'dadas',
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request,
                              'Información del adulto actualizda')
                return redirect(
                    reverse_lazy('adults:dashboard_adult', kwargs={'id': id}))

            else:
                ctx = {
                    'adultform':
                    self.get_initial_adult_form(request,
                                                self.get_adult(request)),
                    'preferenceform':
                    self.get_initial_preferences_form(request,
                                                      self.get_adult(request)),
                    'adult':
                    self.get_adult(request),
                    'hobbieform':
                    AdultHobbieAdd()
                }

                if self.get_adult(request).medical_information:
                    ctx.update({
                        'medicalbasicform':
                        self.get_initial_medical_basic_form(
                            request, self.get_adult(request)),
                        'medicalcontactsform':
                        self.get_initial_medical_contacts_form(
                            request, self.get_adult(request)),
                        'medicalpdaform':
                        self.get_initial_medical_pda_form(
                            request, self.get_adult(request)),
                        'medicalinsuranceform':
                        self.get_initial_medical_insurance_form(
                            request, self.get_adult(request)),
                        'medicalssform':
                        self.get_initial_medical_ss_form(
                            request, self.get_adult(request)),
                        'medicaldoctorform':
                        self.get_initial_medical_doctor_form(
                            request, self.get_adult(request)),
                        'medicaldiseasesform':
                        self.get_initial_medical_diseases_form(
                            request, self.get_adult(request)),
                    })

                return render(request, self.template_name, ctx)

        elif 'preference_form' in request.POST:

            preferenceform = AdultPreferences(request.POST, **kwargs)
            if preferenceform.is_valid():
                preferenceform.save()
                send_email(
                    subject='email/subjects/notification_edit_adult.txt',
                    body='email/notification_edit_adult.html',
                    context={
                        'user_full_name': request.user.get_full_name,
                        'adult_full_name': self.get_adult(request).first_name,
                    },
                    to_email=[settings.DEFAULT_EMAIL_TO],
                )
                messages.info(self.request,
                              'Información del adulto actualizda')
                return redirect(
                    reverse_lazy('adults:dashboard_adult', kwargs={'id': id}))
            else:
                ctx = {
                    'adultform':
                    self.get_initial_adult_form(request,
                                                self.get_adult(request)),
                    'preferenceform':
                    self.get_initial_preferences_form(request,
                                                      self.get_adult(request)),
                    'adult':
                    self.get_adult(request),
                    'hobbieform':
                    AdultHobbieAdd()
                }

                if self.get_adult(request).medical_information:
                    ctx.update({
                        'medicalbasicform':
                        self.get_initial_medical_basic_form(
                            request, self.get_adult(request)),
                        'medicalcontactsform':
                        self.get_initial_medical_contacts_form(
                            request, self.get_adult(request)),
                        'medicalpdaform':
                        self.get_initial_medical_pda_form(
                            request, self.get_adult(request)),
                        'medicalinsuranceform':
                        self.get_initial_medical_insurance_form(
                            request, self.get_adult(request)),
                        'medicalssform':
                        self.get_initial_medical_ss_form(
                            request, self.get_adult(request)),
                        'medicaldoctorform':
                        self.get_initial_medical_doctor_form(
                            request, self.get_adult(request)),
                        'medicaldiseasesform':
                        self.get_initial_medical_diseases_form(
                            request, self.get_adult(request)),
                    })

                return render(request, self.template_name, ctx)

        else:
            raise Http404("No se encontró la pagina")