Commit 2748f76b authored by Darshan Prabhu's avatar Darshan Prabhu

Altered configurations, to facilitate swift hosting on server

parent 1229c12a
from django.conf import settings
def environment_variables(request):
return {
'ALLOCATION_PDF_NAME': settings.ALLOCATION_PDF_NAME + ".pdf",
}
\ No newline at end of file
...@@ -25,7 +25,7 @@ SECRET_KEY = 'd#bja*fn$qe^dy24hdf3okp%qhmcaqh4gv%q&ltcay)xu^7!16' ...@@ -25,7 +25,7 @@ SECRET_KEY = 'd#bja*fn$qe^dy24hdf3okp%qhmcaqh4gv%q&ltcay)xu^7!16'
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
ALLOWED_HOSTS = [] ALLOWED_HOSTS = ['localhost','127.0.0.1','web-nginx-test.cse.iitb.ac.in']
# Application definition # Application definition
...@@ -65,6 +65,8 @@ TEMPLATES = [ ...@@ -65,6 +65,8 @@ TEMPLATES = [
'django.template.context_processors.request', 'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth', 'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages', 'django.contrib.messages.context_processors.messages',
"django.template.context_processors.media",
"GAP.constants.environment_variables"
], ],
}, },
}, },
...@@ -113,7 +115,7 @@ AUTH_PASSWORD_VALIDATORS = [ ...@@ -113,7 +115,7 @@ AUTH_PASSWORD_VALIDATORS = [
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC' TIME_ZONE = 'Asia/Kolkata'
USE_I18N = True USE_I18N = True
...@@ -121,10 +123,20 @@ USE_L10N = True ...@@ -121,10 +123,20 @@ USE_L10N = True
USE_TZ = True USE_TZ = True
MEDIA_URL = '/~internal/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/ # https://docs.djangoproject.com/en/2.2/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = '/~internal/assets/'
DJANGO_DRF_FILEPOND_UPLOAD_TMP = os.path.join(BASE_DIR, 'guideAllocationPortal/static/resume-temp-uploads') STATIC_ROOT = os.path.join(BASE_DIR,'~internal','assets')
DJANGO_DRF_FILEPOND_FILE_STORE_PATH = os.path.join(BASE_DIR, 'guideAllocationPortal/static/resume-uploads')
\ No newline at end of file CORS_ORIGIN_WHITELIST = ['http://web-nginx-test.cse.iitb.ac.in']
DJANGO_DRF_FILEPOND_UPLOAD_TMP = os.path.join(MEDIA_ROOT,'resume-temp-uploads')
DJANGO_DRF_FILEPOND_FILE_STORE_PATH = MEDIA_ROOT
# Environment paths
ALLOCATION_PDF_NAME = "allocationResults"
RESUME_FOLDER_NAME = "resume-uploads"
...@@ -15,10 +15,12 @@ Including another URLconf ...@@ -15,10 +15,12 @@ Including another URLconf
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include
from django.conf import settings
from django.conf.urls import url from django.conf.urls import url
from django.conf.urls.static import static
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('',include(("guideAllocationPortal.urls","gap"),namespace="gap")), path('',include(("guideAllocationPortal.urls","gap"),namespace="gap")),
url(r'^fp/', include('django_drf_filepond.urls')), url(r'^fp/', include(('django_drf_filepond.urls',"drf"),namespace="filepond")),
] ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
{% extends "base.html" %} {% extends "base.html" %}
{% load custom_tags %} {% load custom_tags %}
{% load static %} {% load static %}
{% get_media_prefix %}.
{% block styling %} {% block styling %}
.statistic:not(.last-stat){ .statistic:not(.last-stat){
border-right: 1px solid #e0e1e2 ; border-right: 1px solid #e0e1e2 ;
...@@ -507,7 +508,7 @@ ...@@ -507,7 +508,7 @@
<div class="ui center aligned header" style="color:slategrey;">Allotments done so far <div class="ui center aligned header" style="color:slategrey;">Allotments done so far
<button class="ui right floated flexible labeled teal icon button" onclick="$(this).find('a')[0].click()" > <button class="ui right floated flexible labeled teal icon button" onclick="$(this).find('a')[0].click()" >
<i class="file download icon"></i> <i class="file download icon"></i>
<a href="{% static 'guideAllocationPortal/allocationResults.pdf' %}" style="display: none;" target="_blank"></a> <a href="{{ MEDIA_URL }}{{ ALLOCATION_PDF_NAME }}" style="display: none;" target="_blank"></a>
Download allotments Download allotments
</button> </button>
</div> </div>
......
...@@ -330,14 +330,12 @@ ...@@ -330,14 +330,12 @@
<i class="download icon"></i> <i class="download icon"></i>
<div class="content"> <div class="content">
<div class="header"> <div class="header">
Resume of the applicant Resume of the applicant
</div> </div>
{% if ResumeDetails %} {% if ResumeDetails %}
{% with 'resume-uploads/'|add:'/'|add:ResumeDetails.file.file.name as image_static %} <div class="ui center aligned" ><a href="{{ ResumeDetails.file.file.url }}" target="_blank">Click me to download resume</a></div>
<div class="ui center aligned" ><a href="{% static image_static %}" target="_blank">Click me to download resume</a></div>
{% endwith %}
{% else %} {% else %}
<div class="ui center aligned" ><div style="color:slategrey;">You have not uploaded the Resume.</div></div> <div class="ui center aligned" ><div style="color:slategrey;">You have not uploaded the Resume.</div></div>
{% endif %} {% endif %}
</div> </div>
</div> </div>
...@@ -962,7 +960,7 @@ $(document).ready(function() { ...@@ -962,7 +960,7 @@ $(document).ready(function() {
$('.ui.dropdown').dropdown(); $('.ui.dropdown').dropdown();
FilePond.setOptions({ FilePond.setOptions({
server: { server: {
url: 'http://127.0.0.1:8000/fp', url: '/fp',
process: '/process/', process: '/process/',
patch: '/patch/', patch: '/patch/',
revert: '/revert/', revert: '/revert/',
......
...@@ -17,6 +17,8 @@ from.LatexGen import mappedResult ...@@ -17,6 +17,8 @@ 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
from django.conf import settings
# View to handle login page # View to handle login page
class LoginView(View): class LoginView(View):
...@@ -128,7 +130,7 @@ class dashboardView(LoginRequiredMixin,UserPassesTestMixin,View): ...@@ -128,7 +130,7 @@ class dashboardView(LoginRequiredMixin,UserPassesTestMixin,View):
elif curr_upload_id != upload_id: elif curr_upload_id != upload_id:
# Update previous resume if new one is different from old resume # Update previous resume if new one is different from old resume
temp_upload = TemporaryUpload.objects.get(upload_id=upload_id) temp_upload = TemporaryUpload.objects.get(upload_id=upload_id)
file_reference = store_upload(upload_id,destination_file_path=str(request.user.username) + "/"+ temp_upload.upload_name ) file_reference = store_upload(upload_id,destination_file_path= settings.RESUME_FOLDER_NAME + "/" + str(request.user.username) + "/"+ temp_upload.upload_name )
resume_record.file = file_reference resume_record.file = file_reference
resume_record.save() resume_record.save()
delete_stored_upload(curr_upload_id,delete_file=True) delete_stored_upload(curr_upload_id,delete_file=True)
...@@ -136,7 +138,7 @@ class dashboardView(LoginRequiredMixin,UserPassesTestMixin,View): ...@@ -136,7 +138,7 @@ class dashboardView(LoginRequiredMixin,UserPassesTestMixin,View):
if upload_id != "": if upload_id != "":
# Create new resume model row # Create new resume model row
temp_upload = TemporaryUpload.objects.get(upload_id=upload_id) temp_upload = TemporaryUpload.objects.get(upload_id=upload_id)
file_reference = store_upload(upload_id,destination_file_path=str(request.user.username) + "/"+ temp_upload.upload_name ) file_reference = store_upload(upload_id,destination_file_path= settings.RESUME_FOLDER_NAME + "/" + str(request.user.username) + "/"+ temp_upload.upload_name )
resume_record = StudentResumeModel(student=user_application,file=file_reference) resume_record = StudentResumeModel(student=user_application,file=file_reference)
resume_record.save() resume_record.save()
else: else:
...@@ -586,5 +588,5 @@ def generate_pdf(): ...@@ -586,5 +588,5 @@ def generate_pdf():
print(mappings) print(mappings)
print(guide_info) print(guide_info)
# Storage location for the file # Storage location for the file
filelocation = "guideAllocationPortal/static/guideAllocationPortal/allocationResults" filelocation = "media/" + settings.ALLOCATION_PDF_NAME
mappedResult(mappings,guide_info,StudentDetailModel.objects.all().count(),filelocation) mappedResult(mappings,guide_info,StudentDetailModel.objects.all().count(),filelocation)
\ No newline at end of file
\documentclass{article}%
\usepackage[T1]{fontenc}%
\usepackage[utf8]{inputenc}%
\usepackage{lmodern}%
\usepackage{textcomp}%
\usepackage{lastpage}%
\usepackage{geometry}%
\geometry{margin=0.4in}%
\usepackage{ragged2e}%
\usepackage{longtable}%
\usepackage{tabu}%
\usepackage{booktabs}%
\usepackage{multirow}%
%
%
%
\begin{document}%
\normalsize%
\begin{center}%
\begin{Large}%
\textbf{Summary}%
\end{Large}%
\end{center}%
\renewcommand{\arraystretch}{2.0}%
\setlength{\tabcolsep}{1in}%
\begin{longtabu}{|c c|}%
\hline%
\textbf{No. of Students applied}&2\\%
\textbf{No. of Slots Offered}&4\\%
\textbf{No. of Students alloted}&2\\%
\hline%
\end{longtabu}%
\renewcommand{\arraystretch}{2.0}%
\setlength{\tabcolsep}{0.35in}%
\begin{longtabu}{|c c c c|}%
\hline%
\textbf{GuideId}&\textbf{Guide Name}&\textbf{Requirements}&\textbf{Alloted}\\%
\hline%
\hline%
fac{-}1&Faculty 1&4&\textbf{2}\\%
\hline%
\end{longtabu}%
\begin{center}%
\begin{Large}%
\textbf{Student{-}Guide Mapping Result for Seminar}%
\end{Large}%
\end{center}%
\renewcommand{\arraystretch}{2.0}%
\setlength{\tabcolsep}{0.2in}%
\begin{longtabu}{@{}|c|c|c|c|c|@{}}%
\toprule%
\midrule%
\textbf{GuideId}&\textbf{GuideName}&\textbf{Topic\_offered}&\textbf{AllotedStudentId}&\textbf{AllotedStudentName}\\%
\midrule%
\midrule%
\endhead%
\multirow{2}{*}{fac{-}1}&\multirow{2}{*}{Faculty 1}&\multirow{2}{*}{1}&1&darshan\\%
\cmidrule{4%
-%
5}%
&&&2&student{-}1\\%
\cmidrule{4%
-%
5}%
\cmidrule{3%
-%
5}%
\cmidrule{1%
-%
5}\bottomrule%
%
\end{longtabu}%
\end{document}
\ No newline at end of file
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