diff --git a/FusionIIIT/applications/ps1/api/views.py b/FusionIIIT/applications/ps1/api/views.py index 37d6546e4..587c02e8a 100644 --- a/FusionIIIT/applications/ps1/api/views.py +++ b/FusionIIIT/applications/ps1/api/views.py @@ -53,7 +53,6 @@ def createProposal(request): designation = Designation.objects.get(id=HoldsDesignation.objects.select_related('user', 'working', 'designation').get(id=design).designation_id) upload_file = request.FILES.get('myfile') item_name = request.data.get('item_name') - grade = request.data.get('grade') quantity = request.data.get('quantity') present_stock = request.data.get('present_stock') estimated_cost = request.data.get('estimated_cost') @@ -89,7 +88,6 @@ def createProposal(request): estimated_cost=estimated_cost, purpose=purpose, specification=specification, - grade=grade, item_type=item_type, nature=nature, indigenous=indigenous, @@ -445,12 +443,11 @@ def currentStockView(request,id): else: return Response({"message": "Invalid designation"}, status=status.HTTP_403_FORBIDDEN) - grouped_items = stocks.values('StockEntryId__item_id__item_type', 'StockEntryId__item_id__grade', 'department').annotate(total_quantity=Count('id')) + grouped_items = stocks.values('StockEntryId__item_id__item_type', 'department').annotate(total_quantity=Count('id')) grouped_items_list = [ { 'item_type': item['StockEntryId__item_id__item_type'], - 'grade': item['StockEntryId__item_id__grade'], 'department': DepartmentInfo.objects.get(id=item['department']).name, 'total_quantity': item['total_quantity'] } @@ -462,25 +459,22 @@ def currentStockView(request,id): elif request.method == 'POST': # Handle POST request department = request.data.get('department') - grade = request.data.get('grade') item_type = request.data.get('item_type') - if not department or not grade or not item_type: + if not department or not item_type: return Response({"message": "Missing required parameters"}, status=status.HTTP_400_BAD_REQUEST) # Filter StockItem based on provided filters StockItems = StockItem.objects.filter( department=department, - StockEntryId__item_id__grade=grade, StockEntryId__item_id__item_type=item_type ) - grouped_items = StockItems.values('StockEntryId__item_id__item_type', 'StockEntryId__item_id__grade', 'department').annotate(total_quantity=Count('id')) + grouped_items = StockItems.values('StockEntryId__item_id__item_type', 'department').annotate(total_quantity=Count('id')) grouped_items_list = [ { 'item_type': item['StockEntryId__item_id__item_type'], - 'grade': item['StockEntryId__item_id__grade'], 'department': DepartmentInfo.objects.get(id=department).name, 'total_quantity': item['total_quantity'] } @@ -544,11 +538,9 @@ def stockTransfer(request,id): temp1=IndentFile.objects.get(file_info=temp) item_type_required =temp1.item_type - item_grade_required = temp1.grade available_items=StockItem.objects.filter( StockEntryId__item_id__item_type=item_type_required, - StockEntryId__item_id__grade=item_grade_required, inUse=False ) diff --git a/FusionIIIT/applications/ps1/models.py b/FusionIIIT/applications/ps1/models.py index d5aa60d93..ffbe50020 100644 --- a/FusionIIIT/applications/ps1/models.py +++ b/FusionIIIT/applications/ps1/models.py @@ -15,7 +15,6 @@ class IndentFile(models.Model): estimated_cost=models.IntegerField(null=True, blank=False) purpose=models.CharField(max_length=250,blank=False ) specification=models.CharField(max_length=250) - grade = models.CharField(max_length=1, choices=[('A', 'A'), ('B', 'B'), ('C', 'C')],default='A') item_type=models.CharField(max_length=250) nature=models.BooleanField(default = False) indigenous= models.BooleanField(default = False) @@ -34,14 +33,11 @@ class Meta: class Constants: Locations = ( - ('H1', 'Vashistha Hostel'), - ('H4', 'Vivekananda Hostel'), - ('H3', 'AryaBhatta Hostel'), - ('SR1', 'Storage Room 1'), - ('SR2', 'Storage Room 2'), - ('SR3', 'Storage Room 3'), - ('SR4', 'Storage Room 4'), - ('SR5', 'Storage Room 5'), + ('SR1', 'LHTC'), + ('SR2', 'Computer Center'), + ('SR3', 'Panini Hostel'), + ('SR4', 'Lab complex'), + ('SR5', 'Admin Block'), ) class StockEntry(models.Model): diff --git a/FusionIIIT/applications/ps1/urls.py b/FusionIIIT/applications/ps1/urls.py index 793d34ec5..148e0c753 100644 --- a/FusionIIIT/applications/ps1/urls.py +++ b/FusionIIIT/applications/ps1/urls.py @@ -12,21 +12,22 @@ url(r'^composed_indents/$', views.composed_indents, name='composed_indents'), # here id is the Holdsdesignation id. - url(r'^indentview/(?P\d+)$', views.indentview, name='indentview'), + url(r'^indentview/(?P\d+)/$', views.indentview, name='indentview'), + url(r'^archieveview/(?P\d+)/$', views.archieveview, name='archieveview'), url(r'^drafts/$', views.drafts, name='drafts'), - url(r'^draftview/(?P\d+)$', views.draftview, name='draftview'), + url(r'^draftview/(?P\d+)/$', views.draftview, name='draftview'), url(r'^inwardIndent/$', views.inward, name='inward'), # indentview2 is to get all the indentFiles inwarded towards the request.user. - url(r'^indentview2/(?P\d+)$', views.indentview2, name='indentview2'), - url(r'^confirmdelete/(?P\d+)$', views.confirmdelete, name='confirm_delete'), - url(r'^delete/(?P\d+)$',views.delete, name='delete'), + url(r'^indentview2/(?P\d+)/$', views.indentview2, name='indentview2'), + url(r'^confirmdelete/(?P\d+)/$', views.confirmdelete, name='confirm_delete'), + url(r'^delete/(?P\d+)/$',views.delete, name='delete'), # forward Indent is to see a specific forwarded indent to ourselves url(r'^forwardindent/(?P\d+)/$', views.forwardindent, name='forwardindent'), url(r'^createdindent/(?P\d+)/$', views.createdindent, name='createdindent'), - + url(r'^forwardedIndent/(?P\d+)/$', views.forwardedIndent, name='forwardedIndent'), url(r'^entry/$', views.entry, name='entry'), url(r'^StockEntry/$', views.Stock_Entry, name='Stock_Entry'), @@ -43,6 +44,7 @@ # to display stock items which are having similar item_type ,grade and department.(used in current_stock_view) url(r'^stock_item_view/$', views.stock_item_view, name='stock_item_view'), + url(r'^archieved_indents/$', views.archieved_files, name='archieved_indents_view'), @@ -62,7 +64,7 @@ url(r'^stock_transfer/$', views.stock_transfer, name='stock_transfer'), url(r'^view_transfer/$', views.view_transfer, name='view_transfer'), - url(r'^outboxview2/$', views.outboxview2, name='outboxview2'), + url(r'^outboxview2/(?P\d+)/$', views.outboxview2, name='outboxview2'), url(r'^outboxview/$', views.outboxview, name='outboxview'), diff --git a/FusionIIIT/applications/ps1/views.py b/FusionIIIT/applications/ps1/views.py index f3e603ec5..c07889c43 100644 --- a/FusionIIIT/applications/ps1/views.py +++ b/FusionIIIT/applications/ps1/views.py @@ -14,6 +14,8 @@ from django.utils import timezone from datetime import datetime from applications.globals.models import DepartmentInfo +from applications.filetracking.sdk.methods import * +from datetime import datetime import re import json @@ -34,6 +36,8 @@ @login_required(login_url = "/accounts/login/") def ps1(request): + notifs = request.user.notifications.all() + des_obj = HoldsDesignation.objects.filter(user=request.user) if des_obj: @@ -88,16 +92,24 @@ def create_proposal(request): financial_approval=False purchased =request.POST.get('purchased') """ + if request.session['currentDesignationSelected'] in dept_admin_design + ["ps_admin"]: + return redirect('/purchase-and-store/inwardIndent') print("request.user.id : ", request.user.id) - + notifs = request.user.notifications.all() if request.method =="POST": try: if 'save' in request.POST: uploader = request.user.extrainfo subject = request.POST.get('title') description = request.POST.get('desc') - design = request.POST.get('design') - designation = Designation.objects.get(id = HoldsDesignation.objects.select_related('user','working','designation').get(id = design).designation_id) + # design = request.POST.get('design') + design = HoldsDesignation.objects.filter(user=request.user, designation__name=request.session['currentDesignationSelected']).first() + + #print('design : ',design,'design2' , design2); + + + designation = Designation.objects.get(id = HoldsDesignation.objects.select_related('user','working','designation').get(id = design.id).designation_id) + upload_file = request.FILES.get('myfile') item_name=request.POST.get('item_name') quantity= request.POST.get('quantity') @@ -117,16 +129,20 @@ def create_proposal(request): financial_approval=False purchased =False - file=File.objects.create( + ##get the uploader username + uploader = request.user.username + print("uploader : ",uploader) + file_id=create_draft( uploader=uploader, - description=description, - subject=subject, - designation=designation, - upload_file=upload_file + uploader_designation=designation, + src_module="ps1", + src_object_id="", + file_extra_JSON={"value": 2}, + attached_file=upload_file ) IndentFile.objects.create( - file_info=file, + file_info=get_object_or_404(File, pk=file_id), item_name= item_name, quantity=quantity, present_stock=present_stock, @@ -149,13 +165,24 @@ def create_proposal(request): if 'send' in request.POST: - print('request.POST : ',request.POST); + # print('request.POST : ',request.POST); + uploader = request.user.extrainfo subject = request.POST.get('title') description = request.POST.get('desc') - design = request.POST.get('design') - designation = Designation.objects.get(id = HoldsDesignation.objects.select_related('user','working','designation').get(id = design).designation_id) + # design = request.POST.get('design') + + design = HoldsDesignation.objects.filter(user=request.user, designation__name=request.session['currentDesignationSelected']).first() + + designation = Designation.objects.get(id = HoldsDesignation.objects.select_related('user','working','designation').get(id = design.id).designation_id) + + # print(designation) + # print(design) + # print('design : ',design.id); + + + upload_file = request.FILES.get('myfile') item_name=request.POST.get('item_name') quantity= request.POST.get('quantity') @@ -164,7 +191,6 @@ def create_proposal(request): purpose=request.POST.get('purpose') specification=request.POST.get('specification') item_type=request.POST.get('item_type') - grade=request.POST.get('grade') nature=request.POST.get('nature') indigenous=request.POST.get('indigenous') replaced =request.POST.get('replaced') @@ -177,22 +203,16 @@ def create_proposal(request): purchased = False designations = HoldsDesignation.objects.select_related('user','working','designation').filter(user = request.user) - for des in designations: - if request.session['currentDesignationSelected'] == "Director": - head_approval=True - director_approval=True - financial_approval=True - break - + if request.session['currentDesignationSelected'] == "Director": + head_approval=True + director_approval=True + financial_approval=True # current_id = request.user.extrainfo # remarks = request.POST.get('remarks') - sender = request.POST.get('design') - current_design = HoldsDesignation.objects.select_related('user','working','designation').get(id=sender) - receiver = request.POST.get('receiver') try: @@ -230,7 +250,6 @@ def create_proposal(request): specification=specification, item_type=item_type, nature=nature, - grade=grade, indigenous=indigenous, replaced = replaced , budgetary_head=budgetary_head, @@ -255,8 +274,9 @@ def create_proposal(request): today = timezone.now().strftime('%Y-%m-%d') currDesig = request.session['currentDesignationSelected'] - dept_admin_design = ['dept_admin1', 'dept_admin2', 'dept_admin3'] # Replace with actual department admin designations - isAdmin = currDesig == 'ps_admin' or currDesig in dept_admin_design + dept_admin_designs = dept_admin_design + isAdmin = currDesig == 'ps_admin' or currDesig in dept_admin_designs + notifs = request.user.notifications.all() context = { 'file': file, @@ -265,30 +285,46 @@ def create_proposal(request): 'designations': designations, 'today': today, 'isAdmin': isAdmin, + 'notifications':notifs } return render(request, 'ps1/composeIndent.html', context) -# @login_required(login_url = "/accounts/login") -# def compose_indent(request): -# file = File.objects.select_related('uploader__user','uploader__department','designation').all() -# 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) -# context = { -# 'file': file, -# 'extrainfo': extrainfo, -# 'holdsdesignations': holdsdesignations, -# 'designations': designations, -# } -# return render(request, 'ps1/composeIndent.html', context) + +@login_required(login_url = "/accounts/login") +def composed_indents(request): + """ + The function is used to get all the files created by user(employee). + It gets all files created by user by filtering file(table) object by user i.e, uploader. + It displays user and file details of a file(table) of filetracking(model) in the + template of 'Saved files' tab. + + @param: + request - trivial. + + @variables: + draft - The File object filtered by uploader(user). + extrainfo - The Extrainfo object. + context - Holds data needed to make necessary changes in the template. + """ + + # draft = File.objects.filter(uploader=request.user.extrainfo) + # draft = File.objects.filter(uploader=request.user.extrainfo).order_by('-upload_date') + + # print(File.objects) + # extrainfo = ExtraInfo.objects.all() + # designation = Designation.objects.get(id=HoldsDesignation.objects.get(user=request.user).designation_id) + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') + designation = HoldsDesignation.objects.filter(user=request.user, designation__name=request.session['currentDesignationSelected']).first() + print(designation) - + return redirect(f'/purchase-and-store/indentview/{designation.id}') @login_required(login_url = "/accounts/login") -def composed_indents(request): +def archieved_files(request): """ The function is used to get all the files created by user(employee). It gets all files created by user by filtering file(table) object by user i.e, uploader. @@ -310,16 +346,13 @@ def composed_indents(request): # print(File.objects) # extrainfo = ExtraInfo.objects.all() # designation = Designation.objects.get(id=HoldsDesignation.objects.get(user=request.user).designation_id) - des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() if request.session['currentDesignationSelected'] == "student": return redirect('/dashboard') - designation = HoldsDesignation.objects.filter(user=request.user) - context = { - # 'draft': draft, - # 'extrainfo': extrainfo, - 'designation': designation, - } - return render(request, 'ps1/composed_indents.html', context) + + designation = HoldsDesignation.objects.filter(user=request.user, designation__name=request.session['currentDesignationSelected']).first() + + + return redirect(f'/purchase-and-store/archieveview/{designation.id}') @@ -366,21 +399,24 @@ def drafts(request): # print(File.objects) # extrainfo = ExtraInfo.objects.all() # designation = Designation.objects.get(id=HoldsDesignation.objects.get(user=request.user).designation_id) - des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() if request.session['currentDesignationSelected'] == "student": return redirect('/dashboard') - designation = HoldsDesignation.objects.filter(user=request.user) - context = { - # 'draft': draft, - # 'extrainfo': extrainfo, - 'designation': designation, - } - return render(request, 'ps1/drafts.html', context) + + designation = HoldsDesignation.objects.filter(user=request.user, designation__name=request.session['currentDesignationSelected']).first() + + + return redirect(f'/purchase-and-store/draftview/{designation.id}') @login_required(login_url = "/accounts/login") def indentview(request,id): - print("id : ",id); - + print("id : ",id) + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') + + designation = HoldsDesignation.objects.filter(user=request.user, designation__name=request.session['currentDesignationSelected']).first() + + if str(id) != str(designation.id): + return redirect(f'/purchase-and-store/indentview/{designation.id}') tracking_objects=Tracking.objects.all() tracking_obj_ids=[obj.file_id for obj in tracking_objects] draft_indent = IndentFile.objects.filter(file_info__in=tracking_obj_ids) @@ -391,14 +427,52 @@ def indentview(request,id): abcd = HoldsDesignation.objects.get(pk=id) s = str(abcd).split(" - ") designations = s[1] + notifs = request.user.notifications.all() context = { 'indents' : indents, 'extrainfo': extrainfo, 'designations': designations, + 'notifications':notifs } return render(request, 'ps1/indentview.html', context) +@login_required(login_url = "/accounts/login") +def archieveview(request,id): + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') + + designation = HoldsDesignation.objects.filter(user=request.user, designation__name=request.session['currentDesignationSelected']).first() + + if str(id) != str(designation.id): + return redirect(f'/purchase-and-store/archieveview/{designation.id}') + print("id : ",id); + print("request.user : ",request.user); + + abcd = HoldsDesignation.objects.get(pk=id) + s = str(abcd).split(" - ") + designations = s[1] + print("designations : ",designations); + + archived_files = view_archived( + username=request.user, + designation=designations, + src_module="ps1" + ) + + print("archived_files : ",archived_files); + for files in archived_files: + files['upload_date']=datetime.fromisoformat(files['upload_date']) + files['upload_date']=files['upload_date'].strftime("%B %d, %Y, %I:%M %p") + + notifs = request.user.notifications.all() + context = { + 'archieves' : archived_files, + 'designations': designations, + 'notifications':notifs + } + return render(request, 'ps1/archieve_view.html', context) + # @login_required(login_url = "/accounts/login") # def draftview_multiple_items_indent(request,id): @@ -445,10 +519,13 @@ def indentview(request,id): @login_required(login_url = "/accounts/login") def draftview(request,id): - - des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() if request.session['currentDesignationSelected'] == "student": return redirect('/dashboard') + + designation = HoldsDesignation.objects.filter(user=request.user, designation__name=request.session['currentDesignationSelected']).first() + + if str(id) != str(designation.id): + return redirect(f'/purchase-and-store/draftview/{designation.id}') indents= IndentFile.objects.filter(file_info__in=request.user.extrainfo.uploaded_files.all()).select_related('file_info') indent_ids=[indent.file_info for indent in indents] @@ -461,16 +538,25 @@ def draftview(request,id): abcd = HoldsDesignation.objects.get(pk=id) s = str(abcd).split(" - ") designations = s[1] + notifs = request.user.notifications.all() context = { 'draft': draft_files, 'extrainfo': extrainfo, 'designations': designations, + 'notifications':notifs } return render(request, 'ps1/draftview.html', context) @login_required(login_url = "/accounts/login") def indentview2(request,id): + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') + + designation = HoldsDesignation.objects.filter(user=request.user, designation__name=request.session['currentDesignationSelected']).first() + + if str(id) != str(designation.id): + return redirect(f'/purchase-and-store/indentview2/{designation.id}') abcd = HoldsDesignation.objects.get(pk=id) s = str(abcd).split(" - ") designations = s[1] @@ -482,10 +568,13 @@ def indentview2(request,id): for item in data: item['upload_date'] = datetime.fromisoformat(item['upload_date']) + + notifs = request.user.notifications.all() context = { 'receive_design':abcd, 'in_file': data, + 'notifications':notifs } return render(request, 'ps1/indentview2.html', context) @@ -511,16 +600,13 @@ def inward(request): in_file - The Tracking object filtered by receiver_id i.e, present working user. context - Holds data needed to make necessary changes in the template. """ - des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() - if str(des.designation) == "student": + if request.session['currentDesignationSelected'] == "student": return redirect('/dashboard') - designation = HoldsDesignation.objects.filter(user=request.user) - context = { - 'designation': designation, - } + designation = HoldsDesignation.objects.filter(user=request.user, designation__name=request.session['currentDesignationSelected']).first() + - return render(request, 'ps1/inwardIndent.html', context) + return redirect(f'/purchase-and-store/indentview2/{designation.id}') @@ -573,8 +659,23 @@ def forwardindent(request, id): file=indent.file_info # start = timer() track = Tracking.objects.select_related('file_id__uploader__user','file_id__uploader__department','file_id__designation','current_id__user','current_id__department', -'current_design__user','current_design__working','current_design__designation','receiver_id','receive_design').filter(file_id=file) +'current_design__user','current_design__working','current_design__designation','receiver_id','receive_design').filter(file_id=file).order_by('forward_date') # end = timer() + + lastTrackInstance = track.last(); + + # print(lastTrackInstance.receiver_id ," : " ,lastTrackInstance.receive_design) + # print(request.user); + # print(request.user == lastTrackInstance.receiver_id) + + fileHistory=view_history(file.id) + lastElement = fileHistory[-1] + current_id=lastElement['current_id'] + isArchivable = False + print(request.user.username,"request.user.username") + print(current_id,"current_id") + if current_id == request.user.username: + isArchivable = True if request.method == "POST": # print('Mohit Will Win : ' , request.POST); @@ -583,10 +684,24 @@ def forwardindent(request, id): file.complete_flag = True file.save() + if 'Archieve' in request.POST: + print("inside archieve") + is_archived = archive_file(file_id=file.id) + print("is_archived : ",is_archived) + + if is_archived: + messages.success(request, 'Indent File Archived successfully') + return redirect('/purchase-and-store/forwardedIndent/{0}'.format(file.id)) + else: + messages.error(request, 'Indent File could not be archived') + if 'send' in request.POST: current_id = request.user.extrainfo remarks = request.POST.get('remarks') - sender_design_id = request.POST.get('sender') + + sender_design_id = HoldsDesignation.objects.filter(user=request.user, designation__name=request.session['currentDesignationSelected']).first().id + + sender_designationobj = HoldsDesignation.objects.get(id=sender_design_id).designation sender_designation_name = sender_designationobj.name @@ -595,6 +710,10 @@ def forwardindent(request, id): receiver = receiverHdobj.user.username receive_design = receiverHdobj.designation.name + # print("sender_design_id : ", sender_design_id ); + + + try: receiver_id = User.objects.get(username=receiver) except Exception as e: @@ -617,6 +736,7 @@ def forwardindent(request, id): 'designations': designations, 'file': file, 'track': track, + 'lastTrackingInstance':lastTrackInstance } return render(request, 'ps1/forwardindent.html', context) @@ -631,19 +751,14 @@ def forwardindent(request, id): file_attachment=upload_file ) - - - if (str(receive_design) in dept_admin_design): - indent.head_approval=True - elif (( - (sender_designation_name in dept_admin_design) - or - (sender_designation_name == "ps_admin") - ) - and (str(receive_design) == "Accounts Admin")): - indent.director_approval=True - indent.financial_approval=True - indent.head_approval=True + # 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 + elif ((sender_designation_name in ["Director","Registrar"]) and (str(receive_design) in dept_admin_design)): + indent.director_approval=True + elif ((sender_designation_name == "Accounts Admin") and ((str(receive_design) in dept_admin_design) or str(receive_design) == "ps_admin")): + indent.financial_approval=True + designs =[] designations = HoldsDesignation.objects.select_related('user','working','designation').filter(user=request.user) @@ -668,7 +783,9 @@ def forwardindent(request, id): 'designations':designations, 'file': file, 'track': track, - 'indent':indent + 'indent':indent, + 'isArchivable':isArchivable, + 'lastTrackingInstance':lastTrackInstance } return render(request, 'ps1/forwardindent.html', context) @@ -720,6 +837,9 @@ def createdindent(request, id): current_design = HoldsDesignation.objects.select_related('user','working','designation').get(id=sender) receiver = request.POST.get('receiver') + print("receiver: ", receiver) + print("receiverid : ", User.objects.get(username=receiver)) + try: receiver_id = User.objects.get(username=receiver) except Exception as e: @@ -751,15 +871,24 @@ def createdindent(request, id): return render(request, 'ps1/createdindent.html', context) upload_file = request.FILES.get('myfile') # return HttpResponse ("success") - Tracking.objects.create( - file_id=file, - current_id=current_id, - current_design=current_design, - receive_design=receive_design, - receiver_id=receiver_id, + receiver_obj = User.objects.get(username=receiver) + forwarded_file_id = forward_file( + file_id=file.id, + receiver=receiver, + receiver_designation=receive_design, + file_extra_JSON={"key": 2}, remarks=remarks, - upload_file=upload_file, + file_attachment=upload_file ) + # Tracking.objects.create( + # file_id=file, + # current_id=current_id, + # current_design=current_design, + # receive_design=receive_design, + # receiver_id=receiver_id, + # remarks=remarks, + # upload_file=upload_file, + # ) messages.success(request, 'Indent File sent successfully') @@ -774,7 +903,52 @@ def createdindent(request, id): return render(request, 'ps1/createdindent.html', context) +@login_required(login_url = "/accounts/login") +def forwardedIndent(request, id): + """ + The function is used to forward created indent files by user(employee) . + @param: + request - trivial. + id - id of the file object which the user intends to forward to other employee. + @variables: + file - The File object. + track - The Tracking object. + remarks = Remarks posted by user. + receiver = Receiver to be selected by user for forwarding file. + receiver_id = Receiver_id who has been selected for forwarding file. + upload_file = File attached by user. + extrainfo = ExtraInfo object. + holdsdesignations = HoldsDesignation objects. + context - Holds data needed to make necessary changes in the template. + """ + des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') + # start = timer() + + # end = timer() + indent=IndentFile.objects.select_related('file_info').get(file_info=id) + file=indent.file_info + # start = timer() + track = Tracking.objects.select_related('file_id__uploader__user','file_id__uploader__department','file_id__designation','current_id__user','current_id__department', +'current_design__user','current_design__working','current_design__designation','receiver_id','receive_design').filter(file_id=file) + # end = timer() + + + + + + + designations = HoldsDesignation.objects.select_related('user','working','designation').filter(user=request.user) + + context = { + 'designations':designations, + 'file': file, + 'track': track, + 'indent':indent, + } + return render(request, 'ps1/forwardedIndent.html', context) def AjaxDropdown1(request): des = HoldsDesignation.objects.all().select_related().filter(user = request.user).first() @@ -922,22 +1096,19 @@ def current_stock_view(request): if request.method=="POST": print('the requested data : ', request.POST) department = request.POST.get('department') - grade = request.POST.get('grade') type = request.POST.get('type') # StockEntryId__item_id__file_info_grade StockItems = StockItem.objects.filter( department=department, - StockEntryId__item_id__grade=grade, StockEntryId__item_id__item_type=type ) - grouped_items = StockItems.values('StockEntryId__item_id__item_type', 'StockEntryId__item_id__grade','department').annotate(total_quantity=Count('id')) + grouped_items = StockItems.values('StockEntryId__item_id__item_type', 'department').annotate(total_quantity=Count('id')) grouped_items_list = [ { 'item_type': item['StockEntryId__item_id__item_type'], - 'grade': item['StockEntryId__item_id__grade'], 'department': DepartmentInfo.objects.get(id=department), 'total_quantity': item['total_quantity'] } @@ -946,6 +1117,8 @@ def current_stock_view(request): firstStock=StockItems.first() + + return render(request,'ps1/current_stock_view.html',{'stocks':grouped_items_list,'first_stock':firstStock, 'stockItems':StockItems}) @@ -954,33 +1127,32 @@ def current_stock_view(request): # THIS IS HARDCODED FOR NOW . itemsTypes=['Equipment','Machinery','Furniture','Fixture'] - grades=['A','B','C'] departmentUser=request.user.extrainfo.department if request.session['currentDesignationSelected'] in dept_admin_design: # if department admin then only show the stocks of that department to them print(dept_admin_to_dept[request.session['currentDesignationSelected']]); - deptId = DepartmentInfo.objects.get(name=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) elif request.session['currentDesignationSelected'] == "ps_admin": - departments=DepartmentInfo.objects.all() + departments=DepartmentInfo.objects.values('id','name').all() + StockItems = StockItem.objects.all() else : return redirect('/dashboard') - grouped_items = StockItems.values('StockEntryId__item_id__item_type', 'StockEntryId__item_id__grade','department').annotate(total_quantity=Count('id')) + grouped_items = StockItems.values('StockEntryId__item_id__item_type','department').annotate(total_quantity=Count('id')) grouped_items_list = [ { 'item_type': item['StockEntryId__item_id__item_type'], - 'grade': item['StockEntryId__item_id__grade'], - 'department': DepartmentInfo.objects.get(id=item['department']), + 'department': DepartmentInfo.objects.values('id','name').get(id=item['department']), 'departmentId': item['department'], 'total_quantity': item['total_quantity'] } @@ -988,9 +1160,9 @@ def current_stock_view(request): ] - return render(request,'ps1/current_stock_view_filter.html',{'itemsTypes':itemsTypes,'grades':grades,'departments':departments,'stocks':grouped_items_list}) + return render(request,'ps1/current_stock_view_filter.html',{'itemsTypes':itemsTypes,'departments':departments,'stocks':grouped_items_list}) -# to display stock items which are having similar item_type ,grade and department.(used in current_stock_view) +# to display stock items which are having similar item_type and department.(used in current_stock_view) @login_required(login_url = "/accounts/login") def stock_item_view(request): @@ -1000,13 +1172,11 @@ def stock_item_view(request): if request.method=="POST": departmentId = request.POST.get('departmentId') - grade = request.POST.get('grade') type = request.POST.get('item_type') # StockEntryId__item_id__file_info_grade StockItems = StockItem.objects.filter( department=departmentId, - StockEntryId__item_id__grade=grade, StockEntryId__item_id__item_type=type ) @@ -1020,7 +1190,6 @@ def stock_entry_view(request): if request.session['currentDesignationSelected'] not in dept_admin_design + ["ps_admin"]: return redirect('/dashboard') - department = request.user.extrainfo.department if request.session['currentDesignationSelected'] in dept_admin_design: # if department admin then only show the stocks of that department to them @@ -1305,11 +1474,9 @@ def stock_transfer(request): temp1=IndentFile.objects.get(file_info=temp) item_type_required =temp1.item_type - item_grade_required = temp1.grade available_items = StockItem.objects.filter( StockEntryId__item_id__item_type=item_type_required, # Foreign key traversal to IndentFile model - StockEntryId__item_id__grade=item_grade_required, # Foreign key traversal to IndentFile model inUse=False # Filter for inUse=False ) @@ -1339,7 +1506,6 @@ def view_transfer(request): return render(request,'ps1/view_transfer.html',{'stockTransfers': stockTransfers}) - @login_required(login_url = "/accounts/login") def outboxview2(request,id): abcd = HoldsDesignation.objects.get(pk=id) @@ -1360,12 +1526,13 @@ def outboxview2(request,id): @login_required(login_url = "/accounts/login") def outboxview(request): - designation = HoldsDesignation.objects.filter(user=request.user) - context = { - 'designation': designation, - } + if request.session['currentDesignationSelected'] == "student": + return redirect('/dashboard') + + designation = HoldsDesignation.objects.filter(user=request.user, designation__name=request.session['currentDesignationSelected']).first() + - return render(request, 'ps1/outboxview.html', context) + return redirect(f'/purchase-and-store/outboxview2/{designation.id}') @login_required(login_url="/accounts/login") diff --git a/FusionIIIT/templates/notifications/ps1_sidepanel.html b/FusionIIIT/templates/notifications/ps1_sidepanel.html new file mode 100644 index 000000000..7f2d7f15b --- /dev/null +++ b/FusionIIIT/templates/notifications/ps1_sidepanel.html @@ -0,0 +1,27 @@ +{% load static %} +{% block sidepanel %} + {% load notifications_tags %} + {% for notice in notifications %} + {% if notice.unread %} +
{{notice.data.module}}
+ {% if notice.data.module == "Academic's Module" %} +
+ +
+ +

{{ notice.verb }}

+
+
+ + + +
+
+ {% endif%} + {% endif %} + {% endfor %} +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/ps1/StockEntry.html b/FusionIIIT/templates/ps1/StockEntry.html index 411fa841a..2e7b39fdd 100644 --- a/FusionIIIT/templates/ps1/StockEntry.html +++ b/FusionIIIT/templates/ps1/StockEntry.html @@ -55,8 +55,8 @@

-
- +
+
-
-
- -

@@ -98,12 +94,11 @@


@@ -112,7 +107,7 @@

- +

diff --git a/FusionIIIT/templates/ps1/archieve_view.html b/FusionIIIT/templates/ps1/archieve_view.html new file mode 100644 index 000000000..7526af5a8 --- /dev/null +++ b/FusionIIIT/templates/ps1/archieve_view.html @@ -0,0 +1,41 @@ +{% extends 'ps1/ps1.html' %} +{% load static %} + +{% block filetracking_tab %} + + +
+ + + + + + + + + + + + + {% for archieve in archieves %} + + + + + + + + + {% endfor %} + +
Created ByFile IDSubjectDateView Indent
{{ archieve.uploader }} - {{ request.user.extrainfo.department.name }}{{ request.user.extrainfo.department.name }}-#{{ archieve.id }}{{ archieve.subject }}{{ archieve.upload_date }}
+
+{% endblock %} diff --git a/FusionIIIT/templates/ps1/archieved_indents.html b/FusionIIIT/templates/ps1/archieved_indents.html new file mode 100644 index 000000000..4e2aa9249 --- /dev/null +++ b/FusionIIIT/templates/ps1/archieved_indents.html @@ -0,0 +1,26 @@ +{% extends 'ps1/ps1.html' %} +{% load static %} + +{% block filetracking_tab %} + + +
+
+ {% endfor %} + + + +
+ +{% endblock %} diff --git a/FusionIIIT/templates/ps1/composeIndent.html b/FusionIIIT/templates/ps1/composeIndent.html index 13aba43ce..8c406a8b6 100644 --- a/FusionIIIT/templates/ps1/composeIndent.html +++ b/FusionIIIT/templates/ps1/composeIndent.html @@ -1,3 +1,4 @@ + {% extends 'ps1/ps1.html' %} {% load static %} @@ -67,16 +68,7 @@

- -
- - -
- +
@@ -139,7 +131,7 @@
Replaced*
-
+
- - +
+ + +
+ +

@@ -194,7 +190,7 @@
Replaced*
-             +
{% endcomment %} @@ -206,19 +202,19 @@

Replaced*
-             +
@@ -247,42 +243,7 @@
Replaced*
{% comment %}the compounder prescription tab ends here {% endcomment %} - + {% endblock %} diff --git a/FusionIIIT/templates/ps1/createdindent.html b/FusionIIIT/templates/ps1/createdindent.html index 1940bde2b..dd5c06a75 100644 --- a/FusionIIIT/templates/ps1/createdindent.html +++ b/FusionIIIT/templates/ps1/createdindent.html @@ -2,6 +2,20 @@ {% load static %} {% block filetracking_tab %} + + @@ -344,38 +407,34 @@ - diff --git a/FusionIIIT/templates/ps1/current_stock_view.html b/FusionIIIT/templates/ps1/current_stock_view.html index bfb93f38c..88153c82a 100644 --- a/FusionIIIT/templates/ps1/current_stock_view.html +++ b/FusionIIIT/templates/ps1/current_stock_view.html @@ -35,8 +35,7 @@

Item Type - Item Grade - department + department/Section Quantity @@ -46,7 +45,6 @@

{{s.item_type}} - {{s.grade}} {{s.department}} {{s.total_quantity}} diff --git a/FusionIIIT/templates/ps1/current_stock_view_filter.html b/FusionIIIT/templates/ps1/current_stock_view_filter.html index d57b85d00..d5ec0df6b 100644 --- a/FusionIIIT/templates/ps1/current_stock_view_filter.html +++ b/FusionIIIT/templates/ps1/current_stock_view_filter.html @@ -22,10 +22,10 @@

{% csrf_token %}
- +
@@ -40,20 +40,11 @@

-
- - -
-
+ +
diff --git a/FusionIIIT/templates/ps1/entry.html b/FusionIIIT/templates/ps1/entry.html index 53d91ab48..b0333c05b 100644 --- a/FusionIIIT/templates/ps1/entry.html +++ b/FusionIIIT/templates/ps1/entry.html @@ -23,7 +23,7 @@

{% if IndentFiles %} -
+
@@ -53,7 +53,7 @@

diff --git a/FusionIIIT/templates/ps1/forwardedIndent.html b/FusionIIIT/templates/ps1/forwardedIndent.html new file mode 100644 index 000000000..d149ec563 --- /dev/null +++ b/FusionIIIT/templates/ps1/forwardedIndent.html @@ -0,0 +1,394 @@ +{% extends 'ps1/ps1.html' %} +{% load static %} + +{% block filetracking_tab %} + + + + + +
+ + + + + {% csrf_token %} + +
+
+
Subject- {{file.subject}}
+
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + +
+
+ + {% for t in track %} +
+
+
+ {{t.current_design}} + + + +
+ Received by: {{t.receiver_id}}-{{t.receive_design}} +
+ +
+
+                                                        {% if t.remarks %}
+                                                            {{t.remarks}}
+                                                        {% else %}
+                                                            No Remarks
+                                                        {% endif %}
+
+                                                     
+
+
+
+
+ {% endfor %} + +
+ +
+ + + + + + + + + + + + + + + +
+
+
+ +
+ + + + + + +
+
+ + + + + + + + + + +{% endblock %} + + + \ No newline at end of file diff --git a/FusionIIIT/templates/ps1/forwardindent.html b/FusionIIIT/templates/ps1/forwardindent.html index 709c4ec77..5c5e17ab1 100644 --- a/FusionIIIT/templates/ps1/forwardindent.html +++ b/FusionIIIT/templates/ps1/forwardindent.html @@ -36,73 +36,117 @@
-
{{file.description}}
- -
Indent Name: {{indent.item_name}}
- -
Indent Quantity: {{indent.quantity}}
- -
Indent Present Stock: {{indent.present_stock}}
- -
Indent Estimated Cost: {{indent.estimated_cost}}
- -
Indent Purpose: {{indent.purpose}}
- -
Indent Specification: {{indent.specification}}
- -
Indent Type: {{indent.item_type}}
- - {% if indent.nature == True %} -
Item Nature: Consumable
- {% else %} -
Item Nature: Non Consumable
- {% endif %} - - {% if indent.indigenous == True %} -
Indent Indigenous: Yes
- {% else %} -
Indent Indigenous: No
- {% endif %} - - {% if indent.replaced == True %} -
Indent Replaced: Yes
- {% else %} -
Indent Replaced: No
- {% endif %} - -
Indent Budgetary Head: {{indent.budgetary_head}}
- -
Indent Expected Delivery: {{indent.expected_delivery}}
- -
Indent Sources of Supply: {{indent.sources_of_supply}}
- - {% if indent.head_approval == True %} -
Indent Head Approval: Yes
- {% else %} -
Indent Head Approval: No
- {% endif %} - - {% if indent.director_approval == True %} -
Indent Director Approval: Yes
- {% else %} -
Indent Director Approval: No
- {% endif %} - - {% if indent.financial_approval == True %} -
Indent Financial Approval: Yes
- {% else %} -
Indent Financial Approval: No
- {% endif %} - - {% if indent.purchased == True %} -
Indent Purchased: Yes
- {% else %} -
Indent Purchased: No
- {% endif %} + + + + + + + + + + + + + + + + + + + + +
- {% for t in track %}
@@ -113,7 +157,7 @@ -
+
Received by: {{t.receiver_id}}-{{t.receive_design}}
@@ -138,46 +182,51 @@
-
- -
+ -
+ {% if lastTrackingInstance.receiver_id == request.user %} -
- +
- {% for designation in designations %} - - {% endfor %} - - -
+ + +
+ +
+ +
-
- - -
+ +
+ + +
+ + {% endif %}
@@ -192,10 +241,20 @@

- - +
+ {% if lastTrackingInstance.receiver_id == request.user %} + + {% endif %} + + {% if isArchivable == True %} + + + {% endif %} +

diff --git a/FusionIIIT/templates/ps1/generate_report.html b/FusionIIIT/templates/ps1/generate_report.html index 8f1153740..7374c533d 100644 --- a/FusionIIIT/templates/ps1/generate_report.html +++ b/FusionIIIT/templates/ps1/generate_report.html @@ -147,7 +147,7 @@

No Records present in database

- + diff --git a/FusionIIIT/templates/ps1/indentview.html b/FusionIIIT/templates/ps1/indentview.html index 8e5d1896c..3d300399c 100644 --- a/FusionIIIT/templates/ps1/indentview.html +++ b/FusionIIIT/templates/ps1/indentview.html @@ -13,7 +13,9 @@

-

{% csrf_token %}
Stock_Name Quantity dealing assistant idDepartmentDepartment/Section stock Report
+
+ +
@@ -32,7 +34,7 @@

- {% if indent.head_approval == False or indent.director_approval == False or indent.financial_approval == False %} @@ -54,6 +56,7 @@

Created By{{request.user.extrainfo.department.name}}-{{indent.file_info.upload_date.year}}-{{indent.file_info.upload_date.month}}-#{{indent.file_info.id}} {{indent.file_info.subject}} {{indent.file_info.upload_date}}
+

diff --git a/FusionIIIT/templates/ps1/outboxview.html b/FusionIIIT/templates/ps1/outboxview.html new file mode 100644 index 000000000..d75661474 --- /dev/null +++ b/FusionIIIT/templates/ps1/outboxview.html @@ -0,0 +1,36 @@ +{% extends 'ps1/ps1.html' %} +{% load static %} + +{% block filetracking_tab %} + + +
+ + +
+
+ {% endfor %} + + + + + +
+ +
+ +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/ps1/outboxview2.html b/FusionIIIT/templates/ps1/outboxview2.html new file mode 100644 index 000000000..d5e6bca1f --- /dev/null +++ b/FusionIIIT/templates/ps1/outboxview2.html @@ -0,0 +1,53 @@ +{% extends 'ps1/ps1.html' %} +{% load static %} + +{% block filetracking_tab %} + + +
+
+ + + + + + + + + + + + + + + + + {% for j in in_file %} + + + + + + + + + + + {% endfor %} + + +
Received asSend byFile IDSubjectDateView File
{{receive_design}}{{j.uploader}}{{j.id}} {{j.subject}}{{j.upload_date}}
+
+ +
+ +{% endblock %} \ No newline at end of file diff --git a/FusionIIIT/templates/ps1/perform_transfer1.html b/FusionIIIT/templates/ps1/perform_transfer1.html index 6fc8430d0..22fdaeb7d 100644 --- a/FusionIIIT/templates/ps1/perform_transfer1.html +++ b/FusionIIIT/templates/ps1/perform_transfer1.html @@ -35,7 +35,7 @@

Stock_Name Quantity dealing assistant id - Department + Department/Section Transfer stocks diff --git a/FusionIIIT/templates/ps1/ps1.html b/FusionIIIT/templates/ps1/ps1.html index a44422160..c79184378 100644 --- a/FusionIIIT/templates/ps1/ps1.html +++ b/FusionIIIT/templates/ps1/ps1.html @@ -7,11 +7,13 @@ {% endblock %} + {% block body %} {% block navBar %} {% include 'dashboard/navbar.html' %} {% endblock %} + {% comment %}The grid starts here!{% endcomment %}
@@ -34,34 +36,56 @@ {% comment %}The Tab-Menu starts here!{% endcomment %}
{% comment %}The right-rail segment ends here!{% endcomment %} diff --git a/FusionIIIT/templates/ps1/stock_edit.html b/FusionIIIT/templates/ps1/stock_edit.html index 7e484a64b..a946be70f 100644 --- a/FusionIIIT/templates/ps1/stock_edit.html +++ b/FusionIIIT/templates/ps1/stock_edit.html @@ -54,19 +54,15 @@


- +
-
- +
+
-
-
- -
- +

@@ -93,12 +89,11 @@


diff --git a/FusionIIIT/templates/ps1/stock_entry_item_view.html b/FusionIIIT/templates/ps1/stock_entry_item_view.html index 42141e283..886ffcd6d 100644 --- a/FusionIIIT/templates/ps1/stock_entry_item_view.html +++ b/FusionIIIT/templates/ps1/stock_entry_item_view.html @@ -1,8 +1,51 @@ + {% extends 'ps1/ps2.html' %} {% load static %} {% block filetracking_tab %} +