Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added attendee list flag #176

Merged
merged 4 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions backend/djangoindia/api/serializers/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class EventRegistrationSerializer(serializers.Serializer):
twitter = serializers.URLField(required=False, allow_blank=True)
other_links = serializers.URLField(required=False, allow_blank=True)
rsvp = serializers.BooleanField(default=False)
include_in_attendee_list = serializers.BooleanField(default=False)

def create(self, validated_data):
return EventRegistration.objects.create(**validated_data)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.5 on 2024-10-04 17:56

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('db', '0013_volunteer'),
]

operations = [
migrations.AddField(
model_name='eventregistration',
name='include_in_attendee_list',
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name='volunteer',
name='event',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='volunteers', to='db.event'),
),
]
1 change: 1 addition & 0 deletions backend/djangoindia/db/models/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ class Gender(models.TextChoices):
github = models.URLField(null=True, blank=True)
twitter = models.URLField(null=True, blank=True)
other_links = models.URLField(null=True, blank=True)
include_in_attendee_list = models.BooleanField(default=False)
# TODO: imnplement this (RSVP mailing + RSVP submission link)
rsvp = models.BooleanField(default=False)

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
<input
type={type}
className={cn(
'flex w-full rounded-md bg-background px-5 py-4 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
'flex rounded-md bg-background px-5 py-4 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
type == 'checkbox' ?' w-8': 'w-full',
className,
)}
ref={ref}
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/constants/schema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,8 @@ export const REGISTER_EVENT_FORM_SCHEMA = yup.object({
.matches(
/^https?:\/\/(www\.)?twitter\.com\/.*$/,
'Please enter a valid Twitter URL',
),
),
include_in_attendee_list: yup
.bool()
.optional()
})
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,12 @@ export const REGISTER_FORM_FIELDS: (FieldType | Array<FieldType>)[] = [
type: 'text',
},
],
[
{
name: 'include_in_attendee_list',
label: 'I would like to be included in the attendee list',
placeholder: '',
type: 'checkbox',
},
],
]
40 changes: 30 additions & 10 deletions frontend/src/containers/RegisterEvent/RegisterEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const RegisterEvent = ({ eventId, seats_left, registration_end_date }: {
linkedin: '',
organization: '',
description: '',
include_in_attendee_list: false,
},
})

Expand All @@ -79,19 +80,27 @@ export const RegisterEvent = ({ eventId, seats_left, registration_end_date }: {
}

const currentDate = dayjs();
const registrationEndDate = dayjs(registration_end_date);
const isRegistrationOpen = seats_left > 0 && currentDate.isBefore(registrationEndDate);
const isFull = seats_left === 0;

let buttonText = 'Registration closed';
if (isRegistrationOpen) {
buttonText = 'Register';
} else if (isFull) {
buttonText = 'Housefull!';
}

return (
<Drawer open={isOpen} onOpenChange={setIsOpen}>
<DrawerTrigger asChild>
{seats_left !== 0 && seats_left != null && currentDate.isBefore(dayjs(registration_end_date)) ? (
<Button className="w-fit bg-blue-900 z-50" onClick={() => setIsOpen(true)}>
Register
</Button>
) : ( seats_left != null &&
<Button className="w-fit bg-blue-900 z-50" disabled>
{seats_left < 1 ? 'Housefull !' : 'Registration closed'}
</Button>
)}
{seats_left && registration_end_date&& <Button
className="w-fit bg-blue-900 z-50"
onClick={() => isRegistrationOpen && setIsOpen(true)}
disabled={!isRegistrationOpen}
>
{buttonText}
</Button>}
</DrawerTrigger>
<DrawerContent className="bg-orange-50 bg-[url('/sprinkle.svg')] bg-cover h-full pb-8 z-50">
<div className="overflow-auto no-scrollbar">
Expand Down Expand Up @@ -136,7 +145,16 @@ export const RegisterEvent = ({ eventId, seats_left, registration_end_date }: {
name={name}
render={({ field }) => (
<FormItem>
<FormLabel>{label}</FormLabel>
{type === 'checkbox' ? (
<div className='flex items-center gap-2'>
<FormLabel>{label}</FormLabel>
<FormControl>
<Input type='checkbox' {...field} />
</FormControl>
</div>
):(
<>
<FormLabel>{label}</FormLabel>
{type === 'select' ? (
<Select
onValueChange={field.onChange}
Expand Down Expand Up @@ -164,6 +182,8 @@ export const RegisterEvent = ({ eventId, seats_left, registration_end_date }: {
/>
</FormControl>
)}
</>
)}
<FormMessage>
{errors[name]?.message ?? ' '}
</FormMessage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type RegisterEventForm = {
linkedin: string
github?: string
twitter?: string
include_in_attendee_list?: boolean
}

type SelectField = {
Expand All @@ -25,8 +26,13 @@ type InputField = {
options?: never
}

type Checkbox = {
type: 'checkbox'
options?: never
}

export type FieldType = {
label: string
placeholder: string
name: keyof RegisterEventForm
} & (SelectField | InputField)
} & (SelectField | InputField | Checkbox)
1 change: 0 additions & 1 deletion frontend/src/sections/EventSection/EventCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ interface EventProps {
}

const EventCard: React.FC<EventProps> = ({
eventId,
slug,
title,
date,
Expand Down