From 41da9b8627949d064c26f13540b0bf309417e4fa Mon Sep 17 00:00:00 2001 From: tt-gsa <139235281+tt-gsa@users.noreply.github.com> Date: Tue, 23 Jan 2024 10:37:40 -0500 Subject: [PATCH 1/8] VOTE-727: add retrieval of daily backups up to 15 days (#505) --- docs/devops.md | 4 +- ...ad_latest_backup.sh => download_backup.sh} | 56 +++++++++++-------- scripts/pipeline/scheduled_backup.sh | 20 +++++++ 3 files changed, 54 insertions(+), 26 deletions(-) rename scripts/{download_latest_backup.sh => download_backup.sh} (65%) diff --git a/docs/devops.md b/docs/devops.md index bc9ea1411..3c2c6a2a3 100644 --- a/docs/devops.md +++ b/docs/devops.md @@ -380,6 +380,6 @@ Launched by a `triggered pipeline` in CircleCI, this scripts gathers all S3 buck ### Miscellaneous Scripts -#### download_latest_backup.sh +#### download_backup.sh -Allows for easy downloading of the various backups available on the system. This includes the database backup, the Drupal user uploaded file content, and backups of the Terraform state. +Allows for easy downloading of the various backups available on the system. This includes the database backup, the Drupal user uploaded file content, and backups of the Terraform state. Help with usage is available when running the script without arguments. diff --git a/scripts/download_latest_backup.sh b/scripts/download_backup.sh similarity index 65% rename from scripts/download_latest_backup.sh rename to scripts/download_backup.sh index 321f0751b..f7d235227 100755 --- a/scripts/download_latest_backup.sh +++ b/scripts/download_backup.sh @@ -20,7 +20,7 @@ if [ "$(uname -s)" = "Darwin" ]; then exit 1 fi fi - + if ! hash cf 2>/dev/null ; then echo "Please install cf version 8: Linux: https://docs.cloudfoundry.org/cf-cli/install-go-cli.html @@ -39,45 +39,64 @@ elif [[ "$(cf --version)" != *"cf version 8."* ]]; then fi if ! hash jq 2>/dev/null ; then - echo "Please install jq: + echo "Please install jq: Linux: https://jqlang.github.io/jq/download/ Homebrew: brew install jq" exit 1 fi +# change which date command is used based on host OS +date_command='' + +if [ "$(uname -s)" == "Darwin" ]; then + date_command=gdate +else + date_command=date +fi + help(){ echo "Usage: $0 [options]" >&2 echo echo " -b The name of the S3 bucket with the backup." echo " -e Environment of backup to download." echo " -s Name of the space the backup bucket is in." + echo " -d Date to retrieve backup from. Acceptable values + are 'latest' or in 'YYYY-MM-DD' format and no + more than 15 days ago." } -while getopts 'b:e:s:' flag; do +RED='\033[0;31m' +NC='\033[0m' + +while getopts 'b:e:s:d:' flag; do case "${flag}" in - b) backup_bucket="${OPTARG}" ;; - e) env="${OPTARG}" ;; - s) space=(${OPTARG}) ;; + b) backup_bucket=${OPTARG} ;; + e) env=${OPTARG} ;; + s) space=${OPTARG} ;; + d) retrieve_date=${OPTARG} + [[ $retrieve_date = "latest" || $(${date_command} --date "$retrieve_date" +%s) -ge $(${date_command} --date "15 days ago" +%s) ]] || help && echo -e "\n${RED}Error: Not acceptable -d option.${NC}" && exit 1 + ;; *) help && exit 1 ;; esac done -[[ -z "${backup_bucket}" ]] && help && echo "Missing -b flag." && exit 1 -[[ -z "${env}" ]] && help && echo "Missing -e flag." && exit 1 -[[ -z "${space}" ]] && help && echo "Missing -s flag." && exit 1 +[[ -z "${backup_bucket}" ]] && help && echo -e "\n${RED}Error: Missing -b flag.${NC}" && exit 1 +[[ -z "${env}" ]] && help && echo -e "\n${RED}Error: Missing -e flag.${NC}" && exit 1 +[[ -z "${space}" ]] && help && echo -e "\n${RED}Error: Missing -s flag.${NC}" && exit 1 +[[ -z "${retrieve_date}" ]] && help && echo -e "\n${RED}Error: Missing -d flag.${NC}" && exit 1 echo "Getting backup bucket credentials..." { cf target -s "${space}" - + export service="${backup_bucket}" export service_key="${service}-key" cf delete-service-key "${service}" "${service_key}" -f cf create-service-key "${service}" "${service_key}" sleep 2 export s3_credentials=$(cf service-key "${service}" "${service_key}" | tail -n +2) - + export AWS_ACCESS_KEY_ID=$(echo "${s3_credentials}" | jq -r '.credentials.access_key_id') export bucket=$(echo "${s3_credentials}" | jq -r '.credentials.bucket') export AWS_DEFAULT_REGION=$(echo "${s3_credentials}" | jq -r '.credentials.region') @@ -88,20 +107,9 @@ echo "Getting backup bucket credentials..." echo "Downloading backup..." { - rm -f latest_*.tar.gz - - aws s3 cp s3://${bucket}/${env}/latest.tar.gz . --no-verify-ssl #2>/dev/null - - if [ "$(uname -s)" == "Darwin" ]; then - timestamp=$(gdate -d "$(gstat -c '%w' latest.tar.gz)" +'%Y.%m.%d') - else - timestamp=$(date -d "$(stat -c '%w' latest.tar.gz)" +'%Y.%m.%d') - fi - - mv latest.tar.gz latest_${timestamp}.tar.gz - + aws s3 cp s3://${bucket}/${env}/${retrieve_date}.tar.gz . --no-verify-ssl 2>/dev/null cf delete-service-key "${service}" "${service_key}" -f } >/dev/null 2>&1 -echo "File saved: latest_${timestamp}.tar.gz" +echo "File saved: ${retrieve_date}.tar.gz" diff --git a/scripts/pipeline/scheduled_backup.sh b/scripts/pipeline/scheduled_backup.sh index e9fb99514..6947946df 100755 --- a/scripts/pipeline/scheduled_backup.sh +++ b/scripts/pipeline/scheduled_backup.sh @@ -6,6 +6,7 @@ export BACKUP_ENV=${CIRCLE_BRANCH} export backup_folder=$(date "+%Y/%m/%d") export now=$(date +"%H.%M.%S") +export today=$(date +%F) backup_media="cms/public/media" @@ -113,9 +114,28 @@ echo "Saving to backup bucket..." aws s3 cp ./ s3://${bucket}/${BACKUP_ENV}/${backup_folder} --exclude "*" --include "*.sql.gz" --include "*.tar.gz" --recursive --no-verify-ssl 2>/dev/null tar czf latest.tar.gz *.gz + cp latest.tar.gz ${today}.tar.gz + # delete latest and backups older than 15 days in the env's top level directory aws s3 rm s3://${bucket}/${BACKUP_ENV}/latest.tar.gz --no-verify-ssl 2>/dev/null + aws s3 ls s3://${bucket}/${BACKUP_ENV}/ | while read -r line; + do + create_date=$(echo $line | awk {'print $1" "$2'}) + create_date=$(date --date "$create_date" +%s) + older_than=$(date --date "16 days ago" +%s) + if [[ $create_date -lt $older_than ]] + then + filename=$(echo $line | awk {'print $4'}) + + if [[ $filename != "" ]] + then + aws s3 rm s3://${bucket}/${BACKUP_ENV}/$filename --no-verify-ssl 2>/dev/null + fi + fi + done; + aws s3 cp ./latest.tar.gz s3://${bucket}/${BACKUP_ENV}/ --no-verify-ssl 2>/dev/null + aws s3 cp ./${today}.tar.gz s3://${bucket}/${BACKUP_ENV}/ --no-verify-ssl 2>/dev/null cf delete-service-key "${service}" "${service_key}" -f } >/dev/null 2>&1 From ae879479366f43ff619648d0921fa9aa574a07df Mon Sep 17 00:00:00 2001 From: Ray Estrada Date: Mon, 22 Jan 2024 10:10:44 -0800 Subject: [PATCH 2/8] VOTE-755 update content manager permissions to include access to adminstrative pages and new taxonomy vocab --- config/sync/user.role.content_manager.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/sync/user.role.content_manager.yml b/config/sync/user.role.content_manager.yml index f58033047..4f85d28e5 100644 --- a/config/sync/user.role.content_manager.yml +++ b/config/sync/user.role.content_manager.yml @@ -21,6 +21,7 @@ dependencies: - node.type.page - node.type.state_territory - node.type.voter_guide + - taxonomy.vocabulary.basics_modules - taxonomy.vocabulary.nvrf_field - workflows.workflow.publishing_content module: @@ -41,6 +42,7 @@ label: 'Content Manager' weight: 3 is_admin: null permissions: + - 'access administration pages' - 'access block library' - 'access content overview' - 'access files overview' @@ -62,6 +64,7 @@ permissions: - 'create remote_video media' - 'create sitewide_alert block content' - 'create state_territory content' + - 'create terms in basics_modules' - 'create terms in nvrf_field' - 'create voter_guide content' - 'delete all revisions' @@ -93,6 +96,7 @@ permissions: - 'delete own voter_guide content' - 'delete page revisions' - 'delete state_territory revisions' + - 'delete terms in basics_modules' - 'delete terms in nvrf_field' - 'delete voter_guide revisions' - 'edit any audio media' @@ -122,6 +126,7 @@ permissions: - 'edit own remote_video media' - 'edit own state_territory content' - 'edit own voter_guide content' + - 'edit terms in basics_modules' - 'edit terms in nvrf_field' - 'mark as hidden in editoria11y' - 'revert all revisions' From 119701bec1d5111abae7fadc69c21d297943e0a7 Mon Sep 17 00:00:00 2001 From: SamiraMSadat <108487505+SamiraMSadat@users.noreply.github.com> Date: Fri, 26 Jan 2024 11:36:38 -0700 Subject: [PATCH 3/8] VOTE-422 style state detail page (#509) --- .../votegov/src/sass/_uswds-settings.scss | 6 +++- .../votegov/src/sass/base/typography.scss | 4 +++ .../votegov/src/sass/components/_index.scss | 3 ++ .../votegov/src/sass/components/block.scss | 7 +++++ .../votegov/src/sass/components/date.scss | 6 ++++ .../votegov/src/sass/components/field.scss | 13 ++++++++ .../custom/votegov/src/sass/node/_index.scss | 10 ------- .../src/sass/uswds-overrides/_index.scss | 2 ++ .../src/sass/uswds-overrides/usa-button.scss | 6 ++++ .../src/sass/uswds-overrides/usa-form.scss | 4 +++ .../src/sass/uswds-overrides/usa-select.scss | 7 +++++ ...tent--registration-form-selector.html.twig | 30 +++++++++---------- .../registration-date--by-mail.html.twig | 2 +- .../registration-date--in-person.html.twig | 2 +- .../registration-date--online.html.twig | 2 +- ...nt--field-registration-form-link.html.twig | 2 +- .../node/node--state-territory.html.twig | 5 ++-- 17 files changed, 78 insertions(+), 33 deletions(-) create mode 100644 web/themes/custom/votegov/src/sass/components/block.scss create mode 100644 web/themes/custom/votegov/src/sass/components/date.scss create mode 100644 web/themes/custom/votegov/src/sass/components/field.scss create mode 100644 web/themes/custom/votegov/src/sass/uswds-overrides/usa-button.scss create mode 100644 web/themes/custom/votegov/src/sass/uswds-overrides/usa-select.scss diff --git a/web/themes/custom/votegov/src/sass/_uswds-settings.scss b/web/themes/custom/votegov/src/sass/_uswds-settings.scss index 16f0f63df..a21b1ebcf 100644 --- a/web/themes/custom/votegov/src/sass/_uswds-settings.scss +++ b/web/themes/custom/votegov/src/sass/_uswds-settings.scss @@ -173,7 +173,11 @@ https://designsystem.digital.gov/documentation/settings/ $theme-lead-line-height: 5, $theme-lead-font-size: 8, $theme-font-weight-medium: 500, - $theme-font-weight-bold: 500, + //$theme-font-weight-bold: 500, + $theme-body-font-family: "sans", + $theme-body-line-height: 4, + $theme-body-font-size: 5, + $theme-style-body-element: "true", // https://designsystem.digital.gov/design-tokens/typesetting/font-size/ $theme-h1-font-size: 15, diff --git a/web/themes/custom/votegov/src/sass/base/typography.scss b/web/themes/custom/votegov/src/sass/base/typography.scss index 6cfda5719..88eb754ba 100644 --- a/web/themes/custom/votegov/src/sass/base/typography.scss +++ b/web/themes/custom/votegov/src/sass/base/typography.scss @@ -83,3 +83,7 @@ hr { @include u-margin-y(3); border-bottom: 1px solid #D3D3D3; } + +main { + @include u-font-family('serif'); +} diff --git a/web/themes/custom/votegov/src/sass/components/_index.scss b/web/themes/custom/votegov/src/sass/components/_index.scss index ce7ebce78..e4e1e0d73 100644 --- a/web/themes/custom/votegov/src/sass/components/_index.scss +++ b/web/themes/custom/votegov/src/sass/components/_index.scss @@ -2,4 +2,7 @@ @forward "page-title"; @forward "page-content"; @forward "sidebar"; +@forward "date"; +@forward "block"; +@forward "field"; diff --git a/web/themes/custom/votegov/src/sass/components/block.scss b/web/themes/custom/votegov/src/sass/components/block.scss new file mode 100644 index 000000000..3e31a54b6 --- /dev/null +++ b/web/themes/custom/votegov/src/sass/components/block.scss @@ -0,0 +1,7 @@ +@use "uswds-core" as *; + +.block--content-section { + * + & { + @include u-margin-top(5); + } +} diff --git a/web/themes/custom/votegov/src/sass/components/date.scss b/web/themes/custom/votegov/src/sass/components/date.scss new file mode 100644 index 000000000..298ce6284 --- /dev/null +++ b/web/themes/custom/votegov/src/sass/components/date.scss @@ -0,0 +1,6 @@ +@use "uswds-core" as *; + +.date--updated { + @include u-margin-top(4); + @include u-font-family('ui'); +} diff --git a/web/themes/custom/votegov/src/sass/components/field.scss b/web/themes/custom/votegov/src/sass/components/field.scss new file mode 100644 index 000000000..f7666d716 --- /dev/null +++ b/web/themes/custom/votegov/src/sass/components/field.scss @@ -0,0 +1,13 @@ +@use "uswds-core" as *; + +.field { + * + & { + @include u-margin-top(3); + } +} + +.field--name-field-body { + .node--view-mode-full & { + @include u-maxw('tablet'); + } +} diff --git a/web/themes/custom/votegov/src/sass/node/_index.scss b/web/themes/custom/votegov/src/sass/node/_index.scss index 65a2bf5c9..aef1f5e34 100644 --- a/web/themes/custom/votegov/src/sass/node/_index.scss +++ b/web/themes/custom/votegov/src/sass/node/_index.scss @@ -1,11 +1 @@ @use "uswds-core" as *; - -.node--view-mode-full { - > .field + .field { - @include u-margin-top(5); - } - - .field--name-field-body { - @include u-maxw('tablet'); - } -} diff --git a/web/themes/custom/votegov/src/sass/uswds-overrides/_index.scss b/web/themes/custom/votegov/src/sass/uswds-overrides/_index.scss index f8e7f070b..a989ad3af 100644 --- a/web/themes/custom/votegov/src/sass/uswds-overrides/_index.scss +++ b/web/themes/custom/votegov/src/sass/uswds-overrides/_index.scss @@ -3,3 +3,5 @@ @forward "usa-form"; @forward "usa-legend"; @forward "usa-label"; +@forward "usa-button"; +@forward "usa-select"; diff --git a/web/themes/custom/votegov/src/sass/uswds-overrides/usa-button.scss b/web/themes/custom/votegov/src/sass/uswds-overrides/usa-button.scss new file mode 100644 index 000000000..7686fef2c --- /dev/null +++ b/web/themes/custom/votegov/src/sass/uswds-overrides/usa-button.scss @@ -0,0 +1,6 @@ +@use "uswds-core" as *; + +// Custom usa-button overrides using USWDS mixins and other settings. +.usa-button { + padding: 0.9rem 1.4rem; +} diff --git a/web/themes/custom/votegov/src/sass/uswds-overrides/usa-form.scss b/web/themes/custom/votegov/src/sass/uswds-overrides/usa-form.scss index 94f98c92a..e7e4aaf12 100644 --- a/web/themes/custom/votegov/src/sass/uswds-overrides/usa-form.scss +++ b/web/themes/custom/votegov/src/sass/uswds-overrides/usa-form.scss @@ -2,4 +2,8 @@ .usa-form { @include u-maxw('tablet'); + + main & { + @include u-font-family('serif'); + } } diff --git a/web/themes/custom/votegov/src/sass/uswds-overrides/usa-select.scss b/web/themes/custom/votegov/src/sass/uswds-overrides/usa-select.scss new file mode 100644 index 000000000..645f9f766 --- /dev/null +++ b/web/themes/custom/votegov/src/sass/uswds-overrides/usa-select.scss @@ -0,0 +1,7 @@ +@use "uswds-core" as *; + +// Custom usa-button overrides using USWDS mixins and other settings. +.usa-select--maxw, +.usa-form .usa-select--maxw { + @include u-maxw('mobile'); +} diff --git a/web/themes/custom/votegov/templates/block/block-content--registration-form-selector.html.twig b/web/themes/custom/votegov/templates/block/block-content--registration-form-selector.html.twig index 2dbf49f14..7b2a73854 100755 --- a/web/themes/custom/votegov/templates/block/block-content--registration-form-selector.html.twig +++ b/web/themes/custom/votegov/templates/block/block-content--registration-form-selector.html.twig @@ -8,28 +8,26 @@ * @ingroup themeable */ #} -{% - set classes = [ - 'block-content', - 'block-content--type-' ~ bundle|clean_class, - 'block-content--' ~ id, - 'block-content--view-mode-' ~ view_mode|clean_class - ] +{% set classes = [ + 'block--content-section', + 'block-content', + 'block-content--type-' ~ bundle|clean_class, + 'block-content--' ~ id, + 'block-content--view-mode-' ~ view_mode|clean_class +] %} {{ attach_library('votegov/nvrf_pdf_download') }} - {{ title_prefix }} - {{ title_suffix }} -
-
-

{{ content.field_heading | field_value | render | replace({"@state_name": currentnode.getTitle()}) | raw }}

-

{{ content.field_description }}

+

{{ content.field_heading | field_value | render | replace({"@state_name": currentnode.getTitle()}) | raw }}

+ +

{{ content.field_description | field_value }}

+
{# NVRF language selector #} {{ content.field_registration_form_link }} {# Download button #} - - -
+
+ + diff --git a/web/themes/custom/votegov/templates/component/registration-date/registration-date--by-mail.html.twig b/web/themes/custom/votegov/templates/component/registration-date/registration-date--by-mail.html.twig index e4491ff9a..3f4b3d93d 100644 --- a/web/themes/custom/votegov/templates/component/registration-date/registration-date--by-mail.html.twig +++ b/web/themes/custom/votegov/templates/component/registration-date/registration-date--by-mail.html.twig @@ -24,7 +24,7 @@ {% set deadline = postmarked_deadline | default(received_deadline) %} {% if deadline %} -
  • {{ 'Register by mail deadline:' | t }} {{ deadline }}
  • +
  • {{ 'Register by mail deadline:' | t }} {{ deadline }}
  • {% endif %} {# JSON Schema #} diff --git a/web/themes/custom/votegov/templates/component/registration-date/registration-date--in-person.html.twig b/web/themes/custom/votegov/templates/component/registration-date/registration-date--in-person.html.twig index af39d37f9..13da10549 100644 --- a/web/themes/custom/votegov/templates/component/registration-date/registration-date--in-person.html.twig +++ b/web/themes/custom/votegov/templates/component/registration-date/registration-date--in-person.html.twig @@ -8,7 +8,7 @@ {% set deadline = content.field_in_person_deadline | field_value | default(content.field_g_in_person_deadline | field_value) %} {% if deadline %} -
  • {{ 'In person registration deadline:' | t }} {{ deadline }}
  • +
  • {{ 'In person registration deadline:' | t }} {{ deadline }}
  • {% endif %}