summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arduino_blog/decorators.py43
-rw-r--r--arduino_blog/forms.py22
-rw-r--r--arduino_blog/migrations/0002_auto_20200228_0903.py33
-rw-r--r--arduino_blog/migrations/0003_auto_20200228_1102.py33
-rw-r--r--arduino_blog/migrations/0004_auto_20200228_1219.py27
-rw-r--r--arduino_blog/migrations/0005_auto_20200228_1241.py23
-rw-r--r--arduino_blog/models.py5
-rw-r--r--arduino_blog/templates/dashboard.html23
-rw-r--r--arduino_blog/templates/login.html2
-rw-r--r--arduino_blog/views.py28
-rwxr-xr-xrequirements.txt38
11 files changed, 252 insertions, 25 deletions
diff --git a/arduino_blog/decorators.py b/arduino_blog/decorators.py
index ddb888c..6c185d5 100644
--- a/arduino_blog/decorators.py
+++ b/arduino_blog/decorators.py
@@ -1,5 +1,7 @@
from django.shortcuts import render, redirect
from django.conf import settings
+from arduino_blog.models import Proposal
+from django.db.models import Q
def email_verified(func):
"""
@@ -21,6 +23,45 @@ def email_verified(func):
request, 'activation-status.html', context
)
return func(request, *args, **kwargs)
- except:
+ except Exception as e:
+ print (e)
return redirect('/')
return is_email_verified
+
+
+def is_proposal_submitted(func):
+ def is_submitted(request, *args, **kwargs):
+ user = request.user
+ context = {}
+ try:
+ if user.is_authenticated:
+ if not user.profile.is_email_verified:
+ context['success'] = False
+ context['msg'] = "Your account is not verified. \
+ Please verify your account"
+ return render(
+ request, 'activation-status.html', context
+ )
+ else:
+ _q = Proposal.objects
+ is_sub = _q.get(Q(user_id=user.id)&Q(proposal_status='0'))
+ if is_sub.proposal_status == 0:
+ context['success'] = True
+ context['msg'] = "You have alredy submited a \
+ proposal. Your proposal is under \
+ review"
+ return render(
+ request, 'dashboard.html', context
+ )
+ else:
+ context['success'] = False
+ context['msg'] = "You can submit a new \
+ proposal"
+ return render(
+ request, 'dashboard.html', context
+ )
+ return func(request, *args, **kwargs)
+ except Exception as e:
+ print (e)
+ return redirect('/')
+ return is_submitted
diff --git a/arduino_blog/forms.py b/arduino_blog/forms.py
index ee8b6b1..35a64a2 100644
--- a/arduino_blog/forms.py
+++ b/arduino_blog/forms.py
@@ -2,6 +2,10 @@ from django import forms
from django.forms import ModelForm, widgets
+import datetime
+from dateutil.relativedelta import relativedelta
+
+
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django.core.validators import MinLengthValidator, MinValueValidator, \
@@ -23,6 +27,7 @@ from arduino_blog.models import (
)
from .send_emails import (send_user_mail,
generate_activation_key)
+from arduino_blog.views import *
UNAME_CHARS = letters + "._" + digits
PWD_CHARS = letters + punctuation + digits
@@ -245,13 +250,28 @@ class AbstractProposalForm(forms.ModelForm):
error_messages={
'required': 'Abstract field required.'},
)
+
+ completion_date = forms.DateTimeField(
+ input_formats=['%YY-%mm-%dd'],
+ widget=forms.DateTimeInput(attrs={
+ 'class': 'form-control datetimepicker-input',
+ 'data-target': '#datetimepicker1'
+ })
+ )
+
terms_and_conditions = forms.BooleanField(widget=forms.CheckboxInput(),
required=True, label='I agree to the terms and conditions')
class Meta:
model = Proposal
- exclude = ('user','name_of_author', 'email', 'status', 'rate')
+ exclude = ('user','name_of_author', 'email', 'status', 'rate','proposal_status', 'approval_date')
+
+ def __init__(self, *args, **kwargs):
+ super(AbstractProposalForm, self).__init__(*args, **kwargs)
+ self.fields['completion_date'].disabled = True
+ self.fields['completion_date'].initial = (datetime.date.today() + relativedelta(months=1)).strftime("%Y-%m-%d")
+
def clean_attachment(self):
import os
cleaned_data = self.cleaned_data
diff --git a/arduino_blog/migrations/0002_auto_20200228_0903.py b/arduino_blog/migrations/0002_auto_20200228_0903.py
new file mode 100644
index 0000000..e82c871
--- /dev/null
+++ b/arduino_blog/migrations/0002_auto_20200228_0903.py
@@ -0,0 +1,33 @@
+# Generated by Django 3.0.3 on 2020-02-28 09:03
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('arduino_blog', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='proposal',
+ name='approval_date',
+ field=models.IntegerField(default=0, max_length=100),
+ ),
+ migrations.AddField(
+ model_name='proposal',
+ name='completion_date',
+ field=models.IntegerField(default=0, max_length=100),
+ ),
+ migrations.AddField(
+ model_name='proposal',
+ name='creation_date',
+ field=models.IntegerField(default=0, max_length=100),
+ ),
+ migrations.AddField(
+ model_name='proposal',
+ name='proposal_status',
+ field=models.IntegerField(default=0, max_length=2),
+ ),
+ ]
diff --git a/arduino_blog/migrations/0003_auto_20200228_1102.py b/arduino_blog/migrations/0003_auto_20200228_1102.py
new file mode 100644
index 0000000..d2c5ae8
--- /dev/null
+++ b/arduino_blog/migrations/0003_auto_20200228_1102.py
@@ -0,0 +1,33 @@
+# Generated by Django 3.0.3 on 2020-02-28 11:02
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('arduino_blog', '0002_auto_20200228_0903'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='proposal',
+ name='approval_date',
+ field=models.DateTimeField(auto_now_add=True),
+ ),
+ migrations.AlterField(
+ model_name='proposal',
+ name='completion_date',
+ field=models.DateTimeField(auto_now_add=True),
+ ),
+ migrations.AlterField(
+ model_name='proposal',
+ name='creation_date',
+ field=models.DateTimeField(auto_now_add=True),
+ ),
+ migrations.AlterField(
+ model_name='proposal',
+ name='proposal_status',
+ field=models.IntegerField(default=0),
+ ),
+ ]
diff --git a/arduino_blog/migrations/0004_auto_20200228_1219.py b/arduino_blog/migrations/0004_auto_20200228_1219.py
new file mode 100644
index 0000000..a583a84
--- /dev/null
+++ b/arduino_blog/migrations/0004_auto_20200228_1219.py
@@ -0,0 +1,27 @@
+# Generated by Django 3.0.3 on 2020-02-28 12:19
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('arduino_blog', '0003_auto_20200228_1102'),
+ ]
+
+ operations = [
+ migrations.RemoveField(
+ model_name='proposal',
+ name='creation_date',
+ ),
+ migrations.AlterField(
+ model_name='proposal',
+ name='approval_date',
+ field=models.DateTimeField(),
+ ),
+ migrations.AlterField(
+ model_name='proposal',
+ name='completion_date',
+ field=models.DateTimeField(),
+ ),
+ ]
diff --git a/arduino_blog/migrations/0005_auto_20200228_1241.py b/arduino_blog/migrations/0005_auto_20200228_1241.py
new file mode 100644
index 0000000..ccea2fa
--- /dev/null
+++ b/arduino_blog/migrations/0005_auto_20200228_1241.py
@@ -0,0 +1,23 @@
+# Generated by Django 3.0.3 on 2020-02-28 12:41
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('arduino_blog', '0004_auto_20200228_1219'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='proposal',
+ name='approval_date',
+ field=models.DateTimeField(blank=True, null=True),
+ ),
+ migrations.AlterField(
+ model_name='proposal',
+ name='completion_date',
+ field=models.DateTimeField(blank=True, null=True),
+ ),
+ ]
diff --git a/arduino_blog/models.py b/arduino_blog/models.py
index 4d2f36d..b8c60c8 100644
--- a/arduino_blog/models.py
+++ b/arduino_blog/models.py
@@ -119,5 +119,8 @@ class Proposal(BaseClass):
abstract = models.TextField(max_length=700)
attachment = models.FileField(upload_to=get_document_dir)
status = models.CharField(max_length=100, default='Pending', editable=True)
+ completion_date = models.DateTimeField(null=True, blank=True)
+ approval_date = models.DateTimeField(null=True, blank=True)
+ proposal_status = models.IntegerField(default=0, editable=True)
#tags = models.CharField(max_length=250)
- terms_and_conditions = models.BooleanField(default= 'True') \ No newline at end of file
+ terms_and_conditions = models.BooleanField(default= 'True')
diff --git a/arduino_blog/templates/dashboard.html b/arduino_blog/templates/dashboard.html
new file mode 100644
index 0000000..a4528a8
--- /dev/null
+++ b/arduino_blog/templates/dashboard.html
@@ -0,0 +1,23 @@
+{% extends "base.html" %}
+
+{% block css%}
+ <link rel="stylesheet" href="{{ URL_ROOT }}/static/yaksh/css/dashboard.css" type="text/css" />
+{% endblock %}
+{% block content %}
+{% if success %}
+ <center>
+ <div class="alert alert-success" role="alert">
+ <strong> {{ msg }} </strong>
+ </div>
+ <!-- <a href="{{URL_ROOT}}/exam/"> Home </a> -->
+ </center>
+{% else %}
+ {% if msg %}
+ <center>
+ <div class="alert alert-warning" role="alert">
+ <strong> {{ msg }} </strong>
+ </div>
+ {% endif %}
+{% endif %}
+<br/>
+{% endblock content %}
diff --git a/arduino_blog/templates/login.html b/arduino_blog/templates/login.html
index 7c9bfc2..052fd99 100644
--- a/arduino_blog/templates/login.html
+++ b/arduino_blog/templates/login.html
@@ -26,7 +26,7 @@
<form action="" method="POST">
{% csrf_token %}
{{ form.as_p }}
- <button type="button" class="btn btn-success" name ="login" type="submit">Login</button>
+ <button class="btn btn-success" name ="login" type="submit">Login</button>
<br/>
<br/>
<a style="padding-right : 20px;" href="{% url 'arduino_blog:user_register' %}" class="btn btn btn-primary">Create an Account
diff --git a/arduino_blog/views.py b/arduino_blog/views.py
index b2dc9f4..6cad284 100644
--- a/arduino_blog/views.py
+++ b/arduino_blog/views.py
@@ -1,5 +1,5 @@
from django.http import HttpResponse
-from django.shortcuts import render_to_response, render, redirect, get_object_or_404
+from django.shortcuts import render, redirect, get_object_or_404
from django.template import loader
from django.template import RequestContext
from django.contrib.auth.forms import UserCreationForm
@@ -16,8 +16,9 @@ from .send_emails import (send_user_mail,
generate_activation_key)
from django.utils import timezone
from arduino_projects_website.settings import URL_ROOT
-from .decorators import email_verified
-
+from .decorators import email_verified, is_proposal_submitted
+from django.core.mail import EmailMultiAlternatives
+import datetime
def my_redirect(url):
"""An overridden redirect to deal with URL_ROOT-ing. See settings.py
@@ -183,6 +184,7 @@ def new_activation(request, email=None):
@csrf_protect
@login_required
@email_verified
+@is_proposal_submitted
def submitabstract(request):
context = {}
if request.user.is_authenticated:
@@ -197,11 +199,17 @@ def submitabstract(request):
data.name_of_author = social_user.first_name + ' ' + social_user.last_name
data.email = social_user.email
data.attachment = request.FILES
+ data.proposal_status = 0
+ data.approval_date = datetime.date.today()
data.save()
context['proposal_submit'] = True
+ context['display_message'] = """Thank you for your submission! """
#mail function
+ #message = render_to_string('email/propodal_received.html', context)
+ #send_email(sender_email, to, subject, message, bcc_email)
return render_to_response('index.html', context)
else:
+ print(form.errors)
context['proposal_form'] = form
#context['proposals_a'] = proposals_a
template = loader.get_template('submit-cfp.html')
@@ -212,3 +220,17 @@ def submitabstract(request):
else:
context['login_required'] = True
return render_to_response('login.html', context)
+
+
+def send_email(sender_email, to, subject, message, bcc_email=None):
+ email = EmailMultiAlternatives(
+ subject, '',
+ sender_email, to,
+ bcc=[bcc_email],
+ headers={"Content-type": "text/html;charset=iso-8859-1"}
+ )
+ email.attach_alternative(message, "text/html")
+ email.content_subtype = 'html' # Main content is text/html
+ email.mixed_subtype = 'related'
+ email.send(fail_silently=True)
+
diff --git a/requirements.txt b/requirements.txt
index 3ced17a..a4bef5c 100755
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,21 +1,23 @@
-certifi==2018.8.13
+asgiref==3.2.3
+certifi==2019.11.28
chardet==3.0.4
-defusedxml==0.5.0
-Django==2.1
-django-recaptcha==1.4.0
-idna==2.7
-mysqlclient==1.3.13
-oauthlib==2.1.0
-PyJWT==1.6.4
+defusedxml==0.6.0
+Django==3.0.3
+django-recaptcha==2.0.6
+django-widget-tweaks==1.4.5
+idna==2.9
+mysqlclient==1.4.6
+oauthlib==3.1.0
+PyJWT==1.7.1
python-social-auth==0.3.6
python3-openid==3.1.0
-pytz==2018.5
-requests==2.19.1
-requests-oauthlib==1.0.0
-six==1.11.0
-social-auth-app-django==2.1.0
-social-auth-core==1.7.0
-urllib3==1.23
-django-widget-tweaks
-pyyaml
-
+pytz==2019.3
+PyYAML==5.3
+requests==2.23.0
+requests-oauthlib==1.3.0
+six==1.14.0
+social-auth-app-django==3.1.0
+social-auth-core==3.2.0
+sqlparse==0.3.0
+urllib3==1.25.8
+python-dateutil