Compare commits
13 Commits
98abe5a0de
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41b4e0fe24 | ||
|
|
b8f57ef92f | ||
|
|
20fde958ec | ||
|
|
9ee0c91106 | ||
|
|
fd205b9b61 | ||
|
|
2788e24ec8 | ||
|
|
863429d51b | ||
|
|
93e1e6d41e | ||
|
|
7065acb94d | ||
|
|
9fb26129b6 | ||
|
|
6a378a2425 | ||
|
|
6459e2406e | ||
|
|
ce1847e06c |
@@ -7,7 +7,8 @@ on:
|
|||||||
env:
|
env:
|
||||||
REGISTRY: registry.rose-ash.com:5000
|
REGISTRY: registry.rose-ash.com:5000
|
||||||
IMAGE: market
|
IMAGE: market
|
||||||
REPO_DIR: /root/market
|
REPO_DIR: /root/rose-ash/market
|
||||||
|
COOP_DIR: /root/coop
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
@@ -58,7 +59,7 @@ jobs:
|
|||||||
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
|
||||||
run: |
|
run: |
|
||||||
ssh "root@$DEPLOY_HOST" "
|
ssh "root@$DEPLOY_HOST" "
|
||||||
cd /root/coop
|
cd ${{ env.COOP_DIR }}
|
||||||
source .env
|
source .env
|
||||||
docker stack deploy -c docker-compose.yml coop
|
docker stack deploy -c docker-compose.yml coop
|
||||||
echo 'Waiting for services to update...'
|
echo 'Waiting for services to update...'
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ RUN pip install -r requirements.txt
|
|||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Link app blueprints into the shared library's namespace
|
# Link app blueprints into the shared library's namespace
|
||||||
RUN ln -s /app/bp /app/shared_lib/suma_browser/app/bp
|
RUN rm -rf /app/shared_lib/suma_browser/app/bp && ln -s /app/bp /app/shared_lib/suma_browser/app/bp
|
||||||
|
|
||||||
# ---------- Runtime setup ----------
|
# ---------- Runtime setup ----------
|
||||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
|
|||||||
10
app.py
10
app.py
@@ -8,6 +8,7 @@ from jinja2 import FileSystemLoader, ChoiceLoader
|
|||||||
from sqlalchemy import select
|
from sqlalchemy import select
|
||||||
|
|
||||||
from shared.factory import create_base_app
|
from shared.factory import create_base_app
|
||||||
|
from shared.cart_loader import load_cart
|
||||||
from config import config
|
from config import config
|
||||||
|
|
||||||
from suma_browser.app.bp import register_market_bp
|
from suma_browser.app.bp import register_market_bp
|
||||||
@@ -45,7 +46,7 @@ def create_app() -> "Quart":
|
|||||||
from models.market_place import MarketPlace
|
from models.market_place import MarketPlace
|
||||||
from models.ghost_content import Post
|
from models.ghost_content import Post
|
||||||
|
|
||||||
app = create_base_app("market", context_fn=market_context)
|
app = create_base_app("market", context_fn=market_context, before_request_fns=[load_cart])
|
||||||
|
|
||||||
# App-specific templates override shared templates
|
# App-specific templates override shared templates
|
||||||
app_templates = str(Path(__file__).resolve().parent / "templates")
|
app_templates = str(Path(__file__).resolve().parent / "templates")
|
||||||
@@ -124,6 +125,13 @@ def create_app() -> "Quart":
|
|||||||
abort(404)
|
abort(404)
|
||||||
g.market = market
|
g.market = market
|
||||||
|
|
||||||
|
@app.context_processor
|
||||||
|
async def inject_post():
|
||||||
|
post_data = getattr(g, "post_data", None)
|
||||||
|
if not post_data:
|
||||||
|
return {}
|
||||||
|
return {**post_data}
|
||||||
|
|
||||||
# --- Root route: market listing ---
|
# --- Root route: market listing ---
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
async def markets_listing():
|
async def markets_listing():
|
||||||
|
|||||||
@@ -24,8 +24,10 @@ def register(url_prefix, title):
|
|||||||
async def inject_root():
|
async def inject_root():
|
||||||
market = getattr(g, "market", None)
|
market = getattr(g, "market", None)
|
||||||
market_id = market.id if market else None
|
market_id = market.id if market else None
|
||||||
|
post_data = getattr(g, "post_data", None) or {}
|
||||||
return {
|
return {
|
||||||
"coop_title": title,
|
**post_data,
|
||||||
|
"coop_title": market.name if market else title,
|
||||||
"categories": (await get_nav(g.s, market_id=market_id))["cats"],
|
"categories": (await get_nav(g.s, market_id=market_id))["cats"],
|
||||||
"qs": makeqs_factory()(),
|
"qs": makeqs_factory()(),
|
||||||
"market": market,
|
"market": market,
|
||||||
|
|||||||
@@ -221,6 +221,7 @@ def register():
|
|||||||
product_id=product.id,
|
product_id=product.id,
|
||||||
product=product,
|
product=product,
|
||||||
quantity=count,
|
quantity=count,
|
||||||
|
market_place_id=getattr(g, "market", None) and g.market.id,
|
||||||
)
|
)
|
||||||
g.cart.append(ci)
|
g.cart.append(ci)
|
||||||
g.s.add(ci)
|
g.s.add(ci)
|
||||||
@@ -241,7 +242,8 @@ def register():
|
|||||||
)
|
)
|
||||||
|
|
||||||
# normal POST: go to cart page
|
# normal POST: go to cart page
|
||||||
return redirect(url_for("cart.view_cart"))
|
from shared.urls import cart_url
|
||||||
|
return redirect(cart_url("/"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Submodule shared_lib updated: a420bfa7f0...356d916e26
@@ -11,9 +11,9 @@
|
|||||||
{% block oobs %}
|
{% block oobs %}
|
||||||
|
|
||||||
{% from '_types/root/_n/macros.html' import oob_header with context %}
|
{% from '_types/root/_n/macros.html' import oob_header with context %}
|
||||||
{{oob_header('root-header-child', 'market-header-child', '_types/market/header/_header.html')}}
|
{{oob_header('post-header-child', 'market-header-child', '_types/market/header/_header.html')}}
|
||||||
|
|
||||||
{% from '_types/root/header/_header.html' import header_row with context %}
|
{% from '_types/post/header/_header.html' import header_row with context %}
|
||||||
{{ header_row(oob=True) }}
|
{{ header_row(oob=True) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
{% block oobs %}
|
{% block oobs %}
|
||||||
|
|
||||||
{% from '_types/root/_n/macros.html' import oob_header with context %}
|
{% from '_types/root/_n/macros.html' import oob_header with context %}
|
||||||
{{oob_header('root-header-child', 'market-header-child', '_types/market/header/_header.html')}}
|
{{oob_header('post-header-child', 'market-header-child', '_types/market/header/_header.html')}}
|
||||||
|
|
||||||
{% from '_types/root/header/_header.html' import header_row with context %}
|
{% from '_types/post/header/_header.html' import header_row with context %}
|
||||||
{{ header_row(oob=True) }}
|
{{ header_row(oob=True) }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,11 @@
|
|||||||
|
|
||||||
{% block root_header_child %}
|
{% block root_header_child %}
|
||||||
{% from '_types/root/_n/macros.html' import index_row with context %}
|
{% from '_types/root/_n/macros.html' import index_row with context %}
|
||||||
{% call index_row('market-header-child', '_types/market/header/_header.html') %}
|
{% call index_row('post-header-child', '_types/post/header/_header.html') %}
|
||||||
{% block market_header_child %}
|
{% call index_row('market-header-child', '_types/market/header/_header.html') %}
|
||||||
{% endblock %}
|
{% block market_header_child %}
|
||||||
|
{% endblock %}
|
||||||
|
{% endcall %}
|
||||||
{% endcall %}
|
{% endcall %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
|
|
||||||
{% if not quantity %}
|
{% if not quantity %}
|
||||||
<form
|
<form
|
||||||
action="{{ market_url('/product/' + slug + '/cart') }}"
|
action="{{ url_for('market.browse.product.cart', slug=slug) }}"
|
||||||
method="post"
|
method="post"
|
||||||
hx-post="{{ market_url('/product/' + slug + '/cart') }}"
|
hx-post="{{ url_for('market.browse.product.cart', slug=slug) }}"
|
||||||
hx-target="#cart-mini"
|
hx-target="#cart-mini"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
class="rounded flex items-center"
|
class="rounded flex items-center"
|
||||||
@@ -38,9 +38,9 @@
|
|||||||
<div class="rounded flex items-center gap-2">
|
<div class="rounded flex items-center gap-2">
|
||||||
<!-- minus -->
|
<!-- minus -->
|
||||||
<form
|
<form
|
||||||
action="{{ market_url('/product/' + slug + '/cart') }}"
|
action="{{ url_for('market.browse.product.cart', slug=slug) }}"
|
||||||
method="post"
|
method="post"
|
||||||
hx-post="{{ market_url('/product/' + slug + '/cart') }}"
|
hx-post="{{ url_for('market.browse.product.cart', slug=slug) }}"
|
||||||
hx-target="#cart-mini"
|
hx-target="#cart-mini"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
>
|
>
|
||||||
@@ -80,9 +80,9 @@
|
|||||||
|
|
||||||
<!-- plus -->
|
<!-- plus -->
|
||||||
<form
|
<form
|
||||||
action="{{ market_url('/product/' + slug + '/cart') }}"
|
action="{{ url_for('market.browse.product.cart', slug=slug) }}"
|
||||||
method="post"
|
method="post"
|
||||||
hx-post="{{ market_url('/product/' + slug + '/cart') }}"
|
hx-post="{{ url_for('market.browse.product.cart', slug=slug) }}"
|
||||||
hx-target="#cart-mini"
|
hx-target="#cart-mini"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
>
|
>
|
||||||
@@ -139,7 +139,7 @@
|
|||||||
<div class="flex flex-col sm:flex-row sm:items-start justify-between gap-2 sm:gap-3">
|
<div class="flex flex-col sm:flex-row sm:items-start justify-between gap-2 sm:gap-3">
|
||||||
<div class="min-w-0">
|
<div class="min-w-0">
|
||||||
<h2 class="text-sm sm:text-base md:text-lg font-semibold text-stone-900">
|
<h2 class="text-sm sm:text-base md:text-lg font-semibold text-stone-900">
|
||||||
{% set href=market_url('/product/' + p.slug + '/') %}
|
{% set href=url_for('market.browse.product.product_detail', slug=p.slug) %}
|
||||||
<a
|
<a
|
||||||
href="{{ href }}"
|
href="{{ href }}"
|
||||||
hx_get="{{href}}"
|
hx_get="{{href}}"
|
||||||
@@ -189,9 +189,9 @@
|
|||||||
<div class="flex items-center gap-2 text-xs sm:text-sm text-stone-700">
|
<div class="flex items-center gap-2 text-xs sm:text-sm text-stone-700">
|
||||||
<span class="text-[0.65rem] sm:text-xs uppercase tracking-wide text-stone-500">Quantity</span>
|
<span class="text-[0.65rem] sm:text-xs uppercase tracking-wide text-stone-500">Quantity</span>
|
||||||
<form
|
<form
|
||||||
action="{{ market_url('/product/' + p.slug + '/cart') }}"
|
action="{{ url_for('market.browse.product.cart', slug=p.slug) }}"
|
||||||
method="post"
|
method="post"
|
||||||
hx-post="{{ market_url('/product/' + p.slug + '/cart') }}"
|
hx-post="{{ url_for('market.browse.product.cart', slug=p.slug) }}"
|
||||||
hx-target="#cart-mini"
|
hx-target="#cart-mini"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
>
|
>
|
||||||
@@ -212,9 +212,9 @@
|
|||||||
{{ item.quantity }}
|
{{ item.quantity }}
|
||||||
</span>
|
</span>
|
||||||
<form
|
<form
|
||||||
action="{{ market_url('/product/' + p.slug + '/cart') }}"
|
action="{{ url_for('market.browse.product.cart', slug=p.slug) }}"
|
||||||
method="post"
|
method="post"
|
||||||
hx-post="{{ market_url('/product/' + p.slug + '/cart') }}"
|
hx-post="{{ url_for('market.browse.product.cart', slug=p.slug) }}"
|
||||||
hx-target="#cart-mini"
|
hx-target="#cart-mini"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user