Beispiel #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
Beispiel #2
0
	def setUp(self):
		timeunit = TimeUnit(unit="u", time="time")
		clientD = Client()
		referralD = Referral()
		scheduleD = ScheduleOccurrence()

		self.demandD = Demand(date_created=datetime(2015, 10, 15, 12, 12, 12),
							 date_modified=datetime(2015, 10, 15, 13, 13, 13),
							 edit_status="edit", initial_complaint=True, demand="demand",
							 description="desc", how_long_it_happens=timeunit, frequency=timeunit,
							 severity="severity", duration=timeunit, demand_status = "status",
							 demand_resolution=datetime(2015, 10, 15, 13, 13, 13), bibliography="bibliography",
							 related_sites="related_sites", comments="comments",
							 client=clientD, referral=referralD, occurrence=scheduleD)

		self.demand = "demand"		
		self.frequency = TimeUnit
		self.how_long_it_happens = TimeUnit
		self.duration = TimeUnit
		

		clientD.pk = 11
		referralD.pk = 22
		scheduleD.pk = 33

		self.demandD.client = clientD
		self.demandD.referral = referralD
		self.demandD.occurrence = scheduleD
Beispiel #3
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
Beispiel #4
0
    def test_can_save_client_with_min_attributes(self):
        user = mommy.make('auth.User')
        person = mommy.make('person.Person', user=user)

        old_count = Client.objects.count() 

        client = Client()
        client.person = person
        client.idRecord = 42
        client.save()
        self.assertGreater(Client.objects.count(), old_count)
Beispiel #5
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)
Beispiel #6
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
Beispiel #7
0
    def setUp(self):
        #organization = Organization(name='Organizacao Teste',short_name='OT')
        person = Person()
        person.name = 'Levi Moraes'
        person.id = 01
        person.active = True

        phone = Phone()
        phone.phoneNumber = '12344321'

        #person.phones = phone

        self.client = Client()
        self.client.person = person

        self.client
Beispiel #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
Beispiel #9
0
class ClientModelTest(unittest.TestCase):
    def setUp(self):
        #organization = Organization(name='Organizacao Teste',short_name='OT')
        person = Person()
        person.name = 'Levi Moraes'
        person.id = 01
        person.active = True

        phone = Phone()
        phone.phoneNumber = '12344321'

        #person.phones = phone

        self.client = Client()
        self.client.person = person

        self.client

    def testEmployeeReturn(self):
        self.assertEqual(self.client.person.name, 'Levi Moraes')

    def testIsActiveMethod(self):
        self.assertTrue(self.client.is_active())

    def testIsNotActive(self):
        pass

    def testListItemTitle(self):
        self.assertEqual(self.client.list_item_title(), 'Levi Moraes')

    def testIsActive(self):
        self.assertEqual(self.client.is_active(), True)

    def testListItemTitleAditional(self):
        self.assertEqual(self.client.list_item_title_aditional(), '')

    def testListItemDescription(self):
        self.assertEqual(self.client.list_item_description(), '')

    def tearDown(self):
        del self.client
Beispiel #10
0
class ClientModelTest(unittest.TestCase):
    def setUp(self):
        #organization = Organization(name='Organizacao Teste',short_name='OT')
        person = Person()
        person.name = 'Levi Moraes'
        person.id = 01
        person.active = True

        phone = Phone()
        phone.phoneNumber = '12344321'

        #person.phones = phone

        self.client = Client()
        self.client.person = person

        self.client

    def testEmployeeReturn(self):
        self.assertEqual(self.client.person.name, 'Levi Moraes')

    def testIsActiveMethod(self):
        self.assertTrue(self.client.is_active())

    def testIsNotActive(self):
        pass

    def testListItemTitle(self):
        self.assertEqual(self.client.list_item_title(), 'Levi Moraes')

    def testIsActive(self):
        self.assertEqual(self.client.is_active(),True)

    def testListItemTitleAditional(self):
        self.assertEqual(self.client.list_item_title_aditional(),'')

    def testListItemDescription(self):
        self.assertEqual(self.client.list_item_description(),'')

    def tearDown(self):
        del self.client
Beispiel #11
0
    def test_raise_exception_when_missing_fields(self):
        user = mommy.make('auth.User')
        person = mommy.make('person.Person', user=user)

        client = Client()
        with self.assertRaisesMessage(DatabaseError, "person_id"):
            client.save()

        client.person = person
        with self.assertRaisesMessage(DatabaseError, "idRecord"):
            client.save()
Beispiel #12
0
	def setUp(self):
		clientD = Client()
		referralD = Referral()
		scheduleD = ScheduleOccurrence()

		self.diagnosisD = Diagnosis(date_created=datetime(2015, 10, 15, 12, 12, 12),
							 date_modified=datetime(2015, 10, 15, 13, 13, 13),
							 edit_status="edit", diagnosis_date=datetime(2015, 10, 15, 11, 11, 11),
							 diagnosis_resolution=datetime(2015, 10, 15, 11, 11, 11),
							 diagnosis="diagnosis", diagnosis_status="status", diagnosis_status2="status2", 
							 clinical_description="desc", severity="severity", treatment_indicated="treatment_indicated",
							 bibliography="bibliography", related_sites="related_sites", comments="comments",
							 client=clientD, referral=referralD, occurrence=scheduleD)
		self.diagnosis = "diagnosis"
Beispiel #13
0
    def setUp(self):
        #organization = Organization(name='Organizacao Teste',short_name='OT')
        person = Person()
        person.name = 'Levi Moraes'
        person.id = 01
        person.active = True

        phone = Phone()
        phone.phoneNumber = '12344321'

        #person.phones = phone

        self.client = Client()
        self.client.person = person

        self.client
Beispiel #14
0
    def test_can_save_client_with_min_attributes(self):
        user = mommy.make('auth.User')
        person = mommy.make('person.Person', user=user)

        old_count = Client.objects.count()

        client = Client()
        client.person = person
        client.idRecord = 42
        client.save()
        self.assertGreater(Client.objects.count(), old_count)
Beispiel #15
0
    def test_raise_exception_when_missing_fields(self):
        user = mommy.make('auth.User')
        person = mommy.make('person.Person', user=user)

        client = Client()
        with self.assertRaisesMessage(DatabaseError, "person_id"):
            client.save()

        client.person = person
        with self.assertRaisesMessage(DatabaseError, "idRecord"):
            client.save()
Beispiel #16
0
def setup_required_client():
    organization1 = Organization.objects.get(name=user_stub()["organization"])

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

    person = Person.objects.create(user=user)
    person.name = "Pessoa"
    person.nickname = "nickname"
    person.organization.add(organization1)
    person.save()

    client = Client()
    client.person = person
    client.idRecord = 2
    client.is_active = False
    client.save()
Beispiel #17
0
def setup_required_client():
    organization1 = Organization.objects.get(name=user_stub()["organization"])

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

    person = Person.objects.create(user=user)
    person.name = "Pessoa"
    person.nickname = "nickname"
    person.organization.add(organization1)
    person.save()

    client = Client()
    client.person = person
    client.idRecord = 2
    client.is_active = False
    client.save()