Commit bd65d104 authored by Darshan Prabhu's avatar Darshan Prabhu

Priority List for faculties and students and updated latex generation code

parent f2aabbdd
from pylatex import Document, Section, Subsection, Tabular,MiniPage,LargeText,FlushLeft,LineBreak, \
FlushRight,LongTabu,MultiColumn,MultiRow, LongTabularx, Figure,Center
from pylatex.package import Package
from pylatex.utils import bold, NoEscape
# Function to convert stored data to Latex pdf
def mappedResult(result,guide,studentApplied,fileLocation):
'''
Input:
result: mappings generated for every project
guide: List of guides and the projects proposed by them
studentApplied: Count of students partaking in the allocation
filelocation: path to store the latex file
'''
geometric_options = {
"margin":"0.4in"
}
doc = Document(geometry_options=geometric_options)
center = Center()
center.append(LargeText(bold("Summary")))
doc.append(center)
with doc.create(LongTabu('|c c|',row_height="2.0",col_space="1in")) as table:
totalAlloted = 0
num_offers = 0
for keys, values in result.items():
alloted = sum([len(i) for i in values.values() ])
totalAlloted += alloted
num_offers += guide[keys]['requirement']
table.add_hline()
table.add_row(bold("No. of Students applied"),studentApplied)
table.add_row(bold("No. of Slots Offered"),num_offers)
table.add_row(bold("No. of Students alloted"),totalAlloted)
table.add_hline()
with doc.create(LongTabu("|c c c|",row_height="2.0",col_space="0.35in")) as guideTable:
header_row = ["Guide Name", "Requirements", "Alloted"]
guideTable.add_hline()
guideTable.add_row(header_row,mapper=[bold])
guideTable.add_hline()
guideTable.add_hline()
for keys,values in result.items():
alloted = sum([len(i) for i in values.values() ])
guideTableRow = [guide[keys]['name'], guide[keys]['requirement'], bold(alloted)]
guideTable.add_row(guideTableRow)
guideTable.add_hline()
center = Center()
center.append(LargeText(bold("Student-Guide Mapping Result for MTP")))
doc.append(center)
with doc.create(LongTabu("|c|c|c|c|",booktabs=True,row_height="2.0",col_space="0.2in")) as dataTable:
header_row = ["GuideName","Topic_offered","AllotedStudentId","AllotedStudentName"]
dataTable.add_hline()
dataTable.add_row(header_row,mapper=[bold])
dataTable.add_hline()
dataTable.add_hline()
dataTable.end_table_header()
for keys,value in result.items():
idSpan = sum([len(i) for i in value.values() ])
# idRow = MultiRow(idSpan,data=keys)
nameRow = MultiRow(idSpan,data=guide[keys]['name'])
j = 0
for key,val in value.items():
topicSpan = len(val)
topicRow = MultiRow(topicSpan,data=key)
i = 0
for k,v in val.items():
if(i==0 and j==0):
dataTable.add_row(nameRow,topicRow,k,v)
dataTable.add_hline(3,4)
i += 1
j += 1
elif(i==0 and j>0):
dataTable.add_row('',topicRow,k,v)
dataTable.add_hline(3,4)
i += 1
j += 1
else:
dataTable.add_row('','',k,v)
dataTable.add_hline(3,4)
i += 1
j += 1
dataTable.add_hline(2,4)
dataTable.add_hline(1,4)
# doc.append(NoEscape(r'\end{adjustbox}'))
doc.generate_pdf(fileLocation,clean_tex=False)
if __name__ == '__main__':
result = {"GuideId1":{
"TopicId1":{
"1122":'piyush',
"2233":'sharma'
},
"TopicId2":{
"234":'darshan',
"432":'deepak',
"4567":'prabhu'
}},
"GuideId2":{
"TopicId1":{
"1122":'sandeep'
}},
"GuideId3":{
"TopicId1":{
"1123":'Parihar'
},
"TopicId2":{
"234":'Rajeev',
"432":'Vaidyanathan',
"4568":"Natarajan"
},
"TopicId3":{
"1":'abc',
"2":'bcd',
"3":'cde',
"4":'def'
}},
"GuideId4":{
}
}
guide = {
"GuideId1":{
"name":"Ajit Rajwade",
"requirement":5
},
"GuideId2":{
"name":"Preethi Jyothi",
"requirement":2
},
"GuideId3":{
"name":"Vinay Robeiro",
"requirement":10
},
"GuideId4":{
"name":"Suyash P. Awate",
"requirement":10
}
}
mappedResult(result,guide,27,"static/allocationResults")
......@@ -190,7 +190,76 @@
{% endif %}
</div>
<div class="ui tab " data-tab="second">
<div class="ui warning message">
<div class="header ui center aligned">
Instructions to use the priority window
</div>
<ul>
<li>Each card represents priorities to <span class="header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); ">Individual projects</span> proposed by you. You can see the ribbon to understand which project you are working with.</li>
<li>Arrangement of the applications should be in <span class="header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); ">Ascending order</span>.</li>
<li>You can <span class="medium header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); ">hold and move</span> the applications to change the priority arrangements. </li>
<li>Click on the <span class="header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); ">Update priorities</span> to make changes permanent.</li>
</ul>
</div>
{% for shortlistedApplications in ProjectWiseShortlistedApplications %}
<div style="padding: 2em 0;margin: 2em 0;">
<div class="ui grid">
<div class="right floated four wide column">
<button class="fluid ui labeled {% get_table_color forloop.counter0 %} icon button" onclick="submit_priorities({{ forloop.counter0 }},{% with application=shortlistedApplications|index:0 %}{{ application.project.id }}{% endwith %})" >
<i class="plus icon"></i>
Update priorities
</button>
</div>
</div>
<div class="ui segment fluid raised card">
<div class="ui middle aligned selection divided list" style="margin-bottom: 0px;">
<div class="item" style="padding-bottom: 0px;padding-top: 0px;background-color: rgb(0,0,0,0.03);">
<a class="left aligned floating ui {% get_table_color forloop.counter0 %} ribbon label">{% with application=shortlistedApplications|index:0 %} {{ application.project.title }} {% endwith %}</a>
<div class="ui grid center aligned divided" style="margin-top: 0px;">
<div class="four wide column ui tiny header">NAME</div>
<div class="four wide column ui tiny header ">POSITION</div>
<div class="two wide column ui tiny header">CGPA</div>
<div class="two wide column ui tiny header">SHORTLISTED ON</div>
<div class="four wide column ui tiny header">ACTIONS</div>
</div>
</div>
<div class="ui divider" style="margin-bottom: 0px;"></div>
</div>
<div class="ui middle aligned selection divided list" style="margin-top: 0px;" id="sortable-{{ forloop.counter0 }}">
{% for application in shortlistedApplications %}
<div class="item">
<div class="ui grid">
<input type="hidden" readonly="" disabled="" class="applied-student-id" value="{{ application.student.id }}">
<div class="column four wide center aligned middle aligned"><div class="ui medium ">{{ application.student.student.get_full_name }}</div></div>
<div class="column four wide center aligned middle aligned"><div class="ui medium ">{{ application.project.title }}</div></div>
<div class="column two wide center aligned middle aligned"><div class="ui star yellow rating" data-rating="{% get_normalized_grades application.student.get_cgpa %}" data-max-rating="5"></div></div>
<div class="column two wide center aligned middle aligned"><div>{{ application.date }}</div></div>
<div class="center aligned four wide column">
<div class="ui center aligned" style="display: inline-flex;">
<button class="ui vk button" onclick="show_student_detail( '{{ application.student.id }}-{{ application.project.id }}' )">
<i class="address card icon"></i>
Info
</button>
<form action="{% url 'gap:shortlist' %}" method="POST" class="ui column">
{% csrf_token %}
<input type="hidden" name="student_Id" value="{{ application.student.id }}">
<input type="hidden" name="project_Id" value="{{ application.project.id }}">
<input type="hidden" name="action" value="discard">
<button class="ui right labeled icon negative button" onclick="return confirm('Do you want to DISCARD this application?');">
<i class="trash icon"></i>
Discard
</button>
</form>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% endfor %}
</div>
<div class="ui tab" data-tab="third">
<div class="ui warning message">
......@@ -1068,6 +1137,8 @@ $(document).ready(function() {
} );
function sync_total_forms(){
$('#updateforms .requisitesList').each(function(){
$(this).find('#id_requisites-TOTAL_FORMS').val($(this).find('.update-requisites-form').length);
......@@ -1177,7 +1248,47 @@ function deleteupdaterequisitesForm(btn,id,filled_row){
}
function submit_priorities(index,projectId){
$.ajax({
type: 'POST',
url: '{% url "gap:updatePriorities" %}',
data: {
user: 'faculty',
projectId: String(projectId),
priorities: JSON.stringify({'priority_list':$('#sortable-'+String(index)+' .applied-student-id').map(function(){return $(this).val()}).get()}),
csrfmiddlewaretoken: '{{ csrf_token }}',
},
success: function (json) {
$('body')
.toast({
class: "success",
title: "Priority Updation for "+json["title"],
displayTime: 3000,
closeIcon: true,
position: "top center",
showIcon: "check",
message: json["successMessage"],
className: {
toast: 'ui icon message'
}
});
},
error: function (error) {
error_message = error["responseJSON"]["detail"];
$('body')
.toast({
class: "red",
title: "Error updating priorities for <b>" + error["responseJSON"]["title"]+"</b>",
displayTime: 5000,
closeIcon: true,
position: "top center",
showIcon: "exclamation",
message: error_message,
className: {
toast: 'ui message'
}
});
}
});
}
......
......@@ -117,11 +117,150 @@
</div>
<div class="ui tab active" data-tab="first">
{% if applicationDetails %}
<div class="ui warning message">
<i class="close icon"></i>
<div class="header ui center aligned">
Instructions to Candidates
</div>
<ul>
<li>Use the <span class="header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); "> Info </span> button to know more about the project.</li>
<li>Click on <span class="header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); "> Apply </span> to submit your application for the said role.</li>
<li>You can find the shortlisted applications in the <span class="header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); ">Applied Projects</span> tab</li>
</ul>
</div>
{% else %}
<div class="ui warning message">
<i class="close icon"></i>
<div class="header ui center aligned">
Create your profile
</div>
<ul>
<li>You have not built your profile. This will help faculties know you better</li>
<li>You must fill the <span class="medium header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); ">Profile</span> before applying to faculties.</li>
<li>Thy shall go to the <span class="medium header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); ">My Profile</span> section to do the same.</li>
</ul>
</div>
{% endif %}
<table id="example" class="ui table raised segment center aligned" style="width:100%">
<thead>
<tr>
<th>FACULTY NAME</th>
<th>PROJECT TITLE</th>
<th>CONTACT DETAILS</th>
<th>OPEN POSITIONS</th>
<th class="last-th">ACTIONS</th>
</tr>
</thead>
<tbody>
{% for position in unappliedPositions %}
<tr>
<td>
<span class="ui" style="color: #b58105;">{{ position.faculty.get_full_name }}</span>
</td>
<td>
<span style="color: #5279a2;">{{ position.title }}</span>
</td>
<td>
{{ position.contact_details }}
</td>
<td>
<span class="ui orange header">{{ position.total_positions }}</span>
</td>
<td>
<div style="display: inline-flex;">
<button class="ui vk button column" onclick="show_project_detail({{ position.id }})">
<i class="address card icon"></i>
Info
</button>
{% if applicationDetails and not applicationDetails.alloted_project %}
<form action="{% url 'gap:shortlist' %}" method="POST" class="ui column">
{% csrf_token %}
<input type="hidden" name="project_Id" value="{{ position.id }}">
<input type="hidden" name="action" value="shortlist">
<button class="ui icon right labeled teal button" onclick="return confirm('Do you want to SHORTLIST this application?');" >
<i class="check icon"></i>
Apply
</button>
</form>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="ui tab " data-tab="second">
<div class="ui warning message">
<div class="header ui center aligned">
Instructions to use the priority window
</div>
<ul>
<li>Arrangement of the application should be in <span class="header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); ">Ascending order</span>.</li>
<li>You can <span class="header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); ">hold and move</span> the applications to change the priority arrangements </li>
<li>Click on the <span class="header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); ">Update priorities</span> to make changes permanent.</li>
</ul>
</div>
<div class="ui grid">
<div class="right floated four wide column">
{% if appliedPositions %}
<button class="fluid ui labeled teal icon button" onclick="submit_priorities()" >
<i class="plus icon"></i>
Update priorities
</button>
{% endif %}
</div>
</div>
<div class="ui segment fluid raised card">
<div class="ui middle aligned selection divided list" style="margin-bottom: 0px;">
<div class="item" style="padding-bottom: 0px;padding-top: 0px;background-color: rgb(0,0,0,0.03);">
<div class="ui grid center aligned divided" style="margin-top: 0px;">
<div class="three wide column ui tiny header">FACULTY NAME</div>
<div class="four wide column ui tiny header ">PROJECT TITLE</div>
<div class="four wide column ui tiny header">CONTACT DETAILS</div>
<div class="two wide column ui tiny header">OPEN POSITIONS</div>
<div class="three wide column ui tiny header">ACTIONS</div>
</div>
</div>
<div class="ui divider" style="margin-bottom: 0px;"></div>
</div>
<div class="ui middle aligned selection divided list" style="margin-top: 0px;" id="sortable">
{% for position in appliedPositions %}
<div class="item">
<div class="ui grid">
<input type="hidden" readonly="" disabled="" class="applied-project-id" value="{{ position.id }}">
<div class="column three wide center aligned middle aligned"><span class="ui" style="color: #b58105;">{{ position.faculty.get_full_name }}</span></div>
<div class="column four wide center aligned middle aligned"><span style="color: #5279a2;">{{ position.title }}</span></div>
<div class="column four wide center aligned middle aligned">{{ position.contact_details }}</div>
<div class="column two wide center aligned middle aligned"><span class="ui header" style="color: #f2711c;">{{ position.total_positions }}</span></div>
<div class="right floated three wide column">
<div class="ui center aligned" style="display: inline-flex;">
<button class="ui vk button" onclick="show_project_detail({{ position.id }})">
<i class="address card icon"></i>
Info
</button>
<form action="{% url 'gap:shortlist' %}" method="POST" class="ui column">
{% csrf_token %}
<input type="hidden" name="project_Id" value="{{ position.id }}">
<input type="hidden" name="action" value="discard">
<button class="ui right labeled icon negative button" onclick="return confirm('Do you want to DISCARD this application?');">
<i class="trash icon"></i>
Discard
</button>
</form>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
<div class="ui tab" data-tab="third">
......@@ -993,6 +1132,45 @@ function deleteEducationDetailForm(btn,filled_row){
}
function submit_priorities(){
$.ajax({
type: 'POST',
url: '{% url "gap:updatePriorities" %}',
data: {
user: 'student',
priorities: JSON.stringify({'priority_list':$('.applied-project-id').map(function(){return $(this).val()}).get()}),
csrfmiddlewaretoken: '{{ csrf_token }}',
},
success: function (json) {
$('body')
.toast({
class: "success",
title: "Priority Updation",
displayTime: 3000,
closeIcon: true,
position: "top center",
showIcon: "check",
message: json["successMessage"],
className: {
toast: 'ui icon message'
}
});
},
error: function (error) {
error_message = error["responseJSON"]["detail"];
$('body')
.toast({
class: "red",
title: "Error updating priorities",
displayTime: 5000,
closeIcon: true,
position: "top center",
showIcon: "exclamation",
message: error_message,
className: {
toast: 'ui message'
}
});
}
});
}
{% endblock %}
\ No newline at end of file
from django.urls import path, include
from .views import LoginView, LogoutView, dashboardView, shortlistView, updatePriorityView, generateMappingsView
from .views import LoginView, LogoutView, dashboardView, shortlistView, updatePriorityView
urlpatterns = [
path('login',LoginView.as_view(),name="login"),
path('logout',LogoutView,name="logout"),
path('',dashboardView.as_view(),name="dashboard"),
path('generatemapping',generateMappingsView,name="generateMapping")
path('shortlist',shortlistView,name="shortlist"),
path('updatepriorities',updatePriorityView,name="updatePriorities")
]
File mode changed from 100644 to 100755
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment