init defaults completed
This commit is contained in:
@@ -140,7 +140,10 @@ def create_occupant_types_defaults():
|
||||
]
|
||||
|
||||
for list_occupant_type in list_occupant_types:
|
||||
OccupantTypes.find_or_create(**{"is_confirmed": True, **list_occupant_type})
|
||||
created_type = OccupantTypes.find_or_create(**{"is_confirmed": True, **list_occupant_type})
|
||||
created_type.save()
|
||||
created_type.is_confirmed = True
|
||||
created_type.save()
|
||||
|
||||
|
||||
def create_application_defaults():
|
||||
@@ -157,6 +160,7 @@ def create_application_defaults():
|
||||
RelationshipDutyCompany,
|
||||
)
|
||||
|
||||
created_list = []
|
||||
created_by, confirmed_by = "System", "System"
|
||||
company_management = Companies.find_or_create(
|
||||
**{
|
||||
@@ -171,40 +175,28 @@ def create_application_defaults():
|
||||
"created_by": created_by,
|
||||
"confirmed_by": confirmed_by,
|
||||
"is_commercial": True,
|
||||
**dict(
|
||||
is_confirmed=True, active=True, deleted=False, is_notification_send=True
|
||||
),
|
||||
}
|
||||
)
|
||||
created_list.append(company_management)
|
||||
|
||||
Duties.init_a_company_default_duties(
|
||||
another_list = Duties.init_a_company_default_duties(
|
||||
company_id=company_management.id, company_uu_id=str(company_management.uu_id)
|
||||
)
|
||||
created_list.extend(another_list)
|
||||
bulk_duty = Duty.filter_by_one(
|
||||
system=True,
|
||||
duty_code="BULK",
|
||||
).data
|
||||
|
||||
RelationshipDutyCompany.find_or_create(
|
||||
duties_id=bulk_duty.id,
|
||||
owner_id=company_management.id,
|
||||
member_id=company_management.id,
|
||||
parent_id=None,
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
|
||||
it_dept = Departments.filter_by_one(
|
||||
system=True,
|
||||
department_name="IT Department",
|
||||
department_code="ITD001",
|
||||
company_id=company_management.id,
|
||||
company_uu_id=str(company_management.uu_id),
|
||||
**Departments.valid_record_dict,
|
||||
is_confirmed=True,
|
||||
).data
|
||||
|
||||
Duty.find_or_create(
|
||||
created_duty = Duty.find_or_create(
|
||||
**dict(
|
||||
duty_name="Database Manager",
|
||||
duty_code="DM",
|
||||
@@ -217,7 +209,9 @@ def create_application_defaults():
|
||||
is_notification_send=True,
|
||||
)
|
||||
)
|
||||
Duty.find_or_create(
|
||||
created_list.append(created_duty)
|
||||
|
||||
created_duty = Duty.find_or_create(
|
||||
**dict(
|
||||
duty_name="Network Manager",
|
||||
duty_code="NM",
|
||||
@@ -230,6 +224,8 @@ def create_application_defaults():
|
||||
is_notification_send=True,
|
||||
)
|
||||
)
|
||||
created_list.append(created_duty)
|
||||
|
||||
application_manager_duty = Duty.find_or_create(
|
||||
duty_name="Application Manager",
|
||||
duty_code="AM",
|
||||
@@ -241,6 +237,7 @@ def create_application_defaults():
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
created_list.append(application_manager_duty)
|
||||
application_super_user_duty = Duty.find_or_create(
|
||||
duty_name="Super User",
|
||||
duty_code="SUE",
|
||||
@@ -252,7 +249,7 @@ def create_application_defaults():
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
|
||||
created_list.append(application_super_user_duty)
|
||||
application_manager_duties = Duties.find_or_create(
|
||||
department_id=it_dept.id,
|
||||
department_uu_id=str(it_dept.uu_id),
|
||||
@@ -265,6 +262,7 @@ def create_application_defaults():
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
created_list.append(application_manager_duties)
|
||||
super_user_duties = Duties.find_or_create(
|
||||
department_id=it_dept.id,
|
||||
department_uu_id=str(it_dept.uu_id),
|
||||
@@ -277,6 +275,31 @@ def create_application_defaults():
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
created_list.append(super_user_duties)
|
||||
RelationshipDutyCompany.find_or_create(
|
||||
duties_id=application_manager_duties.id,
|
||||
owner_id=company_management.id,
|
||||
member_id=company_management.id,
|
||||
parent_id=None,
|
||||
child_count=0,
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
created_list.append(application_manager_duties)
|
||||
RelationshipDutyCompany.find_or_create(
|
||||
duties_id=super_user_duties.id,
|
||||
owner_id=company_management.id,
|
||||
member_id=company_management.id,
|
||||
parent_id=None,
|
||||
child_count=0,
|
||||
is_confirmed=True,
|
||||
active=True,
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
created_list.append(super_user_duties)
|
||||
|
||||
app_manager = People.find_or_create(
|
||||
**{
|
||||
@@ -293,12 +316,9 @@ def create_application_defaults():
|
||||
"tax_no": "1231231231",
|
||||
"created_by": created_by,
|
||||
"confirmed_by": confirmed_by,
|
||||
**dict(
|
||||
is_confirmed=True, active=True, deleted=False, is_notification_send=True
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
created_list.append(app_manager)
|
||||
sup_manager = People.find_or_create(
|
||||
**{
|
||||
"firstname": "Berkay Super User",
|
||||
@@ -314,12 +334,9 @@ def create_application_defaults():
|
||||
"tax_no": "1231231232",
|
||||
"created_by": created_by,
|
||||
"confirmed_by": confirmed_by,
|
||||
**dict(
|
||||
is_confirmed=True, active=True, deleted=False, is_notification_send=True
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
created_list.append(sup_manager)
|
||||
application_manager_staff = Staff.find_or_create(
|
||||
staff_description="Application Manager",
|
||||
staff_name="Application Manager Employee",
|
||||
@@ -331,6 +348,7 @@ def create_application_defaults():
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
created_list.append(application_manager_staff)
|
||||
super_user_staff = Staff.find_or_create(
|
||||
staff_description="Super User",
|
||||
staff_name="Super User Employee",
|
||||
@@ -342,6 +360,7 @@ def create_application_defaults():
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
created_list.append(super_user_staff)
|
||||
app_manager_employee = Employees.find_or_create(
|
||||
staff_id=application_manager_staff.id,
|
||||
staff_uu_id=str(application_manager_staff.uu_id),
|
||||
@@ -352,6 +371,8 @@ def create_application_defaults():
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
created_list.append(app_manager_employee)
|
||||
|
||||
super_user_employee = Employees.find_or_create(
|
||||
staff_id=super_user_staff.id,
|
||||
staff_uu_id=str(super_user_staff.uu_id),
|
||||
@@ -362,6 +383,8 @@ def create_application_defaults():
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
created_list.append(super_user_employee)
|
||||
|
||||
app_manager_user = Users.find_or_create(
|
||||
person_id=app_manager.id,
|
||||
person_uu_id=str(app_manager.uu_id),
|
||||
@@ -377,17 +400,18 @@ def create_application_defaults():
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
if not app_manager_user.is_found:
|
||||
app_manager_user.reset_password_token()
|
||||
MongoQueryIdentity(
|
||||
company_uuid=company_management.uu_id
|
||||
).create_domain_via_user(
|
||||
payload=DomainViaUser(
|
||||
user_uu_id=str(app_manager_user.uu_id),
|
||||
main_domain="evyos.com.tr",
|
||||
other_domains_list=["evyos.com.tr"],
|
||||
)
|
||||
created_list.append(app_manager_user)
|
||||
app_manager_user.reset_password_token()
|
||||
mongo_engine = MongoQueryIdentity(
|
||||
company_uuid=company_management.uu_id
|
||||
)
|
||||
mongo_engine.create_domain_via_user(
|
||||
payload=DomainViaUser(
|
||||
user_uu_id=str(app_manager_user.uu_id),
|
||||
main_domain="evyos.com.tr",
|
||||
other_domains_list=["evyos.com.tr"],
|
||||
)
|
||||
)
|
||||
|
||||
sup_manager_employee = Users.find_or_create(
|
||||
person_id=sup_manager.id,
|
||||
@@ -404,15 +428,18 @@ def create_application_defaults():
|
||||
deleted=False,
|
||||
is_notification_send=True,
|
||||
)
|
||||
created_list.append(sup_manager_employee)
|
||||
|
||||
if not sup_manager_employee.is_found:
|
||||
sup_manager_employee.reset_password_token()
|
||||
MongoQueryIdentity(
|
||||
company_uuid=company_management.uu_id
|
||||
).create_domain_via_user(
|
||||
payload=DomainViaUser(
|
||||
user_uu_id=str(sup_manager_employee.uu_id),
|
||||
main_domain="evyos.com.tr",
|
||||
other_domains_list=["evyos.com.tr"],
|
||||
)
|
||||
sup_manager_employee.reset_password_token()
|
||||
mongo_engine.create_domain_via_user(
|
||||
payload=DomainViaUser(
|
||||
user_uu_id=str(sup_manager_employee.uu_id),
|
||||
main_domain="evyos.com.tr",
|
||||
other_domains_list=["evyos.com.tr"],
|
||||
)
|
||||
)
|
||||
People.save()
|
||||
for created_list_item in created_list:
|
||||
created_list_item.is_confirmed = True
|
||||
created_list_item.save()
|
||||
print("All Defaults Create is now completed")
|
||||
|
||||
Reference in New Issue
Block a user