Skip to content

Commit fb8cacc

Browse files
Add field for webinar_code and append to the end of event bodies with the webinar url
1 parent 4bd30c1 commit fb8cacc

5 files changed

Lines changed: 48 additions & 3 deletions

File tree

hackathon/forms.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,16 @@ class EventForm(forms.ModelForm):
242242
required=False,
243243
widget=forms.URLInput(attrs={'class': 'form-control'})
244244
)
245-
245+
webinar_code = forms.CharField(
246+
label="Webinar Join Code",
247+
widget=forms.Textarea(attrs={'rows': 1, 'class': 'form-control'})
248+
)
246249
class Meta:
247250
model = Event
248251
fields = [
249252
'title', 'start', 'end', 'body',
250-
'isReadOnly', 'webinar_link'
253+
'isReadOnly', 'webinar_link',
254+
'webinar_code',
251255
]
252256

253257
def __init__(self, *args, **kwargs):
@@ -257,7 +261,8 @@ def save(self, commit=True):
257261
event = super(EventForm, self).save(commit=False)
258262
# Append f-string to the body field
259263
webinar_link = self.cleaned_data.get('webinar_link', '')
260-
event.body += f'<br><br><b>Meeting Join Link:</b> <a href="{webinar_link}" target="_blank">Click here to join</a><br><b>Meeting Join Code:</b> code'
264+
webinar_code = self.cleaned_data.get('webinar_code', '')
265+
event.body += f'<br><br><b>Meeting Join Link:</b> <a href="{webinar_link}" target="_blank">Click here to join</a><br><b>Meeting Join Code:</b> {webinar_code}'
261266
if commit:
262267
event.save()
263268
return event
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.1.13 on 2024-09-16 10:02
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('hackathon', '0063_auto_20240915_1858'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='event',
15+
name='webinar_code',
16+
field=models.CharField(blank=True, max_length=100, null=True),
17+
),
18+
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 3.1.13 on 2024-09-16 10:09
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('hackathon', '0064_event_webinar_code'),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name='event',
15+
name='webinar_code',
16+
field=models.CharField(blank=True, max_length=50, null=True),
17+
),
18+
]

hackathon/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ class Event(models.Model):
310310
body = models.TextField(max_length=500, default="")
311311
isReadOnly = models.BooleanField(default=True)
312312
webinar_link = models.URLField(blank=True, null=True)
313+
webinar_code = models.CharField(max_length=50, blank=True, null=True)
313314

314315
def save(self, *args, **kwargs):
315316
"""

hackathon/templates/hackathon/change_event.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ <h1>Create Event</h1>
4040
<div class="col-12">
4141
{{ form.webinar_link|as_crispy_field }}
4242
</div>
43+
<div class="col-12">
44+
{{ form.webinar_code|as_crispy_field }}
45+
</div>
4346
<div class="col-12">
4447
<button type="submit" class="btn btn-primary">Save</button>
4548
</div>

0 commit comments

Comments
 (0)