-
Notifications
You must be signed in to change notification settings - Fork 4
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
Updates events page. #15
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
from django.forms import ModelForm | ||
from .models import EventParticipant | ||
from .models import EventParticipant, requestEvent | ||
|
||
|
||
class ParticipantForm(ModelForm): | ||
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'] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,13 @@ class EventParticipant(TimeStampedModel): | |
|
||
def __str__(self): | ||
return self.student_name | ||
|
||
class requestEvent(models.Model): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
from django.urls import path | ||
from .views import events, register | ||
from .views import events, register, requestEvent | ||
|
||
urlpatterns = [ | ||
path('', events, name='tech_events'), | ||
path('register/', register, name='register'), | ||
path('requestEvent/', requestEvent, name='requestEvent'), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,17 @@ | |
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() | ||
#numberOfEvents = len(events) | ||
#if (numberOfEvents) == 0: | ||
# events = 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you left commented code here. You should remove the unused code. |
||
return render(request, 'events.html', {'events': events }) | ||
|
||
|
||
def register(request): | ||
|
@@ -45,3 +48,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 requestEvent(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}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While creating methods, you should not write like this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issues here :
class RequestEventForm(ModelForm)