summaryrefslogtreecommitdiff
path: root/website
diff options
context:
space:
mode:
Diffstat (limited to 'website')
-rw-r--r--website/__init__.py0
-rw-r--r--website/admin.py3
-rw-r--r--website/apps.py5
-rw-r--r--website/context_processors.py7
-rwxr-xr-xwebsite/forms.py158
-rw-r--r--website/migrations/0001_initial.py64
-rw-r--r--website/migrations/__init__.py0
-rw-r--r--website/models.py39
-rw-r--r--website/tests.py3
-rw-r--r--website/urls.py13
-rw-r--r--website/views.py178
11 files changed, 470 insertions, 0 deletions
diff --git a/website/__init__.py b/website/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/website/__init__.py
diff --git a/website/admin.py b/website/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/website/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/website/apps.py b/website/apps.py
new file mode 100644
index 0000000..5e338e4
--- /dev/null
+++ b/website/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class WebsiteConfig(AppConfig):
+ name = 'website'
diff --git a/website/context_processors.py b/website/context_processors.py
new file mode 100644
index 0000000..8abae49
--- /dev/null
+++ b/website/context_processors.py
@@ -0,0 +1,7 @@
+from django.conf import settings
+
+def root_url(request):
+ """
+ Pass your root_url from the settings.py
+ """
+ return {'SITE_URL': settings.ROOT_URL}
diff --git a/website/forms.py b/website/forms.py
new file mode 100755
index 0000000..97f9196
--- /dev/null
+++ b/website/forms.py
@@ -0,0 +1,158 @@
+from django import forms
+
+from django.forms import ModelForm
+
+from django.contrib.auth.forms import UserCreationForm
+from django.contrib.auth.models import User
+from django.core.validators import MinLengthValidator, MinValueValidator, \
+RegexValidator, URLValidator
+from captcha.fields import ReCaptchaField
+
+from website.models import Proposal
+
+MY_CHOICES = (
+ ('Beginner', 'Beginner'),
+ ('Advanced', 'Advanced'),
+)
+
+ws_duration = (
+ ('2', '2'),
+ ('3', '3'),
+ ('4', '4'),
+)
+abs_duration = (
+ ('15', '15'),
+ ('30', '30'),
+)
+
+
+MY_CHOICES = (
+ ('Beginner', 'Beginner'),
+ ('Advanced', 'Advanced'),
+)
+rating=(
+ ('1','1'),
+ ('2','2'),
+ ('3','3'),
+ ('4','4'),
+ ('5','5'),
+ ('6','6'),
+ ('7','7'),
+ ('8','8'),
+ ('9','9'),
+ ('10','10'),
+)
+
+
+
+class ProposalForm(forms.ModelForm):
+
+ class Meta:
+ model = Proposal
+ exclude = ('user', 'email','prerequisite','status','rate')
+
+
+ about_me = forms.CharField(widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'About Me'}),
+ required = True,
+ error_messages = {'required':'About me field required.'},
+ )
+ attachment = forms.FileField(widget=forms.ClearableFileInput(attrs={'multiple': True}),
+ label = 'Please upload relevant documents (if any)',
+ required = False,)
+ phone = forms.CharField(min_length = 10, max_length = 12, widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Phone'}),required=False, validators = [RegexValidator(regex = '^[0-9-_+.]*$', message='Enter a Valid Phone Number',)],
+ # error_messages = {'required':'Title field required.'},
+ )
+ title = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Title'}),
+ required = True,
+ error_messages = {'required':'Title field required.'},
+ )
+ abstract = forms.CharField(min_length = 300, widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'Abstract'}),
+ required = True,
+ label = 'Abstract (Min. 300 char.)',
+ error_messages = {'required':'Abstract field required.'},
+ )
+ proposal_type = forms.CharField(widget = forms.HiddenInput(), label = '', initial = 'ABSTRACT', required=False)
+
+ duration = forms.ChoiceField(choices=abs_duration, label = 'Duration (Mins.)')
+
+ tags = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Tags'}),
+ required = False,
+ )
+
+
+ class Meta:
+ model = Proposal
+ exclude = ('user', 'email','prerequisite','status','rate')
+
+
+ def clean_attachment(self):
+ import os
+ cleaned_data = self.cleaned_data
+ attachment = cleaned_data.get('attachment', None)
+ if attachment:
+ ext = os.path.splitext(attachment.name)[1]
+ valid_extensions = ['.pdf']
+ if not ext in valid_extensions:
+ raise forms.ValidationError(u'File not supported! Only .pdf file is accepted')
+ if attachment.size > (5*1024*1024):
+ raise forms.ValidationError('File size exceeds 5MB')
+ return attachment
+
+class WorkshopForm(forms.ModelForm):
+ about_me = forms.CharField(widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'About Me'}),
+ required = True,
+ error_messages = {'required':'About Me field required.'},
+ )
+ attachment = forms.FileField(widget=forms.ClearableFileInput(attrs={'multiple': True}),
+ label = 'Please upload relevant documents (if any)',
+ required = False,)
+ phone = forms.CharField(min_length = 10, max_length = 12, widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Phone'}),required=False, validators = [RegexValidator(regex = '^[0-9-_+.]*$', message='Enter a Valid Phone Number',)],
+ )
+ title = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Title'}),
+ required = True,
+ error_messages = {'required':'Title field required.'},
+ )
+ abstract = forms.CharField(min_length = 300 ,widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'Desciption'}),
+ required = True,
+ label = 'Description (Min. 300 char.)',
+ error_messages = {'required':'Abstract field required.'},
+ )
+ prerequisite = forms.CharField(widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'Prerequisite'}),
+ label = 'Prerequisites',
+ required = False,
+ )
+ proposal_type = forms.CharField(widget = forms.HiddenInput(), label = '', required=False, initial = 'WORKSHOP')
+
+ duration = forms.ChoiceField(choices=ws_duration, label = 'Duration (Hrs.)')
+
+ tags = forms.ChoiceField(choices=MY_CHOICES, label = 'Level')
+
+ class Meta:
+ model = Proposal
+ exclude = ('user', 'email','status','rate')
+
+ def clean_attachment(self):
+ import os
+ cleaned_data = self.cleaned_data
+ attachment = cleaned_data.get('attachment', None)
+ if attachment:
+ ext = os.path.splitext(attachment.name)[1]
+ valid_extensions = ['.pdf',]
+ if not ext in valid_extensions:
+ raise forms.ValidationError(u'File not supported! Only .pdf file is accepted')
+ if attachment.size > (5*1024*1024):
+ raise forms.ValidationError('File size exceeds 5MB')
+ return attachment
+
+
+class UserLoginForm(forms.Form):
+ username = forms.CharField(
+ widget=forms.TextInput(attrs={'class': 'form-inline', 'placeholder': 'Username'}),
+ label='User Name'
+ )
+ password = forms.CharField(
+ widget=forms.PasswordInput(attrs={'class': 'form-inline', 'placeholder': 'Password'}),
+ label='Password'
+ )
+
+
diff --git a/website/migrations/0001_initial.py b/website/migrations/0001_initial.py
new file mode 100644
index 0000000..5ffde4c
--- /dev/null
+++ b/website/migrations/0001_initial.py
@@ -0,0 +1,64 @@
+# Generated by Django 2.1 on 2018-08-14 07:08
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+import website.models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Comments',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('comment', models.CharField(max_length=700)),
+ ],
+ ),
+ migrations.CreateModel(
+ name='Proposal',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('about_me', models.TextField(max_length=500)),
+ ('email', models.CharField(max_length=128)),
+ ('phone', models.CharField(max_length=20)),
+ ('title', models.CharField(max_length=250)),
+ ('abstract', models.TextField(max_length=700)),
+ ('prerequisite', models.CharField(max_length=750)),
+ ('duration', models.CharField(max_length=100)),
+ ('attachment', models.FileField(upload_to=website.models.get_document_dir)),
+ ('date_created', models.DateTimeField(auto_now_add=True)),
+ ('date_modified', models.DateTimeField(auto_now=True)),
+ ('status', models.CharField(default='Pending', max_length=100)),
+ ('proposal_type', models.CharField(max_length=100)),
+ ('tags', models.CharField(max_length=250)),
+ ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+ ],
+ ),
+ migrations.CreateModel(
+ name='Ratings',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('rating', models.CharField(max_length=700)),
+ ('proposal', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='website.Proposal')),
+ ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+ ],
+ ),
+ migrations.AddField(
+ model_name='comments',
+ name='proposal',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='website.Proposal'),
+ ),
+ migrations.AddField(
+ model_name='comments',
+ name='user',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
+ ),
+ ]
diff --git a/website/migrations/__init__.py b/website/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/website/migrations/__init__.py
diff --git a/website/models.py b/website/models.py
new file mode 100644
index 0000000..4f9aa68
--- /dev/null
+++ b/website/models.py
@@ -0,0 +1,39 @@
+from django.db import models
+from django.contrib.auth.models import User
+
+from social.apps.django_app.default.models import UserSocialAuth
+from nccps2018 import settings
+import os
+
+def get_document_dir(instance, filename):
+ # ename, eext = instance.user.email.split("@")
+ fname, fext = os.path.splitext(filename)
+ #print "----------------->",instance.user
+ return '%s/attachment/%s/%s.%s' % (instance.user, instance.proposal_type, fname+'_'+str(instance.user), fext)
+
+class Proposal(models.Model):
+ user = models.ForeignKey(User,on_delete=models.CASCADE,)
+ about_me = models.TextField(max_length=500)
+ email = models.CharField(max_length=128)
+ phone = models.CharField(max_length = 20)
+ title = models.CharField(max_length=250)
+ abstract = models.TextField(max_length=700)
+ prerequisite = models.CharField(max_length=750)
+ duration = models.CharField(max_length = 100)
+ attachment = models.FileField(upload_to=get_document_dir)
+ date_created = models.DateTimeField(auto_now_add=True)
+ date_modified = models.DateTimeField(auto_now=True)
+ status = models.CharField(max_length = 100, default='Pending', editable=True)
+ proposal_type = models.CharField(max_length = 100)
+ tags = models.CharField(max_length = 250)
+
+class Ratings(models.Model):
+ proposal = models.ForeignKey(Proposal,on_delete=models.CASCADE,)
+ user = models.ForeignKey(User,on_delete=models.CASCADE,)
+ rating = models.CharField(max_length=700)
+
+class Comments(models.Model):
+ proposal = models.ForeignKey(Proposal,on_delete=models.CASCADE,)
+ user = models.ForeignKey(User,on_delete=models.CASCADE,)
+ comment = models.CharField(max_length=700)
+ # rate = models.CharField(max_length =100)
diff --git a/website/tests.py b/website/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/website/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/website/urls.py b/website/urls.py
new file mode 100644
index 0000000..582f905
--- /dev/null
+++ b/website/urls.py
@@ -0,0 +1,13 @@
+from django.urls import path,include
+
+from . import views
+
+urlpatterns = [
+ path('', views.index, name='index'),
+ path('proposal', views.proposal, name='proposal'),
+ #path('login', views.login, name='login'),
+ path('accounts/', include('django.contrib.auth.urls')),
+ path('proposal/view', views.view_abstracts, name='view_abstracts'),
+ path('proposal/submitcfp', views.submitcfp, name='submitcfp'),
+ #path('accounts/register', views.userregister, name='userregister'),
+]
diff --git a/website/views.py b/website/views.py
new file mode 100644
index 0000000..71f57be
--- /dev/null
+++ b/website/views.py
@@ -0,0 +1,178 @@
+# Create your views here.
+
+from django.http import HttpResponse
+from django.shortcuts import render
+from django.shortcuts import render_to_response
+from django.template import loader
+from django.template import RequestContext
+from django.contrib.auth.forms import UserCreationForm
+from django.views.decorators.csrf import csrf_exempt
+from django.contrib.auth.decorators import login_required
+from django.contrib.auth.models import User
+from website.models import Proposal, Comments, Ratings
+from website.forms import ProposalForm
+#UserRegisterForm, UserLoginForm, WorkshopForm, ContactForm
+
+
+def index(request):
+ context = {}
+ template = loader.get_template('index.html')
+ return HttpResponse(template.render(context, request))
+
+def proposal(request):
+ context = {}
+ template = loader.get_template('proposal.html')
+ return HttpResponse(template.render(context, request))
+
+## User Register
+
+def userregister(request):
+ context = {}
+ registered_emails = []
+ users = User.objects.all()
+ for user in users:
+ registered_emails.append(user.email)
+ if request.user.is_anonymous():
+ if request.method == 'POST':
+ form = UserRegisterForm(request.POST)
+ if form.is_valid():
+ data = form.cleaned_data
+ if data['email'] in registered_emails:
+ context['form'] = form
+ context['email_registered'] = True
+ return render_to_response('registration/signup.html', context)
+ else:
+ form.save()
+ context['registration_complete'] = True
+ form = UserLoginForm()
+ context['form'] = form
+ context['user'] = request.user
+ return render_to_response('cfp.html', context)
+ else:
+
+ context['form'] = form
+ return render_to_response('user-register.html', context)
+ else:
+ form = UserRegisterForm()
+ context['form'] = form
+ return render_to_response('user-register.html', context)
+ else:
+ context['user'] = request.user
+ return render_to_response('cfp.html', context)
+
+## View Proposal/Abstract
+@login_required
+def view_abstracts(request):
+ user = request.user
+ context = {}
+ count_list =[]
+ if request.user.is_authenticated:
+ if user.is_superuser :
+ proposals = Proposal.objects.all().order_by('status')
+ ratings = Ratings.objects.all()
+ context['ratings'] = ratings
+ context['proposals'] = proposals
+ context['user'] = user
+ return render(request, 'view-proposals.html', context)
+ elif user is not None:
+ if Proposal.objects.filter(user = user).exists :
+ proposals = Proposal.objects.filter(user = user).order_by('status')
+ proposal_list= [pro.proposal_type for pro in proposals]
+ if 'WORKSHOP' in proposal_list and 'ABSTRACT' in proposal_list:
+ proposal_type = 'BOTH'
+ elif 'WORKSHOP' in proposal_list and 'ABSTRACT' not in proposal_list:
+ proposal_type = 'WORKSHOP'
+ else:
+ proposal_type = 'ABSTRACT'
+
+ context['counts'] = count_list
+ context['proposals'] =proposals
+ context['type'] = proposal_type
+ context['user'] = user
+ return render(request, 'view-proposals.html', context)
+ else:
+ return render(request, 'cfp.html')
+ else:
+ return render(request, 'cfp.html', context)
+
+def cfp(request):
+ if request.method == "POST":
+ context = {}
+ username = request.POST.get('username', None)
+ password = request.POST.get('password', None)
+ user = authenticate(username=username, password=password)
+ if user is not None:
+ login(request, user)
+ if 'next' in request.GET:
+ next = request.GET.get('next', None)
+ return HttpResponseRedirect(next)
+ proposals = Proposal.objects.filter(user = request.user).count()
+ context['user'] = user
+ context['proposals'] = proposals
+ return render_to_response('cfp.html', context)
+ else:
+ context['invalid'] = True
+ context['form'] = UserLoginForm
+ context['user'] = user
+ return render_to_response('cfp.html', context)
+ else:
+ form = UserLoginForm()
+ context = {'request': request,
+ 'user': request.user,
+ }
+ template = loader.get_template('cfp.html')
+ return HttpResponse(template.render(context, request))
+
+
+@login_required
+def submitcfp(request):
+ context = {}
+ if request.user.is_authenticated:
+ social_user = request.user
+
+ django_user = User.objects.get(username=social_user)
+ context['user'] = django_user
+ proposals_a = Proposal.objects.filter(user = request.user, proposal_type = 'ABSTRACT').count()
+ if request.method == 'POST':
+ form = ProposalForm(request.POST, request.FILES)
+ if form.is_valid():
+ data = form.save(commit=False)
+ data.user = django_user
+ data.email = social_user.email
+ data.save()
+ context['proposal_submit'] = True
+ sender_name = "SciPy India 2017"
+ sender_email = TO_EMAIL
+ subject = "SciPy India 2017 – Talk Proposal Submission Acknowledgment"
+ to = (social_user.email, TO_EMAIL)
+ message = """
+ Dear {0}, <br><br>
+ Thank you for showing interest & submitting a talk proposal at SciPy India 2017 conference for the talk titled <b>“{1}”</b>. Reviewal of the proposals will start once the CFP closes.
+ <br><br>You will be notified regarding comments/selection/rejection of your talk via email.
+ Visit this {2} link to view status of your submission.
+ <br>Thank You ! <br><br>Regards,<br>SciPy India 2017,<br>FOSSEE - IIT Bombay.
+ """.format(
+ social_user.first_name,
+ request.POST.get('title', None),
+ 'http://scipy.in/2017/view-abstracts/', )
+ email = EmailMultiAlternatives(
+ subject,'',
+ sender_email, to,
+ headers={"Content-type":"text/html;charset=iso-8859-1"}
+ )
+ email.attach_alternative(message, "text/html")
+ email.send(fail_silently=True)
+ return render_to_response('cfp.html', context)
+ else:
+ context['proposal_form'] = form
+ context['proposals_a'] = proposals_a
+ template = loader.get_template('submit-cfp.html')
+ return HttpResponse(template.render(context, request))
+ else:
+ form = ProposalForm()
+ context['proposals_a'] = proposals_a
+ return render(request, 'submit-cfp.html', {'form': form})
+ else:
+ context['login_required'] = True
+ return render_to_response('cfp.html', context)
+