laishramPong commited on
Commit
d03e822
·
1 Parent(s): a53bc66

adding Application file

Browse files
app.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from time import sleep
3
+ from navigation import make_sidebar
4
+ import yaml
5
+ import datetime
6
+ import pytz
7
+ import os
8
+
9
+
10
+
11
+
12
+ make_sidebar()
13
+
14
+
15
+ st.title("Welcome to Job Finder")
16
+
17
+ hide_st_style = """
18
+ <style>
19
+ #MainMenu {visibility: hidden;}
20
+ footer {visibility: hidden;}
21
+ header {visibility: hidden;}
22
+ </style>
23
+ """
24
+ st.markdown(hide_st_style, unsafe_allow_html=True)
25
+
26
+ sign_in, sign_up = st.tabs(["Sign In", "Sign Up"])
27
+
28
+ with sign_in:
29
+ username = st.text_input("Username")
30
+ password = st.text_input("Password", type="password")
31
+ password = password.strip()
32
+ if st.button("Sign in", type="primary"):
33
+ with open('data/users/users.yaml', 'r') as file:
34
+ config = yaml.safe_load(file)
35
+
36
+
37
+ # print(config)
38
+ if username in list(config.keys()) and password == config[username]["password"]:
39
+ st.session_state.logged_in = True
40
+ st.session_state.user=username
41
+ st.success("Logged in successfully!")
42
+ sleep(0.5)
43
+ st.switch_page("pages/page1.py")
44
+ else:
45
+ st.error("Incorrect username or password")
46
+
47
+ with sign_up:
48
+ name = st.text_input("Full name")
49
+ username = st.text_input("Username",key="signup_user")
50
+ password = st.text_input("Password", type="password",key="Signup_pass")
51
+
52
+
53
+ if st.button("Sign Up", type="primary"):
54
+ with open('data/users/users.yaml', 'r') as file:
55
+ config = yaml.safe_load(file)
56
+
57
+ # new_user = {"username":username,"password":password}
58
+ if username and password and name:
59
+ if username in list(config.keys()):
60
+ st.warning("Username is already taken !!")
61
+ else:
62
+ user_info = {"password":password,
63
+ "time":datetime.datetime.now(pytz.timezone('Asia/Kolkata')),
64
+ "full_name":name,
65
+ "phone_no":0,
66
+ "what_app_no":0}
67
+
68
+ config[username] = user_info
69
+
70
+ # Define the folder name
71
+ folder_name = f'data/users/individuals/{username}'
72
+
73
+ # Create the folder if it doesn't already exist
74
+ status = {}
75
+ status[username] = user_info
76
+
77
+
78
+ if not os.path.exists(folder_name):
79
+ os.mkdir(folder_name)
80
+
81
+
82
+ #update the user info in global user
83
+ with open('data/users/users.yaml', 'w') as file:
84
+ yaml.dump(config, file, default_flow_style=False)
85
+
86
+
87
+
88
+ #Save user info as status file
89
+ with open(f'data/users/individuals/{username}/status.yaml', 'w') as file:
90
+ yaml.dump(status, file, default_flow_style=False)
91
+
92
+ if os.path.exists(folder_name):
93
+ st.info("Your account has been made successfully.")
94
+ st.success("Please login to continue")
95
+ else:
96
+ st.warning("Provide valid username and password")
data/jobs/individual/ssc/status.yaml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ applicants:
2
+ prem:
3
+ applied_date: 2024-10-05 22:24:22.721696+05:30
4
+ tom:
5
+ time: 2024-10-05 11:05:42.791710+05:30
6
+ description: This is a test job
7
+ name: ssc
8
+ qualification: 12+
data/jobs/individual/ssc1/status.yaml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ applicants:
2
+ pong:
3
+ applied_date: 2024-10-05 22:06:43.796564+05:30
4
+ prem:
5
+ applied_date: 2024-10-05 22:21:35.962653+05:30
6
+ tom:
7
+ time: 2024-10-05 16:35:53.100702+05:30
8
+ description: This is a test job
9
+ name: ssc 1
10
+ qualification: 12+
data/jobs/jobs.yaml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ ssc:
2
+ description: This is a new job...
3
+ qualification: 12 and 12+
4
+
5
+ ssc1:
6
+ description: This is a new job...
7
+ qualification: 12 and 12+
data/users/users.yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pong:
2
+ full_name: Pongthang
3
+ password: '123'
4
+ phone_no: 0
5
+ time: 2024-10-05 22:06:04.777256+05:30
6
+ what_app_no: 0
7
+ prem:
8
+ full_name: Premgupta Haobam
9
+ password: '123'
10
+ phone_no: 0
11
+ time: 2024-10-05 22:16:22.591876+05:30
12
+ what_app_no: 0
13
+ tom:
14
+ password: tom
15
+ time: 2024-10-05 11:05:42.791710+05:30
navigation.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from time import sleep
3
+ from streamlit.runtime.scriptrunner import get_script_run_ctx
4
+ from streamlit.source_util import get_pages
5
+
6
+
7
+ def get_current_page_name():
8
+ ctx = get_script_run_ctx()
9
+ if ctx is None:
10
+ raise RuntimeError("Couldn't get script context")
11
+
12
+ pages = get_pages("")
13
+
14
+ return pages[ctx.page_script_hash]["page_name"]
15
+
16
+
17
+ def make_sidebar():
18
+ with st.sidebar:
19
+ st.title("Your Jobs Finder")
20
+ st.write("")
21
+ st.write("")
22
+
23
+ if st.session_state.get("logged_in", False):
24
+ st.page_link("pages/page1.py", label="Find Your Jobs")
25
+ st.page_link("pages/page2.py", label="Account")
26
+ if st.session_state.user == "jobadmin":
27
+ st.page_link("pages/admin.py", label="admin")
28
+ st.write(f"Hello {st.session_state.user}")
29
+ st.write("")
30
+
31
+ if st.button("Log out"):
32
+ logout()
33
+
34
+ elif get_current_page_name() != "streamlit_app":
35
+ # If anyone tries to access a secret page without being logged in,
36
+ # redirect them to the login page
37
+ st.switch_page("streamlit_app.py")
38
+
39
+
40
+ def logout():
41
+ st.session_state.logged_in = False
42
+ st.info("Logged out successfully!")
43
+ sleep(0.5)
44
+ st.switch_page("streamlit_app.py")
pages/admin.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from navigation import make_sidebar
2
+ import streamlit as st
3
+ from time import sleep
4
+ import yaml
5
+
6
+ make_sidebar()
7
+
8
+ with st.button("Get job details"):
9
+ with open(f'data/jobs/jobs.yaml', 'r') as file:
10
+ jobs = yaml.safe_load(file)
11
+ for key,value in jobs.item():
12
+ with st.button(f"{key}"):
13
+ st.session_state["admin_job"] = key
14
+ st.switch_page("pages/admin_job.py")
15
+
pages/admin_job.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from navigation import make_sidebar
2
+ import streamlit as st
3
+ from time import sleep
4
+ import yaml
5
+
6
+ make_sidebar()
7
+
8
+ if st.session_state["admin_job"]:
9
+ with open(f'data/jobs/individual/{st.session_state.admin_job}/status.yaml', 'r') as file:
10
+
11
+ jobs_info = yaml.safe_load(file)
12
+
pages/job_details.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from navigation import make_sidebar
2
+ import streamlit as st
3
+ import yaml
4
+ import datetime
5
+ import pytz
6
+ import time
7
+ make_sidebar()
8
+
9
+ # Sample job data
10
+ with open(f'data/jobs/jobs.yaml', 'r') as file:
11
+ jobs = yaml.safe_load(file)
12
+ st.title("Job Details")
13
+ hide_st_style = """
14
+ <style>
15
+ #MainMenu {visibility: hidden;}
16
+ footer {visibility: hidden;}
17
+ header {visibility: hidden;}
18
+ </style>
19
+ """
20
+ st.markdown(hide_st_style, unsafe_allow_html=True)
21
+ # Show job details if a button was clicked
22
+ if st.session_state.selected_job:
23
+ selected_title = st.session_state.selected_job
24
+ st.subheader(f"Details for {selected_title}")
25
+
26
+ for key,value in jobs[selected_title].items():
27
+ st.write(f"**{key}**: {value}")
28
+
29
+ with open(f'data/jobs/individual/{st.session_state.selected_job}/status.yaml', 'r') as file:
30
+ jobs_info = yaml.safe_load(file)
31
+ if st.session_state.user in list(jobs_info["applicants"].keys()):
32
+ st.info("You already have applied the job !!")
33
+ else:
34
+ if st.button("Apply now"):
35
+ with open(f'data/jobs/individual/{st.session_state.selected_job}/status.yaml', 'r') as file:
36
+ jobs_info = yaml.safe_load(file)
37
+
38
+ applied_time = datetime.datetime.now(pytz.timezone('Asia/Kolkata'))
39
+ jobs_info["applicants"][st.session_state.user] = {'applied_date':applied_time}
40
+
41
+
42
+
43
+ with open(f'data/jobs/individual/{st.session_state.selected_job}/status.yaml', 'w') as file:
44
+ yaml.dump(jobs_info, file, default_flow_style=False)
45
+
46
+
47
+ with open(f'data/users/individuals/{st.session_state.user}/status.yaml', 'r') as file:
48
+ user_jobs_info = yaml.safe_load(file)
49
+ if "jobs" in list(user_jobs_info.keys()):
50
+
51
+ user_jobs_info['jobs'][st.session_state.selected_job] = {"paid":"pending","status":"pending","applied_date":applied_time}
52
+ else:
53
+ user_jobs_info['jobs'] = {st.session_state.selected_job:{"paid":"pending","status":"pending","applied_date":applied_time}}
54
+
55
+
56
+ with open(f'data/users/individuals/{st.session_state.user}/status.yaml', 'w') as file:
57
+ yaml.dump(user_jobs_info, file, default_flow_style=False)
58
+
59
+ st.success("Your application is applied succesfully !!")
60
+ time.sleep(0.5)
61
+ st.info("Redirecting to Jobs Finder!! ")
62
+ time.sleep(1.5)
63
+ st.switch_page("pages/page1.py")
pages/page1.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from navigation import make_sidebar
2
+ import streamlit as st
3
+ from time import sleep
4
+ import yaml
5
+
6
+ make_sidebar()
7
+
8
+ # Sample job data
9
+
10
+ with open(f'data/jobs/jobs.yaml', 'r') as file:
11
+ jobs = yaml.safe_load(file)
12
+ # job = {
13
+ # "ssc1": {"description": "This is a new job...", "qualification": "class 10"},
14
+ # "ssc2": {"description": "Another exciting job...", "qualification": "class 12"},
15
+ # "engineer": {"description": "Engineering job...", "qualification": "B.E/B.Tech"},
16
+ # }
17
+
18
+ st.title("Job Listings")
19
+
20
+ hide_st_style = """
21
+ <style>
22
+ #MainMenu {visibility: hidden;}
23
+ footer {visibility: hidden;}
24
+ header {visibility: hidden;}
25
+ </style>
26
+ """
27
+ st.markdown(hide_st_style, unsafe_allow_html=True)
28
+ # Initialize session state to keep track of which job's details to show
29
+ if 'selected_job' not in st.session_state:
30
+ st.session_state.selected_job = None
31
+
32
+ # Loop through all jobs and display them as buttons with title and description
33
+ for title, details in jobs.items():
34
+ # Format title and description in one string
35
+ button_label = "more details"
36
+ st.markdown(f"""
37
+ <div style="border: 2px solid #4CAF50; padding: 15px; border-radius: 6px;">
38
+ <p style="font-size:18px; color:black; text-align:center;">
39
+ <h2> {title} </h2>
40
+ Description: {details["description"]}
41
+ </p>
42
+ </div>
43
+ """, unsafe_allow_html=True)
44
+
45
+
46
+ if st.button(button_label,key=f"know{title}"):
47
+ # Set the selected job when the button is clicked
48
+ st.session_state.selected_job = title
49
+ sleep(0.5)
50
+ st.switch_page("pages/job_details.py")
51
+
52
+ # # Show job details if a button was clicked
53
+ # if st.session_state.selected_job:
54
+ # selected_title = st.session_state.selected_job
55
+ # st.subheader(f"Details for {selected_title}")
56
+ # st.write(f"**Description**: {job[selected_title]['description']}")
57
+ # st.write(f"**Qualification**: {job[selected_title]['qualification']}")
pages/page2.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from navigation import make_sidebar
2
+ import streamlit as st
3
+ import yaml
4
+ import os
5
+ make_sidebar()
6
+
7
+ st.title( f'Hello {st.session_state.user}')
8
+
9
+ hide_st_style = """
10
+ <style>
11
+ #MainMenu {visibility: hidden;}
12
+ footer {visibility: hidden;}
13
+ header {visibility: hidden;}
14
+ </style>
15
+ """
16
+
17
+ st.markdown(hide_st_style, unsafe_allow_html=True)
18
+ folder_name = f"data/users/individuals/{st.session_state.user}"
19
+
20
+ profile_pic = f'{folder_name}/profile.jpg'
21
+ if os.path.exists(profile_pic):
22
+
23
+ st.image(f'{folder_name}/profile.jpg', caption="Profile Picture", width=150)
24
+ else:
25
+ st.warning("Upload your profile picture")
26
+
27
+
28
+ with open(f'data/users/individuals/{st.session_state.user}/status.yaml', 'r') as file:
29
+ status = yaml.safe_load(file)
30
+
31
+ personal = status[st.session_state.user]
32
+
33
+ full_name = st.text_input("Enter your Full name",value=personal["full_name"])
34
+ phone_no = st.number_input("Enter your phone number",value=personal["phone_no"])
35
+ what_app_no = st.number_input("Enter your whatsapp number",value=personal["what_app_no"])
36
+
37
+ if st.button("Update Info"):
38
+ personal["full_name"] = full_name
39
+ personal["phone_no"] = phone_no
40
+ personal["what_app_no"] = what_app_no
41
+ status[st.session_state.user] = personal
42
+ with open(f'data/users/individuals/{st.session_state.user}/status.yaml', 'w') as file:
43
+ yaml.dump(status, file, default_flow_style=False)
44
+ st.success("Data are updated successfully!! ")
45
+
46
+
47
+ if st.button("show Details", type="primary"):
48
+ with open(f'data/users/individuals/{st.session_state.user}/status.yaml', 'r') as file:
49
+ status = yaml.safe_load(file)
50
+ st.subheader("Applied Jobs")
51
+ if "jobs" in list(status.keys()):
52
+ for i,job_name in enumerate(list(status['jobs'].keys())):
53
+ job = status['jobs'][job_name]
54
+ time_ = job["applied_date"].date()
55
+ stt = job["status"]
56
+ # link = job["application"]
57
+ st.write(f'{i+1}. {job_name} which is applied on {time_} is: ')
58
+ st.info(stt)
59
+ # st.write(f'You can check here: {link}')
60
+ else:
61
+ st.warning("Apply a job !!")
62
+ st.subheader("Uploaded Documents:")
63
+ if "documents" in list(status.keys()):
64
+ for i,doc_name in enumerate(list(status["documents"])):
65
+ doc = status['documents'][doc_name]
66
+ if doc['status']=='done':
67
+ st.write(f'{i+1}. {doc_name} was succesfully uploaded')
68
+ else:
69
+ st.warning("Upload your documents below")
70
+
71
+ st.header("Update your documents")
72
+
73
+ uploaded_profile = st.file_uploader("Upload your profile", type=["jpg", "jpeg", "png"])
74
+
75
+ uploaded_aadhar_f = st.file_uploader("Upload your aadhar front", type=["jpg", "jpeg", "png"])
76
+ uploaded_aadhar_b = st.file_uploader("Upload your aadhar back", type=["jpg", "jpeg", "png"])
77
+ uploaded_10 = st.file_uploader("Upload your 10 mark sheet", type=["jpg", "jpeg", "png"])
78
+ uploaded_12 = st.file_uploader("Upload your 12 mark sheet", type=["jpg", "jpeg", "png"])
79
+
80
+ ##################################################
81
+
82
+ ### List of documents
83
+
84
+ doc_list_names = {"profile.jpg":uploaded_profile,
85
+ "aadhar_f.jpg":uploaded_aadhar_f,
86
+ "aadhar_b.jpg":uploaded_aadhar_b,
87
+ "class_10.jpg":uploaded_10,
88
+ "class_12.jpg":uploaded_12}
89
+
90
+ if st.button("Update"):
91
+ with open(f'data/users/individuals/{st.session_state.user}/status.yaml', 'r') as file:
92
+ status = yaml.safe_load(file)
93
+ for docu in list(doc_list_names.keys()):
94
+ if doc_list_names[docu] is not None:
95
+ file_path = f'{folder_name}/{docu}'
96
+ if os.path.exists(file_path):
97
+ os.remove(file_path)
98
+ with open(file_path, "wb") as f:
99
+ f.write(doc_list_names[docu].getbuffer())
100
+
101
+ file_name = docu.split('.')[0]
102
+
103
+ if "document" in list(status.keys()):
104
+
105
+ status["documents"][file_name] = {"status":"done","link":docu}
106
+ else:
107
+ status["documents"] = {file_name:{"status":"done","link":docu}}
108
+
109
+
110
+
111
+ with open(f'data/users/individuals/{st.session_state.user}/status.yaml', 'w') as file:
112
+ yaml.dump(status, file, default_flow_style=False)
113
+ st.success("Files are uploaded successfully!! ")
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ streamlit>=1.31.0