From ac37d06e1506f20fa8c7f08bbc557a8fbe3e1409 Mon Sep 17 00:00:00 2001
From: Fredrik Jonsson <frjo@xdeb.org>
Date: Thu, 9 Jun 2022 07:53:40 +0200
Subject: [PATCH] Update to wagtail 3.

---
 hypha/apply/funds/models/applications.py                  | 3 ++-
 hypha/apply/users/admin_views.py                          | 2 +-
 hypha/apply/users/templates/wagtailusers/users/edit.html  | 5 +++--
 hypha/apply/users/templates/wagtailusers/users/index.html | 3 ---
 hypha/apply/users/templates/wagtailusers/users/list.html  | 4 +++-
 hypha/public/people/models.py                             | 3 ++-
 requirements.txt                                          | 2 +-
 7 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/hypha/apply/funds/models/applications.py b/hypha/apply/funds/models/applications.py
index 13837638b..f10aafcab 100644
--- a/hypha/apply/funds/models/applications.py
+++ b/hypha/apply/funds/models/applications.py
@@ -33,7 +33,8 @@ from wagtail.admin.edit_handlers import (
 )
 from wagtail.contrib.settings.models import BaseSetting, register_setting
 from wagtail.core.fields import RichTextField
-from wagtail.core.models import Page, PageManager, PageQuerySet
+from wagtail.core.models import Page, PageManager
+from wagtail.query import PageQuerySet
 
 from ..admin_forms import RoundBasePageAdminForm, WorkflowFormAdminForm
 from ..edit_handlers import ReadOnlyInlinePanel, ReadOnlyPanel
diff --git a/hypha/apply/users/admin_views.py b/hypha/apply/users/admin_views.py
index 17c8da583..d5e96cfbd 100644
--- a/hypha/apply/users/admin_views.py
+++ b/hypha/apply/users/admin_views.py
@@ -10,7 +10,7 @@ from django.views.decorators.vary import vary_on_headers
 from wagtail.admin.auth import any_permission_required
 from wagtail.admin.filters import WagtailFilterSet
 from wagtail.admin.forms.search import SearchForm
-from wagtail.core.compat import AUTH_USER_APP_LABEL, AUTH_USER_MODEL_NAME
+from wagtail.compat import AUTH_USER_APP_LABEL, AUTH_USER_MODEL_NAME
 
 User = get_user_model()
 
diff --git a/hypha/apply/users/templates/wagtailusers/users/edit.html b/hypha/apply/users/templates/wagtailusers/users/edit.html
index 6acd9e295..1846bcb28 100644
--- a/hypha/apply/users/templates/wagtailusers/users/edit.html
+++ b/hypha/apply/users/templates/wagtailusers/users/edit.html
@@ -6,7 +6,7 @@
     {% trans "Editing" as editing_str %}
     {% include "wagtailadmin/shared/header.html" with title=editing_str subtitle=user.get_username merged=1 tabbed=1 icon="user" %}
 
-    <ul class="tab-nav merged" data-tab-nav>
+    <ul class="tab-nav merged">
         <li class="active"><a href="#account">{% trans "Account" %}</a></li>
         <li><a href="#roles">{% trans "Roles" %}</a></li>
     </ul>
@@ -24,6 +24,7 @@
                         {% endif %}
                         {% include "wagtailadmin/shared/field_as_li.html" with field=form.email %}
                         {% include "wagtailadmin/shared/field_as_li.html" with field=form.full_name %}
+                        {% block extra_fields %}{% endblock extra_fields %}
 
                         {% comment %}
                             First/last name hidden input with dummy values because.. Wagtail admin
@@ -41,8 +42,8 @@
                         {% if form.is_active %}
                             {% include "wagtailadmin/shared/field_as_li.html" with field=form.is_active %}
                         {% endif %}
-                    {% endblock fields %}
 
+                    {% endblock fields %}
                     <li>
                         <input type="submit" value="{% trans 'Save' %}" class="button" />
                         {% if can_delete %}
diff --git a/hypha/apply/users/templates/wagtailusers/users/index.html b/hypha/apply/users/templates/wagtailusers/users/index.html
index fd28fb0f8..251f77009 100644
--- a/hypha/apply/users/templates/wagtailusers/users/index.html
+++ b/hypha/apply/users/templates/wagtailusers/users/index.html
@@ -21,10 +21,7 @@
 {% endblock %}
 
 {% block extra_css %}
-    {{ block.super }}
     <link rel="stylesheet" href="{% static 'css/apply/wagtail_users_list.css' %}" type="text/css" />
-
-    {{ filters.form.media.css }}
 {% endblock %}
 
 {% block content %}
diff --git a/hypha/apply/users/templates/wagtailusers/users/list.html b/hypha/apply/users/templates/wagtailusers/users/list.html
index 1ba5b89f7..c80d25ea8 100644
--- a/hypha/apply/users/templates/wagtailusers/users/list.html
+++ b/hypha/apply/users/templates/wagtailusers/users/list.html
@@ -28,6 +28,7 @@
                     <a href="{% url 'wagtailusers_users:index' %}?ordering=status" class="icon icon-arrow-down-after"></a>
                 {% endif %}
             </th>
+            <th class="last-login">{% trans "Last Login" %}</th>
         </tr>
     </thead>
     <tbody>
@@ -36,7 +37,7 @@
                 {% include "wagtailadmin/bulk_actions/listing_checkbox_cell.html" with obj_type="user" obj=user aria_labelledby_prefix="user_" aria_labelledby=user.pk|unlocalize aria_labelledby_suffix="_title" %}
                 <td id="user_{{ user.pk|unlocalize }}_title" class="title" valign="top">
                     <h2 class="title-wrapper">
-                        <span class="avatar small"><img src="{% avatar_url user size=25 %}" /></span>
+                        <span class="avatar small"><img src="{% avatar_url user size=25 %}" alt="" /></span>
                         <a href="{% url 'wagtailusers_users:edit' user.pk %}">{{ user.get_full_name|default:user.get_username }}</a>
                     </h2>
                     <ul class="actions">
@@ -46,6 +47,7 @@
                 <td class="username" valign="top">{{ user.get_username }}</td>
                 <td class="level" valign="top">{{ user.roles|join:', ' }}{% if user.is_superuser %} ({% trans "Admin" %}){% endif %}</td>
                 <td class="status" valign="top"><div class="status-tag {% if user.is_active %}primary{% endif %}">{% if user.is_active %}{% trans "Active" %}{% else %}{% trans "Inactive" %}{% endif %}</div></td>
+                <td {% if user.last_login %} class="human-readable-date" title="{{ user.last_login|date:"d M Y H:i" }}"{% endif %}>{% if user.last_login %}{% blocktrans with time_period=user.last_login|timesince %}{{ time_period }} ago{% endblocktrans %}{% endif %}</td>
             </tr>
         {% endfor %}
     </tbody>
diff --git a/hypha/public/people/models.py b/hypha/public/people/models.py
index a41e750bb..763543683 100644
--- a/hypha/public/people/models.py
+++ b/hypha/public/people/models.py
@@ -14,8 +14,9 @@ from wagtail.admin.edit_handlers import (
     StreamFieldPanel,
 )
 from wagtail.core.fields import StreamField
-from wagtail.core.models import Orderable, PageManager, PageQuerySet
+from wagtail.core.models import Orderable, PageManager
 from wagtail.images.edit_handlers import ImageChooserPanel
+from wagtail.query import PageQuerySet
 from wagtail.search import index
 
 from hypha.public.utils.blocks import StoryBlock
diff --git a/requirements.txt b/requirements.txt
index 32d27a17a..0231604ad 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -48,6 +48,6 @@ social_auth_app_django==5.0.0
 tomd==0.1.3
 wagtail-cache==1.0.2
 wagtail-purge==0.1
-wagtail==2.16.1
+wagtail==3.0.0
 whitenoise==5.3.0
 xmltodict==0.12.0
-- 
GitLab