Skip to content

Commit 3ac8164

Browse files
committed
HTML: Add description to meta
1 parent 839a8eb commit 3ac8164

File tree

10 files changed

+81
-7
lines changed

10 files changed

+81
-7
lines changed

gcampus/auth/views/course.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
logger = logging.getLogger("gcampus.auth.views.course")
6363

6464
_TITLE = _("Course administration")
65+
_DESCRIPTION = _(
66+
"Administer your GewässerCampus course. Edit your details, "
67+
"manage and create access keys, and download your course documents."
68+
)
6569
_COURSE_TABS = TabNavigation(
6670
course=Tab(_("Course data"), url=reverse_lazy("gcampusauth:course-update")),
6771
access_keys=Tab(
@@ -77,6 +81,7 @@ class CourseUpdateView(TitleMixin, TabsMixin, UpdateView):
7781
template_name_suffix = "_edit_form"
7882
success_url = reverse_lazy("gcampusauth:course-update")
7983
title = _TITLE
84+
description = _DESCRIPTION
8085
tabs = _COURSE_TABS
8186
current_tab_name = "course"
8287

@@ -117,6 +122,7 @@ class AccessKeyCreateView(
117122
model = AccessKey
118123
success_url = reverse_lazy("gcampusauth:course-access-keys")
119124
title = _TITLE
125+
description = _DESCRIPTION
120126
tabs = _COURSE_TABS
121127
current_tab_name = "access_keys"
122128

gcampus/auth/views/register.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ class RegisterFormView(TitleMixin, CreateView):
3636
model = Course
3737
template_name_suffix = "_create_form"
3838
title = gettext_lazy("Register a new course")
39+
description = gettext_lazy(
40+
"Register your class or course and generate a list"
41+
"of access keys for your students. "
42+
"These keys can be used to create and later edit "
43+
"measurements on GewässerCampus. "
44+
"Alongside the generated access keys, you will also "
45+
"receive a course token that should be kept "
46+
"private. With this key you can view and edit all "
47+
"your student's measurements."
48+
)
3949
success_url = reverse_lazy("gcampuscore:mapview")
4050
object: Course
4151

gcampus/auth/views/token.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ class LoginFormView(FormView, TitleMixin, ABC):
5353
template_name = "gcampusauth/login_form.html"
5454
success_url = reverse_lazy("gcampuscore:mapview")
5555
title = gettext_lazy("Login")
56+
description = gettext_lazy(
57+
"Login as a student using you access key"
58+
"to create new measurements and edit your "
59+
"existing ones. "
60+
"Teachers can login using a course token "
61+
"to administer the course, edit measurements and "
62+
"create new access keys."
63+
)
5664
# Has to be set by child classes
5765
token_type: Optional[TokenType]
5866

gcampus/core/templates/gcampuscore/base.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
<meta charset="utf-8"/>
1111
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
1212
<title>{% block title %}{% if page_title %}{{ page_title }} - GewässerCampus{% else %}GewässerCampus{% endif %}{% endblock %}</title>
13-
<meta name="description" content="{% block description %}{% endblock %}"/>
13+
{% blocktrans asvar default_description trimmed %}
14+
The web application GewässerCampus enables students, teachers,
15+
and Citizen Scientists to publish their measurements and
16+
analyze the data from all measurements to understand and explore
17+
the quality of waters.
18+
{% endblocktrans %}
19+
<meta name="description" content="{% block description %}{% firstof page_description default_description %}{% endblock %}"/>
1420
<meta name="viewport" content="width=device-width, initial-scale=1"/>
1521
<meta name="theme-color" content="#2760A4">
1622
{% settings "ENVIRONMENT" as deploy_env %}

gcampus/core/views/base.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,19 @@
2121

2222

2323
class TitleMixin(ContextMixin):
24-
title: Optional[str] = None
24+
title: str | None = None
25+
description: str | None = None
2526

2627
def get_title(self) -> str:
2728
return self.title
2829

30+
def get_description(self) -> str:
31+
return self.description
32+
2933
def get_context_data(self, **kwargs):
30-
"""Insert the page title into the context dict."""
34+
"""Insert the page title and description into the context."""
3135
kwargs.setdefault("page_title", self.get_title())
36+
kwargs.setdefault("page_description", self.get_description())
3237
return super().get_context_data(**kwargs)
3338

3439

gcampus/core/views/details/measurement.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#
1313
# You should have received a copy of the GNU Affero General Public License
1414
# along with this program. If not, see <https://www.gnu.org/licenses/>.
15+
1516
import datetime
1617
import logging
1718
from inspect import cleandoc
@@ -20,7 +21,7 @@
2021
from django.core.mail import mail_managers
2122
from django.urls import reverse
2223
from django.utils.decorators import method_decorator
23-
from django.utils.translation import gettext
24+
from django.utils.translation import gettext, gettext_lazy
2425
from django.views.generic import DetailView
2526
from django.views.generic.edit import FormMixin
2627

@@ -41,6 +42,11 @@ class MeasurementDetailView(FormMixin, TitleMixin, DetailView):
4142
"parameters"
4243
)
4344
template_name = "gcampuscore/sites/detail/measurement_detail.html"
45+
description = gettext_lazy(
46+
"Learn more about the measurement, explore nearby and similar "
47+
"measurements, and download a PDF summary of this measurement "
48+
"to discuss the results with others."
49+
)
4450
form_class = ReportForm
4551
object: Measurement
4652

gcampus/core/views/details/water.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
__all__ = ["WaterDetailView"]
1717

18+
from django.utils.translation import gettext
1819
from django.views.generic import DetailView
1920

2021
from gcampus.core.models import Water
@@ -31,8 +32,15 @@ class WaterDetailView(TitleMixin, DetailView):
3132
)
3233
template_name = "gcampuscore/sites/detail/water_detail.html"
3334

35+
def get_description(self) -> str:
36+
if not self.object:
37+
raise RuntimeError("'self.object' is not set")
38+
return gettext(
39+
"Learn more about the water '{water}' and explore all measurements "
40+
"that have been recorded at this water on GewässerCampus."
41+
).format(water=self.object.display_name)
42+
3443
def get_title(self) -> str:
35-
if self.object:
36-
return str(self.object)
37-
else:
44+
if not self.object:
3845
raise RuntimeError("'self.object' is not set")
46+
return str(self.object)

gcampus/core/views/lists/measurement.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class MeasurementListView(TitleMixin, ListView):
4343
.all()
4444
)
4545
title = gettext_lazy("All measurements")
46+
description = gettext_lazy(
47+
"List of all the measurements recorded on GewässerCampus."
48+
)
4649
context_object_name = "measurement_list"
4750
filter: MeasurementFilterSet
4851
paginate_by = 10

gcampus/core/views/lists/water.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ class WaterListView(TitleMixin, ListView):
3737
.order_by("-measurement_count", "name")
3838
)
3939
title = gettext_lazy("All waters")
40+
description = gettext_lazy(
41+
"List of all the waters recorded on GewässerCampus. You can "
42+
"browse the waters and view all measurements for a specific "
43+
"water."
44+
)
4045
context_object_name = "water_list"
4146
paginate_by = 10
4247
filter: WaterFilterSet

gcampus/tools/views.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,33 @@
3434
class ToolsOverView(TitleMixin, TemplateView):
3535
title = gettext_lazy("Tools")
3636
template_name = "gcampustools/tools.html"
37+
description = gettext_lazy(
38+
"GewässerCampus provides tools that help you to easily "
39+
"perform and analyze measurements. Calculate chemical "
40+
"parameters from optical densities or view documents and "
41+
"support material for a successful measurement."
42+
)
43+
44+
45+
_DESCRIPTION = gettext_lazy(
46+
"This tool helps you to convert the optical density you measured "
47+
"with the photometer into the value of the specific parameter. "
48+
"It uses a standard calibration which has been prepared by the "
49+
"GewässerCampus team."
50+
)
3751

3852

3953
class MeasurementKitOverView(TitleMixin, ListView):
4054
title = gettext_lazy("Measurement Kits")
55+
description = _DESCRIPTION
4156
template_name = "gcampustools/measurement_kit_overview.html"
4257
model = MeasurementKit
4358
queryset = MeasurementKit.objects.filter(calibrations__isnull=False).distinct()
4459

4560

4661
class ODConverterOverView(TitleMixin, ListView):
4762
title = gettext_lazy("Optical Density Converter")
63+
description = _DESCRIPTION
4864
template_name = "gcampustools/od_converter_overview.html"
4965
model = ParameterType
5066
kit: MeasurementKit
@@ -69,6 +85,7 @@ def get_context_data(self, **kwargs):
6985

7086
class ODConverterDetailView(TitleMixin, DetailView):
7187
title = gettext_lazy("Optical Density Converter")
88+
description = _DESCRIPTION
7289
template_name = "gcampustools/od_converter_detail.html"
7390
model = ParameterType
7491
context_object_name = "parameter"

0 commit comments

Comments
 (0)