<commit_before># coding: utf-8

from django.views import generic
from django.utils.decorators import method_decorator
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse_lazy
from django.shortcuts import get_object_or_404
from django.contrib.auth.decorators import login_required
from member.models import Client, Member, Address, Contact, Referencing, Note
from formtools.wizard.views import *
from django.shortcuts import *


class ClientWizard(NamedUrlSessionWizardView):

    template_name = 'forms/form.html'

    def done(self, form_list, form_dict, **kwargs):

        self.form_dict = form_dict
        self.save()
        return HttpResponseRedirect('/member/list')

    def save(self):
        """Save the client"""

        basic_info = self.form_dict['basic_info']
        address_information = self.form_dict['address_information']
        referent_information = self.form_dict['referent_information']
        payment_information = self.form_dict['payment_information']
        dietary_restriction = self.form_dict['dietary_restriction']
        emergency_contact = self.form_dict['emergency_contact']

        print(basic_info.cleaned_data.get('firstname'))
        print(emergency_contact.cleaned_data.get('firstname'))
        print(referent_information.cleaned_data.get('firstname'))

        member = Member.objects.create(
            firstname=basic_info.cleaned_data.get('firstname'),
            lastname=basic_info.cleaned_data.get('lastname'),
            gender=basic_info.cleaned_data.get('gender'),
            birthdate=basic_info.cleaned_data.get('birthdate'),
        )
        member.save()

        address = Address.objects.create(
            number=address_information.cleaned_data.get('number'),
            street=address_information.cleaned_data.get('street'),
            apartment=address_information.cleaned_data.get(
                'apartment'
            ),
            floor=address_information.cleaned_data.get('floor'),
            city=address_information.cleaned_data.get('city'),
            postal_code=address_information.cleaned_data.get('postal_code'),
            member=member,
        )
        address.save()

        contact = Contact.objects.create(
            type=basic_info.cleaned_data.get('contact_type'),
            value=basic_info.cleaned_data.get("contact_value"),
            member=member,
        )
        contact.save()

        emergency = Member.objects.create(
            firstname=emergency_contact.cleaned_data.get("firstname"),
            lastname=emergency_contact.cleaned_data.get('lastname'),
        )
        emergency.save()

        client_emergency_contact = Contact.objects.create(
            type=emergency_contact.cleaned_data.get("contact_type"),
            value=emergency_contact.cleaned_data.get(
                "contact_value"
            ),

            member=emergency,
        )
        client_emergency_contact.save()

        client = Client.objects.create(
            facturation=payment_information.cleaned_data.get("facturation"),
            member=member,
            billing_address=address,
            emergency_contact=emergency,
            # The default status is always PENDING
            status="PENDING",
            alert=basic_info.cleaned_data.get("alert"),
        )
        client.save()

        referent = Member.objects.create(
            firstname=referent_information.cleaned_data.get(
                "firstname"
            ),
            lastname=referent_information.cleaned_data.get(
                "lastname"
            ),<commit_msg>Fix payment type was not saved in DB<commit_after># coding: utf-8

from django.views import generic
from django.utils.decorators import method_decorator
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse_lazy
from django.shortcuts import get_object_or_404
from django.contrib.auth.decorators import login_required
from member.models import Client, Member, Address, Contact, Referencing, Note
from formtools.wizard.views import *
from django.shortcuts import *


class ClientWizard(NamedUrlSessionWizardView):

    template_name = 'forms/form.html'

    def done(self, form_list, form_dict, **kwargs):

        self.form_dict = form_dict
        self.save()
        return HttpResponseRedirect('/member/list')

    def save(self):
        """Save the client"""

        basic_info = self.form_dict['basic_info']
        address_information = self.form_dict['address_information']
        referent_information = self.form_dict['referent_information']
        payment_information = self.form_dict['payment_information']
        dietary_restriction = self.form_dict['dietary_restriction']
        emergency_contact = self.form_dict['emergency_contact']

        print(basic_info.cleaned_data.get('firstname'))
        print(emergency_contact.cleaned_data.get('firstname'))
        print(referent_information.cleaned_data.get('firstname'))

        member = Member.objects.create(
            firstname=basic_info.cleaned_data.get('firstname'),
            lastname=basic_info.cleaned_data.get('lastname'),
            gender=basic_info.cleaned_data.get('gender'),
            birthdate=basic_info.cleaned_data.get('birthdate'),
        )
        member.save()

        address = Address.objects.create(
            number=address_information.cleaned_data.get('number'),
            street=address_information.cleaned_data.get('street'),
            apartment=address_information.cleaned_data.get(
                'apartment'
            ),
            floor=address_information.cleaned_data.get('floor'),
            city=address_information.cleaned_data.get('city'),
            postal_code=address_information.cleaned_data.get('postal_code'),
            member=member,
        )
        address.save()

        contact = Contact.objects.create(
            type=basic_info.cleaned_data.get('contact_type'),
            value=basic_info.cleaned_data.get("contact_value"),
            member=member,
        )
        contact.save()

        emergency = Member.objects.create(
            firstname=emergency_contact.cleaned_data.get("firstname"),
            lastname=emergency_contact.cleaned_data.get('lastname'),
        )
        emergency.save()

        client_emergency_contact = Contact.objects.create(
            type=emergency_contact.cleaned_data.get("contact_type"),
            value=emergency_contact.cleaned_data.get(
                "contact_value"
            ),

            member=emergency,
        )
        client_emergency_contact.save()

        client = Client.objects.create(
            facturation=payment_information.cleaned_data.get("facturation"),
            billing_payment_type=payment_information.cleaned_data.get(
                "billing_payment_type"),
            member=member,
            billing_address=address,
            emergency_contact=emergency,
            # The default status is always PENDING
            status="PENDING",
            alert=basic_info.cleaned_data.get("alert"),
        )
        client.save()

        referent = Member.objects.create(
            firstname=referent_information.cleaned_data.get(
                "firstname"
            ),
            lastname=referent_information.cleaned_data.get(
                "lastname"
            ),
{'fraction_non_alphanumeric': 0.09664721053346002, 'fraction_numerical': 0.0010859237138591013, 'mean_word_length': 2.662027833001988, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6422687', 'n_tokens_mistral': 2049, 'n_tokens_neox': 1987, 'n_words': 275}