diff --git a/client/src/app/chapters/page-client.tsx b/client/src/app/chapters/page-client.tsx index 1533be1..1358d78 100644 --- a/client/src/app/chapters/page-client.tsx +++ b/client/src/app/chapters/page-client.tsx @@ -1,16 +1,52 @@ "use client"; +import Link from "next/link"; +import { useRouter, useSearchParams } from "next/navigation"; +import { useEffect, useState } from "react"; + import ChapterCard from "@/components/chapter-card"; import { useChapters } from "@/hooks/useChapters"; export default function ChaptersClient() { - const { data: chapters = [], isLoading, isError, error } = useChapters(); + const [page, setPage] = useState(1); + + const router = useRouter(); + const params = useSearchParams(); + + useEffect(() => { + router.push(`/chapters?page=${page}`); + }, [page]); + + // effectively normalise page param to a valid number + useEffect(() => { + const pageAsNum = Number(params.get("page")); + if (pageAsNum !== null && !isNaN(pageAsNum) && pageAsNum !== 0) { + setPage(pageAsNum); + } else { + // redirect to first page + setPage(1); + } + }, [params.get("page")]); + + const pageSize = 15; + + const { + data: response, + isLoading, + isError, + error, + } = useChapters(page, pageSize); if (isLoading) { return

Loading all Chapters...

; } if (isError) { + if (error.status === 404) { + // redirect to first page + setPage(1); + return; + } console.log(error); return ( @@ -21,47 +57,101 @@ export default function ChaptersClient() { ); } + const chapters = response?.results; + + if (!chapters) { + return ( +

+ Error loading chapters. If refreshing doesn't work, please contact an + administrator. +

+ ); + } + + const pageCount = Math.ceil(response.count / pageSize); + + const pageButton = (pageNum: number) => ( + + {pageNum} + + ); + return chapters?.length > 0 ? ( -
- {chapters.map((chapter) => { - console.log(chapter.logo); - if (!chapter.logo) { - // Initials for the logo placeholder - const initials = chapter.name - .split(" ") - .map((word) => word[0]) - .slice(0, 2) - .join("") - .toUpperCase(); - - return ( - (location.href = `/chapters/${chapter.id}`)} - /> - ); - } else { - return ( - (location.href = `/chapters/${chapter.id}`)} - /> - ); - } - })} -
+ <> +
+ {chapters.map((chapter) => { + if (!chapter.logo) { + // Initials for the logo placeholder + const initials = chapter.name + .split(" ") + .map((word) => word[0]) + .slice(0, 2) + .join("") + .toUpperCase(); + + return ( + (location.href = `/chapters/${chapter.id}`)} + /> + ); + } else { + return ( + (location.href = `/chapters/${chapter.id}`)} + /> + ); + } + })} +
+
+ {pageCount === 1 ? ( + <> + ) : pageCount === 2 ? ( + <> + {pageButton(1)} + {pageButton(2)} + + ) : pageCount < 4 ? ( + //render all pages if less than 5 + [ + ...Array(pageCount) + .keys() + .map((key) => key + 1), + ].map((pageNum) =>
{pageButton(pageNum)}
) + ) : ( + // dynamic page button generation + // always includes pages 1 and pageCount and removes/adds buttons to only include those adjacent to the current page + [ + 1, + page - 1 > 1 ? page - 1 : -1, + page === 1 || page === pageCount ? -1 : page, + page + 1 < pageCount ? page + 1 : -1, + pageCount, + ].map((pageNum) => { + if (pageNum !== -1) { + return
{pageButton(pageNum)}
; + } + }) + )} +
+ ) : (

No Chapters available for viewing.

); diff --git a/client/src/app/chapters/page.tsx b/client/src/app/chapters/page.tsx index 5017baa..b14a0fe 100644 --- a/client/src/app/chapters/page.tsx +++ b/client/src/app/chapters/page.tsx @@ -17,10 +17,7 @@ export default function ChaptersPage() { Chapters & Field Alliances - - {/* TEMP TEST BLOCK CARD COMPONENT */} - {/* END TEMP TEST BLOCK */} ); } diff --git a/client/src/app/events/events-client.tsx b/client/src/app/events/events-client.tsx index 02da9ff..14f74a4 100644 --- a/client/src/app/events/events-client.tsx +++ b/client/src/app/events/events-client.tsx @@ -1,16 +1,52 @@ "use client"; +import Link from "next/link"; +import { useRouter, useSearchParams } from "next/navigation"; +import { useEffect, useState } from "react"; + import EventCard from "@/components/event-card"; import { useEvents } from "@/hooks/useEvents"; export default function EventsClient() { - const { data: events = [], isLoading, isError, error } = useEvents(); + const [page, setPage] = useState(1); + + const router = useRouter(); + const params = useSearchParams(); + + useEffect(() => { + router.push(`/events?page=${page}`); + }, [page]); + + // effectively normalise page param to a valid number + useEffect(() => { + const pageAsNum = Number(params.get("page")); + if (pageAsNum !== null && !isNaN(pageAsNum) && pageAsNum !== 0) { + setPage(pageAsNum); + } else { + // redirect to first page + setPage(1); + } + }, [params.get("page")]); + + const pageSize = 20; + + const { + data: response, + isLoading, + isError, + error, + } = useEvents(page, pageSize); if (isLoading) { return

Loading all Events...

; } if (isError) { + if (error.status === 404) { + // redirect to first page + setPage(1); + return; + } console.log(error); return (

@@ -20,26 +56,80 @@ export default function EventsClient() { ); } + const events = response?.results; + + if (!events) { + return ( +

+ Error loading events. If refreshing doesn't work, please contact an + administrator. +

+ ); + } + + const pageCount = Math.ceil(response.count / pageSize); + + const pageButton = (pageNum: number) => ( + + {pageNum} + + ); return ( -
- {events.length ? ( - events.map((event) => ( - - )) - ) : ( -

No Events currently listed.

- )} -
+ <> +
+ {events.length ? ( + events.map((event) => ( + + )) + ) : ( +

No Events currently listed.

+ )} +
+
+ {pageCount === 1 ? ( + <> + ) : pageCount === 2 ? ( + <> + {pageButton(1)} + {pageButton(2)} + + ) : pageCount < 4 ? ( + //render all pages if less than 5 + [ + ...Array(pageCount) + .keys() + .map((key) => key + 1), + ].map((pageNum) =>
{pageButton(pageNum)}
) + ) : ( + // dynamic page button generation + // always includes pages 1 and pageCount and removes/adds buttons to only include those adjacent to the current page + [ + 1, + page - 1 > 1 ? page - 1 : -1, + page === 1 || page === pageCount ? -1 : page, + page + 1 < pageCount ? page + 1 : -1, + pageCount, + ].map((pageNum) => { + if (pageNum !== -1) { + return
{pageButton(pageNum)}
; + } + }) + )} +
+ ); } diff --git a/client/src/components/event-card.tsx b/client/src/components/event-card.tsx index 094ac26..fab8884 100644 --- a/client/src/components/event-card.tsx +++ b/client/src/components/event-card.tsx @@ -20,7 +20,7 @@ export default function EventCard({ link, }: ApiEventList) { return ( - +
diff --git a/client/src/hooks/useChapters.ts b/client/src/hooks/useChapters.ts index 008dec8..ee84152 100644 --- a/client/src/hooks/useChapters.ts +++ b/client/src/hooks/useChapters.ts @@ -3,6 +3,13 @@ import { AxiosError } from "axios"; import api from "@/lib/api"; +type PaginatedResponse = { + count: number; + next: string | null; + previous: string | null; + results: T[]; +}; + export type ApiChapterList = { id: number; name: string; @@ -13,17 +20,18 @@ export type ApiChapterList = { colour: string; }; -export const useChapters = ( - args?: Omit< - UseQueryOptions, - "queryKey" | "queryFn" - >, -) => { - return useQuery({ - ...args, - queryKey: ["chapters"], +export const useChapters = (page: number = 1, pageSize: number) => { + return useQuery, AxiosError>({ + queryKey: ["chapters", page, pageSize], queryFn: () => - api.get("/chapters/").then((res) => res.data), + api + .get>("/chapters/", { + params: { + page, + pageSize, + }, + }) + .then((res) => res.data), retry: (failureCount, error) => { if (error?.response?.status === 404) { return false; diff --git a/client/src/hooks/useEvents.ts b/client/src/hooks/useEvents.ts index 4b00553..4e56ce9 100644 --- a/client/src/hooks/useEvents.ts +++ b/client/src/hooks/useEvents.ts @@ -3,6 +3,13 @@ import { AxiosError } from "axios"; import api from "@/lib/api"; +type PaginatedResponse = { + count: number; + next: string | null; + previous: string | null; + results: T[]; +}; + export type ApiEventList = { id: number; title: string; @@ -15,16 +22,18 @@ export type ApiEventList = { link: string | null; }; -export const useEvents = ( - args?: Omit< - UseQueryOptions, - "queryKey" | "queryFn" - >, -) => { - return useQuery({ - ...args, - queryKey: ["events"], - queryFn: () => api.get("/events/").then((res) => res.data), +export const useEvents = (page: number = 1, pageSize: number) => { + return useQuery, AxiosError>({ + queryKey: ["events", page, pageSize], + queryFn: () => + api + .get>("/events/", { + params: { + page, + pageSize, + }, + }) + .then((res) => res.data), retry: (failureCount, error) => { if (error?.response?.status === 404) { return false; diff --git a/server/agronomy_club/fixtures/chapters.json b/server/agronomy_club/fixtures/chapters.json new file mode 100644 index 0000000..47efee4 --- /dev/null +++ b/server/agronomy_club/fixtures/chapters.json @@ -0,0 +1,652 @@ +[ + { + "model": "agronomy_club.chapter", + "pk": 1, + "fields": { + "name": "Wheatbelt Chapter", + "abbrev": "WHEAT", + "logo": "", + "location": "Perth, WA", + "desc": "The founding chapter, supporting grain growers and students across the WA wheatbelt.", + "email": "wheatbelt@agronomyclub.org", + "colour": "#e63946" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 2, + "fields": { + "name": "Riverina Chapter", + "abbrev": "RVRNA", + "logo": "", + "location": "Wagga Wagga, NSW", + "desc": "Serving irrigated cropping and viticulture students throughout the Riverina region.", + "email": "riverina@agronomyclub.org", + "colour": "#457b9d" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 3, + "fields": { + "name": "Mallee Chapter", + "abbrev": "MALLEE", + "logo": "", + "location": "Bendigo, VIC", + "desc": "A growing chapter focused on dryland farming systems and soil health research.", + "email": "mallee@agronomyclub.org", + "colour": "#2a9d8f" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 4, + "fields": { + "name": "Darling Downs Chapter", + "abbrev": "DDOWNS", + "logo": "", + "location": "Toowoomba, QLD", + "desc": "Connecting students across Queensland's premier grain and cotton growing region.", + "email": "darlingdowns@agronomyclub.org", + "colour": "#f4a261" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 5, + "fields": { + "name": "Barossa Chapter", + "abbrev": "BAROSA", + "logo": "", + "location": "Adelaide, SA", + "desc": "The newest chapter, bringing fresh energy to viticulture and horticulture studies in SA.", + "email": "barossa@agronomyclub.org", + "colour": "#6d597a" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 6, + "fields": { + "name": "Tasman Chapter", + "abbrev": "TASMAN", + "logo": "", + "location": "Launceston, TAS", + "desc": "Focused on pasture management and cool-climate cropping across northern Tasmania.", + "email": "tasman@agronomyclub.org", + "colour": "#f4d35e" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 7, + "fields": { + "name": "Top End Chapter", + "abbrev": "TOPEND", + "logo": "", + "location": "Darwin, NT", + "desc": "Supporting tropical agronomy research and mango, sorghum, and hay production studies.", + "email": "topend@agronomyclub.org", + "colour": "#3a5a40" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 8, + "fields": { + "name": "Liverpool Plains Chapter", + "abbrev": "LPLAIN", + "logo": "", + "location": "Tamworth, NSW", + "desc": "Dedicated to black soil cropping systems, cotton, and precision agriculture research.", + "email": "liverpoolplains@agronomyclub.org", + "colour": "#bc6c25" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 9, + "fields": { + "name": "Gippsland Chapter", + "abbrev": "GIPPS", + "logo": "", + "location": "Traralgon, VIC", + "desc": "Focused on dairy pasture agronomy and sustainable grazing systems in eastern Victoria.", + "email": "gippsland@agronomyclub.org", + "colour": "#7b2cbf" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 10, + "fields": { + "name": "Ord Valley Chapter", + "abbrev": "ORDVAL", + "logo": "", + "location": "Kununurra, WA", + "desc": "Exploring irrigated tropical cropping, chia, and sandalwood production in the Ord Valley.", + "email": "ordvalley@agronomyclub.org", + "colour": "#ff8fab" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 11, + "fields": { + "name": "Fleurieu Chapter", + "abbrev": "FLEUR", + "logo": "", + "location": "McLaren Vale, SA", + "desc": "Specialising in viticulture agronomy and coastal horticulture on the Fleurieu Peninsula.", + "email": "fleurieu@agronomyclub.org", + "colour": "#d62828" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 12, + "fields": { + "name": "Central West Chapter", + "abbrev": "CENWEST", + "logo": "", + "location": "Orange, NSW", + "desc": "Bringing together students studying orchard management and mixed cropping systems.", + "email": "centralwest@agronomyclub.org", + "colour": "#003049" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 13, + "fields": { + "name": "Atherton Tablelands Chapter", + "abbrev": "ATHERTN", + "logo": "", + "location": "Atherton, QLD", + "desc": "Researching tropical dairy pastures, coffee, and avocado agronomy on the Tablelands.", + "email": "athertontablelands@agronomyclub.org", + "colour": "#f77f00" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 14, + "fields": { + "name": "South West Chapter", + "abbrev": "SWEST", + "logo": "", + "location": "Bunbury, WA", + "desc": "Covering dairy pasture systems and viticulture agronomy in WA's South West region.", + "email": "southwest@agronomyclub.org", + "colour": "#fcbf49" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 15, + "fields": { + "name": "Wimmera Chapter", + "abbrev": "WIMMERA", + "logo": "", + "location": "Horsham, VIC", + "desc": "A chapter dedicated to broadacre grain research and dryland cropping trials.", + "email": "wimmera@agronomyclub.org", + "colour": "#eae2b7" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 16, + "fields": { + "name": "Hunter Valley Chapter", + "abbrev": "HUNTER", + "logo": "", + "location": "Cessnock, NSW", + "desc": "Focused on viticulture agronomy, soil science, and vineyard sustainability practices.", + "email": "huntervalley@agronomyclub.org", + "colour": "#06d6a0" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 17, + "fields": { + "name": "Fitzroy Chapter", + "abbrev": "FITZROY", + "logo": "", + "location": "Rockhampton, QLD", + "desc": "Supporting beef cattle pasture agronomy and sorghum research in Central Queensland.", + "email": "fitzroy@agronomyclub.org", + "colour": "#118ab2" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 18, + "fields": { + "name": "Clare Valley Chapter", + "abbrev": "CLARE", + "logo": "", + "location": "Clare, SA", + "desc": "Investigating cool-climate viticulture and Mediterranean cropping systems.", + "email": "clarevalley@agronomyclub.org", + "colour": "#ef476f" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 19, + "fields": { + "name": "Huon Valley Chapter", + "abbrev": "HUON", + "logo": "", + "location": "Huonville, TAS", + "desc": "Dedicated to apple orchard agronomy and cool-climate horticulture research.", + "email": "huonvalley@agronomyclub.org", + "colour": "#073b4c" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 20, + "fields": { + "name": "Kimberley Chapter", + "abbrev": "KIMBRLY", + "logo": "", + "location": "Broome, WA", + "desc": "Exploring pastoral rangeland management and cattle station agronomy in the Kimberley.", + "email": "kimberley@agronomyclub.org", + "colour": "#ffd166" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 21, + "fields": { + "name": "Goulburn Valley Chapter", + "abbrev": "GOULBRN", + "logo": "", + "location": "Shepparton, VIC", + "desc": "Focused on stone fruit orchards, dairy pastures, and irrigation agronomy.", + "email": "goulburnvalley@agronomyclub.org", + "colour": "#8338ec" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 22, + "fields": { + "name": "New England Chapter", + "abbrev": "NEWENG", + "logo": "", + "location": "Armidale, NSW", + "desc": "Supporting wool production, pasture improvement, and high-altitude cropping research.", + "email": "newengland@agronomyclub.org", + "colour": "#3a86ff" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 23, + "fields": { + "name": "Eyre Peninsula Chapter", + "abbrev": "EYRE", + "logo": "", + "location": "Port Lincoln, SA", + "desc": "Researching low-rainfall grain cropping and coastal soil conservation techniques.", + "email": "eyrepeninsula@agronomyclub.org", + "colour": "#fb5607" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 24, + "fields": { + "name": "Capricorn Coast Chapter", + "abbrev": "CAPRICN", + "logo": "", + "location": "Yeppoon, QLD", + "desc": "Specialising in macadamia orchards and subtropical horticultural agronomy.", + "email": "capricorncoast@agronomyclub.org", + "colour": "#ff006e" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 25, + "fields": { + "name": "Margaret River Chapter", + "abbrev": "MARGRVR", + "logo": "", + "location": "Margaret River, WA", + "desc": "Focused on premium viticulture and vineyard soil management studies.", + "email": "margaretriver@agronomyclub.org", + "colour": "#06a77d" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 26, + "fields": { + "name": "Snowy Mountains Chapter", + "abbrev": "SNOWY", + "logo": "", + "location": "Cooma, NSW", + "desc": "Covering alpine grazing systems and cold-tolerant pasture species research.", + "email": "snowymountains@agronomyclub.org", + "colour": "#d90429" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 27, + "fields": { + "name": "Sunraysia Chapter", + "abbrev": "SUNRAY", + "logo": "", + "location": "Mildura, VIC", + "desc": "Dedicated to citrus and table grape agronomy along the Murray River irrigation belt.", + "email": "sunraysia@agronomyclub.org", + "colour": "#4361ee" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 28, + "fields": { + "name": "Burnett Chapter", + "abbrev": "BURNETT", + "logo": "", + "location": "Bundaberg, QLD", + "desc": "Focused on sugarcane agronomy and irrigated horticulture in the Burnett region.", + "email": "burnett@agronomyclub.org", + "colour": "#4cc9f0" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 29, + "fields": { + "name": "Derwent Valley Chapter", + "abbrev": "DERWENT", + "logo": "", + "location": "New Norfolk, TAS", + "desc": "Researching hop cultivation agronomy and cool-climate specialty crops.", + "email": "derwentvalley@agronomyclub.org", + "colour": "#b5179e" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 30, + "fields": { + "name": "Pilbara Chapter", + "abbrev": "PILBARA", + "logo": "", + "location": "Karratha, WA", + "desc": "Exploring arid-zone pastoral agronomy and rangeland rehabilitation studies.", + "email": "pilbara@agronomyclub.org", + "colour": "#52b788" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 31, + "fields": { + "name": "Riverland Chapter", + "abbrev": "REVLAND", + "logo": "", + "location": "Renmark, SA", + "desc": "Focused on citrus and almond orchard agronomy along the Murray River irrigation area.", + "email": "riverland@agronomyclub.org", + "colour": "#ffbe0b" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 32, + "fields": { + "name": "Lockyer Valley Chapter", + "abbrev": "LOCKYER", + "logo": "", + "location": "Gatton, QLD", + "desc": "Specialising in vegetable and salad crop agronomy in Queensland's food bowl.", + "email": "lockyervalley@agronomyclub.org", + "colour": "#fb8500" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 33, + "fields": { + "name": "Central Highlands Chapter", + "abbrev": "CHIGHLD", + "logo": "", + "location": "Emerald, QLD", + "desc": "Researching irrigated cotton and grain cropping systems in Central Queensland.", + "email": "centralhighlands@agronomyclub.org", + "colour": "#219ebc" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 34, + "fields": { + "name": "Wide Bay Chapter", + "abbrev": "WIDEBAY", + "logo": "", + "location": "Maryborough, QLD", + "desc": "Covering macadamia and sugarcane agronomy along the Wide Bay coastline.", + "email": "widebay@agronomyclub.org", + "colour": "#8ecae6" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 35, + "fields": { + "name": "Goldfields Chapter", + "abbrev": "GOLDFLD", + "logo": "", + "location": "Kalgoorlie, WA", + "desc": "Studying arid rangeland restoration and pastoral agronomy in the WA goldfields.", + "email": "goldfields@agronomyclub.org", + "colour": "#023047" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 36, + "fields": { + "name": "Peel Chapter", + "abbrev": "PEEL", + "logo": "", + "location": "Mandurah, WA", + "desc": "Focused on dairy pasture management and coastal horticultural agronomy.", + "email": "peel@agronomyclub.org", + "colour": "#390099" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 37, + "fields": { + "name": "Northern Rivers Chapter", + "abbrev": "NRIVERS", + "logo": "", + "location": "Lismore, NSW", + "desc": "Dedicated to macadamia, sugarcane, and subtropical dairy pasture research.", + "email": "northernrivers@agronomyclub.org", + "colour": "#9e0059" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 38, + "fields": { + "name": "Central Coast Chapter", + "abbrev": "CCOAST", + "logo": "", + "location": "Gosford, NSW", + "desc": "Exploring intensive horticulture and market garden agronomy techniques.", + "email": "centralcoast@agronomyclub.org", + "colour": "#ff0054" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 39, + "fields": { + "name": "Otway Chapter", + "abbrev": "OTWAY", + "logo": "", + "location": "Colac, VIC", + "desc": "Focused on dairy pasture management in Victoria's temperate south west.", + "email": "otway@agronomyclub.org", + "colour": "#ffbc42" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 40, + "fields": { + "name": "Grampians Chapter", + "abbrev": "GRAMPNS", + "logo": "", + "location": "Ararat, VIC", + "desc": "Supporting grain cropping and wool production agronomy research.", + "email": "grampians@agronomyclub.org", + "colour": "#d81159" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 41, + "fields": { + "name": "Yorke Peninsula Chapter", + "abbrev": "YORKEPN", + "logo": "", + "location": "Maitland, SA", + "desc": "Focused on broadacre grain and legume cropping systems research.", + "email": "yorkepeninsula@agronomyclub.org", + "colour": "#8f2d56" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 42, + "fields": { + "name": "Limestone Coast Chapter", + "abbrev": "LIMESTN", + "logo": "", + "location": "Mount Gambier, SA", + "desc": "Studying viticulture, forestry, and dairy agronomy on volcanic soils.", + "email": "limestonecoast@agronomyclub.org", + "colour": "#218380" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 43, + "fields": { + "name": "Granite Belt Chapter", + "abbrev": "GRANITE", + "logo": "", + "location": "Stanthorpe, QLD", + "desc": "Focused on stone fruit orchards and cool-climate viticulture research.", + "email": "granitebelt@agronomyclub.org", + "colour": "#73d2de" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 44, + "fields": { + "name": "Isaac Chapter", + "abbrev": "ISAAC", + "logo": "", + "location": "Moranbah, QLD", + "desc": "Covering grain cropping and cattle grazing agronomy in the Bowen Basin.", + "email": "isaac@agronomyclub.org", + "colour": "#6a4c93" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 45, + "fields": { + "name": "Barwon Chapter", + "abbrev": "BARWON", + "logo": "", + "location": "Geelong, VIC", + "desc": "Researching wool, grain, and coastal dairy pasture agronomy.", + "email": "barwon@agronomyclub.org", + "colour": "#1982c4" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 46, + "fields": { + "name": "Loddon Chapter", + "abbrev": "LODDON", + "logo": "", + "location": "Kerang, VIC", + "desc": "Focused on irrigated dairy pasture and rice growing agronomy.", + "email": "loddon@agronomyclub.org", + "colour": "#ff595e" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 47, + "fields": { + "name": "Macquarie Chapter", + "abbrev": "MACQRIE", + "logo": "", + "location": "Dubbo, NSW", + "desc": "Supporting mixed farming and broadacre grain cropping systems research.", + "email": "macquarie@agronomyclub.org", + "colour": "#ffca3a" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 48, + "fields": { + "name": "Clarence Valley Chapter", + "abbrev": "CLARNCE", + "logo": "", + "location": "Grafton, NSW", + "desc": "Focused on sugarcane and beef cattle pasture agronomy on the NSW north coast.", + "email": "clarencevalley@agronomyclub.org", + "colour": "#c5d86d" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 49, + "fields": { + "name": "Ovens Murray Chapter", + "abbrev": "OVENSMY", + "logo": "", + "location": "Wangaratta, VIC", + "desc": "Researching hops and cool-climate viticulture agronomy in north east Victoria.", + "email": "ovensmurray@agronomyclub.org", + "colour": "#a663cc" + } + }, + { + "model": "agronomy_club.chapter", + "pk": 50, + "fields": { + "name": "Esperance Chapter", + "abbrev": "ESPERNC", + "logo": "", + "location": "Esperance, WA", + "desc": "Studying grain and canola cropping systems along WA's south coast.", + "email": "esperance@agronomyclub.org", + "colour": "#4ea8de" + } + } +] diff --git a/server/agronomy_club/fixtures/events.json b/server/agronomy_club/fixtures/events.json new file mode 100644 index 0000000..14dc34e --- /dev/null +++ b/server/agronomy_club/fixtures/events.json @@ -0,0 +1,652 @@ +[ + { + "model": "agronomy_club.event", + "pk": 1, + "fields": { + "title": "Wheatbelt Soil Health Field Day", + "description": "Hands-on field day covering soil testing, nutrient budgeting, and stubble management for grain growers.", + "location": "Merredin Research Station, WA", + "date": "2026-08-18T09:00:00+00:00", + "thumbnail": "", + "chapter": 1, + "link": "https://agronomyclub.org/events/wheatbelt-soil-health" + } + }, + { + "model": "agronomy_club.event", + "pk": 2, + "fields": { + "title": "Riverina Irrigation Efficiency Workshop", + "description": "A workshop on scheduling irrigation and reducing water loss in high-value cropping systems.", + "location": "Charles Sturt University, Wagga Wagga, NSW", + "date": "2026-09-02T10:30:00+00:00", + "thumbnail": "", + "chapter": 2, + "link": "https://agronomyclub.org/events/riverina-irrigation" + } + }, + { + "model": "agronomy_club.event", + "pk": 3, + "fields": { + "title": "Mallee Dryland Cropping Seminar", + "description": "Seminar exploring drought-tolerant crop varieties and moisture conservation techniques.", + "location": "Bendigo Agricultural Showgrounds, VIC", + "date": "2026-08-25T09:30:00+00:00", + "thumbnail": "", + "chapter": 3, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 4, + "fields": { + "title": "Darling Downs Cotton Field Walk", + "description": "On-farm walk through irrigated cotton trials with a focus on pest management and yield forecasting.", + "location": "Kingsthorpe, QLD", + "date": "2026-10-05T08:00:00+00:00", + "thumbnail": "", + "chapter": 4, + "link": "https://agronomyclub.org/events/darling-downs-cotton" + } + }, + { + "model": "agronomy_club.event", + "pk": 5, + "fields": { + "title": "Barossa Viticulture Masterclass", + "description": "A masterclass on canopy management and vine nutrition presented by local viticulturists.", + "location": "Barossa Valley Wine Centre, SA", + "date": "2026-09-14T13:00:00+00:00", + "thumbnail": "", + "chapter": 5, + "link": "https://agronomyclub.org/events/barossa-viticulture" + } + }, + { + "model": "agronomy_club.event", + "pk": 6, + "fields": { + "title": "Top End Tropical Pasture Field Day", + "description": "Field demonstration of tropical pasture legumes and their role in improving grazing systems.", + "location": "Katherine Research Station, NT", + "date": "2026-08-30T08:30:00+00:00", + "thumbnail": "", + "chapter": 7, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 7, + "fields": { + "title": "Gippsland Dairy Pasture Renovation Day", + "description": "Practical session on pasture renovation techniques to boost dairy farm productivity.", + "location": "Warragul Showgrounds, VIC", + "date": "2026-09-20T09:00:00+00:00", + "thumbnail": "", + "chapter": 9, + "link": "https://agronomyclub.org/events/gippsland-pasture" + } + }, + { + "model": "agronomy_club.event", + "pk": 8, + "fields": { + "title": "Ord Valley Chia Crop Trial Showcase", + "description": "Showcase of trial results for emerging tropical crops including chia and sandalwood intercropping.", + "location": "Kununurra Agricultural Precinct, WA", + "date": "2026-10-12T09:00:00+00:00", + "thumbnail": "", + "chapter": 10, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 9, + "fields": { + "title": "Central West Orchard Management Workshop", + "description": "Workshop covering pruning strategies, pest monitoring, and frost protection for orchard crops.", + "location": "Orange Agricultural Institute, NSW", + "date": "2026-08-22T09:00:00+00:00", + "thumbnail": "", + "chapter": 12, + "link": "https://agronomyclub.org/events/central-west-orchards" + } + }, + { + "model": "agronomy_club.event", + "pk": 10, + "fields": { + "title": "Wimmera Grain Storage Field Day", + "description": "Field day on grain storage hygiene, aeration systems, and reducing post-harvest losses.", + "location": "Horsham Research Farm, VIC", + "date": "2026-09-05T09:30:00+00:00", + "thumbnail": "", + "chapter": 15, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 11, + "fields": { + "title": "Hunter Valley Soil Microbiology Talk", + "description": "Guest lecture on vineyard soil microbiology and its impact on grape quality.", + "location": "Pokolbin Community Hall, NSW", + "date": "2026-09-28T18:00:00+00:00", + "thumbnail": "", + "chapter": 16, + "link": "https://agronomyclub.org/events/hunter-valley-soil" + } + }, + { + "model": "agronomy_club.event", + "pk": 12, + "fields": { + "title": "Clare Valley Cover Cropping Field Day", + "description": "Demonstration of cover crop species for inter-row vineyard management and erosion control.", + "location": "Clare Showgrounds, SA", + "date": "2026-08-29T09:00:00+00:00", + "thumbnail": "", + "chapter": 18, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 13, + "fields": { + "title": "Kimberley Rangeland Management Forum", + "description": "Forum discussing grazing pressure, rangeland monitoring, and pastoral lease sustainability.", + "location": "Broome Civic Centre, WA", + "date": "2026-10-08T09:00:00+00:00", + "thumbnail": "", + "chapter": 20, + "link": "https://agronomyclub.org/events/kimberley-rangeland" + } + }, + { + "model": "agronomy_club.event", + "pk": 14, + "fields": { + "title": "New England Wool and Pasture Field Day", + "description": "Combined field day on pasture improvement strategies and wool quality outcomes.", + "location": "Armidale Showgrounds, NSW", + "date": "2026-09-11T09:00:00+00:00", + "thumbnail": "", + "chapter": 22, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 15, + "fields": { + "title": "Margaret River Vineyard Sustainability Day", + "description": "Sustainability day focused on organic inputs, canopy health, and vineyard water use efficiency.", + "location": "Margaret River Community Centre, WA", + "date": "2026-09-19T10:00:00+00:00", + "thumbnail": "", + "chapter": 25, + "link": "https://agronomyclub.org/events/margaret-river-sustainability" + } + }, + { + "model": "agronomy_club.event", + "pk": 16, + "fields": { + "title": "Sunraysia Citrus Nutrition Seminar", + "description": "Seminar on citrus tree nutrition programs and diagnosing common nutrient deficiencies.", + "location": "Mildura Arts Centre, VIC", + "date": "2026-08-27T13:30:00+00:00", + "thumbnail": "", + "chapter": 27, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 17, + "fields": { + "title": "Pilbara Arid Rangeland Rehabilitation Tour", + "description": "Site tour of rangeland rehabilitation trials following historic grazing and mining disturbance.", + "location": "Karratha Pastoral Precinct, WA", + "date": "2026-10-15T08:00:00+00:00", + "thumbnail": "", + "chapter": 30, + "link": "https://agronomyclub.org/events/pilbara-rangeland" + } + }, + { + "model": "agronomy_club.event", + "pk": 18, + "fields": { + "title": "Wide Bay Macadamia Field Walk", + "description": "Field walk through mature macadamia orchards focusing on canopy nutrition and harvest timing.", + "location": "Maryborough Showgrounds, QLD", + "date": "2026-09-24T09:00:00+00:00", + "thumbnail": "", + "chapter": 34, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 19, + "fields": { + "title": "Grampians Grain and Wool Field Day", + "description": "Annual field day pairing grain agronomy updates with wool production best practices.", + "location": "Ararat Showgrounds, VIC", + "date": "2026-08-16T09:00:00+00:00", + "thumbnail": "", + "chapter": 40, + "link": "https://agronomyclub.org/events/grampians-field-day" + } + }, + { + "model": "agronomy_club.event", + "pk": 20, + "fields": { + "title": "Macquarie Mixed Farming Conference", + "description": "Conference bringing together mixed farming producers to discuss crop rotation and livestock integration.", + "location": "Dubbo Regional Theatre, NSW", + "date": "2026-10-01T09:00:00+00:00", + "thumbnail": "", + "chapter": 47, + "link": "https://agronomyclub.org/events/macquarie-conference" + } + }, + { + "model": "agronomy_club.event", + "pk": 21, + "fields": { + "title": "Tasman Cool-Climate Cropping Field Day", + "description": "Field day exploring cool-climate grain varieties and pasture rotation strategies for northern Tasmania.", + "location": "Launceston Showgrounds, TAS", + "date": "2026-08-19T09:00:00+00:00", + "thumbnail": "", + "chapter": 6, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 22, + "fields": { + "title": "Liverpool Plains Precision Agriculture Demo", + "description": "Demonstration of variable rate technology and soil mapping for black soil cotton systems.", + "location": "Quirindi Showgrounds, NSW", + "date": "2026-09-08T09:00:00+00:00", + "thumbnail": "", + "chapter": 8, + "link": "https://agronomyclub.org/events/liverpool-plains-precision-ag" + } + }, + { + "model": "agronomy_club.event", + "pk": 23, + "fields": { + "title": "Fleurieu Coastal Horticulture Open Day", + "description": "Open day showcasing coastal horticulture trials and vineyard soil conservation practices.", + "location": "McLaren Vale Visitor Centre, SA", + "date": "2026-09-26T10:00:00+00:00", + "thumbnail": "", + "chapter": 11, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 24, + "fields": { + "title": "Atherton Tablelands Coffee and Avocado Workshop", + "description": "Workshop on tropical tree crop nutrition, covering coffee and avocado orchard management.", + "location": "Atherton Showgrounds, QLD", + "date": "2026-08-21T09:00:00+00:00", + "thumbnail": "", + "chapter": 13, + "link": "https://agronomyclub.org/events/atherton-coffee-avocado" + } + }, + { + "model": "agronomy_club.event", + "pk": 25, + "fields": { + "title": "South West Dairy Pasture Field Walk", + "description": "Field walk demonstrating rotational grazing and pasture species selection for dairy farms.", + "location": "Bunbury Regional Farm, WA", + "date": "2026-09-16T08:30:00+00:00", + "thumbnail": "", + "chapter": 14, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 26, + "fields": { + "title": "Fitzroy Beef and Sorghum Field Day", + "description": "Field day covering sorghum forage systems and their integration into beef cattle grazing.", + "location": "Rockhampton Showgrounds, QLD", + "date": "2026-10-03T08:00:00+00:00", + "thumbnail": "", + "chapter": 17, + "link": "https://agronomyclub.org/events/fitzroy-beef-sorghum" + } + }, + { + "model": "agronomy_club.event", + "pk": 27, + "fields": { + "title": "Huon Valley Apple Orchard Field Day", + "description": "Field day on pruning, pest monitoring, and frost management for apple orchards.", + "location": "Huonville Community Hall, TAS", + "date": "2026-08-24T09:00:00+00:00", + "thumbnail": "", + "chapter": 19, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 28, + "fields": { + "title": "Goulburn Valley Stone Fruit Nutrition Seminar", + "description": "Seminar on nutrient programs and irrigation scheduling for stone fruit and dairy pasture systems.", + "location": "Shepparton Showgrounds, VIC", + "date": "2026-09-10T13:00:00+00:00", + "thumbnail": "", + "chapter": 21, + "link": "https://agronomyclub.org/events/goulburn-valley-stone-fruit" + } + }, + { + "model": "agronomy_club.event", + "pk": 29, + "fields": { + "title": "Eyre Peninsula Soil Conservation Forum", + "description": "Forum on low-rainfall cropping strategies and coastal wind erosion control measures.", + "location": "Port Lincoln Civic Hall, SA", + "date": "2026-08-31T09:30:00+00:00", + "thumbnail": "", + "chapter": 23, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 30, + "fields": { + "title": "Capricorn Coast Macadamia Field Walk", + "description": "Field walk through macadamia orchards focusing on subtropical horticulture and irrigation.", + "location": "Yeppoon Showgrounds, QLD", + "date": "2026-09-22T09:00:00+00:00", + "thumbnail": "", + "chapter": 24, + "link": "https://agronomyclub.org/events/capricorn-coast-macadamia" + } + }, + { + "model": "agronomy_club.event", + "pk": 31, + "fields": { + "title": "Snowy Mountains Alpine Grazing Seminar", + "description": "Seminar covering cold-tolerant pasture species and grazing management at high altitude.", + "location": "Cooma Showgrounds, NSW", + "date": "2026-10-06T09:00:00+00:00", + "thumbnail": "", + "chapter": 26, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 32, + "fields": { + "title": "Burnett Sugarcane Nutrient Management Day", + "description": "Field day on precision nutrient application for sugarcane and irrigated horticulture crops.", + "location": "Bundaberg Research Facility, QLD", + "date": "2026-08-28T09:00:00+00:00", + "thumbnail": "", + "chapter": 28, + "link": "https://agronomyclub.org/events/burnett-sugarcane" + } + }, + { + "model": "agronomy_club.event", + "pk": 33, + "fields": { + "title": "Derwent Valley Hop Cultivation Workshop", + "description": "Workshop exploring trellising, irrigation, and pest control for hop cultivation systems.", + "location": "New Norfolk Community Centre, TAS", + "date": "2026-09-17T10:00:00+00:00", + "thumbnail": "", + "chapter": 29, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 34, + "fields": { + "title": "Riverland Citrus and Almond Field Day", + "description": "Field day on irrigation efficiency and nutrient scheduling for citrus and almond orchards.", + "location": "Renmark Showgrounds, SA", + "date": "2026-09-04T09:00:00+00:00", + "thumbnail": "", + "chapter": 31, + "link": "https://agronomyclub.org/events/riverland-citrus-almond" + } + }, + { + "model": "agronomy_club.event", + "pk": 35, + "fields": { + "title": "Lockyer Valley Vegetable Cropping Expo", + "description": "Expo highlighting salad crop rotation, pest management, and soil fertility for vegetable growers.", + "location": "Gatton Showgrounds, QLD", + "date": "2026-10-09T09:00:00+00:00", + "thumbnail": "", + "chapter": 32, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 36, + "fields": { + "title": "Central Highlands Cotton and Grain Field Day", + "description": "Field day covering irrigated cotton agronomy and grain rotation planning in Central Queensland.", + "location": "Emerald Showgrounds, QLD", + "date": "2026-08-20T08:00:00+00:00", + "thumbnail": "", + "chapter": 33, + "link": "https://agronomyclub.org/events/central-highlands-cotton" + } + }, + { + "model": "agronomy_club.event", + "pk": 37, + "fields": { + "title": "Goldfields Arid Rangeland Restoration Tour", + "description": "Site tour of rangeland restoration trials and pastoral lease management in the WA goldfields.", + "location": "Kalgoorlie Pastoral Centre, WA", + "date": "2026-10-13T08:30:00+00:00", + "thumbnail": "", + "chapter": 35, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 38, + "fields": { + "title": "Peel Coastal Horticulture Field Day", + "description": "Field day on dairy pasture renovation and coastal horticultural crop diversification.", + "location": "Mandurah Showgrounds, WA", + "date": "2026-09-13T09:00:00+00:00", + "thumbnail": "", + "chapter": 36, + "link": "https://agronomyclub.org/events/peel-horticulture" + } + }, + { + "model": "agronomy_club.event", + "pk": 39, + "fields": { + "title": "Northern Rivers Subtropical Dairy Forum", + "description": "Forum on subtropical pasture systems and macadamia intercropping for mixed farm operations.", + "location": "Lismore Showgrounds, NSW", + "date": "2026-08-23T09:00:00+00:00", + "thumbnail": "", + "chapter": 37, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 40, + "fields": { + "title": "Central Coast Market Garden Workshop", + "description": "Workshop on intensive horticulture practices and soil fertility management for market gardens.", + "location": "Gosford Community Hall, NSW", + "date": "2026-09-29T10:00:00+00:00", + "thumbnail": "", + "chapter": 38, + "link": "https://agronomyclub.org/events/central-coast-market-garden" + } + }, + { + "model": "agronomy_club.event", + "pk": 41, + "fields": { + "title": "Otway Dairy Pasture Field Day", + "description": "Field day on pasture species trials and rotational grazing for the temperate south west.", + "location": "Colac Showgrounds, VIC", + "date": "2026-08-26T09:00:00+00:00", + "thumbnail": "", + "chapter": 39, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 42, + "fields": { + "title": "Yorke Peninsula Legume Cropping Field Day", + "description": "Field day covering legume rotation benefits and nitrogen fixation in broadacre grain systems.", + "location": "Maitland Showgrounds, SA", + "date": "2026-09-07T09:30:00+00:00", + "thumbnail": "", + "chapter": 41, + "link": "https://agronomyclub.org/events/yorke-peninsula-legumes" + } + }, + { + "model": "agronomy_club.event", + "pk": 43, + "fields": { + "title": "Limestone Coast Viticulture and Forestry Day", + "description": "Field day exploring volcanic soil management for viticulture, forestry, and dairy operations.", + "location": "Mount Gambier Showgrounds, SA", + "date": "2026-10-11T09:00:00+00:00", + "thumbnail": "", + "chapter": 42, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 44, + "fields": { + "title": "Granite Belt Stone Fruit and Viticulture Field Day", + "description": "Field day on frost mitigation and canopy management for stone fruit and cool-climate vineyards.", + "location": "Stanthorpe Showgrounds, QLD", + "date": "2026-08-17T09:00:00+00:00", + "thumbnail": "", + "chapter": 43, + "link": "https://agronomyclub.org/events/granite-belt-field-day" + } + }, + { + "model": "agronomy_club.event", + "pk": 45, + "fields": { + "title": "Isaac Grain and Cattle Grazing Seminar", + "description": "Seminar on integrating grain cropping with cattle grazing in the Bowen Basin.", + "location": "Moranbah Community Centre, QLD", + "date": "2026-09-23T09:00:00+00:00", + "thumbnail": "", + "chapter": 44, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 46, + "fields": { + "title": "Barwon Wool and Grain Field Day", + "description": "Field day covering pasture-cropping rotations and wool quality outcomes near Geelong.", + "location": "Geelong Showgrounds, VIC", + "date": "2026-08-15T09:00:00+00:00", + "thumbnail": "", + "chapter": 45, + "link": "https://agronomyclub.org/events/barwon-wool-grain" + } + }, + { + "model": "agronomy_club.event", + "pk": 47, + "fields": { + "title": "Loddon Rice and Dairy Irrigation Day", + "description": "Field day on irrigated rice growing and dairy pasture water use efficiency near Kerang.", + "location": "Kerang Showgrounds, VIC", + "date": "2026-09-30T09:00:00+00:00", + "thumbnail": "", + "chapter": 46, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 48, + "fields": { + "title": "Clarence Valley Sugarcane and Cattle Field Day", + "description": "Field day on sugarcane ratoon management and beef cattle pasture integration on the NSW north coast.", + "location": "Grafton Showgrounds, NSW", + "date": "2026-10-14T08:30:00+00:00", + "thumbnail": "", + "chapter": 48, + "link": "https://agronomyclub.org/events/clarence-valley-sugarcane" + } + }, + { + "model": "agronomy_club.event", + "pk": 49, + "fields": { + "title": "Ovens Murray Hops and Viticulture Field Day", + "description": "Field day on hop trellising systems and cool-climate viticulture practices in north east Victoria.", + "location": "Wangaratta Showgrounds, VIC", + "date": "2026-09-18T09:00:00+00:00", + "thumbnail": "", + "chapter": 49, + "link": "" + } + }, + { + "model": "agronomy_club.event", + "pk": 50, + "fields": { + "title": "Esperance Grain and Canola Field Day", + "description": "Field day showcasing canola variety trials and grain cropping strategies along WA's south coast.", + "location": "Esperance Showgrounds, WA", + "date": "2026-08-13T09:00:00+00:00", + "thumbnail": "", + "chapter": 50, + "link": "https://agronomyclub.org/events/esperance-grain-canola" + } + } +] diff --git a/server/agronomy_club/views.py b/server/agronomy_club/views.py index 667c2ff..145ac9b 100644 --- a/server/agronomy_club/views.py +++ b/server/agronomy_club/views.py @@ -2,6 +2,7 @@ from .serializers import QuizSerializer, QuizDataSerializer, ResourceSerializer, ResourceTypeTagSerializer, EventListSerializer, AlumniSerializer, ChapterSerializer, ListedChapterSerializer # noqa: E501 from .models import Resource, ResourceTypeTag, User, Event, Quiz, Chapter from rest_framework.decorators import api_view +from rest_framework.pagination import PageNumberPagination from django.http import HttpResponse, FileResponse @@ -11,6 +12,18 @@ def ping(request): return HttpResponse("Pong!", status=200) +class EventsPagination(PageNumberPagination): + page_size = 20 + page_size_query_param = 'page_size' + max_page_size = 30 + + +class ChaptersPagination(PageNumberPagination): + page_size = 15 + page_size_query_param = 'page_size' + max_page_size = 30 + + class QuizDataAPIView(generics.RetrieveAPIView): serializer_class = QuizDataSerializer lookup_field = "id" @@ -67,6 +80,7 @@ class EventListAPIView(generics.ListAPIView): Returns a list of events. """ serializer_class = EventListSerializer + pagination_class = EventsPagination def get_queryset(self): return Event.objects.all().order_by("-date") @@ -85,6 +99,7 @@ def get_queryset(self): class ChapterListAPIView(generics.ListAPIView): serializer_class = ListedChapterSerializer + pagination_class = ChaptersPagination def get_queryset(self): - return Chapter.objects.all() + return Chapter.objects.order_by("abbrev")