diff --git a/events/admin.py b/events/admin.py
index 3b8cfed..4845bfd 100644
--- a/events/admin.py
+++ b/events/admin.py
@@ -1,5 +1,6 @@
from django.contrib import admin
-from .models import Event, EventParticipant
+from .models import Event, EventParticipant, RequestEvent
admin.site.register(Event)
admin.site.register(EventParticipant)
+admin.site.register(RequestEvent)
diff --git a/events/forms.py b/events/forms.py
index 3d91c68..62f7b9d 100644
--- a/events/forms.py
+++ b/events/forms.py
@@ -1,5 +1,5 @@
from django.forms import ModelForm
-from .models import EventParticipant
+from .models import EventParticipant, RequestEvent
class ParticipantForm(ModelForm):
@@ -7,3 +7,8 @@ class Meta:
model = EventParticipant
fields = ['title', 'student_name',
'email_id', 'mobile_number', 'roll_no', 'branch']
+
+class RequestEventForm(ModelForm):
+ class Meta:
+ model = RequestEvent
+ fields = ['title', 'description', 'your_name','roll_no' ,'contact']
diff --git a/events/migrations/0008_requestevent.py b/events/migrations/0008_requestevent.py
new file mode 100644
index 0000000..e87f49f
--- /dev/null
+++ b/events/migrations/0008_requestevent.py
@@ -0,0 +1,24 @@
+# Generated by Django 2.2.9 on 2020-08-07 07:54
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('events', '0007_auto_20190924_1641'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='RequestEvent',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('title', models.CharField(max_length=50)),
+ ('description', models.TextField()),
+ ('your_name', models.CharField(max_length=50)),
+ ('roll_no', models.CharField(max_length=15)),
+ ('contact', models.CharField(max_length=10)),
+ ],
+ ),
+ ]
diff --git a/events/models.py b/events/models.py
index 7b1dbef..e593590 100644
--- a/events/models.py
+++ b/events/models.py
@@ -53,3 +53,14 @@ class EventParticipant(TimeStampedModel):
def __str__(self):
return self.student_name
+
+
+class RequestEvent(models.Model):
+ title = models.CharField(max_length=50, blank=False)
+ description = models.TextField(blank=False)
+ your_name = models.CharField(max_length=50, blank=False)
+ roll_no = models.CharField(max_length=15, blank=False)
+ contact = models.CharField(max_length=10, blank=False)
+
+ def __str__(self):
+ return self.title
diff --git a/events/urls.py b/events/urls.py
index 4586823..7888de9 100644
--- a/events/urls.py
+++ b/events/urls.py
@@ -1,7 +1,8 @@
from django.urls import path
-from .views import events, register
+from .views import events, register, request_event
urlpatterns = [
path('', events, name='tech_events'),
path('register/', register, name='register'),
+ path('request_event/', request_event, name='request_event'),
]
diff --git a/events/views.py b/events/views.py
index 5abf9ed..5c4bb3d 100644
--- a/events/views.py
+++ b/events/views.py
@@ -2,14 +2,14 @@
from django.contrib import messages
from django.shortcuts import render, redirect
from django.views.generic import ListView
-from .models import Event, EventParticipant
-from .forms import ParticipantForm
+from .models import Event, EventParticipant, RequestEvent
+from .forms import ParticipantForm, RequestEventForm
import csv
def events(request):
- events = Event.objects.all
- return render(request, 'events.html', {'events': events})
+ events = Event.objects.all()
+ return render(request, 'events.html', {'events': events })
def register(request):
@@ -45,3 +45,17 @@ def export_to_csv(request):
error = "Please Enter a Valid Token"
return render(request, 'download.html', {'error': error})
return render(request, 'download.html')
+
+def request_event(request):
+ if request.method == 'POST':
+ form = RequestEventForm(request.POST)
+ if form.is_valid():
+ form.save()
+ your_name = form.cleaned_data.get('your_name')
+ title = form.cleaned_data.get('title')
+ messages.success(
+ request, f'Thank you { your_name } for requesting to organise { title }, you will be contacted shortly!')
+ return redirect('homepage')
+ else:
+ form = RequestEventForm()
+ return render(request, 'event_register.html', {'form': form})
diff --git a/templates/event_register.html b/templates/event_register.html
index 3a350cf..84b10e4 100644
--- a/templates/event_register.html
+++ b/templates/event_register.html
@@ -8,7 +8,7 @@