bug fixes

This commit is contained in:
Gowtham Sai 2022-08-11 15:44:39 +05:30
parent e284c2de68
commit 380043c240
11 changed files with 61 additions and 12 deletions

View File

@ -194,7 +194,7 @@ def addPlacement(request):
'%d-%m-%Y').date()
# Only Allowing Fourth Year for Placement
opening.allowed_batch = [FOURTH_YEAR, ]
opening.allowed_batch = [2017, 2018, 2019, 2020, 2021]
# Check if allowed_branch are valid
if data[ALLOWED_BRANCH] is None:
raise ValueError('Allowed Branch cannot be empty')

View File

@ -34,6 +34,11 @@ TIERS = [
['6', 'Tier 6']
]
DEGREE_CHOICES = [
['bTech', 'B.Tech'],
['ms/phd', 'MS/ PhD'],
]
TOTAL_BRANCHES = 4 # Total No of Branches
TOTAL_BATCHES = 4 # Total No of Batches

View File

@ -6,6 +6,9 @@ from simple_history.models import HistoricalRecords
from .constants import *
# from .utils import *
class User(models.Model):
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)
@ -30,6 +33,7 @@ class Student(models.Model):
cpi = models.DecimalField(decimal_places=2, max_digits=4)
can_apply = models.BooleanField(default=True, verbose_name='Registered')
changed_by = models.ForeignKey(User, blank=True, on_delete=models.RESTRICT, default=None, null=True)
degree = models.CharField(choices=DEGREE_CHOICES, blank=False, max_length=10, default=DEGREE_CHOICES[0][0])
history = HistoricalRecords(user_model=User)
def __str__(self):
@ -47,6 +51,25 @@ class Student(models.Model):
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():
return timezone.now() + timezone.timedelta(days=2)

View File

@ -162,7 +162,7 @@ class PlacementApplicationSerializer(serializers.ModelSerializer):
return data
def get_resume_link(self, obj):
ele = {'link': LINK_TO_STORAGE_RESUME + urllib.parse.quote(obj.id + "/" + obj.resume), 'name': obj.resume}
ele = {'link': LINK_TO_STORAGE_RESUME + urllib.parse.quote(str(obj.student.roll_no) + "/" + obj.resume), 'name': obj.resume}
return ele
class Meta:

View File

@ -180,6 +180,9 @@ def PlacementApplicationConditions(student, placement):
if int(i.placement.tier) < int(placement.tier):
return False, "Can't apply for this tier"
if student.degree != 'bTech' and not placement.rs_eligible:
raise PermissionError("Can't apply for this placement")
return True, "Conditions Satisfied"
except PermissionError as e:
@ -325,4 +328,3 @@ def send_opening_notifications(placement_id):
except:
logger.warning('Utils - send_opening_notifications: ' + str(sys.exc_info()))
return False

View File

@ -15,7 +15,6 @@ import os
from dotenv import load_dotenv
load_dotenv("../dev.env")
# import django_heroku
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -55,6 +54,7 @@ MIDDLEWARE = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'corsheaders.middleware.CorsPostCsrfMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
@ -145,15 +145,14 @@ STATICFILES_DIR = (
os.path.join(BASE_DIR, 'static'),
)
CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_ALLOW_ALL = False
CORS_ORIGIN_WHITELIST = [
"https://cdc.iitdh.ac.in",
"http://localhost:3000",
"http://127.0.0.1:3000",
"http://localhost:8000",
"http://127.0.0.1:8000"
"https://localhost:3000"
]
CSRF_TRUSTED_ORIGINS = []
CORS_REPLACE_HTTPS_REFERER = True
CSRF_TRUSTED_ORIGINS = [ "https://cdc.iitdh.ac.in", "http://cdc.iitdh.ac.in"]
# EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = './emails'

View File

@ -6,7 +6,6 @@ It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application

1
CDC_Backend/run_prod.sh Normal file
View File

@ -0,0 +1 @@
gunicorn --certfile=/home/cdc/Desktop/1f9476e3959ebe60.crt --keyfile=/home/cdc/Desktop/star_iitdh_key.key --bind localhost:8000 CDC_Backend.wsgi --access-logfile access.log --error-logfile error.log &

13
Email_service_README.md Normal file
View File

@ -0,0 +1,13 @@
we have defined a service for running the `start_email_service.sh` file continusouly on the server. Use the following commands for doing anything to the email
service.
## Enable the Service
`sudo systemctl enable cdc-email-sender.service`
## Start the Service
`sudo systemctl start cdc-email-sender.service`
## Check Status of the Service
`sudo systemctl status cdc-email-sender.service`
Any Doubts contact Gowtham Sai - 190010036

7
start_email_service.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
source /home/cdc/Desktop/CDC_Web_Portal_Backend/cdc-placement-website-backend/venv/bin/activate
cd /home/cdc/Desktop/CDC_Web_Portal_Backend/cdc-placement-website-backend/CDC_Backend
python manage.py process_tasks