Skip to content

Commit

Permalink
All material review pages now generate from the same material_page.ht…
Browse files Browse the repository at this point in the history
…ml template instead of their own individual html files.
  • Loading branch information
Gilleece committed Apr 5, 2021
1 parent 111cbfb commit 42338f1
Show file tree
Hide file tree
Showing 17 changed files with 40 additions and 1,452 deletions.
7 changes: 5 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,12 @@ def search():

@app.route("/material/<material_name>", methods=["GET"])
def material(material_name):
# material_obj = mongo.db.material.find({''})
material_obj = mongo.db.materials.find({'path': material_name})
reviews = mongo.db.reviews.find({'material_name': material_name})
return render_template(f"materials/{material_name}.html", reviews=reviews)
return render_template(
"material_page.html",
reviews=reviews,
material_obj=material_obj)


"""
Expand Down
48 changes: 24 additions & 24 deletions forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ class ReviewForm(FlaskForm):
'Filament type',
[DataRequired()],
choices=[
('ABS', 'ABS'),
('ASA', 'ASA'),
('Carbon', 'Carbon Fiber'),
('HIPS', 'HIPS'),
('Metal', 'Metal'),
('Nylon', 'Nylon'),
('PETG', 'PETG'),
('PLA', 'PLA'),
('Polycarbonate', 'Polycarbonate'),
('PVA', 'PVA'),
('TPU', 'TPU'),
('Wood', 'Wood')
('abs', 'ABS'),
('asa', 'ASA'),
('carbon', 'Carbon Fiber'),
('hips', 'HIPS'),
('metal', 'Metal'),
('nylon', 'Nylon'),
('petg', 'PETG'),
('pla', 'PLA'),
('polycarbonate', 'Polycarbonate'),
('pva', 'PVA'),
('tpu', 'TPU'),
('wood', 'Wood')
]
)
brand = StringField(
Expand Down Expand Up @@ -175,18 +175,18 @@ class EditForm(FlaskForm):
'Filament type',
[DataRequired()],
choices=[
('ABS', 'ABS'),
('ASA', 'ASA'),
('Carbon', 'Carbon Fiber'),
('HIPS', 'HIPS'),
('Metal', 'Metal'),
('Nylon', 'Nylon'),
('PETG', 'PETG'),
('PLA', 'PLA'),
('Polycarbonate', 'Polycarbonate'),
('PVA', 'PVA'),
('TPU', 'TPU'),
('Wood', 'Wood')
('abs', 'ABS'),
('asa', 'ASA'),
('carbon', 'Carbon Fiber'),
('hips', 'HIPS'),
('metal', 'Metal'),
('nylon', 'Nylon'),
('petg', 'PETG'),
('pla', 'PLA'),
('polycarbonate', 'Polycarbonate'),
('pva', 'PVA'),
('tpu', 'TPU'),
('wood', 'Wood')
]
)
brand = StringField(
Expand Down
11 changes: 9 additions & 2 deletions templates/material_page.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{% extends "base.html" %}
{% block content %}

{% for material in material_obj %}
<div class="row justify-content-center">
<div class="col-12">
<div class="card p-3 mb-5 bg-body">
Expand All @@ -21,9 +25,12 @@ <h3>
</div>
</div>
</div>
{% endfor %}

<div class="row row-cols-1 row-cols-md-2 g-4">
{% for review in reviews %}
{% include 'reviews.html' %}
{% include 'reviews.html' %}
{% endfor %}
</div>
</div>

{% endblock %}
2 changes: 1 addition & 1 deletion templates/materials.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h3>
<div class="card m-3 text-center shadow rounded" style="width: 18rem;">
<img src="{{ material.image }}" class="card-img-top material-card" alt="{{ material.material_name }} image">
<div class="card-body">
<a href="{{ material.path }}" class="btn btn-primary stretched-link">{{ material.material_name }}</a>
<a href="{{ url_for('material', material_name=material.path) }}" class="btn btn-primary stretched-link">{{ material.material_name }}</a>
</div>
</div>
{% endfor %}
Expand Down
5 changes: 0 additions & 5 deletions templates/materials/abs.html

This file was deleted.

130 changes: 0 additions & 130 deletions templates/materials/asa.html

This file was deleted.

Loading

0 comments on commit 42338f1

Please sign in to comment.