Skip to content

Commit

Permalink
Fix shell incluir telefones. Close #48
Browse files Browse the repository at this point in the history
  • Loading branch information
rg3915 committed Nov 25, 2018
1 parent 7964117 commit 7cf83c3
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 20 deletions.
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,31 @@ createuser:
./manage.py createsuperuser --username='admin' --email=''

shell_num_last_proposal:
./manage.py shell < shell/shell_num_last_proposal.py
./manage.py shell_plus < shell/shell_num_last_proposal.py

shell_occupation:
./manage.py shell < shell/shell_occupation.py
./manage.py shell_plus < shell/shell_occupation.py

shell_employee:
./manage.py shell < shell/shell_employee.py
./manage.py shell_plus < shell/shell_employee.py

shell_person:
./manage.py shell < shell/shell_person.py
./manage.py shell_plus < shell/shell_person.py

shell_customer:
./manage.py shell < shell/shell_customer.py
./manage.py shell_plus < shell/shell_customer.py

shell_work:
./manage.py shell < shell/shell_work.py
./manage.py shell_plus < shell/shell_work.py

shell_entry:
./manage.py shell < shell/shell_entry.py
./manage.py shell_plus < shell/shell_entry.py

shell_proposal:
./manage.py shell < shell/shell_proposal.py
./manage.py shell_plus < shell/shell_proposal.py

shell_contract:
./manage.py shell < shell/shell_contract.py
./manage.py shell_plus < shell/shell_contract.py

selenium_login:
python selenium/selenium_login.py
Expand Down
7 changes: 3 additions & 4 deletions orcamentos/proposal/actions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from django.utils import timezone
from django.shortcuts import redirect, resolve_url as r
from django.http import HttpResponse
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.auth.decorators import login_required
from django.core.exceptions import ObjectDoesNotExist
from django.http import HttpResponse
from django.shortcuts import redirect, resolve_url as r
from django.utils import timezone
from orcamentos.crm.models import Employee
from orcamentos.proposal.models import Entry, Proposal, Contract, NumLastProposal
Expand Down
34 changes: 31 additions & 3 deletions shell/shell_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@
import names
import csv
from django.template.defaultfilters import slugify
from orcamentos.crm.models import Customer
from orcamentos.crm.models import Customer, Person, PhonePerson
from orcamentos.utils.lists import COMPANY_LIST
from orcamentos.utils.gen_random_values import gen_digits, gen_cpf, gen_rg
from orcamentos.utils.gen_names import gen_male_first_name, gen_female_first_name, gen_last_name
from orcamentos.utils.gen_random_values import (
gen_cpf,
gen_digits,
gen_phone,
gen_rg,
)
from orcamentos.utils.gen_names import (
gen_female_first_name,
gen_male_first_name,
)


customer_list = []
Expand Down Expand Up @@ -88,3 +96,23 @@


# done

'''
Para cada Person incluimos dois telefones:
um principal e um celular
'''
customers = Customer.objects.all()
aux = []
for person in customers:
obj_pri = PhonePerson(
phone=gen_phone(),
person=person,
)
obj = PhonePerson(
phone=gen_phone(),
person=person,
phone_type='cel'
)
aux.append(obj_pri)
aux.append(obj)
PhonePerson.objects.bulk_create(aux)
25 changes: 24 additions & 1 deletion shell/shell_employee.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from django.template.defaultfilters import slugify
from orcamentos.crm.models import Employee, Occupation
from orcamentos.crm.models import Employee, Occupation, PhoneEmployee
from orcamentos.utils.gen_random_values import gen_phone
from orcamentos.utils.lists import OCCUPATION_LIST


'''
Definindo a senha padrão para todos os usuarios,
como o django aceita apenas hash, criei uma senha padrão [password=1] e copiei
Expand Down Expand Up @@ -223,3 +225,24 @@ def get_occupation(occupation_name):


# done


'''
Para cada Person incluimos dois telefones:
um principal e um celular
'''
employees = Employee.objects.all()
aux = []
for employee in employees:
obj_pri = PhoneEmployee(
phone=gen_phone(),
employee=employee,
)
obj = PhoneEmployee(
phone=gen_phone(),
employee=employee,
phone_type='cel'
)
aux.append(obj_pri)
aux.append(obj)
PhoneEmployee.objects.bulk_create(aux)
29 changes: 26 additions & 3 deletions shell/shell_person.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
import names
import csv
from django.template.defaultfilters import slugify
from orcamentos.crm.models import Person, Occupation
from orcamentos.crm.models import Person, PhonePerson, Occupation
from orcamentos.utils.lists import COMPANY_LIST, OCCUPATION_LIST
from orcamentos.utils.gen_random_values import *
from orcamentos.utils.gen_names import *
from orcamentos.utils.gen_random_values import gen_phone, gen_rg, gen_cpf
from orcamentos.utils.gen_names import (
gen_female_first_name,
gen_male_first_name,
)

address_list = []
REPEAT = 48
Expand Down Expand Up @@ -113,3 +116,23 @@


print('%d Persons salvo com sucesso.' % REPEAT)

'''
Para cada Person incluimos dois telefones:
um principal e um celular
'''
persons = Person.objects.all()
aux = []
for person in persons:
obj_pri = PhonePerson(
phone=gen_phone(),
person=person,
)
obj = PhonePerson(
phone=gen_phone(),
person=person,
phone_type='cel'
)
aux.append(obj_pri)
aux.append(obj)
PhonePerson.objects.bulk_create(aux)

0 comments on commit 7cf83c3

Please sign in to comment.