From 64ab50bb06eb01b4364bfcdaf45ae926b6670612 Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Fri, 14 Sep 2018 15:17:21 +0530 Subject: Enabled registration and login interface, activation emails, paper submission interface --- logs/emailconfig.yaml | 20 ++ nccps2018/urls.py | 2 +- requirements.txt | 3 +- static/website/templates/activation.html | 48 +++ static/website/templates/cfp.html | 65 +++- static/website/templates/comment-abstract.html | 11 +- static/website/templates/login.html | 32 ++ static/website/templates/navbar.html | 19 +- static/website/templates/proposal.html | 122 ++----- static/website/templates/submit-cfp.html | 29 +- static/website/templates/user-register.html | 167 ++++++++-- static/website/templates/view-profile.html | 59 ++++ static/website/templates/view-proposals.html | 1 + website/forms.py | 199 ++++++++++- website/models.py | 62 +++- website/send_mails.py | 435 +++++++++++++++++++++++++ website/urls.py | 7 +- website/views.py | 264 +++++++++------ 18 files changed, 1270 insertions(+), 275 deletions(-) create mode 100755 logs/emailconfig.yaml create mode 100644 static/website/templates/activation.html create mode 100644 static/website/templates/login.html create mode 100644 static/website/templates/view-profile.html create mode 100644 website/send_mails.py diff --git a/logs/emailconfig.yaml b/logs/emailconfig.yaml new file mode 100755 index 0000000..ab0fa3f --- /dev/null +++ b/logs/emailconfig.yaml @@ -0,0 +1,20 @@ +version: 1 +disable_existing_loggers: False + +formatters: + detailed: + format: '%(asctime)s - %(levelname)s - Function: %(funcName)s() - Line: %(lineno)d - %(message)s' + +handlers: + emaillogfile: + level: INFO + class: logging.handlers.RotatingFileHandler + maxBytes: 10000000 #10MB + backupCount: 9 + formatter: detailed + filename: path/to/emailfile.log + +root: + level: INFO + handlers: + - emaillogfile diff --git a/nccps2018/urls.py b/nccps2018/urls.py index 21733fd..b234d88 100644 --- a/nccps2018/urls.py +++ b/nccps2018/urls.py @@ -1,4 +1,4 @@ -"""Scipy2018 URL Configuration +"""NCCPS2018 URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.1/topics/http/urls/ diff --git a/requirements.txt b/requirements.txt index fd6c4e3..3ced17a 100755 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,6 @@ django-recaptcha==1.4.0 idna==2.7 mysqlclient==1.3.13 oauthlib==2.1.0 -pkg-resources==0.0.0 PyJWT==1.6.4 python-social-auth==0.3.6 python3-openid==3.1.0 @@ -17,4 +16,6 @@ six==1.11.0 social-auth-app-django==2.1.0 social-auth-core==1.7.0 urllib3==1.23 +django-widget-tweaks +pyyaml diff --git a/static/website/templates/activation.html b/static/website/templates/activation.html new file mode 100644 index 0000000..b5d8052 --- /dev/null +++ b/static/website/templates/activation.html @@ -0,0 +1,48 @@ +{% extends "base.html" %} +{% load static %} +{% load widget_tweaks %} + +{% csrf_token %} +{% block content %} + {% if status == '2' %} +
+
+

Your email is already verified, Please view your profile here

+ +
+
+ {% elif status == '1' %} + +
+
+

Your activation has expired please register again

+
+
+ {% elif status == '0' %} +
+
+

Your account has been activated. Please view your profile here

+ +
+
+ {% else %} + + +
+
+

Activation Awaiting

+

The Activation Link has been sent to your email. The link expires in 24hours from the date of registration. You will be logged out automatically.

+
+
+ {% endif %} +{% endblock %} diff --git a/static/website/templates/cfp.html b/static/website/templates/cfp.html index 52bf3a5..33535be 100755 --- a/static/website/templates/cfp.html +++ b/static/website/templates/cfp.html @@ -1,3 +1,4 @@ +{% extends "base.html" %} {% load static %} @@ -164,8 +165,66 @@ {% endif %} +{% block content %} +
+
+
+

Call for Papers

+
+
+
+

We invite papers on Chemical Process Modelling, Simulation and Optimization. Time duration for oral presentation will be 15 minutes. Accepted papers will be published in conference proceedings. Award will be given to best paper and best poster.

+

Paper submission starts on September 15 2018.

+
+
+
+
+

+ General guidelines for paper submission: +

+
    +
  • Papers are invited on chemical process, modelling, simulation, and optimization.
  • +
  • Use of open source software such as DWSIM and OpenModelica will be preferred.
  • +
  • Authors must submit the manuscript up to 6 pages of length including tables, figures and references in the required 2-column format as described in the template below.
  • +
  • Multiple submissions from one author is allowed.
  • +
  • Maximum 3 authors for one paper are allowed, in that case only one author should submit a paper on behalf of everyone. All authors should register and book a ticket for the conference. +
  • +
  • Submissions will be judged on originality, significance, interest, clarity, relevance, and presentation.
  • +
  • Authors should ensure that their work doesn’t contain plagiarized content and not under copyright elsewhere.
  • +
  • Please download the appropriate file for structure of the paper. We encourage use of LaTeX for creating paper.
  • +
  • Click the following links for templates + +
  • +
+
+
+

+ Suggested Contents of a paper +

+ +
    +
  • Selection of a topic
  • +
  • Importance of a topic
  • +
  • Any difficulties while solving with open source software.
  • +
  • The methodology followed to overcome these difficulties(any assumptions, data regression, custom modelling, etc.)
  • +
  • Validation of the results with published papers/experimentation/commercial simulators like CHEMCAD, Aspen Plus, UniSim etc.
  • +
  • Sensitivity studies, adjust, some tricks used for faster calculation etc done to optimize results and reduce simulation time.
  • +
+
+ +
+
+
+
+
{% endblock %} - {% include 'footer.html' %} - - diff --git a/static/website/templates/comment-abstract.html b/static/website/templates/comment-abstract.html index b6dd3a2..f77eb3f 100755 --- a/static/website/templates/comment-abstract.html +++ b/static/website/templates/comment-abstract.html @@ -15,10 +15,11 @@

{{ proposal.user.first_name }} {{ proposal.user.last_name }}

-

Title:  {{ proposal.title }}

-

About Me:  {{ proposal.about_me |linebreaks }}

- {% if proposal.proposal_type == "ABSTRACT"%} -

Abstract:  +

Title of the paper:  {{ proposal.title }}

+

Name of the author(s):  {{proposal.name_of_authors}}

+

About the Author(s):  {{ proposal.about_the_authors |linebreaks }}

+

Duration:  {{ proposal.duration }} {% if proposal.proposal_type == "ABSTRACT"%} Mins {% else %}Hours {%endif%}

{% if proposal.proposal_type == "ABSTRACT"%}

Tags:  {{ proposal.tags }}

diff --git a/static/website/templates/login.html b/static/website/templates/login.html new file mode 100644 index 0000000..65da512 --- /dev/null +++ b/static/website/templates/login.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} +{% load static %} +{% block content %} +
+
+
+
+
+

Login

+

Login/Register to Submit a paper

+ {% if invalid %} +

* Invalid Username/Password

+ {% endif %} +
+ {% csrf_token %} + {{ form.as_p }} + +
+
+ Create an Account + +
+ Forgot Password? +
+

+
+
+
+
+
+{% endblock %} + diff --git a/static/website/templates/navbar.html b/static/website/templates/navbar.html index ce70dcc..001fce8 100644 --- a/static/website/templates/navbar.html +++ b/static/website/templates/navbar.html @@ -39,12 +39,23 @@
  • Venue
  • Organiser
  • Contact Us
  • +
  • cfp
  • {% if user.is_authenticated %} -
  • - {{ user.username }}!
  • -
  • logout
  • + + {% else %} -
  • cfp
  • + +
  • Login
  • {% endif %} diff --git a/static/website/templates/proposal.html b/static/website/templates/proposal.html index c6b51c3..1f7d4a0 100644 --- a/static/website/templates/proposal.html +++ b/static/website/templates/proposal.html @@ -6,7 +6,7 @@
    {% if user and not user.is_anonymous %} -

    Submit Proposal

    +

    Submit paper

    {% else %}

    Login

    {% endif %} @@ -32,113 +32,33 @@

    {% endif %} {% if user and not user.is_anonymous and not login_required %} -

    We invite you to submit proposals for talks or workshops to be presented at SciPy 2018 The time duration for talks is 15 or 30 minutes and for workshops is 2 to 4 hours. There will be two parallel tracks for the workshops this year. One track - is meant for beginners and the other is for advanced users. -

    +

    We invite papers on Chemical Process Modelling, Simulation and Optimization. Time duration for oral presentation will be 15 minutes. Accepted papers will be published in conference proceedings. Award will be given to best paper and best poster.

    Important Dates

    -
    {% if user.is_superuser %} -
    - View Proposals - Submit Proposal - Submit Workshop -
    - {% else %} -
    - View Proposals -
    - {% endif %} {% else %} - -
    -
    -
    - -

    - Login -

    -
    -

    Login/Register to Submit a Proposal

    - {% if invalid %} -

    * Invalid Username/Password

    - {% endif %} - -
    - {{ form.as_p }} - -

    - Create an Account -
    - Forgot Password? {% csrf_token %} -
    - -

    Or Sign in with: 
    - - -   - - - -

    -
    -

    -

    - Important Dates -

    - - -
    - -
    -
    -

    - Guidelines for a Proposal -

    - -
    -
    -
    -

    - Guidelines for a Workshop -

    - - -
    - -
    +
    + {% if user.is_superuser %} +
    + View Proposals + Submit paper + +
    + {% else %} +
    + View Proposals + Submit paper + +
    + {% endif %} + {% else %} + diff --git a/static/website/templates/submit-cfp.html b/static/website/templates/submit-cfp.html index b3aa2ee..b31658d 100755 --- a/static/website/templates/submit-cfp.html +++ b/static/website/templates/submit-cfp.html @@ -6,23 +6,24 @@
    {% if proposals_a >= 1 %} You have exceeded the abstract submission limit. You may view your submitted proposals by clicking here - {% else %}
    + {% else %}
    -

    Submit Proposal

    +

    Submit paper


    -

    Proposal Guidelines

    - +

    + General guidelines for paper submission: +

    +
    -
    {% for field in proposal_form %}

    {{ field.label}} {% if field.field.required %} * {% endif %} {{ field }} @@ -32,7 +33,7 @@ {% csrf_token %}

    - Back + Back
    {% endif %} diff --git a/static/website/templates/user-register.html b/static/website/templates/user-register.html index c5ea301..3d8d38f 100755 --- a/static/website/templates/user-register.html +++ b/static/website/templates/user-register.html @@ -1,43 +1,150 @@ {% extends "base.html" %} {% load static %} +{% load widget_tweaks %}
    {% block content %}
    -

    Register

    +

    Sign Up

    - {% if email_registered %} -
    -
    - × -

    Email ID is already registered !

    -
    -

    Have you already logged in using social logins ?

    -

    or

    -

    Click Here if you forgot your username or password

    -
    - {% endif %} - {% if registration_complete %} -

    Your Account is Created Successfully !

    - {% endif %} - -
    - +{% if form.errors %} + {% for field in form %} + {% for error in field.errors %} +
    + {{ error|escape }} +
    + {% endfor %} + {% endfor %} +{% endif %} + {% csrf_token %} - {% for field in form %} -

    {{ field.label}} - {% if field.field.required %} * {% endif %} - {{ field }} -

    - {{ field.errors }} - {% endfor %} -
    - - I have an account + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + + * +
    +
    +
    + {% render_field form.username %} +
    +
    +
    + + * +
    +
    +
    + {% render_field form.email %} +
    +
    +
    + * +
    +
    +
    + {% render_field form.password %} +
    +
    +
    + * +
    +
    +
    + {% render_field form.confirm_password %} +
    +
    +
    + * +
    +
    +
    + {% render_field form.title %}{% render_field form.first_name %} {% render_field form.last_name %} +
    +
    +
    + * +
    +
    +
    + {% render_field form.phone_number %} +
    +
    +
    + * +
    +
    +
    + {% render_field form.institute %}
    Enter your institute/ organisation/ company +
    +
    +
    + * +
    +
    +
    + {% render_field form.how_did_you_hear_about_us %} +
    +
    +
    + * marked fields are mandatory. Please enter the correct information. It will help us to solve your issues in short timespan. +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/static/website/templates/view-profile.html b/static/website/templates/view-profile.html new file mode 100644 index 0000000..844a2ba --- /dev/null +++ b/static/website/templates/view-profile.html @@ -0,0 +1,59 @@ +{% extends "base.html" %} +{% load static %} + {% block content %} +
    +
    + {% if user and not user.is_anonymous %} +

    Welcome {{ user.username }}

    + {% endif %} +
    +
    + {% if user.is_superuser %} +
    + +
    +
    + + + {% else %} + +
    +

    +
    + + + {% endif %} + + +
    +
    + +

    + Important Dates +

    +
    +
      +
    • Last date for paper submission: 28/09/2018
    • +
    • Notification of acceptance: 22/10/2018
    • +
    • Last date for final paper submission: 02/11/2018
    • +
    +
    + +
    +
    +
    +{% endblock %} diff --git a/static/website/templates/view-proposals.html b/static/website/templates/view-proposals.html index bdb39f7..89be03d 100755 --- a/static/website/templates/view-proposals.html +++ b/static/website/templates/view-proposals.html @@ -122,6 +122,7 @@ {% endfor %}

    + Back

    diff --git a/website/forms.py b/website/forms.py index 8690ff7..7999dea 100755 --- a/website/forms.py +++ b/website/forms.py @@ -7,8 +7,23 @@ from django.contrib.auth.models import User from django.core.validators import MinLengthValidator, MinValueValidator, \ RegexValidator, URLValidator from captcha.fields import ReCaptchaField +from string import punctuation, digits +try: + from string import letters +except ImportError: + from string import ascii_letters as letters from website.models import Proposal +from website.send_mails import generate_activation_key +from django.contrib.auth.models import User +from django.contrib.auth import authenticate +from django.utils import timezone +from website.models import ( + Profile, User +) + +UNAME_CHARS = letters + "._" + digits +PWD_CHARS = letters + punctuation + digits MY_CHOICES = ( ('Beginner', 'Beginner'), @@ -22,7 +37,6 @@ ws_duration = ( ) abs_duration = ( ('15', '15'), - ('30', '30'), ) @@ -46,43 +60,101 @@ rating = ( CHOICES = [('1', 'Yes'), ('0', 'No')] +position_choices = ( + ("student", "Student"), + ("faculty", "Faculty"), + ("industry_people", "Industry People"), +) + +source = ( + ("FOSSEE website", "FOSSEE website"), + ("Google", "Google"), + ("Social Media", "Social Media"), + ("From other College", "From other College"), +) + +title = ( + ("Mr", "Mr."), + ("Miss", "Ms."), + ("Professor", "Prof."), + ("Doctor", "Dr."), +) +states = ( + ("IN-AP", "Andhra Pradesh"), + ("IN-AR", "Arunachal Pradesh"), + ("IN-AS", "Assam"), + ("IN-BR", "Bihar"), + ("IN-CT", "Chhattisgarh"), + ("IN-GA", "Goa"), + ("IN-GJ", "Gujarat"), + ("IN-HR", "Haryana"), + ("IN-HP", "Himachal Pradesh"), + ("IN-JK", "Jammu and Kashmir"), + ("IN-JH", "Jharkhand"), + ("IN-KA", "Karnataka"), + ("IN-KL", "Kerala"), + ("IN-MP", "Madhya Pradesh"), + ("IN-MH", "Maharashtra"), + ("IN-MN", "Manipur"), + ("IN-ML", "Meghalaya"), + ("IN-MZ", "Mizoram"), + ("IN-NL", "Nagaland"), + ("IN-OR", "Odisha"), + ("IN-PB", "Punjab"), + ("IN-RJ", "Rajasthan"), + ("IN-SK", "Sikkim"), + ("IN-TN", "Tamil Nadu"), + ("IN-TG", "Telangana"), + ("IN-TR", "Tripura"), + ("IN-UT", "Uttarakhand"), + ("IN-UP", "Uttar Pradesh"), + ("IN-WB", "West Bengal"), + ("IN-AN", "Andaman and Nicobar Islands"), + ("IN-CH", "Chandigarh"), + ("IN-DN", "Dadra and Nagar Haveli"), + ("IN-DD", "Daman and Diu"), + ("IN-DL", "Delhi"), + ("IN-LD", "Lakshadweep"), + ("IN-PY", "Puducherry") +) + # modal proposal form for cfp class ProposalForm(forms.ModelForm): - - about_me = forms.CharField(widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'About Me'}), + name_of_authors = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'First Author, Second Author, Third Author'}), + required=True, + error_messages={ + 'required': 'Name of authors field required.'}, + ) + about_the_authors = forms.CharField(widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'About the author(s)'}), required=True, error_messages={ - 'required': 'About me field required.'}, + 'required': 'About the 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',)], + required=True,) + phone = forms.CharField(min_length=10, max_length=10, widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Enter your valid contact number'}), 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'}), + title = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Enter the title of your paper'}), required=True, error_messages={ 'required': 'Title field required.'}, ) - abstract = forms.CharField(min_length=300, widget=forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'Abstract', 'onkeyup': 'countChar(this)'}), - required=True, - label='Abstract (Min. 300 char.)', - error_messages={ - 'required': 'Abstract field required.'}, - ) + abstract = forms.CharField(widget= forms.HiddenInput(),required=False, label='') proposal_type = forms.CharField( widget=forms.HiddenInput(), label='', initial='ABSTRACT', required=False) - duration = forms.ChoiceField( - choices=abs_duration, label='Duration (Mins.)') + duration = forms.ChoiceField(widget=forms.Select(attrs={'readonly': True}), choices=abs_duration, required=True) + #duration = forms.ChoiceField(choices=abs_duration, widget=forms.ChoiceField(attrs={'readonly': True}), + # label='Duration (Mins.)') tags = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Tags'}), required=False, ) open_to_share = forms.ChoiceField(choices=CHOICES, widget=forms.RadioSelect(), required=True, - label='I am agree to publish my content',) + label='I agree to publish my content',) class Meta: model = Proposal @@ -131,7 +203,7 @@ class WorkshopForm(forms.ModelForm): proposal_type = forms.CharField( widget=forms.HiddenInput(), label='', required=False, initial='WORKSHOP') - duration = forms.ChoiceField(choices=ws_duration, label='Duration (Hrs.)') + #duration = forms.ChoiceField(choices=ws_duration, label='Duration (Hrs.)') tags = forms.ChoiceField(choices=MY_CHOICES, label='Level') open_to_share = forms.ChoiceField(choices=CHOICES, widget=forms.RadioSelect(), required=True, @@ -212,4 +284,95 @@ class UserLoginForm(forms.Form): widget=forms.PasswordInput( attrs={'class': 'form-inline', 'placeholder': 'Password'}), label='Password' - ) \ No newline at end of file + ) + + +class UserRegistrationForm(forms.Form): + """A Class to create new form for User's Registration. + It has the various fields and functions required to register + a new user to the system""" + required_css_class = 'required' + errorlist_css_class = 'errorlist' + username = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Enter user name'}), max_length=32, help_text='''Letters, digits, + period and underscore only.''',) + email = forms.EmailField(widget=forms.TextInput( + attrs={'placeholder': 'Enter valid email id'})) + password = forms.CharField(max_length=32, widget=forms.PasswordInput()) + confirm_password = forms.CharField(max_length=32, widget=forms.PasswordInput()) + title = forms.ChoiceField(choices=title) + first_name = forms.CharField(max_length=32, label='First name', widget=forms.TextInput( + attrs={'placeholder': 'Enter first name'})) + last_name = forms.CharField(max_length=32, label='Last name', widget=forms.TextInput( + attrs={'placeholder': 'Enter last name'},)) + phone_number = forms.RegexField(regex=r'^.{10}$', + error_messages={'invalid': "Phone number must be entered \ + in the format: '9999999999'.\ + Up to 10 digits allowed."}, label='Phone/Mobile', widget=forms.TextInput(attrs={'placeholder': 'Enter valid contact number'},)) + institute = forms.CharField(max_length=32, + label='Institute/Organization/Company', widget=forms.TextInput()) + # department = forms.ChoiceField(help_text='Department you work/study', + # choices=department_choices) + #location = forms.CharField(max_length=255, help_text="Place/City") + #state = forms.ChoiceField(choices=states) + how_did_you_hear_about_us = forms.ChoiceField( + choices=source, label='How did you hear about us?') + + def clean_username(self): + u_name = self.cleaned_data["username"] + if u_name.strip(UNAME_CHARS): + msg = "Only letters, digits, period are"\ + " allowed in username" + raise forms.ValidationError(msg) + try: + User.objects.get(username__exact=u_name) + raise forms.ValidationError("Username already exists.") + except User.DoesNotExist: + return u_name + + def clean_password(self): + pwd = self.cleaned_data['password'] + if pwd.strip(PWD_CHARS): + raise forms.ValidationError("Only letters, digits and punctuation\ + are allowed in password") + return pwd + + def clean_confirm_password(self): + c_pwd = self.cleaned_data['confirm_password'] + pwd = self.data['password'] + if c_pwd != pwd: + raise forms.ValidationError("Passwords do not match") + + return c_pwd + + def clean_email(self): + user_email = self.cleaned_data['email'] + if User.objects.filter(email=user_email).exists(): + raise forms.ValidationError("This email already exists") + return user_email + + def save(self): + u_name = self.cleaned_data["username"] + u_name = u_name.lower() + pwd = self.cleaned_data["password"] + email = self.cleaned_data["email"] + new_user = User.objects.create_user(u_name, email, pwd) + new_user.first_name = self.cleaned_data["first_name"] + new_user.last_name = self.cleaned_data["last_name"] + new_user.save() + + cleaned_data = self.cleaned_data + new_profile = Profile(user=new_user) + new_profile.institute = cleaned_data["institute"] + #new_profile.department = cleaned_data["department"] + #new_profile.position = cleaned_data["position"] + new_profile.phone_number = cleaned_data["phone_number"] + #new_profile.location = cleaned_data["location"] + new_profile.title = cleaned_data["title"] + #new_profile.state = cleaned_data["state"] + new_profile.how_did_you_hear_about_us = cleaned_data["how_did_you_hear_about_us"] + new_profile.activation_key = generate_activation_key(new_user.username) + new_profile.key_expiry_time = timezone.now() + \ + timezone.timedelta(days=1) + new_profile.save() + key = Profile.objects.get(user=new_user).activation_key + return u_name, pwd, key \ No newline at end of file diff --git a/website/models.py b/website/models.py index b73446b..f5b004a 100644 --- a/website/models.py +++ b/website/models.py @@ -3,8 +3,29 @@ from django.contrib.auth.models import User from social.apps.django_app.default.models import UserSocialAuth from nccps2018 import settings +from django.core.validators import RegexValidator import os +position_choices = ( + ("student", "Student"), + ("faculty", "Faculty"), + ("industry_people", "Industry People"), +) + +source = ( + ("FOSSEE website", "FOSSEE website"), + ("Google", "Google"), + ("Social Media", "Social Media"), + ("From other College", "From other College"), +) + +title = ( + ("Mr", "Mr."), + ("Miss", "Ms."), + ("Professor", "Prof."), + ("Doctor", "Dr."), +) + def get_document_dir(instance, filename): # ename, eext = instance.user.email.split("@") @@ -15,11 +36,12 @@ def get_document_dir(instance, filename): class Proposal(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE,) - about_me = models.TextField(max_length=500) + name_of_authors = models.CharField(max_length=200, default='None') + about_the_authors = 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) + abstract = models.TextField(max_length=10, default='abstract') prerequisite = models.CharField(max_length=750) duration = models.CharField(max_length=100) attachment = models.FileField(upload_to=get_document_dir) @@ -41,4 +63,38 @@ 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) \ No newline at end of file + # rate = models.CharField(max_length =100) + +# profile module + + +class Profile(models.Model): + """Profile for users""" + + user = models.OneToOneField(User, on_delete=models.CASCADE) + title = models.CharField(max_length=32, blank=True, choices=title) + institute = models.CharField(max_length=150) + phone_number = models.CharField( + max_length=10, + validators=[RegexValidator( + regex=r'^.{10}$', message=( + "Phone number must be entered \ + in the format: '9999999999'.\ + Up to 10 digits allowed.") + )], null=False) + position = models.CharField(max_length=32, choices=position_choices, + default='student', + help_text='Selected catagoery ID shold be required') + how_did_you_hear_about_us = models.CharField( + max_length=255, blank=True, choices=source) + is_email_verified = models.BooleanField(default=False) + activation_key = models.CharField(max_length=255, blank=True, null=True) + key_expiry_time = models.DateTimeField(blank=True, null=True) + + def __str__(self): + return u"id: {0}| {1} {2} | {3} ".format( + self.user.id, + self.user.first_name, + self.user.last_name, + self.user.email + ) \ No newline at end of file diff --git a/website/send_mails.py b/website/send_mails.py new file mode 100644 index 0000000..3f83c78 --- /dev/null +++ b/website/send_mails.py @@ -0,0 +1,435 @@ +__author__ = "Akshen Doke" + +import hashlib +import logging +import logging.config +import yaml +import re +from django.core.mail import send_mail +from textwrap import dedent +from random import randint +from smtplib import SMTP +from django.utils.crypto import get_random_string +from string import punctuation, digits +try: + from string import letters +except ImportError: + from string import ascii_letters as letters +from nccps2018.config import ( + EMAIL_HOST, + EMAIL_PORT, + EMAIL_HOST_USER, + EMAIL_HOST_PASSWORD, + EMAIL_USE_TLS, + PRODUCTION_URL, + SENDER_EMAIL, + ADMIN_EMAIL +) +from django.core.mail import EmailMultiAlternatives +from django.conf import settings +from os import listdir, path +from email.mime.multipart import MIMEMultipart +from email.mime.text import MIMEText +from email.mime.base import MIMEBase +from email import encoders +from time import sleep +from nccps2018.settings import LOG_FOLDER + + +def validateEmail(email): + if len(email) > 7: + if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", + email) != None: + return 1 + return 0 + + +def generate_activation_key(username): + """Generates hashed secret key for email activation""" + chars = letters + digits + punctuation + secret_key = get_random_string(randint(10, 40), chars) + return hashlib.sha256((secret_key + username).encode('utf-8')).hexdigest() + + +def send_smtp_email(request=None, subject=None, message=None, + user_position=None, workshop_date=None, + workshop_title=None, user_name=None, + other_email=None, phone_number=None, + institute=None, attachment=None): + ''' + Send email using SMTPLIB + ''' + + msg = MIMEMultipart() + msg['From'] = EMAIL_HOST_USER + msg['To'] = other_email + msg['Subject'] = subject + body = message + msg.attach(MIMEText(body, 'plain')) + + if attachment: + from django.conf import settings + from os import listdir, path + files = listdir(settings.MEDIA_ROOT) + for f in files: + attachment = open(path.join(settings.MEDIA_ROOT, f), 'rb') + part = MIMEBase('application', 'octet-stream') + part.set_payload((attachment).read()) + encoders.encode_base64(part) + part.add_header('Content-Disposition', + "attachment; filename= %s " % f) + msg.attach(part) + + server = SMTP(EMAIL_HOST, EMAIL_PORT) + server.ehlo() + server.starttls() + server.ehlo() + server.esmtp_features['auth'] = 'LOGIN DIGEST-MD5 PLAIN' + server.login(EMAIL_HOST_USER, EMAIL_HOST_PASSWORD) + text = msg.as_string() + server.sendmail(EMAIL_HOST_USER, other_email, text) + server.close() + + +def send_email(request, call_on, + user_position=None, workshop_date=None, + new_workshop_date=None, + workshop_title=None, user_name=None, + other_email=None, phone_number=None, + institute=None, key=None + ): + ''' + Email sending function while registration and + booking confirmation. + ''' + try: + with open(path.join(LOG_FOLDER, 'emailconfig.yaml'), 'r') as configfile: + config_dict = yaml.load(configfile) + logging.config.dictConfig(config_dict) + except: + print('File Not Found and Configuration Error') + print(LOG_FOLDER) + if call_on == "Registration": + message = dedent("""\ + Thank you for registering with us. + + Please click on the below link to + activate your account + {0}/activate_user/{1} + + After activation you can proceed to book your ticket for + the conference/ propose a paper. + + In case of queries regarding ticket booking and proposing a paper, + revert to this email.""".format(PRODUCTION_URL, key)) + + logging.info("New Registration from: %s", request.user.email) + try: + send_mail( + "NCCPS-2018 Registration at FOSSEE, IIT Bombay", message, SENDER_EMAIL, + [request.user.email], fail_silently=True + ) + + except Exception: + send_smtp_email(request=request, + subject="NCCPS-2018 Registration - FOSSEE, IIT Bombay", + message=message, other_email=request.user.email, + ) + + elif call_on == "Booking": + if user_position == "instructor": + message = dedent("""\ + Coordinator name:{0} + Coordinator email: {1} + Contact number:{2} + Institute:{3} + Workshop date:{4} + Workshop title:{5} + + You may accept or reject this booking + {6}/my_workshops/ .""".format( + user_name, request.user.email, + request.user.profile.phone_number, + request.user.profile.institute, + workshop_date, workshop_title, + PRODUCTION_URL + )) + + logging.info("Booking Done by{0} for {1} ".format(request.user.email, + other_email)) + try: + send_mail( + "New FOSSEE Workshop booking on {0}".format(workshop_date), + message, SENDER_EMAIL, [other_email], + fail_silently=True + ) + except Exception: + send_smtp_email(request=request, + subject="New FOSSEE Workshop booking on {0}" + .format(workshop_date), + message=message, other_email=other_email, + ) + else: + message = dedent("""\ + Thank You for New FOSSEE Workshop booking. + + Workshop date:{0} + Workshop title:{1} + + Your request has been received and is awaiting instructor + approval/disapproval. You will be notified about the status + via email and on {2}/my_workshops/ + + Please Note: Unless you get a confirmation email for this workshop with + the list of instructions, your workshop shall be in the waiting list. + + In case of queries regarding workshop booking(s), revert + to this email.""".format( + workshop_date, workshop_title, PRODUCTION_URL + )) + + try: + send_mail( + "Pending Request for New FOSSEE Workshop booking on {0}" + .format(workshop_date), message, SENDER_EMAIL, + [request.user.email], fail_silently=True + ) + except Exception: + send_smtp_email(request=request, + subject="Pending Request for New FOSSEE Workshop booking \ + on {0}".format(workshop_date), + message=message, other_email=request.user.email, + ) + + elif call_on == "Booking Confirmed": + if user_position == "instructor": + message = dedent("""\ + Coordinator name:{0} + Coordinator email: {1} + Contact number:{2} + Institute:{3} + Workshop date:{4} + Workshop title:{5} + + You have accepted this booking. Detailed instructions have + been sent to the coordinator. + + This is a auto-generated mail. + """.format(user_name, other_email, + phone_number, institute, workshop_date, workshop_title)) + + logging.info("Booking Confirmed by {0} for {1} ".format(request.user.email, + other_email)) + + subject = "FOSSEE Workshop booking confirmation on {0}".\ + format(workshop_date) + msg = EmailMultiAlternatives( + subject, message, SENDER_EMAIL, [request.user.email]) + attachment_paths = path.join( + settings.MEDIA_ROOT, workshop_title.replace(" ", "_")) + files = listdir(attachment_paths) + for f in files: + attachment = open(path.join(attachment_paths, f), 'rb') + part = MIMEBase('application', 'octet-stream') + part.set_payload((attachment).read()) + encoders.encode_base64(part) + part.add_header('Content-Disposition', + "attachment; filename= %s " % f) + msg.attach(part) + sleep(1) + msg.send() + + else: + message = dedent("""\ + Instructor name:{0} + Instructor email: {1} + Contact number:{2} + Workshop date:{3} + Workshop title:{4} + + Your workshop booking has been accepted. Detailed + instructions are attached below. + + In case of queries regarding the workshop + instructions/schedule revert to this email.""".format( + request.user.username, request.user.email, + phone_number, workshop_date, workshop_title + )) + + subject = "FOSSEE Workshop booking confirmation on {0}".\ + format(workshop_date) + msg = EmailMultiAlternatives( + subject, message, SENDER_EMAIL, [other_email]) + attachment_paths = path.join( + settings.MEDIA_ROOT, workshop_title.replace(" ", "_")) + files = listdir(attachment_paths) + for f in files: + attachment = open(path.join(attachment_paths, f), 'rb') + part = MIMEBase('application', 'octet-stream') + part.set_payload((attachment).read()) + encoders.encode_base64(part) + part.add_header('Content-Disposition', + "attachment; filename= %s " % f) + msg.attach(part) + msg.send() + + elif call_on == "Booking Request Rejected": + if user_position == "instructor": + message = dedent("""\ + Coordinator name: {0} + Coordinator email: {1} + Contact number: {2} + Institute: {3} + Workshop date: {4} + Workshop title: {5} + + You have rejected this booking. The coordinator has + been notified. + + This is a auto-generated mail. + """.format(user_name, other_email, + phone_number, institute, + workshop_date, workshop_title)) + + logging.info("Booking Rejected by {0} for {1} ".format(request.user.email, + other_email)) + + try: + send_mail("FOSSEE Workshop booking rejected for {0}" + .format(workshop_date), message, SENDER_EMAIL, + [request.user.email], fail_silently=True) + except Exception: + send_smtp_email(request=request, + subject="FOSSEE Workshop booking rejected for {0}". + format(workshop_date), message=message, + other_email=request.user.email + ) + else: + message = dedent("""\ + Workshop date:{0} + Workshop title:{1} + + We regret to inform you that your workshop booking + has been rejected due to unavailability of the + instructor. You may try booking other available + slots {2}/book/ or you can also Propose a workshop + based on your available date. + + This is a auto-generated mail. + """ + .format(workshop_date, workshop_title, PRODUCTION_URL)) + + try: + send_mail("FOSSEE Workshop booking rejected for {0}". + format(workshop_date), message, SENDER_EMAIL, + [other_email], fail_silently=True) + except Exception: + send_smtp_email(request=request, + subject="FOSSEE Workshop booking rejected for {0}". + format(workshop_date), message=message, + other_email=other_email + ) + + elif call_on == 'Workshop Deleted': + message = dedent("""\ + You have deleted a Workshop. + + Workshop date:{0} + Workshop title:{1} + + This is a auto-generated mail. + """ + .format(workshop_date, workshop_title)) + + logging.info("Workshop Deleted by {0} for {1} ".format(request.user.email, + workshop_date)) + try: + send_mail("FOSSEE workshop deleted for {0}".format(workshop_date), + message, SENDER_EMAIL, [request.user.email], + fail_silently=True) + except Exception: + send_smtp_email(request=request, + subject="FOSSEE Workshop deleted for {0}". + format(workshop_date), message=message, + other_email=request.user.email + ) + + elif call_on == 'Proposed Workshop': + if user_position == "instructor": + message = dedent("""\ + A coordinator has proposed a workshop. The details are + given below: + + Coordinator name: {0} + Coordinator email: {1} + Contact number: {2} + Institute: {3} + Workshop date: {4} + Workshop title: {5} + + Please Accept only if you are willing to take the workshop. + {6}/my_workshops/ + + This is a auto-generated mail. + """ + .format(user_name, request.user.email, + phone_number, institute, + workshop_date, workshop_title, + PRODUCTION_URL)) + + logging.info("Workshop Proposed by {0} for {1} ".format(request.user.email, + workshop_date)) + + send_mail("Proposed Workshop on {0}". + format(workshop_date), message, SENDER_EMAIL, + [other_email], fail_silently=False) + + elif call_on == 'Change Date': + if user_position == "instructor": + message = dedent("""\ + Dear Instructor, + + Your workshop date has been changed from {0} to {1}. + + This is a auto-generated mail. + """ + .format( + workshop_date, new_workshop_date)) + + logging.info("Workshop Date Changed Done by {0} from {1} to {2}" + .format(request.user.email, + new_workshop_date, workshop_date)) + try: + send_mail( + "FOSSEE Python Workshop Date Changed", + message, SENDER_EMAIL, [request.user.email], + fail_silently=True + ) + except Exception: + send_smtp_email(request=request, + subject="FOSSEE Python Workshop Date Changed", + message=message, other_email=other_email, + ) + else: + message = dedent("""\ + Dear Coordinator, + + Your workshop has been rescheduled from {0} to {1}. + + This is a auto-generated mail. + """ + .format( + workshop_date, new_workshop_date + )) + + try: + send_mail( + "FOSSEE Python Workshop Date Changed", + message, SENDER_EMAIL, + [other_email], fail_silently=True + ) + except Exception: + send_smtp_email(request=request, + subject="FOSSEE Python Workshop Date Changed", + message=message, other_email=request.user.email, + ) diff --git a/website/urls.py b/website/urls.py index 8568004..4d95ab7 100644 --- a/website/urls.py +++ b/website/urls.py @@ -6,7 +6,8 @@ app_name = 'website' urlpatterns = [ #path('', views.index, name='index'), re_path(r'^$', views.index, name='index'), - #path('proposal', views.proposal, name='proposal'), + re_path(r'^view_profile/$', views.view_profile, name='view_profile'), + re_path(r'^proposal/$', views.proposal, name='proposal'), #path('login', views.login, name='login'), #path('accounts/', include('django.contrib.auth.urls')), #re_path(r'^', include('django.contrib.auth.urls')), @@ -20,8 +21,8 @@ urlpatterns = [ re_path(r'^submit-cfw/$', views.submitcfw, name='submitcfw'), #url(r'^submit-cfp/$', 'website.views.cfp', name='home'), #url(r'^submit-cfw/$', 'website.views.home', name='home'), - re_path(r'^accounts/register/$', views.userregister, name='userregister'), - re_path(r'^accounts/login/$', views.cfp, name='cfp'), + re_path(r'^accounts/register/$', views.user_register, name='user_register'), + re_path(r'^accounts/login/$', views.user_login, name='user_login'), re_path(r'^gallery/$', views.gallery, name='gallery'), # url(r'^view-abstracts/$', 'website.views.view_abstracts', name='view_abstracts'), re_path(r'^view-abstracts/$', views.view_abstracts, name='view_abstracts'), diff --git a/website/views.py b/website/views.py index f665868..f081617 100644 --- a/website/views.py +++ b/website/views.py @@ -2,16 +2,20 @@ from django.http import HttpResponse from django.shortcuts import render -from django.shortcuts import render_to_response, render +from django.shortcuts import render_to_response, render, redirect 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, csrf_protect +from django.views.decorators.cache import cache_page +from django.views.decorators.csrf import (csrf_exempt, csrf_protect, + ensure_csrf_cookie, + requires_csrf_token) 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 +from website.forms import (ProposalForm, UserRegisterForm, UserRegistrationForm, + UserLoginForm, WorkshopForm) # ,ContactForm from website.models import Proposal, Comments, Ratings from social.apps.django_app.default.models import UserSocialAuth from django.contrib.auth import authenticate, login, logout @@ -19,6 +23,18 @@ from django.contrib.auth import authenticate, login, logout from django.core.mail import EmailMultiAlternatives import os from nccps2018.config import * +from website.send_mails import send_email + + +def is_email_checked(user): + if hasattr(user, 'profile'): + return True if user.profile.is_email_verified else False + else: + return False + + +def is_superuser(user): + return True if user.is_superuser else False def index(request): @@ -26,6 +42,11 @@ def index(request): template = loader.get_template('index.html') return HttpResponse(template.render(context, request)) +def cfp(request): + context = {} + template = loader.get_template('cfp.html') + return HttpResponse(template.render(context, request)) + # def proposal(request): # context = {} # template = loader.get_template('proposal.html') @@ -145,35 +166,40 @@ def view_abstracts(request): return render(request, 'cfp.html', context) -@csrf_protect -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) +@requires_csrf_token +def user_login(request): + user = request.user + if request.user.is_authenticated: + return redirect('/proposal/') else: - form = UserLoginForm() - context = {'request': request, - 'user': request.user, - 'form': form, - } - template = loader.get_template('cfp.html') - return HttpResponse(template.render(context, request)) + if request.method == "POST": + context = {} + username = request.POST.get('username', None) + password = request.POST.get('password', None) + user = authenticate(username=username, password=password) + #proposals_a = Proposal.objects.filter( + # user=request.user, proposal_type='ABSTRACT').count() + if user is not None: + login(request, user) + proposals = Proposal.objects.filter(user=request.user).count() + context['user'] = user + return redirect('/proposal') + #template = loader.get_template('index.html') + #return render(request, 'index.html', context) + else: + context['invalid'] = True + context['form'] = UserLoginForm + context['user'] = user + #context['proposals_a'] = proposals_a + return render(request, 'login.html', context) + else: + form = UserLoginForm() + context = {'request': request, + 'user': request.user, + 'form': form, + } + template = loader.get_template('login.html') + return HttpResponse(template.render(context, request)) @csrf_protect @@ -195,20 +221,20 @@ def submitcfp(request): data.email = social_user.email data.save() context['proposal_submit'] = True - sender_name = "SciPy India 2018" + sender_name = "NCCPS 2018" sender_email = TO_EMAIL - subject = "SciPy India 2018 – Talk Proposal Submission Acknowledgment" + subject = "NCCPS 2018 – Talk Proposal Submission Acknowledgment" to = (social_user.email, TO_EMAIL) message = """ Dear {0},

    - Thank you for showing interest & submitting a talk proposal at SciPy India 2018 conference for the talk titled “{1}”. Reviewal of the proposals will start once the CFP closes. + Thank you for showing interest & submitting a talk proposal at NCCPS 2018 conference for the talk titled “{1}”. Reviewal of the proposals will start once the CFP closes.

    You will be notified regarding comments/selection/rejection of your talk via email. Visit this {2} link to view status of your submission. -
    Thank You !

    Regards,
    SciPy India 2018,
    FOSSEE - IIT Bombay. +
    Thank You !

    Regards,
    NCCPS 2018,
    FOSSEE - IIT Bombay. """.format( social_user.first_name, request.POST.get('title', None), - 'http://scipy.in/2018/view-abstracts/',) + 'http://dwsim.fossee.in/2018/view-abstracts/',) email = EmailMultiAlternatives( subject, '', sender_email, to, @@ -216,7 +242,7 @@ def submitcfp(request): ) email.attach_alternative(message, "text/html") email.send(fail_silently=True) - return render_to_response('cfp.html', context) + return render_to_response('proposal.html', context) else: context['proposal_form'] = form context['proposals_a'] = proposals_a @@ -250,20 +276,20 @@ def submitcfw(request): data.email = social_user.email data.save() context['proposal_submit'] = True - sender_name = "SciPy India 2018" + sender_name = "NCCPS 2018" sender_email = TO_EMAIL - subject = "SciPy India 2018 – Workshop Proposal Submission Acknowledgment" + subject = "NCCPS 2018 – Workshop Proposal Submission Acknowledgment" to = (social_user.email, TO_EMAIL) message = """ Dear {0},

    - Thank you for showing interest & submitting a workshop proposal at SciPy India 2018 conference for the workshop titled “{1}”. Reviewal of the proposals will start once the CFP closes. + Thank you for showing interest & submitting a workshop proposal at NCCPS 2018 conference for the workshop titled “{1}”. Reviewal of the proposals will start once the CFP closes.

    You will be notified regarding comments/selection/rejection of your workshop via email. Visit this {2} link to view status of your submission. -
    Thank You !

    Regards,
    SciPy India 2018,
    FOSSEE - IIT Bombay. +
    Thank You !

    Regards,
    NCCPS 2018,
    FOSSEE - IIT Bombay. """.format( social_user.first_name, request.POST.get('title', None), - 'http://scipy.in/2018/view-abstracts/',) + 'http://dwsim.fossee.in/nccps-2018/view-abstracts/',) email = EmailMultiAlternatives( subject, '', sender_email, to, @@ -436,35 +462,35 @@ def comment_abstract(request, proposal_id=None): comment.proposal = proposal comment.save() comments = Comments.objects.filter(proposal=proposal) - sender_name = "SciPy India 2018" + sender_name = "NCCPS 2018" sender_email = TO_EMAIL to = (proposal.user.email, TO_EMAIL) if proposal.proposal_type == 'ABSTRACT': - subject = "SciPy India 2018 - Comment on Your talk Proposal" + subject = "NCCPS 2018 - Comment on Your talk Proposal" message = """ Dear {0},

    There is a comment posted on your proposal for the talk titled {1}.
    Once we receive your response, you will be notified regarding further comments/acceptance/ rejection of your talk/workshop via email. Visit this link {2} to view comments on your submission.

    - Thank You !

    Regards,
    SciPy India 2018,
    FOSSEE - IIT Bombay. + Thank You !

    Regards,
    NCCPS 2018,
    FOSSEE - IIT Bombay. """.format( proposal.user.first_name, proposal.title, - 'http://scipy.in/2018/abstract-details/' + + 'http://dwsim.fossee.in/nccps-2018/abstract-details/' + str(proposal.id), ) elif proposal.proposal_type == 'WORKSHOP': - subject = "SciPy India 2018 - Comment on Your Workshop Proposal" + subject = "NCCPS 2018 - Comment on Your Workshop Proposal" message = """ Dear {0},

    There is a comment posted on your proposal for the workshop titled {1}.
    Once we receive your response, you will be notified regarding further comments/acceptance/ rejection of your talk/workshop via email. Visit this {2} link to view comments on your submission.

    - Thank You !

    Regards,
    SciPy India 2018,
    FOSSEE - IIT Bombay. + Thank You !

    Regards,
    NCCPS 2018,
    FOSSEE - IIT Bombay. """.format( proposal.user.first_name, proposal.title, - 'http://scipy.in/2018/abstract-details/' + + 'http://dwsim.fossee.in/nccps-2018/abstract-details/' + str(proposal.id), ) email = EmailMultiAlternatives( @@ -517,69 +543,69 @@ def status(request, proposal_id=None): if 'accept' in request.POST: proposal.status = "Accepted" proposal.save() - sender_name = "SciPy India 2018" + sender_name = "NCCPS 2018" sender_email = TO_EMAIL to = (proposal.user.email, TO_EMAIL) if proposal.proposal_type == 'ABSTRACT': - subject = "SciPy India 2018 - Talk Proposal Accepted" + subject = "NCCPS 2018 - Talk Proposal Accepted" message = """Dear """+proposal.user.first_name+""", Thank you for your excellent submissions! This year we received many really good submissions. Due the number and quality of the talks this year we have decided to give 20 minute slots to all the accepted talks. So even though you may have submitted a 30 minute one, we are sorry you will only have 20 minutes. Of these 20 minutes please plan to do a 15 minute talk (we will strive hard to keep to time), and keep 5 minutes for Q&A and transfer. We will have the next speaker get ready during your Q&A session in order to not waste time. Pardon the unsolicited advice but it is important that you plan your presentations carefully. 15 minutes is a good amount of time to communicate your central idea. Most really good TED talks finish in 15 minutes. Keep your talk focussed and please do rehearse your talk and slides to make sure it flows well. If you need help with this, the program chairs can try to help you by giving you some early feedback on your slides. Just upload your slides before 26th on the same submission interface and we will go over it once. For anything submitted after 26th we may not have time to comment on but will try to give you feedback. Please also keep handy a PDF version of your talk in case your own laptops have a problem. Please confirm your participation. The schedule will be put up online by end of day. We look forward to hearing your talk. - \n\nYou will be notified regarding instructions of your talk via email.\n\nThank You ! \n\nRegards,\nSciPy India 2018,\nFOSSEE - IIT Bombay""" + \n\nYou will be notified regarding instructions of your talk via email.\n\nThank You ! \n\nRegards,\nNCCPS 2018,\nFOSSEE - IIT Bombay""" elif proposal.proposal_type == 'WORKSHOP': - subject = "SciPy India 2018 - Workshop Proposal Accepted" + subject = "NCCPS 2018 - Workshop Proposal Accepted" message = """Dear """+proposal.user.first_name+""", Thank you for your excellent submissions! We are pleased to accept your workshop. Due to the large number of submissions we have decided to accept 8 workshops and give all the selected workshops 2 hours each. Please plan for 1 hour and 55 minutes in order to give the participants a 10 minute break between workshops for tea. The tentative schedule will be put up on the website shortly. Please do provide detailed instructions for the participants (and the organizers if they need to do something for you) in your reply. Please also confirm your participation. We strongly suggest that you try to plan your workshops carefully and focus on doing things hands-on and not do excessive amounts of theory. Try to give your participants a decent overview so they can pick up additional details on their own. It helps to pick one or two overarching problems you plan to solve and work your way through the solution of those. Installation is often a problem, so please make sure your instructions are simple and easy to follow. If you wish, we could allow some time the previous day for installation help. Let us know about this. Also, do not waste too much time on installation during your workshop. - \n\nYou will be notified regarding instructions of your talk via email.\n\nThank You ! \n\nRegards,\nSciPy India 2018,\nFOSSEE - IIT Bombay""" + \n\nYou will be notified regarding instructions of your talk via email.\n\nThank You ! \n\nRegards,\nNCCPS 2018,\nFOSSEE - IIT Bombay""" #send_mail(subject, message, sender_email, to) # context.update(csrf(request)) elif 'reject' in request.POST: proposal.status = "Rejected" proposal.save() - sender_name = "SciPy India 2018" + sender_name = "NCCPS 2018" sender_email = TO_EMAIL to = (proposal.user.email, TO_EMAIL, ) if proposal.proposal_type == 'ABSTRACT': - subject = "SciPy India 2018 - Talk Proposal Rejected" + subject = "NCCPS 2018 - Talk Proposal Rejected" message = """Dear """+proposal.user.first_name+""", Thank you for your submission to the conference. Unfortunately, due to the large number of excellent talks that were submitted, your talk was not selected. We hope you are not discouraged and request you to kindly attend the conference and participate. We have an excellent line up of workshops (8 in total) and many excellent talks. You may also wish to give a lightning talk (a short 5 minute talk) at the conference if you so desire. We look forward to your active participation in the conference. - \n\nThank You ! \n\nRegards,\nSciPy India 2018,\nFOSSEE - IIT Bombay""" + \n\nThank You ! \n\nRegards,\nNCCPS 2018,\nFOSSEE - IIT Bombay""" # message = """Dear """+proposal.user.first_name+""", # Your talk was rejected because the contents of your work (your report for example) were entirely plagiarized. This is unacceptable and this amounts to severe academic malpractice and misconduct. As such we do not encourage this at any level whatsoever. We strongly suggest that you change your ways. You should NEVER EVER copy paste any content, no matter where you see it. Even if you cite the place where you lifted material from, it is not acceptable to copy anything verbatim. Always write in your own words. Your own personal integrity is much more important than a publication. When giving a tutorial it is understandable that you may use material that someone else has made if you acknowledge this correctly and with their full knowledge. However, the expectation is that you have done something yourself too. In your case a bulk of the work seems plagiarized and even if your talk material is your own, your act of plagiarizing content for your report is unacceptable to us. # Having said that, we do encourage you to attend the conference. We hope you do change your ways and be honest in the future. # \n\nRegards,\n\n - # SciPy India Program chairs""" + # NCCPS Program chairs""" elif proposal.proposal_type == 'WORKSHOP': - subject = "SciPy India 2018 - Workshop Proposal Rejected" + subject = "NCCPS 2018 - Workshop Proposal Rejected" message = """Dear """+proposal.user.first_name+""", Thank you for your submission to the conference. Unfortunately, due to the large number of excellent workshops submitted, yours was not selected. We hope you are not discouraged and request you to kindly attend the conference and participate. We have an excellent line up of workshops (8 in total) and many excellent talks. You may also wish to give a lightning talk (a short 5 minute talk) at the conference if you so desire. We look forward to your active participation in the conference. - \n\nThank You ! \n\nRegards,\nSciPy India 2018,\nFOSSEE - IIT Bombay""" + \n\nThank You ! \n\nRegards,\nNCCPS 2018,\nFOSSEE - IIT Bombay""" # message = """Dear """+proposal.user.first_name+""", - # Thank you for your excellent workshop submission titled “Digital forensics using Python”. The program committee was really excited about your proposal and thought it was a very good one. While the tools you use are certainly in the SciPy toolstack the application was not entirely in the domain of the attendees we typically have at SciPy. This along with the fact that we had many really good workshops that were submitted made it hard to select your proposal this time -- your proposal narrowly missed out. We strongly suggest that you submit this to other more generic Python conferences like the many PyCon and PyData conferences as it may be a much better fit there. We also encourage you to try again next year and if we have a larger audience, we may have space for it next year. This year with two tracks we already have 8 excellent workshops selected. + # Thank you for your excellent workshop submission titled “Digital forensics using Python”. The program committee was really excited about your proposal and thought it was a very good one. While the tools you use are certainly in the NCCPS toolstack the application was not entirely in the domain of the attendees we typically have at NCCPS. This along with the fact that we had many really good workshops that were submitted made it hard to select your proposal this time -- your proposal narrowly missed out. We strongly suggest that you submit this to other more generic Python conferences like the many PyCon and PyData conferences as it may be a much better fit there. We also encourage you to try again next year and if we have a larger audience, we may have space for it next year. This year with two tracks we already have 8 excellent workshops selected. # We really hope you are not discouraged as it was indeed a very good submission and a rather original one at that. We hope you understand and do consider participating in the conference anyway. # We look forward to seeing you at the conference and to your continued interest and participation. - # \n\nRegards,\n\nSciPy India Program chairs""" + # \n\nRegards,\n\nNCCPS Program chairs""" #send_mail(subject, message, sender_email, to) # context.update(csrf(request)) elif 'resubmit' in request.POST: to = (proposal.user.email, TO_EMAIL) - sender_name = "SciPy India 2018" + sender_name = "NCCPS 2018" sender_email = TO_EMAIL if proposal.proposal_type == 'ABSTRACT': - subject = "SciPy India 2018 - Talk Proposal Resumbmission" + subject = "NCCPS 2018 - Talk Proposal Resumbmission" message = """ Dear {0},

    Thank you for your excellent submissions! Your talk has been accepted! This year we received many really good submissions. Due to the number and quality of the talks this year we have decided to give 20 minute slots to all the accepted talks. So even though you may have submitted a 30 minute one, we are sorry you will only have 20 minutes. Of these 20 minutes please plan to do a 15 minute talk (we will strive hard to keep to time), and keep 5 minutes for Q&A and transfer. We will have the next speaker get ready during your Q&A session in order to not waste time. @@ -590,19 +616,19 @@ def status(request, proposal_id=None): """.format( proposal.user.first_name, proposal.title, - 'https://scipy.in/2018/view-abstracts/' + 'http://dwsim.fossee.in/nccps-2018/view-abstracts/' ) elif proposal.proposal_type == 'WORKSHOP': - subject = "SciPy India 2018 - Workshop Proposal Resubmission" + subject = "NCCPS 2018 - Workshop Proposal Resubmission" message = """ - Thank you for showing interest & submitting a workshop proposal at SciPy India 2018 conference for the workshop titled "{1}". You are requested to submit this talk proposal once again.
    + Thank you for showing interest & submitting a workshop proposal at NCCPS 2018 conference for the workshop titled "{1}". You are requested to submit this talk proposal once again.
    You will be notified regarding comments/selection/rejection of your workshop via email. Visit this {2} link to view comments on your submission.

    - Thank You !

    Regards,
    SciPy India 2018,
    FOSSEE - IIT Bombay. + Thank You !

    Regards,
    NCCPS 2018,
    FOSSEE - IIT Bombay. """.format( proposal.user.first_name, proposal.title, - 'https://scipy.in/2018/view-abstracts/' + 'http://dwsim.fossee.in/nccps-2018/view-abstracts/' ) email = EmailMultiAlternatives( subject, '', @@ -707,25 +733,25 @@ def status_change(request): proposal = Proposal.objects.get(id=proposal_id) proposal.status = "Accepted" proposal.save() - sender_name = "SciPy India 2018" + sender_name = "NCCPS 2018" sender_email = TO_EMAIL to = (proposal.user.email, TO_EMAIL) if proposal.proposal_type == 'ABSTRACT': - subject = "SciPy India 2018 - Talk Proposal Accepted" + subject = "NCCPS 2018 - Talk Proposal Accepted" message = """Dear """+proposal.user.first_name+""", Thank you for your excellent submissions! This year we received many really good submissions. Due the number and quality of the talks this year we have decided to give 20 minute slots to all the accepted talks. So even though you may have submitted a 30 minute one, we are sorry you will only have 20 minutes. Of these 20 minutes please plan to do a 15 minute talk (we will strive hard to keep to time), and keep 5 minutes for Q&A and transfer. We will have the next speaker get ready during your Q&A session in order to not waste time. Pardon the unsolicited advice but it is important that you plan your presentations carefully. 15 minutes is a good amount of time to communicate your central idea. Most really good TED talks finish in 15 minutes. Keep your talk focussed and please do rehearse your talk and slides to make sure it flows well. If you need help with this, the program chairs can try to help you by giving you some early feedback on your slides. Just upload your slides before 26th on the same submission interface and we will go over it once. For anything submitted after 26th we may not have time to comment on but will try to give you feedback. Please also keep handy a PDF version of your talk in case your own laptops have a problem. Please confirm your participation. The schedule will be put up online by end of day. We look forward to hearing your talk. - \n\nYou will be notified regarding instructions of your talk via email.\n\nThank You ! \n\nRegards,\nSciPy India 2018,\nFOSSEE - IIT Bombay""" + \n\nYou will be notified regarding instructions of your talk via email.\n\nThank You ! \n\nRegards,\nNCCPS 2018,\nFOSSEE - IIT Bombay""" elif proposal.proposal_type == 'WORKSHOP': - subject = "SciPy India 2018 - Workshop Proposal Accepted" + subject = "NCCPS 2018 - Workshop Proposal Accepted" message = """Dear """+proposal.user.first_name+""", Thank you for your excellent submissions! We are pleased to accept your workshop. Due to the large number of submissions, we have decided to accept 8 workshops and give all the selected workshops 2 hours each. Please plan for 1 hour and 55 minutes in order to give the participants a 10 minute break between workshops for tea. The tentative schedule will be put up on the website shortly. Please confirm your participation and do provide detailed instructions for the participants (and the organizers if they need to do something for you) by replying to this email. These instructions will be made available on the conference website. Installation is often a problem, so please make sure your instructions are simple and easy to follow. If you wish, we could allow some time on the previous day for installation help. Let us know about this. Also, do not waste too much time on installation during your workshop. We strongly suggest that you try to plan your workshops carefully and focus on doing things hands-on and not do excessive amounts of theory. Try to give your participants a decent overview so they can pick up additional details on their own. It helps to pick one or two overarching problems you plan to solve and work your way through the solution of those. -\n\nThank You ! \n\nRegards,\nSciPy India 2018,\nFOSSEE - IIT Bombay""" +\n\nThank You ! \n\nRegards,\nNCCPS 2018,\nFOSSEE - IIT Bombay""" #send_mail(subject, message, sender_email, to) # context.update(csrf(request)) proposals = Proposal.objects.all() @@ -739,35 +765,35 @@ We strongly suggest that you try to plan your workshops carefully and focus on d proposal = Proposal.objects.get(id=proposal_id) proposal.status = "Rejected" proposal.save() - sender_name = "SciPy India 2018" + sender_name = "NCCPS 2018" sender_email = TO_EMAIL to = (proposal.user.email, TO_EMAIL) if proposal.proposal_type == 'ABSTRACT': - subject = "SciPy India 2018 - Talk Proposal Rejected" + subject = "NCCPS 2018 - Talk Proposal Rejected" message = """Dear """+proposal.user.first_name+""", Thank you for your submission to the conference. Unfortunately, due to the large number of excellent talks that were submitted, your talk was not selected. We hope you are not discouraged and request you to kindly attend the conference and participate. We have an excellent line up of workshops (8 in total) and many excellent talks. You may also wish to give a lightning talk (a short 5 minute talk) at the conference if you so desire. We look forward to your active participation in the conference. - \n\nThank You ! \n\nRegards,\nSciPy India 2018,\nFOSSEE - IIT Bombay""" + \n\nThank You ! \n\nRegards,\nNCCPS 2018,\nFOSSEE - IIT Bombay""" # message = """Dear """+proposal.user.first_name+""", # Your talk was rejected because the contents of your work (your report for example) were entirely plagiarized. This is unacceptable and this amounts to severe academic malpractice and misconduct. As such we do not encourage this at any level whatsoever. We strongly suggest that you change your ways. You should NEVER EVER copy paste any content, no matter where you see it. Even if you cite the place where you lifted material from, it is not acceptable to copy anything verbatim. Always write in your own words. Your own personal integrity is much more important than a publication. When giving a tutorial it is understandable that you may use material that someone else has made if you acknowledge this correctly and with their full knowledge. However, the expectation is that you have done something yourself too. In your case a bulk of the work seems plagiarized and even if your talk material is your own, your act of plagiarizing content for your report is unacceptable to us. # Having said that, we do encourage you to attend the conference. We hope you do change your ways and be honest in the future. - # \n\nRegards,\n\nSciPy India Program chairs""" + # \n\nRegards,\n\nNCCPS Program chairs""" elif proposal.proposal_type == 'WORKSHOP': - subject = "SciPy India 2018 - Workshop Proposal Rejected" + subject = "NCCPS 2018 - Workshop Proposal Rejected" message = """Dear """+proposal.user.first_name+""", Thank you for your submission to the conference. Unfortunately, due to the large number of excellent workshops submitted, yours was not selected. We hope you are not discouraged and request you to kindly attend the conference and participate. We have an excellent line up of workshops (8 in total) and many excellent talks. You may also wish to give a lightning talk (a short 5 minute talk) at the conference if you so desire. We look forward to your active participation in the conference. - \n\nThank You ! \n\nRegards,\nSciPy India 2018,\nFOSSEE - IIT Bombay""" + \n\nThank You ! \n\nRegards,\nNCCPS 2018,\nFOSSEE - IIT Bombay""" # message = """Dear """+proposal.user.first_name+""", - # Thank you for your excellent workshop submission titled “Digital forensics using Python”. The program committee was really excited about your proposal and thought it was a very good one. While the tools you use are certainly in the SciPy toolstack the application was not entirely in the domain of the attendees we typically have at SciPy. This along with the fact that we had many really good workshops that were submitted made it hard to select your proposal this time -- your proposal narrowly missed out. We strongly suggest that you submit this to other more generic Python conferences like the many PyCon and PyData conferences as it may be a much better fit there. We also encourage you to try again next year and if we have a larger audience, we may have space for it next year. This year with two tracks we already have 8 excellent workshops selected. + # Thank you for your excellent workshop submission titled “Digital forensics using Python”. The program committee was really excited about your proposal and thought it was a very good one. While the tools you use are certainly in the NCCPS toolstack the application was not entirely in the domain of the attendees we typically have at NCCPS. This along with the fact that we had many really good workshops that were submitted made it hard to select your proposal this time -- your proposal narrowly missed out. We strongly suggest that you submit this to other more generic Python conferences like the many PyCon and PyData conferences as it may be a much better fit there. We also encourage you to try again next year and if we have a larger audience, we may have space for it next year. This year with two tracks we already have 8 excellent workshops selected. # We really hope you are not discouraged as it was indeed a very good submission and a rather original one at that. We hope you understand and do consider participating in the conference anyway. # We look forward to seeing you at the conference and to your continued interest and participation. - # \n\nRegards,\n\nSciPy India Program chairs""" + # \n\nRegards,\n\nNCCPS Program chairs""" #send_mail(subject, message, sender_email, to) # context.update(csrf(request)) proposals = Proposal.objects.all() @@ -779,11 +805,11 @@ We strongly suggest that you try to plan your workshops carefully and focus on d delete_proposal = request.POST.getlist('delete_proposal') for proposal_id in delete_proposal: proposal = Proposal.objects.get(id=proposal_id) - sender_name = "SciPy India 2018" + sender_name = "NCCPS 2018" sender_email = TO_EMAIL to = (proposal.user.email, TO_EMAIL) if proposal.proposal_type == 'ABSTRACT': - subject = "SciPy India 2018 - Talk Proposal Acceptance" + subject = "NCCPS 2018 - Talk Proposal Acceptance" message = """ Dear {0},

    Thank you for your excellent submissions! Your talk has been accepted! This year, we have received many really good submissions. Due to the number and quality of the talks this year we have decided to give 20 minute slots to all the accepted talks. So even though you may have submitted a 30 minute one, we are sorry you will only have 20 minutes. Of these 20 minutes, please plan to do a 15 minute talk (we will strive hard to keep to time), and keep 5 minutes for Q&A and transfer. We will have the next speaker get ready during your Q&A session in order to not waste time. @@ -793,23 +819,23 @@ Pardon the unsolicited advice but it is important that you plan your presentatio We (the program chairs) are happy to help you by giving you some early feedback on your slides. Just upload your slides before 26th and we will go over it once. You may upload your slides by clicking on edit when you login to the site. You may also modify your abstract if you want to improve it. For anything submitted after 26th we may not have time to comment but will try to give you feedback. Please also keep handy a PDF version of your talk in case your own laptops have a problem. Please confirm your participation via return email. The tentative schedule will be put up online by end of day. We look forward to hearing your talk. -Thank You !

    Regards,
    SciPy India 2018,
    FOSSEE - IIT Bombay. +Thank You !

    Regards,
    NCCPS 2018,
    FOSSEE - IIT Bombay. """.format( proposal.user.first_name, proposal.title, - 'https://scipy.in/2018/view-abstracts/' + 'http://dwsim.fossee.in/nccps-2018/view-abstracts/' ) elif proposal.proposal_type == 'WORKSHOP': - subject = "SciPy India 2018 - Workshop Proposal Resubmission" + subject = "NCCPS 2018 - Workshop Proposal Resubmission" message = """ - Thank you for showing interest & submitting a workshop proposal at SciPy India 2018 conference for the workshop titled "{1}". You are requested to submit this talk proposal once again.
    + Thank you for showing interest & submitting a workshop proposal at NCCPS 2018 conference for the workshop titled "{1}". You are requested to submit this talk proposal once again.
    You will be notified regarding comments/selection/rejection of your workshop via email. Visit this {2} link to view comments on your submission.

    - Thank You !

    Regards,
    SciPy India 2018,
    FOSSEE - IIT Bombay. + Thank You !

    Regards,
    NCCPS 2018,
    FOSSEE - IIT Bombay. """.format( proposal.user.first_name, proposal.title, - 'https://scipy.in/2018/view-abstracts/' + 'http://dwsim.fossee.in/nccps-2018/view-abstracts/' ) email = EmailMultiAlternatives( subject, '', @@ -898,7 +924,7 @@ def contact_us(request, next_url): # form = ContactForm(request.POST) # sender_name = request.POST['name'] # sender_email = request.POST['email'] - # to = ('scipy@fossee.in',) + # to = ('nccps@fossee.in',) # subject = "Query from - "+sender_name # message = request.POST['message'] # try: @@ -908,4 +934,58 @@ def contact_us(request, next_url): # except: # context['mailfailed'] = True # context['user'] = user - # return redirect(next_url,context) \ No newline at end of file + # return redirect(next_url,context) + + +@csrf_protect +def user_register(request): + '''User Registration form''' + if request.method == 'POST': + form = UserRegistrationForm(request.POST) + if form.is_valid(): + data = form.cleaned_data + username, password, key = form.save() + new_user = authenticate(username=username, password=password) + login(request, new_user) + user_position = request.user.profile.position + send_email( + request, call_on='Registration', + user_position=user_position, + key=key + ) + + return render(request, 'view-profile.html') + else: + if request.user.is_authenticated: + return redirect('/view_profile/') + return render( + request, "user-register.html", + {"form": form} + ) + else: + if request.user.is_authenticated and is_email_checked(request.user): + return redirect('/view_profile/') + elif request.user.is_authenticated: + return render(request, 'activation.html') + form = UserRegistrationForm() + return render(request, "user-register.html", {"form": form}) + + +@csrf_protect +@login_required +def view_profile(request): + """ view instructor and coordinator profile """ + user = request.user + if is_superuser(user): + return redirect('/admin') + if is_email_checked(user) and user.is_authenticated: + return render(request, "view-profile.html") + else: + if user.is_authenticated: + return render(request, 'view-profile.html') + else: + try: + logout(request) + return redirect('/login/') + except: + return redirect('/register/') \ No newline at end of file -- cgit