Skip to content

Commit

Permalink
feat: Properly display room in shows section
Browse files Browse the repository at this point in the history
  • Loading branch information
noahpistilli committed Jun 30, 2024
1 parent 42466f8 commit fe63d44
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
4 changes: 3 additions & 1 deletion theunderground/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def add_category():
form.thumbnail.validators = [FileRequired()]

if form.validate_on_submit():
new_category = Categories(name=form.category_name.data, sp_page_id=form.room.data)
new_category = Categories(
name=form.category_name.data, sp_page_id=form.room.data
)

# Add to retrieve the category ID.
db.session.add(new_category)
Expand Down
21 changes: 12 additions & 9 deletions url1/category_n.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
from models import Categories
from room import app
from models import Categories, Rooms
from room import app, db
from helpers import xml_node_name, RepeatedElement


@app.route("/url1/list/category/<list_id>.xml")
@xml_node_name("CategoryList")
def list_category_n(list_id):
queried_categories = (
Categories.query.order_by(Categories.name.asc()).limit(64).all()
queried_data = (
db.session.query(Categories, Rooms)
.filter(Categories.sp_page_id == Rooms.room_id)
.order_by(Categories.category_id)
.all()
)
results = []

for i, category in enumerate(queried_categories):
for i, category in enumerate(queried_data):
# Items must be indexed by 1.
results.append(
RepeatedElement(
{
"place": i + 1,
"categid": category.category_id,
"name": category.name,
"sppageid": 0,
"splinktext": "Link text",
"categid": category[0].category_id,
"name": category[0].name,
"sppageid": category[1].room_id,
"splinktext": category[1].news,
}
)
)
Expand Down

0 comments on commit fe63d44

Please sign in to comment.