feat(cms): add partners collection - #54
Conversation
| }, | ||
| maxPerDoc: 50, | ||
| }, | ||
| fields: [ |
There was a problem hiding this comment.
Kindly include a new field to store partner description. It should be an optional text.
ASPactores
left a comment
There was a problem hiding this comment.
@sbcxty In src/constants/sidebarGroup.ts under SIDEBAR_GROUP_ITEMS, to ensure the Partners collection appears under the correct sidebar group in admin, add COLLECTIONS.DURIANPY_WEBSITE_PARTNERS to SIDEBAR_GROUP_ITEMS:
export const SIDEBAR_GROUP_ITEMS: Record<SidebarGroupSlug, CollectionSlug[]> = {
[SIDEBAR_GROUPS.DURIANPY_WEBSITE]: [
COLLECTIONS.DURIANPY_WEBSITE_EVENTS,
COLLECTIONS.DURIANPY_WEBSITE_SPONSORS,
COLLECTIONS.DURIANPY_WEBSITE_SIGS,
COLLECTIONS.DURIANPY_WEBSITE_PARTNERS,
],
[SIDEBAR_GROUPS.ADMIN]: ['users'],
} as const| access: { | ||
| admin: checkPartnersAccess('admin'), | ||
| create: checkPartnersAccess('create'), | ||
| delete: checkPartnersAccess('delete'), | ||
| read: ({ req }) => { | ||
| if (req.user) return true | ||
| return { _status: { equals: 'published' } } | ||
| }, | ||
| update: checkPartnersAccess('update'), | ||
| }, |
There was a problem hiding this comment.
We have a new standards for Access Checking (defined in checkResourceAccess.ts), let's use the createCollectionAccess factory helper instead of manual access wrapper functions (checkCollectionAccess). Since Partners has drafts enabled (versions: { drafts: ... }), pass true for hasDrafts.
import { createCollectionAccess } from '@/access/checkResourceAccess'
import { COLLECTION_LABELS, COLLECTIONS } from '@/constants/collections'
import { SIDEBAR_GROUPS, getSidebarGroupLabel } from '@/constants/sidebarGroup'
import type { CollectionConfig } from 'payload'
export const Partners: CollectionConfig = {
slug: COLLECTIONS.DURIANPY_WEBSITE_PARTNERS,
labels: COLLECTION_LABELS[COLLECTIONS.DURIANPY_WEBSITE_PARTNERS],
access: createCollectionAccess(COLLECTIONS.DURIANPY_WEBSITE_PARTNERS, true),
// ...
}| }, | ||
| admin: { | ||
| defaultColumns: ['name', 'websiteUrl'], | ||
| group: getCollectionGroupLabel('durianpy-website'), |
There was a problem hiding this comment.
Sidebar groups now use SIDEBAR_GROUPS and getSidebarGroupLabel from @/constants/sidebarGroup. Kindly apply something like below:
admin: {
defaultColumns: ['name', 'websiteUrl'],
group: getSidebarGroupLabel(SIDEBAR_GROUPS.DURIANPY_WEBSITE),
},|
Before addressing the request changes, kindly do Also, as a reminder and as a best practice, write a seed function for the Partners collection. You may look at existing seed functions in Your changes are looking good, keep it up! |


📝 Overview
What does this PR do? Briefly describe the changes and the goal of this PR.
Adds a new
Partnerscollection to Payload CMS for the DurianPy website, per ticket #19. Includes schema (name, logo, websiteUrl), draft/versioning support with scheduled publish, role-based access control viacheckCollectionAccess, and URL-format validation onwebsiteUrl.🚀 Type of Change
🧱 CMS & Database Changes
Skip this section if no CMS or database changes were made.
payload migrate:createand saved the file.📊 Data Structure
Describe the new fields/tables or drag-and-drop a screenshot here:
fields:
🧪 Testing & Validation
📸 Visual Evidence (Mandatory)
Important
Visual proof is required to demonstrate that the approved test cases from the issue were successfully met.
Please provide screenshots, screen recordings (GIFs/Videos), or sample API outputs proving that the feature satisfies all approved test cases and do not introduce regressions.
Schema and UI Verification
Validation and Versioning
Access Control Verification
REST API Verification
GraphQL Verification
mainand resolved conflicts.🧠 Extra Notes / Questions
Add any additional context or questions for the reviewers here.
I didn’t strictly follow the
read: anyonepattern because I noticed that it also allows unauthenticated users to read drafts. I used a helper function to modify the logic so only authenticated users can read everything. I used the same helper function for both Events and Partners collections. Would it make sense to make it a shared helper function, similar toanyone.ts, so it can be reused?