From: Parker Berberian Date: Thu, 30 Jan 2020 18:33:35 +0000 (-0500) Subject: Adds Template Overrides X-Git-Tag: 2.0.99~46 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F14%2F69614%2F4;p=laas.git Adds Template Overrides Changes the structure of the template directories to allow a new project to define their own set of override templates that inherit from a common base. I have slightly modified landing.html here as an example. In comming changes we will try to move all the "laas" specific content into the laas directory Change-Id: I46151be182de901f870debb247b305ea34ae77ba Signed-off-by: Parker Berberian --- diff --git a/config.env.sample b/config.env.sample index 7677c2f..01194b9 100644 --- a/config.env.sample +++ b/config.env.sample @@ -36,3 +36,6 @@ EMAIL_PORT= EMAIL_HOST_USER= EMAIL_HOST_PASSWORD= DEFAULT_FROM_EMAIL=webmaster@localhost + + +TEMPLATE_OVERRIDE_DIR=laas diff --git a/src/laas_dashboard/settings.py b/src/laas_dashboard/settings.py index 951ce1a..d41ad0c 100644 --- a/src/laas_dashboard/settings.py +++ b/src/laas_dashboard/settings.py @@ -53,10 +53,23 @@ MIDDLEWARE = [ ROOT_URLCONF = 'laas_dashboard.urls' +TEMPLATE_OVERRIDE = os.environ.get("TEMPLATE_OVERRIDE_DIR", "") # the user's custom template dir +TEMPLATE_DIRS = ["base"] # where all the base templates are + +# If the user has a custom template directory, +# We should search that first. Then we search the +# root template directory so that we can extend the base +# templates within the custom template dir. +if TEMPLATE_OVERRIDE: + TEMPLATE_DIRS = [TEMPLATE_OVERRIDE, ""] + TEMPLATE_DIRS + +# all template dirs are relative to /project_root/templates/ +dirs = [os.path.join(BASE_DIR, "templates", d) for d in TEMPLATE_DIRS] + TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'templates')], + 'DIRS': dirs, 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ diff --git a/src/templates/README b/src/templates/README new file mode 100644 index 0000000..d058036 --- /dev/null +++ b/src/templates/README @@ -0,0 +1,25 @@ +We use a special directory structure here that allows you to define +your own set of templates than inherit from a common base. + +To create your own templates: + +Create your new directory as a sibling of base/ + `mkdir my_templates` + +Now you can override any template file in base/ by creating a file of the same name in my_templates. + +For example, to replace base/booking/booking_table.html, +you would create my_templates/booking/booking_table.html. Your template will be loaded instead of the original. + + +You can also inherit from the base templates. For example, if you +wanted to add to base/dashboard/landing.html, you can create +a template at my_templates/dashboard/landing.html and add this line to +the top of the file: + {% extends base/dashboard/landing.html %} + +This way you can add in new {% block %} tags to the parents and define only +the new content you need without affecting the default behavior. + + +When your template directory is ready, you must add it to your config.env diff --git a/src/templates/account/booking_list.html b/src/templates/base/account/booking_list.html similarity index 100% rename from src/templates/account/booking_list.html rename to src/templates/base/account/booking_list.html diff --git a/src/templates/account/configuration_list.html b/src/templates/base/account/configuration_list.html similarity index 100% rename from src/templates/account/configuration_list.html rename to src/templates/base/account/configuration_list.html diff --git a/src/templates/account/details.html b/src/templates/base/account/details.html similarity index 100% rename from src/templates/account/details.html rename to src/templates/base/account/details.html diff --git a/src/templates/account/image_list.html b/src/templates/base/account/image_list.html similarity index 100% rename from src/templates/account/image_list.html rename to src/templates/base/account/image_list.html diff --git a/src/templates/account/resource_list.html b/src/templates/base/account/resource_list.html similarity index 100% rename from src/templates/account/resource_list.html rename to src/templates/base/account/resource_list.html diff --git a/src/templates/account/user_list.html b/src/templates/base/account/user_list.html similarity index 100% rename from src/templates/account/user_list.html rename to src/templates/base/account/user_list.html diff --git a/src/templates/account/userprofile_update_form.html b/src/templates/base/account/userprofile_update_form.html similarity index 100% rename from src/templates/account/userprofile_update_form.html rename to src/templates/base/account/userprofile_update_form.html diff --git a/src/templates/base.html b/src/templates/base/base.html similarity index 100% rename from src/templates/base.html rename to src/templates/base/base.html diff --git a/src/templates/booking/booking_calendar.html b/src/templates/base/booking/booking_calendar.html similarity index 100% rename from src/templates/booking/booking_calendar.html rename to src/templates/base/booking/booking_calendar.html diff --git a/src/templates/booking/booking_delete.html b/src/templates/base/booking/booking_delete.html similarity index 100% rename from src/templates/booking/booking_delete.html rename to src/templates/base/booking/booking_delete.html diff --git a/src/templates/booking/booking_detail.html b/src/templates/base/booking/booking_detail.html similarity index 100% rename from src/templates/booking/booking_detail.html rename to src/templates/base/booking/booking_detail.html diff --git a/src/templates/booking/booking_grid_item.html b/src/templates/base/booking/booking_grid_item.html similarity index 100% rename from src/templates/booking/booking_grid_item.html rename to src/templates/base/booking/booking_grid_item.html diff --git a/src/templates/booking/booking_list.html b/src/templates/base/booking/booking_list.html similarity index 100% rename from src/templates/booking/booking_list.html rename to src/templates/base/booking/booking_list.html diff --git a/src/templates/booking/booking_table.html b/src/templates/base/booking/booking_table.html similarity index 100% rename from src/templates/booking/booking_table.html rename to src/templates/base/booking/booking_table.html diff --git a/src/templates/booking/quick_deploy.html b/src/templates/base/booking/quick_deploy.html similarity index 100% rename from src/templates/booking/quick_deploy.html rename to src/templates/base/booking/quick_deploy.html diff --git a/src/templates/booking/stats.html b/src/templates/base/booking/stats.html similarity index 100% rename from src/templates/booking/stats.html rename to src/templates/base/booking/stats.html diff --git a/src/templates/booking/steps/booking_meta.html b/src/templates/base/booking/steps/booking_meta.html similarity index 100% rename from src/templates/booking/steps/booking_meta.html rename to src/templates/base/booking/steps/booking_meta.html diff --git a/src/templates/config_bundle/steps/assign_host_roles.html b/src/templates/base/config_bundle/steps/assign_host_roles.html similarity index 100% rename from src/templates/config_bundle/steps/assign_host_roles.html rename to src/templates/base/config_bundle/steps/assign_host_roles.html diff --git a/src/templates/config_bundle/steps/assign_network_roles.html b/src/templates/base/config_bundle/steps/assign_network_roles.html similarity index 100% rename from src/templates/config_bundle/steps/assign_network_roles.html rename to src/templates/base/config_bundle/steps/assign_network_roles.html diff --git a/src/templates/config_bundle/steps/config_software.html b/src/templates/base/config_bundle/steps/config_software.html similarity index 100% rename from src/templates/config_bundle/steps/config_software.html rename to src/templates/base/config_bundle/steps/config_software.html diff --git a/src/templates/config_bundle/steps/define_software.html b/src/templates/base/config_bundle/steps/define_software.html similarity index 100% rename from src/templates/config_bundle/steps/define_software.html rename to src/templates/base/config_bundle/steps/define_software.html diff --git a/src/templates/config_bundle/steps/pick_installer.html b/src/templates/base/config_bundle/steps/pick_installer.html similarity index 100% rename from src/templates/config_bundle/steps/pick_installer.html rename to src/templates/base/config_bundle/steps/pick_installer.html diff --git a/src/templates/config_bundle/steps/table_formset.html b/src/templates/base/config_bundle/steps/table_formset.html similarity index 100% rename from src/templates/config_bundle/steps/table_formset.html rename to src/templates/base/config_bundle/steps/table_formset.html diff --git a/src/templates/dashboard/genericselect.html b/src/templates/base/dashboard/genericselect.html similarity index 100% rename from src/templates/dashboard/genericselect.html rename to src/templates/base/dashboard/genericselect.html diff --git a/src/templates/dashboard/host_profile_detail.html b/src/templates/base/dashboard/host_profile_detail.html similarity index 100% rename from src/templates/dashboard/host_profile_detail.html rename to src/templates/base/dashboard/host_profile_detail.html diff --git a/src/templates/dashboard/idf.yaml b/src/templates/base/dashboard/idf.yaml similarity index 100% rename from src/templates/dashboard/idf.yaml rename to src/templates/base/dashboard/idf.yaml diff --git a/src/templates/dashboard/lab_detail.html b/src/templates/base/dashboard/lab_detail.html similarity index 100% rename from src/templates/dashboard/lab_detail.html rename to src/templates/base/dashboard/lab_detail.html diff --git a/src/templates/dashboard/lab_list.html b/src/templates/base/dashboard/lab_list.html similarity index 100% rename from src/templates/dashboard/lab_list.html rename to src/templates/base/dashboard/lab_list.html diff --git a/src/templates/dashboard/landing.html b/src/templates/base/dashboard/landing.html similarity index 80% rename from src/templates/dashboard/landing.html rename to src/templates/base/dashboard/landing.html index f0fa954..9e45b09 100644 --- a/src/templates/dashboard/landing.html +++ b/src/templates/base/dashboard/landing.html @@ -19,14 +19,9 @@

About Us

-

The Lab as a Service (LaaS) project aims to help in the development and testing of LFN projects such as - OPNFV - by hosting hardware and providing access to the community. Currently, the only participating lab is the - University of New Hampshire Interoperability Lab (UNH-IOL).

-

To get started, you can request access to a server at the right. PTL's have the ability to design and - book a - whole block of servers with customized layer2 networks (e.g. a Pharos Pod). Read more here: LaaS Wiki

+ {% block about_us %} +

Here is some information about us!

+ {% endblock about_us %}
diff --git a/src/templates/dashboard/login.html b/src/templates/base/dashboard/login.html similarity index 100% rename from src/templates/dashboard/login.html rename to src/templates/base/dashboard/login.html diff --git a/src/templates/dashboard/multiple_select_filter_widget.html b/src/templates/base/dashboard/multiple_select_filter_widget.html similarity index 100% rename from src/templates/dashboard/multiple_select_filter_widget.html rename to src/templates/base/dashboard/multiple_select_filter_widget.html diff --git a/src/templates/dashboard/pdf.yaml b/src/templates/base/dashboard/pdf.yaml similarity index 100% rename from src/templates/dashboard/pdf.yaml rename to src/templates/base/dashboard/pdf.yaml diff --git a/src/templates/dashboard/resource.html b/src/templates/base/dashboard/resource.html similarity index 100% rename from src/templates/dashboard/resource.html rename to src/templates/base/dashboard/resource.html diff --git a/src/templates/dashboard/resource_all.html b/src/templates/base/dashboard/resource_all.html similarity index 100% rename from src/templates/dashboard/resource_all.html rename to src/templates/base/dashboard/resource_all.html diff --git a/src/templates/dashboard/resource_detail.html b/src/templates/base/dashboard/resource_detail.html similarity index 100% rename from src/templates/dashboard/resource_detail.html rename to src/templates/base/dashboard/resource_detail.html diff --git a/src/templates/dashboard/searchable_select_multiple.html b/src/templates/base/dashboard/searchable_select_multiple.html similarity index 100% rename from src/templates/dashboard/searchable_select_multiple.html rename to src/templates/base/dashboard/searchable_select_multiple.html diff --git a/src/templates/dashboard/server_table.html b/src/templates/base/dashboard/server_table.html similarity index 100% rename from src/templates/dashboard/server_table.html rename to src/templates/base/dashboard/server_table.html diff --git a/src/templates/dashboard/table.html b/src/templates/base/dashboard/table.html similarity index 100% rename from src/templates/dashboard/table.html rename to src/templates/base/dashboard/table.html diff --git a/src/templates/layout.html b/src/templates/base/layout.html similarity index 100% rename from src/templates/layout.html rename to src/templates/base/layout.html diff --git a/src/templates/notifier/email_ended.txt b/src/templates/base/notifier/email_ended.txt similarity index 100% rename from src/templates/notifier/email_ended.txt rename to src/templates/base/notifier/email_ended.txt diff --git a/src/templates/notifier/email_expiring.txt b/src/templates/base/notifier/email_expiring.txt similarity index 100% rename from src/templates/notifier/email_expiring.txt rename to src/templates/base/notifier/email_expiring.txt diff --git a/src/templates/notifier/email_fulfilled.txt b/src/templates/base/notifier/email_fulfilled.txt similarity index 100% rename from src/templates/notifier/email_fulfilled.txt rename to src/templates/base/notifier/email_fulfilled.txt diff --git a/src/templates/notifier/end_booking.html b/src/templates/base/notifier/end_booking.html similarity index 100% rename from src/templates/notifier/end_booking.html rename to src/templates/base/notifier/end_booking.html diff --git a/src/templates/notifier/expiring_booking.html b/src/templates/base/notifier/expiring_booking.html similarity index 100% rename from src/templates/notifier/expiring_booking.html rename to src/templates/base/notifier/expiring_booking.html diff --git a/src/templates/notifier/inbox.html b/src/templates/base/notifier/inbox.html similarity index 100% rename from src/templates/notifier/inbox.html rename to src/templates/base/notifier/inbox.html diff --git a/src/templates/notifier/new_booking.html b/src/templates/base/notifier/new_booking.html similarity index 100% rename from src/templates/notifier/new_booking.html rename to src/templates/base/notifier/new_booking.html diff --git a/src/templates/notifier/notification.html b/src/templates/base/notifier/notification.html similarity index 100% rename from src/templates/notifier/notification.html rename to src/templates/base/notifier/notification.html diff --git a/src/templates/resource/hostprofile_detail.html b/src/templates/base/resource/hostprofile_detail.html similarity index 100% rename from src/templates/resource/hostprofile_detail.html rename to src/templates/base/resource/hostprofile_detail.html diff --git a/src/templates/resource/hosts.html b/src/templates/base/resource/hosts.html similarity index 100% rename from src/templates/resource/hosts.html rename to src/templates/base/resource/hosts.html diff --git a/src/templates/resource/mxClient.min.js b/src/templates/base/resource/mxClient.min.js similarity index 100% rename from src/templates/resource/mxClient.min.js rename to src/templates/base/resource/mxClient.min.js diff --git a/src/templates/resource/steps/define_hardware.html b/src/templates/base/resource/steps/define_hardware.html similarity index 100% rename from src/templates/resource/steps/define_hardware.html rename to src/templates/base/resource/steps/define_hardware.html diff --git a/src/templates/resource/steps/host_info.html b/src/templates/base/resource/steps/host_info.html similarity index 100% rename from src/templates/resource/steps/host_info.html rename to src/templates/base/resource/steps/host_info.html diff --git a/src/templates/resource/steps/meta_info.html b/src/templates/base/resource/steps/meta_info.html similarity index 100% rename from src/templates/resource/steps/meta_info.html rename to src/templates/base/resource/steps/meta_info.html diff --git a/src/templates/resource/steps/pod_definition.html b/src/templates/base/resource/steps/pod_definition.html similarity index 100% rename from src/templates/resource/steps/pod_definition.html rename to src/templates/base/resource/steps/pod_definition.html diff --git a/src/templates/resource/uncommon.css b/src/templates/base/resource/uncommon.css similarity index 100% rename from src/templates/resource/uncommon.css rename to src/templates/base/resource/uncommon.css diff --git a/src/templates/rest_framework/api.html b/src/templates/base/rest_framework/api.html similarity index 100% rename from src/templates/rest_framework/api.html rename to src/templates/base/rest_framework/api.html diff --git a/src/templates/snapshot_workflow/steps/meta.html b/src/templates/base/snapshot_workflow/steps/meta.html similarity index 100% rename from src/templates/snapshot_workflow/steps/meta.html rename to src/templates/base/snapshot_workflow/steps/meta.html diff --git a/src/templates/snapshot_workflow/steps/select_host.html b/src/templates/base/snapshot_workflow/steps/select_host.html similarity index 100% rename from src/templates/snapshot_workflow/steps/select_host.html rename to src/templates/base/snapshot_workflow/steps/select_host.html diff --git a/src/templates/workflow/confirm.html b/src/templates/base/workflow/confirm.html similarity index 100% rename from src/templates/workflow/confirm.html rename to src/templates/base/workflow/confirm.html diff --git a/src/templates/workflow/no_workflow.html b/src/templates/base/workflow/no_workflow.html similarity index 100% rename from src/templates/workflow/no_workflow.html rename to src/templates/base/workflow/no_workflow.html diff --git a/src/templates/workflow/viewport-base.html b/src/templates/base/workflow/viewport-base.html similarity index 100% rename from src/templates/workflow/viewport-base.html rename to src/templates/base/workflow/viewport-base.html diff --git a/src/templates/workflow/viewport-element.html b/src/templates/base/workflow/viewport-element.html similarity index 100% rename from src/templates/workflow/viewport-element.html rename to src/templates/base/workflow/viewport-element.html diff --git a/src/templates/laas/dashboard/landing.html b/src/templates/laas/dashboard/landing.html new file mode 100644 index 0000000..b1ac7c5 --- /dev/null +++ b/src/templates/laas/dashboard/landing.html @@ -0,0 +1,12 @@ +{% extends "base/dashboard/landing.html" %} + +{% block about_us %} +

The Lab as a Service (LaaS) project aims to help in the development and testing of LFN projects such as + OPNFV + by hosting hardware and providing access to the community. Currently, the only participating lab is the + University of New Hampshire Interoperability Lab (UNH-IOL).

+

To get started, you can request access to a server at the right. PTL's have the ability to design and + book a + whole block of servers with customized layer2 networks (e.g. a Pharos Pod). Read more here: LaaS Wiki

+{% endblock about_us %}