Skip to content

Commit

Permalink
Implement beta flag for clubs
Browse files Browse the repository at this point in the history
  • Loading branch information
julianweng committed Oct 5, 2024
1 parent 51288a4 commit d65b377
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
23 changes: 23 additions & 0 deletions backend/clubs/migrations/0115_club_beta_historicalclub_beta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 5.0.4 on 2024-10-05 02:24

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("clubs", "0114_alter_advisor_public"),
]

operations = [
migrations.AddField(
model_name="club",
name="beta",
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name="historicalclub",
name="beta",
field=models.BooleanField(default=False),
),
]
1 change: 1 addition & 0 deletions backend/clubs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class Club(models.Model):

code = models.SlugField(max_length=255, unique=True, db_index=True)
active = models.BooleanField(default=False)
beta = models.BooleanField(default=False) # opts club into all beta features
name = models.CharField(max_length=255)
subtitle = models.CharField(blank=True, max_length=255)
terms = models.CharField(blank=True, max_length=1024)
Expand Down
6 changes: 6 additions & 0 deletions backend/clubs/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,11 @@ def save(self):
"""
Override save in order to replace code with slugified name if not specified.
"""
if "beta" in self.validated_data:
raise serializers.ValidationError(
"The beta field is not allowed to be set by clubs."
)

# remove any spaces from the name
if "name" in self.validated_data:
self.validated_data["name"] = self.validated_data["name"].strip()
Expand Down Expand Up @@ -1704,6 +1709,7 @@ class Meta(ClubListSerializer.Meta):
"approved_by",
"approved_comment",
"badges",
"beta",
"created_at",
"description",
"events",
Expand Down
10 changes: 7 additions & 3 deletions frontend/components/ClubEditPage/EventsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ const CreateContainer = styled.div`
align-items: center;
`

const CreateTickets = ({ event }: { event: ClubEvent }) => {
const CreateTickets = ({ event, club }: { event: ClubEvent; club: Club }) => {
const [show, setShow] = useState(false)
const showModal = () => setShow(true)
const hideModal = () => setShow(false)
Expand Down Expand Up @@ -431,7 +431,11 @@ const CreateTickets = ({ event }: { event: ClubEvent }) => {
closeModal={hideModal}
marginBottom={false}
>
<TicketsModal event={event} onSuccessfulSubmit={hideModal} />
<TicketsModal
club={club}
event={event}
onSuccessfulSubmit={hideModal}
/>
</Modal>
)}
</CreateContainer>
Expand Down Expand Up @@ -476,7 +480,7 @@ export default function EventsCard({ club }: EventsCardProps): ReactElement {
}}
/>
<Line />
<CreateTickets event={event} />
<CreateTickets event={event} club={club} />
<Line />
<div ref={eventDetailsRef}>
<EventPreview event={event} />
Expand Down
9 changes: 7 additions & 2 deletions frontend/components/ClubEditPage/TicketsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '../../constants/colors'
import { BORDER_RADIUS } from '../../constants/measurements'
import { BODY_FONT } from '../../constants/styles'
import { ClubEvent } from '../../types'
import { Club, ClubEvent } from '../../types'
import { doApiRequest } from '../../utils'
import CoverPhoto from '../EventPage/CoverPhoto'

Expand Down Expand Up @@ -56,13 +56,15 @@ const notify = (

type TicketItemProps = {
ticket: Ticket
club: Club
onChange?: (ticket: Ticket) => void
onDelete?: () => void
deletable: boolean
}

const TicketItem: React.FC<TicketItemProps> = ({
ticket: propTicket,
club,
onChange,
onDelete,
deletable,
Expand Down Expand Up @@ -122,7 +124,7 @@ const TicketItem: React.FC<TicketItemProps> = ({
className="input"
value={ticket.price ?? ''}
placeholder="Ticket Price"
disabled={!TICKETING_PAYMENT_ENABLED}
disabled={!TICKETING_PAYMENT_ENABLED && !club.beta}
onChange={(e) => {
const price = e.target.value
setTicket({ ...ticket, price })
Expand Down Expand Up @@ -221,9 +223,11 @@ type Ticket = {

const TicketsModal = ({
event,
club,
onSuccessfulSubmit,
}: {
event: ClubEvent
club: Club
onSuccessfulSubmit: () => void
}): ReactElement => {
const { large_image_url, image_url, club_name, name, id } = event
Expand Down Expand Up @@ -333,6 +337,7 @@ const TicketsModal = ({
<TicketItem
key={index}
ticket={ticket}
club={club}
deletable={tickets.length > 1}
onChange={(newTicket) => {
setTickets((t) =>
Expand Down
1 change: 1 addition & 0 deletions frontend/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export interface Club {
approved_comment: string | null
available_virtually: boolean
badges: Badge[]
beta: boolean
code: string
description: string
email: string
Expand Down

0 comments on commit d65b377

Please sign in to comment.