Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b0b516c
all except resume work
yoogottamk May 18, 2020
0c472cd
cleared warnings
yoogottamk May 18, 2020
bef69a7
everything except resume upload works
yoogottamk May 18, 2020
fbf3c0e
Editing student profile done. Prev resume doesnot get deleted though
abhigyanghosh30 May 18, 2020
d3415c8
Changed some colours here and there
abhigyanghosh30 May 18, 2020
b3f24ff
Some more colour changes
abhigyanghosh30 May 18, 2020
f0c3d92
added colours to student home based on status
abhigyanghosh30 May 18, 2020
e9783cf
minor UI changed and formSubmission changes
abhigyanghosh30 May 19, 2020
aa8381f
profiles didn't have navbars
abhigyanghosh30 May 19, 2020
be0eea8
Password edit fixed
abhigyanghosh30 May 19, 2020
7cc99af
send token using Auth header::frontend
yoogottamk May 20, 2020
649acf2
send token using Auth header::backend
yoogottamk May 20, 2020
0ffd36b
added a 404 page
abhigyanghosh30 May 20, 2020
e914fd1
minor older edits
yoogottamk Jun 2, 2020
5476904
Merge branch 'edit-profile' of github.com:IIIT-ECell/campus_works int…
yoogottamk Jun 2, 2020
279044f
better profile editing [students]
yoogottamk Jun 3, 2020
bce394c
better profile editing [company]
yoogottamk Jun 3, 2020
7f83caf
not sending password hash to frontend
yoogottamk Jun 3, 2020
8394cdd
fixed jobs fetch issue
AakashJ2412 May 23, 2021
368b403
Fixed misc. bugs
AakashJ2412 Jun 1, 2021
1f84155
Added email regex
deutranium Jun 4, 2021
35f5665
Fixed resume and edit page errors
AakashJ2412 Jun 4, 2021
451d1d4
Updated profile encryption
AakashJ2412 Jun 4, 2021
888ab0a
Encrypted student and company profiles
AakashJ2412 Jun 4, 2021
cbf5eb3
fixed company API
AakashJ2412 Jun 4, 2021
aa8d397
updated resume bug
AakashJ2412 Jun 4, 2021
2895736
Fixed company profile bug
AakashJ2412 Jun 7, 2021
b113034
Updated Registration Access
AakashJ2412 Jun 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions backend/decorators.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
from rest_framework.authtoken.models import Token
from backend.models import *


def student_required(key):
token = Token.objects.get(key=key)
user = CustomUser.objects.get(id=token.user_id)
if(user.user_type==1):
if user.user_type == 1:
return True
return False


def company_required(key):
token = Token.objects.get(key=key)
user = CustomUser.objects.get(id=token.user_id)
if(user.user_type == 2):
if user.user_type == 2:
return True
return False


def get_student_id(key):
token = Token.objects.get(key=key)
student = Student.objects.get(user_id=token.user_id)
print(student.id)
return student.id


def get_company_id(key):
token = Token.objects.get(key=key)
company = Company.objects.get(user_id=token.user_id)
print(company.id)
return company.id
36 changes: 22 additions & 14 deletions backend/serializers.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,50 @@
import copy

from rest_framework import serializers
from .models import Student, CustomUser, Application, Job, Company


class StudentSerializer(serializers.ModelSerializer):
class Meta:
model = Student
fields = '__all__'
fields = "__all__"


class UserSerializer(serializers.ModelSerializer):
class Meta:
model = CustomUser
fields = ['email','first_name','password']
fields = ["email", "first_name", "password"]


class ApplicationStudentSerializer(serializers.ModelSerializer):
class Meta:
model = Application
fields = ['student_id','job_id','date_of_application','select_status']

fields = ["student_id", "job_id", "date_of_application", "select_status"]


class CompanySerializer(serializers.ModelSerializer):
class Meta:
model = Company
fields = '__all__'

fields = "__all__"


class JobSerializer(serializers.ModelSerializer):
class Meta:
model = Job
fields = '__all__'
depth = 2
fields = "__all__"
depth = 2


class JobCompanySerializer(serializers.Serializer):
company = CompanySerializer()
job = JobSerializer()


def user_filter(user_dict):
user = copy.deepcopy(user_dict)

# add fields to hide here
for hidden_field in ["password"]:
del user["fields"][hidden_field]







return user
23 changes: 14 additions & 9 deletions backend/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,57 @@ def update_student_resume(instance, created, **kwargs):
if created: # checks if it is a new object

initial_path = instance.resume.path
new_path = f'uploads/student/resume/{instance.user.pk}{os.path.splitext(initial_path)[1]}'

new_path = f"uploads/student/resume/{instance.user.pk}{os.path.splitext(initial_path)[1]}"

os.makedirs(os.path.dirname(new_path), exist_ok=True)
os.rename(initial_path, new_path)
instance.resume = new_path
instance.save()


@receiver(post_save, sender=Company)
def update_company_logo(instance, created, **kwargs):

if created: # checks if it is a new object

initial_path = instance.logo.path

new_path = f'uploads/company/logo/{instance.user.pk}{os.path.splitext(initial_path)[1]}'
new_path = f"uploads/company/logo/{instance.user.pk}{os.path.splitext(initial_path)[1]}"

os.makedirs(os.path.dirname(new_path), exist_ok=True)
os.rename(initial_path, new_path)
instance.resume = new_path
instance.save()


@receiver(post_save, sender=Application)
def update_application_resume(instance, created, **kwargs):
if created: # checks if it is a new object

initial_path = instance.resume.path
new_path = f'uploads/application/resume/{instance.pk}{os.path.splitext(initial_path)[1]}'

new_path = f"uploads/application/resume/{instance.pk}{os.path.splitext(initial_path)[1]}"

os.makedirs(os.path.dirname(new_path), exist_ok=True)
os.rename(initial_path, new_path)
instance.resume = new_path
instance.save()



@receiver(post_save, sender=CustomUser)
def create_user_profile(sender, instance, created, **kwargs):
if created:
if instance.user_type==1:
if instance.user_type == 1:
Student.objects.create(user=instance)
else:
Company.objects.create(user=instance)


@receiver(post_save, sender=CustomUser)
def save_user_profile(sender, instance, **kwargs):
if instance.user_type==1:
if instance.user_type == 1:
instance.student.save()
else:
instance.company.save()
instance.company.save()

24 changes: 12 additions & 12 deletions backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
"""
from django.contrib import admin
from django.urls import path
from backend import views
from backend import views
from rest_framework.authtoken.views import obtain_auth_token

appname = "backend"

urlpatterns = [
path('user',views.UserViews.as_view()),
path('student', views.StudentViews.as_view()),
path('company', views.CompanyViews.as_view()),
path('authenticate', views.CustomObtainAuthToken.as_view(), name='api_token_auth'),
path('post-job',views.PostJob.as_view()),
path('applications',views.StudentApplications.as_view()),
path('apply-for-job',views.ApplicationViews.as_view()),
path('jobs',views.ViewJobs.as_view()),
path('resume',views.Resume.as_view()),
path('profile/student',views.StudentProfile.as_view()),
path('profile/company',views.CompanyProfile.as_view())
path("user", views.UserViews.as_view()),
path("student", views.StudentViews.as_view()),
path("company", views.CompanyViews.as_view()),
path("authenticate", views.CustomObtainAuthToken.as_view(), name="api_token_auth"),
path("post-job", views.PostJob.as_view()),
path("applications", views.StudentApplications.as_view()),
path("apply-for-job", views.ApplicationViews.as_view()),
path("jobs", views.ViewJobs.as_view()),
path("resume", views.Resume.as_view()),
path("profile/student", views.StudentProfile.as_view()),
path("profile/company", views.CompanyProfile.as_view()),
]
Loading