diff --git a/FusionIIIT/applications/ps1/models.py b/FusionIIIT/applications/ps1/models.py index ffbe50020..b34683836 100644 --- a/FusionIIIT/applications/ps1/models.py +++ b/FusionIIIT/applications/ps1/models.py @@ -16,6 +16,7 @@ class IndentFile(models.Model): purpose=models.CharField(max_length=250,blank=False ) specification=models.CharField(max_length=250) item_type=models.CharField(max_length=250) + item_subtype = models.CharField(max_length=250,blank=False,default='computers') nature=models.BooleanField(default = False) indigenous= models.BooleanField(default = False) replaced =models.BooleanField(default = False) diff --git a/FusionIIIT/applications/ps1/urls.py b/FusionIIIT/applications/ps1/urls.py index 148e0c753..dc0b33bae 100644 --- a/FusionIIIT/applications/ps1/urls.py +++ b/FusionIIIT/applications/ps1/urls.py @@ -68,7 +68,8 @@ url(r'^outboxview/$', views.outboxview, name='outboxview'), - url(r'^update_stock_item_inUse/$', views.updateStockItemInUse, name='outboxview'), + url(r'^update_stock_item_inUse/$', views.updateStockItemInUse, name='stockItemInUse'), + url(r'^item_detail/(?P\d+)/$', views.item_detail, name='item_detail'), # BASE API url(r'^api/',include('applications.ps1.api.urls')), diff --git a/FusionIIIT/applications/ps1/views.py b/FusionIIIT/applications/ps1/views.py index c07889c43..971df43b0 100644 --- a/FusionIIIT/applications/ps1/views.py +++ b/FusionIIIT/applications/ps1/views.py @@ -20,6 +20,8 @@ import json from django.db.models import Q,Count +from datetime import datetime +from datetime import datetime dept_admin_to_dept = { "deptadmin_cse": "CSE", @@ -29,9 +31,11 @@ "deptadmin_design": "Design", "deptadmin_liberalarts": "Liberal Arts", "deptadmin_ns": "Natural Science", + "Admin IWD":"IWD", + "Compounder":"Health Center" } -dept_admin_design = ["deptadmin_cse", "deptadmin_ece", "deptadmin_me","deptadmin_sm", "deptadmin_design", "deptadmin_liberalarts","deptadmin_ns" ] +dept_admin_design = ["deptadmin_cse", "deptadmin_ece", "deptadmin_me","deptadmin_sm", "deptadmin_design", "deptadmin_liberalarts","deptadmin_ns" ,"Admin IWD","Compounder"] @login_required(login_url = "/accounts/login/") @@ -118,6 +122,8 @@ def create_proposal(request): purpose=request.POST.get('purpose') specification=request.POST.get('specification') item_type=request.POST.get('item_type') + item_subtype=request.POST.get('item_subtype') + nature=request.POST.get('nature') indigenous=request.POST.get('indigenous') replaced =request.POST.get('replaced') @@ -150,6 +156,7 @@ def create_proposal(request): purpose=purpose, specification=specification, item_type=item_type, + item_subtype=item_subtype, nature=nature, indigenous=indigenous, replaced = replaced , @@ -191,6 +198,8 @@ def create_proposal(request): purpose=request.POST.get('purpose') specification=request.POST.get('specification') item_type=request.POST.get('item_type') + item_subtype=request.POST.get('item_subtype') + nature=request.POST.get('nature') indigenous=request.POST.get('indigenous') replaced =request.POST.get('replaced') @@ -249,6 +258,7 @@ def create_proposal(request): purpose=purpose, specification=specification, item_type=item_type, + item_subtype=item_subtype, nature=nature, indigenous=indigenous, replaced = replaced , @@ -751,6 +761,7 @@ def forwardindent(request, id): file_attachment=upload_file ) + # CREATOR -> HOD -> DIRECTOR/REGISTRAR -> DEPT_ADMIN -> if((sender_designation_name in ["HOD (CSE)", "HOD (ECE)", "HOD (ME)", "HOD (SM)", "HOD (Design)", "HOD (Liberal Arts)", "HOD (Natural Science)"]) and (str(receive_design) in ["Director","Registrar"])): indent.head_approval=True @@ -768,8 +779,9 @@ def forwardindent(request, id): indent.save() - + office_module_notif(request.user, receiver_id) messages.success(request, 'Indent File Forwarded successfully') + extrainfo = ExtraInfo.objects.select_related('user','department').all() holdsdesignations = HoldsDesignation.objects.select_related('user','working','designation').all() designations = HoldsDesignation.objects.select_related('user','working','designation').filter(user=request.user) @@ -1104,11 +1116,12 @@ def current_stock_view(request): StockEntryId__item_id__item_type=type ) - grouped_items = StockItems.values('StockEntryId__item_id__item_type', 'department').annotate(total_quantity=Count('id')) + grouped_items = StockItems.values('StockEntryId__item_id__item_type','StockEntryId__item_id__item_subtype', 'department').annotate(total_quantity=Count('id')) grouped_items_list = [ { 'item_type': item['StockEntryId__item_id__item_type'], + 'item_subtype': item['StockEntryId__item_id__item_subtype'], 'department': DepartmentInfo.objects.get(id=department), 'total_quantity': item['total_quantity'] } @@ -1118,6 +1131,7 @@ def current_stock_view(request): firstStock=StockItems.first() + print(grouped_items_list) return render(request,'ps1/current_stock_view.html',{'stocks':grouped_items_list,'first_stock':firstStock, @@ -1135,9 +1149,11 @@ def current_stock_view(request): print(dept_admin_to_dept[request.session['currentDesignationSelected']]); deptId = DepartmentInfo.objects.values('id', 'name').get(name=dept_admin_to_dept[request.session['currentDesignationSelected']]) + + departments=[deptId] - StockItems = StockItem.objects.filter(department=deptId) + StockItems = StockItem.objects.filter(department=deptId['id']) elif request.session['currentDesignationSelected'] == "ps_admin": departments=DepartmentInfo.objects.values('id','name').all() @@ -1147,11 +1163,12 @@ def current_stock_view(request): return redirect('/dashboard') - grouped_items = StockItems.values('StockEntryId__item_id__item_type','department').annotate(total_quantity=Count('id')) + grouped_items = StockItems.values('StockEntryId__item_id__item_type','StockEntryId__item_id__item_subtype','department').annotate(total_quantity=Count('id')) grouped_items_list = [ { 'item_type': item['StockEntryId__item_id__item_type'], + 'item_subtype': item['StockEntryId__item_id__item_subtype'], 'department': DepartmentInfo.objects.values('id','name').get(id=item['department']), 'departmentId': item['department'], 'total_quantity': item['total_quantity'] @@ -1170,14 +1187,19 @@ def stock_item_view(request): if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: return redirect('/dashboard') + if request.method=="GET": + return HttpResponseRedirect('../current_stock_view') + if request.method=="POST": departmentId = request.POST.get('departmentId') type = request.POST.get('item_type') + subtype = request.POST.get('item_subtype') # StockEntryId__item_id__file_info_grade StockItems = StockItem.objects.filter( department=departmentId, - StockEntryId__item_id__item_type=type + StockEntryId__item_id__item_type=type, + StockEntryId__item_id__item_subtype=subtype ) return render(request,'ps1/stock_item_view.html',{'stocks':StockItems}) @@ -1339,16 +1361,57 @@ def generate_report(request): if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: return redirect('/dashboard') + - des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() - department = request.user.extrainfo.department.name + if request.method =='GET': + if request.session['currentDesignationSelected'] in dept_admin_design: - if request.session['currentDesignationSelected'] in dept_admin_design: - sto=StockEntry.objects.filter(item_id__file_info__uploader__department__name=dept_admin_to_dept[request.session['currentDesignationSelected']]) - else: - sto=StockEntry.objects.all() + deptId = DepartmentInfo.objects.values('id', 'name').get(name=dept_admin_to_dept[request.session['currentDesignationSelected']]) + departments=[deptId] + + elif request.session['currentDesignationSelected'] == "ps_admin": + departments=DepartmentInfo.objects.values('id','name').all() + + return render(request,'ps1/generate_report_filter.html',{'departments':departments}) + + + if request.method=="POST": - return render(request,'ps1/generate_report.html',{'sto':sto}) + + departments = request.POST.getlist('departments') + start_date = request.POST.get('start_date'); + finish_date = request.POST.get('finish_date'); + + + + start_date = datetime.strptime(start_date, '%Y-%m-%d').date() + finish_date = datetime.strptime(finish_date, '%Y-%m-%d').date() + + if(departments[0]=='all'): + StockItems = StockItem.objects.filter(StockEntryId__recieved_date__range=(start_date, finish_date)) + else : + StockItems = StockItem.objects.filter(department__in=departments, StockEntryId__recieved_date__range=(start_date, finish_date)) + + + grouped_items = StockItems.values('StockEntryId__item_id__item_type','StockEntryId__item_id__item_subtype','department').annotate(total_quantity=Count('id')) + + grouped_items_list = [ + { + 'item_type': item['StockEntryId__item_id__item_type'], + 'item_subtype': item['StockEntryId__item_id__item_subtype'], + 'department': DepartmentInfo.objects.values('id','name').get(id=item['department']), + 'departmentId': item['department'], + 'total_quantity': item['total_quantity'], + 'StockItems': StockItem.objects.filter( + department=item['department'], + StockEntryId__item_id__item_type=item['StockEntryId__item_id__item_type'] + ) + } + for item in grouped_items + ] + + + return render(request,'ps1/generate_report.html',{'departments':departments,'stocks':grouped_items_list}) @login_required(login_url = "/accounts/login") @@ -1447,7 +1510,7 @@ def perform_transfer(request): dest_location=dest_location ) - messages.success(request,'Stock Transfer Done Successfully.!') + messages.success(request,'Stock Transfer Done Successfully.!') # if the quantity required for this indent file is fulfilled we should mark this indentfile as done. if(moreStocksRequired<=0): myIndent.purchased=True @@ -1458,7 +1521,7 @@ def perform_transfer(request): department = request.user.extrainfo.department.name - return HttpResponseRedirect('../view_transfer') + return JsonResponse({'success':True}) # This is to get the list of all the available stock items for transfer. @login_required(login_url = "/accounts/login") @@ -1537,8 +1600,14 @@ def outboxview(request): @login_required(login_url="/accounts/login") def updateStockItemInUse(request): + print("updatestockiteminuse"); + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: return redirect('/dashboard') + + if request.method=="GET": + return redirect('../current_stock_view') + if request.method == "POST": @@ -1557,4 +1626,23 @@ def updateStockItemInUse(request): stock_item.inUse = checked stock_item.save() - return redirect('/purchase-and-store/current_stock_view') \ No newline at end of file + return JsonResponse({'success': True}) + + # return HttpResponseRedirect('../current_stock_view') + + +@login_required(login_url="/accounts/login") +def item_detail(request, id): + if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: + return redirect('/dashboard') + + stock_transfers = StockTransfer.objects.filter(stockItem=id).order_by('dateTime') + stock_item = StockItem.objects.filter(id=id).first(); + # Do something with the stock_transfers + + context = { + 'transfers': stock_transfers, + 'item': stock_item + } + + return render(request, 'ps1/stock_item_details.html', context) diff --git a/FusionIIIT/applications/scholarships/urls.py b/FusionIIIT/applications/scholarships/urls.py index 769dec040..121cdd116 100755 --- a/FusionIIIT/applications/scholarships/urls.py +++ b/FusionIIIT/applications/scholarships/urls.py @@ -17,6 +17,5 @@ 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'), ] \ No newline at end of file diff --git a/FusionIIIT/applications/scholarships/views.py b/FusionIIIT/applications/scholarships/views.py index 9bffc3fb8..bbcbffb16 100755 --- a/FusionIIIT/applications/scholarships/views.py +++ b/FusionIIIT/applications/scholarships/views.py @@ -3,7 +3,6 @@ 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 @@ -24,13 +23,9 @@ 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') @@ -75,8 +70,6 @@ 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( @@ -84,11 +77,8 @@ def convener_view(request): 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') @@ -108,17 +98,14 @@ 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=int(batch)-2000) for batch in active_batches)) recipient = Student.objects.filter(programme=programme).filter(query) else: recipient = Student.objects.filter(programme=programme, id__id__startswith=int(batch)-2000) - # Notification starts - print(recipient) convenor = request.user for student in recipient: scholarship_portal_notif(convenor, student.id.user, 'award_' + award) # Notification @@ -139,9 +126,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 ' + str(batch) + ' batch(es)') + award + ' applications are invited successfully for ' + batch + ' batch(es)') return HttpResponseRedirect('/spacs/convener_view') elif 'Email' in request.POST: @@ -278,7 +265,6 @@ 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) @@ -404,52 +390,37 @@ 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') - - # 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( + award = Award_and_scholarship.objects.get(award_name=award_name) + winners = Previous_winner.objects.select_related('student','award_id').filter( year=batch_year, award_id=award, programme=programme_name) + context = {} + context['student_name'] = [] + context['student_program'] = [] + context['roll'] = [] - context = { - 'result': 'Success', - 'winners': [], - } - - # Process the winners if any found +# If-Else Condition for previous winner if there is or no data in the winner table if winners: for winner in winners: - # Fetch extra information for the student - extra_info = winner.student.extra_info + + extra_info = ExtraInfo.objects.get(id=winner.student_id) + student_id = Student.objects.get(id=extra_info) student_name = extra_info.user.first_name student_roll = winner.student_id - 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, - }) + 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' else: context['result'] = 'Failure' - context['message'] = 'No winners found for the provided criteria' - return JsonResponse(context) + return HttpResponse(json.dumps(context), content_type='getWinners/json') def get_MCM_Flag(request): # Here we are extracting mcm_flag print("get mcm_flags here") @@ -469,7 +440,6 @@ 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 - print("get convo_flags here") x = Notification.objects.filter(student_id=request.user.extrainfo.id) for i in x: @@ -521,18 +491,6 @@ 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 @@ -1064,6 +1022,7 @@ 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) @@ -1071,7 +1030,6 @@ def sendConvenerRenderRequest(request, additionalParams={}): def sendStudentRenderRequest(request, additionalParams={}): context = getCommonParams(request) - ch = Constants.BATCH time = Constants.TIME mother_occ = Constants.MOTHER_OCC_CHOICES @@ -1091,7 +1049,6 @@ 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): print("sudheer's test --->") @@ -1102,11 +1059,11 @@ def sendStudentRenderRequest(request, additionalParams={}): if no_of_mcm_filled > 0: update_mcm_flag = True elif dates.award == 'Convocation Medals' and dates.batch == "20"+str(request.user.extrainfo.student)[0:2]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 =="20"+ str(request.user.extrainfo.student)[0:2]: try: @@ -1141,7 +1098,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) diff --git a/FusionIIIT/templates/ps1/composeIndent.html b/FusionIIIT/templates/ps1/composeIndent.html index 8c406a8b6..d71d826e9 100644 --- a/FusionIIIT/templates/ps1/composeIndent.html +++ b/FusionIIIT/templates/ps1/composeIndent.html @@ -80,6 +80,11 @@

+
+ + +
+
diff --git a/FusionIIIT/templates/ps1/createdindent.html b/FusionIIIT/templates/ps1/createdindent.html index dd5c06a75..f88edfeb1 100644 --- a/FusionIIIT/templates/ps1/createdindent.html +++ b/FusionIIIT/templates/ps1/createdindent.html @@ -59,7 +59,7 @@