Commit 4d61743d authored by Darshan Prabhu's avatar Darshan Prabhu

Revert "Login methods and application view to faculties and students"

This reverts commit 4dbb4e6a
parent 3e57a643
from django.contrib import admin from django.contrib import admin
# Register your models here. # Register your models here.
from .models import *
from django_drf_filepond.models import TemporaryUpload, StoredUpload
admin.site.register(PositionsModel)
admin.site.register(RequisitesModel)
admin.site.register(StudentDetailModel)
admin.site.register(StudentProjectsModel)
admin.site.register(StudentEducationModel)
admin.site.register(StudentPriorities)
admin.site.register(ProjectPriorities)
admin.site.register(GeneratedMappingsModel)
admin.site.register(RoundDetailsModel)
admin.site.register(StudentPrioritiesArchive)
admin.site.register(ProjectPrioritiesArchive)
admin.site.register(StudentResumeModel)
admin.site.register(TemporaryUpload)
admin.site.register(StoredUpload)
\ No newline at end of file
...@@ -106,88 +106,6 @@ ...@@ -106,88 +106,6 @@
</div> </div>
<div class="ui tab active" data-tab="first"> <div class="ui tab active" data-tab="first">
{% if availablePositions|length == 0 %}
<div class="ui warning message">
<i class="close icon"></i>
<div class="header ui center aligned">
Information to Faculty
</div>
<ul>
<li>You have not added any <span class="medium header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); ">Projects</span> yet.</li>
</ul>
</div>
{% elif allApplications|length == 0 %}
<div class="ui warning message">
<i class="close icon"></i>
<div class="header ui center aligned">
Information to Faculty
</div>
<ul>
<li><span class="medium header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); ">No applications</span> are submitted to you yet.</li>
</ul>
</div>
{% else %}
<div class="ui warning message">
<i class="close icon"></i>
<div class="header ui center aligned">
Instructions to Faculty
</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 student.</li>
<li>Click on <span class="header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); "> Shortlist </span> to allocate priority to said student.</li>
<li>You can find the shortlisted applications in the <span class="header" style="display: inline;background-color:rgba(0, 0, 0, 0.06); ">Shortlisted Applications</span> tab.</li>
</ul>
</div>
<table id="applications" class="ui table raised segment center aligned" style="width:100%">
<thead>
<tr>
<th>NAME</th>
<th>POSITION</th>
<th>CGPA</th>
<th>DATE</th>
<th class="last-th">ACTIONS</th>
</tr>
</thead>
<tbody>
{% for application in allApplications %}
<tr>
<td>
{{ application.student.student.get_full_name }}
</td>
<td>
{{ application.project.title }}
</td>
<td>
<div style="display: none;">{% get_normalized_grades application.student.get_cgpa %}</div>
<div class="ui yellow rating" data-rating="{% get_normalized_grades application.student.get_cgpa %}" data-max-rating="5">
</td>
<td>
{{ application.date }}
</td>
<td>
<div class="" 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="shortlist">
<button class="ui icon right labeled teal button" onclick="return confirm('Do you want to SHORTLIST this application?');" >
<i class="check icon"></i>
Shortlist
</button>
</form>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div> </div>
<div class="ui tab " data-tab="second"> <div class="ui tab " data-tab="second">
...@@ -1045,10 +963,6 @@ $(document).ready(function() { ...@@ -1045,10 +963,6 @@ $(document).ready(function() {
$('#applications').DataTable({ $('#applications').DataTable({
columnDefs: [ { orderable: false, targets: [4] } ], columnDefs: [ { orderable: false, targets: [4] } ],
}); });
{% if user_type == 'facad' %}
$('#generatedAllotments').DataTable({
});
{% endif %}
$('.ui.dropdown').dropdown(); $('.ui.dropdown').dropdown();
sync_total_forms(); sync_total_forms();
{% if messages %} {% if messages %}
...@@ -1068,6 +982,8 @@ $(document).ready(function() { ...@@ -1068,6 +982,8 @@ $(document).ready(function() {
} ); } );
function sync_total_forms(){ function sync_total_forms(){
$('#updateforms .requisitesList').each(function(){ $('#updateforms .requisitesList').each(function(){
$(this).find('#id_requisites-TOTAL_FORMS').val($(this).find('.update-requisites-form').length); $(this).find('#id_requisites-TOTAL_FORMS').val($(this).find('.update-requisites-form').length);
...@@ -1177,7 +1093,6 @@ function deleteupdaterequisitesForm(btn,id,filled_row){ ...@@ -1177,7 +1093,6 @@ function deleteupdaterequisitesForm(btn,id,filled_row){
} }
function submit_priorities(index,projectId){ function submit_priorities(index,projectId){
} }
......
<!DOCTYPE html>
<html>
<head>
<title>GAP</title>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.7/semantic.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.4.1/components/icon.min.css" integrity="sha512-8Tb+T7SKUFQWOPIQCaLDWWe1K/SY8hvHl7brOH8Nz5z1VT8fnf8B+9neoUzmFY3OzkWMMs3OjrwZALgB1oXFBg==" crossorigin="anonymous" />
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.7/semantic.min.js"></script>
<!-- Custom styling -->
<style type="text/css">
.typewriter h1 {
color: #fff;
font-family: monospace;
overflow: hidden; /* Ensures the content is not revealed until the animation */
border-right: .15em solid orange; /* The typwriter cursor */
white-space: nowrap; /* Keeps the content on a single line */
margin: 0 auto; /* Gives that scrolling effect as the typing happens */
letter-spacing: .1em; /* Adjust as needed */
animation:
typing 3.5s steps(30, end),
blink-caret .5s step-end infinite;
}
/* The typing effect */
@keyframes typing {
from { width: 0 }
to { width: 100% }
}
/* The typewriter cursor effect */
@keyframes blink-caret {
from, to { border-color: transparent }
50% { border-color: orange }
}
form h4 {
font-size: 1.5rem;
text-align: center;
padding-bottom: 1rem;
font-family: monospace;
}
h3{
font-size: 1.5rem;
font-family: monospace;
padding-left: inherit;
}
.field{
padding-bottom: 1rem;
}
form{
top: 32%;
padding-left: 2rem;
}
</style>
</head>
<body>
<div class="ui two column grid" style="min-height: 100%;">
<div class="column ui aligned grid teal">
<div class="column" style="top:35%;padding-left: 13%;">
<div class=typewriter>
<h1 style="font-size: 2.5rem;">Guide Allocation Portal</h1>
</div>
<h3>CSE Department, IIT Bombay</h3>
</div>
</div>
<div class="column">
<form class="ui large form" method="POST">
{% csrf_token %}
<h4 >Login now</h4>
<div class="ui">
<div class="field">
<div class="ui left icon input">
<i class="user icon"></i>
<input type="text" name="username" placeholder="CSE username">
</div>
</div>
<div class="field">
<div class="ui left icon input">
<i class="lock icon"></i>
<input type="password" name="password" placeholder="Password">
</div>
</div>
<button class="ui fluid large black submit button" type="submit">Login</button>
</div>
</form>
</div>
</div>
<!-- Scripts -->
{% if messages %}
{% for message in messages %}
<script>
$('body')
.toast({
class: "red",
title: "Error logging in",
displayTime: 3000,
closeIcon: true,
position: "top center",
showIcon: "exclamation",
message: "{{ message }}",
className: {
toast: 'ui icon message'
}
});
</script>
{% endfor %}
{% endif %}
</body>
</html>
\ No newline at end of file
from django import template
from ..choices import language_color_mappings, color_choices
import random
from datetime import datetime, timezone
register = template.Library()
# Function to get particular element from a list
@register.filter
def index(indexable, i):
'''
Input:
indexable: Array type date
i: index
Output:
element at index i in indexable
'''
return indexable[i]
# Function to get color for a language
@register.simple_tag
def get_color(language):
'''
Input:
language: Language
Output:
color for language
'''
return language_color_mappings[language]
# Function to get normalized grades
@register.simple_tag
def get_normalized_grades(grade):
'''
Input:
grade: Unnormalized grade, can be for 100 or 10
Output:
grade normalized to 5
'''
if grade < 11:
return grade / 2.0
else:
return grade / 20.0
# Function to get color for priority tables to guide
@register.simple_tag
def get_table_color(index):
'''
Input:
index: Index of the table'
Output:
Random color choice
'''
index = index % len(color_choices)
return color_choices[index]
# Function to get random color
@register.simple_tag
def get_random_color(index):
'''
Input:
index: Index
Output:
Random color choice
'''
return random.choice(color_choices)
# Function to get cout of elements in nested list
@register.filter
def get_count_multilist(indexable):
'''
Input:
indexable: Nested list
Output:
count of elements in indexable
'''
return flatten_count(indexable)
# Function to calculate left over days for round ending
@register.simple_tag
def get_remaining_days(date):
'''
Input:
date: roundDetail object
Output:
string showing remaining days
'''
string = ''
now = datetime.now(timezone.utc).date()
diff = date - now
year = diff.days//365.25
month = (diff.days%365) // 30
day = (diff.days%30)
hour = diff.seconds//3600
minute = (diff.seconds%3600) // 60
second = diff.seconds%60
if year != 0 :
if year == 1:
string = '{} year to go'.format(year)
else:
string = '{} years to go'.format(year)
elif month != 0 :
if month == 1:
string = '{} month to go'.format(month)
else:
string = '{} months to go'.format(month)
elif day != 0 :
if day == 1:
string = '{} day to go'.format(day)
else:
string = '{} days to go'.format(day)
elif hour != 0 :
if hour == 1:
string = '{} hour to go'.format(hour)
else:
string = '{} hours to go'.format(hour)
elif minute != 0 :
if minute == 1:
string = '{} minute to go'.format(minute)
else:
string = '{} minutes to go'.format(minute)
else:
if second == 0:
string = ' About to end'
elif second == 1:
string = '{} second to go'.format(second)
else:
string = '{} seconds to go'.format(second)
return string
# Function to get percentage of time left over
@register.simple_tag
def get_progress_percent(current_round):
'''
Input:
date: roundDetail object
Output:
percentage of remaining time
'''
now = datetime.now(timezone.utc).date()
start_date = current_round.startDate
end_date = current_round.endDate
return (end_date - now).days*100.0 / (end_date-start_date).days
# Function to get color of timebar
@register.simple_tag
def get_progress_color(date):
'''
Input:
Date : end date
Output:
returns color based on remaining time
'''
now = datetime.now(timezone.utc).date()
diff = date - now
if diff.days >= 6:
return "green"
if diff.days >4:
return "yellow"
if diff.days >2:
return "orange"
return "red"
# Helper codes
# COde to get count of nested list
def flatten_count(listOrItem, result = None):
if type(listOrItem) != type([]): # Handle non-list by appending.
return 1
else:
count = 0
for item in listOrItem: # Recursively handle each item in a list.
count+=flatten_count(item, result)
return count
\ No newline at end of file
...@@ -2,8 +2,6 @@ from django.urls import path, include ...@@ -2,8 +2,6 @@ from django.urls import path, include
from .views import LoginView, LogoutView, dashboardView, shortlistView, updatePriorityView, generateMappingsView from .views import LoginView, LogoutView, dashboardView, shortlistView, updatePriorityView, generateMappingsView
urlpatterns = [ urlpatterns = [
path('login',LoginView.as_view(),name="login"),
path('logout',LogoutView,name="logout"),
path('',dashboardView.as_view(),name="dashboard"), path('',dashboardView.as_view(),name="dashboard"),
path('generatemapping',generateMappingsView,name="generateMapping") path('generatemapping',generateMappingsView,name="generateMapping")
] ]
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from django.views import View from django.views import View
from django.contrib.auth import authenticate, login, logout
from django.contrib import messages from django.contrib import messages
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
from django.db import transaction from django.db import transaction
from django.http import JsonResponse from django.http import JsonResponse
import json import json
...@@ -12,44 +9,11 @@ from datetime import datetime ...@@ -12,44 +9,11 @@ from datetime import datetime
from .models import * from .models import *
from django.contrib.auth.models import User from django.contrib.auth.models import User
from .forms import * from .forms import *
from .allocator import SPA
from.LatexGen import mappedResult from.LatexGen import mappedResult
from django_drf_filepond.api import store_upload, delete_stored_upload from django_drf_filepond.api import store_upload, delete_stored_upload
from django_drf_filepond.models import TemporaryUpload, StoredUpload from django_drf_filepond.models import TemporaryUpload, StoredUpload
# View to handle login page
class LoginView(View):
template_name = 'login.html'
def get(self,request,*args,**kwargs):
# Render login page
return render(request,self.template_name)
def post(self,request,*args,**kwargs):
# Get details from the post request
username = request.POST.get('username')
password = request.POST.get('password')
user = authenticate(request,username=username,password=password)
if user is not None:
# user exists
login(request,user)
return redirect('gap:dashboard')
else:
messages.error(request,'Username or password is incorrect')
return render(request,self.template_name)
# Function to logout a user
@login_required(login_url = 'gap:login')
def LogoutView(request):
logout(request)
return redirect('gap:login')
# Dashboard for all users # Dashboard for all users
class dashboardView(LoginRequiredMixin,UserPassesTestMixin,View): class dashboardView(LoginRequiredMixin,UserPassesTestMixin,View):
login_url = reverse_lazy('gap:login') login_url = reverse_lazy('gap:login')
......
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