diff --git a/CDC_Backend/APIs/admin.py b/CDC_Backend/APIs/admin.py index ab52c34..581d493 100644 --- a/CDC_Backend/APIs/admin.py +++ b/CDC_Backend/APIs/admin.py @@ -8,7 +8,6 @@ from django.utils.safestring import SafeText from .models import * admin.site.register(User, SimpleHistoryAdmin) -admin.site.register(Admin, SimpleHistoryAdmin) admin.site.site_header = "CDC Recruitment Portal" diff --git a/CDC_Backend/APIs/constants.py b/CDC_Backend/APIs/constants.py index aeb26b1..4b31276 100644 --- a/CDC_Backend/APIs/constants.py +++ b/CDC_Backend/APIs/constants.py @@ -1,3 +1,5 @@ +import os + BRANCH_CHOICES = [ ["CSE", "CSE"], ["EE", "EE"], @@ -36,14 +38,15 @@ TOTAL_BRANCHES = 4 # Total No of Branches TOTAL_BATCHES = 4 # Total No of Batches # 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 -PLACEMENT_OPENING_URL = "http://localhost:3000/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_RESUME = "http://localhost/storage/Resumes/" -LINK_TO_APPLICATIONS_CSV = "http://localhost/storage/Application_CSV/" -LINK_TO_EMAIl_VERIFICATION_API = "http://localhost:3000/company/verifyEmail?token={token}" +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 = "https://cdc.iitdh.ac.in/storage/Company_Attachments/" +LINK_TO_STORAGE_RESUME = "https://cdc.iitdh.ac.in/storage/Resumes/" +LINK_TO_APPLICATIONS_CSV = "https://cdc.iitdh.ac.in/storage/Application_CSV/" +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" @@ -54,6 +57,7 @@ TIER = 'tier' # To be Configured Properly FOURTH_YEAR = '2019' MAX_OFFERS_PER_STUDENT = 2 +MAX_RESUMES_PER_STUDENT = 3 EMAIL_VERIFICATION_TOKEN_TTL = 48 # in hours JNF_TEXT_MAX_CHARACTER_COUNT = 100 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', 'Resume', 'Selected', ] -PDF_FILES_SERVING_ENDPOINT = 'http://localhost/storage/Company_Attachments/' # TODO: Change this to actual URL diff --git a/CDC_Backend/APIs/models.py b/CDC_Backend/APIs/models.py index 8580029..1a92d10 100644 --- a/CDC_Backend/APIs/models.py +++ b/CDC_Backend/APIs/models.py @@ -6,9 +6,6 @@ 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) @@ -50,25 +47,6 @@ 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) diff --git a/CDC_Backend/APIs/studentViews.py b/CDC_Backend/APIs/studentViews.py index ccb25bf..0fbadd0 100644 --- a/CDC_Backend/APIs/studentViews.py +++ b/CDC_Backend/APIs/studentViews.py @@ -40,6 +40,9 @@ def addResume(request, id, email, user_type): student = get_object_or_404(Student, id=id) files = request.FILES + if len(student.resumes) >= MAX_RESUMES_PER_STUDENT: + raise PermissionError('Max Number of Resumes limit reached') + file = files['file'] destination_path = STORAGE_DESTINATION_RESUMES + str(student.roll_no) + "/" file_name = saveFile(file, destination_path) @@ -51,6 +54,9 @@ def addResume(request, id, email, user_type): except Http404: return Response({'action': "Upload Resume", 'message': 'Student 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: if path.exists(destination_path): logger.error("Upload Resume: Error in Saving Resume") diff --git a/CDC_Backend/APIs/utils.py b/CDC_Backend/APIs/utils.py index 7fcf318..d4f6204 100644 --- a/CDC_Backend/APIs/utils.py +++ b/CDC_Backend/APIs/utils.py @@ -269,7 +269,7 @@ def opening_description_table_html(opening): if key == 'website': details[key] = {"details": details[key], "type": ["link"]} 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 + "/"} new_key = key.replace('_', ' ') if new_key.endswith(' names'): diff --git a/CDC_Backend/CDC_Backend/settings.py b/CDC_Backend/CDC_Backend/settings.py index 22552bf..373c6fb 100644 --- a/CDC_Backend/CDC_Backend/settings.py +++ b/CDC_Backend/CDC_Backend/settings.py @@ -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/ # 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! -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 @@ -153,6 +153,8 @@ CORS_ORIGIN_WHITELIST = [ "http://127.0.0.1:8000" ] +CSRF_TRUSTED_ORIGINS = [] + # EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend' EMAIL_FILE_PATH = './emails' diff --git a/CDC_Backend/templates/company_jnf_response.html b/CDC_Backend/templates/company_jnf_response.html index 6e7191c..3e3419f 100644 --- a/CDC_Backend/templates/company_jnf_response.html +++ b/CDC_Backend/templates/company_jnf_response.html @@ -44,7 +44,7 @@ {% for item in value.details %}