Skip to content

Commit

Permalink
Update to use just the query object
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelCenzano committed Dec 1, 2023
1 parent ee40041 commit b95c50c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 66 deletions.
83 changes: 26 additions & 57 deletions labconnect/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,75 +258,44 @@ def positions():
@main_blueprint.route("/opportunity/<int:id>")
def opportunity(id: int):
promoters_attr_names = ["rcs_id", "name"]
promoters = [
", ".join(str(row).split(",")) for row in get_opportunity_promoters(id).all()
] # List of strings

recommended_courses_attr_names = ["course_code", "course_name"]
recommended_courses = [
", ".join(str(row).split(","))
for row in get_opportunity_recommended_courses(id).all()
]

recommended_majors_attr_names = ["major_code", "major_name"]
recommended_majors = [
", ".join(str(row).split(","))
for row in get_opportunity_recommended_majors(id).all()
]

recommended_class_years_attr_names = ["class_year", "class_name"]
recommended_class_years = [
", ".join(str(row).split(","))
for row in get_opportunity_recommended_class_years(id).all()
]

salaries_attr_names = ["usd_per_hour"]
salaries = [
", ".join(str(row).split(",")) for row in get_opportunity_hourly_rates(id).all()
]

upfront_pay_attr_names = ["usd"]
upfront_pay = [
", ".join(str(row).split(",")) for row in get_opportunity_upfront_pay(id).all()
]

course_credits_attr_names = ["course_code", "number_of_credits"]
course_credits = [
", ".join(str(row).split(","))
for row in get_opportunity_course_credits(id).all()
]

application_due_dates_attr_names = ["date"]
application_due_dates = [
", ".join(str(row).split(","))
for row in get_opportunity_application_due_dates(id).all()
]

active_semesters_attr_names = ["year", "season"]
active_semesters = [
", ".join(str(row).split(","))
for row in get_opportunity_active_semesters(id).all()
]

promoters = get_opportunity_promoters(id).all()

# Columns "course_code", "course_name"
recommended_courses = get_opportunity_recommended_courses(id).all()

# Columns "major_code", "major_name"
recommended_majors = get_opportunity_recommended_majors(id).all()

# Columns "class_year", "class_name"
recommended_class_years = get_opportunity_recommended_class_years(id).all()

# Columns "usd_per_hour"
salaries = get_opportunity_hourly_rates(id).all()

# Columns "usd"
upfront_pay = get_opportunity_upfront_pay(id).all()

# Columns "course_code", "number_of_credits"
course_credits = get_opportunity_course_credits(id).all()

# Columns "date"
application_due_dates = get_opportunity_application_due_dates(id).all()

# Columns "year", "season"
active_semesters = get_opportunity_active_semesters(id).all()

return render_template(
"opportunity_details.html",
promoters_attr_names=promoters_attr_names,
promoters=promoters,
recommended_courses_attr_names=recommended_courses_attr_names,
recommended_courses=recommended_courses,
recommended_majors_attr_names=recommended_majors_attr_names,
recommended_majors=recommended_majors,
recommended_class_years_attr_names=recommended_class_years_attr_names,
recommended_class_years=recommended_class_years,
salaries_attr_names=salaries_attr_names,
salaries=salaries,
upfront_pay_attr_names=upfront_pay_attr_names,
upfront_pay=upfront_pay,
course_credits_attr_names=course_credits_attr_names,
course_credits=course_credits,
application_due_dates_attr_names=application_due_dates_attr_names,
application_due_dates=application_due_dates,
active_semesters_attr_names=active_semesters_attr_names,
active_semesters=active_semesters,
)

Expand Down
9 changes: 0 additions & 9 deletions labconnect/templates/opportunity_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,47 +93,38 @@
</head>

<body>
<p> {{ promoters_attr_names }} </p>
{% for row in promoters %}
<p> {{ row }} </p>
{% endfor %}

<p> {{ recommended_courses_attr_names }} </p>
{% for row in recommended_courses %}
<p> {{ row }} </p>
{% endfor %}

<p> {{ recommended_majors_attr_names }} </p>
{% for row in recommended_majors %}
<p> {{ row }} </p>
{% endfor %}

<p> {{ recommended_class_years_attr_names }} </p>
{% for row in recommended_class_years %}
<p> {{ row }} </p>
{% endfor %}

<p> {{ salaries_attr_names }} </p>
{% for row in salaries %}
<p> {{ row }} </p>
{% endfor %}

<p> {{ upfront_pay_attr_names }} </p>
{% for row in upfront_pay %}
<p> {{ row }} </p>
{% endfor %}

<p> {{ course_credits_attr_names }} </p>
{% for row in course_credits %}
<p> {{ row }} </p>
{% endfor %}

<p> {{ application_due_dates_attr_names }} </p>
{% for row in application_due_dates %}
<p> {{ row }} </p>
{% endfor %}

<p> {{ active_semesters_attr_names }} </p>
{% for row in active_semesters %}
<p> {{ row }} </p>
{% endfor %}
Expand Down

0 comments on commit b95c50c

Please sign in to comment.