Update app.py
Browse files
app.py
CHANGED
|
@@ -105,6 +105,7 @@ with app.app_context():
|
|
| 105 |
def index():
|
| 106 |
return redirect(url_for("jobs"))
|
| 107 |
|
|
|
|
| 108 |
@app.route("/jobs", methods=["GET", "POST"])
|
| 109 |
def jobs():
|
| 110 |
if request.method == "POST":
|
|
@@ -126,12 +127,14 @@ def jobs():
|
|
| 126 |
except SQLAlchemyError:
|
| 127 |
app.logger.exception("Error adding job")
|
| 128 |
flash("Error adding job. See logs for details.")
|
|
|
|
| 129 |
# GET handling
|
| 130 |
search = request.args.get("search", "").strip()
|
| 131 |
status_filter = request.args.get("status_filter", "").strip()
|
| 132 |
sort_by = request.args.get("sort", "")
|
| 133 |
direction = request.args.get("direction", "asc")
|
| 134 |
|
|
|
|
| 135 |
query = Job.query
|
| 136 |
if search:
|
| 137 |
query = query.filter(
|
|
@@ -148,21 +151,25 @@ def jobs():
|
|
| 148 |
query = query.order_by(col.desc() if direction=="desc" else col.asc())
|
| 149 |
|
| 150 |
jobs_list = query.all()
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
|
|
|
| 156 |
return render_template(
|
| 157 |
"jobs.html",
|
| 158 |
jobs=jobs_list,
|
| 159 |
-
|
| 160 |
status_filter=status_filter,
|
| 161 |
sort_by=sort_by,
|
| 162 |
direction=direction,
|
| 163 |
-
|
|
|
|
|
|
|
| 164 |
)
|
| 165 |
|
|
|
|
| 166 |
@app.route("/edit_job/<int:job_id>", methods=["GET", "POST"])
|
| 167 |
def edit_job(job_id):
|
| 168 |
job = Job.query.get_or_404(job_id)
|
|
|
|
| 105 |
def index():
|
| 106 |
return redirect(url_for("jobs"))
|
| 107 |
|
| 108 |
+
@app.route("/jobs", methods=["GET", "POST"])
|
| 109 |
@app.route("/jobs", methods=["GET", "POST"])
|
| 110 |
def jobs():
|
| 111 |
if request.method == "POST":
|
|
|
|
| 127 |
except SQLAlchemyError:
|
| 128 |
app.logger.exception("Error adding job")
|
| 129 |
flash("Error adding job. See logs for details.")
|
| 130 |
+
|
| 131 |
# GET handling
|
| 132 |
search = request.args.get("search", "").strip()
|
| 133 |
status_filter = request.args.get("status_filter", "").strip()
|
| 134 |
sort_by = request.args.get("sort", "")
|
| 135 |
direction = request.args.get("direction", "asc")
|
| 136 |
|
| 137 |
+
# build the filtered/sorted query
|
| 138 |
query = Job.query
|
| 139 |
if search:
|
| 140 |
query = query.filter(
|
|
|
|
| 151 |
query = query.order_by(col.desc() if direction=="desc" else col.asc())
|
| 152 |
|
| 153 |
jobs_list = query.all()
|
| 154 |
+
|
| 155 |
+
# compute clear, snake_case counts
|
| 156 |
+
applied_count = Job.query.filter_by(status="Applied").count()
|
| 157 |
+
interviewing_count = Job.query.filter_by(status="Interviewing").count()
|
| 158 |
+
rejected_count = Job.query.filter_by(status="Rejected").count()
|
| 159 |
+
|
| 160 |
return render_template(
|
| 161 |
"jobs.html",
|
| 162 |
jobs=jobs_list,
|
| 163 |
+
search_query=search, # matches {{ search_query }} in template
|
| 164 |
status_filter=status_filter,
|
| 165 |
sort_by=sort_by,
|
| 166 |
direction=direction,
|
| 167 |
+
applied_count=applied_count, # matches {{ applied_count }}
|
| 168 |
+
interviewing_count=interviewing_count,
|
| 169 |
+
rejected_count=rejected_count,
|
| 170 |
)
|
| 171 |
|
| 172 |
+
|
| 173 |
@app.route("/edit_job/<int:job_id>", methods=["GET", "POST"])
|
| 174 |
def edit_job(job_id):
|
| 175 |
job = Job.query.get_or_404(job_id)
|