Ejemplo n.º 1
0
    def save(self, request, client, *args, **kwargs):
        company_client = super(CompanyClientForm, self).save(commit=False,
                                                             *args,
                                                             **kwargs)
        company_client.company = client.person.company

        if not request.POST.get(
                'client_id'
        ):  # client and person is new, lets create it before
            person = Person(name=request.POST.get('name'))
            person.save()
            person.organization.add(request.user.get_profile().org_active.id)
            client_related = Client(
                person=person,
                idRecord=request.user.get_profile().org_active.last_id_record +
                1)
            client_related.save()
            company_client.active = True
        else:  # client already exist, let's create or edit some existing relation
            if not request.POST.get('client_id') in [
                    i.client.id
                    for i in client.person.company.companyclient_set.all()
            ] and not request.POST.get(
                    'active'):  # relation already exists, let's edit it
                company_client.active = True
            client_related = Client.objects.get(
                pk=request.POST.get('client_id'),
                person__organization=request.user.get_profile().org_active)

        company_client.client = client_related
        company_client.responsible = False if not request.POST.get(
            'responsible') else True
        company_client.save()

        return company_client
Ejemplo n.º 2
0
    def save(self, request, client, *args, **kwargs):
        company_client = super(CompanyClientForm, self).\
            save(commit=False, *args, **kwargs)
        company_client.company = client.person.company

        # client and person is new, lets create it before
        if not request.POST.get('client_id'):
            person = Person(name=request.POST.get('name'))
            person.save()
            person.organization.add(request.user.get_profile().org_active.id)
            client_related = Client(person=person,
                                    idRecord=request.user.get_profile().
                                    org_active.last_id_record + 1)
            client_related.save()
            company_client.active = True
        # client already exist, let's create or edit some existing relation
        else:
            # relation already exists, let's edit it
            if not request.POST.get('client_id') in [
                i.client.id for i in
                client.person.company.
                companyclient_set.all()]\
                    and not request.POST.get('active'):
                company_client.active = True
            client_related = Client.objects.get(pk=request.POST.get(
                'client_id'), person__organization=request.
                user.get_profile().org_active)

        company_client.client = client_related
        company_client.responsible = False if not request.POST.get(
            'responsible') else True
        company_client.save()

        return company_client
Ejemplo n.º 3
0
def setup_required_service():
    service_type = ServiceType()
    service_type.name = "Tipo de Servico"
    service_type.save()

    area1 = Area()
    area1.area_name = "area 1"
    area1.save()

    organization1 = Organization.objects.get(name=user_stub()["organization"])

    service1 = Service()
    service1.area = area1
    service1.name = "Servico 1"
    service1.organization = organization1
    service1.service_type = service_type
    service1.save()

    a = AdmissionChoice()
    a.weight = 1
    a.save()

    u = User()
    u.username = "******"
    u.password = "******"
    u.is_superuser = True
    u.save()

    person = Person()
    person.name = "nome12"
    person.user = u
    person.nickname = "apelido12"
    person.save()
    person.organization.add(organization1)
    person.save()
Ejemplo n.º 4
0
def setup_required_service():
    service_type = ServiceType()
    service_type.name="Tipo de Servico"
    service_type.save()

    area1 = Area()
    area1.area_name = "area 1"
    area1.save()

    organization1 = Organization.objects.get(name=user_stub()["organization"])

    service1 = Service()
    service1.area = area1;
    service1.name = "Servico 1"
    service1.organization = organization1
    service1.service_type = service_type
    service1.save()

    a = AdmissionChoice()
    a.weight = 1
    a.save()

    u = User()
    u.username = "******"
    u.password = "******"
    u.is_superuser = True
    u.save()

    person = Person()
    person.name = "nome12"
    person.user = u
    person.nickname = "apelido12"
    person.save()
    person.organization.add(organization1)
    person.save()
Ejemplo n.º 5
0
def save_mini_professional(request):
    object = CareProfessional()
    person = Person()
    person.name = request.POST.get('label')
    person.save()
    person.organization.add(Organization.objects.get(pk=request.POST.get('organization')))
    object.person = person
    object.save()

    return HttpResponse("%s" % (object.id))
Ejemplo n.º 6
0
def save_mini_professional(request):
    object = CareProfessional()
    person = Person()
    person.name = request.POST.get('label')
    person.save()
    person.organization.add(
        Organization.objects.get(pk=request.POST.get('organization')))
    object.person = person
    object.save()

    return HttpResponse("%s" % (object.id))
Ejemplo n.º 7
0
    def setUp(self):
        self.factory = RequestFactory()
        p = Person()

        User.objects.create(username="******", password="******")      
        p.user = User.objects.get(username="******")

        p.save()

        client = Client(person=p, idRecord=1)
        client.save()

        self.person = Person.objects.get(user_id=p.user.id)
Ejemplo n.º 8
0
    def save(self, request, client, *args, **kwargs):
        family = super(FamilyForm, self).save(*args, **kwargs)
        family.client = client
        if request.POST.get('client_id'): # existing client
            client_related = Client.objects.filter(pk=request.POST.get('client_id'), person__organization = request.user.get_profile().org_active)[0]
        else: # client and person is new, lets create it before
            person = Person(name=request.POST.get('name'))
            person.save()
            person.organization.add(request.user.get_profile().org_active.id)
            client_related = Client(person=person, idRecord = request.user.get_profile().org_active.last_id_record + 1)
            client_related.save()

        family.client_related = client_related
        family.save()
        return family
Ejemplo n.º 9
0
def contact_professional_save(request, object_id=None):

    try:
        object = get_object_or_404(CareProfessional, pk=object_id)
        identification = object.professionalIdentification
        person = object.person
    except:
        object = CareProfessional()
        person = Person()

    if object.id and not have_careprofessional_perms_save(request, object):
        return render_to_response('403.html', {
            'object': _("Access Denied"),
        },
                                  context_instance=RequestContext(request))

    if not request.POST.get('name'):
        return HttpResponseRedirect(
            ('/contact/form/professional/' if not object.id else
             ('/contact/form/professional/%s/') % object.id))

    if not object.professionalIdentification:
        if request.POST.get('symbol'):
            identification = ProfessionalIdentification()
            identification.profession = Profession.objects.get(
                id=request.POST.get('service_profession'))
            identification.registerNumber = request.POST.get(
                'professional_subscription')
            identification.save()
            object.professionalIdentification = identification
        else:
            object.professionalIdentification = None

    person.name = request.POST.get('name')
    person.save()

    person.organization.remove()
    person.organization.add(
        Organization.objects.get(pk=request.POST.get('organization')))

    person = extra_data_save(request, person)

    object.comments = request.POST.get('comments')
    object.person = person
    object.save()

    messages.success(request, _('Professional contact saved successfully'))
    return HttpResponseRedirect('/contact/form/professional/%s/' % (object.id))
Ejemplo n.º 10
0
    def setUp(self):
        person = Person()

        User.objects.create(username="******", password="******")
        person.user = User.objects.get(username="******")

        person.birthDate = "1990-05-14"
        person.birthForeignCity = "Melbourne"
        person.birthForeignState = "Victoria"
        person.birthForeignCountry = '1'

        person.save()

        contentType = ContentType()
        contentType.app_label = "auth"
        contentType.model = "any"
        contentType.save()

        emailType = EmailType()
        emailType.description = "Email Type"
        emailType.save()
        email = Email()
        email.email = "*****@*****.**"
        email.email_type = EmailType.objects.all()[0]
        email.content_object = person
        email.save()

        site = Site()
        site.description = "this is a website"
        site.site = "www.google.com.br"
        site.content_object = person
        site.save()

        person.save()

        self.p = Person.objects.get(user_id=person.user.id)

        def tearDown(self):
            for person in Person.objects.all():
                person.delete()

            for user in User.objects.all():
                user.delete()
Ejemplo n.º 11
0
    def setUp(self):
        person = Person()
		
        User.objects.create(username="******", password="******")		
        person.user = User.objects.get(username="******")
	    
        person.birthDate = "1990-05-14"
        person.birthForeignCity = "Melbourne"
        person.birthForeignState = "Victoria"
        person.birthForeignCountry = '1'
        
        person.save()
        
        contentType = ContentType()
        contentType.app_label = "auth"
        contentType.model = "any"
        contentType.save()
        
        emailType = EmailType()
        emailType.description = "Email Type"
        emailType.save()
        email = Email()
        email.email = "*****@*****.**"
        email.email_type = EmailType.objects.all()[0]
        email.content_object = person
        email.save()

        site = Site()
        site.description = "this is a website"
        site.site = "www.google.com.br"
        site.content_object = person
        site.save()

        person.save()

        self.p = Person.objects.get(user_id=person.user.id)

	def tearDown(self):
	    for person in Person.objects.all():
	        person.delete()

	    for user in User.objects.all():
	        user.delete()
Ejemplo n.º 12
0
def contact_professional_save(request, object_id=None):

    try:
        object = get_object_or_404(CareProfessional, pk=object_id)
        identification = object.professionalIdentification
        person = object.person
    except:
        object = CareProfessional()
        person = Person()

    if object.id and not have_careprofessional_perms_save(request, object):
        return render_to_response('403.html', {'object': _("Access Denied"), }, context_instance=RequestContext(request))

    if not request.POST.get('name'):
        return HttpResponseRedirect(('/contact/form/professional/' if not object.id else ('/contact/form/professional/%s/') % object.id))

    if not object.professionalIdentification:
        if request.POST.get('symbol'):
            identification = ProfessionalIdentification()
            identification.profession = Profession.objects.get(
                id=request.POST.get('service_profession'))
            identification.registerNumber = request.POST.get(
                'professional_subscription')
            identification.save()
            object.professionalIdentification = identification
        else:
            object.professionalIdentification = None

    person.name = request.POST.get('name')
    person.save()

    person.organization.remove()
    person.organization.add(Organization.objects.get(
        pk=request.POST.get('organization')))

    person = extra_data_save(request, person)

    object.comments = request.POST.get('comments')
    object.person = person
    object.save()

    messages.success(request, _('Professional contact saved successfully'))
    return HttpResponseRedirect('/contact/form/professional/%s/' % (object.id))
Ejemplo n.º 13
0
    def save(self, request, client, *args, **kwargs):
        family = super(FamilyForm, self).save(*args, **kwargs)
        family.client = client
        if request.POST.get('client_id'):  # existing client
            client_related = Client.objects.filter(
                pk=request.POST.get('client_id'),
                person__organization=request.user.get_profile().org_active)[0]
        else:  # client and person is new, lets create it before
            person = Person(name=request.POST.get('name'))
            person.save()
            person.organization.add(request.user.get_profile().org_active.id)
            client_related = Client(
                person=person,
                idRecord=request.user.get_profile().org_active.last_id_record +
                1)
            client_related.save()

        family.client_related = client_related
        family.save()
        return family