mirror of
https://gitlab.crans.org/mediatek/med.git
synced 2025-07-07 09:44:01 +02:00
Add present field
This commit is contained in:
@ -1,16 +1,18 @@
|
||||
# -*- mode: python; coding: utf-8 -*-
|
||||
# Copyright (C) 2017-2019 by BDE ENS Paris-Saclay
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
from http.client import NO_CONTENT
|
||||
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import login_required, permission_required
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.http import HttpResponse
|
||||
from django_filters.rest_framework import DjangoFilterBackend
|
||||
from django.db import transaction
|
||||
from django.shortcuts import redirect, render
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.views.generic import TemplateView
|
||||
from django.views.generic import TemplateView, DetailView
|
||||
from rest_framework import viewsets
|
||||
from rest_framework.filters import SearchFilter
|
||||
from reversion import revisions as reversion
|
||||
@ -53,6 +55,42 @@ class FindMediumView(LoginRequiredMixin, TemplateView):
|
||||
template_name = "media/find_medium.html"
|
||||
|
||||
|
||||
class MarkMediumAsPresent(LoginRequiredMixin, DetailView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
object = self.get_object()
|
||||
object.present = not request.GET.get("absent", False)
|
||||
object.save()
|
||||
return HttpResponse("", content_type=204)
|
||||
|
||||
|
||||
class MarkBDAsPresent(MarkMediumAsPresent):
|
||||
model = BD
|
||||
|
||||
|
||||
class MarkMangaAsPresent(MarkMediumAsPresent):
|
||||
model = Manga
|
||||
|
||||
|
||||
class MarkCDAsPresent(MarkMediumAsPresent):
|
||||
model = CD
|
||||
|
||||
|
||||
class MarkVinyleAsPresent(MarkMediumAsPresent):
|
||||
model = Vinyle
|
||||
|
||||
|
||||
class MarkRomanAsPresent(MarkMediumAsPresent):
|
||||
model = Roman
|
||||
|
||||
|
||||
class MarkRevueAsPresent(MarkMediumAsPresent):
|
||||
model = Revue
|
||||
|
||||
|
||||
class MarkFutureAsPresent(MarkMediumAsPresent):
|
||||
model = FutureMedia
|
||||
|
||||
|
||||
class AuteurViewSet(viewsets.ModelViewSet):
|
||||
"""
|
||||
API endpoint that allows authors to be viewed or edited.
|
||||
@ -127,7 +165,6 @@ class RevueViewSet(viewsets.ModelViewSet):
|
||||
search_fields = ["$title"]
|
||||
|
||||
|
||||
|
||||
class FutureMediaViewSet(viewsets.ModelViewSet):
|
||||
"""
|
||||
API endpoint that allows media to be viewed or edited.
|
||||
|
Reference in New Issue
Block a user