Coverage for crateweb/core/views.py: 69%
16 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-08-27 10:34 -0500
« prev ^ index » next coverage.py v7.8.0, created at 2025-08-27 10:34 -0500
1"""
2crate_anon/crateweb/core/views.py
4===============================================================================
6 Copyright (C) 2015, University of Cambridge, Department of Psychiatry.
7 Created by Rudolf Cardinal (rnc1001@cam.ac.uk).
9 This file is part of CRATE.
11 CRATE is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 CRATE is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with CRATE. If not, see <https://www.gnu.org/licenses/>.
24===============================================================================
26**A few core views, like the home page.**
28"""
30import logging
31from django.conf import settings
32from django.http import HttpResponse
33from django.http.request import HttpRequest
34from django.shortcuts import render
35from crate_anon.crateweb.core.utils import is_clinician, is_developer
36from crate_anon.crateweb.research.views import query_context
37from crate_anon.version import CRATE_VERSION, CRATE_VERSION_DATE
39log = logging.getLogger(__name__)
42# =============================================================================
43# Home
44# =============================================================================
47def home(request: HttpRequest) -> HttpResponse:
48 """
49 The home (main menu) view.
50 """
51 # leaflets = [{'key': x[0], 'name': x[1]} for x in Leaflet.LEAFLET_CHOICES]
52 # log.debug("IP Address for debug-toolbar: " + request.META['REMOTE_ADDR'])
53 # log.debug(f"MIDDLEWARE_CLASSES: {MIDDLEWARE_CLASSES!r}")
54 context = {
55 "nav_on_main_menu": True,
56 "is_clinician": is_clinician(request.user),
57 "is_developer": is_developer(request.user),
58 "safety_catch_on": settings.SAFETY_CATCH_ON,
59 "developer_email": settings.DEVELOPER_EMAIL,
60 # 'leaflets': leaflets,
61 }
62 context.update(query_context(request))
63 return render(request, "home.html", context)
66# =============================================================================
67# About
68# =============================================================================
71def about(request: HttpRequest) -> HttpResponse:
72 """
73 The "about CRATE" view.
74 """
75 context = {
76 "VERSION": CRATE_VERSION,
77 "VERSION_DATE": CRATE_VERSION_DATE,
78 }
79 return render(request, "about.html", context)