Skip to content
Merged
6 changes: 4 additions & 2 deletions FusionIIIT/applications/eis/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,12 @@

# Main profile landing view
def profile(request, username=None):
print("eis",username)
user = get_object_or_404(User, username=username) if username else request.user

extra_info = get_object_or_404(ExtraInfo, user=user)
if extra_info.user_type != 'faculty':
return redirect('/')
# if extra_info.user_type != 'fx':
# return redirect('/')
pf = extra_info.id

form = ConfrenceForm()
Expand Down
1 change: 1 addition & 0 deletions FusionIIIT/applications/feeds/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ def profile(request, string):
string- user's username
@variables
"""
print("user is this", request)
if request.method == "POST":
profile = Profile.objects.select_related().all().filter(user=request.user)
Pr = None
Expand Down
1 change: 1 addition & 0 deletions FusionIIIT/applications/globals/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
url(r'^auth/login/', views.login, name='login-api'),
url(r'^auth/logout/', views.logout, name='logout-api'),
# generic profile endpoint
#code of corresponding view is modifiedtemporary because of mismatched designations
url(r'^profile/(?P<username>.+)/', views.profile, name='profile-api'),
# current user profile
url(r'^profile/', views.profile, name='profile-api'),
Expand Down
6 changes: 5 additions & 1 deletion FusionIIIT/applications/globals/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,15 @@ def profile(request, username=None):
user = get_object_or_404(User, username=username) if username else request.user
user_detail = serializers.UserSerializer(user).data
profile = serializers.ExtraInfoSerializer(user.extrainfo).data

print(user)

if profile['user_type'] == 'student':
student = user.extrainfo.student
skills = serializers.HasSerializer(student.has_set.all(),many=True).data
education = serializers.EducationSerializer(student.education_set.all(), many=True).data
course = serializers.CourseSerializer(student.course_set.all(), many=True).data
experience = serializers.ExperienceSerializer(student.experience_set.all(), many=True).data
experience = serializers.ExperienceSerializer(student.experience_set.all(), many=True).datap
project = serializers.ProjectSerializer(student.project_set.all(), many=True).data
achievement = serializers.AchievementSerializer(student.achievement_set.all(), many=True).data
publication = serializers.PublicationSerializer(student.publication_set.all(), many=True).data
Expand All @@ -102,6 +105,7 @@ def profile(request, username=None):
}
return Response(data=resp, status=status.HTTP_200_OK)
elif profile['user_type'] == 'faculty':
print(username)
return redirect('/eis/api/profile/' + (username+'/' if username else ''))

@api_view(['PUT'])
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.5 on 2023-11-16 23:23

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('globals', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='extrainfo',
name='user_status',
field=models.CharField(choices=[('NEW', 'NEW'), ('PRESENT', 'PRESENT')], default='PRESENT', max_length=50),
),
]
3 changes: 3 additions & 0 deletions FusionIIIT/applications/globals/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from audioop import reverse
import json

from django.contrib.auth import logout
Expand Down Expand Up @@ -771,6 +772,8 @@ def profile(request, username=None):
username: Username of the user. If None,
displays the profile of currently logged-in user
"""

print(username)
user = get_object_or_404(User, Q(username=username)) if username else request.user

editable = request.user == user
Expand Down
14 changes: 14 additions & 0 deletions FusionIIIT/applications/scholarships/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import subprocess
from datetime import datetime

from django.conf import settings


def getBatch(roll):
batch = "20"
if(str(roll)[2].isdigit()):
return str(roll)[0:4]

else:
batch+=str(roll)[0:2]
return batch
1 change: 1 addition & 0 deletions FusionIIIT/applications/scholarships/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
url(r'^getConvocationFlag/$', views.getConvocationFlag, name='getConvocationFlag'),
url(r'^getContent/$', views.getContent, name='getContent'),
url(r'^updateEndDate/$', views.updateEndDate, name='updateEndDate'),
url(r'^deleteRelease/$', views.deleteRelease, name='deleteRelease'),

]
133 changes: 104 additions & 29 deletions FusionIIIT/applications/scholarships/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from operator import or_
from functools import reduce

from django.http import JsonResponse
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseRedirect
Expand All @@ -23,9 +24,13 @@
from .validations import MCM_list, MCM_schema, gold_list, gold_schema, silver_list, silver_schema, proficiency_list,proficiency_schema
from jsonschema import validate
from jsonschema.exceptions import ValidationError
from .helpers import getBatch
# Create your views here.





@login_required(login_url='/accounts/login')
def spacs(request):
convener = Designation.objects.get(name='spacsconvenor')
Expand Down Expand Up @@ -70,15 +75,20 @@ def spacs(request):

@login_required(login_url='/accounts/login')
def convener_view(request):
print(request)

try:
convener = Designation.objects.get(name='spacsconvenor')
hd = HoldsDesignation.objects.get(
user=request.user, designation=convener)
except:
return HttpResponseRedirect('/logout')
if request.method == 'POST':
print("this is a check for post request")
if 'Submit' in request.POST:
print("this is a check for post xfhjgisdfkhlsjk request")
award = request.POST.get('type')
print("award " + award)
programme = request.POST.get('programme')
batch = request.POST.get('batch')
from_date = request.POST.get('From')
Expand All @@ -98,14 +108,27 @@ def convener_view(request):
)

# It updates the student Notification table on the spacs head sending the mcm invitation
if batch == 'all':
if batch == 'All':
active_batches = range(datetime.datetime.now().year - 4 , datetime.datetime.now().year + 1)
query = reduce(or_, (Q(id__id__startswith=batch) for batch in active_batches))
# active_batches=str(active_batches)
# active_batches.split(',')
print(active_batches)
querybatch = []
for curbatch in active_batches:
if curbatch > 2019:
curbatch=curbatch%2000
querybatch.append(curbatch)
print( active_batches)
query = reduce(or_, (Q(id__id__startswith=batch) for batch in querybatch))
print(query)
recipient = Student.objects.filter(programme=programme).filter(query)
else:
recipient = Student.objects.filter(programme=programme, id__id__startswith=batch)
if(int(batch)>2019):
curbatch=int(batch)%2000
recipient = Student.objects.filter(programme=programme, id__id__startswith=curbatch)

# Notification starts
print(recipient)
convenor = request.user
for student in recipient:
scholarship_portal_notif(convenor, student.id.user, 'award_' + award) # Notification
Expand All @@ -124,9 +147,9 @@ def convener_view(request):
notification_convocation_flag=True,
invite_convocation_accept_flag=False) for student in recipient])
# Notification ends

print(batch)
messages.success(request,
award + ' applications are invited successfully for ' + batch + ' batch(es)')
award + ' applications are invited successfully for ' + str(batch) + ' batch(es)')
return HttpResponseRedirect('/spacs/convener_view')

elif 'Email' in request.POST:
Expand Down Expand Up @@ -257,6 +280,7 @@ def convener_view(request):

@login_required(login_url='/accounts/login')
def student_view(request):

if request.method == 'POST':
if 'Submit_MCM' in request.POST:
return submitMCM(request)
Expand Down Expand Up @@ -382,37 +406,52 @@ def convenerCatalogue(request):
context['result'] = 'Failure'
return HttpResponse(json.dumps(context), content_type='convenerCatalogue/json')



#below function is refactored and changed as it is not used by the user interface
#it will be changed later for other testing and download of winners
def getWinners(request):
# Extract parameters from the request
award_name = request.GET.get('award_name')
batch_year = int(request.GET.get('batch'))
programme_name = request.GET.get('programme')
award = Award_and_scholarship.objects.get(award_name=award_name)
winners = Previous_winner.objects.select_related('student','award_id').filter(

# Get the Award_and_scholarship object based on the provided award name
try:
award = Award_and_scholarship.objects.get(award_name=award_name)
except Award_and_scholarship.DoesNotExist:
return JsonResponse({'result': 'Failure', 'message': 'Award not found'})

# Query for previous winners based on the provided criteria
winners = Previous_winner.objects.select_related('student__extra_info').filter(
year=batch_year, award_id=award, programme=programme_name)
context = {}
context['student_name'] = []
context['student_program'] = []
context['roll'] = []

# If-Else Condition for previous winner if there is or no data in the winner table
context = {
'result': 'Success',
'winners': [],
}

# Process the winners if any found
if winners:
for winner in winners:

extra_info = ExtraInfo.objects.get(id=winner.student_id)
student_id = Student.objects.get(id=extra_info)
# Fetch extra information for the student
extra_info = winner.student.extra_info
student_name = extra_info.user.first_name
student_roll = winner.student_id
student_program = student_id.programme
context['student_name'].append(student_name)
context['roll'].append(student_roll)
context['student_program'].append(student_program)

context['result'] = 'Success'
student_program = winner.student.programme

# Append student details to the context
context['winners'].append({
'student_name': student_name,
'roll': student_roll,
'student_program': student_program,
})

else:
context['result'] = 'Failure'
context['message'] = 'No winners found for the provided criteria'

return HttpResponse(json.dumps(context), content_type='getWinners/json')
return JsonResponse(context)

def get_MCM_Flag(request): # Here we are extracting mcm_flag
x = Notification.objects.select_related('student_id','release_id').filter(student_id=request.user.extrainfo.id)
Expand All @@ -431,7 +470,7 @@ def get_MCM_Flag(request): # Here we are extracting mcm_flag
# return HttpResponseRedirect('/spacs/student_view')

def getConvocationFlag(request): # Here we are extracting convocation_flag
x = Notification.objects.filter(student_id=request.user.extrainfo.id)
x = Notification.objects.select_related('student_id', 'release_id').filter(student_id=request.user.extrainfo.id)
for i in x:
i.invite_convocation_accept_flag = True
i.save()
Expand Down Expand Up @@ -481,6 +520,18 @@ def updateEndDate(request):
context['result'] = 'Failure'
return HttpResponse(json.dumps(context), content_type='updateEndDate/json')

def deleteRelease(request):
print("deleteRelease")
id = request.GET.get('id')
is_deleted = Release.objects.filter(pk=id).delete()
request.session['last_clicked'] = "Release_deleted"
context = {}
if is_deleted:
context['result'] = 'Success'
else:
context['result'] = 'Failure'
return HttpResponse(json.dumps(context), content_type='deleteRelease/json')

def getAwardId(request):
award = request.POST.get('award')
a = Award_and_scholarship.objects.get(award_name=award).id
Expand Down Expand Up @@ -1012,14 +1063,14 @@ def sendConvenerRenderRequest(request, additionalParams={}):
source = Constants.FATHER_OCC_CHOICE
time = Constants.TIME
release = Release.objects.all()
notification = Notification.objects.select_related('student_id','release_id').all()
spi = Spi.objects.all()
context.update({ 'source': source, 'time': time, 'ch': ch, 'spi': spi, 'release': release})
context.update(additionalParams)
return render(request, 'scholarshipsModule/scholarships_convener.html', context)

def sendStudentRenderRequest(request, additionalParams={}):
context = getCommonParams(request)

ch = Constants.BATCH
time = Constants.TIME
mother_occ = Constants.MOTHER_OCC_CHOICES
Expand All @@ -1039,24 +1090,48 @@ def sendStudentRenderRequest(request, additionalParams={}):
update_con_flag = False
x_notif_mcm_flag = False
x_notif_con_flag = False
student_batch = getBatch(request.user.extrainfo.student)
for dates in release:
if checkDate(dates.startdate, dates.enddate):
if dates.award == 'Merit-cum-Means Scholarship' and dates.batch == str(request.user.extrainfo.student)[0:4] and dates.programme == request.user.extrainfo.student.programme:
curBatch = dates.batch
checkBatch = str(request.user.extrainfo.student)[0:4]
batchCondition = False
if checkBatch[2] >= "A" and checkBatch[2] <= "Z":
if(curBatch == 'All'):
batchRange = range(datetime.datetime.now().year - 4, datetime.datetime.now().year + 1)
for batches in batchRange :
if int(checkBatch[0:2]) == batches % 2000:
batchCondition = True
elif curBatch == checkBatch:
batchCondition = True
else:
if(curBatch == 'All'):
batchRange = range(datetime.datetime.now().year - 4, datetime.datetime.now().year + 1)
for batch in batchRange:
if str(checkBatch) == batch:
batchCondition = True
elif curBatch == checkBatch:
True
print("bye")


print(curBatch, checkBatch)
if dates.award == 'Merit-cum-Means Scholarship' and batchCondition and dates.programme == request.user.extrainfo.student.programme:
x_notif_mcm_flag = True
if no_of_mcm_filled > 0:
update_mcm_flag = True
elif dates.award == 'Convocation Medals' and dates.batch == str(request.user.extrainfo.student)[0:4] and dates.programme == request.user.extrainfo.student.programme:
elif dates.award == 'Convocation Medals' and dates.batch == student_batch and dates.programme == request.user.extrainfo.student.programme:
x_notif_con_flag = True
if no_of_con_filled > 0:
update_con_flag = True
else:
if dates.award == "Merit-cum-Means Scholarship" and dates.batch == str(request.user.extrainfo.student)[0:4]:
if dates.award == "Merit-cum-Means Scholarship" and dates.batch == student_batch:
try:
x = Notification.objects.select_related('student_id','release_id').get(
student_id=request.user.extrainfo.id, release_id=dates.id).delete()
except:
pass
elif dates.award == 'Convocation Medals' and dates.batch == str(request.user.extrainfo.student)[0:4]:
elif dates.award == 'Convocation Medals' and dates.batch == student_batch:
try:
x = Notification.objects.select_related('student_id','release_id').get(
student_id=request.user.extrainfo.id, release_id=dates.id).delete()
Expand All @@ -1081,7 +1156,7 @@ def sendStudentRenderRequest(request, additionalParams={}):
context.update(additionalParams)
return render(request, 'scholarshipsModule/scholarships_student.html',context)

def sendStaffRenderRequest(request, additionalParams={}):
def sendStaffRenderRequest(request, additionalParams={}):
context = getCommonParams(request)
context.update(additionalParams)
return render(request, 'scholarshipsModule/scholarships_staff.html', context)
Expand Down
2 changes: 2 additions & 0 deletions FusionIIIT/notification/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ def scholarship_portal_notif(sender, recipient, type):

if type.startswith('award'):
s = type.split('_')
# print("psss")
# print(type, s)
verb = "Invitation to apply for " + s[1]
elif type == 'Accept_MCM':
verb = "Your Mcm form has been accepted "
Expand Down
Loading