feat(market): settings toggle
This commit is contained in:
parent
a5fe8aacaf
commit
47812ffd09
@ -57,9 +57,8 @@ def migrate_data_backward(apps, schema_editor):
|
|||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('opus_magnum', '0014_steamcollection_accepting_submissions'),
|
("opus_magnum", "0014_steamcollection_accepting_submissions"),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
from ninja import NinjaAPI
|
from ninja import NinjaAPI
|
||||||
|
from django.conf import settings
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.http import HttpRequest
|
from django.http import HttpRequest
|
||||||
from opus_magnum.api import router as submissions_router
|
from opus_magnum.api import router as submissions_router
|
||||||
@ -37,7 +38,9 @@ api.add_router("/opus-magnum/", submissions_router, tags=["opus-magnum"])
|
|||||||
api.add_router("/results/", results_router, tags=["results"])
|
api.add_router("/results/", results_router, tags=["results"])
|
||||||
api.add_router("/noita/", noita_router, tags=["noita"])
|
api.add_router("/noita/", noita_router, tags=["noita"])
|
||||||
api.add_router("/games/", games_router, tags=["games"])
|
api.add_router("/games/", games_router, tags=["games"])
|
||||||
api.add_router("/market/", market_router)
|
|
||||||
|
if settings.MARKET_ENABLED:
|
||||||
|
api.add_router("/market/", market_router)
|
||||||
|
|
||||||
|
|
||||||
# Health check endpoint
|
# Health check endpoint
|
||||||
|
|||||||
@ -169,6 +169,9 @@ ALLOWED_SUBMISSION_TYPES = [
|
|||||||
"video/webm",
|
"video/webm",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Market app settings
|
||||||
|
MARKET_ENABLED = os.environ.get("MARKET_ENABLED", "true").lower() == "true"
|
||||||
|
|
||||||
# Authentication backends
|
# Authentication backends
|
||||||
AUTHENTICATION_BACKENDS = [
|
AUTHENTICATION_BACKENDS = [
|
||||||
"django.contrib.auth.backends.ModelBackend",
|
"django.contrib.auth.backends.ModelBackend",
|
||||||
|
|||||||
@ -33,7 +33,15 @@ OPUS_MAGNUM_APP_ID = 558990
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def home(request: HttpRequest):
|
def home(request: HttpRequest):
|
||||||
return render(request, "home.html", {})
|
from django.conf import settings
|
||||||
|
|
||||||
|
return render(
|
||||||
|
request,
|
||||||
|
"home.html",
|
||||||
|
{
|
||||||
|
"market_enabled": settings.MARKET_ENABLED,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
|||||||
@ -3,9 +3,16 @@ import { ref, onMounted } from "vue";
|
|||||||
import { gamesApiListGames } from "./api";
|
import { gamesApiListGames } from "./api";
|
||||||
import type { GamesApiListGamesResponse } from "./api/types.gen";
|
import type { GamesApiListGamesResponse } from "./api/types.gen";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
marketEnabled?: string | boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<Props>(), {
|
||||||
|
marketEnabled: true,
|
||||||
|
});
|
||||||
|
|
||||||
const games = ref<GamesApiListGamesResponse | undefined>();
|
const games = ref<GamesApiListGamesResponse | undefined>();
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
|
|
||||||
const imageErrors = ref<Set<number>>(new Set());
|
const imageErrors = ref<Set<number>>(new Set());
|
||||||
|
|
||||||
const getHeaderImage = (appId: number) => {
|
const getHeaderImage = (appId: number) => {
|
||||||
@ -20,7 +27,15 @@ const navigate = (path: string) => {
|
|||||||
window.location.href = path;
|
window.location.href = path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isMarketEnabled = () => {
|
||||||
|
if (typeof props.marketEnabled === 'string') {
|
||||||
|
return props.marketEnabled === 'true';
|
||||||
|
}
|
||||||
|
return Boolean(props.marketEnabled);
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
// Fetch games list
|
||||||
const response = await gamesApiListGames();
|
const response = await gamesApiListGames();
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
games.value = response.data;
|
games.value = response.data;
|
||||||
@ -48,7 +63,7 @@ onMounted(async () => {
|
|||||||
<!-- Cards Grid -->
|
<!-- Cards Grid -->
|
||||||
<div v-else class="grid grid-cols-1 md:grid-cols-2 gap-8">
|
<div v-else class="grid grid-cols-1 md:grid-cols-2 gap-8">
|
||||||
<!-- Market Card -->
|
<!-- Market Card -->
|
||||||
<div @click="navigate('/market')"
|
<div v-if="isMarketEnabled()" @click="navigate('/market')"
|
||||||
class="card card-xl bg-base-200 shadow-xl hover:shadow-2xl transition-all cursor-pointer transform hover:-translate-y-2 hover:scale-[1.05] hover:bg-base-100 overflow-hidden">
|
class="card card-xl bg-base-200 shadow-xl hover:shadow-2xl transition-all cursor-pointer transform hover:-translate-y-2 hover:scale-[1.05] hover:bg-base-100 overflow-hidden">
|
||||||
<figure class="relative h-60 bg-gradient-to-br from-purple-600 to-blue-600 flex items-center justify-center">
|
<figure class="relative h-60 bg-gradient-to-br from-purple-600 to-blue-600 flex items-center justify-center">
|
||||||
<i class="mdi mdi-chart-box text-6xl text-white opacity-80"></i>
|
<i class="mdi mdi-chart-box text-6xl text-white opacity-80"></i>
|
||||||
|
|||||||
@ -9,5 +9,5 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="app"></div>
|
<div id="app" data-market-enabled="{{ market_enabled|lower }}"></div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user