Ejemplo n.º 1
0
Archivo: home.py Proyecto: Nearata/kami
    async def get(self, request: Request) -> _TemplateResponse:
        context = {"request": request}

        anime = []
        for i in Anime.select():
            try:
                fansub = Fansub.get(id=i.fansub_id)
                fansub_name = fansub.name
            except Fansub.DoesNotExist:
                fansub_name = "N.A"

            anime.append({
                "name":
                i.name,
                "url": [{
                    "name": parts.split(";")[0],
                    "href": parts.split(";")[1]
                } for parts in i.url.split(",")] if len(i.url) else [],
                "fansub":
                fansub_name
            })

        context.update({"anime": anime})

        return templates.TemplateResponse("home.html", context)
Ejemplo n.º 2
0
    def __response(self,
                   request: Request,
                   extra: Optional[dict] = None) -> _TemplateResponse:
        context = {"request": request, "anime": Anime.select()}

        if extra:
            context.update(extra)

        return templates.TemplateResponse("anime/backend.html", context)
Ejemplo n.º 3
0
    def __response(self,
                   request: Request,
                   extra: dict = None) -> _TemplateResponse:
        context = {"request": request, "fansub": Fansub.select()}

        if extra:
            context.update(extra)

        return templates.TemplateResponse("anime/edit.html", context)
Ejemplo n.º 4
0
    def __response(self,
                   request: Request,
                   extra: Optional[dict] = None) -> _TemplateResponse:
        context = {"request": request}

        if extra:
            context.update(extra)

        return templates.TemplateResponse("pages/add.html", context)
Ejemplo n.º 5
0
    def __response(self,
                   request: Request,
                   extra: Optional[dict] = None) -> _TemplateResponse:
        context = {"request": request, "fansub": Fansub.select()}

        if extra:
            context.update(extra)

        return templates.TemplateResponse("fansub/remove.html", context)
Ejemplo n.º 6
0
    def __response(self,
                   request: Request,
                   extra: Optional[dict] = None) -> _TemplateResponse:
        context = {"request": request}

        if extra:
            context.update(extra)

        return templates.TemplateResponse("security/changepassword.html",
                                          context)
Ejemplo n.º 7
0
    def __response(self,
                   request: Request,
                   extra: Optional[dict] = None,
                   status_code: Optional[int] = 200) -> _TemplateResponse:
        context = {"request": request}

        if extra:
            context.update(extra)

        return templates.TemplateResponse("security_twofactor.html",
                                          context=context,
                                          status_code=status_code)
Ejemplo n.º 8
0
    def __auth_response(self,
                        request: Request,
                        extra: dict = None,
                        status_code: int = 200) -> _TemplateResponse:
        context = {
            "request": request,
            "captcha": CAPTCHA,
            "captcha_sitekey": CAPTCHA_SITE_KEY
        }

        if extra:
            context.update(extra)

        return templates.TemplateResponse("auth_login.html", context,
                                          status_code)
Ejemplo n.º 9
0
    async def get(self, request: Request) -> _TemplateResponse:
        slug = request.path_params.get("slug", "")

        try:
            page = Pages.get(slug=slug)
        except Pages.DoesNotExist:
            raise HTTPException(404)

        context = {
            "request": request,
            "name": page.name,
            "content": page.content
        }

        return templates.TemplateResponse("pages/frontend.html", context)
Ejemplo n.º 10
0
 async def get(self, request: Request) -> _TemplateResponse:
     return templates.TemplateResponse("dashboard.html",
                                       {"request": request})
Ejemplo n.º 11
0
 async def get(self, request: Request) -> _TemplateResponse:
     return templates.TemplateResponse("security/backend.html",
                                       {"request": request})