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