updated initilazer

This commit is contained in:
Berkay 2025-04-29 16:36:42 +03:00
parent 2d418644bb
commit 113e43c7d7
4 changed files with 99 additions and 55 deletions

View File

@ -444,6 +444,8 @@ def create_application_defaults(db_session):
f"{str(company_management.uu_id)}*Domain", f"{str(company_management.uu_id)}*Domain",
) )
with mongo_handler.collection(collection_name) as mongo_engine: with mongo_handler.collection(collection_name) as mongo_engine:
existing_record = mongo_engine.find_one({"user_uu_id": str(gen_manager_user.uu_id)})
if not existing_record:
mongo_engine.insert_one( mongo_engine.insert_one(
document={ document={
"user_uu_id": str(gen_manager_user.uu_id), "user_uu_id": str(gen_manager_user.uu_id),
@ -452,6 +454,15 @@ def create_application_defaults(db_session):
"modified_at": arrow.now().timestamp(), "modified_at": arrow.now().timestamp(),
} }
) )
else:
mongo_engine.update_one(
{"user_uu_id": str(gen_manager_user.uu_id)},
{"$set": {
"other_domains_list": [main_domain],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}}
)
app_manager_user = Users.find_or_create( app_manager_user = Users.find_or_create(
person_id=app_manager.id, person_id=app_manager.id,
@ -472,6 +483,8 @@ def create_application_defaults(db_session):
app_manager_user.password_token = PasswordModule.generate_refresher_token() app_manager_user.password_token = PasswordModule.generate_refresher_token()
with mongo_handler.collection(collection_name) as mongo_engine: with mongo_handler.collection(collection_name) as mongo_engine:
existing_record = mongo_engine.find_one({"user_uu_id": str(app_manager_user.uu_id)})
if not existing_record:
mongo_engine.insert_one( mongo_engine.insert_one(
document={ document={
"user_uu_id": str(app_manager_user.uu_id), "user_uu_id": str(app_manager_user.uu_id),
@ -480,6 +493,15 @@ def create_application_defaults(db_session):
"modified_at": arrow.now().timestamp(), "modified_at": arrow.now().timestamp(),
} }
) )
else:
mongo_engine.update_one(
{"user_uu_id": str(app_manager_user.uu_id)},
{"$set": {
"other_domains_list": [main_domain],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}}
)
sup_manager_employee = Users.find_or_create( sup_manager_employee = Users.find_or_create(
person_id=sup_manager.id, person_id=sup_manager.id,
@ -502,6 +524,9 @@ def create_application_defaults(db_session):
sup_manager_employee.password_expiry_begins = str(arrow.now()) sup_manager_employee.password_expiry_begins = str(arrow.now())
sup_manager_employee.password_token = PasswordModule.generate_refresher_token() sup_manager_employee.password_token = PasswordModule.generate_refresher_token()
with mongo_handler.collection(collection_name) as mongo_engine: with mongo_handler.collection(collection_name) as mongo_engine:
existing_record = mongo_engine.find_one({"user_uu_id": str(sup_manager_employee.uu_id)})
if not existing_record:
mongo_engine.insert_one( mongo_engine.insert_one(
document={ document={
"user_uu_id": str(sup_manager_employee.uu_id), "user_uu_id": str(sup_manager_employee.uu_id),
@ -510,6 +535,16 @@ def create_application_defaults(db_session):
"modified_at": arrow.now().timestamp(), "modified_at": arrow.now().timestamp(),
} }
) )
else:
# Optionally update the existing record if needed
mongo_engine.update_one(
{"user_uu_id": str(sup_manager_employee.uu_id)},
{"$set": {
"other_domains_list": [main_domain],
"main_domain": main_domain,
"modified_at": arrow.now().timestamp(),
}}
)
db_session.commit() db_session.commit()
print("All Defaults Create is now completed") print("All Defaults Create is now completed")

View File

@ -56,14 +56,23 @@ export const PaginationToolsComponent: React.FC<
{/* Navigation buttons - center */} {/* Navigation buttons - center */}
<div className="flex items-center space-x-2"> <div className="flex items-center space-x-2">
<Button
{
pagination.back ? (<><Button
variant="outline" variant="outline"
size="sm" size="sm"
onClick={() => handlePageChange(pagination.page - 1)} onClick={() => handlePageChange(pagination.page - 1)}
disabled={pagination.next}
> >
{t.previous} {t.previous}
</Button> </Button></>) : (<><Button
variant="ghost"
size="sm"
>
{t.previous}
</Button></>)
}
{/* Page number buttons */} {/* Page number buttons */}
<div className="flex items-center space-x-1"> <div className="flex items-center space-x-1">
@ -120,14 +129,20 @@ export const PaginationToolsComponent: React.FC<
)} )}
</div> </div>
<Button {
pagination.page < pagination.totalPages ? (<><Button
variant="outline" variant="outline"
size="sm" size="sm"
onClick={() => handlePageChange(pagination.page + 1)} onClick={() => handlePageChange(pagination.page + 1)}
disabled={pagination.back}
> >
{t.next} {t.next}
</Button> </Button></>) : (<><Button
variant="ghost"
size="sm"
>
{t.next}
</Button></>)
}
{/* Page text display */} {/* Page text display */}
<span className="px-4 py-1 text-sm text-muted-foreground"> <span className="px-4 py-1 text-sm text-muted-foreground">

View File

@ -36,14 +36,10 @@ export const SearchComponent: React.FC<SearchComponentProps> = ({
const handleSearch = (query: string, url: string, type: "employee" | "occupant") => { const handleSearch = (query: string, url: string, type: "employee" | "occupant") => {
const searchParams: Record<string, string> = {}; const searchParams: Record<string, string> = {};
if (query && query.length > 3) {
searchParams.name = query;
}
if (url) { if (url) {
searchParams.site_url = url; searchParams.site_url = url;
} }
searchParams.name = query
searchParams.application_for = type === "employee" ? "EMP" : "OCC"; searchParams.application_for = type === "employee" ? "EMP" : "OCC";
// Call onSearch with the search parameters // Call onSearch with the search parameters
@ -99,7 +95,7 @@ export const SearchComponent: React.FC<SearchComponentProps> = ({
value={searchQuery} value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)} onChange={(e) => setSearchQuery(e.target.value)}
onKeyUp={(e) => { onKeyUp={(e) => {
if (e.key === 'Enter' && searchQuery.length >= 3) { if (e.key === 'Enter') {
handleSearch(searchQuery, selectedUrl, selectedType); handleSearch(searchQuery, selectedUrl, selectedType);
} }
}} }}
@ -111,9 +107,7 @@ export const SearchComponent: React.FC<SearchComponentProps> = ({
size="sm" size="sm"
className="ml-2" className="ml-2"
onClick={() => { onClick={() => {
if (searchQuery.length >= 3) {
handleSearch(searchQuery, selectedUrl, selectedType); handleSearch(searchQuery, selectedUrl, selectedType);
}
}} }}
> >
<Search className="h-4 w-4" /> <Search className="h-4 w-4" />

View File

@ -12,6 +12,7 @@ services:
# - NODE_ENV=development # - NODE_ENV=development
# cpus: 1 # cpus: 1
# mem_limit: 2048m # mem_limit: 2048m
# volumes: # volumes:
# - client-frontend:/WebServices/client-frontend # - client-frontend:/WebServices/client-frontend
@ -26,7 +27,7 @@ services:
- "3001:3001" - "3001:3001"
environment: environment:
- NODE_ENV=development - NODE_ENV=development
cpus: 2 cpus: 1
mem_limit: 2048m mem_limit: 2048m
auth_service: auth_service:
@ -165,7 +166,6 @@ services:
networks: networks:
wag-services: wag-services:
# template_service: # template_service:
# container_name: template_service # container_name: template_service
# build: # build: