From e5b9b98f66a2a5a9bae35e4391c6b3be8fd35ef6 Mon Sep 17 00:00:00 2001 From: Ali Hassan Date: Fri, 17 Mar 2023 11:55:53 +0500 Subject: [PATCH 1/3] Removes "View Draft" and "Preview" to prevent unpredictable results --- iogt/templates/wagtailadmin/pages/create.html | 117 ++++++++++++ iogt/templates/wagtailadmin/pages/edit.html | 177 ++++++++++++++++++ .../wagtailadmin/pages/listing/_buttons.html | 5 + 3 files changed, 299 insertions(+) create mode 100644 iogt/templates/wagtailadmin/pages/create.html create mode 100644 iogt/templates/wagtailadmin/pages/edit.html create mode 100644 iogt/templates/wagtailadmin/pages/listing/_buttons.html diff --git a/iogt/templates/wagtailadmin/pages/create.html b/iogt/templates/wagtailadmin/pages/create.html new file mode 100644 index 000000000..c265a4276 --- /dev/null +++ b/iogt/templates/wagtailadmin/pages/create.html @@ -0,0 +1,117 @@ +{% extends "wagtailadmin/base.html" %} +{% load wagtailadmin_tags %} +{% load i18n %} + +{% block titletag %}{% blocktrans with page_type=content_type.model_class.get_verbose_name %}New {{ page_type }}{% endblocktrans %}{% endblock %} +{% block bodyclass %}page-editor create model-{{ content_type.model }}{% endblock %} + +{% block content %} +
+
+ {% explorer_breadcrumb parent_page include_self=1 trailing_arrow=True %} + +
+
+

{% trans 'New' %} {{ content_type.model_class.get_verbose_name }}

+
+
+ + {% if locale %} + + {% endif %} +
+ +
+ {% csrf_token %} + + + {% if parent_page.is_root %} + {# The user is allowed to set a different locale for pages created at the root #} + {# If they've done this, make sure their chosen locale is passed in the form #} + + {% endif %} + + {{ edit_handler.render_form_content }} + +
+
    + + {% include "wagtailadmin/pages/_unsaved_changes_warning.html" %} +
+
+
+ +{% endblock %} + +{% block extra_css %} + {{ block.super }} + {% include "wagtailadmin/pages/_editor_css.html" %} + {{ edit_handler.form.media.css }} + {{ action_menu.media.css }} +{% endblock %} + +{% block extra_js %} + {{ block.super }} + {% include "wagtailadmin/pages/_editor_js.html" %} + + {% comment %} + Additional js from widgets media. Allows for custom widgets in admin panel. + {% endcomment %} + {{ edit_handler.form.media.js }} + {{ action_menu.media.js }} + + {% comment %} + Additional HTML code that edit handlers define through 'html_declarations'. (Technically this isn't JavaScript, but it will generally be data that exists for JavaScript to work with...) + {% endcomment %} + {{ edit_handler.html_declarations }} + + +{% endblock %} diff --git a/iogt/templates/wagtailadmin/pages/edit.html b/iogt/templates/wagtailadmin/pages/edit.html new file mode 100644 index 000000000..4072d5924 --- /dev/null +++ b/iogt/templates/wagtailadmin/pages/edit.html @@ -0,0 +1,177 @@ +{% extends "wagtailadmin/base.html" %} +{% load wagtailadmin_tags %} +{% load i18n %} +{% load l10n %} +{% block titletag %}{% blocktrans with title=page.get_admin_display_title page_type=content_type.model_class.get_verbose_name %}Editing {{ page_type }}: {{ title }}{% endblocktrans %}{% endblock %} +{% block bodyclass %}page-editor {% if page.live %}page-is-live{% endif %} model-{{ content_type.model }} {% if page_locked %}page-locked{% endif %}{% endblock %} + +{% block content %} +
+ {% page_permissions page as page_perms %} +
+ {% explorer_breadcrumb page %} + +
+

+ {{ page.get_admin_display_title }} +

+ +
+ {% include "wagtailadmin/pages/_page_view_live_tag.html" with page=page_for_status %} +
+
+ +
+ + {% block form %} +
+ {% csrf_token %} + + + {{ edit_handler.render_form_content }} + + {% if is_revision %} + + {% endif %} + +
+
    + + {% include "wagtailadmin/pages/_unsaved_changes_warning.html" %} +
+
+
+ {% endblock %} + +{% endblock %} + +{% block extra_css %} + {{ block.super }} + {% include "wagtailadmin/pages/_editor_css.html" %} + {{ edit_handler.form.media.css }} + {{ action_menu.media.css }} +{% endblock %} + +{% block extra_js %} + {{ block.super }} + {% include "wagtailadmin/pages/_editor_js.html" %} + + {% comment %} + Additional js from widgets media. Allows for custom widgets in admin panel. + {% endcomment %} + {{ edit_handler.form.media.js }} + {{ action_menu.media.js }} + + {% comment %} + Additional HTML code that edit handlers define through 'html_declarations'. (Technically this isn't JavaScript, but it will generally be data that exists for JavaScript to work with...) + {% endcomment %} + {{ edit_handler.html_declarations }} + + +{% endblock %} diff --git a/iogt/templates/wagtailadmin/pages/listing/_buttons.html b/iogt/templates/wagtailadmin/pages/listing/_buttons.html new file mode 100644 index 000000000..07f6b9e3d --- /dev/null +++ b/iogt/templates/wagtailadmin/pages/listing/_buttons.html @@ -0,0 +1,5 @@ +{% for button in buttons %} + {% if button.show and button.label != 'View draft' %} +
  • {{ button|safe }}
  • + {% endif %} +{% endfor %} From b6ae42ba4d5a087eaf0207f2fabca3d6c1d87203 Mon Sep 17 00:00:00 2001 From: Ali Hassan Date: Mon, 20 Mar 2023 11:55:55 +0500 Subject: [PATCH 2/3] Removes 'View Draft' button and preview buttons for questionnaires --- iogt/templates/wagtailadmin/pages/create.html | 21 ++++++++++++++++++ iogt/templates/wagtailadmin/pages/edit.html | 22 +++++++++++++++++++ .../wagtailadmin/pages/listing/_buttons.html | 8 ++++--- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/iogt/templates/wagtailadmin/pages/create.html b/iogt/templates/wagtailadmin/pages/create.html index c265a4276..2b10f9b8c 100644 --- a/iogt/templates/wagtailadmin/pages/create.html +++ b/iogt/templates/wagtailadmin/pages/create.html @@ -47,6 +47,27 @@

    {% trans 'New' %} {{ content_type.model_class.get_verbose_name }} + + {% if preview_modes and content_type.name != 'poll' and content_type.name != 'quiz' and content_type.name != 'survey' %} +
  • + {% trans 'Preview' as preview_label %} + {% if preview_modes|length > 1 %} + + {% else %} + {% include "wagtailadmin/pages/_preview_button_on_create.html" with label=preview_label icon=1 %} + {% endif %} +
  • + {% endif %} {% block extra_footer_actions %} {% endblock %} diff --git a/iogt/templates/wagtailadmin/pages/edit.html b/iogt/templates/wagtailadmin/pages/edit.html index 4072d5924..a0d13e6b8 100644 --- a/iogt/templates/wagtailadmin/pages/edit.html +++ b/iogt/templates/wagtailadmin/pages/edit.html @@ -63,6 +63,28 @@

    + {% trans 'Preview' as preview_label %} + {% if preview_modes|length > 1 %} + + {% else %} + {% include "wagtailadmin/pages/_preview_button_on_edit.html" with label=preview_label icon=1 %} + {% endif %} + + {% endif %} + {% endwith %} {% block extra_footer_actions %} {% endblock %} diff --git a/iogt/templates/wagtailadmin/pages/listing/_buttons.html b/iogt/templates/wagtailadmin/pages/listing/_buttons.html index 07f6b9e3d..78c50b860 100644 --- a/iogt/templates/wagtailadmin/pages/listing/_buttons.html +++ b/iogt/templates/wagtailadmin/pages/listing/_buttons.html @@ -1,5 +1,7 @@ {% for button in buttons %} - {% if button.show and button.label != 'View draft' %} -
  • {{ button|safe }}
  • - {% endif %} + {% with page.get_type as page_type %} + {% if button.show and page_type != 'poll' and page_type != 'quiz' and page_type != 'survey' or button.label != 'View draft' %} +
  • {{ button|safe }}
  • + {% endif %} + {% endwith %} {% endfor %} From e3c63e2d4daf7b3f986febbbcb199952dc693038 Mon Sep 17 00:00:00 2001 From: Ali Hassan Date: Mon, 20 Mar 2023 14:33:05 +0500 Subject: [PATCH 3/3] minor change --- iogt/templates/wagtailadmin/pages/create.html | 138 ------------ iogt/templates/wagtailadmin/pages/edit.html | 199 ------------------ questionnaires/models.py | 1 + 3 files changed, 1 insertion(+), 337 deletions(-) delete mode 100644 iogt/templates/wagtailadmin/pages/create.html delete mode 100644 iogt/templates/wagtailadmin/pages/edit.html diff --git a/iogt/templates/wagtailadmin/pages/create.html b/iogt/templates/wagtailadmin/pages/create.html deleted file mode 100644 index 2b10f9b8c..000000000 --- a/iogt/templates/wagtailadmin/pages/create.html +++ /dev/null @@ -1,138 +0,0 @@ -{% extends "wagtailadmin/base.html" %} -{% load wagtailadmin_tags %} -{% load i18n %} - -{% block titletag %}{% blocktrans with page_type=content_type.model_class.get_verbose_name %}New {{ page_type }}{% endblocktrans %}{% endblock %} -{% block bodyclass %}page-editor create model-{{ content_type.model }}{% endblock %} - -{% block content %} -
    -
    - {% explorer_breadcrumb parent_page include_self=1 trailing_arrow=True %} - -
    -
    -

    {% trans 'New' %} {{ content_type.model_class.get_verbose_name }}

    -
    -
    - - {% if locale %} -
      -
    • - {% include "wagtailadmin/shared/locale_selector.html" %} -
    • -
    - {% endif %} -
    - -
    - {% csrf_token %} - - - {% if parent_page.is_root %} - {# The user is allowed to set a different locale for pages created at the root #} - {# If they've done this, make sure their chosen locale is passed in the form #} - - {% endif %} - - {{ edit_handler.render_form_content }} - -
    -
      - - {% include "wagtailadmin/pages/_unsaved_changes_warning.html" %} -
    -
    -
    - -{% endblock %} - -{% block extra_css %} - {{ block.super }} - {% include "wagtailadmin/pages/_editor_css.html" %} - {{ edit_handler.form.media.css }} - {{ action_menu.media.css }} -{% endblock %} - -{% block extra_js %} - {{ block.super }} - {% include "wagtailadmin/pages/_editor_js.html" %} - - {% comment %} - Additional js from widgets media. Allows for custom widgets in admin panel. - {% endcomment %} - {{ edit_handler.form.media.js }} - {{ action_menu.media.js }} - - {% comment %} - Additional HTML code that edit handlers define through 'html_declarations'. (Technically this isn't JavaScript, but it will generally be data that exists for JavaScript to work with...) - {% endcomment %} - {{ edit_handler.html_declarations }} - - -{% endblock %} diff --git a/iogt/templates/wagtailadmin/pages/edit.html b/iogt/templates/wagtailadmin/pages/edit.html deleted file mode 100644 index a0d13e6b8..000000000 --- a/iogt/templates/wagtailadmin/pages/edit.html +++ /dev/null @@ -1,199 +0,0 @@ -{% extends "wagtailadmin/base.html" %} -{% load wagtailadmin_tags %} -{% load i18n %} -{% load l10n %} -{% block titletag %}{% blocktrans with title=page.get_admin_display_title page_type=content_type.model_class.get_verbose_name %}Editing {{ page_type }}: {{ title }}{% endblocktrans %}{% endblock %} -{% block bodyclass %}page-editor {% if page.live %}page-is-live{% endif %} model-{{ content_type.model }} {% if page_locked %}page-locked{% endif %}{% endblock %} - -{% block content %} -
    - {% page_permissions page as page_perms %} -
    - {% explorer_breadcrumb page %} - -
    -

    - {{ page.get_admin_display_title }} -

    - -
    - {% include "wagtailadmin/pages/_page_view_live_tag.html" with page=page_for_status %} -
    -
    -
      - {% include "wagtailadmin/shared/workflow_status.html" with page=page_for_status %} - {% if page.get_latest_revision %} -
    • - - {% icon "history" class_name="default" %} - {% trans "History" %} - -
    • - {% endif %} -
    • - {% icon name="doc-empty-inverse" class_name="default" %} - {{ content_type.model_class.get_verbose_name }} -
    • - {% if locale %} -
    • - {% include "wagtailadmin/shared/locale_selector.html" %} -
    • - {% endif %} -
    -
    - - {% block form %} -
    - {% csrf_token %} - - - {{ edit_handler.render_form_content }} - - {% if is_revision %} - - {% endif %} - -
    -
      - - {% include "wagtailadmin/pages/_unsaved_changes_warning.html" %} -
    -
    -
    - {% endblock %} - -{% endblock %} - -{% block extra_css %} - {{ block.super }} - {% include "wagtailadmin/pages/_editor_css.html" %} - {{ edit_handler.form.media.css }} - {{ action_menu.media.css }} -{% endblock %} - -{% block extra_js %} - {{ block.super }} - {% include "wagtailadmin/pages/_editor_js.html" %} - - {% comment %} - Additional js from widgets media. Allows for custom widgets in admin panel. - {% endcomment %} - {{ edit_handler.form.media.js }} - {{ action_menu.media.js }} - - {% comment %} - Additional HTML code that edit handlers define through 'html_declarations'. (Technically this isn't JavaScript, but it will generally be data that exists for JavaScript to work with...) - {% endcomment %} - {{ edit_handler.html_declarations }} - - -{% endblock %} diff --git a/questionnaires/models.py b/questionnaires/models.py index 18e85b1e1..e7e518692 100644 --- a/questionnaires/models.py +++ b/questionnaires/models.py @@ -56,6 +56,7 @@ class QuestionnairePage(Page, PageUtilsMixin, TitleIconMixin): parent_page_types = [] subpage_types = [] show_in_menus_default = True + preview_modes = [] description = StreamField( [