Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ RUN npm run webpack
FROM docker.io/python:3.12-slim-bookworm
MAINTAINER Computer Science House <webmaster@csh.rit.edu>

RUN mkdir /opt/conditional
WORKDIR /opt/conditional

COPY requirements.txt /opt/conditional

WORKDIR /opt/conditional

RUN apt-get -yq update && \
apt-get -yq install libsasl2-dev libldap2-dev libldap-common libssl-dev gcc g++ make && \
pip install -r requirements.txt && \
Expand All @@ -35,6 +33,7 @@ ENV PORT=${PORT}
EXPOSE ${PORT}

COPY conditional /opt/conditional/conditional
COPY migrations /opt/conditional/migrations
COPY *.py package.json /opt/conditional/
COPY --from=build-frontend /opt/conditional/conditional/static/ /opt/conditional/conditional/static/

Expand Down
2 changes: 1 addition & 1 deletion conditional/blueprints/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def display_dashboard(user_dict=None):
"time_spent": p.time_spent,
"skills": p.skills,
"desc": p.description,
"links": list(filter(None, p.links.split("\n"))),
"links": [] if p.links is None else list(filter(None, p.links.split("\n"))),
"status": p.status,
}
for p in get_project_list().filter(MajorProject.uid == uid)
Expand Down
10 changes: 8 additions & 2 deletions conditional/blueprints/major_project_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def display_major_project(user_dict=None):
"time_spent": p.time_spent,
"skills": p.skills,
"desc": p.description,
"links": list(filter(None, p.links.split("\n"))),
"links": [] if p.links is None else list(filter(None, p.links.split("\n"))),
"status": p.status,
"is_owner": bool(user_dict["username"] == p.uid),
"files": list_files_in_folder(bucket, f"{p.id}/")
Expand All @@ -65,6 +65,7 @@ def display_major_project(user_dict=None):
return render_template(
"major_project_submission.html",
major_projects=major_projects,
bucket_name=bucket,
major_projects_len=len(major_projects),
username=user_dict["username"])

Expand Down Expand Up @@ -156,12 +157,17 @@ def submit_major_project(user_dict=None):
for file in os.listdir(temp_dir):
filepath = f"{temp_dir}/{file}"

s3.upload_file(filepath, 'major-project-media', f"{project.id}/{file}")
s3.upload_file(filepath, app.config['S3_BUCKET_ID'], f"{project.id}/{file}", ExtraArgs={
'ExpectedBucketOwner': app.config['S3_BUCKET_ID']
})

os.remove(filepath)

# Delete the temp directory once all the files have been stored in S3
os.rmdir(temp_dir)
else:
log.error("Could not create temp directory for uploading files")
return jsonify({"success": False}), 500


# Send the slack ping only after we know that the data was properly saved to the DB
Expand Down
4 changes: 2 additions & 2 deletions conditional/templates/major_project_submission.html
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ <h5 class="img-header"><strong>Images</strong></h5>
{% for f in p['files'] %}
<img
class="proj-img"
src="https://assets.csh.rit.edu/major-project-media/{{ f }}"
src="https://assets.csh.rit.edu/{{ bucket_name }}/{{ f }}"
alt="User submitted image for the project"/>
{% endfor %}
{% endif %}
Expand All @@ -342,4 +342,4 @@ <h5 class="img-header"><strong>Images</strong></h5>
{% endif %}
</div>

{% endblock %}
{% endblock %}
Loading