Skip to content

Commit

Permalink
Add field for webinar_code and append to the end of event bodies with…
Browse files Browse the repository at this point in the history
… the webinar url
  • Loading branch information
kenanwright1988 committed Sep 17, 2024
1 parent 4bd30c1 commit fb8cacc
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
11 changes: 8 additions & 3 deletions hackathon/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,16 @@ class EventForm(forms.ModelForm):
required=False,
widget=forms.URLInput(attrs={'class': 'form-control'})
)

webinar_code = forms.CharField(
label="Webinar Join Code",
widget=forms.Textarea(attrs={'rows': 1, 'class': 'form-control'})
)
class Meta:
model = Event
fields = [
'title', 'start', 'end', 'body',
'isReadOnly', 'webinar_link'
'isReadOnly', 'webinar_link',
'webinar_code',
]

def __init__(self, *args, **kwargs):
Expand All @@ -257,7 +261,8 @@ def save(self, commit=True):
event = super(EventForm, self).save(commit=False)
# Append f-string to the body field
webinar_link = self.cleaned_data.get('webinar_link', '')
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'
webinar_code = self.cleaned_data.get('webinar_code', '')
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}'
if commit:
event.save()
return event
18 changes: 18 additions & 0 deletions hackathon/migrations/0064_event_webinar_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.13 on 2024-09-16 10:02

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('hackathon', '0063_auto_20240915_1858'),
]

operations = [
migrations.AddField(
model_name='event',
name='webinar_code',
field=models.CharField(blank=True, max_length=100, null=True),
),
]
18 changes: 18 additions & 0 deletions hackathon/migrations/0065_auto_20240916_1009.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.13 on 2024-09-16 10:09

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('hackathon', '0064_event_webinar_code'),
]

operations = [
migrations.AlterField(
model_name='event',
name='webinar_code',
field=models.CharField(blank=True, max_length=50, null=True),
),
]
1 change: 1 addition & 0 deletions hackathon/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ class Event(models.Model):
body = models.TextField(max_length=500, default="")
isReadOnly = models.BooleanField(default=True)
webinar_link = models.URLField(blank=True, null=True)
webinar_code = models.CharField(max_length=50, blank=True, null=True)

def save(self, *args, **kwargs):
"""
Expand Down
3 changes: 3 additions & 0 deletions hackathon/templates/hackathon/change_event.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ <h1>Create Event</h1>
<div class="col-12">
{{ form.webinar_link|as_crispy_field }}
</div>
<div class="col-12">
{{ form.webinar_code|as_crispy_field }}
</div>
<div class="col-12">
<button type="submit" class="btn btn-primary">Save</button>
</div>
Expand Down

0 comments on commit fb8cacc

Please sign in to comment.