Ejemplo n.º 1
0
def extra_data_save(request, object=None):
    phone_save(object, request.POST.getlist('phoneId'),
               request.POST.getlist('area'),
               request.POST.getlist('phoneNumber'),
               request.POST.getlist('ext'), request.POST.getlist('phoneType'))
    email_save(object, request.POST.getlist('email_id'),
               request.POST.getlist('email_email'),
               request.POST.getlist('email_type'))
    site_save(object, request.POST.getlist('site_id'),
              request.POST.getlist('site_description'),
              request.POST.getlist('site_site'))
    im_save(object, request.POST.getlist('im_id'),
            request.POST.getlist('im_identity'),
            request.POST.getlist('im_network'))
    address_save(object, request.POST.getlist('addressId'),
                 request.POST.getlist('addressPrefix'),
                 request.POST.getlist('addressLine1'),
                 request.POST.getlist('addressLine2'),
                 request.POST.getlist('addressNumber'),
                 request.POST.getlist('neighborhood'),
                 request.POST.getlist('zipCode'),
                 request.POST.getlist('addressType'),
                 request.POST.getlist('city'),
                 request.POST.getlist('foreignCountry'),
                 request.POST.getlist('foreignState'),
                 request.POST.getlist('foreignCity'))
    return object
Ejemplo n.º 2
0
def save(request):

    user = request.user

    try:
        object = Organization.objects.get(pk= user.get_profile().org_active.id)
    except:
        object = Organization()
        object.short_name = slugify(request.POST['name'])
    
    if (object.short_name != request.POST['short_name']):
        if (Organization.objects.filter(short_name__iexact = request.POST['short_name']).count()):
            return HttpResponse("false")
        else:
            object.short_name = request.POST['short_name']
    
    #identity
    object.name = request.POST['name']
    object.trade_name = request.POST['trade_name']
    object.register_number = request.POST['register_number']
    object.cnes = request.POST['cnes']
    object.state_inscription = request.POST.get('state_inscription')
    object.city_inscription = request.POST['city_inscription']
    object.photo = request.POST['photo']
    object.visible = get_visible( request, request.POST.get('visible') )
    #profile
    object.person_type = get_object_or_None(PersonType, pk=request.POST.get('person_type'))
    object.unit_type = get_object_or_None(UnitType, pk=request.POST.get('unit_type'))
    object.environment = get_object_or_None(AdministrationEnvironment, pk=request.POST.get('environment'))
    object.management = get_object_or_None(Management, pk=request.POST.get('management'))
    object.source = get_object_or_None(Source, pk=request.POST.get('source'))
    object.dependence = get_object_or_None(Dependence, pk=request.POST.get('dependence'))
    object.activity = get_object_or_None(Activitie, pk=request.POST.get('activity'))
    """ provided types """
    object.provided_type.clear()

    for p in request.POST.getlist('provided_type'):
        object.provided_type.add(ProvidedType.objects.get(pk=p))

    object.comment = request.POST['comment']
    object.save()
   
    professional_responsible_save(request, object, request.POST.getlist('professionalId'), request.POST.getlist('professional_name'), request.POST.getlist('professional_subscription'), request.POST.getlist('professional_organization_subscription'), request.POST.getlist('service_profession'))

    phone_save(object, request.POST.getlist('phoneId'), request.POST.getlist('area'), request.POST.getlist('phoneNumber'), request.POST.getlist('ext'), request.POST.getlist('phoneType'))
    email_save(object, request.POST.getlist('email_id'), request.POST.getlist('email_email'), request.POST.getlist('email_type'))
    site_save(object, request.POST.getlist('site_id'), request.POST.getlist('site_description'), request.POST.getlist('site_site'))
    im_save(object, request.POST.getlist('im_id'), request.POST.getlist('im_identity'), request.POST.getlist('im_network'))
    address_save(object, request.POST.getlist('addressId'), request.POST.getlist('addressPrefix'),
    request.POST.getlist('addressLine1'), request.POST.getlist('addressLine2'),
    request.POST.getlist('addressNumber'), request.POST.getlist('neighborhood'),
    request.POST.getlist('zipCode'), request.POST.getlist('addressType'),
    request.POST.getlist('city'), request.POST.getlist('foreignCountry'),
    request.POST.getlist('foreignState'), request.POST.getlist('foreignCity'))

    messages.success(request, _('Organization details saved successfully'))
    return HttpResponseRedirect('/organization/')
Ejemplo n.º 3
0
def extra_data_save(request, object = None):
    phone_save(object, request.POST.getlist('phoneId'), request.POST.getlist('area'), request.POST.getlist('phoneNumber'), request.POST.getlist('ext'), request.POST.getlist('phoneType'))
    email_save(object, request.POST.getlist('email_id'), request.POST.getlist('email_email'), request.POST.getlist('email_type'))
    site_save(object, request.POST.getlist('site_id'), request.POST.getlist('site_description'), request.POST.getlist('site_site'))
    im_save(object, request.POST.getlist('im_id'), request.POST.getlist('im_identity'), request.POST.getlist('im_network'))
    address_save(object, request.POST.getlist('addressId'), request.POST.getlist('addressPrefix'),
        request.POST.getlist('addressLine1'), request.POST.getlist('addressLine2'),
        request.POST.getlist('addressNumber'), request.POST.getlist('neighborhood'),
        request.POST.getlist('zipCode'), request.POST.getlist('addressType'),
        request.POST.getlist('city'), request.POST.getlist('foreignCountry'),
        request.POST.getlist('foreignState'), request.POST.getlist('foreignCity'))
    return object
Ejemplo n.º 4
0
def person_save(request, person):

    person.name = request.POST['name']
    person.nickname = request.POST['nickname']
    person.comments = request.POST.get('comments')

    if (request.POST['photo']):
        person.photo = request.POST['photo']
    else:
        person.photo = ''
    """ AGE """
    try:
        if (request.POST.get('dateBirth')):
            person.birthDate = datetime.strptime(request.POST.get('dateBirth'),
                                                 '%d/%m/%Y')
    except ValueError as error:
        print error
    else:
        if request.POST.get('Years'):
            birthYear = ((int(datetime.now().strftime("%Y"))) -
                         (int(request.POST.get('Years'))))
            today = (datetime.now().strftime("%d/%m/"))
            dt = "%s%s" % (today, birthYear)
            person.birthDate = datetime.strptime(dt, '%d/%m/%Y')

    if (request.POST.get('aprox')):
        person.birthDateSupposed = True
    else:
        person.birthDateSupposed = False
    """ AGE """

    person.gender = request.POST['gender']

    # maritalStatus
    try:
        if not (request.POST['maritalStatus']):
            person.maritalStatus = None
        else:
            person.maritalStatus = MaritalStatus.objects.get(
                pk=request.POST['maritalStatus'])
    except:
        person.maritalStatus = None

    # birthPlace (Naturality)
    person.birthForeignCity = ''
    person.birthForeignState = ''
    person.birthForeignCountry = None

    try:
        person.birthPlace = City.objects.get(pk=request.POST['birthPlace'])
    except:
        person.birthPlace = None
        try:
            person.birthForeignCity = request.POST['birthForeignCity']
        except:
            person.birthForeignCity = None
        try:
            person.birthForeignState = request.POST['birthForeignState']
        except:
            person.birthForeignState = None
        try:
            person.birthForeignCountry = request.POST['birthForeignCountry']
        except:
            person.birthForeignCountry = None

    person.save()
    user = request.user
    person.organization.add(user.get_profile().org_active)

    # save phone numbers (using Phone APP)
    phone_save(person, request.POST.getlist('phoneId'),
               request.POST.getlist('area'),
               request.POST.getlist('phoneNumber'),
               request.POST.getlist('ext'), request.POST.getlist('phoneType'))

    # save addresses (using Address APP)
    address_save(person, request.POST.getlist('addressId'),
                 request.POST.getlist('addressPrefix'),
                 request.POST.getlist('addressLine1'),
                 request.POST.getlist('addressLine2'),
                 request.POST.getlist('addressNumber'),
                 request.POST.getlist('neighborhood'),
                 request.POST.getlist('zipCode'),
                 request.POST.getlist('addressType'),
                 request.POST.getlist('city'),
                 request.POST.getlist('foreignCountry'),
                 request.POST.getlist('foreignState'),
                 request.POST.getlist('foreignCity'))

    # save documents (using Document APP)
    document_save(person, request.POST.getlist('documentId'),
                  request.POST.getlist('document_typeDocument'),
                  request.POST.getlist('document_document'),
                  request.POST.getlist('document_identifier'),
                  request.POST.getlist('document_issuer'),
                  request.POST.getlist('document_state'))

    # save internet data
    email_save(person, request.POST.getlist('email_id'),
               request.POST.getlist('email_email'),
               request.POST.getlist('email_type'))

    site_save(person, request.POST.getlist('site_id'),
              request.POST.getlist('site_description'),
              request.POST.getlist('site_site'))

    im_save(person, request.POST.getlist('im_id'),
            request.POST.getlist('im_identity'),
            request.POST.getlist('im_network'))

    return person
Ejemplo n.º 5
0
def person_save(request, person):

    person.name = request.POST['name']
    person.nickname = request.POST['nickname']
    person.comments = request.POST.get('comments')

    if(request.POST['photo']):
        person.photo = request.POST['photo']
    else:
        person.photo = ''

    """ AGE """
    if(request.POST.get('dateBirth')):
        person.birthDate = datetime.strptime(
            request.POST.get('dateBirth'), '%d/%m/%Y')
    else:
        if request.POST.get('Years'):
            birthYear = ((int(datetime.now().strftime("%Y"))) -
                         (int(request.POST.get('Years'))))
            today = (datetime.now().strftime("%d/%m/"))
            dt = "%s%s" % (today, birthYear)
            person.birthDate = datetime.strptime(dt, '%d/%m/%Y')

    if(request.POST.get('aprox')):
        person.birthDateSupposed = True
    else:
        person.birthDateSupposed = False
    """ AGE """

    person.gender = request.POST['gender']

    # maritalStatus
    try:
        if not (request.POST['maritalStatus']):
            person.maritalStatus = None
        else:
            person.maritalStatus = MaritalStatus.objects.get(
                pk=request.POST['maritalStatus'])
    except:
        person.maritalStatus = None

    # birthPlace (Naturality)
    person.birthForeignCity = ''
    person.birthForeignState = ''
    person.birthForeignCountry = None

    try:
        person.birthPlace = City.objects.get(pk=request.POST['birthPlace'])
    except:
        person.birthPlace = None
        try:
            person.birthForeignCity = request.POST['birthForeignCity']
        except:
            person.birthForeignCity = None
        try:
            person.birthForeignState = request.POST['birthForeignState']
        except:
            person.birthForeignState = None
        try:
            person.birthForeignCountry = request.POST['birthForeignCountry']
        except:
            person.birthForeignCountry = None

    person.save()
    user = request.user
    person.organization.add(user.get_profile().org_active)

    # save phone numbers (using Phone APP)
    phone_save(person, request.POST.getlist('phoneId'), request.POST.getlist('area'), request.POST.getlist(
        'phoneNumber'), request.POST.getlist('ext'), request.POST.getlist('phoneType'))

    # save addresses (using Address APP)
    address_save(person, request.POST.getlist('addressId'), request.POST.getlist('addressPrefix'),
                 request.POST.getlist(
                     'addressLine1'), request.POST.getlist('addressLine2'),
                 request.POST.getlist(
                     'addressNumber'), request.POST.getlist('neighborhood'),
                 request.POST.getlist(
                     'zipCode'), request.POST.getlist('addressType'),
                 request.POST.getlist('city'), request.POST.getlist(
                     'foreignCountry'),
                 request.POST.getlist('foreignState'), request.POST.getlist('foreignCity'))

    # save documents (using Document APP)
    document_save(person, request.POST.getlist('documentId'), request.POST.getlist('document_typeDocument'), request.POST.getlist(
        'document_document'), request.POST.getlist('document_issuer'), request.POST.getlist('document_state'))

    # save internet data
    email_save(person, request.POST.getlist('email_id'), request.POST.getlist(
        'email_email'), request.POST.getlist('email_type'))
    site_save(person, request.POST.getlist('site_id'), request.POST.getlist(
        'site_description'), request.POST.getlist('site_site'))
    im_save(person, request.POST.getlist('im_id'), request.POST.getlist(
        'im_identity'), request.POST.getlist('im_network'))

    return person