Prod Changes

This commit is contained in:
Gowtham Sai 2022-08-04 00:49:53 +05:30
parent 3115efa9eb
commit d694268623
9 changed files with 40 additions and 46 deletions

View File

@ -8,7 +8,6 @@ from django.utils.safestring import SafeText
from .models import * from .models import *
admin.site.register(User, SimpleHistoryAdmin) admin.site.register(User, SimpleHistoryAdmin)
admin.site.register(Admin, SimpleHistoryAdmin)
admin.site.site_header = "CDC Recruitment Portal" admin.site.site_header = "CDC Recruitment Portal"

View File

@ -1,3 +1,5 @@
import os
BRANCH_CHOICES = [ BRANCH_CHOICES = [
["CSE", "CSE"], ["CSE", "CSE"],
["EE", "EE"], ["EE", "EE"],
@ -36,14 +38,15 @@ TOTAL_BRANCHES = 4 # Total No of Branches
TOTAL_BATCHES = 4 # Total No of Batches TOTAL_BATCHES = 4 # Total No of Batches
# To be Configured Properly # To be Configured Properly
CLIENT_ID = "956830229554-290mirc16pdhd5j7ph7v7ukibo4t1qcp.apps.googleusercontent.com" # Google Login Client ID CLIENT_ID = os.environ.get('GOOGLE_OAUTH_CLIENT_ID') # Google Login Client ID
# To be Configured Properly # To be Configured Properly
PLACEMENT_OPENING_URL = "http://localhost:3000/student/dashboard/placements/{id}" # On frontend, this is the URL to be opened PLACEMENT_OPENING_URL = "https://cdc.iitdh.ac.in/portal/student/dashboard/placements/{id}" # On frontend, this is the URL to be opened
LINK_TO_STORAGE_COMPANY_ATTACHMENT = "http://localhost/storage/Company_Attachments/" LINK_TO_STORAGE_COMPANY_ATTACHMENT = "https://cdc.iitdh.ac.in/storage/Company_Attachments/"
LINK_TO_STORAGE_RESUME = "http://localhost/storage/Resumes/" LINK_TO_STORAGE_RESUME = "https://cdc.iitdh.ac.in/storage/Resumes/"
LINK_TO_APPLICATIONS_CSV = "http://localhost/storage/Application_CSV/" LINK_TO_APPLICATIONS_CSV = "https://cdc.iitdh.ac.in/storage/Application_CSV/"
LINK_TO_EMAIl_VERIFICATION_API = "http://localhost:3000/company/verifyEmail?token={token}" LINK_TO_EMAIl_VERIFICATION_API = "https://cdc.iitdh.ac.in/portal/company/verifyEmail?token={token}"
PDF_FILES_SERVING_ENDPOINT = 'https://cdc.iitdh.ac.in/storage/Company_Attachments/' # TODO: Change this to actual URL
EMAIL = "email" EMAIL = "email"
@ -54,6 +57,7 @@ TIER = 'tier'
# To be Configured Properly # To be Configured Properly
FOURTH_YEAR = '2019' FOURTH_YEAR = '2019'
MAX_OFFERS_PER_STUDENT = 2 MAX_OFFERS_PER_STUDENT = 2
MAX_RESUMES_PER_STUDENT = 3
EMAIL_VERIFICATION_TOKEN_TTL = 48 # in hours EMAIL_VERIFICATION_TOKEN_TTL = 48 # in hours
JNF_TEXT_MAX_CHARACTER_COUNT = 100 JNF_TEXT_MAX_CHARACTER_COUNT = 100
JNF_TEXTMEDIUM_MAX_CHARACTER_COUNT = 200 JNF_TEXTMEDIUM_MAX_CHARACTER_COUNT = 200
@ -155,4 +159,3 @@ NOTIFY_STUDENTS_OPENING_TEMPLATE = 'notify_students_new_opening.html'
APPLICATION_CSV_COL_NAMES = ['Applied At', 'Roll No.', 'Name', 'Email', 'Phone Number', 'Branch', 'Batch', 'CPI', APPLICATION_CSV_COL_NAMES = ['Applied At', 'Roll No.', 'Name', 'Email', 'Phone Number', 'Branch', 'Batch', 'CPI',
'Resume', 'Selected', ] 'Resume', 'Selected', ]
PDF_FILES_SERVING_ENDPOINT = 'http://localhost/storage/Company_Attachments/' # TODO: Change this to actual URL

View File

@ -6,9 +6,6 @@ from simple_history.models import HistoricalRecords
from .constants import * from .constants import *
# from .utils import *
class User(models.Model): class User(models.Model):
email = models.EmailField(primary_key=True, blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT) email = models.EmailField(primary_key=True, blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT)
id = models.CharField(blank=False, max_length=25, db_index=True) id = models.CharField(blank=False, max_length=25, db_index=True)
@ -50,25 +47,6 @@ class Student(models.Model):
self.changed_by = None self.changed_by = None
class Admin(models.Model):
id = models.CharField(blank=False, max_length=15, primary_key=True)
name = models.CharField(blank=False, max_length=JNF_TEXT_MAX_CHARACTER_COUNT)
changed_by = models.ForeignKey(User, blank=True, on_delete=models.RESTRICT, default=None, null=True)
history = HistoricalRecords(user_model=User)
@property
def _history_user(self):
return self.changed_by
@_history_user.setter
def _history_user(self, value):
if isinstance(value, User):
self.changed_by = value
else:
self.changed_by = None
def two_day_after_today(): def two_day_after_today():
return timezone.now() + timezone.timedelta(days=2) return timezone.now() + timezone.timedelta(days=2)

View File

@ -40,6 +40,9 @@ def addResume(request, id, email, user_type):
student = get_object_or_404(Student, id=id) student = get_object_or_404(Student, id=id)
files = request.FILES files = request.FILES
if len(student.resumes) >= MAX_RESUMES_PER_STUDENT:
raise PermissionError('Max Number of Resumes limit reached')
file = files['file'] file = files['file']
destination_path = STORAGE_DESTINATION_RESUMES + str(student.roll_no) + "/" destination_path = STORAGE_DESTINATION_RESUMES + str(student.roll_no) + "/"
file_name = saveFile(file, destination_path) file_name = saveFile(file, destination_path)
@ -51,6 +54,9 @@ def addResume(request, id, email, user_type):
except Http404: except Http404:
return Response({'action': "Upload Resume", 'message': 'Student Not Found'}, return Response({'action': "Upload Resume", 'message': 'Student Not Found'},
status=status.HTTP_404_NOT_FOUND) status=status.HTTP_404_NOT_FOUND)
except PermissionError:
return Response({'action': "Upload Resume", 'message': 'Max Number of Resumes limit reached'},
status=status.HTTP_400_BAD_REQUEST)
except: except:
if path.exists(destination_path): if path.exists(destination_path):
logger.error("Upload Resume: Error in Saving Resume") logger.error("Upload Resume: Error in Saving Resume")

View File

@ -269,7 +269,7 @@ def opening_description_table_html(opening):
if key == 'website': if key == 'website':
details[key] = {"details": details[key], "type": ["link"]} details[key] = {"details": details[key], "type": ["link"]}
else: else:
details[key] = {"details": [item[16:] for item in details[key]["details"]], "type": ["list", "link"], details[key] = {"details": [item for item in details[key]["details"]], "type": ["list", "link"],
"link": PDF_FILES_SERVING_ENDPOINT + opening.id + "/"} "link": PDF_FILES_SERVING_ENDPOINT + opening.id + "/"}
new_key = key.replace('_', ' ') new_key = key.replace('_', ' ')
if new_key.endswith(' names'): if new_key.endswith(' names'):

View File

@ -24,12 +24,12 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'e_i2g3z!y4+p3dwm%k9k=zmsot@aya-0$mmetgxz4mp#8_oy#*' SECRET_KEY = os.environ.get("SECRET_KEY")
# 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 = os.environ.get('DEBUG')
ALLOWED_HOSTS = ['cdc-iitdh.herokuapp.com/', 'localhost', '192.168.29.199', '127.0.0.1'] ALLOWED_HOSTS = ['cdc.iitdh.ac.in', 'localhost']
# Application definition # Application definition
@ -153,6 +153,8 @@ CORS_ORIGIN_WHITELIST = [
"http://127.0.0.1:8000" "http://127.0.0.1:8000"
] ]
CSRF_TRUSTED_ORIGINS = []
# EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend' # EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = './emails' EMAIL_FILE_PATH = './emails'

View File

@ -44,7 +44,7 @@
{% for item in value.details %} {% for item in value.details %}
<li> <li>
{% if 'link' in value.type and value.link %} {% if 'link' in value.type and value.link %}
<a href="{{ value.link|add:item}}">{{ item }}</a> <a href="{{ value.link|add:item}}">{{ item|slice:"16:"}}</a>
{% elif 'link' in value.type %} {% elif 'link' in value.type %}
<a href="{{ item }}">{{ item }}</a> <a href="{{ item }}">{{ item }}</a>
{% else %} {% else %}

View File

@ -1,6 +1,5 @@
HOSTING_URL=http://localhost:8000/
DEBUG=True DEBUG=True
EMAIL=saisurya3127@gmail.com EMAIL=cdc.support@iitdh.ac.in
EMAIL_PASSWORD=deirkdgolaopottv EMAIL_PASSWORD=deirkdgolaopottv
SECRET_KEY=%2e!&f6(ib^690y48z=)&w6fczhwukzzp@3y*^*7u+7%4s-mie SECRET_KEY=%2e!&f6(ib^690y48z=)&w6fczhwukzzp@3y*^*7u+7%4s-mie
EMAIL_VERIFICATION_SECRET_KEY=b'<\xa3\xaf&(*|\x0e\xbces\x07P\xf7\xd6\xa9sf\x19$\x96\xb7\x90\x8b\x88\x84\x0e\x191\xde,M\x90\x17(\xf7\nG\x13"\x8d$\x9f&\xb0\xcd\xa4\xaf\xa9\x1b\x15\x02B\x8a\xaf\xff\x0c\x1e\xd5\xb3\x06\xb8\xa6\x9bQ\xa0TR\xe8\x98\x9ae\xe0n}\xcc/[\xdaFz\x18\xfeX\xaf\xbd\xd0\x88\xeal\xe3\xd2\xe3\xb8\x8c\x199{\xf3<\xb0\xc5\xd0\xe7*Rv\xda\xbb \x1d\x85~\xff%>\x1e\xb8\xa7\xbf\xbc\xb2\x06\x86X\xc3\x9f\x13<\x9fd\xea\xb5"\\5&\x01\xa4\x7f=\xa0\x1b\x8bO\x01h\xe8\xfd\x1f\xfe\xba\xbeg\\\xc2\xcb\xc3\xd1~\xff\xd5/9d\xa8\xa7x{\x16\xdb\\\xbb\x08\rI\xcd\x9e7\x8c~\x0f\x1d\x81rXZD\xf0\xf7\x87K\x8f\xfb,\xf4\xf0\xa5\x9e\xde^\xca\xae\x80|9b\x9b\xaaE"\xba\xfb\xdf\x80\xb1\x99\x83e[\xf8\xce&Rq\x99\xdb}\xeeO\xd5\x18\x8d\x0bv\xe7\xab\xf9\xb9{\xb5u\xce\xcf\x90\xa6HE\xc5\x92p\x00\x158\xdf\x1d' EMAIL_VERIFICATION_SECRET_KEY=b'<\xa3\xaf&(*|\x0e\xbces\x07P\xf7\xd6\xa9sf\x19$\x96\xb7\x90\x8b\x88\x84\x0e\x191\xde,M\x90\x17(\xf7\nG\x13"\x8d$\x9f&\xb0\xcd\xa4\xaf\xa9\x1b\x15\x02B\x8a\xaf\xff\x0c\x1e\xd5\xb3\x06\xb8\xa6\x9bQ\xa0TR\xe8\x98\x9ae\xe0n}\xcc/[\xdaFz\x18\xfeX\xaf\xbd\xd0\x88\xeal\xe3\xd2\xe3\xb8\x8c\x199{\xf3<\xb0\xc5\xd0\xe7*Rv\xda\xbb \x1d\x85~\xff%>\x1e\xb8\xa7\xbf\xbc\xb2\x06\x86X\xc3\x9f\x13<\x9fd\xea\xb5"\\5&\x01\xa4\x7f=\xa0\x1b\x8bO\x01h\xe8\xfd\x1f\xfe\xba\xbeg\\\xc2\xcb\xc3\xd1~\xff\xd5/9d\xa8\xa7x{\x16\xdb\\\xbb\x08\rI\xcd\x9e7\x8c~\x0f\x1d\x81rXZD\xf0\xf7\x87K\x8f\xfb,\xf4\xf0\xa5\x9e\xde^\xca\xae\x80|9b\x9b\xaaE"\xba\xfb\xdf\x80\xb1\x99\x83e[\xf8\xce&Rq\x99\xdb}\xeeO\xd5\x18\x8d\x0bv\xe7\xab\xf9\xb9{\xb5u\xce\xcf\x90\xa6HE\xc5\x92p\x00\x158\xdf\x1d'
@ -9,4 +8,5 @@ DB_USER=postgres
DB_PASSWORD=postgres DB_PASSWORD=postgres
DB_HOST=localhost DB_HOST=localhost
DB_PORT=5432 DB_PORT=5432
RECAPTCHA_SECRET_KEY=6Lcv-mEfAAAAAOxM3pzPc-9W96yPlkWnn6v41fLl RECAPTCHA_SECRET_KEY=6Lc1_zshAAAAAFUMrGjosEFNyFltOml1slEDqOYN
GOOGLE_OAUTH_CLIENT_ID=546234123038-4v6m6s6u1dmqbiertv9m9b5ee3e540g7.apps.googleusercontent.com

View File

@ -34,21 +34,27 @@ http {
server { server {
listen 80; listen 80;
server_name localhost; server_name cdc.iitdh.ac.in;
# listen 443 ssl; listen 443 ssl;
# server_name localhost; # server_name localhost;
# ssl_certificate cert.pem; ssl_certificate /home/cdc/Desktop/1f9476e3959ebe60.pem;
# ssl_certificate_key cert.key; ssl_certificate_key /home/cdc/Desktop/star_iitdh_key.key;
#charset koi8-r; #charset koi8-r;
#access_log logs/host.access.log main; #access_log logs/host.access.log main;
location / { location / {
root /usr/share/nginx/html; root /usr/share/nginx/html;
index index.html index.htm; try_files $uri $uri/ /portal;
}
location /portal {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /portal/index.html;
} }
# Server static files /storage # Server static files /storage
@ -65,14 +71,14 @@ http {
} }
location /api/ { location /api/ {
proxy_pass http://localhost:8000; proxy_pass https://localhost:8000;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade"; proxy_set_header Connection "Upgrade";
proxy_set_header Host $host; proxy_set_header Host $host;
} }
location /admin/ { location /admin/ {
proxy_pass http://localhost:8000; proxy_pass https://localhost:8000;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade"; proxy_set_header Connection "Upgrade";