From 89c6368538db05c584916475b8b2f817a1e4fbb6 Mon Sep 17 00:00:00 2001 From: Toshaan Bharvani Date: Fri, 14 Apr 2023 17:57:29 +0200 Subject: [PATCH] add a cancelled membership field - allow membership to be cancelled and retain historical membership - do not display any cancelled members in the listing and single pages Signed-off-by: Toshaan Bharvani --- .../layouts/members/list.html | 37 ++++++++++++------- .../layouts/members/single.html | 13 +++++++ .../layouts/members/single.json | 3 ++ 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/themes/openpowerfoundation/layouts/members/list.html b/themes/openpowerfoundation/layouts/members/list.html index a56fa3d..5b56d47 100644 --- a/themes/openpowerfoundation/layouts/members/list.html +++ b/themes/openpowerfoundation/layouts/members/list.html @@ -1,6 +1,7 @@ {{ partial "header.html" . }} {{ partial "navbar.html" . }} {{ $i := 0 }} +{{ $now := now.Format "20060102" }}
@@ -24,20 +25,30 @@ {{ $level := .Param "level" }} {{ if eq $level $key }}
-
- - {{ if .Param "image" }} - {{ $imagename := .Param "image" }} - {{ $imagelocation := (printf "%s/%s" "images/members/" $imagename) }} - {{ $imageresource := resources.Get $imagelocation }} - {{ $image := $imageresource.Fit $imagesize }} - {{ .Title }} - - {{ else }} -

{{ .Title }}

+ {{ $memberstatus := true }} + {{ $cancelled := now.Format "20060102" }} + {{ if isset .Params "cancelled" }} + {{ $cancelled = time (.Param "cancelled") | dateFormat "20060102" }} + {{ if lt $cancelled $now }} + {{ $memberstatus = false }} {{ end }} - {{ $i = add $i 1 }} -
+ {{ end }} + {{ if eq $memberstatus true }} + + {{ end }}
{{ end }} {{ end }} diff --git a/themes/openpowerfoundation/layouts/members/single.html b/themes/openpowerfoundation/layouts/members/single.html index 222ee29..cbf025d 100644 --- a/themes/openpowerfoundation/layouts/members/single.html +++ b/themes/openpowerfoundation/layouts/members/single.html @@ -1,3 +1,14 @@ +{{ $now := now.Format "20060102" }} +{{ $memberstatus := true }} +{{ $cancelled := now.Format "20060102" }} +{{ if isset .Params "cancelled" }} + {{ $cancelled = time (.Param "cancelled") | dateFormat "20060102" }} + {{ if lt $cancelled $now }} + {{ $memberstatus = false }} + {{ end }} +{{ end }} +{{ if eq $memberstatus true }} + {{ partial "header.html" . }} {{ partial "navbar.html" . }}
@@ -69,3 +80,5 @@
{{ partial "footer.html" . }} + +{{ end }} diff --git a/themes/openpowerfoundation/layouts/members/single.json b/themes/openpowerfoundation/layouts/members/single.json index a29b897..bd3c2aa 100644 --- a/themes/openpowerfoundation/layouts/members/single.json +++ b/themes/openpowerfoundation/layouts/members/single.json @@ -3,6 +3,9 @@ "permalink": "{{ .RelPermalink }}", "level": "{{ .Params.level }}", "joined": "{{ .Params.joined }}", +{{ if isset .Params "cancelled" }} +"cancelled": "{{ time (.Param "cancelled") | dateFormat "20060102" }}", +{{ end }} "link": "{{ .Params.link }}", "content": "{{ .PlainWords }}" }