Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ SPOKEN_DB='13thJune'
SECRET_KEY=''
VIDEO_PATH=''
DEBUG=True
TEMPLATE_DEBUG=True
TEMPLATE_DEBUG=True
URL_MONGO_IP='localhost'
URL_MONGO_PORT='27017'
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ static/CACHE/*
robots.txt
# C extensions
*.so
media/

# Packages
*.egg
Expand Down Expand Up @@ -43,4 +44,4 @@ nosetests.xml
.pydevproject
uwsgi-master.pid
.env
.vscode
.vscode
7 changes: 7 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,12 @@ django-extensions==2.1.3
django-filter==2.0.0
django-debug-toolbar==1.4
python-dotenv==0.10.3
scikit-learn>=0.19.1
StackAPI==0.1.12
pymongo==3.10.1
lxml==4.6.2
pandas==0.25.3
nltk==3.5
scipy==1.4.1
sklearn==0.0
django-mysql==3.10.0
9 changes: 9 additions & 0 deletions spoken_auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,12 @@ class TutorialResources(models.Model):

class Meta:
db_table = 'creation_tutorialresource'


class TutorialCommonContent(models.Model):
id = models.IntegerField(primary_key=True)
tutorial_detail = models.ForeignKey(TutorialDetails, on_delete=models.CASCADE,)
keyword = models.TextField()

class Meta:
db_table = 'creation_tutorialcommoncontent'
34 changes: 32 additions & 2 deletions static/website/js/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $(document).ready(function() {
}
});

$tutorial.change(function() {
$tutorial.on('input', function() {
/* resetting dropdowns */
reset("minute_range", "second_range");
var category = $category.val();
Expand Down Expand Up @@ -98,6 +98,35 @@ $(document).ready(function() {
});
}
});

// this is in faq page
$tutorial.change(function() {
$.ajax({
url: "/ajax-faq-questions/",
type: "POST",
data: {
category: $category.val(),
tutorial: $tutorial.val(),
},
dataType: "html",
success: function(data) {
$response = $(data);
var similar_count= $response.find("#similar-count").text();
console.log(similar_count);
$("#similar-link").show();
$("#modal-body").html(data);

$.ajax({
url:"/ajax-fetch-questions/",
type: "POST",
data: {
category: $category.val(),
tutorial: $tutorial.val(),
}
});
}
});
});

$title.keyup(function() {
var len = $title.val().split(' ').length;
Expand All @@ -117,7 +146,8 @@ $(document).ready(function() {
success: function(data) {
$response = $(data);
var similar_count= $response.find("#similar-count").text();
$("#similar-link").show().html(similar_count);
console.log(similar_count);
$("#similar-link").show();
$("#modal-body").html(data);
}
});
Expand Down
6 changes: 5 additions & 1 deletion static/website/templates/ajax-similar-questions.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
{% endif %}
</div>
<br>

<table class="table table-bordered table-hover">
{% for question in questions %}
<tr>
<td>
<a href="{% url 'website:get_question' question.id %}" target="_blank">
<a href="{{ question.body }}" target="_blank">
{{ question.title }}
</a>
{% for tag in question.tags %}
<span class="badge badge-pill badge-dark">{{ tag }}</span>
{% endfor %}
</td>
</tr>
{% endfor %}
Expand Down
57 changes: 57 additions & 0 deletions static/website/templates/ajax_faq_questions.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<div>
<div id="similar-count">
{% if questions.count > 0 %}
{% if questions.count == 1 %}
1 similar question
{% else %}
{{ questions.count }} similar questions
{% endif %}
{% endif %}
</div>
<br>
<table class="table table-bordered table-hover">
{% if questions|length == 0 %}
<h4>No similar questions found</h4>
{% else %}
<thead>
<tr>
<th>Accepted <br> Answer</th>
<th>Author <br> Details</th>
<th style="vertical-align: middle;">Question Details</th>
</tr>
</thead>
{% endif %}

{% for question in questions %}
<tr>
<td style="text-align: center;">
{% if question.accepted_answer != "" %}
<a href="{{ question.accepted_answer }}" target="_blank"><i style="color: green" class="fa fa-lg fa-check" aria-hidden="true"></i></a>
{% endif %}
</td>
<td style="text-align: center;">
<a href="{{ question.owner.link }}" target="_blank"><i class="fa fa-md fa-user-check" aria-hidden="true"></i></a>
</td>
<td>
<div class="col-md-8">
<a href="{{ question.body }}" target="_blank">
&nbsp; {{ question.title }}
</a>
<br>
{% for tag in question.tags %}
<span class="badge badge-pill badge-dark">{{ tag }}</span>
{% endfor %}
</div>
<div class="col-md-4">
<div class="row pull-right" style="font-size: 14;">
<span class="label label-warning">{{ question.views }} <i class="fa fa-md fa-eye" aria-hidden="true"></i></span>
<span class="label label-success">{{ question.score }} <i class="fa fa-md fa-thumbs-up" aria-hidden="true"></i></span>
<span class="label label-primary">{{ question.answer_count }} <i class="fa fa-md fa-comments" aria-hidden="true"></i></span>
</div>
</div>
</td>
</tr>
{% endfor %}
</table>
</div> <!-- /div for ajax -->

9 changes: 8 additions & 1 deletion static/website/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@

{% endcompress %}
<script src="{% static 'website/js/jquery-1.12.4.min.js' %}"></script>
<script src="{% static 'website/js/jquery.tablesorter.min.js' %}"></script>
<script src="{% static 'website/js/jquery.tablesorter.min.js' %}"></script>
<script src="https://kit.fontawesome.com/9e55978135.js" crossorigin="anonymous"></script>
<!-- settig up csrf token for every ajax request -->
<script type="text/javascript">window.csrftoken = '{{ csrf_token }}';
function csrfSafeMethod(method) {
Expand Down Expand Up @@ -70,6 +71,12 @@
Search
</a>
</li>
<li>
<a href="{% url 'website:faq' %}">
<span class="glyphicon glyphicon-list"></span>
FAQ
</a>
</li>
<li>
<a href="{% url 'website:new_question' %}">
<span class="glyphicon glyphicon-pencil"></span>
Expand Down
65 changes: 65 additions & 0 deletions static/website/templates/faq.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{% extends 'website/templates/base.html' %}
{% load static %}
{% load widget_tweaks %}
{% block content %}
<h4>
<span class="glyphicon glyphicon-pencil">
</span> Create a new question . . .
</h4>
<hr>
<form role="form" action="" method="POST" novalidate>{% csrf_token %}
{% with WIDGET_ERROR_CLASS='field_error' %}

<p>
Please enter the tutorial details.
<img id="ajax-loader" src="{% static 'website/images/ajax-loader.gif' %}" style="display:none;">
</p>
<div class="row">
<div class="col-lg-3 col-md-3 col-sm-3">
{% render_field form.category class+="form-control"%}
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
{% if category %}
{% render_field form.tutorial class+="form-control" %}
{% else %}
{% render_field form.tutorial class+="form-control" disabled="disabled" %}
{% endif %}
</div>

<!-- <div class="col-lg-2 col-md-2 col-sm-2">
<small><strong>
<a id="similar-link" data-toggle="modal" data-target="#similarModal" href="#">
0 similar questions
</a>
</strong></small>
</div> -->
</div>
<hr>
<!-- Added this part for fetching related questions -->
<div class="alert-dismissible" id="similar-link">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel"><i style="color: #f48024;" class="fa fa-lg fa-stack-overflow" aria-hidden="true"></i> Related Questions from StackOverflow</h4>
</div>
<div class="modal-body" id="modal-body" style="color: black">
...
</div>
</div>


{% endwith %}
</form>

<script src="{% static 'website/js/nicEdit.js' %}" type="text/javascript"></script>
<script type="text/javascript">
bkLib.onDomLoaded(function() {
new nicEditor({
iconsPath: "{% static 'website/js/nicEditorIcons.gif' %}",
buttonList : ['fontSize','bold','italic','underline','strikeThrough','subscript','superscript','html','image', 'link', 'forecolor', 'bgcolor']
}).panelInstance('id_body');
});
</script>
{% endblock %}

{% block javascript %}
<script src="{% static 'website/js/custom.js' %}"></script>
{% endblock %}
17 changes: 12 additions & 5 deletions static/website/templates/new-question.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ <h4>
<div class="col-lg-2 col-md-2 col-sm-2">
{% render_field form.second_range class+="form-control" disabled="disabled" %}
</div>
<!-- <div class="col-lg-2 col-md-2 col-sm-2">
<small><strong>
<a id="similar-link" data-toggle="modal" data-target="#similarModal" href="#">
0 similar questions
</a>
</strong></small>
</div> -->
</div>
<hr>

Expand Down Expand Up @@ -61,7 +68,7 @@ <h4>
</form>

<!-- Modal -->
<div class="modal fade" id="similarModal" tabindex="-1" role="dialog" aria-labelledby="similarModalLabel" aria-hidden="true">
<!-- <div class="modal fade" id="similarModal" tabindex="-1" role="dialog" aria-labelledby="similarModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
Expand All @@ -70,10 +77,10 @@ <h4 class="modal-title" id="myModalLabel">Similar Questions</h4>
</div>
<div class="modal-body" id="modal-body">
...
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div> -->
<!-- </div>/.modal-content -->
<!-- </div>/.modal-dialog -->
<!-- </div>/.modal -->

<script src="{% static 'website/js/nicEdit.js' %}" type="text/javascript"></script>
<script type="text/javascript">
Expand Down
3 changes: 1 addition & 2 deletions website/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, *args, **kwargs):
seconds = (
("", "sec"),
)

if not category and args and 'category' in args[0] and args[0]['category']:
category = args[0]['category']
if FossCategory.objects.filter(foss=category).exists():
Expand All @@ -66,7 +66,6 @@ def __init__(self, *args, **kwargs):
self.fields['minute_range'] = forms.CharField(widget=forms.Select(choices=minutes))
self.fields['second_range'] = forms.CharField(widget=forms.Select(choices=seconds))


class AnswerQuesitionForm(forms.Form):
question = forms.IntegerField(widget=forms.HiddenInput())
body = forms.CharField(widget=forms.Textarea())
5 changes: 3 additions & 2 deletions website/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ def prettify(string):

def pre_process(text):
text=text.lower() # lowercase
text=re.sub("<!--?.*?-->","",text) # remove tags
text=re.sub("(\\d|\\W)+"," ",text) # remove special characters and digits
text = re.sub('<.*?>', ' ', text).replace(' ',' ')
text=re.sub("<!--?.*?-->"," ",text).replace(' ',' ') # remove tags
text=re.sub("(\\d|\\W)+"," ",text).replace(' ',' ') # remove special characters and digits
return text

def clean_user_data(text):
Expand Down
28 changes: 28 additions & 0 deletions website/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.2.6 on 2021-01-07 04:47

from django.db import migrations, models
import django.db.models.deletion
import django_mysql.models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='StackQuestions',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('category', models.CharField(max_length=200)),
('tutorial', models.CharField(max_length=200)),
('stackdata', django_mysql.models.JSONField(default=dict)),
],
options={
'unique_together': {('category', 'tutorial')},
},
)
]
Empty file added website/migrations/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions website/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.db import models
from django.contrib.auth import get_user_model
from django_mysql.models import JSONField

User = get_user_model()

Expand Down Expand Up @@ -87,4 +88,11 @@ def poster(self):
user = User.objects.get(id=self.pid)
return user.username

class StackQuestions(models.Model):
category = models.CharField(max_length=200)
tutorial = models.CharField(max_length=200)
stackdata = JSONField()

class Meta(object):
unique_together = ('category', 'tutorial')
# CDEEP database created using inspectdb arg of manage.py
Loading