summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFOSSEE Git User2018-10-25 19:32:12 +0530
committerFOSSEE Git User2018-10-25 19:32:12 +0530
commit23c740c79135c8e2dcae6b2935d0fb6d573f2b26 (patch)
tree9ae0c5fcd00ec2fa9e58333d4d3ca57f81a37b75
parent03a61256c477fbe30714a12ad09258ad93295936 (diff)
parent7d171e9b3dfdf6119f719ae7283add795bd1ec6c (diff)
downloadnccps-2018-23c740c79135c8e2dcae6b2935d0fb6d573f2b26.tar.gz
nccps-2018-23c740c79135c8e2dcae6b2935d0fb6d573f2b26.tar.bz2
nccps-2018-23c740c79135c8e2dcae6b2935d0fb6d573f2b26.zip
Merge branch 'master' of https://github.com/FOSSEE/nccps-2018
-rwxr-xr-x.gitignore5
-rw-r--r--nccps2018/settings.py8
-rw-r--r--static/website/templates/question_list.html1
-rwxr-xr-xwebsite/forms.py13
-rw-r--r--website/models.py16
-rw-r--r--website/urls.py1
-rw-r--r--website/views.py60
7 files changed, 87 insertions, 17 deletions
diff --git a/.gitignore b/.gitignore
index fd97ce3..08cbbb1 100755
--- a/.gitignore
+++ b/.gitignore
@@ -20,4 +20,7 @@ db.sqlite3
# Django Migration files
#MAC OS specific
-.DS_Store \ No newline at end of file
+.DS_Store
+
+#VScode
+.vscode/
diff --git a/nccps2018/settings.py b/nccps2018/settings.py
index f28ffa7..9ce4c32 100644
--- a/nccps2018/settings.py
+++ b/nccps2018/settings.py
@@ -81,10 +81,10 @@ WSGI_APPLICATION = 'nccps2018.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
- 'NAME': DB_NAME_DEFAULT, # Or path to database file if using sqlite3.
- 'USER': DB_USER_DEFAULT,
- 'PASSWORD': DB_PASS_DEFAULT,
- 'HOST': DB_HOST_DEFAULT,
+ 'NAME': DB_NAME_DEFAULT, # Or path to database file if using sqlite3.
+ 'USER': DB_USER_DEFAULT,
+ 'PASSWORD': DB_PASS_DEFAULT,
+ 'HOST': DB_HOST_DEFAULT,
}
}
diff --git a/static/website/templates/question_list.html b/static/website/templates/question_list.html
index 65b571a..cc11098 100644
--- a/static/website/templates/question_list.html
+++ b/static/website/templates/question_list.html
@@ -13,6 +13,7 @@
<br>
<a href="{% url 'website:add_questions' %}" ><button class="btn-default btn-warning"> Add Question </button></a>
<a href="{% url 'website:leaderboard' %}" ><button class="btn-default btn-info"> LeaderBoard </button></a>
+
<br><br>
</div>
diff --git a/website/forms.py b/website/forms.py
index 5b094e7..bee9ba9 100755
--- a/website/forms.py
+++ b/website/forms.py
@@ -1,7 +1,7 @@
from django import forms
from django.forms import ModelForm, widgets
-
+import datetime
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django.core.validators import MinLengthValidator, MinValueValidator, \
@@ -396,4 +396,13 @@ class QuestionUploadForm(forms.ModelForm):
widgets = {
'question_day': DateInput(),
- } \ No newline at end of file
+ }
+
+
+#To upload model for each question
+'''
+class UploadModelForm(forms.ModelForm):
+ class Meta:
+ model = UploadModel
+ fields = ['model_file']
+'''
diff --git a/website/models.py b/website/models.py
index 2481177..e482453 100644
--- a/website/models.py
+++ b/website/models.py
@@ -34,7 +34,11 @@ def get_document_dir(instance, filename):
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)
-
+
+
+def attachments(instance, filename):
+ return os.sep.join((instance.workshoptype_name.replace(" ", '_'), filename))
+
class Proposal(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE,)
@@ -123,4 +127,12 @@ class AnswerPaper(models.Model):
participant = models.ForeignKey(Profile, on_delete=models.CASCADE)
answered_q = models.ForeignKey(Question, on_delete=models.CASCADE)
validate_ans = models.BooleanField()
- date = models.DateTimeField(auto_now=True) \ No newline at end of file
+ date = models.DateTimeField(auto_now=True)
+
+
+#To upload model for each question
+'''
+class UploadModel(models.Model):
+ question = models.ForeignKey(Question, on_delete=models.CASCADE, blank=True, null=True)
+ model_file = models.FileField(upload_to=attachments)
+''' \ No newline at end of file
diff --git a/website/urls.py b/website/urls.py
index 7cf47c5..f0dbe60 100644
--- a/website/urls.py
+++ b/website/urls.py
@@ -20,6 +20,7 @@ urlpatterns = [
re_path(r'^cfp/$', views.cfp, name='cfp'),
#re_path(r'^quiz/$', views.quiz_view, name='quiz_view'),
re_path(r'^question_list/$', views.question_list, name='question_list'),
+ #re_path(r'^uploadmodel/$', views.uploadmodel, name='uploadmodel'),
re_path(r'^add_questions/$', views.add_questions, name='add_questions'),
re_path(r'^edit_question/(?P<qid>\d+)$', views.edit_question, name='edit_question'),
re_path(r'^take_quiz/$', views.take_quiz, name='take_quiz'),
diff --git a/website/views.py b/website/views.py
index 35686e7..a330387 100644
--- a/website/views.py
+++ b/website/views.py
@@ -16,11 +16,12 @@ from website.models import (Proposal, Comments, Ratings, Question,
AnswerPaper, Profile)
from website.forms import (ProposalForm, UserRegisterForm, UserRegistrationForm,
- UserLoginForm, WorkshopForm,QuestionUploadForm) # ,ContactForm
+ UserLoginForm, WorkshopForm,QuestionUploadForm
+ )# ,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
-from datetime import datetime
+from datetime import datetime, date
from django import template
from django.core.mail import EmailMultiAlternatives
import os
@@ -1163,17 +1164,60 @@ def take_quiz(request):
def leaderboard(request):
profiles = Profile.objects.all()
-
leaderboard = {p:0 for p in profiles}
-
+ marks = {
+ '5': [date(2018, 10, 29), date(2018, 11, 4)],
+ '10': [date(2018, 11, 5), date(2018, 11, 12)]
+ }
answers = AnswerPaper.objects.all()
for i in leaderboard:
- profile_data = AnswerPaper.objects.filter(participant=i)
- for pro in profile_data:
- if pro.validate_ans==1:
- leaderboard[i] +=1
+ profiles = AnswerPaper.objects.filter(participant=i)
+ for p in profiles:
+ if p.validate_ans==1:
+ if marks['5'][0] <= p.answered_q.question_day <= marks['5'][1]:
+ leaderboard[i] +=5
+ elif marks['10'][0] <= p.answered_q.question_day <= marks['10'][1]:
+ leaderboard[i] +=10
+ else:
+ leaderboard[i] +=1
+
sorted_leaderboard = sorted(leaderboard.items(), key=lambda kv: kv[1])
return render(request, "leaderboard.html", {'leaderboard': sorted_leaderboard[::-1]})
+
+'''
+@login_required
+def uploadmodel(request):
+ if request.method == 'POST':
+ data = request.body.decode("utf-8").split('&')
+ date = data[1].replace("qdate=", "")
+ date = datetime.strptime(date, "%Y-%m-%d").date()
+ question_list = Question.objects.all()
+ try:
+ question_obj = Question.objects.get(question_day=date)
+ print(question_obj)
+ messages.info(request, 'Uploaded Successfully!')
+ except:
+ messages.error(request, 'No question uploaded for mentioned date')
+
+
+ form = UploadModelForm(request.POST)
+ if form.is_valid():
+ uploadForm = form.save(commit=False)
+ try:
+ question_obj = Question.objects.get(question_day=date)
+ uploadForm.question = question_obj
+ uploadForm.model_file
+ uploadForm.save()
+ messages.info(request, 'Uploaded Successfully!')
+ except:
+ messages.error(request, 'No question uploaded for mentioned date')
+ print(question_obj)
+ else:
+ messages.error(request, 'Invalid Form')
+
+
+ return render(request, "uploadmodel.html", {"question_list":question_list})'''
+ \ No newline at end of file