Exemple #1
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/')
Exemple #2
0
def save_mini(request):

    user = request.user
    obj = Organization()

    if request.POST.get('label'):
        if Organization.objects.filter(short_name=slugify(request.POST.get('label')) ):
            r = True
        else:
            obj.name = request.POST.get('label') # adding by mini form
            obj.short_name = slugify(request.POST.get('label'))
            obj.organization = user.get_profile().org_active
            obj.contact_owner = user.get_profile().person
            obj.save()
            r = u"%s|%s|%s" % (False, obj.id, obj.name)

    return HttpResponse(r)
Exemple #3
0
def save_mini(request):

    user = request.user
    obj = Organization()

    if request.POST.get('label'):
        if Organization.objects.filter(
                short_name=slugify(request.POST.get('label'))):
            r = True
        else:
            obj.name = request.POST.get('label')  # adding by mini form
            obj.short_name = slugify(request.POST.get('label'))
            obj.organization = user.get_profile().org_active
            obj.contact_owner = user.get_profile().person
            obj.save()
            r = u"%s|%s|%s" % (False, obj.id, obj.name)

    return HttpResponse(r)