Skip to content

Commit

Permalink
update feature complete
Browse files Browse the repository at this point in the history
  • Loading branch information
gsheth21 committed Nov 1, 2024
1 parent a884869 commit c0263cf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
24 changes: 17 additions & 7 deletions app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,15 @@ def add():
reviews.append(job['_id'])
USERS_DB.update_one({"username": session['username']}, {
"$set": {"reviews": reviews}})
else:
JOBS_DB.update_one(
{'_id': job['_id']},
{"$set": job} # Update the job details with the new values
)

if job['_id'] not in reviews:
reviews.append(job['_id'])
USERS_DB.update_one({"username": session['username']}, {"$set": {"reviews": reviews}})

return redirect('/')

Expand Down Expand Up @@ -401,7 +410,7 @@ def view(view_id):
"""An API to help view review information"""
intialize_db()
job_review = JOBS_DB.find_one({"_id": view_id})
job_review['view_id'] = job_review.pop('_id')
job_review['id'] = job_review.pop('_id')
return render_template("view.html", entry=job_review)


Expand Down Expand Up @@ -444,7 +453,7 @@ def delete(delete_id):
return redirect("/myjobs")

@app.route('/api/getUser')
def getUser():
def get_user():
try:
if 'username' in session.keys() and session['username']:
return jsonify(session['username'])
Expand All @@ -454,12 +463,13 @@ def getUser():
print("Error: ", e)

@app.route('/api/updateReview')
def updateReview():
def update_review():
try:
id = request.args.get('id')
intializeDB()
jobReview = jobsDB.find_one({"_id": id})
jobReview['id'] = jobReview.pop('_id')
return render_template("review-page.html", entry=jobReview)
print(id)
intialize_db()
job_review = JOBS_DB.find_one({"_id": id})
job_review['id'] = job_review.pop('_id')
return render_template("review-page.html", entry=job_review)
except Exception as e:
print("Error: ", e)
30 changes: 15 additions & 15 deletions app/templates/review-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ <h1>Please add your Review
<label>Your overall experience with your job ?</label><br>

<span class="star-rating">
<input type="radio" name="rating" id="rating" value="1" {% if entry.rating == 1 %} checked {% endif %}><i></i>
<input type="radio" name="rating" id="rating" value="2" {% if entry.rating == 2 %} checked {% endif %}><i></i>
<input type="radio" name="rating" id="rating" value="3" {% if entry.rating == 3 %} checked {% endif %}><i></i>
<input type="radio" name="rating" id="rating" value="4" {% if entry.rating == 4 %} checked {% endif %}><i></i>
<input type="radio" name="rating" id="rating" value="5" {% if entry.rating == 5 %} checked {% endif %}><i></i>
<input type="radio" name="rating" id="rating" value="1" {% if entry and entry.rating == '1' %}checked{% endif %}><i></i>
<input type="radio" name="rating" id="rating" value="2" {% if entry and entry.rating == '2' %}checked{% endif %}><i></i>
<input type="radio" name="rating" id="rating" value="3" {% if entry and entry.rating == '3' %}checked{% endif %}><i></i>
<input type="radio" name="rating" id="rating" value="4" {% if entry and entry.rating == '4' %}checked{% endif %}><i></i>
<input type="radio" name="rating" id="rating" value="5" {% if entry and entry.rating == '5' %}checked{% endif %}><i></i>
</span>
<div class="clear"></div>

Expand All @@ -99,43 +99,43 @@ <h1>Please add your Review
</div>
<span class="scale-rating">
<label value="1">
<input type="radio" name="recommendation" id="recommendation" value="1" {% if entry.recommendation == 1 %} checked {% endif %}>
<input type="radio" name="recommendation" id="recommendation" value="1" {% if entry and entry.rating == '1' %}checked{% endif %}>
<label style="width:100%;"></label>
</label>
<label value="2">
<input type="radio" name="recommendation" id="recommendation" value="2" {% if entry.recommendation == 2 %} checked {% endif %}>
<input type="radio" name="recommendation" id="recommendation" value="2" {% if entry and entry.rating == '2' %}checked{% endif %}>
<label style="width:100%;"></label>
</label>
<label value="3">
<input type="radio" name="recommendation" id="recommendation" value="3" {% if entry.recommendation == 3 %} checked {% endif %}>
<input type="radio" name="recommendation" id="recommendation" value="3" {% if entry and entry.rating == '3' %}checked{% endif %}>
<label style="width:100%;"></label>
</label>
<label value="4">
<input type="radio" name="recommendation" id="recommendation" value="4" {% if entry.recommendation == 4 %} checked {% endif %}>
<input type="radio" name="recommendation" id="recommendation" value="4" {% if entry and entry.rating == '4' %}checked{% endif %}>
<label style="width:100%;"></label>
</label>
<label value="5">
<input type="radio" name="recommendation" id="recommendation" value="5" {% if entry.recommendation == 5 %} checked {% endif %}>
<input type="radio" name="recommendation" id="recommendation" value="5" {% if entry and entry.rating == '5' %}checked{% endif %}>
<label style="width:100%;"></label>
</label>
<label value="6">
<input type="radio" name="recommendation" id="recommendation" value="6" {% if entry.recommendation == 6 %} checked {% endif %}>
<input type="radio" name="recommendation" id="recommendation" value="6" {% if entry and entry.rating == '6' %}checked{% endif %}>
<label style="width:100%;"></label>
</label>
<label value="7">
<input type="radio" name="recommendation" id="recommendation" value="7" {% if entry.recommendation == 7 %} checked {% endif %}>
<input type="radio" name="recommendation" id="recommendation" value="7" {% if entry and entry.rating == '7' %}checked{% endif %}>
<label style="width:100%;"></label>
</label>
<label value="8">
<input type="radio" name="recommendation" id="recommendation" value="8" {% if entry.recommendation == 8 %} checked {% endif %}>
<input type="radio" name="recommendation" id="recommendation" value="8" {% if entry and entry.rating == '8' %}checked{% endif %}>
<label style="width:100%;"></label>
</label>
<label value="9">
<input type="radio" name="recommendation" id="recommendation" value="9" {% if entry.recommendation == 9 %} checked {% endif %}>
<input type="radio" name="recommendation" id="recommendation" value="9" {% if entry and entry.rating == '9' %}checked{% endif %}>
<label style="width:100%;"></label>
</label>
<label value="10">
<input type="radio" name="recommendation" id="recommendation" value="10" {% if entry.recommendation == 10 %} checked {% endif %}>
<input type="radio" name="recommendation" id="recommendation" value="10" {% if entry and entry.rating == '10' %}checked{% endif %}>
<label style="width:100%;"></label>
</label>
</span>
Expand Down

0 comments on commit c0263cf

Please sign in to comment.