From 55f5a9b882a2d03b06199a369e7829e780b17608 Mon Sep 17 00:00:00 2001 From: Ravichendraa <112809862+Ravichendraa@users.noreply.github.com> Date: Mon, 15 Apr 2024 03:09:00 +0530 Subject: [PATCH] AC-1: Fts Added (#1458) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * deployment ports config * gad-3 : week-2 : changed api functions (#1069) * gad-4: Created fileTrackingNotAllowed.html (#1082) * gad-4: new views.py to remove students from file tracking (#1104) * fix: reverting deployment changes * gad-3 : workers would be assigned by Section Incharge instead of Caretaker (#1132) Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> * gad-3: Week7 : fixed the notification and re-assign worker button issues (#1137) Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * auto-restart docker (#1147) * OS -2 : Week 4 : Addition of important personal information during booking an appointment (#1084) * Date validation added * Date Validation for booking ambulance --------- Co-authored-by: Akshay010203 <92329718+Akshay010203@users.noreply.github.com> * gad-3 : week-8 : db migrations after adding Section Incharge (#1173) * before adding functionality for secincharge * Delete 0002_auto_20230321_0041.py * gad-3 : week8 : remove wrong dependency to globals. (#1178) * GAD-4: FTS SDK * fix requirements and docker-compose * fix docker compose and dependencies * add sdk and api folder structure * add sdk methods and fix some urls * update models for API * add urls for api * add methods for viewing file, inbox, outbox, getting designation with serializers and minor bug fixes * fix serializers and fix file attachment functionality in forward_file * sync with upstream * add views and fix urls * create file * create file change * fix create_file, without upload_file feature * fix sdk forward_file : accept remarks * add view_history in sdk * add blueprint for draft and archive methods to sdk * fix FileHeaderSerializer to include id * fix empty file upload error * fix inbox outbox methods to return unique ids * fix complete_flag to is_read * fix inbox outbox methods to not show archived * add view_archived method to sdk * add archive_file method to sdk * fix inbox and outbox output and add support for attachments * add draft methods to sdk * fix default values of named params * fix css for filetracking.html * fix fts serializer.py * add dept adding method to sdk * add helper methods to sdk * fix inbox based on SDK * remove track from TabMenu * fix outbox using SDK * fix archive view for SDK * fix Drafts based on SDK * fix the view file functionality in the web app * fix frontend * fix .gitignore to untrack migrations * fix 1. order of files in inbox and outbox 2. order of files is mantained in uniqueList function * fix login required on viewing file * fix create_file method so that subject and description are also accepted * add rest api for create file and view file * add rest api for create, view and delete file * add rest api for inbox, outbox, history view * add rest api for draft view, forward file * prevent student access of the filetracking module * add dropdown filtering based on reciever username and update notallowed template * add option to unarchive files * fix template for filetrackingnotallowed page * fix attachments view in the history of the file * make the fields in draft view editable * update the views --------- Co-authored-by: Aragorn-64 Co-authored-by: aish0749 * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * changes in programme_cuuriculam,adding version to models (#1330) * Gad 5 (#1341) * Enabled all modules for access (#1120) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) --------- Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> * Os 2 (#1346) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * added announcements and pathologist schedule * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * changes in programme_cuuriculam,adding version to models (#1330) * Fixing ui bugs (#1335) * module completed * integrated dashboard * Revert "integrated dashboard" This reverts commit 8e48ec598072104d1678bfede3daab6fb8d20a2f. * Revert "module completed" This reverts commit 254487731b88e097e42743fabc97e77d84388694. * Revert "module completed" This reverts commit 254487731b88e097e42743fabc97e77d84388694. * Revert "integrated dashboard" This reverts commit 8e48ec598072104d1678bfede3daab6fb8d20a2f. * errors corrected * errors resolved * added dashboard and corrected errors * removed Migrations * removed migrations * removed migrations --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Anudeep Sanapala <71971574+anudeeps0306@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Revert "Os 2" (#1352) This reverts commit 1db64d7da40d190218f6e8b0991bc71cd9da7c88. * Os 2 (#1353) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * added announcements and pathologist schedule * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * changes in programme_cuuriculam,adding version to models (#1330) * Fixing ui bugs (#1335) * module completed * integrated dashboard * Revert "integrated dashboard" This reverts commit 8e48ec598072104d1678bfede3daab6fb8d20a2f. * Revert "module completed" This reverts commit 254487731b88e097e42743fabc97e77d84388694. * Revert "module completed" This reverts commit 254487731b88e097e42743fabc97e77d84388694. * Revert "integrated dashboard" This reverts commit 8e48ec598072104d1678bfede3daab6fb8d20a2f. * errors corrected * errors resolved * added dashboard and corrected errors * removed Migrations * removed migrations * removed migrations * corrected errors --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Anudeep Sanapala <71971574+anudeeps0306@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * OS-1 | VH Module (#1334) * OS1 issue 1024 resolved : Booking form integrated with Front End (#1025) * Enabled all modules for access (#1120) * OS-1 : Week 5 : All changes till week 5 (#1116) * Added start date display in pre registration (#1063) * Major changes in Visitor's Hostel --------- Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> * OS-1 Minor issues resolved (#1202) * Booking form integrated with Front End * OS-1 week 7 issue resolve * Bill structured properly, updated room availability, meal record fixed, url fixed * Indentaion problems fixed * database changed * More indentations issues resolved * More indentations issues resolved * Next button issue resolved * Database Changed, inventory functionality added * Database conflict resolved * Minor issues resolved * Final changes made --------- Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> * visitor hostel * os-1 vh complete * os-1 vh module * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * refactored and corrected booking issues * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * added form * Fixing ui bugs (#1335) --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> --------- Co-authored-by: VedantJain1103 <105827483+VedantJain1103@users.noreply.github.com> Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: harsh-k-singh <105146460+harsh-k-singh@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> Co-authored-by: davneesh Co-authored-by: Avneesh <97170838+davneesh@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: varunraj03 <113377182+varunraj03@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * GAD-4 Updated according to Dashboard changes (#1361) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * fix requirements and docker-compose * fix docker compose and dependencies * add sdk and api folder structure * add sdk methods and fix some urls * update models for API * add urls for api * add methods for viewing file, inbox, outbox, getting designation with serializers and minor bug fixes * fix serializers and fix file attachment functionality in forward_file * sync with upstream * add views and fix urls * create file * create file change * fix create_file, without upload_file feature * fix sdk forward_file : accept remarks * add view_history in sdk * add blueprint for draft and archive methods to sdk * fix FileHeaderSerializer to include id * fix empty file upload error * fix inbox outbox methods to return unique ids * fix complete_flag to is_read * fix inbox outbox methods to not show archived * add view_archived method to sdk * add archive_file method to sdk * fix inbox and outbox output and add support for attachments * add draft methods to sdk * fix default values of named params * fix css for filetracking.html * fix fts serializer.py * add dept adding method to sdk * add helper methods to sdk * fix inbox based on SDK * remove track from TabMenu * fix outbox using SDK * fix archive view for SDK * fix Drafts based on SDK * fix the view file functionality in the web app * fix frontend * fix .gitignore to untrack migrations * fix 1. order of files in inbox and outbox 2. order of files is mantained in uniqueList function * fix login required on viewing file * fix create_file method so that subject and description are also accepted * add rest api for create file and view file * add rest api for create, view and delete file * add rest api for inbox, outbox, history view * add rest api for draft view, forward file * prevent student access of the filetracking module * add dropdown filtering based on reciever username and update notallowed template * add option to unarchive files * fix template for filetrackingnotallowed page * fix attachments view in the history of the file * make the fields in draft view editable * update the views * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * fix file sending and forwarding template to include designation automatically * fix forward file view to include designations automatically * add redirect to dropdown designation to views * add redirect on designation change --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Divyansh Tripathi <55395696+theoden42@users.noreply.github.com> Co-authored-by: aish0749 Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Sa 2 (#1362) * sa-2 : till week-4 : #1009 , #1044 and #1097 fix (#1010) Co-authored-by: theparasgami <20BCS151@iiitdmj.ac.in> * Added start date display in pre registration (#1063) * SA-2 :Query Optimization (#1134) * Query Optimization * Removed Unnecessary print Statements * Used .exists() method * Sa-2: Week 8: Created Api's (#1172) Co-authored-by: Mayankingale123 Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> * Sa 2 (#1332) * updated models * Revert "updated models" This reverts commit 83e2e73d895fc7f6a7ba2fa117624bbcb2ede278. * revert to old * some changes in frontend * some updates in frontend files * added the api for mobiles and updated urls and views of web * some updates in backend * Added frontend for new apis Created frontend for registered students and update menu features * updated admin and ui * resolved errors * Menu UI changes * Updated Menu_card * some fixes * migrations fixed * added mess registration request model * minor changes * added model and view for registeration * url fixed * fixed rebate * added new form for registration request * fixed gitignore resolved conflicts * context * Registration UI Changes * registration UI changes * restored migration file * completed registration * made some ui changes * migration fix * done things about payments * changed some views * Added Registration Remark and Dropdown * Changed id in reg * rectified error with rebate response frontend * fixed datetime in reg * worked on manage reg * deregistration request functionality added * rectified the backend issues for generate bills * added registration list * completed dereg * student bill functionality addded * rectified error of previous commit * added view reg records * added filter in view mess students * worked on bills caretaker side * changed development * Updated special food request * Updated Special food Functionality * minor ui fixes * added search * updated manage registration * added view bills and payments of students for mess caretaker * added notification functionality in right rail * Added Sem start and end date form (#26) * added start date to registration form * made some ui changes * added modal for details of a student * made some ui improvements * tested crontab * added excel upload for bill and reg * added add student to mess * fixes * update bill added and dates added (#32) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * Some UI changes (#35) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * merge fixes * added remove * some ui fixes * fixed cronjobs * semdate fixes * removed migrations * automation of bills no new msg resolved some merge conflicts * useless commit for pulling no msg * completed automation of mess bill generation and payment history feature for student * resolved a merge error --------- Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul * Sa 2 - updated dashboard (#1342) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * updated models * Revert "updated models" This reverts commit 83e2e73d895fc7f6a7ba2fa117624bbcb2ede278. * revert to old * some changes in frontend * some updates in frontend files * added the api for mobiles and updated urls and views of web * some updates in backend * Added frontend for new apis Created frontend for registered students and update menu features * updated admin and ui * resolved errors * Menu UI changes * Updated Menu_card * some fixes * migrations fixed * added mess registration request model * minor changes * added model and view for registeration * url fixed * fixed rebate * added new form for registration request * fixed gitignore resolved conflicts * context * Registration UI Changes * registration UI changes * restored migration file * completed registration * made some ui changes * migration fix * done things about payments * changed some views * Added Registration Remark and Dropdown * Changed id in reg * rectified error with rebate response frontend * fixed datetime in reg * worked on manage reg * deregistration request functionality added * rectified the backend issues for generate bills * added registration list * completed dereg * student bill functionality addded * rectified error of previous commit * added view reg records * added filter in view mess students * worked on bills caretaker side * changed development * Updated special food request * GAD -5 Dashboard Changes (#1325) * Updated Special food Functionality * dashboard and usercard updated (#1329) * minor ui fixes * added search * updated manage registration * added view bills and payments of students for mess caretaker * added notification functionality in right rail * Added Sem start and end date form (#26) * added start date to registration form * made some ui changes * added modal for details of a student * made some ui improvements * tested crontab * added excel upload for bill and reg * added add student to mess * fixes * update bill added and dates added (#32) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * Some UI changes (#35) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * merge fixes * added remove * some ui fixes * fixed cronjobs * semdate fixes * removed migrations * Fixing ui bugs (#1335) * automation of bills no new msg resolved some merge conflicts * useless commit for pulling no msg * completed automation of mess bill generation and payment history feature for student * resolved a merge error --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Sa 2 (#1351) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * updated models * Revert "updated models" This reverts commit 83e2e73d895fc7f6a7ba2fa117624bbcb2ede278. * revert to old * some changes in frontend * some updates in frontend files * added the api for mobiles and updated urls and views of web * some updates in backend * Added frontend for new apis Created frontend for registered students and update menu features * updated admin and ui * resolved errors * Menu UI changes * Updated Menu_card * some fixes * migrations fixed * added mess registration request model * minor changes * added model and view for registeration * url fixed * fixed rebate * added new form for registration request * fixed gitignore resolved conflicts * context * Registration UI Changes * registration UI changes * restored migration file * completed registration * made some ui changes * migration fix * done things about payments * changed some views * Added Registration Remark and Dropdown * Changed id in reg * rectified error with rebate response frontend * fixed datetime in reg * worked on manage reg * deregistration request functionality added * rectified the backend issues for generate bills * added registration list * completed dereg * student bill functionality addded * rectified error of previous commit * added view reg records * added filter in view mess students * worked on bills caretaker side * changed development * Updated special food request * GAD -5 Dashboard Changes (#1325) * Updated Special food Functionality * dashboard and usercard updated (#1329) * minor ui fixes * added search * updated manage registration * added view bills and payments of students for mess caretaker * added notification functionality in right rail * Added Sem start and end date form (#26) * added start date to registration form * made some ui changes * added modal for details of a student * made some ui improvements * tested crontab * added excel upload for bill and reg * added add student to mess * fixes * update bill added and dates added (#32) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * Some UI changes (#35) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * merge fixes * added remove * some ui fixes * fixed cronjobs * semdate fixes * removed migrations * Fixing ui bugs (#1335) * added django crontab to requirements.txt * automation of bills no new msg resolved some merge conflicts * useless commit for pulling no msg * completed automation of mess bill generation and payment history feature for student * resolved a merge error --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> --------- Co-authored-by: Samay Sagar <73112080+samay-rgb@users.noreply.github.com> Co-authored-by: theparasgami <20BCS151@iiitdmj.ac.in> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: PARAS GAMI <86421345+theparasgami@users.noreply.github.com> Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: Mayankingale123 <122631799+Mayankingale123@users.noreply.github.com> Co-authored-by: Mayankingale123 Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Gad 4 - FTS * deployment ports config * gad-4: Created fileTrackingNotAllowed.html (#1082) * gad-4: new views.py to remove students from file tracking (#1104) * fix: reverting deployment changes * GAD-4: FTS SDK * fix requirements and docker-compose * fix docker compose and dependencies * add sdk and api folder structure * add sdk methods and fix some urls * update models for API * add urls for api * add methods for viewing file, inbox, outbox, getting designation with serializers and minor bug fixes * fix serializers and fix file attachment functionality in forward_file * sync with upstream * add views and fix urls * create file * create file change * fix create_file, without upload_file feature * fix sdk forward_file : accept remarks * add view_history in sdk * add blueprint for draft and archive methods to sdk * fix FileHeaderSerializer to include id * fix empty file upload error * fix inbox outbox methods to return unique ids * fix complete_flag to is_read * fix inbox outbox methods to not show archived * add view_archived method to sdk * add archive_file method to sdk * fix inbox and outbox output and add support for attachments * add draft methods to sdk * fix default values of named params * fix css for filetracking.html * fix fts serializer.py * add dept adding method to sdk * add helper methods to sdk * fix inbox based on SDK * remove track from TabMenu * fix outbox using SDK * fix archive view for SDK * fix Drafts based on SDK * fix the view file functionality in the web app * fix frontend * fix .gitignore to untrack migrations * fix 1. order of files in inbox and outbox 2. order of files is mantained in uniqueList function * fix login required on viewing file * fix create_file method so that subject and description are also accepted * add rest api for create file and view file * add rest api for create, view and delete file * add rest api for inbox, outbox, history view * add rest api for draft view, forward file * prevent student access of the filetracking module * add dropdown filtering based on reciever username and update notallowed template * add option to unarchive files * fix template for filetrackingnotallowed page * fix attachments view in the history of the file * make the fields in draft view editable * update the views --------- Co-authored-by: Aragorn-64 Co-authored-by: aish0749 * GAD-4 Updated according to Dashboard changes (#1361) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * fix requirements and docker-compose * fix docker compose and dependencies * add sdk and api folder structure * add sdk methods and fix some urls * update models for API * add urls for api * add methods for viewing file, inbox, outbox, getting designation with serializers and minor bug fixes * fix serializers and fix file attachment functionality in forward_file * sync with upstream * add views and fix urls * create file * create file change * fix create_file, without upload_file feature * fix sdk forward_file : accept remarks * add view_history in sdk * add blueprint for draft and archive methods to sdk * fix FileHeaderSerializer to include id * fix empty file upload error * fix inbox outbox methods to return unique ids * fix complete_flag to is_read * fix inbox outbox methods to not show archived * add view_archived method to sdk * add archive_file method to sdk * fix inbox and outbox output and add support for attachments * add draft methods to sdk * fix default values of named params * fix css for filetracking.html * fix fts serializer.py * add dept adding method to sdk * add helper methods to sdk * fix inbox based on SDK * remove track from TabMenu * fix outbox using SDK * fix archive view for SDK * fix Drafts based on SDK * fix the view file functionality in the web app * fix frontend * fix .gitignore to untrack migrations * fix 1. order of files in inbox and outbox 2. order of files is mantained in uniqueList function * fix login required on viewing file * fix create_file method so that subject and description are also accepted * add rest api for create file and view file * add rest api for create, view and delete file * add rest api for inbox, outbox, history view * add rest api for draft view, forward file * prevent student access of the filetracking module * add dropdown filtering based on reciever username and update notallowed template * add option to unarchive files * fix template for filetrackingnotallowed page * fix attachments view in the history of the file * make the fields in draft view editable * update the views * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * fix file sending and forwarding template to include designation automatically * fix forward file view to include designations automatically * add redirect to dropdown designation to views * add redirect on designation change --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Divyansh Tripathi <55395696+theoden42@users.noreply.github.com> Co-authored-by: aish0749 Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> --------- Co-authored-by: Yathartha Goenka Co-authored-by: prakhar-da-gama <95561933+prakhar-da-gama@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: manavdesai27 Co-authored-by: Divyansh Tripathi <55395696+theoden42@users.noreply.github.com> Co-authored-by: Aragorn-64 Co-authored-by: aish0749 Co-authored-by: Advay Sagarkar <72992475+Aragorn-64@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Ac 1 Request to merge in staging again. (#1373) * Checked the sidebar after acad-admin login and fixed the (#1113) fix: icons that were disabled or not working. * Enabled all modules for access (#1120) * AC-1 : Add functionality to add and update courses (#1300) * Add functionality to add and update courses * Course version added * Delete FusionIIIT/Fusion/settings/development.py * Delete FusionIIIT/applications/academic_procedures/migrations/0002_auto_20240218_1206.py * Delete FusionIIIT/applications/eis/migrations/0002_auto_20240218_1206.py * Delete FusionIIIT/applications/globals/migrations/0002_auto_20240218_1206.py * Delete FusionIIIT/applications/globals/migrations/0003_auto_20240218_1235.py * Delete FusionIIIT/applications/globals/migrations/0004_auto_20240218_1242.py * Delete FusionIIIT/applications/globals/migrations/0005_auto_20240218_1325.py * Delete FusionIIIT/applications/globals/migrations/0006_auto_20240218_1336.py * Delete FusionIIIT/applications/globals/migrations/0007_auto_20240218_1601.py * Delete FusionIIIT/applications/globals/migrations/0008_auto_20240218_1942.py * Delete FusionIIIT/applications/globals/migrations/0009_auto_20240219_2217.py * Delete FusionIIIT/applications/globals/migrations/0010_auto_20240219_2232.py * Delete FusionIIIT/applications/scholarships/migrations/0002_auto_20240218_1206.py * Delete requirements.txt * Delete FusionIIIT/applications/programme_curriculum/migrations/0002_auto_20240312_1929.py * Delete FusionIIIT/applications/programme_curriculum/migrations/0003_auto_20240312_1944.py * Delete FusionIIIT/applications/programme_curriculum/migrations/0004_course_latest_version.py * Delete FusionIIIT/applications/programme_curriculum/migrations/0005_auto_20240313_0128.py * AC-1 Updated according to dashboard (#1355) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Ac1 Updated Dashboard --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * changes in programme_cuuriculam,adding version to models (#1330) * Ac-1 updated model.py (#1372) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Ac1 Updated Dashboard * changes * Changes in model.py * Changes in model.py --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> --------- Co-authored-by: EyeOfHorus158 <75492668+EyeOfHorus158@users.noreply.github.com> Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Ravichendraa <112809862+Ravichendraa@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: Anudeep Sanapala <71971574+anudeeps0306@users.noreply.github.com> * Revert "Ac 1 Request to merge in staging again. (#1373)" (#1376) This reverts commit 16523a7a1568d165a8212794bc646b8557bd0569. * Ac-1 updated model.py (#1372) (#1378) * GAD-5: Fix responsiveness (#1125) * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Ac1 Updated Dashboard * changes * Changes in model.py * Changes in model.py --------- Co-authored-by: Ravichendraa <112809862+Ravichendraa@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * merging Ac 5 into staging (#1379) * Fix problem regarding fetching batch for students enrolled in batch 2… (#1030) * Fix form render for students of 2020 batch and later (#1103) * AC-5 (spacs) : dashboard integration and invitations and application update issues (#1345) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * debugging and refactoring * resolved invitation notifications error * added apply convocation functionality * fixed profile redirection issue * fixed profile redirection issues * refactoring and other changes * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * resolved routing error * removed delete button --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Nitya Tiwari Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> --------- Co-authored-by: gaur-abhi524 <82049206+gaur-abhi524@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: Sudheer dagar <60738162+sudheerdagar@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: Nitya Tiwari Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> * modified academic_info_models * removed migrations * removed migration folders * added migrationns * Update development.py * Update requirements.txt * Gad 3 (#1383) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * Minor changes * Implementation of FTS and completion of the redirect functionality * Change in model of supervisor * Complition of redirect functionality and pagination * Fixation of a error * Completion of module * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Integrated dashborad * creating new branch * disallowing migrations * removing migration files --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Ac 2 merging to staging (#1384) * ac-2: added sample excel sheet to add new students and deleted unnecessary files (#1109) * AC-2: Replaced .xlsx file with .xls file (#1124) * created apis for AC2 module * created apis for AC2 module * created apis for AC2 module * added apis for AC2 module and created backlog model * created functionalities for pre registration configuration , also created html templates and apis for the same * removing postgres data files and migrations file * Remove ignored files from repository * removing postgres data files and migrations file * removing postgres data files * functionality for faculty to view assigned course and generate roll list * Wrong details displayed : course name in place of course code * Removed migrations file * Changed the gitignore file * Updated PR AC2-Course registration after the changes and integration with new Dashboard (#1357) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * Added JSON APIs for get_next_sem_courses , add_course_to_slot , remove_course_from_slot * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * changes in programme_cuuriculam,adding version to models (#1330) * initial commit * new features for making pre registration automated * Revert "Replace course functionality added" * useless commit * changes in code - for verification of student by admin after final registration * replace functionality added * check for if seats available during replace course and pre reg, solved issues when returning student personal details * Fixing ui bugs (#1335) * added swayam functionality and resolved some other issues * fixed dropcourse option issue in acad admin view * ais/profile conflict * old modules.html * check modules.html conflict * check modules.html conflict 2 * resolving conflict --------- Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: Divyanshu Sharma <21bcs079@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Anudeep Sanapala <71971574+anudeeps0306@users.noreply.github.com> Co-authored-by: TilteD24 <21bcs080@iiitdmj.ac.in> Co-authored-by: Divyanshu Srivastava <97041656+TilteD24@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> --------- Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Divyanshu Sharma <21bcs079@iiitdmj.ac.in> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: Divyanshu Sharma <114430068+Divyanshusir@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Anudeep Sanapala <71971574+anudeeps0306@users.noreply.github.com> Co-authored-by: TilteD24 <21bcs080@iiitdmj.ac.in> Co-authored-by: Divyanshu Srivastava <97041656+TilteD24@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Staging6 (#1385) * Checked the sidebar after acad-admin login and fixed the (#1113) fix: icons that were disabled or not working. * Enabled all modules for access (#1120) * OS -2 : Week 4 : Addition of important personal information during booking an appointment (#1084) * Date validation added * Date Validation for booking ambulance --------- Co-authored-by: Akshay010203 <92329718+Akshay010203@users.noreply.github.com> * AC-1 : Add functionality to add and update courses (#1300) * Add functionality to add and update courses * Course version added * Delete FusionIIIT/Fusion/settings/development.py * Delete FusionIIIT/applications/academic_procedures/migrations/0002_auto_20240218_1206.py * Delete FusionIIIT/applications/eis/migrations/0002_auto_20240218_1206.py * Delete FusionIIIT/applications/globals/migrations/0002_auto_20240218_1206.py * Delete FusionIIIT/applications/globals/migrations/0003_auto_20240218_1235.py * Delete FusionIIIT/applications/globals/migrations/0004_auto_20240218_1242.py * Delete FusionIIIT/applications/globals/migrations/0005_auto_20240218_1325.py * Delete FusionIIIT/applications/globals/migrations/0006_auto_20240218_1336.py * Delete FusionIIIT/applications/globals/migrations/0007_auto_20240218_1601.py * Delete FusionIIIT/applications/globals/migrations/0008_auto_20240218_1942.py * Delete FusionIIIT/applications/globals/migrations/0009_auto_20240219_2217.py * Delete FusionIIIT/applications/globals/migrations/0010_auto_20240219_2232.py * Delete FusionIIIT/applications/scholarships/migrations/0002_auto_20240218_1206.py * Delete requirements.txt * Delete FusionIIIT/applications/programme_curriculum/migrations/0002_auto_20240312_1929.py * Delete FusionIIIT/applications/programme_curriculum/migrations/0003_auto_20240312_1944.py * Delete FusionIIIT/applications/programme_curriculum/migrations/0004_course_latest_version.py * Delete FusionIIIT/applications/programme_curriculum/migrations/0005_auto_20240313_0128.py * Gad 5 (#1341) * Enabled all modules for access (#1120) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) --------- Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> * Os 2 (#1346) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * added announcements and pathologist schedule * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * changes in programme_cuuriculam,adding version to models (#1330) * Fixing ui bugs (#1335) * module completed * integrated dashboard * Revert "integrated dashboard" This reverts commit 8e48ec598072104d1678bfede3daab6fb8d20a2f. * Revert "module completed" This reverts commit 254487731b88e097e42743fabc97e77d84388694. * Revert "module completed" This reverts commit 254487731b88e097e42743fabc97e77d84388694. * Revert "integrated dashboard" This reverts commit 8e48ec598072104d1678bfede3daab6fb8d20a2f. * errors corrected * errors resolved * added dashboard and corrected errors * removed Migrations * removed migrations * removed migrations --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Anudeep Sanapala <71971574+anudeeps0306@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Revert "Os 2" (#1352) This reverts commit 1db64d7da40d190218f6e8b0991bc71cd9da7c88. * Os 2 (#1353) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * added announcements and pathologist schedule * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * changes in programme_cuuriculam,adding version to models (#1330) * Fixing ui bugs (#1335) * module completed * integrated dashboard * Revert "integrated dashboard" This reverts commit 8e48ec598072104d1678bfede3daab6fb8d20a2f. * Revert "module completed" This reverts commit 254487731b88e097e42743fabc97e77d84388694. * Revert "module completed" This reverts commit 254487731b88e097e42743fabc97e77d84388694. * Revert "integrated dashboard" This reverts commit 8e48ec598072104d1678bfede3daab6fb8d20a2f. * errors corrected * errors resolved * added dashboard and corrected errors * removed Migrations * removed migrations * removed migrations * corrected errors --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Anudeep Sanapala <71971574+anudeeps0306@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * OS-1 | VH Module (#1334) * OS1 issue 1024 resolved : Booking form integrated with Front End (#1025) * Enabled all modules for access (#1120) * OS-1 : Week 5 : All changes till week 5 (#1116) * Added start date display in pre registration (#1063) * Major changes in Visitor's Hostel --------- Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> * OS-1 Minor issues resolved (#1202) * Booking form integrated with Front End * OS-1 week 7 issue resolve * Bill structured properly, updated room availability, meal record fixed, url fixed * Indentaion problems fixed * database changed * More indentations issues resolved * More indentations issues resolved * Next button issue resolved * Database Changed, inventory functionality added * Database conflict resolved * Minor issues resolved * Final changes made --------- Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> * visitor hostel * os-1 vh complete * os-1 vh module * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * refactored and corrected booking issues * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * added form * Fixing ui bugs (#1335) --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> --------- Co-authored-by: VedantJain1103 <105827483+VedantJain1103@users.noreply.github.com> Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: harsh-k-singh <105146460+harsh-k-singh@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> Co-authored-by: davneesh Co-authored-by: Avneesh <97170838+davneesh@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: varunraj03 <113377182+varunraj03@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * AC-1 Updated according to dashboard (#1355) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Ac1 Updated Dashboard --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Sa 2 (#1362) * sa-2 : till week-4 : #1009 , #1044 and #1097 fix (#1010) Co-authored-by: theparasgami <20BCS151@iiitdmj.ac.in> * Added start date display in pre registration (#1063) * SA-2 :Query Optimization (#1134) * Query Optimization * Removed Unnecessary print Statements * Used .exists() method * Sa-2: Week 8: Created Api's (#1172) Co-authored-by: Mayankingale123 Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> * Sa 2 (#1332) * updated models * Revert "updated models" This reverts commit 83e2e73d895fc7f6a7ba2fa117624bbcb2ede278. * revert to old * some changes in frontend * some updates in frontend files * added the api for mobiles and updated urls and views of web * some updates in backend * Added frontend for new apis Created frontend for registered students and update menu features * updated admin and ui * resolved errors * Menu UI changes * Updated Menu_card * some fixes * migrations fixed * added mess registration request model * minor changes * added model and view for registeration * url fixed * fixed rebate * added new form for registration request * fixed gitignore resolved conflicts * context * Registration UI Changes * registration UI changes * restored migration file * completed registration * made some ui changes * migration fix * done things about payments * changed some views * Added Registration Remark and Dropdown * Changed id in reg * rectified error with rebate response frontend * fixed datetime in reg * worked on manage reg * deregistration request functionality added * rectified the backend issues for generate bills * added registration list * completed dereg * student bill functionality addded * rectified error of previous commit * added view reg records * added filter in view mess students * worked on bills caretaker side * changed development * Updated special food request * Updated Special food Functionality * minor ui fixes * added search * updated manage registration * added view bills and payments of students for mess caretaker * added notification functionality in right rail * Added Sem start and end date form (#26) * added start date to registration form * made some ui changes * added modal for details of a student * made some ui improvements * tested crontab * added excel upload for bill and reg * added add student to mess * fixes * update bill added and dates added (#32) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * Some UI changes (#35) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * merge fixes * added remove * some ui fixes * fixed cronjobs * semdate fixes * removed migrations * automation of bills no new msg resolved some merge conflicts * useless commit for pulling no msg * completed automation of mess bill generation and payment history feature for student * resolved a merge error --------- Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul * Sa 2 - updated dashboard (#1342) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * updated models * Revert "updated models" This reverts commit 83e2e73d895fc7f6a7ba2fa117624bbcb2ede278. * revert to old * some changes in frontend * some updates in frontend files * added the api for mobiles and updated urls and views of web * some updates in backend * Added frontend for new apis Created frontend for registered students and update menu features * updated admin and ui * resolved errors * Menu UI changes * Updated Menu_card * some fixes * migrations fixed * added mess registration request model * minor changes * added model and view for registeration * url fixed * fixed rebate * added new form for registration request * fixed gitignore resolved conflicts * context * Registration UI Changes * registration UI changes * restored migration file * completed registration * made some ui changes * migration fix * done things about payments * changed some views * Added Registration Remark and Dropdown * Changed id in reg * rectified error with rebate response frontend * fixed datetime in reg * worked on manage reg * deregistration request functionality added * rectified the backend issues for generate bills * added registration list * completed dereg * student bill functionality addded * rectified error of previous commit * added view reg records * added filter in view mess students * worked on bills caretaker side * changed development * Updated special food request * GAD -5 Dashboard Changes (#1325) * Updated Special food Functionality * dashboard and usercard updated (#1329) * minor ui fixes * added search * updated manage registration * added view bills and payments of students for mess caretaker * added notification functionality in right rail * Added Sem start and end date form (#26) * added start date to registration form * made some ui changes * added modal for details of a student * made some ui improvements * tested crontab * added excel upload for bill and reg * added add student to mess * fixes * update bill added and dates added (#32) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * Some UI changes (#35) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * merge fixes * added remove * some ui fixes * fixed cronjobs * semdate fixes * removed migrations * Fixing ui bugs (#1335) * automation of bills no new msg resolved some merge conflicts * useless commit for pulling no msg * completed automation of mess bill generation and payment history feature for student * resolved a merge error --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Sa 2 (#1351) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * updated models * Revert "updated models" This reverts commit 83e2e73d895fc7f6a7ba2fa117624bbcb2ede278. * revert to old * some changes in frontend * some updates in frontend files * added the api for mobiles and updated urls and views of web * some updates in backend * Added frontend for new apis Created frontend for registered students and update menu features * updated admin and ui * resolved errors * Menu UI changes * Updated Menu_card * some fixes * migrations fixed * added mess registration request model * minor changes * added model and view for registeration * url fixed * fixed rebate * added new form for registration request * fixed gitignore resolved conflicts * context * Registration UI Changes * registration UI changes * restored migration file * completed registration * made some ui changes * migration fix * done things about payments * changed some views * Added Registration Remark and Dropdown * Changed id in reg * rectified error with rebate response frontend * fixed datetime in reg * worked on manage reg * deregistration request functionality added * rectified the backend issues for generate bills * added registration list * completed dereg * student bill functionality addded * rectified error of previous commit * added view reg records * added filter in view mess students * worked on bills caretaker side * changed development * Updated special food request * GAD -5 Dashboard Changes (#1325) * Updated Special food Functionality * dashboard and usercard updated (#1329) * minor ui fixes * added search * updated manage registration * added view bills and payments of students for mess caretaker * added notification functionality in right rail * Added Sem start and end date form (#26) * added start date to registration form * made some ui changes * added modal for details of a student * made some ui improvements * tested crontab * added excel upload for bill and reg * added add student to mess * fixes * update bill added and dates added (#32) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * Some UI changes (#35) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * merge fixes * added remove * some ui fixes * fixed cronjobs * semdate fixes * removed migrations * Fixing ui bugs (#1335) * added django crontab to requirements.txt * automation of bills no new msg resolved some merge conflicts * useless commit for pulling no msg * completed automation of mess bill generation and payment history feature for student * resolved a merge error --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> --------- Co-authored-by: Samay Sagar <73112080+samay-rgb@users.noreply.github.com> Co-authored-by: theparasgami <20BCS151@iiitdmj.ac.in> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: PARAS GAMI <86421345+theparasgami@users.noreply.github.com> Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: Mayankingale123 <122631799+Mayankingale123@users.noreply.github.com> Co-authored-by: Mayankingale123 Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Gad 4 - FTS * deployment ports config * gad-4: Created fileTrackingNotAllowed.html (#1082) * gad-4: new views.py to remove students from file tracking (#1104) * fix: reverting deployment changes * GAD-4: FTS SDK * fix requirements and docker-compose * fix docker compose and dependencies * add sdk and api folder structure * add sdk methods and fix some urls * update models for API * add urls for api * add methods for viewing file, inbox, outbox, getting designation with serializers and minor bug fixes * fix serializers and fix file attachment functionality in forward_file * sync with upstream * add views and fix urls * create file * create file change * fix create_file, without upload_file feature * fix sdk forward_file : accept remarks * add view_history in sdk * add blueprint for draft and archive methods to sdk * fix FileHeaderSerializer to include id * fix empty file upload error * fix inbox outbox methods to return unique ids * fix complete_flag to is_read * fix inbox outbox methods to not show archived * add view_archived method to sdk * add archive_file method to sdk * fix inbox and outbox output and add support for attachments * add draft methods to sdk * fix default values of named params * fix css for filetracking.html * fix fts serializer.py * add dept adding method to sdk * add helper methods to sdk * fix inbox based on SDK * remove track from TabMenu * fix outbox using SDK * fix archive view for SDK * fix Drafts based on SDK * fix the view file functionality in the web app * fix frontend * fix .gitignore to untrack migrations * fix 1. order of files in inbox and outbox 2. order of files is mantained in uniqueList function * fix login required on viewing file * fix create_file method so that subject and description are also accepted * add rest api for create file and view file * add rest api for create, view and delete file * add rest api for inbox, outbox, history view * add rest api for draft view, forward file * prevent student access of the filetracking module * add dropdown filtering based on reciever username and update notallowed template * add option to unarchive files * fix template for filetrackingnotallowed page * fix attachments view in the history of the file * make the fields in draft view editable * update the views --------- Co-authored-by: Aragorn-64 Co-authored-by: aish0749 * GAD-4 Updated according to Dashboard changes (#1361) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * fix requirements and docker-compose * fix docker compose and dependencies * add sdk and api folder structure * add sdk methods and fix some urls * update models for API * add urls for api * add methods for viewing file, inbox, outbox, getting designation with serializers and minor bug fixes * fix serializers and fix file attachment functionality in forward_file * sync with upstream * add views and fix urls * create file * create file change * fix create_file, without upload_file feature * fix sdk forward_file : accept remarks * add view_history in sdk * add blueprint for draft and archive methods to sdk * fix FileHeaderSerializer to include id * fix empty file upload error * fix inbox outbox methods to return unique ids * fix complete_flag to is_read * fix inbox outbox methods to not show archived * add view_archived method to sdk * add archive_file method to sdk * fix inbox and outbox output and add support for attachments * add draft methods to sdk * fix default values of named params * fix css for filetracking.html * fix fts serializer.py * add dept adding method to sdk * add helper methods to sdk * fix inbox based on SDK * remove track from TabMenu * fix outbox using SDK * fix archive view for SDK * fix Drafts based on SDK * fix the view file functionality in the web app * fix frontend * fix .gitignore to untrack migrations * fix 1. order of files in inbox and outbox 2. order of files is mantained in uniqueList function * fix login required on viewing file * fix create_file method so that subject and description are also accepted * add rest api for create file and view file * add rest api for create, view and delete file * add rest api for inbox, outbox, history view * add rest api for draft view, forward file * prevent student access of the filetracking module * add dropdown filtering based on reciever username and update notallowed template * add option to unarchive files * fix template for filetrackingnotallowed page * fix attachments view in the history of the file * make the fields in draft view editable * update the views * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * fix file sending and forwarding template to include designation automatically * fix forward file view to include designations automatically * add redirect to dropdown designation to views * add redirect on designation change --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Divyansh Tripathi <55395696+theoden42@users.noreply.github.com> Co-authored-by: aish0749 Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> --------- Co-authored-by: Yathartha Goenka Co-authored-by: prakhar-da-gama <95561933+prakhar-da-gama@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: manavdesai27 Co-authored-by: Divyansh Tripathi <55395696+theoden42@users.noreply.github.com> Co-authored-by: Aragorn-64 Co-authored-by: aish0749 Co-authored-by: Advay Sagarkar <72992475+Aragorn-64@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * changes in programme_cuuriculam,adding version to models (#1330) * Ac-1 updated model.py (#1372) (#1378) * GAD-5: Fix responsiveness (#1125) * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Ac1 Updated Dashboard * changes * Changes in model.py * Changes in model.py --------- Co-authored-by: Ravichendraa <112809862+Ravichendraa@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * merging Ac 5 into staging (#1379) * Fix problem regarding fetching batch for students enrolled in batch 2… (#1030) * Fix form render for students of 2020 batch and later (#1103) * AC-5 (spacs) : dashboard integration and invitations and application update issues (#1345) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * debugging and refactoring * resolved invitation notifications error * added apply convocation functionality * fixed profile redirection issue * fixed profile redirection issues * refactoring and other changes * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * resolved routing error * removed delete button --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Nitya Tiwari Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> --------- Co-authored-by: gaur-abhi524 <82049206+gaur-abhi524@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: Sudheer dagar <60738162+sudheerdagar@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: Nitya Tiwari Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> * modified academic_info_models * removed migrations * removed migration folders * added migrationns * Update development.py * Update requirements.txt --------- Co-authored-by: EyeOfHorus158 <75492668+EyeOfHorus158@users.noreply.github.com> Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Apc010101 <122636844+Apc010101@users.noreply.github.com> Co-authored-by: Akshay010203 <92329718+Akshay010203@users.noreply.github.com> Co-authored-by: Ravichendraa <112809862+Ravichendraa@users.noreply.github.com> Co-authored-by: Abhikumar Gupta <97209802+abhi87374@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: prem-charan <118535829+prem-charan@users.noreply.github.com> Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: Anudeep Sanapala <71971574+anudeeps0306@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> Co-authored-by: Prajjwal kapoor <68912239+prajjwalkapoor@users.noreply.github.com> Co-authored-by: VedantJain1103 <105827483+VedantJain1103@users.noreply.github.com> Co-authored-by: harsh-k-singh <105146460+harsh-k-singh@users.noreply.github.com> Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> Co-authored-by: davneesh Co-authored-by: Avneesh <97170838+davneesh@users.noreply.github.com> Co-authored-by: varunraj03 <113377182+varunraj03@users.noreply.github.com> Co-authored-by: Shivkant Chauhan <91013793+Shivkant-Chauhan@users.noreply.github.com> Co-authored-by: Samay Sagar <73112080+samay-rgb@users.noreply.github.com> Co-authored-by: theparasgami <20BCS151@iiitdmj.ac.in> Co-authored-by: PARAS GAMI <86421345+theparasgami@users.noreply.github.com> Co-authored-by: Mayankingale123 <122631799+Mayankingale123@users.noreply.github.com> Co-authored-by: Mayankingale123 Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul Co-authored-by: Yathartha Goenka Co-authored-by: prakhar-da-gama <95561933+prakhar-da-gama@users.noreply.github.com> Co-authored-by: manavdesai27 Co-authored-by: Divyansh Tripathi <55395696+theoden42@users.noreply.github.com> Co-authored-by: Aragorn-64 Co-authored-by: aish0749 Co-authored-by: Advay Sagarkar <72992475+Aragorn-64@users.noreply.github.com> Co-authored-by: Prajjwal Kapoor Co-authored-by: gaur-abhi524 <82049206+gaur-abhi524@users.noreply.github.com> Co-authored-by: Sudheer dagar <60738162+sudheerdagar@users.noreply.github.com> Co-authored-by: Nitya Tiwari * corrected faculty profile error * correct faculty profile error * corrected user profile * Faculty Profile errors resolved (#1388) * Checked the sidebar after acad-admin login and fixed the (#1113) fix: icons that were disabled or not working. * Enabled all modules for access (#1120) * OS -2 : Week 4 : Addition of important personal information during booking an appointment (#1084) * Date validation added * Date Validation for booking ambulance --------- Co-authored-by: Akshay010203 <92329718+Akshay010203@users.noreply.github.com> * AC-1 : Add functionality to add and update courses (#1300) * Add functionality to add and update courses * Course version added * Delete FusionIIIT/Fusion/settings/development.py * Delete FusionIIIT/applications/academic_procedures/migrations/0002_auto_20240218_1206.py * Delete FusionIIIT/applications/eis/migrations/0002_auto_20240218_1206.py * Delete FusionIIIT/applications/globals/migrations/0002_auto_20240218_1206.py * Delete FusionIIIT/applications/globals/migrations/0003_auto_20240218_1235.py * Delete FusionIIIT/applications/globals/migrations/0004_auto_20240218_1242.py * Delete FusionIIIT/applications/globals/migrations/0005_auto_20240218_1325.py * Delete FusionIIIT/applications/globals/migrations/0006_auto_20240218_1336.py * Delete FusionIIIT/applications/globals/migrations/0007_auto_20240218_1601.py * Delete FusionIIIT/applications/globals/migrations/0008_auto_20240218_1942.py * Delete FusionIIIT/applications/globals/migrations/0009_auto_20240219_2217.py * Delete FusionIIIT/applications/globals/migrations/0010_auto_20240219_2232.py * Delete FusionIIIT/applications/scholarships/migrations/0002_auto_20240218_1206.py * Delete requirements.txt * Delete FusionIIIT/applications/programme_curriculum/migrations/0002_auto_20240312_1929.py * Delete FusionIIIT/applications/programme_curriculum/migrations/0003_auto_20240312_1944.py * Delete FusionIIIT/applications/programme_curriculum/migrations/0004_course_latest_version.py * Delete FusionIIIT/applications/programme_curriculum/migrations/0005_auto_20240313_0128.py * Gad 5 (#1341) * Enabled all modules for access (#1120) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) --------- Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> * Os 2 (#1346) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * added announcements and pathologist schedule * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * changes in programme_cuuriculam,adding version to models (#1330) * Fixing ui bugs (#1335) * module completed * integrated dashboard * Revert "integrated dashboard" This reverts commit 8e48ec598072104d1678bfede3daab6fb8d20a2f. * Revert "module completed" This reverts commit 254487731b88e097e42743fabc97e77d84388694. * Revert "module completed" This reverts commit 254487731b88e097e42743fabc97e77d84388694. * Revert "integrated dashboard" This reverts commit 8e48ec598072104d1678bfede3daab6fb8d20a2f. * errors corrected * errors resolved * added dashboard and corrected errors * removed Migrations * removed migrations * removed migrations --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Anudeep Sanapala <71971574+anudeeps0306@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Revert "Os 2" (#1352) This reverts commit 1db64d7da40d190218f6e8b0991bc71cd9da7c88. * Os 2 (#1353) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * added announcements and pathologist schedule * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * changes in programme_cuuriculam,adding version to models (#1330) * Fixing ui bugs (#1335) * module completed * integrated dashboard * Revert "integrated dashboard" This reverts commit 8e48ec598072104d1678bfede3daab6fb8d20a2f. * Revert "module completed" This reverts commit 254487731b88e097e42743fabc97e77d84388694. * Revert "module completed" This reverts commit 254487731b88e097e42743fabc97e77d84388694. * Revert "integrated dashboard" This reverts commit 8e48ec598072104d1678bfede3daab6fb8d20a2f. * errors corrected * errors resolved * added dashboard and corrected errors * removed Migrations * removed migrations * removed migrations * corrected errors --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Anudeep Sanapala <71971574+anudeeps0306@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * OS-1 | VH Module (#1334) * OS1 issue 1024 resolved : Booking form integrated with Front End (#1025) * Enabled all modules for access (#1120) * OS-1 : Week 5 : All changes till week 5 (#1116) * Added start date display in pre registration (#1063) * Major changes in Visitor's Hostel --------- Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> * OS-1 Minor issues resolved (#1202) * Booking form integrated with Front End * OS-1 week 7 issue resolve * Bill structured properly, updated room availability, meal record fixed, url fixed * Indentaion problems fixed * database changed * More indentations issues resolved * More indentations issues resolved * Next button issue resolved * Database Changed, inventory functionality added * Database conflict resolved * Minor issues resolved * Final changes made --------- Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> * visitor hostel * os-1 vh complete * os-1 vh module * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * refactored and corrected booking issues * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * added form * Fixing ui bugs (#1335) --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> --------- Co-authored-by: VedantJain1103 <105827483+VedantJain1103@users.noreply.github.com> Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: harsh-k-singh <105146460+harsh-k-singh@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> Co-authored-by: davneesh Co-authored-by: Avneesh <97170838+davneesh@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: varunraj03 <113377182+varunraj03@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * AC-1 Updated according to dashboard (#1355) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Ac1 Updated Dashboard --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Sa 2 (#1362) * sa-2 : till week-4 : #1009 , #1044 and #1097 fix (#1010) Co-authored-by: theparasgami <20BCS151@iiitdmj.ac.in> * Added start date display in pre registration (#1063) * SA-2 :Query Optimization (#1134) * Query Optimization * Removed Unnecessary print Statements * Used .exists() method * Sa-2: Week 8: Created Api's (#1172) Co-authored-by: Mayankingale123 Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> * Sa 2 (#1332) * updated models * Revert "updated models" This reverts commit 83e2e73d895fc7f6a7ba2fa117624bbcb2ede278. * revert to old * some changes in frontend * some updates in frontend files * added the api for mobiles and updated urls and views of web * some updates in backend * Added frontend for new apis Created frontend for registered students and update menu features * updated admin and ui * resolved errors * Menu UI changes * Updated Menu_card * some fixes * migrations fixed * added mess registration request model * minor changes * added model and view for registeration * url fixed * fixed rebate * added new form for registration request * fixed gitignore resolved conflicts * context * Registration UI Changes * registration UI changes * restored migration file * completed registration * made some ui changes * migration fix * done things about payments * changed some views * Added Registration Remark and Dropdown * Changed id in reg * rectified error with rebate response frontend * fixed datetime in reg * worked on manage reg * deregistration request functionality added * rectified the backend issues for generate bills * added registration list * completed dereg * student bill functionality addded * rectified error of previous commit * added view reg records * added filter in view mess students * worked on bills caretaker side * changed development * Updated special food request * Updated Special food Functionality * minor ui fixes * added search * updated manage registration * added view bills and payments of students for mess caretaker * added notification functionality in right rail * Added Sem start and end date form (#26) * added start date to registration form * made some ui changes * added modal for details of a student * made some ui improvements * tested crontab * added excel upload for bill and reg * added add student to mess * fixes * update bill added and dates added (#32) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * Some UI changes (#35) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * merge fixes * added remove * some ui fixes * fixed cronjobs * semdate fixes * removed migrations * automation of bills no new msg resolved some merge conflicts * useless commit for pulling no msg * completed automation of mess bill generation and payment history feature for student * resolved a merge error --------- Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul * Sa 2 - updated dashboard (#1342) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * updated models * Revert "updated models" This reverts commit 83e2e73d895fc7f6a7ba2fa117624bbcb2ede278. * revert to old * some changes in frontend * some updates in frontend files * added the api for mobiles and updated urls and views of web * some updates in backend * Added frontend for new apis Created frontend for registered students and update menu features * updated admin and ui * resolved errors * Menu UI changes * Updated Menu_card * some fixes * migrations fixed * added mess registration request model * minor changes * added model and view for registeration * url fixed * fixed rebate * added new form for registration request * fixed gitignore resolved conflicts * context * Registration UI Changes * registration UI changes * restored migration file * completed registration * made some ui changes * migration fix * done things about payments * changed some views * Added Registration Remark and Dropdown * Changed id in reg * rectified error with rebate response frontend * fixed datetime in reg * worked on manage reg * deregistration request functionality added * rectified the backend issues for generate bills * added registration list * completed dereg * student bill functionality addded * rectified error of previous commit * added view reg records * added filter in view mess students * worked on bills caretaker side * changed development * Updated special food request * GAD -5 Dashboard Changes (#1325) * Updated Special food Functionality * dashboard and usercard updated (#1329) * minor ui fixes * added search * updated manage registration * added view bills and payments of students for mess caretaker * added notification functionality in right rail * Added Sem start and end date form (#26) * added start date to registration form * made some ui changes * added modal for details of a student * made some ui improvements * tested crontab * added excel upload for bill and reg * added add student to mess * fixes * update bill added and dates added (#32) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * Some UI changes (#35) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * merge fixes * added remove * some ui fixes * fixed cronjobs * semdate fixes * removed migrations * Fixing ui bugs (#1335) * automation of bills no new msg resolved some merge conflicts * useless commit for pulling no msg * completed automation of mess bill generation and payment history feature for student * resolved a merge error --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Sa 2 (#1351) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * updated models * Revert "updated models" This reverts commit 83e2e73d895fc7f6a7ba2fa117624bbcb2ede278. * revert to old * some changes in frontend * some updates in frontend files * added the api for mobiles and updated urls and views of web * some updates in backend * Added frontend for new apis Created frontend for registered students and update menu features * updated admin and ui * resolved errors * Menu UI changes * Updated Menu_card * some fixes * migrations fixed * added mess registration request model * minor changes * added model and view for registeration * url fixed * fixed rebate * added new form for registration request * fixed gitignore resolved conflicts * context * Registration UI Changes * registration UI changes * restored migration file * completed registration * made some ui changes * migration fix * done things about payments * changed some views * Added Registration Remark and Dropdown * Changed id in reg * rectified error with rebate response frontend * fixed datetime in reg * worked on manage reg * deregistration request functionality added * rectified the backend issues for generate bills * added registration list * completed dereg * student bill functionality addded * rectified error of previous commit * added view reg records * added filter in view mess students * worked on bills caretaker side * changed development * Updated special food request * GAD -5 Dashboard Changes (#1325) * Updated Special food Functionality * dashboard and usercard updated (#1329) * minor ui fixes * added search * updated manage registration * added view bills and payments of students for mess caretaker * added notification functionality in right rail * Added Sem start and end date form (#26) * added start date to registration form * made some ui changes * added modal for details of a student * made some ui improvements * tested crontab * added excel upload for bill and reg * added add student to mess * fixes * update bill added and dates added (#32) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * Some UI changes (#35) Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> * merge fixes * added remove * some ui fixes * fixed cronjobs * semdate fixes * removed migrations * Fixing ui bugs (#1335) * added django crontab to requirements.txt * automation of bills no new msg resolved some merge conflicts * useless commit for pulling no msg * completed automation of mess bill generation and payment history feature for student * resolved a merge error --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> --------- Co-authored-by: Samay Sagar <73112080+samay-rgb@users.noreply.github.com> Co-authored-by: theparasgami <20BCS151@iiitdmj.ac.in> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: PARAS GAMI <86421345+theparasgami@users.noreply.github.com> Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: Mayankingale123 <122631799+Mayankingale123@users.noreply.github.com> Co-authored-by: Mayankingale123 Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Gad 4 - FTS * deployment ports config * gad-4: Created fileTrackingNotAllowed.html (#1082) * gad-4: new views.py to remove students from file tracking (#1104) * fix: reverting deployment changes * GAD-4: FTS SDK * fix requirements and docker-compose * fix docker compose and dependencies * add sdk and api folder structure * add sdk methods and fix some urls * update models for API * add urls for api * add methods for viewing file, inbox, outbox, getting designation with serializers and minor bug fixes * fix serializers and fix file attachment functionality in forward_file * sync with upstream * add views and fix urls * create file * create file change * fix create_file, without upload_file feature * fix sdk forward_file : accept remarks * add view_history in sdk * add blueprint for draft and archive methods to sdk * fix FileHeaderSerializer to include id * fix empty file upload error * fix inbox outbox methods to return unique ids * fix complete_flag to is_read * fix inbox outbox methods to not show archived * add view_archived method to sdk * add archive_file method to sdk * fix inbox and outbox output and add support for attachments * add draft methods to sdk * fix default values of named params * fix css for filetracking.html * fix fts serializer.py * add dept adding method to sdk * add helper methods to sdk * fix inbox based on SDK * remove track from TabMenu * fix outbox using SDK * fix archive view for SDK * fix Drafts based on SDK * fix the view file functionality in the web app * fix frontend * fix .gitignore to untrack migrations * fix 1. order of files in inbox and outbox 2. order of files is mantained in uniqueList function * fix login required on viewing file * fix create_file method so that subject and description are also accepted * add rest api for create file and view file * add rest api for create, view and delete file * add rest api for inbox, outbox, history view * add rest api for draft view, forward file * prevent student access of the filetracking module * add dropdown filtering based on reciever username and update notallowed template * add option to unarchive files * fix template for filetrackingnotallowed page * fix attachments view in the history of the file * make the fields in draft view editable * update the views --------- Co-authored-by: Aragorn-64 Co-authored-by: aish0749 * GAD-4 Updated according to Dashboard changes (#1361) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * fix requirements and docker-compose * fix docker compose and dependencies * add sdk and api folder structure * add sdk methods and fix some urls * update models for API * add urls for api * add methods for viewing file, inbox, outbox, getting designation with serializers and minor bug fixes * fix serializers and fix file attachment functionality in forward_file * sync with upstream * add views and fix urls * create file * create file change * fix create_file, without upload_file feature * fix sdk forward_file : accept remarks * add view_history in sdk * add blueprint for draft and archive methods to sdk * fix FileHeaderSerializer to include id * fix empty file upload error * fix inbox outbox methods to return unique ids * fix complete_flag to is_read * fix inbox outbox methods to not show archived * add view_archived method to sdk * add archive_file method to sdk * fix inbox and outbox output and add support for attachments * add draft methods to sdk * fix default values of named params * fix css for filetracking.html * fix fts serializer.py * add dept adding method to sdk * add helper methods to sdk * fix inbox based on SDK * remove track from TabMenu * fix outbox using SDK * fix archive view for SDK * fix Drafts based on SDK * fix the view file functionality in the web app * fix frontend * fix .gitignore to untrack migrations * fix 1. order of files in inbox and outbox 2. order of files is mantained in uniqueList function * fix login required on viewing file * fix create_file method so that subject and description are also accepted * add rest api for create file and view file * add rest api for create, view and delete file * add rest api for inbox, outbox, history view * add rest api for draft view, forward file * prevent student access of the filetracking module * add dropdown filtering based on reciever username and update notallowed template * add option to unarchive files * fix template for filetrackingnotallowed page * fix attachments view in the history of the file * make the fields in draft view editable * update the views * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * fix file sending and forwarding template to include designation automatically * fix forward file view to include designations automatically * add redirect to dropdown designation to views * add redirect on designation change --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Divyansh Tripathi <55395696+theoden42@users.noreply.github.com> Co-authored-by: aish0749 Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> --------- Co-authored-by: Yathartha Goenka Co-authored-by: prakhar-da-gama <95561933+prakhar-da-gama@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: manavdesai27 Co-authored-by: Divyansh Tripathi <55395696+theoden42@users.noreply.github.com> Co-authored-by: Aragorn-64 Co-authored-by: aish0749 Co-authored-by: Advay Sagarkar <72992475+Aragorn-64@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * changes in programme_cuuriculam,adding version to models (#1330) * Ac-1 updated model.py (#1372) (#1378) * GAD-5: Fix responsiveness (#1125) * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Ac1 Updated Dashboard * changes * Changes in model.py * Changes in model.py --------- Co-authored-by: Ravichendraa <112809862+Ravichendraa@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * merging Ac 5 into staging (#1379) * Fix problem regarding fetching batch for students enrolled in batch 2… (#1030) * Fix form render for students of 2020 batch and later (#1103) * AC-5 (spacs) : dashboard integration and invitations and application update issues (#1345) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * debugging and refactoring * resolved invitation notifications error * added apply convocation functionality * fixed profile redirection issue * fixed profile redirection issues * refactoring and other changes * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * resolved routing error * removed delete button --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Nitya Tiwari Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> --------- Co-authored-by: gaur-abhi524 <82049206+gaur-abhi524@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: Sudheer dagar <60738162+sudheerdagar@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: Nitya Tiwari Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> * modified academic_info_models * removed migrations * removed migration folders * added migrationns * Update development.py * Update requirements.txt * corrected faculty profile error * correct faculty profile error * corrected user profile --------- Co-authored-by: EyeOfHorus158 <75492668+EyeOfHorus158@users.noreply.github.com> Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Apc010101 <122636844+Apc010101@users.noreply.github.com> Co-authored-by: Akshay010203 <92329718+Akshay010203@users.noreply.github.com> Co-authored-by: Ravichendraa <112809862+Ravichendraa@users.noreply.github.com> Co-authored-by: Abhikumar Gupta <97209802+abhi87374@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: prem-charan <118535829+prem-charan@users.noreply.github.com> Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: Anudeep Sanapala <71971574+anudeeps0306@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> Co-authored-by: Prajjwal kapoor <68912239+prajjwalkapoor@users.noreply.github.com> Co-authored-by: VedantJain1103 <105827483+VedantJain1103@users.noreply.github.com> Co-authored-by: harsh-k-singh <105146460+harsh-k-singh@users.noreply.github.com> Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> Co-authored-by: davneesh Co-authored-by: Avneesh <97170838+davneesh@users.noreply.github.com> Co-authored-by: varunraj03 <113377182+varunraj03@users.noreply.github.com> Co-authored-by: Shivkant Chauhan <91013793+Shivkant-Chauhan@users.noreply.github.com> Co-authored-by: Samay Sagar <73112080+samay-rgb@users.noreply.github.com> Co-authored-by: theparasgami <20BCS151@iiitdmj.ac.in> Co-authored-by: PARAS GAMI <86421345+theparasgami@users.noreply.github.com> Co-authored-by: Mayankingale123 <122631799+Mayankingale123@users.noreply.github.com> Co-authored-by: Mayankingale123 Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul Co-authored-by: Yathartha Goenka Co-authored-by: prakhar-da-gama <95561933+prakhar-da-gama@users.noreply.github.com> Co-authored-by: manavdesai27 Co-authored-by: Divyansh Tripathi <55395696+theoden42@users.noreply.github.com> Co-authored-by: Aragorn-64 Co-authored-by: aish0749 Co-authored-by: Advay Sagarkar <72992475+Aragorn-64@users.noreply.github.com> Co-authored-by: Prajjwal Kapoor Co-authored-by: gaur-abhi524 <82049206+gaur-abhi524@users.noreply.github.com> Co-authored-by: Sudheer dagar <60738162+sudheerdagar@users.noreply.github.com> Co-authored-by: Nitya Tiwari * Gad-3 : fixed minor issues (#1389) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * Minor changes * Implementation of FTS and completion of the redirect functionality * Change in model of supervisor * Complition of redirect functionality and pagination * Fixation of a error * Completion of module * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Integrated dashborad * creating new branch * disallowing migrations * removing migration files * resolved errors --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Gad 3 complaint (#1390) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * Minor changes * Implementation of FTS and completion of the redirect functionality * Change in model of supervisor * Complition of redirect functionality and pagination * Fixation of a error * Completion of module * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Integrated dashborad * creating new branch * disallowing migrations * removing migration files * resolved errors --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Gad 3 complaint (#1391) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * Minor changes * Implementation of FTS and completion of the redirect functionality * Change in model of supervisor * Complition of redirect functionality and pagination * Fixation of a error * Completion of module * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Integrated dashborad * creating new branch * disallowing migrations * removing migration files * resolved errors * resolved error --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * merged staging into gad-3 * merge Gad 3 into staging (#1392) * gad-3 : week-2 : changed api functions (#1069) * gad-3 : workers would be assigned by Section Incharge instead of Caretaker (#1132) Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> * gad-3: Week7 : fixed the notification and re-assign worker button issues (#1137) Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * auto-restart docker (#1147) * gad-3 : week-8 : db migrations after adding Section Incharge (#1173) * before adding functionality for secincharge * Delete 0002_auto_20230321_0041.py * gad-3 : week8 : remove wrong dependency to globals. (#1178) * Gad 3 (#1383) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * Minor changes * Implementation of FTS and completion of the redirect functionality * Change in model of supervisor * Complition of redirect functionality and pagination * Fixation of a error * Completion of module * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Integrated dashborad * creating new branch * disallowing migrations * removing migration files --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Gad-3 : fixed minor issues (#1389) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * Minor changes * Implementation of FTS and completion of the redirect functionality * Change in model of supervisor * Complition of redirect functionality and pagination * Fixation of a error * Completion of module * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Integrated dashborad * creating new branch * disallowing migrations * removing migration files * resolved errors --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Gad 3 complaint (#1390) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * Minor changes * Implementation of FTS and completion of the redirect functionality * Change in model of supervisor * Complition of redirect functionality and pagination * Fixation of a error * Completion of module * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Integrated dashborad * creating new branch * disallowing migrations * removing migration files * resolved errors --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Gad 3 complaint (#1391) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * Minor changes * Implementation of FTS and completion of the redirect functionality * Change in model of supervisor * Complition of redirect functionality and pagination * Fixation of a error * Completion of module * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * Integrated dashborad * creating new branch * disallowing migrations * removing migration files * resolved errors * resolved error --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * merged staging into gad-3 --------- Co-authored-by: ujjawallele13 <111732396+ujjawallele13@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: nidhibarapatre <116302859+nidhibarapatre@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * migrations removed * added phc corrections * prescribe issue resolved in PHC * phc issue resolved * complaint management issue solved * merging sa-4(Pcell) into latest_staging (#1417) * sa-4 : 4 : all-changes-till-now (#1115) Co-authored-by: Smeet Chavan * PlacementModuleWeb (#1322) * urls * added apply for jobs and upload documents * added options for TPO and Chairman * PLacement Schedule method * Added PLacement Statistics * Features added resume,update placement data ,notiication , add schedule * fixed ui issue placement.html * send invitation, check invitaion status ,resolved other minor bugs * Placement cell updated dashboard (#1402) * urls * added apply for jobs and upload documents * added options for TPO and Chairman * PLacement Schedule method * Added PLacement Statistics * Features added resume,update placement data ,notiication , add schedule * fixed ui issue placement.html * send invitation, check invitaion status ,resolved other minor bugs * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * pull * update * invitation status * invitation status --------- Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> * Placementcell (#1411) * urls * added apply for jobs and upload documents * added options for TPO and Chairman * PLacement Schedule method * Added PLacement Statistics * Features added resume,update placement data ,notiication , add schedule * fixed ui issue placement.html * send invitation, check invitaion status ,resolved other minor bugs * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * pull * update * invitation status * invitation status * placement cell --------- Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> * resolved dashboard profile view --------- Co-authored-by: Smeetiiitdmj <121860497+Smeetiiitdmj@users.noreply.github.com> Co-authored-by: Smeet Chavan Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Kush Batla <97120358+kushbatla@users.noreply.github.com> Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> * Pcell (#1423) * sa-4 : 4 : all-changes-till-now (#1115) Co-authored-by: Smeet Chavan * PlacementModuleWeb (#1322) * urls * added apply for jobs and upload documents * added options for TPO and Chairman * PLacement Schedule method * Added PLacement Statistics * Features added resume,update placement data ,notiication , add schedule * fixed ui issue placement.html * send invitation, check invitaion status ,resolved other minor bugs * Placement cell updated dashboard (#1402) * urls * added apply for jobs and upload documents * added options for TPO and Chairman * PLacement Schedule method * Added PLacement Statistics * Features added resume,update placement data ,notiication , add schedule * fixed ui issue placement.html * send invitation, check invitaion status ,resolved other minor bugs * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * pull * update * invitation status * invitation status --------- Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> * Placementcell (#1411) * urls * added apply for jobs and upload documents * added options for TPO and Chairman * PLacement Schedule method * Added PLacement Statistics * Features added resume,update placement data ,notiication , add schedule * fixed ui issue placement.html * send invitation, check invitaion status ,resolved other minor bugs * Added pylint (#1302) * Create bandit_security_test.yml Added Bandit security test for python * Update bandit_security_test.yml * Update bandit_security_test.yml * Create pylint.yml * Update pylint.yml * Update pylint.yml * Revert "Added pylint (#1302)" (#1324) This reverts commit c1359b7ce8a1945e41e90330fe39bc634d9ca6f3. * pull * update * invitation status * invitation status * placement cell --------- Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> * resolved dashboard profile view * reverted requirements.txt changes --------- Co-authored-by: Smeetiiitdmj <121860497+Smeetiiitdmj@users.noreply.github.com> Co-authored-by: Smeet Chavan Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Kush Batla <97120358+kushbatla@users.noreply.github.com> Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> * corrected requirement txt version * mess update merge (#1421) (#1427) * sa-2 : till week-4 : #1009 , #1044 and #1097 fix (#1010) * Added start date display in pre registration (#1063) * GAD-5: Fix responsiveness (#1125) * SA-2 :Query Optimization (#1134) * Query Optimization * Removed Unnecessary print Statements * Used .exists() method * Sa-2: Week 8: Created Api's (#1172) * updated models * Revert "updated models" This reverts commit 83e2e73d895fc7f6a7ba2fa117624bbcb2ede278. * revert to old * some changes in frontend * some updates in frontend files * added the api for mobiles and updated urls and views of web * some updates in backend * Added frontend for new apis Created frontend for registered students and update menu features * updated admin and ui * resolved errors * Menu UI changes * Updated Menu_card * some fixes * migrations fixed * added mess registration request model * minor changes * added model and view for registeration * url fixed * fixed rebate * added new form for registration request * fixed gitignore resolved conflicts * context * Registration UI Changes * registration UI changes * restored migration file * completed registration * made some ui changes * migration fix * done things about payments * changed some views * Added Registration Remark and Dropdown * Changed id in reg * rectified error with rebate response frontend * fixed datetime in reg * worked on manage reg * deregistration request functionality added * rectified the backend issues for generate bills * added registration list * completed dereg * student bill functionality addded * rectified error of previous commit * added view reg records * added filter in view mess students * worked on bills caretaker side * changed development * Updated special food request * GAD -5 Dashboard Changes (#1325) * Updated Special food Functionality * dashboard and usercard updated (#1329) * minor ui fixes * added search * updated manage registration * added view bills and payments of students for mess caretaker * added notification functionality in right rail * Added Sem start and end date form (#26) * added start date to registration form * made some ui changes * added modal for details of a student * made some ui improvements * tested crontab * added excel upload for bill and reg * added add student to mess * fixes * update bill added and dates added (#32) * Some UI changes (#35) * merge fixes * added remove * some ui fixes * fixed cronjobs * semdate fixes * removed migrations * Fixing ui bugs (#1335) * added django crontab to requirements.txt * automation of bills no new msg resolved some merge conflicts * useless commit for pulling no msg * completed automation of mess bill generation and payment history feature for student * resolved a merge error * bug fixes * bug fixes * merging mess and staging * conflict resolve --------- Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> Co-authored-by: Samay Sagar <73112080+samay-rgb@users.noreply.github.com> Co-authored-by: theparasgami <20BCS151@iiitdmj.ac.in> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: PARAS GAMI <86421345+theparasgami@users.noreply.github.com> Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: Mayankingale123 <122631799+Mayankingale123@users.noreply.github.com> Co-authored-by: Mayankingale123 Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Update booking-request-action-modal.html Removed readonly tag from html only * GAD-4: Fix edit draft functionality and usertype Access (#1410) * GAD-5: Fix responsiveness (#1125) Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> * fix requirements and docker-compose * fix docker compose and dependencies * add sdk and api folder structure * add sdk methods and fix some urls * update models for API * add urls for api * add methods for viewing file, inbox, outbox, getting designation with serializers and minor bug fixes * fix serializers and fix file attachment functionality in forward_file * sync with upstream * add views and fix urls * create file * create file change * fix create_file, without upload_file feature * fix sdk forward_file : accept remarks * add view_history in sdk * add blueprint for draft and archive methods to sdk * fix FileHeaderSerializer to include id * fix empty file upload error * fix inbox outbox methods to return unique ids * fix complete_flag to is_read * fix inbox outbox methods to not show archived * add view_archived method to sdk * add archive_file method to sdk * fix inbox and outbox output and add support for attachments * add draft methods to sdk * fix default values of named params * fix css for filetracking.html * fix fts serializer.py * add dept adding method to sdk * add helper methods to sdk * fix inbox based on SDK * remove track from TabMenu * fix outbox using SDK * fix archive view for SDK * fix Drafts based on SDK * fix the view file functionality in the web app * fix frontend * fix .gitignore to untrack migrations * fix 1. order of files in inbox and outbox 2. order of files is mantained in uniqueList function * fix login required on viewing file * fix create_file method so that subject and description are also accepted * add rest api for create file and view file * add rest api for create, view and delete file * add rest api for inbox, outbox, history view * add rest api for draft view, forward file * prevent student access of the filetracking module * add dropdown filtering based on reciever username and update notallowed template * add option to unarchive files * fix template for filetrackingnotallowed page * fix attachments view in the history of the file * make the fields in draft view editable * update the views * GAD -5 Dashboard Changes (#1325) * dashboard and usercard updated (#1329) * Fixing ui bugs (#1335) * fix file sending and forwarding template to include designation automatically * fix forward file view to include designations automatically * add redirect to dropdown designation to views * add redirect on designation change * fix: forward file does not autodetect designation * fix merge conflicts again * add notification display and fix non department file * add decorator to handle staff or faculty * add options to admin.py for FTS * fix remark saved to draft --------- Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: Divyansh Tripathi <55395696+theoden42@users.noreply.github.com> Co-authored-by: aish0749 Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> * Upadted modules.html (#1432) * merged sa-3 into new branch gk (#1433) * Revert " merged sa-3 into new branch gk (#1433)" (#1434) This reverts commit b3fbfbc96d1e7f7847724f2ea56380745f0d4801. * fix gad-4 merge conflicts * fix merging errors from latest_staging * create space for notification panel in filetracking view * new functionality added --------- Co-authored-by: Yathartha Goenka Co-authored-by: ujjawallele13 <111732396+ujjawallele13@users.noreply.github.com> Co-authored-by: prakhar-da-gama <95561933+prakhar-da-gama@users.noreply.github.com> Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in> Co-authored-by: manavdesai27 Co-authored-by: Akshat Nema <76521428+akshatnema@users.noreply.github.com> Co-authored-by: Aksh Bansal <63552235+Aksh-Bansal-dev@users.noreply.github.com> Co-authored-by: Apc010101 <122636844+Apc010101@users.noreply.github.com> Co-authored-by: Akshay010203 <92329718+Akshay010203@users.noreply.github.com> Co-authored-by: Divyansh Tripathi <55395696+theoden42@users.noreply.github.com> Co-authored-by: Aragorn-64 Co-authored-by: aish0749 Co-authored-by: Hardik Sharma <104981324+hardiksharma11@users.noreply.github.com> Co-authored-by: Raman Chaudhary <97114586+ChaudharyRaman@users.noreply.github.com> Co-authored-by: Anudeep Sanapala <71971574+anudeeps0306@users.noreply.github.com> Co-authored-by: Abhikumar Gupta <97209802+abhi87374@users.noreply.github.com> Co-authored-by: Yathartha Goenka <75240973+yatharthagoenka@users.noreply.github.com> Co-authored-by: Harshvardhan Singh <73544247+Lawful2002@users.noreply.github.com> Co-authored-by: A Anunaya <76819712+Anunaya07@users.noreply.github.com> Co-authored-by: BlackHAWK2001 <150950834+BlackHAWK2001@users.noreply.github.com> Co-authored-by: Arpit Tak <140220904+Ishu-ji@users.noreply.github.com> Co-authored-by: prem-charan <118535829+prem-charan@users.noreply.github.com> Co-authored-by: SukulSarve <143542658+SukulSarve@users.noreply.github.com> Co-authored-by: Prajjwal kapoor <68912239+prajjwalkapoor@users.noreply.github.com> Co-authored-by: VedantJain1103 <105827483+VedantJain1103@users.noreply.github.com> Co-authored-by: harsh-k-singh <105146460+harsh-k-singh@users.noreply.github.com> Co-authored-by: davneesh Co-authored-by: Avneesh <97170838+davneesh@users.noreply.github.com> Co-authored-by: varunraj03 <113377182+varunraj03@users.noreply.github.com> Co-authored-by: Shivkant Chauhan <91013793+Shivkant-Chauhan@users.noreply.github.com> Co-authored-by: Advay Sagarkar <72992475+Aragorn-64@users.noreply.github.com> Co-authored-by: Samay Sagar <73112080+samay-rgb@users.noreply.github.com> Co-authored-by: theparasgami <20BCS151@iiitdmj.ac.in> Co-authored-by: PARAS GAMI <86421345+theparasgami@users.noreply.github.com> Co-authored-by: Mayankingale123 <122631799+Mayankingale123@users.noreply.github.com> Co-authored-by: Mayankingale123 Co-authored-by: Harshul Choudhary <113760758+Harshul-25@users.noreply.github.com> Co-authored-by: Harshit0009 Co-authored-by: Harshul Co-authored-by: hemantsinghhere <115834099+hemantsinghhere@users.noreply.github.com> Co-authored-by: Hritik Yadav Co-authored-by: Harshit0009 Co-authored-by: Harshit Tiwari <96289939+Harshit0009@users.noreply.github.com> Co-authored-by: hemantsinghhere Co-authored-by: Hritik Yadav <97102768+HritikYadav7@users.noreply.github.com> Co-authored-by: Harshul Co-authored-by: Prajjwal Kapoor Co-authored-by: Kushagra Yadav <137766817+Kushagra-Yadav@users.noreply.github.com> Co-authored-by: EyeOfHorus158 <75492668+EyeOfHorus158@users.noreply.github.com> Co-authored-by: gaur-abhi524 <82049206+gaur-abhi524@users.noreply.github.com> Co-authored-by: Sudheer dagar <60738162+sudheerdagar@users.noreply.github.com> Co-authored-by: Nitya Tiwari Co-authored-by: prabhatsuman Co-authored-by: Prabhat Suman <32027224+prabhatsuman@users.noreply.github.com> Co-authored-by: nidhibarapatre <116302859+nidhibarapatre@users.noreply.github.com> Co-authored-by: Divyanshu Sharma <21bcs079@iiitdmj.ac.in> Co-authored-by: Divyanshu Sharma <114430068+Divyanshusir@users.noreply.github.com> Co-authored-by: TilteD24 <21bcs080@iiitdmj.ac.in> Co-authored-by: Divyanshu Srivastava <97041656+TilteD24@users.noreply.github.com> Co-authored-by: Abhikumar Gupta Co-authored-by: Yogesh Saini <97088265+Ykumar1415@users.noreply.github.com> Co-authored-by: Smeetiiitdmj <121860497+Smeetiiitdmj@users.noreply.github.com> Co-authored-by: Smeet Chavan Co-authored-by: Kush Batla <97120358+kushbatla@users.noreply.github.com> Co-authored-by: TusharGupta03 <114795108+TusharGupta03@users.noreply.github.com> Co-authored-by: Priyansh Mehta <96513964+Priyansh61@users.noreply.github.com> --- .gitignore | 2 + FusionIIIT/Fusion/settings/common.py | 11 +- FusionIIIT/Fusion/settings/development.py | 12 +- .../academic_information/models.py | 4 +- FusionIIIT/applications/central_mess/admin.py | 73 +- .../central_mess/api/serializers.py | 91 + .../applications/central_mess/api/urls.py | 27 + .../applications/central_mess/api/views.py | 487 +++ FusionIIIT/applications/central_mess/forms.py | 34 +- .../applications/central_mess/handlers.py | 513 ++- .../applications/central_mess/models.py | 111 +- FusionIIIT/applications/central_mess/tasks.py | 151 + FusionIIIT/applications/central_mess/urls.py | 28 +- FusionIIIT/applications/central_mess/utils.py | 2 +- FusionIIIT/applications/central_mess/views.py | 1014 ++++-- .../applications/complaint_system/admin.py | 3 +- .../complaint_system/api/views.py | 6 +- .../applications/complaint_system/models.py | 21 +- .../static/complaint_system/js/rating.js | 182 + .../applications/complaint_system/urls.py | 22 +- .../applications/complaint_system/views.py | 1659 ++++++--- FusionIIIT/applications/eis/models.py | 26 +- FusionIIIT/applications/eis/views.py | 6 +- FusionIIIT/applications/feeds/views.py | 1 + FusionIIIT/applications/filetracking/admin.py | 24 +- .../filetracking/api/serializers.py | 24 + .../applications/filetracking/api/urls.py | 24 + .../applications/filetracking/api/views.py | 247 ++ .../applications/filetracking/decorators.py | 51 + .../applications/filetracking/models.py | 12 +- .../applications/filetracking/sdk/methods.py | 429 +++ FusionIIIT/applications/filetracking/tests.py | 6 +- FusionIIIT/applications/filetracking/urls.py | 78 +- FusionIIIT/applications/filetracking/views.py | 795 +++-- FusionIIIT/applications/globals/api/urls.py | 4 +- FusionIIIT/applications/globals/api/views.py | 46 +- FusionIIIT/applications/globals/views.py | 5 +- .../applications/health_center/admin.py | 10 +- .../health_center/api/serializers.py | 17 +- .../applications/health_center/api/views.py | 19 +- .../applications/health_center/models.py | 78 +- FusionIIIT/applications/health_center/urls.py | 9 +- .../applications/health_center/utils.py | 113 +- .../applications/health_center/views.py | 185 +- .../applications/placement_cell/forms.py | 86 +- .../applications/placement_cell/models.py | 3 +- .../applications/placement_cell/urls.py | 1 + .../applications/placement_cell/views.py | 3172 ++++++++++++++++- .../programme_curriculum/admin.py | 15 +- .../programme_curriculum/forms.py | 230 +- .../programme_curriculum/models.py | 149 +- .../applications/programme_curriculum/urls.py | 20 +- .../programme_curriculum/views.py | 554 ++- .../applications/scholarships/helpers.py | 14 + FusionIIIT/applications/scholarships/urls.py | 1 + FusionIIIT/applications/scholarships/views.py | 133 +- .../applications/visitor_hostel/forms.py | 48 +- .../applications/visitor_hostel/models.py | 19 +- .../static/visitor_hostel/visitor-hostel.js | 210 +- .../applications/visitor_hostel/urls.py | 7 +- .../applications/visitor_hostel/views.py | 447 +-- FusionIIIT/notification/views.py | 10 + .../complaintModule/add_workers.html | 34 +- .../complaintModule/assignworker.html | 160 +- .../complaintModule/carefeedback.html | 133 + .../complaintModule/complaint_caretaker.html | 59 +- .../complaint_caretaker_detail.html | 167 - .../complaint_secincharge.html | 161 + .../complaint_secincharge_detail.html | 0 .../complaint_supervisor_detail.html | 4 +- .../complaintModule/complaint_user.html | 6 +- .../complaint_user_detail.html | 7 +- .../complainthistory_care_final.html | 335 ++ ...html => complainthistory_secincharge.html} | 14 +- .../complainthistory_super_final.html | 369 ++ .../complainthistory_user.html | 608 +--- .../complainthistory_user_final.html | 379 +- .../templates/complaintModule/feedback.html | 18 +- .../lodgecomplaint_caretaker.html | 160 + .../complaintModule/lodgecomplaint_super.html | 160 + .../complaintModule/lodgecomplaint_user.html | 2 +- .../complaintModule/overdue_complaint1.html | 4 +- .../complaintModule/overdue_super.html | 32 +- .../complaintModule/overduecomplaint.html | 58 +- .../complaintModule/reassignworker.html | 82 +- .../complaintModule/resolve_caretaker.html | 162 + .../complaintModule/resolve_pending.html | 15 +- .../resolvecomplaint_caretaker.html | 128 + .../resolvecomplaint_secincharge.html | 134 + .../complaintModule/resolved_super.html | 6 +- .../complaintModule/supervisor1.html | 57 +- ...complaint.html => unresolvecomplaint.html} | 78 +- .../complaintModule/unresolved_super.html | 184 +- .../complaintModule/worker_id_know_more.html | 2 +- FusionIIIT/templates/dashboard/dashboard.html | 2 +- FusionIIIT/templates/dashboard/modules.html | 39 +- .../templates/dashboard/sidenavbar.html | 2 +- .../templates/filetracking/archive.html | 54 +- .../filetracking/archive_design.html | 2 +- .../filetracking/archive_finish.html | 57 +- .../templates/filetracking/composefile.html | 58 +- .../templates/filetracking/confirmdelete.html | 4 +- .../templates/filetracking/draft_design.html | 30 + FusionIIIT/templates/filetracking/drafts.html | 78 +- .../templates/filetracking/editdraft.html | 197 + .../filetracking/fileTrackingNotAllowed.html | 41 + .../templates/filetracking/filetracking.html | 13 +- .../templates/filetracking/fileview.html | 51 - .../templates/filetracking/fileview1.html | 49 - .../templates/filetracking/fileview2.html | 57 - .../templates/filetracking/forward.html | 70 +- FusionIIIT/templates/filetracking/inbox.html | 54 + .../filetracking/invalid_designation.html | 44 + FusionIIIT/templates/filetracking/inward.html | 2 +- .../filetracking/notif_sidepanel.html | 28 + FusionIIIT/templates/filetracking/outbox.html | 48 + .../templates/filetracking/outward.html | 2 +- .../templates/filetracking/viewfile.html | 144 + FusionIIIT/templates/globals/usercard.html | 4 + .../templates/messModule/add_remove.html | 243 ++ FusionIIIT/templates/messModule/alerts.html | 89 + .../templates/messModule/applications.html | 50 +- .../templates/messModule/billpdfexport.html | 20 +- .../templates/messModule/changemenu.html | 367 +- .../messModule/de-registraionsrequests.html | 277 ++ .../templates/messModule/de-registration.html | 113 + .../messModule/meeting_information.html | 6 +- .../templates/messModule/menu_card.html | 125 +- .../messModule/menudownloadable1.html | 106 +- .../messModule/menudownloadable2.html | 75 +- FusionIIIT/templates/messModule/mess.html | 125 +- .../templates/messModule/messInfoForm.html | 32 +- .../templates/messModule/messactivities.html | 473 +-- .../templates/messModule/nonvegfood.html | 20 +- .../templates/messModule/nonvegorder.html | 4 +- FusionIIIT/templates/messModule/reg_list.html | 354 ++ .../messModule/registered_student.html | 328 ++ .../templates/messModule/registration.html | 85 + .../templates/messModule/respondmenu.html | 12 +- .../messModule/respondtorequests.html | 798 +++-- FusionIIIT/templates/messModule/splreq.html | 4 +- .../templates/messModule/updateSemdates.html | 73 + .../templates/messModule/updatemenu.html | 519 +++ .../templates/messModule/view_feedback.html | 115 +- .../messModule/view_payments_bills.html | 319 ++ FusionIIIT/templates/messModule/viewmenu.html | 170 +- FusionIIIT/templates/messModule/views.html | 333 +- .../templates/phcModule/appointment.html | 485 +-- .../phcModule/comp_prescription.html | 20 +- FusionIIIT/templates/phcModule/doctors.html | 231 +- FusionIIIT/templates/phcModule/history.html | 18 +- .../phcModule/make_announce_comp.html | 163 + .../{comapproval.html => patientlog.html} | 36 +- FusionIIIT/templates/phcModule/phc.html | 6 +- .../templates/phcModule/phc_compounder.html | 33 +- .../templates/phcModule/phc_student.html | 37 +- FusionIIIT/templates/phcModule/publish.html | 134 + FusionIIIT/templates/phcModule/schedule.html | 412 ++- .../templates/phcModule/schedule_student.html | 294 +- .../templates/placementModule/activity.html | 12 +- .../placementModule/add_placement_visits.html | 4 +- .../placementModule/managerecords.html | 12 +- .../templates/placementModule/placement.html | 51 +- .../placementModule/placementstatistics.html | 169 +- .../placementModule/studentrecords.html | 16 +- .../acad_admin/add_curriculum_form.html | 7 + .../admin_view_all_working_curriculums.html | 2 +- ...{add_course_form.html => course_form.html} | 32 +- .../faculty/course_proposal_form.html | 64 +- .../faculty/dean_view_a_course_proposal.html | 76 +- .../dean_view_course_proposal_forms.html | 159 - .../dean_view_update_a_course_proposal.html | 251 -- .../faculty/faculty_view_a_course.html | 23 +- .../faculty/faculty_view_all_courses.html | 21 +- .../faculty/filetracking.html | 130 + .../programme_curriculum/faculty/forward.html | 354 ++ .../head_view_course_proposal_forms.html | 162 - .../head_view_update_a_course_proposal.html | 180 - .../faculty/inward_course_forms.html | 99 + .../faculty/outward_course_forms.html | 96 + .../faculty/update_course_proposal_form.html | 24 +- .../faculty/view_a_course.html | 22 +- ...posal.html => view_a_course_proposal.html} | 30 +- .../faculty/view_a_courseslot.html | 22 +- .../view_a_semester_of_a_curriculum.html | 22 +- .../faculty/view_all_batches.html | 22 +- .../faculty/view_all_courses.html | 22 +- .../faculty/view_all_disciplines.html | 22 +- .../faculty/view_all_programmes.html | 22 +- .../faculty/view_all_working_curriculums.html | 22 +- .../faculty/view_course_proposal_forms.html | 127 +- .../view_curriculums_of_a_programme.html | 22 +- .../faculty/view_file.html | 369 ++ .../view_semesters_of_a_curriculum.html | 22 +- .../scholarshipsModule/aboutspacs.html | 4 +- .../scholarshipsModule/applyNew.html | 16 +- .../templates/scholarshipsModule/invite.html | 35 +- FusionIIIT/templates/vhModule/accounts.html | 11 +- .../templates/vhModule/add-item-modal.html | 31 +- FusionIIIT/templates/vhModule/bookaroom.html | 2 +- .../templates/vhModule/booking-details.html | 4 +- .../booking-request-action-modal.html | 9 +- FusionIIIT/templates/vhModule/bookings.html | 12 +- .../templates/vhModule/check-out-modal.html | 8 +- .../templates/vhModule/generate_records.html | 2 +- .../templates/vhModule/record-meal.html | 45 +- .../templates/vhModule/request-booking.html | 47 +- .../templates/vhModule/room-availability.html | 228 +- .../vhModule/room-availability1.html | 3 - .../templates/vhModule/view-inventory.html | 49 +- .../templates/vhModule/visitorhostel.html | 10 +- docker-compose.yml | 4 +- requirements.txt | 74 + 213 files changed, 19619 insertions(+), 7398 deletions(-) create mode 100644 FusionIIIT/applications/central_mess/api/serializers.py create mode 100644 FusionIIIT/applications/central_mess/api/urls.py create mode 100644 FusionIIIT/applications/central_mess/api/views.py create mode 100644 FusionIIIT/applications/filetracking/api/serializers.py create mode 100644 FusionIIIT/applications/filetracking/api/urls.py create mode 100644 FusionIIIT/applications/filetracking/api/views.py create mode 100644 FusionIIIT/applications/filetracking/decorators.py create mode 100644 FusionIIIT/applications/filetracking/sdk/methods.py create mode 100644 FusionIIIT/applications/scholarships/helpers.py create mode 100644 FusionIIIT/templates/complaintModule/carefeedback.html delete mode 100644 FusionIIIT/templates/complaintModule/complaint_caretaker_detail.html create mode 100644 FusionIIIT/templates/complaintModule/complaint_secincharge.html create mode 100644 FusionIIIT/templates/complaintModule/complaint_secincharge_detail.html create mode 100644 FusionIIIT/templates/complaintModule/complainthistory_care_final.html rename FusionIIIT/templates/complaintModule/{complainthistory_caretaker.html => complainthistory_secincharge.html} (96%) create mode 100644 FusionIIIT/templates/complaintModule/complainthistory_super_final.html create mode 100644 FusionIIIT/templates/complaintModule/lodgecomplaint_caretaker.html create mode 100644 FusionIIIT/templates/complaintModule/lodgecomplaint_super.html create mode 100644 FusionIIIT/templates/complaintModule/resolve_caretaker.html create mode 100644 FusionIIIT/templates/complaintModule/resolvecomplaint_caretaker.html create mode 100644 FusionIIIT/templates/complaintModule/resolvecomplaint_secincharge.html rename FusionIIIT/templates/complaintModule/{resolvecomplaint.html => unresolvecomplaint.html} (79%) create mode 100644 FusionIIIT/templates/filetracking/draft_design.html create mode 100644 FusionIIIT/templates/filetracking/editdraft.html create mode 100644 FusionIIIT/templates/filetracking/fileTrackingNotAllowed.html delete mode 100644 FusionIIIT/templates/filetracking/fileview.html delete mode 100644 FusionIIIT/templates/filetracking/fileview1.html delete mode 100644 FusionIIIT/templates/filetracking/fileview2.html create mode 100644 FusionIIIT/templates/filetracking/inbox.html create mode 100644 FusionIIIT/templates/filetracking/invalid_designation.html create mode 100644 FusionIIIT/templates/filetracking/notif_sidepanel.html create mode 100644 FusionIIIT/templates/filetracking/outbox.html create mode 100644 FusionIIIT/templates/filetracking/viewfile.html create mode 100644 FusionIIIT/templates/messModule/add_remove.html create mode 100644 FusionIIIT/templates/messModule/alerts.html create mode 100644 FusionIIIT/templates/messModule/de-registraionsrequests.html create mode 100644 FusionIIIT/templates/messModule/de-registration.html create mode 100644 FusionIIIT/templates/messModule/reg_list.html create mode 100644 FusionIIIT/templates/messModule/registered_student.html create mode 100644 FusionIIIT/templates/messModule/registration.html create mode 100644 FusionIIIT/templates/messModule/updateSemdates.html create mode 100644 FusionIIIT/templates/messModule/updatemenu.html create mode 100644 FusionIIIT/templates/messModule/view_payments_bills.html create mode 100644 FusionIIIT/templates/phcModule/make_announce_comp.html rename FusionIIIT/templates/phcModule/{comapproval.html => patientlog.html} (95%) create mode 100644 FusionIIIT/templates/phcModule/publish.html rename FusionIIIT/templates/programme_curriculum/acad_admin/{add_course_form.html => course_form.html} (94%) delete mode 100644 FusionIIIT/templates/programme_curriculum/faculty/dean_view_course_proposal_forms.html delete mode 100644 FusionIIIT/templates/programme_curriculum/faculty/dean_view_update_a_course_proposal.html create mode 100644 FusionIIIT/templates/programme_curriculum/faculty/filetracking.html create mode 100644 FusionIIIT/templates/programme_curriculum/faculty/forward.html delete mode 100644 FusionIIIT/templates/programme_curriculum/faculty/head_view_course_proposal_forms.html delete mode 100644 FusionIIIT/templates/programme_curriculum/faculty/head_view_update_a_course_proposal.html create mode 100644 FusionIIIT/templates/programme_curriculum/faculty/inward_course_forms.html create mode 100644 FusionIIIT/templates/programme_curriculum/faculty/outward_course_forms.html rename FusionIIIT/templates/programme_curriculum/faculty/{head_view_a_course_proposal.html => view_a_course_proposal.html} (88%) create mode 100644 FusionIIIT/templates/programme_curriculum/faculty/view_file.html create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 497fd7a16..13184f251 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,5 @@ node_modules/ FusionIIIT/static/ package-lock.json + + diff --git a/FusionIIIT/Fusion/settings/common.py b/FusionIIIT/Fusion/settings/common.py index fabe81ec2..54494036e 100644 --- a/FusionIIIT/Fusion/settings/common.py +++ b/FusionIIIT/Fusion/settings/common.py @@ -104,7 +104,7 @@ 'django.contrib.staticfiles', 'django.contrib.sites', 'django.contrib.humanize', - + 'django_crontab', 'corsheaders', 'applications.eis', @@ -171,7 +171,7 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, '..', 'templates/'),], + 'DIRS': [os.path.join(BASE_DIR, '..', 'templates'),], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -256,9 +256,9 @@ # os.path.join(BASE_DIR, 'static/') STATIC_URL = '/static/' -STATIC_ROOT = os.path.join(BASE_DIR, '..', 'static/') +STATIC_ROOT = os.path.join(BASE_DIR, '..', 'static') STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' -MEDIA_ROOT = os.path.join(BASE_DIR, '..', 'media/') +MEDIA_ROOT = os.path.join(BASE_DIR, '..', 'media') MEDIA_URL = '/media/' ACCOUNT_USERNAME_REQUIRED = False @@ -279,5 +279,6 @@ YOUTUBE_DATA_API_KEY = 'api_key' + CORS_ORIGIN_ALLOW_ALL = True -ALLOW_PASS_RESET = True +ALLOW_PASS_RESET = True \ No newline at end of file diff --git a/FusionIIIT/Fusion/settings/development.py b/FusionIIIT/Fusion/settings/development.py index 6acc214c1..3f95a478c 100644 --- a/FusionIIIT/Fusion/settings/development.py +++ b/FusionIIIT/Fusion/settings/development.py @@ -1,7 +1,7 @@ from Fusion.settings.common import * DEBUG = True - +TEMPLATE_DEBUG = True SECRET_KEY = '=&w9due426k@l^ju1=s1)fj1rnpf0ok8xvjwx+62_nc-f12-8(' ALLOWED_HOSTS = ['*'] @@ -16,9 +16,11 @@ } } + REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.TokenAuthentication', + 'rest_framework.authentication.SessionAuthentication', ), 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAuthenticated', @@ -53,3 +55,11 @@ DEBUG_TOOLBAR_CONFIG = { 'INTERCEPT_REDIRECTS': False, } + +CRONJOBS = [ + # the below job will update the bill at every minute can be used for testing + # ('* * * * *', 'applications.central_mess.tasks.generate_bill'), + + #the below job which we need to add in production server, to update the mess bill of student everyday at 10 pm in night + ('0 22 * * *', 'applications.central_mess.tasks.generate_bill'), +] diff --git a/FusionIIIT/applications/academic_information/models.py b/FusionIIIT/applications/academic_information/models.py index ea1178878..d5103fbd7 100755 --- a/FusionIIIT/applications/academic_information/models.py +++ b/FusionIIIT/applications/academic_information/models.py @@ -93,8 +93,8 @@ class Student(models.Model): batch_id = models.ForeignKey(Batch, null=True, blank=True, on_delete=models.CASCADE) cpi = models.FloatField(default=0) category = models.CharField(max_length=10, choices=Constants.CATEGORY, null=False) - father_name = models.CharField(max_length=40, default='') - mother_name = models.CharField(max_length=40, default='') + father_name = models.CharField(max_length=40, default='',null=True) + mother_name = models.CharField(max_length=40, default='',null=True) hall_no = models.IntegerField(default=0) room_no = models.CharField(max_length=10, blank=True, null=True) specialization = models.CharField(max_length=40,choices=Constants.MTechSpecialization, null=True, default='') diff --git a/FusionIIIT/applications/central_mess/admin.py b/FusionIIIT/applications/central_mess/admin.py index cbb2fcb6c..cbeb94d1c 100755 --- a/FusionIIIT/applications/central_mess/admin.py +++ b/FusionIIIT/applications/central_mess/admin.py @@ -2,8 +2,8 @@ from .models import (Feedback, Menu, Menu_change_request, Mess_meeting, Mess_minutes, Mess_reg, Messinfo, Monthly_bill, - Nonveg_data, Nonveg_menu, Payments, Rebate, - Special_request, Vacation_food,MessBillBase) + Payments, Rebate, + Special_request, Vacation_food,MessBillBase, Registration_Request, Reg_records, Reg_main) # Register your models here. @@ -45,7 +45,7 @@ class Mess_regAdmin(admin.ModelAdmin): ('start_reg', {'fields': ['start_reg']}), ('end_reg', {'fields': ['end_reg']}), ] - list_display = ('start_reg', 'end_reg') + list_display = ('sem','start_reg', 'end_reg') @@ -56,14 +56,14 @@ class Monthly_billAdmin(admin.ModelAdmin): ('month', {'fields': ['month']}), ('year', {'fields': ['year']}), ('amount', {'fields': ['amount']}), - ('nonveg_total_bill', {'fields': ['nonveg_total_bill']}), + # ('nonveg_total_bill', {'fields': ['nonveg_total_bill']}), ('rebate_count', {'fields': ['rebate_count']}), ('rebate_amount', {'fields': ['rebate_amount']}), ('total_bill', {'fields': ['total_bill']}), ] list_display = ('student_id', 'month', 'year', 'amount', - 'nonveg_total_bill', 'rebate_count', 'rebate_amount', 'total_bill') + 'rebate_count', 'rebate_amount', 'total_bill') @@ -71,11 +71,9 @@ class PaymentsAdmin(admin.ModelAdmin): model = Payments fieldsets = [ ('student_id', {'fields': ['student_id']}), - ('sem', {'fields': ['sem']}), - ('year', {'fields': ['year']}), ('amount_paid', {'fields': ['amount_paid']}), ] - list_display = ('student_id', 'sem', 'year', 'amount_paid') + list_display = ('student_id', 'amount_paid') class RebateAdmin(admin.ModelAdmin): @@ -106,26 +104,26 @@ class Vacation_foodAdmin(admin.ModelAdmin): -class Nonveg_menuAdmin(admin.ModelAdmin): - model = Nonveg_menu - fieldsets = [ - ('dish', {'fields': ['dish']}), - ('price', {'fields': ['price']}), - ('order_interval', {'fields': ['order_interval']}), - ] - list_display = ('dish', 'price', 'order_interval') +# class Nonveg_menuAdmin(admin.ModelAdmin): +# model = Nonveg_menu +# fieldsets = [ +# ('dish', {'fields': ['dish']}), +# ('price', {'fields': ['price']}), +# ('order_interval', {'fields': ['order_interval']}), +# ] +# list_display = ('dish', 'price', 'order_interval') -class Nonveg_dataAdmin(admin.ModelAdmin): - model = Nonveg_data - fieldsets = [ - ('student_id', {'fields': ['student_id']}), - ('order_date', {'fields': ['order_date']}), - ('dish', {'fields': ['dish']}), - ('order_interval', {'fields': ['order_interval']}), - ] - list_display = ('student_id', 'order_date', 'dish', 'order_interval') +# class Nonveg_dataAdmin(admin.ModelAdmin): +# model = Nonveg_data +# fieldsets = [ +# ('student_id', {'fields': ['student_id']}), +# ('order_date', {'fields': ['order_date']}), +# ('dish', {'fields': ['dish']}), +# ('order_interval', {'fields': ['order_interval']}), +# ] +# list_display = ('student_id', 'order_date', 'dish', 'order_interval') @@ -172,9 +170,10 @@ class FeedbackAdmin(admin.ModelAdmin): ('student_id', {'fields': ['student_id']}), ('fdate', {'fields': ['fdate']}), ('description', {'fields': ['description']}), - ('feedback_type', {'fields': ['feedback_type']}) + ('feedback_type', {'fields': ['feedback_type']}), + ('feedback_remark', {'fields':['feedback_remark']}) ] - list_display = ('student_id', 'fdate', 'description', 'feedback_type') + list_display = ('student_id', 'fdate', 'description', 'feedback_type', 'feedback_remark') class MessBillBaseAdmin(admin.ModelAdmin): @@ -184,6 +183,19 @@ class MessBillBaseAdmin(admin.ModelAdmin): ] list_display = ('bill_amount', 'timestamp') +class Reg_mainAdmin(admin.ModelAdmin): + model = Reg_main + list_display = ('student_id','program','current_mess_status','balance','mess_option') + +class Reg_recordsAdmin(admin.ModelAdmin): + model=Reg_records + list_display = ('student_id','start_date','end_date') + + +class Registration_RequestAdmin(admin.ModelAdmin): + model=Registration_Request + list_display = ('student_id','Txn_no','img','amount','status','registration_remark') + admin.site.register(Mess_minutes, Mess_minutesAdmin), admin.site.register(Messinfo, MessinfoAdmin), @@ -194,9 +206,12 @@ class MessBillBaseAdmin(admin.ModelAdmin): admin.site.register(Rebate, RebateAdmin), admin.site.register(Vacation_food, Vacation_foodAdmin), admin.site.register(Special_request, Special_requestAdmin), -admin.site.register(Nonveg_menu, Nonveg_menuAdmin), -admin.site.register(Nonveg_data, Nonveg_dataAdmin), +# admin.site.register(Nonveg_menu, Nonveg_menuAdmin), +# admin.site.register(Nonveg_data, Nonveg_dataAdmin), admin.site.register(Mess_meeting, Mess_meetingAdmin), admin.site.register(Feedback, FeedbackAdmin), admin.site.register(MessBillBase,MessBillBaseAdmin), admin.site.register(Menu_change_request, Menu_change_requestAdmin) +admin.site.register(Reg_main,Reg_mainAdmin) +admin.site.register(Reg_records,Reg_recordsAdmin) +admin.site.register(Registration_Request,Registration_RequestAdmin) diff --git a/FusionIIIT/applications/central_mess/api/serializers.py b/FusionIIIT/applications/central_mess/api/serializers.py new file mode 100644 index 000000000..b30ad2686 --- /dev/null +++ b/FusionIIIT/applications/central_mess/api/serializers.py @@ -0,0 +1,91 @@ +from rest_framework import serializers +from applications.central_mess.models import * + +class MessinfoSerializer(serializers.ModelSerializer): + + class Meta: + model=Messinfo + fields=('__all__') + +class Mess_regSerializer(serializers.ModelSerializer): + class Meta: + model = Mess_reg + fields=('__all__') + +class MessBillBaseSerializer(serializers.ModelSerializer): + class Meta: + model = MessBillBase + fields=('__all__') + +class Monthly_billSerializer(serializers.ModelSerializer): + class Meta: + model=Monthly_bill + fields=('__all__') + +class PaymentsSerializer(serializers.ModelSerializer): + class Meta: + model=Payments + fields=('__all__') + +class MenuSerializer(serializers.ModelSerializer): + class Meta: + model=Menu + fields=('__all__') + +class RebateSerializer(serializers.ModelSerializer): + + class Meta: + model=Rebate + fields=('__all__') + +class Vacation_foodSerializer(serializers.ModelSerializer): + class Meta: + model = Vacation_food + fields=('__all__') + +# class Nonveg_menuSerializer(serializers.ModelSerializer): +# class Meta: +# model = Nonveg_menu +# fields=('__all__') + +# class Nonveg_dataSerializer(serializers.ModelSerializer): +# class Meta: +# model=Nonveg_data +# fields=('__all__') + +class Special_requestSerializer(serializers.ModelSerializer): + class Meta: + model=Special_request + fields=('__all__') + +class Mess_meetingSerializer(serializers.ModelSerializer): + class Meta: + model=Mess_meeting + fields=('__all__') + +class Mess_minutesSerializer(serializers.ModelSerializer): + class Meta: + model = Mess_minutes + fields=('__all__') + +class Menu_change_requestSerializer(serializers.ModelSerializer): + class Meta: + model = Menu_change_request + fields=('__all__') + +class FeedbackSerializer(serializers.ModelSerializer): + class Meta: + model=Feedback + fields=('__all__') + +class GetFilteredSerialzer(serializers.ModelSerializer): + first_name = serializers.CharField(source='student_id.id.user.first_name') + last_name = serializers.CharField(source='student_id.id.user.last_name') + class Meta: + model=Reg_main + fields=('__all__') + +class reg_recordSerialzer(serializers.ModelSerializer): + class Meta: + model = Reg_records + fields=('__all__') \ No newline at end of file diff --git a/FusionIIIT/applications/central_mess/api/urls.py b/FusionIIIT/applications/central_mess/api/urls.py new file mode 100644 index 000000000..2bd15c746 --- /dev/null +++ b/FusionIIIT/applications/central_mess/api/urls.py @@ -0,0 +1,27 @@ +from django.conf.urls import url +from . import views +from .views import * + +urlpatterns = [ + url("feedbackApi", views.FeedbackApi.as_view(), name="feedbackApi"), + url("menuChangeRequestApi", views.Menu_change_requestApi.as_view(), name="menuChangeRequestApi"), + url("messMinutesApi", views.Mess_minutesApi.as_view(), name="messMinutesApi"), + # url("nonvegDataApi", views.Nonveg_dataApi.as_view(), name="nonvegDataApi"), + url("specialRequestApi", views.Special_requestApi.as_view(), name="specialRequestApi"), + url("messMeetingApi", views.Mess_meetingApi.as_view(), name="messMeetingApi"), + # url("nonvegMenuApi", views.Nonveg_menuApi.as_view(), name="nonvegMenuApi"), + url("vacationFoodApi", views.Vacation_foodApi.as_view(), name="vacationFoodApi"), + url("messInfoApi", views.MessinfoApi.as_view(), name="messInfoApi"), + url("rebateApi", views.RebateApi.as_view(), name="rebateApi"), + url("menuApi", views.MenuApi.as_view(), name="menuApi"), + url("paymentsApi", views.PaymentsApi.as_view(), name="paymentsApi"), + url("monthlyBillApi", views.Monthly_billApi.as_view(), name="monthlyBillApi"), + url("messBillBaseApi", views.MessBillBaseApi.as_view(), name="messBillBaseApi"), + url("messRegApi", views.Mess_regApi.as_view(), name="messRegApi"), + url("get_mess_students", views.Get_Filtered_Students.as_view(), name="get_mess_students"), + url("get_reg_records",views.Get_Reg_Records.as_view(),name="reg_record_API"), + # url("billDashboard", views.Bill_dashboard.as_view(), name="billDashboard"), + url("get_student_bill",views.Get_Student_bill.as_view(),name="student_bill_API"), + url("get_student_payment",views.Get_Student_Payments.as_view(),name="student_payment_API"), + url("get_student_all_details",views.Get_Student_Details.as_view(),name="get_student_details_API") +] \ No newline at end of file diff --git a/FusionIIIT/applications/central_mess/api/views.py b/FusionIIIT/applications/central_mess/api/views.py new file mode 100644 index 000000000..6d1b7d4ae --- /dev/null +++ b/FusionIIIT/applications/central_mess/api/views.py @@ -0,0 +1,487 @@ + #APIs +from rest_framework.views import APIView +from rest_framework.response import Response +from .serializers import * +from django.shortcuts import get_object_or_404 +from applications.central_mess.models import * +from django.contrib.auth.models import User +from applications.globals.models import ExtraInfo, HoldsDesignation, Designation +from django.http import JsonResponse + +class FeedbackApi(APIView): + + def get(self, request): + feedback_obj = Feedback.objects.all(); + serialized_obj = FeedbackSerializer(feedback_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + def post(self, request): + data = request.data + + mess = data['mess'] + _type = data['type'] + desc = data['desc'] + username = get_object_or_404(User,username=request.user.username) + idd = ExtraInfo.objects.get(user=username) + student = Student.objects.get(id=idd.id) + obj = Feedback( + student_id = student, + mess =mess, + feedback_type=_type, + description=desc + ) + obj.save() + return Response({'status':200}) + + +class MessinfoApi(APIView): + def get(self, request): + messinfo_obj = Messinfo.objects.all(); + serialized_obj = MessinfoSerializer(messinfo_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + def post(self, request): + data = request.data + + mess_option = data['mess_option'] + + username = get_object_or_404(User,username=request.user.username) + idd = ExtraInfo.objects.get(user=username) + student = Student.objects.get(id=idd.id) + obj = Messinfo( + student_id = student, + mess_option =mess_option, + ) + obj.save() + return Response({'status':200}) + +class Mess_regApi(APIView): + def get(self, request): + mess_reg_obj = Mess_reg.objects.all(); + serialized_obj = Mess_regSerializer(mess_reg_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + def post(self, request): + data = request.data + + sem = data['sem'] + start_reg = data['start_reg'] + end_reg= data['end_reg'] + + obj = Mess_reg( + sem = sem, + start_reg = start_reg, + end_reg = end_reg + ) + obj.save() + return Response({'status':200}) + +class MessBillBaseApi(APIView): + def get(self, request): + messBillBase_obj = MessBillBase.objects.all(); + serialized_obj = MessBillBaseSerializer(messBillBase_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + def post(self, request): + data = request.data + + bill_amount = data['bill_amount'] + # timestamp = data['timestamp'] + + obj = MessBillBase( + bill_amount = bill_amount, + # timestamp = timestamp, + ) + obj.save() + return Response({'status':200}) + +class Monthly_billApi(APIView): + def get(self, request): + monthly_bill_obj = Monthly_bill.objects.all(); + serialized_obj = Monthly_billSerializer(monthly_bill_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + def post(self, request): + data = request.data + + month = data['month'] + year = data['year'] + amount = data['amount'] + rebate_count = data['rebate_count'] + rebate_amount = data['rebate_amount'] + #nonveg_total_bill = data['nonveg_total_bill'] + paid = data['paid'] + + username = get_object_or_404(User,username=request.user.username) + idd = ExtraInfo.objects.get(user=username) + student = Student.objects.get(id=idd.id) + + + obj = Monthly_bill( + student_id = student, + month = month, + year = year, + amount = amount, + rebate_count = rebate_count, + rebate_amount = rebate_amount, + # nonveg_total_bill = nonveg_total_bill, + paid = paid + ) + obj.save() + return Response({'status':200}) + +class PaymentsApi(APIView): + def get(self, request): + payments_obj = Payments.objects.all(); + serialized_obj = PaymentsSerializer(payments_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + def post(self, request): + data = request.data + + # sem = data['sem'] + # year = data['year'] + amount_paid = data['amount_paid'] + + + username = get_object_or_404(User,username=request.user.username) + idd = ExtraInfo.objects.get(user=username) + student = Student.objects.get(id=idd.id) + + + obj = Payments( + student_id = student, + # sem = sem, + # year = year, + amount_paid = amount_paid, + ) + obj.save() + return Response({'status':200}) +class MenuApi(APIView): + def get(self, request): + menu_obj = Menu.objects.all(); + serialized_obj = MenuSerializer(menu_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + def post(self, request): + data = request.data + + mess_option = data['mess_option'] + meal_time = data['meal_time'] + dish = data['dish'] + + + obj = Menu( + mess_option = mess_option, + meal_time = meal_time, + dish = dish, + ) + obj.save() + return Response({'status':200}) +class RebateApi(APIView): + def get(self, request): + rebate_obj = Rebate.objects.all(); + serialized_obj = RebateSerializer(rebate_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + def post(self, request): + data = request.data + + # student_id = data['mess_option'] + start_date = data['start_date'] + end_date = data['end_date'] + purpose = data['purpose'] + status = data['status'] + app_date = data['app_date'] + leave_type = data['leave_type'] + + username = get_object_or_404(User,username=request.user.username) + idd = ExtraInfo.objects.get(user=username) + student = Student.objects.get(id=idd.id) + + + obj = Rebate( + student_id = student, + leave_type = leave_type, + app_date = app_date, + status = status, + purpose = purpose, + end_date= end_date, + start_date = start_date + ) + obj.save() + return Response({'status':200}) +class Vacation_foodApi(APIView): + def get(self, request): + vacation_food_obj = Vacation_food.objects.all(); + serialized_obj = Vacation_foodSerializer(vacation_food_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + def post(self, request): + data = request.data + + start_date = data['start_date'] + end_date = data['end_date'] + purpose = data['purpose'] + status = data['status'] + app_date = data['app_date'] + + + username = get_object_or_404(User,username=request.user.username) + idd = ExtraInfo.objects.get(user=username) + student = Student.objects.get(id=idd.id) + + + obj = Vacation_food( + student_id = student, + app_date = app_date, + status = status, + purpose = purpose, + end_date= end_date, + start_date = start_date + ) + obj.save() + return Response({'status':200}) + +class Nonveg_menuApi(APIView): + def get(self, request): + nonveg_menu_obj = Nonveg_menu.objects.all(); + serialized_obj = Nonveg_menuSerializer(nonveg_menu_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + def post(self, request): + data = request.data + + dish= data['dish'] + price = data['price'] + order_interval = data['order_interval'] + + + obj = Nonveg_menu( + dish = dish, + price = price, + order_interval = order_interval, + ) + obj.save() + return Response({'status':200}) + +class Nonveg_dataApi(APIView): + def get(self, request): + nonveg_data_obj = Nonveg_data.objects.all(); + serialized_obj = Nonveg_dataSerializer(nonveg_data_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + def post(self, request): + data = request.data + + dish= data['dish'] + order_date = data['order_date'] + app_date = data['app_date'] + order_interval = data['order_interval'] + + username = get_object_or_404(User,username=request.user.username) + idd = ExtraInfo.objects.get(user=username) + student = Student.objects.get(id=idd.id) + + dish_obj = Nonveg_menu.objects.get(dish=dish) + + obj = Nonveg_data( + student_id = student, + order_date = order_date, + app_date = app_date, + dish = dish_obj, + order_interval = order_interval, + ) + obj.save() + return Response({'status':200}) + +class Special_requestApi(APIView): + def get(self, request): + special_request_obj = Special_request.objects.all(); + serialized_obj = Special_requestSerializer(special_request_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + + def post(self, request): + data = request.data + + + start_date = data['start_date'] + end_date = data['end_date'] + status = data['status'] + app_date = data['app_date'] + request_= data['request'] + item1 = data['item1'] + item2 = data['item2'] + + + + username = get_object_or_404(User,username=request.user.username) + idd = ExtraInfo.objects.get(user=username) + student = Student.objects.get(id=idd.id) + + obj = Special_request( + student_id = student, + app_date = app_date, + status = status, + item1 = item1, + item2 = item2, + end_date= end_date, + start_date = start_date, + request = request_ + ) + obj.save() + return Response({'status':200}) + +class Mess_meetingApi(APIView): + def get(self, request): + mess_meeting_obj = Mess_meeting.objects.all(); + serialized_obj = Mess_meetingSerializer(mess_meeting_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + def post(self, request): + data = request.data + meet_date = data['meet_date'] + agenda = data['agenda'] + venue = data['venue'] + meeting_time = data['meeting_time'] + + obj = Mess_meeting( + meet_date = meet_date, + meeting_time = meeting_time, + agenda = agenda, + venue = venue, + ) + obj.save() + return Response({'status':200}) + +class Mess_minutesApi(APIView): + def get(self, request): + mess_minutes_obj = Mess_minutes.objects.all(); + serialized_obj = Mess_minutesSerializer(mess_minutes_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + def post(self, request): + data = request.data + + # meeting_date = data['meeting_date'] + mess_minutes = data['mess_minutes'] + meeting_date_obj = Mess_meeting.objects.get(meet_date=meeting_date) + + obj = Mess_minutes( + # meeting_date = meeting_date_obj, + mess_minutes = mess_minutes, + ) + obj.save() + return Response({'status':200}) + +class Menu_change_requestApi(APIView): + def get(self, request): + menu_change_request_obj = Menu_change_request.objects.all(); + serialized_obj = Menu_change_requestSerializer(menu_change_request_obj, many=True) + return Response({'status':200, 'payload':serialized_obj.data}) + + def post(self, request): + data = request.data + dish = data['dish'] + reason = data['reason'] + status = data['status'] + app_date = data['app_date'] + request_ = data['request'] + + + dish_obj = Menu.objects.get(dish=dish) + username = get_object_or_404(User,username=request.user.username) + idd = ExtraInfo.objects.get(user=username) + student = Student.objects.get(id=idd.id) + + obj = Menu_change_request( + student_id = student, + app_date = app_date, + status = status, + reason = reason, + request = request_, + dish = dish_obj + ) + obj.save() + return Response({'status':200}) + +class Get_Filtered_Students(APIView): + + def post(self,request): + type = request.data['type'] + if(type=='filter'): + reg_main = Reg_main.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').all() + status=request.data['status'] + program=request.data['program'] + mess_option=request.data['mess_option'] + + if(status!='all'): + + reg_main=reg_main.filter(current_mess_status=status) + + if(program!='all'): + reg_main=reg_main.filter(program=program) + + if(mess_option!='all'): + + reg_main=reg_main.filter(mess_option=mess_option) + + serialized_obj = GetFilteredSerialzer(reg_main,many=True) + return Response({'payload':serialized_obj.data}) + + elif(type=='search'): + student = request.data['student_id'] + student = str(student).upper() + try: + reg_main = Reg_main.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').get(student_id=student) + serialized_obj = GetFilteredSerialzer(reg_main) + return Response({'payload':serialized_obj.data}) + except: + response = JsonResponse({"error": "student does not exist"}) + response.status_code = 404 + return response + +class Get_Reg_Records(APIView): + + def post(self,request): + student = request.data['student_id'] + reg_record = Reg_records.objects.filter(student_id=student) + + serialized_obj = reg_recordSerialzer(reg_record,many=True) + return Response({'payload':serialized_obj.data}) + + +class Get_Student_bill(APIView): + + def post(self,request): + student = request.data['student_id'] + bill_details = Monthly_bill.objects.filter(student_id=student) + + serialized_obj = Monthly_billSerializer(bill_details,many=True) + return Response({'payload':serialized_obj.data}) + + +class Get_Student_Payments(APIView): + + def post(self,request): + student = request.data['student_id'] + payment_details = Payments.objects.filter(student_id=student) + + serialized_obj = PaymentsSerializer(payment_details,many=True) + return Response({'payload':serialized_obj.data}) + +class Get_Student_Details(APIView): + + def post(self,request): + student = request.data['student_id'] + bill_details = Monthly_bill.objects.filter(student_id=student) + payment_details = Payments.objects.filter(student_id=student) + reg_record = Reg_records.objects.filter(student_id=student) + payment_serialized_obj = PaymentsSerializer(payment_details,many=True) + bill_serialized_obj = Monthly_billSerializer(bill_details,many=True) + reg_record_serialized_obj = reg_recordSerialzer(reg_record,many=True) + reg_main = Reg_main.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').get(student_id=student) + serialized_obj = GetFilteredSerialzer(reg_main) + data={'payment':payment_serialized_obj.data,'bill':bill_serialized_obj.data,'reg_records':reg_record_serialized_obj.data,'student_details':serialized_obj.data} + return Response({'payload':data}) \ No newline at end of file diff --git a/FusionIIIT/applications/central_mess/forms.py b/FusionIIIT/applications/central_mess/forms.py index ac52d5d3a..ceecf4400 100644 --- a/FusionIIIT/applications/central_mess/forms.py +++ b/FusionIIIT/applications/central_mess/forms.py @@ -1,6 +1,8 @@ from django import forms from .models import Mess_minutes +from .models import Registration_Request +from .models import Semdates class MinuteForm(forms.ModelForm): @@ -13,4 +15,34 @@ class MessInfoForm(forms.Form, ): ('mess1', 'Veg Mess'), ('mess2', 'Non Veg Mess'), ] - mess_option = forms.CharField(label='Mess Option', widget=forms.Select(choices=MESS_CHOICES)) \ No newline at end of file + mess_option = forms.CharField(label='Mess Option', widget=forms.Select( + choices=MESS_CHOICES, attrs={'style': 'border-radius:1rem;padding:7px;'})) + + + +class RegistrationRequest(forms.ModelForm): + + class Meta: + model = Registration_Request + fields = ('Txn_no','amount','img','start_date','payment_date') + + widgets={ + 'Txn_no':forms.TextInput(attrs={'class':'ui big input','style':'border-radius:4px', 'initial':'590'}), + 'amount':forms.TextInput(attrs={'class':'ui big input'}), + 'img':forms.FileInput(attrs={'class':'ui big input'}), + 'start_date':forms.widgets.DateInput(attrs={'type':'date'}), + 'payment_date':forms.widgets.DateInput(attrs={'type':'date'}), + } + + +class UpdateBalanceRequest(forms.ModelForm): + + class Meta: + model = Registration_Request + fields = ('Txn_no','amount','img') + + widgets={ + 'Txn_no':forms.TextInput(attrs={'class':'ui big input','style':'border-radius:4px'}), + 'amount':forms.TextInput(attrs={'class':'ui big input'}), + 'img':forms.FileInput(attrs={'class':'ui big input'}), + } \ No newline at end of file diff --git a/FusionIIIT/applications/central_mess/handlers.py b/FusionIIIT/applications/central_mess/handlers.py index e469e1286..47e840810 100644 --- a/FusionIIIT/applications/central_mess/handlers.py +++ b/FusionIIIT/applications/central_mess/handlers.py @@ -16,8 +16,7 @@ from applications.globals.models import ExtraInfo, HoldsDesignation, Designation from .models import (Feedback, Menu, Menu_change_request, Mess_meeting, Mess_minutes, Mess_reg, Messinfo, Monthly_bill, - Nonveg_data, Nonveg_menu, Payments, Rebate, - Special_request, Vacation_food, MessBillBase) + Payments, Rebate,Special_request, Vacation_food, MessBillBase,Registration_Request, Reg_main, Reg_records ,Deregistration_Request, Semdates) from notification.views import central_mess_notif @@ -25,40 +24,49 @@ year_g = today_g.year tomorrow_g = today_g + timedelta(days=1) first_day_of_this_month = date.today().replace(day=1) +this_month = first_day_of_this_month.strftime('%B') +this_year = first_day_of_this_month.year last_day_prev_month = first_day_of_this_month - timedelta(days=1) previous_month = last_day_prev_month.strftime('%B') previous_month_year = last_day_prev_month.year first_day_of_next_month = (date.today().replace(day=28) + timedelta(days=4)).replace(day=1) last_day_of_this_month = first_day_of_next_month - timedelta(days=1) next_month = first_day_of_next_month.month - - -def add_nonveg_order(request, student): - """ - This function is to place non veg orders - :param request: - user: Current user - order_interval: Time of the day for which order is placed eg breakfast/lunch/dinner - :param student: student placing the order - :variables: - extra_info: Extra information about the current user. From model ExtraInfo - student: Student information about the current user - student_mess: Mess choices of the student - dish_request: Predefined dish available - nonveg_object: Object of Nonveg_data - :return: - """ - try: - dish_request = Nonveg_menu.objects.get(dish=request.POST.get("dish")) - order_interval = request.POST.get("interval") - order_date = tomorrow_g - nonveg_object = Nonveg_data(student_id=student, order_date=order_date, - order_interval=order_interval, dish=dish_request) - nonveg_object.save() - # messages.success(request, 'Your request is forwarded !!', extra_tags='successmsg') - - except ObjectDoesNotExist: - return HttpResponse("Seems like object does not exist") +first_day_prev_month = last_day_prev_month.replace(day=1) + +def current_month(): + return date.today().strftime("%B") + + +def current_year(): + return date.today().strftime("%Y") + +# def add_nonveg_order(request, student): +# """ +# This function is to place non veg orders +# :param request: +# user: Current user +# order_interval: Time of the day for which order is placed eg breakfast/lunch/dinner +# :param student: student placing the order +# :variables: +# extra_info: Extra information about the current user. From model ExtraInfo +# student: Student information about the current user +# student_mess: Mess choices of the student +# dish_request: Predefined dish available +# nonveg_object: Object of Nonveg_data +# :return: +# """ +# try: +# dish_request = Nonveg_menu.objects.get(dish=request.POST.get("dish")) +# order_interval = request.POST.get("interval") +# order_date = tomorrow_g +# nonveg_object = Nonveg_data(student_id=student, order_date=order_date, +# order_interval=order_interval, dish=dish_request) +# nonveg_object.save() +# # messages.success(request, 'Your request is forwarded !!', extra_tags='successmsg') + +# except ObjectDoesNotExist: +# return HttpResponse("Seems like object does not exist") def add_mess_feedback(request, student): @@ -76,7 +84,7 @@ def add_mess_feedback(request, student): data: to record success or any errors """ date_today = datetime.now().date() - mess_optn = Messinfo.objects.get(student_id=student) + mess_optn = Reg_main.objects.get(student_id=student) description = request.POST.get('description') feedback_type = request.POST.get('feedback_type') feedback_object = Feedback(student_id=student, fdate=date_today, @@ -117,7 +125,7 @@ def add_vacation_food_request(request, student): } return data - vacation_check = Vacation_food.objects.filter(student_id =student) + vacation_check = Vacation_food.objects.filter(student_id=student).prefetch_related('student_id','student_id__id','student_id__id__user','student_id__id__department') date_format = "%Y-%m-%d" b = datetime.strptime(str(start_date), date_format) @@ -155,11 +163,10 @@ def add_menu_change_request(request, student): :return: """ try: - print("inside add_menu") - dish = Menu.objects.get(dish=request.POST.get("dish")) - print(dish, "-------------------------------------------------------------------") + + dishID =request.POST['dish']; + dish=Menu.objects.get(id=dishID) new_dish = request.POST.get("newdish") - print(new_dish) reason = request.POST.get("reason") # menu_object = Menu_change_request(dish=dish, request=new_dish, reason=reason) menu_object = Menu_change_request(dish=dish, student_id=student, request=new_dish, reason=reason) @@ -172,7 +179,6 @@ def add_menu_change_request(request, student): data = { 'status': 0 } - print(e) return data @@ -192,16 +198,15 @@ def handle_menu_change_response(request): ap_id = request.POST.get('idm') user = request.user stat = request.POST['status'] - application = Menu_change_request.objects.get(pk=ap_id) + application = Menu_change_request.objects.get(id=ap_id) # student = application.student_id # receiver = User.objects.get(username=student) if stat == '2': application.status = 2 - meal = application.dish - obj = Menu.objects.get(dish=meal.dish) + obj = Menu.objects.get(Q(meal_time=application.dish.meal_time) & Q(mess_option=application.dish.mess_option)) obj.dish = application.request obj.save() - data = { + data = { 'status': '2', } # central_mess_notif(user, receiver, 'menu_change_accepted') @@ -334,9 +339,9 @@ def add_leave_request(request, student): } return data - rebates = Rebate.objects.filter(student_id=student) - rebate_check = rebates.filter(Q(status='1') | Q(status='2')) - + rebate_check = Rebate.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(student_id=student, status__in=['1', '2']) + + for r in rebate_check: a = datetime.strptime(str(r.start_date), date_format) c = datetime.strptime(str(r.end_date), date_format) @@ -373,8 +378,8 @@ def add_mess_meeting_invitation(request): venue = request.POST['venue'] agenda = request.POST['agenda'] time = request.POST['time'] - members_mess = HoldsDesignation.objects.filter(Q(designation__name__contains='mess_convener') - | Q(designation__name__contains='mess_committee')|Q(designation__name='mess_manager') + members_mess = HoldsDesignation.objects.select_related().filter(Q(designation__name__contains='mess_convener') + | Q(designation__name__contains='mess_committee')|Q(designation__name='mess_manager') | Q(designation__name='mess_warden')) date_today = str(today_g.date()) if date <= date_today: @@ -398,7 +403,49 @@ def add_mess_meeting_invitation(request): } return data - +def rebateCountFn(start_date, end_date, student_id): + ''' + This function is used to store the rebate_count in generte bill table and in what month that rebate has been issued. + ''' + start_date_month = start_date.strftime('%B') + start_date_year = start_date.year + end_date_month = end_date.strftime('%B') + date_format = "%Y-%m-%d" + begin_day = datetime.strptime(str(start_date), date_format) + end_day = datetime.strptime(str(end_date), date_format) + rebate_count_days = 0 + rebate_count_days_next_month = 0 + if start_date_month != end_date_month: + last_day_day = int(last_day_of_this_month.day) + begin_day_day = int(begin_day.day) + end_day_day = int(end_day.day) + first_day_day = int(first_day_of_next_month.day) + rebate_count_days = abs(last_day_day-begin_day_day) + 1 + rebate_count_days_next_month = abs(end_day_day-first_day_day)+1 + else: + rebate_count_days = abs((end_day - begin_day).days) + 1 + + #### Storing the rebate count days into the monthly bill table so it can be used while bill generation. + + try: + existing_student = Monthly_bill.objects.get(student_id=student_id, month=start_date_month, year=start_date_year) + new_rebate_count = existing_student.rebate_count + rebate_count_days + existing_student.rebate_count = new_rebate_count + existing_student.save() + if(rebate_count_days_next_month != 0): + new_student = Monthly_bill.objects.create(student_id=student_id, month=end_date_month, year=start_date_year, rebate_count=rebate_count_days_next_month) + new_student.save() + except: + new_student = Monthly_bill.objects.create(student_id=student_id, month=start_date_month, year=start_date_year, rebate_count=rebate_count_days) + new_student.save() + if(rebate_count_days_next_month != 0): + new_student = Monthly_bill.objects.create(student_id=student_id, month=end_date_month, year=start_date_year, rebate_count=rebate_count_days_next_month) + new_student.save() + + + + + def handle_rebate_response(request): """ This function is to respond to rebate requests @@ -419,9 +466,12 @@ def handle_rebate_response(request): rebate_count = abs((d - b).days) + 1 receiver = leaves.student_id.id.user action = request.POST["status"] + remark = request.POST["remark"] + leaves.rebate_remark = remark leaves.status = action leaves.save() if action == '2': + rebateCountFn(leaves.start_date, leaves.end_date, leaves.student_id) message = 'Your leave request has been accepted between dates ' + str(b.date()) + ' and ' + str(d.date()) else: message = 'Your leave request has been rejected between dates ' + str(b.date()) + ' and ' + str(d.date()) @@ -470,8 +520,8 @@ def add_special_food_request(request, student): return data spfood_obj = Special_request(student_id=student, start_date=fr, end_date=to, item1=food1, item2=food2, request=purpose) - requests_food = Special_request.objects.filter(student_id=student) - s_check = requests_food.filter(Q(status='1') | Q(status='2')) + s_check = Special_request.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(student_id=student,status__in=['1', '2']).order_by('-app_date') + for r in s_check: a = datetime.strptime(str(r.start_date), date_format) @@ -536,95 +586,302 @@ def add_bill_base_amount(request): return data +def add_sem_dates(request): + """ + This function is to update the semester start and end date + :param request: + :return: + """ + start_date = request.POST.get("semstart_date") + end_date = request.POST.get("semend_date") + + if (end_date <= start_date): + data = { + 'status': 3, + 'message': "Please check the dates" + } + return data + + data = { + 'status': 1, + 'message': "Successfully updated" + } + semdate_object = Semdates(start_date=start_date, end_date=end_date) + semdate_object.save() + return data def add_mess_committee(request, roll_number): - print("\n\n\\n\n\n\n\n") - print(roll_number) - mess = Messinfo.objects.get(student_id__id=roll_number) - print(mess) - if mess.mess_option == 'mess1': - designation = Designation.objects.get(name='mess_committee_mess1') - else: - designation = Designation.objects.get(name='mess_committee_mess2') - # designation = Designation.objects.get(name='mess_committee') - # add_obj = HoldsDesignation.objects.filter(Q(user__username=roll_number) & Q(designation=designation)) - check_obj = HoldsDesignation.objects.filter(Q(user__username=roll_number) & + studentHere = Student.objects.get(id=roll_number) + try: + mess = Messinfo.objects.get(student_id_id=studentHere) + if mess.mess_option == 'mess1': + designation = Designation.objects.get(name='mess_committee') + else: + designation = Designation.objects.get(name='mess_committee_mess2') + check_obj=HoldsDesignation.objects.select_related().filter(Q(user__username=studentHere) & (Q(designation__name__contains='mess_committee') | Q(designation__name__contains='mess_convener'))) - if check_obj: - data = { - 'status': 2, - 'message': roll_number + " is already a part of mess committee" - } + if check_obj: + data = { + 'status': 2, + 'message': roll_number + " is already a part of mess committee" + } + return data + else: + add_user = User.objects.get(username=roll_number) + designation_object = HoldsDesignation(user=add_user, working=add_user, designation=designation) + designation_object.save() + central_mess_notif(request.user, add_user, 'added_committee', '') + data = { + 'status': 1, + 'message': roll_number + " is added to Mess Committee" + } return data - else: - add_user = User.objects.get(username=roll_number) - designation_object = HoldsDesignation(user=add_user, working=add_user, designation=designation) - designation_object.save() - central_mess_notif(request.user, add_user, 'added_committee', '') + except: data = { - 'status': 1, - 'message': roll_number + " is added to Mess Committee" + 'status': 0, + 'message': roll_number + " is not registered for any Mess." } - return data +def Calculate_rebate(id, month_previous, amount_per_day): + students = Rebate.objects.filter(student_id_id=id) + print(students) + no_of_days = 0 + for student in students: + start_date_month = student.start_date.month + end_date_month = student.end_date.month + if(start_date_month == month_previous): + if(end_date_month == month_previous): + no_of_days = no_of_days + abs((student.end_date - student.start_date).days) + 1 + elif(end_date_month == today_g.month): + no_of_days = no_of_days + abs((last_day_prev_month - student.start_date).days) + 1 + else: + if(end_date_month == month_previous): + no_of_days = no_of_days + abs((student.end_date - student.start_date).days) + 1 + elif(end_date_month == today_g.month): + no_of_days = no_of_days + abs((last_day_prev_month - first_day_prev_month).days) + 1 + print(no_of_days) + rebate_amount = no_of_days*amount_per_day + return rebate_amount + + def generate_bill(): - student_all = Student.objects.all() - month_t = datetime.now().month - 1 - month_g = last_day_prev_month.month - first_day_prev_month = last_day_prev_month.replace(day=1) - # previous_month = month_t.strftime("%B") - amount_c = MessBillBase.objects.latest('timestamp') + + per_day_cost_obj = MessBillBase.objects.latest('timestamp') + per_day_cost = per_day_cost_obj.bill_amount + print(per_day_cost) + amount = int(last_day_prev_month.day) * int(per_day_cost) + print(amount) + student_all = Reg_main.objects.filter(current_mess_status = "Registered") + print(student_all) for student in student_all: - nonveg_total_bill=0 - rebate_count = 0 - total = 0 - nonveg_data = Nonveg_data.objects.filter(student_id=student) - rebates = Rebate.objects.filter(student_id=student) - for order in nonveg_data: - if order.order_date.strftime("%B") == previous_month: - nonveg_total_bill = nonveg_total_bill + order.dish.price - for r in rebates: - if r.status == '2': - if r.start_date.month == month_g: - if r.end_date.month == today_g: - rebate_count = rebate_count + abs((last_day_prev_month - r.start_date).days) + 1 - else: - rebate_count = rebate_count + abs((r.end_date - r.start_date).days) + 1 - elif r.end_date.month == month_g: - rebate_count = rebate_count + abs((r.end_date - first_day_prev_month).days) + 1 - else: - rebate_count = 0 - rebate_amount = rebate_count*amount_c.bill_amount/30 - total = amount_c.bill_amount + nonveg_total_bill - rebate_amount - bill_object = Monthly_bill(student_id=student, - month=previous_month, - year = previous_month_year, - amount=amount_c.bill_amount, - rebate_count=rebate_count, - rebate_amount=rebate_amount, - nonveg_total_bill=nonveg_total_bill, - total_bill=total) - if Monthly_bill.objects.filter(student_id=student, - month=previous_month, - year = previous_month_year, - total_bill=total): - print("exists") - elif Monthly_bill.objects.filter(student_id=student, - month=previous_month, - year = previous_month_year): - Monthly_bill.objects.filter(student_id=student, - month=previous_month, - year=previous_month_year).update(student_id=student, - month=previous_month, - amount=amount_c.bill_amount, - rebate_count=rebate_count, - rebate_amount=rebate_amount, - nonveg_total_bill=nonveg_total_bill, - total_bill=total) - # bill_object.update() - else: - bill_object.save() + student_id = student.student_id + rem_balance = student.balance + try: + monthly_bill_obj = Monthly_bill.objects.get(student_id=student_id, month=previous_month, year=previous_month_year) + rebate_count_count = monthly_bill_obj.rebate_count + rebate_amount = int(rebate_count_count)*int(per_day_cost) + monthly_bill_obj.rebate_amount = rebate_amount + total_bill = amount - rebate_amount + monthly_bill_obj.total_bill = total_bill + rem_balance = rem_balance - total_bill + student.balance = rem_balance + monthly_bill_obj.amount = amount + monthly_bill_obj.save() + except: + new_monthly_bill_obj = Monthly_bill(student_id=student_id, month=previous_month, year=previous_month_year, amount=amount, total_bill=amount) + rem_balance = rem_balance - amount + student.balance = rem_balance + new_monthly_bill_obj.save() + if(student.balance <= 0): + student.current_mess_status = 'Deregistered' + student.save() + + + + +def handle_reg_response(request): + """ + This function is to respond to registeration requests + @variables: + id: id of the registeration request + reg_req: Object corresponding to the id of the reg request + @return: + data: returns the status of the application + """ + + id = request.POST['id_reg'] + status = request.POST['status'] + remark = request.POST['remark'] + reg_req = Registration_Request.objects.get(pk=id) + start_date = reg_req.start_date + payment_date = reg_req.payment_date + student = reg_req.student_id + reg_req.status = status + reg_req.registration_remark=remark + try: + sem_end_date = Semdates.objects.latest('start_date').end_date + except: + sem_end_date= None + reg_req.save() + message='' + if(status=='accept'): + amount = reg_req.amount + mess = request.POST['mess_no'] + try : + reg_main = Reg_main.objects.get(student_id=student) + if(start_date == date.today()): + reg_main.current_mess_status="Registered" + else: + reg_main.current_mess_status = "Deregistered" + reg_main.mess_option=mess + reg_main.balance=reg_main.balance+amount + reg_main.save() + except: + program = student.programme + if(start_date == date.today()): + mess_status = "Registered" + else: + mess_status = "Deregistered" + new_reg = Reg_main(student_id=student,program=program,current_mess_status=mess_status,balance=amount,mess_option=mess) + new_reg.save() + new_reg_record = Reg_records(student_id=student, start_date=start_date, end_date=sem_end_date) + new_reg_record.save() + + new_payment_record = Payments(student_id = student, amount_paid = amount, payment_date=payment_date, payment_month=current_month(), payment_year=current_year()) + new_payment_record.save() + message="Your registeration request has been accepted" + else: + message="Your registeration request has been rejected" + + + receiver = reg_req.student_id.id.user + central_mess_notif(request.user, receiver, 'leave_request', message) + data = { + 'message': 'success' + } + return data + + +def handle_dreg_response(request): + """ + This function is to respond to de registeration requests + @variables: + id: id of the registeration request + dreg_req: Object corresponding to the id of the de reg request + @return: + data: returns the status of the application + """ + + id = request.POST['id_reg'] + status = request.POST['status'] + remark = request.POST['remark'] + dreg_req = Deregistration_Request.objects.get(pk=id) + end_date = dreg_req.end_date + student = dreg_req.student_id + dreg_req.status = status + dreg_req.deregistration_remark=remark + dreg_req.save() + message='' + if(status=='accept'): + try : + reg_main = Reg_main.objects.get(student_id=student) + if(end_date == date.today()): + reg_main.current_mess_status="Deregistered" + reg_record_obj = Reg_records.objects.filter(student_id = student).latest('start_date') + reg_record_obj.end_date = end_date + reg_record_obj.save() + reg_main.save() + except: + data = {'message': 'Student does not exist in database'} + return data + + message="Your De-registeration request has been accepted" + else: + message="Your De-registeration request has been rejected" + + receiver = dreg_req.student_id.id.user + central_mess_notif(request.user, receiver, 'leave_request', message) + data = { + 'message': 'success' + } + return data + +def update_month_bill(request): + """ + This function is used to update the monthly bill of student by caretaker if any discrepancy arises. + """ + student = str(request.POST.get("rollNo")).upper() + studentHere = Student.objects.get(id = student) + rebate_count = int(request.POST.get("RebateCount")) + print(rebate_count) + rebate_amount = int(request.POST.get("RebateAmount")) + print(rebate_amount) + new_amount = int(request.POST.get("new_amount")) + month = request.POST.get("Month") + year = int(request.POST.get("Year")) + bill_base_amount = int(MessBillBase.objects.latest('timestamp').bill_amount) + fixed_amount_per_month = int(bill_base_amount)*int(30) + + reg_main_obj = Reg_main.objects.get(student_id=student) + curr_balance = reg_main_obj.balance + try: + existing_monthly_bill_object = Monthly_bill.objects.get(student_id = studentHere, month=month, year=year) + previous_total_bill = existing_monthly_bill_object.total_bill + curr_balance = curr_balance + previous_total_bill + existing_monthly_bill_object.total_bill = new_amount + curr_balance = curr_balance - int(new_amount) + reg_main_obj.balance = curr_balance + reg_main_obj.save() + existing_monthly_bill_object.save() + except: + new_monthly_bill_obj = Monthly_bill(student_id = studentHere, rebate_amount=rebate_amount, rebate_count=rebate_count, month=month, year= year, total_bill = new_amount, amount=fixed_amount_per_month) + curr_balance = curr_balance - new_amount + reg_main_obj.balance = curr_balance + reg_main_obj.save() + new_monthly_bill_obj.save() + data = { + 'message': 'success' + } + return data + +def handle_add_reg(request): + start_date = request.POST['start_date'] + amount = int(request.POST['amount']) + studentID = str(request.POST['input_roll']).upper() + student = Student.objects.select_related('id','id__user','id__department').get(id=studentID) + payment_date = request.POST['payment_date'] + try: + latest=Semdates.objects.latest('start_date') + latest_end_date = latest.end_date + except: + latest_end_date= None + + mess=request.POST['mess_option_form'] + try : + reg_main = Reg_main.objects.get(student_id=studentID) + if(start_date==str(date.today())): + reg_main.current_mess_status='Registered' + reg_main.mess_option=mess + reg_main.balance=reg_main.balance+amount + reg_main.save() + except: + program = student.programme + if(start_date==str(date.today())): + mess_status = "Registered" + else: + mess_status = "Deregistered" + new_reg = Reg_main(student_id=student,program=program,current_mess_status=mess_status,balance=amount,mess_option=mess) + new_reg.save() + + new_reg_record = Reg_records(student_id=student, start_date=start_date,end_date = latest_end_date) + new_reg_record.save() + + new_payment_record = Payments(student_id = student, amount_paid = amount, payment_date=payment_date, payment_month=current_month(), payment_year=current_year()) + new_payment_record.save() + message="Your registeration request has been accepted" + + diff --git a/FusionIIIT/applications/central_mess/models.py b/FusionIIIT/applications/central_mess/models.py index cdd4de8a3..cd5427736 100644 --- a/FusionIIIT/applications/central_mess/models.py +++ b/FusionIIIT/applications/central_mess/models.py @@ -8,6 +8,18 @@ ('vacation', 'Vacation') ) +SPECIAL_FOOD = ( + ('dal_chawal', 'Dal Chawal'), + ('khicdi', 'Khicdi'), + ('tomato_soup','Tomato Soup') +) + +MEAL_TIME = ( + ('breakfast', 'Breakfast'), + ('lunch', 'Lunch'), + ('dinner','Dinner') +) + MEAL = ( ('MB', 'Monday Breakfast'), ('ML', 'Monday Lunch'), @@ -83,8 +95,8 @@ ) MESS_OPTION = ( - ('mess1', 'Veg_mess'), - ('mess2', 'Non_veg_mess') + ('mess1', 'Mess1'), + ('mess2', 'Mess2') ) @@ -126,8 +138,9 @@ class Monthly_bill(models.Model): amount = models.IntegerField(default=0) rebate_count = models.IntegerField(default=0) rebate_amount = models.IntegerField(default=0) - nonveg_total_bill = models.IntegerField(default=0) + # nonveg_total_bill = models.IntegerField(default=0) total_bill = models.IntegerField(default=0) + paid = models.BooleanField(default=False) class Meta: unique_together = (('student_id', 'month', 'year'),) @@ -138,15 +151,16 @@ def __str__(self): class Payments(models.Model): student_id = models.ForeignKey(Student, on_delete=models.CASCADE) - sem = models.IntegerField() - year = models.IntegerField(default=current_year) amount_paid = models.IntegerField(default=0) + payment_month = models.CharField(max_length=20, default=current_month) + payment_year = models.IntegerField(default = current_year) + payment_date = models.DateField(default= datetime.date.today()) class Meta: - unique_together = (('student_id', 'sem', 'year'),) + unique_together = (('student_id', 'payment_date')) def __str__(self): - return '{} - {}'.format(self.student_id.id, self.sem) + return '{}'.format(self.student_id.id) class Menu(models.Model): @@ -167,9 +181,10 @@ class Rebate(models.Model): purpose = models.TextField() status = models.CharField(max_length=20, choices=STATUS, default='1') app_date = models.DateField(default=datetime.date.today) + # TODO = remove leave type leave_type = models.CharField(choices=LEAVE_TYPE, max_length=20, default="casual") # leave_document = models.FileField(upload_to='central_mess/') - + rebate_remark = models.CharField(max_length=50,default='NA') def __str__(self): return str(self.student_id.id) @@ -186,26 +201,26 @@ def __str__(self): return str(self.student_id.id) -class Nonveg_menu(models.Model): - dish = models.CharField(max_length=20) - price = models.IntegerField() - order_interval = models.CharField(max_length=20, choices=INTERVAL, - default='Breakfast') +# class Nonveg_menu(models.Model): +# dish = models.CharField(max_length=20) +# price = models.IntegerField() +# order_interval = models.CharField(max_length=20, choices=INTERVAL, +# default='Breakfast') - def __str__(self): - return '{} - {}'.format(self.dish, self.price) +# def __str__(self): +# return '{} - {}'.format(self.dish, self.price) -class Nonveg_data(models.Model): - student_id = models.ForeignKey(Student, on_delete=models.CASCADE) - order_date = models.DateField(default=datetime.date.today) - order_interval = models.CharField(max_length=20, choices=INTERVAL, - default='Breakfast') - dish = models.ForeignKey(Nonveg_menu, on_delete=models.CASCADE) - app_date = models.DateField(default=datetime.date.today) +# class Nonveg_data(models.Model): +# student_id = models.ForeignKey(Student, on_delete=models.CASCADE) +# order_date = models.DateField(default=datetime.date.today) +# order_interval = models.CharField(max_length=20, choices=INTERVAL, +# default='Breakfast') +# dish = models.ForeignKey(Nonveg_menu, on_delete=models.CASCADE) +# app_date = models.DateField(default=datetime.date.today) - def __str__(self): - return str(self.student_id.id) +# def __str__(self): +# return str(self.student_id.id) class Special_request(models.Model): @@ -214,9 +229,10 @@ class Special_request(models.Model): end_date = models.DateField(default=datetime.date.today) request = models.TextField() status = models.CharField(max_length=20, choices=STATUS, default='1') - item1 = models.CharField(max_length=50) - item2 = models.CharField(max_length=50) + item1 = models.CharField(choices = SPECIAL_FOOD, max_length=50, default ='dal_chawal') + item2 = models.CharField(choices = MEAL_TIME, max_length=50, default ='breakfast') app_date = models.DateField(default=datetime.date.today) + # special_food = models.CharField(choices = SPECIAL_FOOD, max_length = 50) def __str__(self): return str(self.student_id.id) @@ -259,6 +275,49 @@ class Feedback(models.Model): fdate = models.DateField(default=datetime.date.today) description = models.TextField() feedback_type = models.CharField(max_length=20, choices=FEEDBACK_TYPE) + feedback_remark = models.CharField(max_length=50, default ="NA") + def __str__(self): + return str(self.student_id.id) + +class Registration_Request(models.Model): + student_id = models.ForeignKey(Student, on_delete=models.CASCADE) + Txn_no =models.CharField(max_length=20) + img = models.ImageField(upload_to='images/',default=None) + amount=models.IntegerField(default=0) + status=models.CharField(max_length=10,default='pending') + registration_remark=models.CharField(max_length=50,default='NA') + start_date=models.DateField(default=None, null=True) + # end_date=models.DateField(default=None, null=True) + payment_date= models.DateField(default=None, null=True) + def __str__(self): + return str(self.student_id.id) + +class Reg_main(models.Model): + student_id = models.ForeignKey(Student, on_delete=models.CASCADE) + program = models.CharField(max_length=10) + current_mess_status = models.CharField(max_length=20,default='Deregistered') + balance = models.IntegerField(default=0) + mess_option = models.CharField(max_length=20,default='mess2') def __str__(self): return str(self.student_id.id) +class Reg_records(models.Model): + student_id = models.ForeignKey(Student, on_delete=models.CASCADE) + start_date = models.DateField(default=datetime.date.today) + end_date = models.DateField(default=None, null=True) + def __str__(self): + return str(self.student_id.id) + +class Deregistration_Request(models.Model): + student_id = models.ForeignKey(Student, on_delete=models.CASCADE) + status=models.CharField(max_length=10,default='pending') + deregistration_remark=models.CharField(max_length=50,default='NA') + end_date = models.DateField(default=None, null=True) + def __str__(self): + return str(self.student_id.id) + +class Semdates(models.Model): + start_date = models.DateField(blank=False,default=datetime.date.today) + end_date = models.DateField(blank=False,default=datetime.date.today) + class Meta: + unique_together = (('start_date', 'end_date'),) diff --git a/FusionIIIT/applications/central_mess/tasks.py b/FusionIIIT/applications/central_mess/tasks.py index 36ce85d45..e27254b36 100644 --- a/FusionIIIT/applications/central_mess/tasks.py +++ b/FusionIIIT/applications/central_mess/tasks.py @@ -18,3 +18,154 @@ # @periodic_task(run_every=(crontab(minute='*/1')), name="some_task", ignore_result=True) # def some_task(): # print("5") + +from datetime import date, datetime, timedelta +from django.db import transaction +from threading import Thread +from .models import * +from notification.views import central_mess_notif + +today_g = date.today() +year_g = today_g.year +tomorrow_g = today_g + timedelta(days=1) +first_day_of_this_month = date.today().replace(day=1) +this_month = first_day_of_this_month.strftime('%B') +this_year = first_day_of_this_month.year +last_day_prev_month = first_day_of_this_month - timedelta(days=1) +previous_month = last_day_prev_month.strftime('%B') +previous_month_year = last_day_prev_month.year +first_day_of_next_month = (date.today().replace(day=28) + timedelta(days=4)).replace(day=1) +last_day_of_this_month = first_day_of_next_month - timedelta(days=1) +next_month = first_day_of_next_month.month +first_day_prev_month = last_day_prev_month.replace(day=1) + + +def generate_bill(): + print(today_g) + print(this_month) + print(previous_month) + + t1 = Thread(target=generate_per_day_bill(), args=()) + t1.setDaemon(True) + t1.start() + + + + +def check_registration(student): + try: + reg_date = Reg_records.objects.filter(student_id = student).latest('start_date') + if(reg_date.start_date == today_g): + try: + reg_object = Reg_main.objects.get(student_id = student) + reg_object.current_mess_status = "Registered" + except: + pass + except: + pass + + + + +def check_deregistration(student): + try: + reg_end_date = Reg_records.objects.filter(student_id = student).latest('start_date') + if(reg_end_date.end_date == today_g): + try: + reg_object = Reg_main.objects.get(student_id = student) + reg_object.current_mess_status = "Deregistered" + reg_object.save() + except: + pass + except: + pass + + + +def check_next_month_status(per_day_cost, current_balance, amount): + rem_days = abs(int(last_day_of_this_month.day) -25) + amount_for_remain_days = int(rem_days)*int(per_day_cost) + if(current_balance - amount_for_remain_days < amount): + # TODO send notification to student for paying the fees + central_mess_notif() + + +def check_daily(student, per_day_cost): + two_day_amount = int(2)*int(per_day_cost) + reg_main_obj = Reg_main.objects.get(student_id=student) + balance = reg_main_obj.balance + if(balance <= two_day_amount): + #TODO add the notification for the student + central_mess_notif() + + reg_end_date_obj = Reg_records.objects.filter(student_id = student).latest('start_date') + reg_end_date = tomorrow_g + timedelta(days=1) + reg_end_date_obj.end_date = reg_end_date + reg_end_date_obj.save() + + +def generate_per_day_bill(): + per_day_cost_obj = MessBillBase.objects.latest('timestamp') + per_day_cost = per_day_cost_obj.bill_amount + amount = int(30) * int(per_day_cost) + # print(per_day_cost) + deregistered_students = Reg_main.objects.filter(current_mess_status = "Deregistered") + for student in deregistered_students: + student_id = student.student_id + check_registration(student_id) + + registered_students = Reg_main.objects.filter(current_mess_status = "Registered") + for student in registered_students: + student_id = student.student_id + check_deregistration(student_id) + + registered_students = Reg_main.objects.filter(current_mess_status = "Registered") + for student in registered_students: + student_id = student.student_id + current_balance = student.balance + check_daily(student_id, per_day_cost) + if(int(today_g.day) == 25): + check_next_month_status(per_day_cost, current_balance, amount) + try: + rebate_obj = Rebate.objects.get(student_id = student_id, start_date__lte = today_g, end_date__gte= today_g, status = 2) # TODO check for the correct value of accepting status + try: + monthly_bill_object = Monthly_bill.objects.get(student_id=student_id, month= this_month, year=this_year) + monthly_bill_object.rebate_count = monthly_bill_object.rebate_count + 1 + monthly_bill_object.rebate_amount = monthly_bill_object.rebate_amount + per_day_cost + monthly_bill_object.save() + except: + new_monthly_bill_object = Monthly_bill(student_id=student_id, month = this_month, year=this_year, amount= amount, total_bill = 0, rebate_count = 1, rebate_amount= per_day_cost) + new_monthly_bill_object.save() + except: + try: + monthly_bill_object = Monthly_bill.objects.get(student_id=student_id, month= this_month, year=this_year) + print(monthly_bill_object.total_bill) + monthly_bill_object.total_bill = monthly_bill_object.total_bill + per_day_cost + print(monthly_bill_object.total_bill) + + current_balance = current_balance - per_day_cost + student.balance = current_balance + monthly_bill_object.save() + except: + new_monthly_bill_object = Monthly_bill(student_id=student_id, month = this_month, year=this_year, amount= amount, total_bill = per_day_cost, rebate_count = 0, rebate_amount= 0) + current_balance = current_balance - per_day_cost + student.balance = current_balance + new_monthly_bill_object.save() + if(today_g == last_day_of_this_month and current_balance < amount): + student.current_mess_status = "Deregistered" + try: + reg_record_end_date = Reg_records.objects.filter(student_id = student_id).order_by('start_date')[0] + reg_record_end_date.end_date = first_day_of_next_month + print(reg_record_end_date) + reg_record_end_date.save() + except: + pass + student.save() + + + + + +# def my_scheduled_task(): + # Your task code goes here + # Monthly_bill.objects.all().delete() \ No newline at end of file diff --git a/FusionIIIT/applications/central_mess/urls.py b/FusionIIIT/applications/central_mess/urls.py index f98b83047..031626819 100644 --- a/FusionIIIT/applications/central_mess/urls.py +++ b/FusionIIIT/applications/central_mess/urls.py @@ -1,4 +1,6 @@ -from django.conf.urls import url +from django.conf.urls import url , include +from django.conf import settings +from django.conf.urls.static import static from . import views @@ -8,15 +10,16 @@ url(r'^$', views.mess, name='mess'), url(r'^menurequest/', views.menu_change_request, name='menu_change_request'), - url(r'^placeorder/', views.place_order, name='placeorder'), + # url(r'^placeorder/', views.place_order, name='placeorder'), url(r'^addleavet/', views.add_leave_manager, name='addleavet'), url(r'^submitmessfeedback/', views.submit_mess_feedback, name='submitmessfeedback'), url(r'^messvacationsubmit/', views.mess_vacation_submit, name='messvacationsubmit'), url(r'^messmenusubmit/', views.submit_mess_menu, name='messmenusubmit'), url(r'^regsubmit/', views.regsubmit, name='regsubmit'), url(r'^startmessregistration/', views.start_mess_registration, name='startmessregistration'), + url(r'^closemessregistration/', views.closeRegistration, name='closemessregistration'), url(r'^menudownload/', views.MenuPDF.as_view(), name='MenuPDF'), - url(r'^menudownload1/', views.MenuPDF.as_view(), name='MenuPDF1'), + url(r'^menudownload1/', views.MenuPDF1.as_view(), name='MenuPDF1'), # url(r'^(?P[0-9]+)/response/', views.response, name='response'), url(r'^response', views.menu_change_response, name='response'), url(r'^(?P[0-9]+)/responsevacationfood/', views.response_vacation_food, name='responsevacationfood'), @@ -29,12 +32,25 @@ url(r'^rebateresponse', views.rebate_response, name='rebateresponse'), url(r'^specialrequestresponse', views.special_request_response, name='specialrequestresponse'), url(r'^updatecost', views.update_cost, name='updatecost'), - url(r'^getnonvegorder', views.get_nonveg_order, name='getnonvegorder'), + # url(r'^getnonvegorder', views.get_nonveg_order, name='getnonvegorder'), url(r'^getleave', views.get_leave_data, name='getleave'), url(r'^generatemessbill', views.generate_mess_bill, name='generatemessbill'), url(r'^acceptleave', views.accept_vacation_leaves, name='acceptleave'), url(r'^selectmessconvener', views.select_mess_convener, name='selectmessconvener'), - url(r'^billdownload', views.download_bill_mess, name='billdownload'), + url(r'^billdownload', views.BillPDFStudent.as_view(), name='BillPDFStudent'), url("info-form", views.mess_info, name="info"), + url(r'^updatemenuu', views.update_menu1, name='update_menu1'), + url(r'^updatemenu', views.update_menu2, name='update_menu2'), -] + url(r'^api', include('applications.central_mess.api.urls')), + + url(r'^registeredstudent', views.searchAddOrRemoveStudent, name='registeredstudent'), + url(r'^registrationRequest', views.reg_request, name='reg_request'), + # url(r'^uploadpayment', views.uploadPaymentDue, name='uploadpayment') + url(r'^respond_to_reg_req',views.respond_to_reg, name='reg_response'), + url(r'^deregistrationRequest', views.de_reg_request, name='deregistrationRequest'), + url(r'^updatesemdates', views.update_semdates, name='updatesemdates'), + url(r'^updateBill', views.update_bill, name='updateBill'), + url(r'^updatemonthlybill',views.update_bill_excel,name="update_bill"), + +]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file diff --git a/FusionIIIT/applications/central_mess/utils.py b/FusionIIIT/applications/central_mess/utils.py index 17ea7826e..480ef91a3 100644 --- a/FusionIIIT/applications/central_mess/utils.py +++ b/FusionIIIT/applications/central_mess/utils.py @@ -10,7 +10,7 @@ def render_to_pdf(template_src, context_dict={}): html = template.render(context_dict) result = BytesIO() print(result.read) - pdf = pisa.pisaDocument(BytesIO(html.encode("ISO-8859-1")), result) + pdf = pisa.pisaDocument(BytesIO(html.encode("utf-8")), result) if not pdf.err: return HttpResponse(result.getvalue(), content_type='application/pdf') return None diff --git a/FusionIIIT/applications/central_mess/views.py b/FusionIIIT/applications/central_mess/views.py index bb1498d55..4bc7238bd 100644 --- a/FusionIIIT/applications/central_mess/views.py +++ b/FusionIIIT/applications/central_mess/views.py @@ -14,25 +14,30 @@ from .utils import render_to_pdf from applications.academic_information.models import Student from applications.globals.models import ExtraInfo, HoldsDesignation, Designation -from .forms import MinuteForm, MessInfoForm +from .forms import MinuteForm, MessInfoForm,RegistrationRequest +from .tasks import * from .models import (Feedback, Menu, Menu_change_request, Mess_meeting, Mess_minutes, Mess_reg, Messinfo, Monthly_bill, - Nonveg_data, Nonveg_menu, Payments, Rebate, - Special_request, Vacation_food, MessBillBase) -from .handlers import (add_nonveg_order, add_mess_feedback, add_vacation_food_request, + Payments, Rebate, + Special_request, Vacation_food, MessBillBase,Registration_Request, Reg_records ,Reg_main,Deregistration_Request,Semdates) +from .handlers import (add_mess_feedback, add_sem_dates, add_vacation_food_request, add_menu_change_request, handle_menu_change_response, handle_vacation_food_request, add_mess_registration_time, add_leave_request, add_mess_meeting_invitation, handle_rebate_response, add_special_food_request, - handle_special_request, add_bill_base_amount, add_mess_committee, generate_bill) + handle_special_request, add_bill_base_amount, add_mess_committee, handle_reg_response, handle_dreg_response, update_month_bill,handle_add_reg) + from notification.views import central_mess_notif +import csv +import openpyxl + -today_g = datetime.today() +today_g = datetime.datetime.now() month_g = today_g.month month_g_l = today_g.strftime('%B') year_g = today_g.year tomorrow_g = today_g + timedelta(days=1) -first_day_of_this_month = date.today().replace(day=1) +first_day_of_this_month = date.today().replace(day=1) first_day_of_next_month = (date.today().replace(day=28) + timedelta(days=4)).replace(day=1) last_day_of_this_month = first_day_of_next_month - timedelta(days=1) next_month = first_day_of_next_month.month @@ -41,13 +46,14 @@ year_last_g = last_day_prev_month.year previous_month = last_day_prev_month.strftime('%B') - +@login_required def mess(request): """ This view get the access to the central mess dashboard. View all details and apply for any changes. It also shows the previous feedback submitted by the user. """ user = request.user + notifs=request.user.notifications.all() extrainfo = ExtraInfo.objects.select_related().get(user=user) current_date = date.today() holds_designations = HoldsDesignation.objects.select_related().filter(user=user) @@ -62,140 +68,162 @@ def mess(request): count6 = 0 count7 = 0 count8 = 0 - + reg_form = RegistrationRequest() if extrainfo.user_type == 'student': + # def deleteEntries(): + # Registration_Request.objects.all().delete() + # deleteEntries() student = Student.objects.select_related('id','id__user','id__department').get(id=extrainfo) vaca_obj = Vacation_food.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(student_id=student) feedback_obj = Feedback.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(student_id=student).order_by('-fdate') - data = Nonveg_data.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department','dish').filter(student_id=student).order_by('-app_date') monthly_bill = Monthly_bill.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(student_id=student) payments = Payments.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(student_id=student) rebates = Rebate.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(student_id=student).order_by('-app_date') splrequest = Special_request.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(student_id=student).order_by('-app_date') + + reg_form = RegistrationRequest() + + reg_request = Registration_Request.objects.filter(student_id=student) + + de_reg_request = Deregistration_Request.objects.filter(student_id=student) + menu_data = Menu.objects.all() + try: - mess_optn = Messinfo.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').get(student_id=student) + mess_optn = Reg_main.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').get(student_id=student) + y = Menu.objects.filter(mess_option=mess_optn.mess_option) + current_rem_balance = mess_optn.balance + current_mess_status = mess_optn.current_mess_status except: - return HttpResponseRedirect("/mess/info-form") + mess_optn={} + mess_optn={'mess_option':'no-mess'} + y = Menu.objects.filter(mess_option="mess1") + current_rem_balance = 0 + current_mess_status = 'Deregistered' + + + + reg_record = Reg_records.objects.filter(student_id=student) + monthly_bill=monthly_bill[::-1] + + # tot_am=0 + # if len(payments)>0: + # tot_am=payments[0].amount_paid + # else: + # tot_am=0 + # for x in monthly_bill: + # tot_am=tot_am+x.total_bill + # Payments.objects.create(student_id=student,amount_paid=(-tot_am)) + # payments = Payments.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(student_id=student) + + + + + # for i in range(0,len(monthly_bill)): + # if(monthly_bill[i].paid): + # monthly_bill[i].due_amount=0; + # elif monthly_bill[i].total_bill+tot_am<0: + # monthly_bill[i].due_amount=(monthly_bill[i].total_bill) + # else: + # monthly_bill[i].due_amount=(-tot_am) + # tot_am+=monthly_bill[i].total_bill + # amount_due=-payments[0].amount_paid + amount_due = 0 + ## adding the batch of student if btech or bdes then value of programme is 1 or else 0, holds value of phd and mtech. if student.programme == 'B.Tech' or student.programme == 'B.Des': programme = 1 else: programme = 0 - # newmenu = Menu_change_request.objects.all() - # meeting = Mess_meeting.objects.all() - # minutes = Mess_minutes.objects.all() - # feed = Feedback.objects.all() - # sprequest = Special_request.objects.filter(status='1') + meeting = Mess_meeting.objects.all() + minutes = Mess_minutes.objects.all() count = 0 - #variable y stores the menu items - - y = Menu.objects.filter(mess_option=mess_optn.mess_option) - x = Nonveg_menu.objects.all() - - # for item in rebates: - # d1 = item.start_date - # d2 = item.end_date - # item.duration = abs((d2 - d1).days)+1 - # item.save() - - # for items in rebates: - # if items.leave_type == 'casual' and (items.status == '1' or items.status == '2'): - # count += item.duration - - bill = Monthly_bill.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(Q(student_id=student) & Q(month=month_g_l) & Q(year=year_g)) - amount_c = MessBillBase.objects.latest('timestamp') - rebate_count = 0 - nonveg_total_bill = 0 - for z in data: - if z.order_date.month == month_g: - nonveg_total_bill = nonveg_total_bill + z.dish.price - else: - bill.nonveg_total_bill = 0 - - for r in rebates: - if r.status == '2': - if r.start_date.month == month_g: - if r.end_date.month == next_month: - rebate_count = rebate_count + abs((last_day_of_this_month - r.start_date).days) + 1 - else: - rebate_count = rebate_count + abs((r.end_date - r.start_date).days) + 1 - elif r.end_date.month == month_g: - rebate_count = rebate_count + abs((r.end_date - first_day_of_this_month).days) + 1 - else: - rebate_count = 0 - rebate_amount = rebate_count * amount_c.bill_amount / 30 - total_bill = amount_c.bill_amount - rebate_amount + nonveg_total_bill - if bill: - bill.update(student_id = student, - month = month_g_l, - year = year_g, - amount = amount_c.bill_amount, - rebate_count = rebate_count, - rebate_amount = rebate_amount, - nonveg_total_bill=nonveg_total_bill, - total_bill = total_bill) + # try: + # mess_optn = Messinfo.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').get(student_id=student) + # y = Menu.objects.filter(mess_option=mess_optn.mess_option) - else: - bill_object = Monthly_bill(student_id=student, - amount=amount_c.bill_amount, - rebate_count=rebate_count, - rebate_amount=rebate_amount, - nonveg_total_bill=nonveg_total_bill, - total_bill=total_bill, - month=month_g_l, - year=year_g) - bill_object.save() + + # bill = Monthly_bill.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(Q(student_id=student) & Q(month=month_g_l) & Q(year=year_g)) + # amount_c = MessBillBase.objects.latest('timestamp') + # rebate_count = 0 + + # for r in rebates: + # if r.status == '2': + # if r.start_date.month == month_g: + # if r.end_date.month == next_month: + # rebate_count = rebate_count + abs((last_day_of_this_month - r.start_date).days) + 1 + # else: + # rebate_count = rebate_count + abs((r.end_date - r.start_date).days) + 1 + # elif r.end_date.month == month_g: + # rebate_count = rebate_count + abs((r.end_date - first_day_of_this_month).days) + 1 + # else: + # rebate_count = 0 + # rebate_amount = rebate_count * amount_c.bill_amount / 30 + # total_bill = amount_c.bill_amount - rebate_amount + # if bill: + # bill.update(student_id = student, + # month = month_g_l, + # year = year_g, + # amount = amount_c.bill_amount, + # rebate_count = rebate_count, + # rebate_amount = rebate_amount, + # total_bill = total_bill) + + # else: + # bill_object = Monthly_bill(student_id=student, + # amount=amount_c.bill_amount, + # rebate_count=rebate_count, + # rebate_amount=rebate_amount, + # total_bill=total_bill, + # month=month_g_l, + # year=year_g) + # bill_object.save() + # except: + # mess_optn={'mess_option':'no-mess'} + # y = Menu.objects.filter(mess_option="mess1") for d in desig: - if d.designation.name == 'mess_committee_mess1' or d.designation.name == 'mess_convener_mess1': + if d.designation.name == 'mess_committee' or d.designation.name == 'mess_convener': newmenu = Menu_change_request.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department','dish').filter(dish__mess_option='mess1').order_by('-app_date') - # newmenu = Menu_change_request.objects.all() meeting = Mess_meeting.objects.all() minutes = Mess_minutes.objects.select_related().all() feed = Feedback.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(mess='mess1').order_by('-fdate') feed2 = Feedback.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(mess='mess2').order_by('-fdate') sprequest = Special_request.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(status='1').order_by('-app_date') sprequest_past = Special_request.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(status='2').order_by('-app_date') - # count1 = feed.filter(Q(feedback_type='Maintenance') & Q(mess='mess1')).count() + menuchangerequest= Menu_change_request.objects.select_related('student_id').filter().order_by('-app_date') + # menu_data = Menu.objects.all() for f in feed: - if f.feedback_type == 'Maintenance' and mess_optn.mess_option == 'mess1': + if f.feedback_type == 'Maintenance' : count1 += 1 - elif f.feedback_type == 'Food' and mess_optn.mess_option == 'mess1': + elif f.feedback_type == 'Food' : count2 += 1 - elif f.feedback_type == 'Cleanliness' and mess_optn.mess_option == 'mess1': + elif f.feedback_type == 'Cleanliness' : count3 += 1 - elif f.feedback_type == 'Others' and mess_optn.mess_option == 'mess1': + elif f.feedback_type == 'Others' : count4 += 1 - for f in feed2: - if f.feedback_type == 'Maintenance' and mess_optn.mess_option == 'mess2': - count5 += 1 - - elif f.feedback_type == 'Food' and mess_optn.mess_option == 'mess2': - count6 += 1 - - elif f.feedback_type == 'Cleanliness' and mess_optn.mess_option == 'mess2': - count7 += 1 - - elif f.feedback_type == 'Others' and mess_optn.mess_option == 'mess2': - count8 += 1 + count5=0 + count6=0 + count7=0 + count8=0 context = { - 'menu': y, + 'menu': menu_data, + 'reg_menu': y, 'messinfo': mess_optn, 'newmenu': newmenu, 'monthly_bill': monthly_bill, - 'payments': payments, - 'nonveg': x, + 'total_due': amount_due, + 'vaca': vaca_obj, 'info': extrainfo, 'feedback': feedback_obj, - 'feed': feed, + 'feed1': feed, + 'feed2':'', 'student': student, - 'data': data, 'mess_reg': mess_reg, 'current_date': current_date, 'count': count, @@ -205,6 +233,7 @@ def mess(request): 'sprequest': sprequest, 'splrequest': splrequest, 'sprequest_past': sprequest_past, + 'menuchangerequest':menuchangerequest, 'programme':programme, 'count1': count1, 'count2': count2, @@ -215,12 +244,17 @@ def mess(request): 'count7': count7, 'count8': count8, 'form': form, - 'desig': desig + 'desig': desig, + 'reg_form':reg_form, + 'reg_request':reg_request, + 'reg_main':mess_optn, + 'reg_record':reg_record, + 'de_reg_request':de_reg_request, + } return render(request, "messModule/mess.html", context) if d.designation.name == 'mess_committee_mess2' or d.designation.name == 'mess_convener_mess2': - # newmenu = Menu_change_request.objects.all() newmenu = Menu_change_request.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department','dish').filter(dish__mess_option='mess2').order_by('-app_date') meeting = Mess_meeting.objects.all() minutes = Mess_minutes.objects.select_related().all() @@ -228,45 +262,39 @@ def mess(request): feed2 = Feedback.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(mess='mess1').order_by('-fdate') sprequest = Special_request.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(status='1').order_by('-app_date') sprequest_past = Special_request.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(status='2').order_by('-app_date') - # count5 = feed.filter(Q(feedback_type='Maintenance') & Q(mess='mess2')).count() - for f in feed2: - if f.feedback_type == 'Maintenance' and mess_optn.mess_option == 'mess1': + menuchangerequest= Menu_change_request.objects.select_related('student_id').filter().order_by('-app_date') + # menu_data = Menu.objects.all().order_by() + count5=0 + count6=0 + count7=0 + count8=0 + for f in feed: + if f.feedback_type == 'Maintenance' : count1 += 1 - elif f.feedback_type == 'Food' and mess_optn.mess_option == 'mess1': + elif f.feedback_type == 'Food' : count2 += 1 - elif f.feedback_type == 'Cleanliness' and mess_optn.mess_option == 'mess1': + elif f.feedback_type == 'Cleanliness' : count3 += 1 - elif f.feedback_type == 'Others' and mess_optn.mess_option == 'mess1': + elif f.feedback_type == 'Others' : count4 += 1 - for f in feed: - if f.feedback_type == 'Maintenance' and mess_optn.mess_option == 'mess2': - count5 += 1 - - elif f.feedback_type == 'Food' and mess_optn.mess_option == 'mess2': - count6 += 1 - - elif f.feedback_type == 'Cleanliness' and mess_optn.mess_option == 'mess2': - count7 += 1 - - elif f.feedback_type == 'Others' and mess_optn.mess_option == 'mess2': - count8 += 1 context = { - 'menu': y, + 'menu': menu_data, + 'reg_menu': y, 'messinfo': mess_optn, 'newmenu': newmenu, 'monthly_bill': monthly_bill, - 'payments': payments, - 'nonveg': x, + 'total_due': amount_due, 'vaca': vaca_obj, 'info': extrainfo, 'feedback': feedback_obj, - 'feed': feed, + 'feed2': feed, + 'feed1':'', 'student': student, - 'data': data, + # 'data': data, 'mess_reg': mess_reg, 'current_date': current_date, 'count': count, @@ -274,9 +302,10 @@ def mess(request): 'programme': programme, 'meeting': meeting, 'minutes': minutes, - 'sprequest': sprequest, 'splrequest': splrequest, + 'sprequest': sprequest, 'sprequest_past': sprequest_past, + 'menuchangerequest':menuchangerequest, 'count1': count1, 'count2': count2, 'count3': count3, @@ -286,21 +315,25 @@ def mess(request): 'count7': count7, 'count8': count8, 'form': form, - 'desig': desig + 'desig': desig, + 'reg_form':reg_form, + 'reg_request':reg_request, + 'reg_main':mess_optn, + 'reg_record':reg_record, + 'de_reg_request':de_reg_request, } return render(request, "messModule/mess.html", context) context = { - 'menu': y, + 'menu': menu_data, + 'reg_menu': y, 'messinfo': mess_optn, 'monthly_bill': monthly_bill, - 'payments': payments, - 'nonveg': x, + 'total_due': amount_due, 'vaca': vaca_obj, 'info': extrainfo, 'feedback': feedback_obj, 'student': student, - 'data': data, 'mess_reg': mess_reg, 'current_date': current_date, 'count': count, @@ -308,92 +341,153 @@ def mess(request): 'splrequest': splrequest, 'form': form, 'programme': programme, - 'desig': desig - } + 'desig': desig, + 'minutes': minutes, + 'meeting': meeting, + 'reg_form':reg_form, + 'reg_main_stud':mess_optn, + 'reg_request':reg_request, + 'reg_record':reg_record, + 'de_reg_request':de_reg_request, + 'payments': payments, + 'curr_balance': current_rem_balance, + 'curr_status':current_mess_status, + 'notifications':notifs + } return render(request, "messModule/mess.html", context) + + + elif extrainfo.user_type == 'staff': - current_bill = MessBillBase.objects.latest('timestamp') - nonveg_orders_today = Nonveg_data.objects.filter(order_date=today_g)\ - .values('dish__dish','order_interval').annotate(total=Count('dish')) - nonveg_orders_tomorrow = Nonveg_data.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department','dish').filter(order_date=tomorrow_g)\ - .values('dish__dish','order_interval').annotate(total=Count('dish')) - # make info with diff name and then pass context - newmenu = Menu_change_request.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department','dish').all().order_by('-app_date') - vaca_all = Vacation_food.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').all().order_by('-app_date') - # members_mess = HoldsDesignation.objects.filter(designation__name='mess_convener') - members_mess = HoldsDesignation.objects.select_related().filter(Q(designation__name__contains='mess_convener') - | Q(designation__name__contains='mess_committee')) - y = Menu.objects.all() - x = Nonveg_menu.objects.all() - leave = Rebate.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(status='1').order_by('-app_date') - leave_past = Rebate.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(status='2').order_by('-app_date') + for d in desig: + if(d.designation.name == 'mess_manager'): + current_bill = MessBillBase.objects.latest('timestamp') + newmenu = Menu_change_request.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department','dish').all().order_by('-app_date') + vaca_all = Vacation_food.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').all().order_by('-app_date') + members_mess = HoldsDesignation.objects.select_related().filter(Q(designation__name__contains='mess_convener') + | Q(designation__name__contains='mess_committee')) + y = Menu.objects.all() + leave = Rebate.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(status='1').order_by('-app_date') + leave_past = Rebate.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(status='2').order_by('-app_date') + meeting = Mess_meeting.objects.all() + minutes = Mess_minutes.objects.all() + feed1 = Feedback.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(mess='mess1').order_by('-fdate') + feed2 = Feedback.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(mess='mess2').order_by('-fdate') + + for f in feed1: + if f.feedback_type == 'Maintenance' : + count1 += 1 - context = { - 'bill_base': current_bill, - 'today': today_g.date(), - 'tomorrow': tomorrow_g.date(), - 'nonveg_orders_t':nonveg_orders_tomorrow, - 'nonveg_orders': nonveg_orders_today, - 'members': members_mess, - 'menu': y, - 'newmenu': newmenu, - 'vaca_all': vaca_all, - 'info': extrainfo, - 'leave': leave, - 'leave_past': leave_past, - 'current_date': current_date, - 'mess_reg': mess_reg, - 'desig': desig, - } + elif f.feedback_type == 'Food' : + count2 += 1 - return render(request, "messModule/mess.html", context) + elif f.feedback_type == 'Cleanliness' : + count3 += 1 + + elif f.feedback_type == 'Others' : + count4 += 1 + + for f in feed2: + if f.feedback_type == 'Maintenance': + count5 += 1 + + elif f.feedback_type == 'Food': + count6 += 1 + + elif f.feedback_type == 'Cleanliness': + count7 += 1 + + elif f.feedback_type == 'Others': + count8 += 1 + + sprequest = Special_request.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(status='1').order_by('-app_date') + sprequest_past = Special_request.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(status='2').order_by('-app_date') + + reg_request = Registration_Request.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').all().filter(status='pending') + de_reg_request = Deregistration_Request.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').all().filter(status='pending') + reg_main = Reg_main.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(current_mess_status='Registered') + reg_record = Reg_records.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').all() + bills = Monthly_bill.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').all() + # bills = Monthly_bill.objects.all() + context = { + 'bill_base': current_bill, + 'today': today_g.date(), + 'tomorrow': tomorrow_g.date(), + 'members': members_mess, + 'menu': y, + 'newmenu': newmenu, + 'vaca_all': vaca_all, + 'info': extrainfo, + 'leave': leave, + 'leave_past': leave_past, + 'current_date': current_date, + 'mess_reg': mess_reg, + 'desig': desig, + 'meeting': meeting, + 'minutes': minutes, + 'sprequest': sprequest, + 'sprequest_past': sprequest_past, + 'count1': count1, + 'count2': count2, 'count3': count3, 'feed1': feed1,'feed2':feed2, + 'count4': count4, 'form': form, 'count5': count5, + 'count6': count6, 'count7': count7, 'count8': count8, 'desig': desig, + 'reg_request':reg_request,'reg_record':reg_record,'reg_main':reg_main, + 'de_reg_request':de_reg_request, + 'bill': bills, + 'reg_form':reg_form + } + return render(request, "messModule/mess.html", context) elif extrainfo.user_type == 'faculty': - meeting = Mess_meeting.objects.all() - minutes = Mess_minutes.objects.select_related().all() - feed = Feedback.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').all().order_by('-fdate') - y = Menu.objects.all() + for d in desig: + if(d.designation.name == 'mess_warden'): + + feed1 = Feedback.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(mess='mess1').order_by('-fdate') + feed2 = Feedback.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(mess='mess2').order_by('-fdate') + y = Menu.objects.all() - for f in feed: - mess_opt = Messinfo.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').get(student_id=f.student_id) - if f.feedback_type == 'Maintenance' and mess_opt.mess_option == 'mess1': - count1 += 1 + reg_main = Reg_main.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(current_mess_status='Registered') + reg_record = Reg_records.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').all() + bills = Monthly_bill.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').all() - elif f.feedback_type == 'Food' and mess_opt.mess_option == 'mess1': - count2 += 1 + for f in feed1: + if f.feedback_type == 'Maintenance' : + count1 += 1 - elif f.feedback_type == 'Cleanliness' and mess_opt.mess_option == 'mess1': - count3 += 1 + elif f.feedback_type == 'Food' : + count2 += 1 - elif f.feedback_type == 'Others' and mess_opt.mess_option == 'mess1': - count4 += 1 + elif f.feedback_type == 'Cleanliness' : + count3 += 1 - for f in feed: - mess_opt = Messinfo.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').get(student_id=f.student_id) - if f.feedback_type == 'Maintenance' and mess_opt.mess_option == 'mess2': - count5 += 1 + elif f.feedback_type == 'Others' : + count4 += 1 - elif f.feedback_type == 'Food' and mess_opt.mess_option == 'mess2': - count6 += 1 + for f in feed2: + if f.feedback_type == 'Maintenance': + count5 += 1 - elif f.feedback_type == 'Cleanliness' and mess_opt.mess_option == 'mess2': - count7 += 1 + elif f.feedback_type == 'Food': + count6 += 1 - elif f.feedback_type == 'Others' and mess_opt.mess_option == 'mess2': - count8 += 1 - context = { - 'info': extrainfo, - 'menu': y, - 'meeting': meeting, - 'minutes': minutes, - 'count1': count1, - 'count2': count2, 'count3': count3, 'feed': feed, - 'count4': count4, 'form': form, 'count5': count5, - 'count6': count6, 'count7': count7, 'count8': count8, 'desig': desig - } - return render(request, 'messModule/mess.html', context) + elif f.feedback_type == 'Cleanliness': + count7 += 1 + + elif f.feedback_type == 'Others': + count8 += 1 + context = { + 'info': extrainfo, + 'desig': desig, + 'menu': y, + 'count1': count1, + 'count2': count2, 'count3': count3, 'feed1': feed1,'feed2':feed2, + 'count4': count4, 'form': form, 'count5': count5, + 'count6': count6, 'count7': count7, 'count8': count8, 'desig': desig, + 'reg_record':reg_record,'reg_main':reg_main,'bill': bills, + } + return render(request, 'messModule/mess.html', context) @login_required @transaction.atomic @@ -417,38 +511,19 @@ def mess_info(request): mess_option = form.cleaned_data['mess_option'] Messinfo.objects.create(student_id=student_id, mess_option=mess_option) return HttpResponseRedirect("/mess") - + user_id = request.user + student_id = Student.objects.select_related( + 'id').only('id__id').get(id__id=user_id) + if Messinfo.objects.filter(student_id=student_id).exists(): + return HttpResponseRedirect("/mess") form = MessInfoForm() context = { "form": form } return render(request, "messModule/messInfoForm.html", context) -@login_required -@transaction.atomic -@csrf_exempt -def place_order(request): - """ - This function is to place non-veg food orders - @param: - request: contains metadata about the requested page - - @variables: - user: Current user - order_interval: Time of the day for which order is placed eg breakfast/lunch/dinner - extra_info: Extra information about the current user. From model ExtraInfo - student: Student information about the current user - student_mess: Mess choices of the student - dish_request: Predefined dish available - """ - user = request.user - extra_info = ExtraInfo.objects.select_related().get(user=user) - if extra_info.user_type == 'student': - student = Student.objects.select_related('id','id__user','id__department').get(id=extra_info) - student_mess = Messinfo.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').get(student_id=student) - add_nonveg_order(request, student) - return HttpResponseRedirect('/mess') + @csrf_exempt @@ -525,9 +600,9 @@ def submit_mess_menu(request): extrainfo = ExtraInfo.objects.select_related().get(user=user) designation = holds_designations student = Student.objects.select_related('id','id__user','id__department').get(id=extrainfo) - # globallyChange() + context = {} - # A user may hold multiple designations + data = add_menu_change_request(request,student) if data['status'] == 1: @@ -569,7 +644,7 @@ def response_vacation_food(request, ap_id): holds_designations: designation of current user """ user = request.user - # extra_info = ExtraInfo.objects.get(user=user) + holds_designations = HoldsDesignation.objects.select_related().filter(user=user) designation = holds_designations @@ -659,6 +734,12 @@ def start_mess_registration(request): data = add_mess_registration_time(request) return JsonResponse(data) +@csrf_exempt +def closeRegistration(request): + mess_reg = Mess_reg.objects.last() + yesterday = date.today() - timedelta(days=1) + Mess_reg.objects.filter(id=mess_reg.id).update(end_reg=yesterday) + return HttpResponseRedirect('/mess') @transaction.atomic @csrf_exempt @@ -743,6 +824,8 @@ def rebate_response(request): for d in designation: if d.designation.name == 'mess_manager': data = handle_rebate_response(request) + print(data) + print(request) return JsonResponse(data) @@ -798,10 +881,29 @@ def update_cost(request): user - contains user details """ user = request.user - # extrainfo = ExtraInfo.objects.get(user=user) data = add_bill_base_amount(request) return JsonResponse(data) +@login_required +def update_semdates(request): + """ + This function is to update the semester start and end date + + @param: + request - contains metadata about the requested page + + @variables: + user - contains user details + """ + user = request.user + data = add_sem_dates(request) + return HttpResponseRedirect('/mess') +@csrf_exempt +@login_required +def update_bill(request): + # user = request.user + update_month_bill(request) + return HttpResponseRedirect('/mess') def generate_mess_bill(request): """ @@ -822,10 +924,10 @@ def generate_mess_bill(request): """ # todo generate proper logic for generate_mess_bill user = request.user - t1 = Thread(target=generate_bill, args=()) - t1.setDaemon(True) - t1.start() - # int = generate_bill() + # t1 = Thread(target=generate_bill, args=()) + # t1.setDaemon(True) + # t1.start() + generate_bill() data ={ 'status': 1 } @@ -880,6 +982,24 @@ def post(self, request, *args, **kwargs): 'mess_option': 'mess1' } return render_to_pdf('messModule/menudownloadable1.html', context) + +class BillPDFStudent(View): + def post(self, request, *args, **kwargs): + user = request.user + extra_info = ExtraInfo.objects.select_related().get(user=user) + student = Student.objects.select_related('id','id__user','id__department').get(id=extra_info) + # reg_student = Reg_records.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').get(student_id_id=student) + try: + monthly_bill = Monthly_bill.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department').filter(student_id=student) + if monthly_bill.exists(): + context = { + 'student_bill': monthly_bill + } + return render_to_pdf('messModule/billpdfexport.html', context) + else : + return HttpResponseRedirect('/mess') + except: + return HttpResponseRedirect('/mess') def menu_change_request(request): @@ -899,6 +1019,7 @@ def menu_change_request(request): return JsonResponse(data) +@csrf_exempt def submit_mess_committee(request): """ This function is to add the new mess committee @@ -910,10 +1031,9 @@ def submit_mess_committee(request): current_user - get user from request user_details - extract details and designation of the user from the database """ - roll_number = request.POST['rollnumber'] - + roll_number = str(request.POST.get('roll_number')).upper() data = add_mess_committee(request, roll_number) - return JsonResponse(data) + return HttpResponseRedirect("/mess") def remove_mess_committee(request): @@ -931,10 +1051,10 @@ def remove_mess_committee(request): member_id = request.POST['member_id'] data_m = member_id.split("-") roll_number = data_m[1] - if data_m[0] == 'mess_committee_mess1': - designation = Designation.objects.get(name='mess_committee_mess1') - elif data_m[0] == 'mess_convener_mess1': - designation = Designation.objects.get(name='mess_convener_mess1') + if data_m[0] == 'mess_committee': + designation = Designation.objects.get(name='mess_committee') + elif data_m[0] == 'mess_convener': + designation = Designation.objects.get(name='mess_convener') elif data_m[0] == 'mess_committee_mess2': designation = Designation.objects.get(name='mess_committee_mess2') else: @@ -1015,9 +1135,9 @@ def select_mess_convener(request): data_m = member_id.split("-") roll_number = data_m[1] - if data_m[0] == 'mess_committee_mess1': - designation = Designation.objects.get(name='mess_committee_mess1') - new_designation = Designation.objects.get(name='mess_convener_mess1') + if data_m[0] == 'mess_committee': + designation = Designation.objects.get(name='mess_committee') + new_designation = Designation.objects.get(name='mess_convener') # One mess can have only one mess convener existing_check = HoldsDesignation.objects.select_related().filter(designation=new_designation) if existing_check.count(): @@ -1081,27 +1201,6 @@ def download_bill_mess(request): } return render_to_pdf('messModule/billpdfexport.html', context) - -def get_nonveg_order(request): - """ - This function is to apply for non-veg order - - @param: - request - contains metadata about the requested page - - @variables: - current_user - get user from request - user_details - extract details of the user from the database - """ - date_o = request.POST['order_date'] - nonveg_orders_tomorrow = Nonveg_data.objects.select_related('student_id','student_id__id','student_id__id__user','student_id__id__department','dish').filter(order_date=date_o) \ - .values('dish__dish', 'order_interval').annotate(total=Count('dish')) - data = { - 'status': 1, - } - return JsonResponse(data) - - def add_leave_manager(request): """ This function is to apply for leave @@ -1162,3 +1261,392 @@ def add_leave_manager(request): central_mess_notif(request.user, student.id.user, 'leave_request', message) add_obj.save() return HttpResponseRedirect('/mess') + +def update_menu2(request): + if (request.method == "POST"): + mb = request.POST['MB2'] + ml = request.POST['ML2'] + md = request.POST['MD2'] + sud = request.POST['SUD2'] + sul = request.POST['SUL2'] + sub = request.POST['SUB2'] + sd = request.POST['SD2'] + sl = request.POST['SL2'] + sb = request.POST['SB2'] + fd = request.POST['FD2'] + fl = request.POST['FL2'] + fb = request.POST['FB2'] + thd = request.POST['THD2'] + thl = request.POST['THL2'] + thb = request.POST['THB2'] + wd = request.POST['WD2'] + wl = request.POST['WL2'] + wb = request.POST['WB2'] + td = request.POST['TD2'] + tl = request.POST['TL2'] + tb = request.POST['TB2'] + + print("mb", mb) + Menu.objects.filter(mess_option = 'mess2',meal_time='MB').update(dish = mb) + Menu.objects.filter(mess_option = 'mess2',meal_time='ML').update(dish = ml) + Menu.objects.filter(mess_option = 'mess2',meal_time='MD').update(dish = md) + Menu.objects.filter(mess_option = 'mess2',meal_time='TB').update(dish = tb) + Menu.objects.filter(mess_option = 'mess2',meal_time='TL').update(dish = tl) + Menu.objects.filter(mess_option = 'mess2',meal_time='TD').update(dish = td) + Menu.objects.filter(mess_option = 'mess2',meal_time='WB').update(dish = wb) + Menu.objects.filter(mess_option = 'mess2',meal_time='WL').update(dish = wl) + Menu.objects.filter(mess_option = 'mess2',meal_time='WD').update(dish = wd) + Menu.objects.filter(mess_option = 'mess2',meal_time='THB').update(dish = thb) + Menu.objects.filter(mess_option = 'mess2',meal_time='THL').update(dish = thl) + Menu.objects.filter(mess_option = 'mess2',meal_time='THD').update(dish = thd) + Menu.objects.filter(mess_option = 'mess2',meal_time='FB').update(dish = fb) + Menu.objects.filter(mess_option = 'mess2',meal_time='FL').update(dish = fl) + Menu.objects.filter(mess_option = 'mess2',meal_time='FD').update(dish = fd) + Menu.objects.filter(mess_option = 'mess2',meal_time='SB').update(dish = sb) + Menu.objects.filter(mess_option = 'mess2',meal_time='SL').update(dish = sl) + Menu.objects.filter(mess_option = 'mess2',meal_time='SD').update(dish = sd) + Menu.objects.filter(mess_option = 'mess2',meal_time='SUB').update(dish = sub) + Menu.objects.filter(mess_option = 'mess2',meal_time='SUL').update(dish = sul) + Menu.objects.filter(mess_option = 'mess2',meal_time='SUD').update(dish = sud) + + + return redirect('/mess') +def update_menu1(request): + if (request.method == "POST"): + mb1 = request.POST['MB1'] + ml1 = request.POST['ML1'] + md1 = request.POST['MD1'] + sud1 = request.POST['SUD1'] + sul1 = request.POST['SUL1'] + sub1 = request.POST['SUB1'] + sd1 = request.POST['SD1'] + sl1 = request.POST['SL1'] + sb1 = request.POST['SB1'] + fd1 = request.POST['FD1'] + fl1 = request.POST['FL1'] + fb1 = request.POST['FB1'] + thd1 = request.POST['THD1'] + thl1 = request.POST['THL1'] + thb1 = request.POST['THB1'] + wd1 = request.POST['WD1'] + wl1 = request.POST['WL1'] + wb1 = request.POST['WB1'] + td1 = request.POST['TD1'] + tl1 = request.POST['TL1'] + tb1 = request.POST['TB1'] + + print("mb", mb1) + Menu.objects.filter(mess_option = 'mess1',meal_time='MB').update(dish = mb1) + Menu.objects.filter(mess_option = 'mess1',meal_time='ML').update(dish = ml1) + Menu.objects.filter(mess_option = 'mess1',meal_time='MD').update(dish = md1) + Menu.objects.filter(mess_option = 'mess1',meal_time='TB').update(dish = tb1) + Menu.objects.filter(mess_option = 'mess1',meal_time='TL').update(dish = tl1) + Menu.objects.filter(mess_option = 'mess1',meal_time='TD').update(dish = td1) + Menu.objects.filter(mess_option = 'mess1',meal_time='WB').update(dish = wb1) + Menu.objects.filter(mess_option = 'mess1',meal_time='WL').update(dish = wl1) + Menu.objects.filter(mess_option = 'mess1',meal_time='WD').update(dish = wd1) + Menu.objects.filter(mess_option = 'mess1',meal_time='THB').update(dish = thb1) + Menu.objects.filter(mess_option = 'mess1',meal_time='THL').update(dish = thl1) + Menu.objects.filter(mess_option = 'mess1',meal_time='THD').update(dish = thd1) + Menu.objects.filter(mess_option = 'mess1',meal_time='FB').update(dish = fb1) + Menu.objects.filter(mess_option = 'mess1',meal_time='FL').update(dish = fl1) + Menu.objects.filter(mess_option = 'mess1',meal_time='FD').update(dish = fd1) + Menu.objects.filter(mess_option = 'mess1',meal_time='SB').update(dish = sb1) + Menu.objects.filter(mess_option = 'mess1',meal_time='SL').update(dish = sl1) + Menu.objects.filter(mess_option = 'mess1',meal_time='SD').update(dish = sd1) + Menu.objects.filter(mess_option = 'mess1',meal_time='SUB').update(dish = sub1) + Menu.objects.filter(mess_option = 'mess1',meal_time='SUL').update(dish = sul1) + Menu.objects.filter(mess_option = 'mess1',meal_time='SUD').update(dish = sud1) + + return redirect('/mess') + +@csrf_exempt +def searchAddOrRemoveStudent(request): + if request.method=='GET': + submitType=request.GET.get('type') + msg="" + if submitType=='searchStudent': + studentId=str((request.GET.get('roll_number'))).upper() + try: + reg_main = Reg_main.objects.values('current_mess_status','mess_option').get(student_id=studentId) + if(reg_main['current_mess_status']=="Registered"): + msg= str(studentId)+" is registered for "+str(reg_main['mess_option']) + else: + msg=str(studentId)+" is not registered for Mess" + except: + msg="unable to find this student in database." + + # try: + # mess_optn = Messinfo.objects.select_related().values('mess_option').get(student_id=studentId) + # msg= str(studentId)+" is registered for "+str(mess_optn['mess_option']) + # except: + # msg=str(studentId)+" is not registered for Mess" + + elif submitType=='addStudent': + messNo=request.GET.get('messNo') + studentId = str((request.GET.get('roll_number'))).upper() + try: + reg_main = Reg_main.objects.get(student_id=studentId) + + if(reg_main.current_mess_status=="Registered"): + msg=str(studentId)+" is already registered for "+str(reg_main.mess_option) + else: + reg_main.current_mess_status="Registered" + reg_main.mess_option=str(messNo) + reg_main.save() + msg="success" + except: + msg="unable to find this student in database." + + # try: + # mess_optn = Messinfo.objects.select_related().values('mess_option').get(student_id=studentId) + # msg=str(studentId)+" is already registered for "+str(mess_optn['mess_option']) + # except: + # try: + # studentHere = Student.objects.select_related('id','id__user','id__department').get(id=studentId) + # newData=Messinfo(student_id=studentHere,mess_option=str(messNo)) + # newData.save() + # msg=str(studentId)+" is successfully registered for Mess." + # except: + # msg="unable to find this student in database." + + elif submitType=='removeStudent': + studentId = str((request.GET.get('roll_number'))).upper() + try: + reg_main = Reg_main.objects.get(student_id=studentId,current_mess_status="Registered") + reg_main.current_mess_status="Deregistered" + reg_main.save() + msg=str(studentId)+" is successfully removed from mess." + except: + msg=str(studentId)+" is not registered for mess." + + # try: + # studentHere = Student.objects.select_related('id','id__user','id__department').get(id=studentId) + # data=Messinfo.objects.get(student_id=studentId) + # data.delete() + # Messinfo.objects.all() + # msg=str(studentId)+" is successfully removed from mess." + # except: + # msg=str(studentId)+" is not registered for mess." + elif (submitType=='removeAllStudent1' or submitType=='removeAllStudent2'): + messNo=request.GET.get('mess') + + try: + reg_main = Reg_main.objects.filter(mess_option=str(messNo),current_mess_status="Registered") + for reg in reg_main: + reg.current_mess_status="Deregistered" + reg.save() + msg="All students removed successfully from "+str(messNo) + except: + msg="can't remove students." + + return JsonResponse({'message':msg}) + else: + if(request.FILES): + # if 'excelUpload1' in request.POST: + # messNo='mess1' + # excel_file = request.FILES['excel_file1'] + # else: + # messNo='mess2' + # excel_file = request.FILES['excel_file2'] + try: + latest = Semdates.objects.latest('end_date') + latest_end_date=latest.end_date + print(latest_end_date) + except: + latest_end_date=None + excel_file = request.FILES['excel_file1'] + wb = openpyxl.load_workbook(excel_file) + flag = False + for row in wb.active: + if(flag==False): + flag=True + continue + studentId=(str(row[0].value)).upper() + studentHere = Student.objects.select_related('id','id__user','id__department').get(id=studentId) + balance=row[1].value + messNo = row[2].value + try: + reg_main = Reg_main.objects.get(student_id=studentId) + reg_main.current_mess_status="Registered" + reg_main.mess_option=str(messNo) + reg_main.balance=reg_main.balance+balance + reg_main.save() + # if Messinfo.objects.filter(student_id=studentId).exists(): + # Messinfo.objects.filter(student_id=studentId).update(mess_option=str(messNo)) + # else: + # newData=Messinfo(student_id=studentHere,mess_option=str(messNo)) + # newData.save() + except: + reg_main = Reg_main(student_id=reg_main.student_id,program=studentHere.programme,current_mess_status="Registered",mess_option=str(messNo),balance=balance) + reg_main.save() + + new_reg_record = Reg_records(student_id=reg_main.student_id,start_date=today_g,end_date=latest_end_date) + new_reg_record.save() + # messages.success(request,"Done.") + return HttpResponseRedirect("/mess") + +@csrf_exempt +def uploadPaymentDue(request): + if(request.FILES): + + excel_file = request.FILES['excel_file'] + wb = openpyxl.load_workbook(excel_file) + + for row in wb.active: + studentId=(str(row[0].value)).upper() + amount=(row[1].value) + try: + studentHere = Student.objects.get(id=studentId) + monthly_bill = Monthly_bill.objects.select_related('student_id').filter(student_id=studentHere) + try: + Payments.objects.filter(student_id=studentHere).delete() + except: + 1 + Payments.objects.create(student_id=studentHere,amount_paid=(-1*(amount))) + if amount<=0: + for x in monthly_bill: + Monthly_bill.objects.filter(student_id=studentHere).filter(month=x.month).filter(year=x.year).update(paid=True) + else: + monthly_bill=monthly_bill[::-1] + curr_amount=amount + for x in monthly_bill: + if(curr_amount<=0): + Monthly_bill.objects.filter(student_id=studentHere).filter(month=x.month).filter(year=x.year).update(paid=True) + else: + Monthly_bill.objects.filter(student_id=studentHere).filter(month=x.month).filter(year=x.year).update(paid=False) + curr_amount-=x.total_bill; + print(x) + except: + 1 + messages.success(request,"Done.") + return HttpResponseRedirect("/mess") + + +@csrf_exempt +@login_required +def respond_to_reg(request): + """ + This function is used to respond to registeration requests + + @param request: + request - contains metadata about the requested page + + @variables: + user: Current user details + designation : designation of the user + + @return: + data: returns the status of the application + """ + data = { + 'status': 1 + } + user = request.user + designation = HoldsDesignation.objects.select_related().filter(user=user) + type = request.POST['type'] + for d in designation: + if d.designation.name == 'mess_manager': + if(type=='reg'): + data = handle_reg_response(request) + elif(type=='dreg'): + data = handle_dreg_response(request) + return JsonResponse(data) + + +def reg_request(request): + + user = request.user + extra_info = ExtraInfo.objects.select_related().get(user=user) + try: + if request.POST['input_roll']: + # print(request.POST) + studentID = str(request.POST['input_roll']).upper() + handle_add_reg(request) + form = RegistrationRequest(request.POST, request.FILES) + student = Student.objects.select_related('id','id__user','id__department').get(id=studentID) + if form.is_valid(): + temp=form.save(commit=False) + temp.student_id=student + temp.status='accept' + temp.save() + return HttpResponseRedirect("/mess") + except: + student = Student.objects.select_related('id','id__user','id__department').get(id=extra_info) + if request.method == 'POST': + form = RegistrationRequest(request.POST, request.FILES) + + if form.is_valid(): + temp=form.save(commit=False) + temp.student_id=student + temp.save() + return HttpResponseRedirect("/mess") + + + +@csrf_exempt +def update_bill_excel(request): + if(request.FILES): + excel_file = request.FILES['excel_file_bill'] + wb = openpyxl.load_workbook(excel_file) + flag = False + for row in wb.active: + if(flag==False): + flag=True + continue + studentId=(str(row[0].value)).upper() + studentHere = Student.objects.select_related('id','id__user','id__department').get(id=studentId) + month=str(row[1].value) + year = row[2].value + amt = row[3].value + rebate_cnt = row[4].value + rebate_amt = row[5].value + total_amt = row[6].value + try: + bill = Monthly_bill.objects.get(student_id=studentId,month=month,year=year) + reg_main = Reg_main.objects.get(student_id=studentId) + reg_main.balance=reg_main.balance+bill.total_bill + bill.amount=amt + bill.rebate_count=rebate_cnt + bill.rebate_amount=rebate_amt + bill.total_bill=total_amt + reg_main.balance=reg_main.balance-total_amt + bill.save() + reg_main.save() + except: + bill = Monthly_bill(student_id=studentHere,month=month,year=year,amount=amt,rebate_count=rebate_cnt,rebate_amount=rebate_amt,total_bill=total_amt) + bill.save() + # messages.success(request,"Done.") + return HttpResponseRedirect("/mess") + +def de_reg_request(request): + try: + if request.POST['input_roll']: + # print(request.POST) + studentID = str(request.POST['input_roll']).upper() + end_date = request.POST.get("end_date") + try: + reg_main = Reg_main.objects.get(student_id=studentID) + + if(end_date == str(date.today())): + reg_main.current_mess_status = 'Deregistered' + reg_main.save() + reg_record = Reg_records.objects.filter(student_id=studentID).latest('start_date') + reg_record.end_date=end_date + reg_record.save() + except: + pass + return HttpResponseRedirect('/mess') + except: + data={ + 'message':'request submitted successfully' + } + user = request.user + end_date = request.POST.get("end_date") + print(end_date) + extra_info = ExtraInfo.objects.select_related().get(user=user) + student = Student.objects.select_related('id','id__user','id__department').get(id=extra_info) + new_req=Deregistration_Request(student_id=student, end_date=end_date) + new_req.save() + return HttpResponseRedirect('/mess') + diff --git a/FusionIIIT/applications/complaint_system/admin.py b/FusionIIIT/applications/complaint_system/admin.py index 84314fcd9..8bf43cab7 100644 --- a/FusionIIIT/applications/complaint_system/admin.py +++ b/FusionIIIT/applications/complaint_system/admin.py @@ -1,8 +1,9 @@ from django.contrib import admin -from .models import Caretaker, StudentComplain, Supervisor, Workers +from .models import Caretaker, StudentComplain, Supervisor, Workers, SectionIncharge admin.site.register(Caretaker) admin.site.register(Workers) admin.site.register(StudentComplain) admin.site.register(Supervisor) +admin.site.register(SectionIncharge) diff --git a/FusionIIIT/applications/complaint_system/api/views.py b/FusionIIIT/applications/complaint_system/api/views.py index 612c6573c..304697017 100644 --- a/FusionIIIT/applications/complaint_system/api/views.py +++ b/FusionIIIT/applications/complaint_system/api/views.py @@ -23,7 +23,7 @@ def complaint_details_api(request,detailcomp_id1): if complaint_detail.worker_id is None: worker_detail_serialized = {} else : - worker_detail = worker_detail.objects.get(id=complaint_detail.worker_id) + worker_detail = Workers.objects.get(id=complaint_detail.worker_id.id) worker_detail_serialized = serializers.WorkersSerializers(instance=worker_detail).data complainer = User.objects.get(username=complaint_detail.complainer.user.username) complainer_serialized = serializers.UserSerializers(instance=complainer).data @@ -154,7 +154,7 @@ def caretaker_api(request): user = get_object_or_404(User ,username=request.user.username) user = ExtraInfo.objects.all().filter(user = user).first() try : - supervisor = Supervisor.objects.get(staff_id=user) + supervisor = Supervisor.objects.get(sup_id=user) except Supervisor.DoesNotExist: return Response({'message':'Logged in user does not have the permissions'},status=status.HTTP_203_NON_AUTHORITATIVE_INFORMATION) serializer = serializers.CaretakerSerializers(data=request.data) @@ -170,7 +170,7 @@ def edit_caretaker_api(request,c_id): user = get_object_or_404(User ,username=request.user.username) user = ExtraInfo.objects.all().filter(user = user).first() try : - supervisor = Supervisor.objects.get(staff_id=user) + supervisor = Supervisor.objects.get(sup_id=user) except Supervisor.DoesNotExist: return Response({'message':'Logged in user does not have the permissions'},status=status.HTTP_203_NON_AUTHORITATIVE_INFORMATION) try: diff --git a/FusionIIIT/applications/complaint_system/models.py b/FusionIIIT/applications/complaint_system/models.py index 9f8849e69..47145fad3 100644 --- a/FusionIIIT/applications/complaint_system/models.py +++ b/FusionIIIT/applications/complaint_system/models.py @@ -12,11 +12,13 @@ class Constants: ('hall-1', 'hall-1'), ('hall-3', 'hall-3'), ('hall-4', 'hall-4'), - ('CC1', 'CC1'), - ('CC2', 'CC2'), + ('library', 'CC1'), + ('computer center', 'CC2'), ('core_lab', 'core_lab'), ('LHTC', 'LHTC'), ('NR2', 'NR2'), + ('NR3', 'NR3'), + ('Admin building', 'Admin building'), ('Rewa_Residency', 'Rewa_Residency'), ('Maa Saraswati Hostel', 'Maa Saraswati Hostel'), ('Nagarjun Hostel', 'Nagarjun Hostel'), @@ -42,11 +44,18 @@ class Caretaker(models.Model): # no_of_comps = models.CharField(max_length=1000) def __str__(self): - return str(self.id) + '-' + self.area + return str(self.id) + '-' + str(self.area) +class SectionIncharge(models.Model): + staff_id = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE) + work_type = models.CharField(choices=Constants.COMPLAINT_TYPE, + max_length=20, default='Electricity') + + def __str__(self): + return str(self.id) + '-' + self.work_type class Workers(models.Model): - caretaker_id = models.ForeignKey(Caretaker, on_delete=models.CASCADE) + secincharge_id = models.ForeignKey(SectionIncharge, on_delete=models.CASCADE, null=True) name = models.CharField(max_length=50) age = models.CharField(max_length=10) phone = models.BigIntegerField(blank=True) @@ -82,7 +91,7 @@ def __str__(self): class Supervisor(models.Model): sup_id = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE) - area = models.CharField(choices=Constants.AREA, max_length=20) + type = models.CharField(choices=Constants.COMPLAINT_TYPE, max_length=30,default='Electricity') def __str__(self): - return str(self.sup_id.user.username) + return str(self.sup_id) + '-' + str(self.type) diff --git a/FusionIIIT/applications/complaint_system/static/complaint_system/js/rating.js b/FusionIIIT/applications/complaint_system/static/complaint_system/js/rating.js index 3884f885b..825fe759d 100644 --- a/FusionIIIT/applications/complaint_system/static/complaint_system/js/rating.js +++ b/FusionIIIT/applications/complaint_system/static/complaint_system/js/rating.js @@ -58,6 +58,93 @@ $(document).ready(function(){ } }; + function sub2(event) + { + var specific_location= $('input[name="specific_location"]').val(); + var Location = $('input[name="Location"]').val(); + var complaint_type = $('input[name="complaint_type"]').val() ; + var details =$('input[name="details"]').val() ; + var myfile = $('input[name="myfile"]').val(); + if(specific_location=="" || Location=="" || details=="" || complaint_type=="") + { + alert("Please fill all the details!"); + return; + } + else + { + event.preventDefault(); + $.ajax({ + type : 'POST', + url : '.', + data : { + 'specific_location' : specific_location, + 'Location' : Location, + 'complaint_type' : complaint_type, + 'details' : details, + 'myfile' : myfile, + + }, + success : function (data){ + + // alert("Complaint successfully lodged"); + setTimeout(function() { + window.location.replace('http://localhost:8000/complaint/caretaker'); + }, 1500); + + + }, + error : function (data,err){ + alert('Complaint successfully lodged ... '); + + } + }); + } + }; + function sub3(event) + { + var specific_location= $('input[name="specific_location"]').val(); + var Location = $('input[name="Location"]').val(); + var complaint_type = $('input[name="complaint_type"]').val() ; + var details =$('input[name="details"]').val() ; + var myfile = $('input[name="myfile"]').val(); + if(specific_location=="" || Location=="" || details=="" || complaint_type=="") + { + alert("Please fill all the details!"); + return; + } + else + { + event.preventDefault(); + $.ajax({ + type : 'POST', + url : '.', + data : { + 'specific_location' : specific_location, + 'Location' : Location, + 'complaint_type' : complaint_type, + 'details' : details, + 'myfile' : myfile, + + }, + success : function (data){ + + // alert("Complaint successfully lodged"); + setTimeout(function() { + window.location.replace('http://localhost:8000/complaint/supervisor'); + }, 1500); + + + }, + error : function (data,err){ + alert('Complaint successfully lodged ... '); + + } + }); + } + }; + + + @@ -767,3 +854,98 @@ $.fn.rating.settings = { }; })( jQuery, window, document ); + + +function paginate(tableId, rowsPerPage, paginationDiv) { + var currentPage = 1; + var tableRows = document.querySelectorAll('#' + tableId + ' tbody tr'); + var totalPages = Math.ceil(tableRows.length / rowsPerPage); + + function displayRows() { + var startIndex = (currentPage - 1) * rowsPerPage; + var endIndex = startIndex + rowsPerPage; + tableRows.forEach(function (row, index) { + if (index >= startIndex && index < endIndex) { + row.style.display = ''; + } else { + row.style.display = 'none'; + } + }); + } + + function generatePagination() { + var pagination = document.getElementById(paginationDiv); + pagination.innerHTML = ''; + + var maxPagesToShow = 5; + + // Calculate the range of pages to display + var startPage = Math.max(1, currentPage - Math.floor(maxPagesToShow / 2)); + var endPage = Math.min(totalPages, startPage + maxPagesToShow - 1); + + // Adjust startPage and endPage if needed + if (endPage - startPage < maxPagesToShow - 1) { + startPage = Math.max(1, endPage - maxPagesToShow + 1); + } + + // Create the backward scroll button + if (currentPage > 1) { + pagination.appendChild(createScrollButton('<')); + } + + // Create the page links + for (var i = startPage; i <= endPage; i++) { + pagination.appendChild(createPageLink(i)); + } + + // Create the forward scroll button + if (currentPage < totalPages) { + pagination.appendChild(createScrollButton('>')); + } +} + +function createScrollButton(label) { + var button = document.createElement('button'); + button.textContent = label; + button.addEventListener('click', function () { + if (label === '<') { + currentPage = Math.max(1, currentPage - 1); + } else { + currentPage = Math.min(totalPages, currentPage + 1); + } + displayRows(); + generatePagination(); + }); + return button; +} + + + function createPageLink(pageNumber) { + var link = document.createElement('a'); + link.href = '#'; + link.textContent = pageNumber; + link.style.display = 'inline-block'; + link.style.padding = '5px 10px'; + link.style.marginRight = '5px'; + link.style.color = '#333'; + link.style.textDecoration = 'none'; + link.style.border = '1px solid #ccc'; + link.style.borderRadius = '3px'; + + if (pageNumber === currentPage) { + link.style.backgroundColor = '#007bff'; + link.style.color = '#fff'; + } + + link.addEventListener('click', function () { + currentPage = parseInt(this.textContent); + displayRows(); + generatePagination(); + }); + + return link; + } + + displayRows(); + generatePagination(); +} \ No newline at end of file diff --git a/FusionIIIT/applications/complaint_system/urls.py b/FusionIIIT/applications/complaint_system/urls.py index b95605ade..2bd0c87e0 100644 --- a/FusionIIIT/applications/complaint_system/urls.py +++ b/FusionIIIT/applications/complaint_system/urls.py @@ -9,33 +9,30 @@ url(r'^$', views.check, name='complaint'), # url(r'^login/$', views.login1, name='complaint'), url(r'^user/$', views.user), - url(r'^user/caretakerfb/$' , views.caretaker_feedback), - url(r'^user/(?P[0-9]+)/$', views.submitfeedback), url(r'^user/detail/(?P[0-9]+)/$', views.detail,name='detail'), - # url(r'^user/check_complaint/$', views.save_comp), - + # url(r'^user/check_complaint/$', views.save_comp), # caretaker + url(r'^caretaker/lodge/$', views.caretakerlodge), url(r'^caretaker/$', views.caretaker, name='caretaker'), url(r'^caretaker/feedback/(?P[0-9]+)/$', views.feedback_care), - url(r'^caretaker/worker_id_know_more/(?P[0-9]+)/complaint_reassign/(?P[0-9]+)/discharge_worker/$', views.discharge_worker,name='discharge_worker'), - url(r'^caretaker/worker_id_know_more/(?P[0-9]+)/$', views.worker_id_know_more, name='come_back_to_this'), - url(r'^caretaker/worker_id_know_more/(?P[0-9]+)/complaint_reassign/(?P[0-9]+)/$', views.complaint_reassign), - #url(r'^caretaker/list_caretakers_area/$', views.caretaker, name='caretaker'), url(r'^caretaker/pending/(?P[0-9]+)/$', views.resolvepending), - url(r'^caretaker/detail2/(?P[0-9]+)/$', views.detail2,name='detail2'), + url(r'^caretaker/detail2/(?P[0-9]+)/$', views.detail), url(r'^caretaker/search_complaint$', views.search_complaint), + url(r'^caretaker/(?P[0-9]+)/feedback/$', views.submitfeedbackcaretaker), # supervisor + url(r'^supervisor/lodge/$', views.supervisorlodge), url(r'^supervisor/$', views.supervisor), url(r'^supervisor/feedback/(?P[0-9]+)/$', views.feedback_super), url(r'^supervisor/caretaker_id_know_more/(?P[0-9]+)/$', views.caretaker_id_know_more), - url(r'^supervisor/caretaker_id_know_more/(?P[0-9]+)/complaint_reassign_super/(?P[0-9]+)/$', views.complaint_reassign_super, name = 'complaint_reassign_super'), - url(r'^supervisor/detail3/(?P[0-9]+)/$', views.detail3, name = 'detail3'), - + # url(r'^supervisor/caretaker_id_know_more/(?P[0-9]+)/complaint_reassign_super/(?P[0-9]+)/$', views.complaint_reassign_super, name = 'complaint_reassign_super'), + url(r'^supervisor/detail/(?P[0-9]+)/$', views.detail3, name = 'detail3'), + url(r'^supervisor/pending/(?P[0-9]+)/$', views.resolvependingsuper), + url(r'^supervisor/(?P[0-9]+)/$', views.submitfeedbacksuper), @@ -45,6 +42,7 @@ url(r'^caretaker/deletecomplaint/(?P[0-9]+)/$', views.deletecomplaint), # url(r'^caretaker/(?P[0-9]+)/$', views.assign_worker), url(r'^caretaker/(?P[0-9]+)/(?P[0-9]+)/$', views.changestatus), + url(r'^supervisor/(?P[0-9]+)/(?P[0-9]+)/$', views.changestatussuper), url(r'^api/',include('applications.complaint_system.api.urls')) diff --git a/FusionIIIT/applications/complaint_system/views.py b/FusionIIIT/applications/complaint_system/views.py index b566856aa..9d3dd7316 100644 --- a/FusionIIIT/applications/complaint_system/views.py +++ b/FusionIIIT/applications/complaint_system/views.py @@ -10,96 +10,85 @@ from applications.globals.models import User , ExtraInfo, HoldsDesignation from notifications.models import Notification -from .models import Caretaker, StudentComplain, Supervisor, Workers +from .models import Caretaker, StudentComplain, Supervisor, Workers, SectionIncharge from notification.views import complaint_system_notif -#function for reassign to another worker -@login_required -def complaint_reassign(request,wid,iid): - current_user = get_object_or_404(User, username=request.user.username) - y = ExtraInfo.objects.all().select_related('user','department').filter(user=current_user).first() - if request.method == 'POST': - type = request.POST.get('submit', '') - a = get_object_or_404(User, username=request.user.username) - y = ExtraInfo.objects.all().select_related('user','department').filter(user=a).first() - comp_id = y.id - if type == 'assign': - - complaint_finish = request.POST.get('complaint_finish', '') - worker_id = request.POST.get('assign_worker', '') - w = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').get(id=worker_id) - StudentComplain.objects.select_for_update().filter(id=iid).\ - update(worker_id=w, status=1) - url = '/complaint/caretaker/worker_id_know_more/'+wid; - complainer_details = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').get(id=iid) - student=0 - message = "Your complaint has been re-assigned" - complaint_system_notif(request.user, complainer_details.complainer.user ,'reassign_worker_alert',complainer_details.id,student,message) - return HttpResponseRedirect(url) - elif type == 'redirect': - assign_caretaker = request.POST.get('assign_caretaker', '') - c = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').get(id=assign_caretaker) - c1 = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').get(id=iid) - remark = 'Redirect complaint from ' + c1.area - StudentComplain.objects.select_for_update().filter(id=iid).\ - update(location=c.area, remarks=remark) - url = '/complaint/caretaker/worker_id_know_more/'+wid; - complainer_details = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').get(id=iid) - student=0 - message = "Your complaint has been redirected to another caretaker" - complaint_system_notif(request.user, complainer_details.complainer.user ,'comp_redirect_alert',complainer_details.id,student,message) - return HttpResponseRedirect(url) - - else: - y = ExtraInfo.objects.all().select_related('user','department').get(id=y.id) - a = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').get(staff_id=y) - b = a.area - comp_id = y.id - try: - detail = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(id=iid).first() - total_caretaker = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').all() - total_caretakers_in_area = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').filter(area=b) - worker = [] - workertemp = [] - flag = '' - temp = detail.location - try: - - if Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').filter(caretaker_id=a).count() == 0: - flag = 'no_worker' - else: - workertemp = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').filter(caretaker_id=a) - j = 1 - for i in workertemp: - worker.append(i) - # if j%2 != 0: - # worker.append(i) - # j = j + 1 - - - except Caretaker.DoesNotExist: - flag = 'no_worker' - - except StudentComplain.DoesNotExist: - return HttpResponse("

Not a valid complaint

") - return render(request, "complaintModule/reassignworker.html", - {'detail': detail, 'worker': worker, 'flag': - flag, 'total_caretaker': total_caretaker,'a':a, 'wid':wid, 'total_caretakers_in_area':total_caretakers_in_area}) - -@login_required -def complaint_reassign_super(request,caretaker_id,iid): - current_user = get_object_or_404(User, username=request.user.username) - y = ExtraInfo.objects.all().select_related('user','department').filter(user=current_user).first() - sup = Supervisor.objects.select_related('sup_id','sup_id__user','sup_id__department').get(sup_id = y) - this_area = sup.area - if request.method == 'POST': - a = get_object_or_404(User, username=request.user.username) - y = ExtraInfo.objects.all().select_related('user','department').filter(user=a).first() - comp_id = y.id - - +from applications.filetracking.sdk.methods import * +from applications.filetracking.models import * +from operator import attrgetter +#function for reassign to another worker +# @login_required +# def complaint_reassign(request,wid,iid): + # current_user = get_object_or_404(User, username=request.user.username) + # y = ExtraInfo.objects.all().select_related('user','department').filter(user=current_user).first() + # if request.method == 'POST': + # type = request.POST.get('submit', '') + # a = get_object_or_404(User, username=request.user.username) + # y = ExtraInfo.objects.all().select_related('user','department').filter(user=a).first() + # comp_id = y.id + # if type == 'assign': + + # complaint_finish = request.POST.get('complaint_finish', '') + # worker_id = request.POST.get('assign_worker', '') + # w = Workers.objects.select_related('secincharge_id','secincharge_id__staff_id','secincharge_id__staff_id__user','secincharge_id__staff_id__department').get(id=worker_id) + # StudentComplain.objects.select_for_update().filter(id=iid).\ + # update(worker_id=w, status=1) + # url = '/complaint/secincharge/worker_id_know_more/'+wid; + # complainer_details = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').get(id=iid) + # student=0 + # message = "Your complaint has been re-assigned" + # complaint_system_notif(request.user, complainer_details.complainer.user ,'reassign_worker_alert',complainer_details.id,student,message) + # return HttpResponseRedirect(url) + + # else: + # y = ExtraInfo.objects.all().select_related('user','department').get(id=y.id) + # a = SectionIncharge.objects.select_related('staff_id','staff_id__user','staff_id__department').get(staff_id=y) + # b = a.work_type + # comp_id = y.id + # try: + # detail = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=iid).first() + # total_secincharge = SectionIncharge.objects.select_related('staff_id','staff_id__user','staff_id__department').all() + # total_secincharges_in_area = SectionIncharge.objects.select_related('staff_id','staff_id__user','staff_id__department').filter(work_type=b) + # worker = [] + # workertemp = [] + # flag = '' + # temp = detail.location + # try: + + # if Workers.objects.select_related('secincharge_id','secincharge_id__staff_id','secincharge_id__staff_id__user','secincharge_id__staff_id__department').filter(secincharge_id=a).count() == 0: + # flag = 'no_worker' + # else: + # workertemp = Workers.objects.select_related('secincharge_id','secincharge_id__staff_id','secincharge_id__staff_id__user','secincharge_id__staff_id__department').filter(secincharge_id=a) + # j = 1 + # for i in workertemp: + # worker.append(i) + + # except SectionIncharge.DoesNotExist: + # flag = 'no_worker' + + # except StudentComplain.DoesNotExist: + # return HttpResponse("

Not a valid complaint

") + # return render(request, "complaintModule/reassignworker.html", + # {'detail': detail, 'worker': worker, 'flag': + # flag, 'total_secincharge': total_secincharge,'a':a, 'wid':wid, 'total_secincharges_in_area':total_secincharges_in_area}) + + + +# @login_required +# def complaint_reassign_super(request,caretaker_id,iid): + # current_user = get_object_or_404(User, username=request.user.username) + # y = ExtraInfo.objects.all().select_related('user','department').filter(user=current_user).first() + # sup = Supervisor.objects.select_related('sup_id','sup_id__user','sup_id__department').get(sup_id = y) + # this_area = sup.area + # if request.method == 'POST': + # a = get_object_or_404(User, username=request.user.username) + # y = ExtraInfo.objects.all().select_related('user','department').filter(user=a).first() + # comp_id = y.id + + +#for SectionIncharge @login_required def assign_worker(request, comp_id1): current_user = get_object_or_404(User, username=request.user.username) @@ -121,88 +110,89 @@ def assign_worker(request, comp_id1): a = get_object_or_404(User, username=request.user.username) y = ExtraInfo.objects.all().select_related('user','department').filter(user=a).first() comp_id = y.id - if type == 'assign': - complaint_finish = request.POST.get('complaint_finish', '') - worker_id = request.POST.get('assign_worker', '') - w = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').get(id=worker_id) - StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').select_for_update().filter(id=comp_id1).\ - update(worker_id=w, status=1) - complainer_details = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').get(id=comp_id1) - student = 0 - message = "Worker has been assigned to your complaint" - complaint_system_notif(request.user, complainer_details.complainer.user ,'assign_worker_alert',complainer_details.id,student,message) - - return HttpResponseRedirect('/complaint/caretaker/') - elif type == 'redirect': - assign_caretaker = request.POST.get('assign_caretaker', '') - c = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').get(id=assign_caretaker) - c1 = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').get(id=comp_id) - remark = 'Redirect complaint from ' + c1.area - StudentComplain.objects.select_for_update().filter(id=comp_id1).\ - update(location=c.area, remarks=remark) - complainer_details = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').get(id=comp_id1) - student=0 - message = "Your Complaint has been redirected to another caretaker" - complaint_system_notif(request.user, complainer_details.complainer.user ,'comp_redirect_alert',complainer_details.id,student,message) - return HttpResponseRedirect('/complaint/caretaker/') + + + complaint_details = StudentComplain.objects.all().filter(id=comp_id1) + + + + complaint_type=complaint_details[0].complaint_type + + supervisor=Supervisor.objects.all().filter(type=complaint_type) + if not supervisor.exists(): + return HttpResponse("

Supervisor does not exist of this complaint type

") + + supervisor_details=ExtraInfo.objects.all().filter(id=supervisor[0].sup_id.id) + + StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(id=comp_id1).\ + update(status=1) + + sup = HoldsDesignation.objects.select_related('user','working','designation').filter(user = supervisor_details[0].user_id) + + + files=File.objects.all().filter(src_object_id=comp_id1) + + supervisor_username=User.objects.all().filter(id=supervisor_details[0].user_id) + file=forward_file(file_id= files.first().id, + receiver=supervisor_username[0].username, + receiver_designation=sup[0].designation, + file_extra_JSON= {}, + remarks = "", + file_attachment= None) + print(file) + + + return HttpResponseRedirect('/complaint/caretaker/') else: y = ExtraInfo.objects.all().select_related('user','department').get(id=y.id) - a = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').get(staff_id=y) - b = a.area + # a = SectionIncharge.objects.select_related('staff_id','staff_id__user','staff_id__department').get(staff_id=y) + comp_id = y.id try: - detail = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(id=comp_id1).first() - total_caretaker = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').all() - total_caretakers_in_area = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').filter(area=b and id!=a.id) - workertemp = [] - worker = [] - flag = '' - temp = detail.location - try: - #care = Caretaker.objects.filter(area=temp).first() - if Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').filter(caretaker_id=a).count() == 0: - flag = 'no_worker' - else: - workertemp1 = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').filter(caretaker_id=a) - workertemp = workertemp1.filter(worker_type=detail.complaint_type) - j = 1 - for i in workertemp: - worker.append(i) - # if j%2 != 0: - # worker.append(i) - # j = j + 1 - - - except Caretaker.DoesNotExist: - flag = 'no_worker' + detail = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=comp_id1).first() + # total_caretaker = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').all() + # total_caretakers_in_area = Supervisor.objects.select_related('sup_id') + # supervisors_in_area= HoldsDesignation.objects.select_related('user','working','designation').get(total_caretakers_in_area = dsgn) + # workertemp = [] + # worker = [] + # flag = '' + # temp = detail.location + # try: + # if Workers.objects.select_related('secincharge_id','secincharge_id__staff_id','secincharge_id__staff_id__user','secincharge_id__staff_id__department').filter(secincharge_id=a).count() == 0: + # flag = 'no_worker' + # else: + # workertemp1 = Workers.objects.select_related('secincharge_id','secincharge_id__staff_id','secincharge_id__staff_id__user','secincharge_id__staff_id__department').filter(secincharge_id=a) + # workertemp = workertemp1.filter(worker_type=detail.complaint_type) + # j = 1 + # for i in workertemp: + # worker.append(i) + + # except SectionIncharge.DoesNotExist: + # flag = 'no_worker' except StudentComplain.DoesNotExist: return HttpResponse("

Not a valid complaint

") return render(request, "complaintModule/assignworker.html", - {'detail': detail, 'worker': worker, 'flag': - flag, 'total_caretaker': total_caretaker,'a':a, 'total_caretakers_in_area':total_caretakers_in_area}) + {'detail': detail}) + +#for SectionIncharge @login_required def discharge_worker(request,wid,cid): current_user = get_object_or_404(User, username=request.user.username) y = ExtraInfo.objects.all().select_related('user','department').filter(user=current_user).first() - this_worker = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').get(id=wid) - com_in_concern= StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').get(id=cid); + this_worker = Workers.objects.select_related('secincharge_id','secincharge_id__staff_id','secincharge_id__staff_id__user','secincharge_id__staff_id__department').get(id=wid) + com_in_concern= StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').get(id=cid); com_in_concern.worker_id=None; com_in_concern.status=0; StudentComplain.objects.select_for_update().filter(id=cid).\ update(worker_id=None, status=0) - #StudentComplain.objects.get(id=cid).delete() - url='/complaint/caretaker/detail2/'+cid; + url='/complaint/secincharge/detail2/'+cid; return HttpResponseRedirect(url) - - - - @login_required def caretaker_feedback(request): """ @@ -234,23 +224,23 @@ def caretaker_feedback(request): return render(request, "complaintModule/submit_feedback_caretaker.html", {'a': a}) +#for SectionIncharge @login_required def worker_id_know_more(request, work_id): """ function to know pending complaints assigned to the worker """ - this_worker = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').get(id=work_id) - num = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(worker_id=this_worker).count(); - complaints_list = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(worker_id=this_worker); + this_worker = Workers.objects.select_related('secincharge_id','secincharge_id__staff_id','secincharge_id__staff_id__user','secincharge_id__staff_id__department').get(id=work_id) + num = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(worker_id=this_worker).count(); + complaints_list = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(worker_id=this_worker); complaints_list_onhold = [] for i in complaints_list: if i.status == 1: complaints_list_onhold.append(i) numpend = len(complaints_list_onhold) - work_under_caretaker1 = this_worker.caretaker_id.staff_id.user.first_name - work_under_caretaker2 = this_worker.caretaker_id.staff_id.user.last_name - return render(request, "complaintModule/worker_id_know_more.html",{'this_worker':this_worker,'work_under_caretaker1':work_under_caretaker1,'work_under_caretaker2':work_under_caretaker2, 'num':num, 'complaints_list':complaints_list, 'complaints_list_onhold':complaints_list_onhold, 'numpend':numpend}) - + work_under_secincharge1 = this_worker.secincharge_id.staff_id.user.first_name + work_under_secincharge2 = this_worker.secincharge_id.staff_id.user.last_name + return render(request, "complaintModule/worker_id_know_more.html",{'this_worker':this_worker,'work_under_secincharge1':work_under_secincharge1,'work_under_secincharge2':work_under_secincharge2, 'num':num, 'complaints_list':complaints_list, 'complaints_list_onhold':complaints_list_onhold, 'numpend':numpend}) @@ -283,12 +273,31 @@ def check(request): print('----------------------------') print('----------------------------') print('----------------------------') - if b.user_type == 'student': + supervisor_list=Supervisor.objects.all() + caretaker_list=Caretaker.objects.all() + is_supervisor=False + is_caretaker=False + for i in supervisor_list: + if b.id==i.sup_id_id: + is_supervisor=True + break + for i in caretaker_list: + if b.id==i.staff_id_id: + is_caretaker=True + break + if is_supervisor: + return HttpResponseRedirect('/complaint/supervisor/') + elif is_caretaker: + return HttpResponseRedirect('/complaint/caretaker/') + + elif b.user_type == 'student': return HttpResponseRedirect('/complaint/user/') + # elif b.user_type == 'fx': + # return HttpResponseRedirect('/complaint/supervisor/') elif b.user_type == 'staff': - return HttpResponseRedirect('/complaint/caretaker/') + return HttpResponseRedirect('/complaint/user/') elif b.user_type == 'faculty': - return HttpResponseRedirect('/complaint/supervisor/') + return HttpResponseRedirect('/complaint/user/') else: return HttpResponse("

wrong user credentials

") else: @@ -338,20 +347,11 @@ def user(request): complaint_finish = datetime.now() + timedelta(days=4) elif comp_type == 'other': complaint_finish = datetime.now() + timedelta(days=3) - y = ExtraInfo.objects.all().select_related('user','department').get(id=comp_id) - #check if location given + if location!="": - # x = StudentComplain(complainer=y, - # complaint_type=comp_type, - # location=location, - # specific_location=specific_location, - # details=details, - # status=status, - # complaint_finish=complaint_finish, - # upload_complaint=comp_file) - - - # x.save() + + user_details=User.objects.get(id=y.user_id) + obj1, created = StudentComplain.objects.get_or_create(complainer=y, complaint_type=comp_type, location=location, @@ -361,27 +361,11 @@ def user(request): complaint_finish=complaint_finish, upload_complaint=comp_file) - - historytemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(complainer=y).order_by('-id') - history = [] - j = 1 - k = 1 - for i in historytemp: - history.append(i) - # if j%2 != 0: - # history.append(i) - # j = j+1 - - for h in history: - h.serial_no = k - k = k+1 - # if location == "hall1": - # dsgn = "hall1caretaker" - # elif location == "hall3": - # dsgn = "hall3caretaker" - # else : - # dsgn = "hall4caretaker" + + + + if location == "hall-1": dsgn ="hall1caretaker" elif location =="hall-3": @@ -408,24 +392,38 @@ def user(request): dsgn = "rewacaretaker" caretaker_name = HoldsDesignation.objects.select_related('user','working','designation').get(designation__name = dsgn) + c1=HoldsDesignation.objects.filter(user_id=y.user_id).all() + print(c1[0].designation) + file_id = create_file(uploader=user_details.username, + uploader_designation=c1[0].designation, + receiver=caretaker_name.user.username, + receiver_designation=caretaker_name.designation, + src_module="complaint", + src_object_id= str(obj1.id), + file_extra_JSON= {}, + attached_file = None) + + # print(" wertyuioiuhygfdsdfghjk") + print(file_id) # This is to allow the student - student = 1 + student = 0 message = "A New Complaint has been lodged" complaint_system_notif(request.user, caretaker_name.user,'lodge_comp_alert',obj1.id,student,message) - - # return render(request, "complaintModule/complaint_user.html", - # {'history': history, 'comp_id': comp_id }) - # next = request.POST.get('next', '/') + # complaint_system_notif(request.user, secincharge_name.staff_id.user,'lodge_comp_alert',obj1.id,1,message) messages.success(request,message) + + + return HttpResponseRedirect('/complaint/user') else: a = get_object_or_404(User, username=request.user.username) y = ExtraInfo.objects.all().select_related('user','department').filter(user=a).first() - historytemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(complainer=y).order_by('-id') - history=[] + + user_details=User.objects.get(id=y.user_id) + notification = Notification.objects.filter(recipient=a.id) notification = notification.filter(data__exact={'url':'complaint:detail','module':'Complaint System'}) @@ -437,45 +435,54 @@ def user(request): # notification_message.append(notification.verb+' by '+ to + ' ' + duration + ' ago ') + c1=HoldsDesignation.objects.filter(user_id=y.user_id).all() + print(c1[0].designation) + # c2=Designation.objects.filter(i) - - j = 1 - for i in historytemp: - history.append(i) - # if j%2 != 0: - # history.append(i) - # j = j+1 - - for i in history: - i.serial_no = j - j = j+1 - - # if location == "hall-1": - # dsgn ="hall1caretaker" - # elif location =="hall-3": - # dsgn ="hall3caretaker" - # elif location =="hall-4": - # dsgn ="hall4caretaker" - # elif location =="CC1": - # dsgn ="CC convenor" - # elif location =="CC2": - # dsgn ="CC2 convener" - # elif location == "core_lab": - # dsgn = "corelabcaretaker" - # elif location =="LHTC": - # dsgn ="lhtccaretaker" - # elif location =="NR2": - # dsgn ="nr2caretaker" - # else: - # dsgn = "rewacaretaker" - # caretaker_name = HoldsDesignation.objects.get(designation__name = dsgn) + + - # complaint_system_notif(request.user, caretaker_name.user,'lodge_comp_alert') + outbox_files = view_outbox( + username=user_details.username, + designation=c1[0].designation, + src_module="complaint" + ) + print(outbox_files) + + outbox=[] + comp_list=set() + for i in outbox_files: + + outbox.append(i) + print(outbox) + for i in outbox: + file_history = view_history(file_id=i['id']) + print(i['id']) + comp=File.objects.filter(id=i['id']) + print(comp[0].src_object_id) + complaint=StudentComplain.objects.all().filter(id=comp[0].src_object_id) + print(complaint) + if complaint[0].complainer.user.username == user_details.username : + comp_list.add(complaint) + # file_history = view_history(file_id=i['id']) + + # comp=File.objects.filter(uploader=file_history[0]['current_id']) + # for j in comp: + # c=StudentComplain.objects.all().filter(id=j.src_object_id) + # comp_list.add(c) + # print(c[0]) + + # break + complaint_final_list=[] + for i in comp_list: + complaint_final_list.append(i[0]) + + sorted_history = sorted(complaint_final_list, key=attrgetter('complaint_date'), reverse=True) + print(complaint_final_list) return render(request, "complaintModule/complaint_user.html", - {'history': history,'notification':notification, 'comp_id': y.id}) + {'outbox': sorted_history,'notification':notification, 'comp_id': y.id, 'history':outbox}) + - return render(request, "complaintModule/complaint_user.html", - {'history': history, 'comp_id': comp_id }) @login_required def save_comp(request): """ @@ -523,14 +530,15 @@ def save_comp(request): upload_complaint =comp_file) x.save() - # messages.info(request,'Complaint successfully launched.') - # return HttpResponseRedirect('/complaint/user/') + return HttpResponseRedirect('/complaint/user/') + + @login_required def caretaker(request): """ - The function is used to display details to the caretaker such as registered complaints and allows to assign workers + The function is used to display details to the caretaker such as registered complaints @param: request - trivial. @@ -543,21 +551,21 @@ def caretaker(request): """ current_user = get_object_or_404(User, username=request.user.username) y = ExtraInfo.objects.all().select_related('user','department').filter(user=current_user).first() - + if request.method == 'POST': - type = request.POST.get('submit', '') - worker_type = request.POST.get('complaint_type', '') - name = request.POST.get('name', '') - phone = request.POST.get('phone_no', '') - age = request.POST.get('age', '') - try: - y = ExtraInfo.objects.all().select_related('user','department').get(id=y.id) - a = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').get(staff_id=y) - except Exception as e: - a = None - y = None - intage = int(age) - intphone = int(phone) + # type = request.POST.get('submit', '') + # worker_type = request.POST.get('complaint_type', '') + # name = request.POST.get('name', '') + # phone = request.POST.get('phone_no', '') + # age = request.POST.get('age', '') + # try: + # y = ExtraInfo.objects.all().select_related('user','department').get(id=y.id) + # a = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').get(staff_id=y) + # except Exception as e: + # a = None + # y = None + # intage = int(age) + # intphone = int(phone) # if len(phone) == 10 and intage > 20 and intage < 50 and intphone > 1999999999: # x = Workers(caretaker_id=a, # name=name, @@ -567,116 +575,252 @@ def caretaker(request): # if not Workers.objects.filter(caretaker_id=a,name=name, age=age,phone=phone,worker_type=worker_type).exists(): # x.save() - if len(phone) == 10 and intage > 20 and intage < 50 and intphone > 1999999999: - obj, created = Workers.objects.get_or_create(caretaker_id=a, - name=name, - age=age, - phone=phone, - worker_type=worker_type) - - b = a.area - historytemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(location=b).order_by('-id') - history = [] - j = 1 - k = 1 - for i in historytemp: - history.append(i) - # if j%2 == 1: - # history.append(i) - # j = j+1 - for h in history: - h.serial_no = k - k=k+1 + # if len(phone) == 10 and intage > 20 and intage < 50 and intphone > 1999999999: + # obj, created = Workers.objects.get_or_create(caretaker_id=a, + # name=name, + # age=age, + # phone=phone, + # worker_type=worker_type) + # b = a.area + # historytemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(location=b).order_by('-id') + # history = [] + # j = 1 + # k = 1 + # for i in historytemp: + # history.append(i) + # # if j%2 == 1: + # # history.append(i) + # # j = j+1 + + # for h in history: + # h.serial_no = k + # k=k+1 + user_details=User.objects.get(id=y.user_id) + # if user_details.username=="shyams": + # desgn="hall3caretaker" + # if user_details.username=="hall4caretaker": + # desgn="hall4caretaker" + + # total_worker = [] + - total_worker = [] - total_workertemp = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').filter(caretaker_id=a) - j = 1 + # total_workertemp = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').filter(caretaker_id=a) + # j = 1 # for i in total_workertemp: # if j%2 != 0: # total_worker.append(i) # j = j + 1 - for i in total_workertemp: - total_worker.append(i) + # for i in total_workertemp: + # total_worker.append(i) complaint_assign_no = [] + comp_type = request.POST.get('complaint_type', '') + location = request.POST.get('Location', '') + specific_location = request.POST.get('specific_location', '') + comp_file = request.FILES.get('myfile') + + details = request.POST.get('details', '') + status = 0 + # finish time is according to complaint type + complaint_finish = datetime.now() + timedelta(days=2) + if comp_type == 'Electricity': + complaint_finish = datetime.now() + timedelta(days=2) + elif comp_type == 'carpenter': + complaint_finish = datetime.now() + timedelta(days=2) + elif comp_type == 'plumber': + complaint_finish = datetime.now() + timedelta(days=2) + elif comp_type == 'garbage': + complaint_finish = datetime.now() + timedelta(days=1) + elif comp_type == 'dustbin': + complaint_finish = datetime.now() + timedelta(days=1) + elif comp_type == 'internet': + complaint_finish = datetime.now() + timedelta(days=4) + elif comp_type == 'other': + complaint_finish = datetime.now() + timedelta(days=3) + # y = ExtraInfo.objects.all().select_related('user','department').get(id=comp_id) + #check if location given + if location!="": + user_details=User.objects.get(id=y.user_id) + obj1, created = StudentComplain.objects.get_or_create(complainer=y, + complaint_type=comp_type, + location=location, + specific_location=specific_location, + details=details, + status=status, + complaint_finish=complaint_finish, + upload_complaint=comp_file) + + + if location == "hall-1": + dsgn ="hall1caretaker" + elif location =="hall-3": + dsgn ="hall3caretaker" + elif location =="hall-4": + dsgn ="hall4caretaker" + elif location =="CC1": + dsgn ="cc1convener" + elif location =="CC2": + dsgn ="CC2 convener" + elif location == "core_lab": + dsgn = "corelabcaretaker" + elif location =="LHTC": + dsgn ="lhtccaretaker" + elif location =="NR2": + dsgn ="nr2caretaker" + elif location =="Maa Saraswati Hostel": + dsgn ="mshcaretaker" + elif location =="Nagarjun Hostel": + dsgn ="nhcaretaker" + elif location =="Panini Hostel": + dsgn ="phcaretaker" + else: + dsgn = "rewacaretaker" + caretaker_name = HoldsDesignation.objects.select_related('user','working','designation').get(designation__name = dsgn) + print(caretaker_name.user.username) + print(user_details.username) + print(caretaker_name.designation) + + user_details=User.objects.get(id=y.user_id) + des=HoldsDesignation.objects.filter(user=user_details).all() + file_id = create_file(uploader=user_details.username, + uploader_designation=des[0].designation, + receiver=caretaker_name.user.username, + receiver_designation=dsgn, + src_module="complaint", + src_object_id= str(obj1.id), + file_extra_JSON= {}, + attached_file = None) + + + # This is to allow the student + student = 1 + message = "A New Complaint has been lodged" + complaint_system_notif(request.user, caretaker_name.user,'lodge_comp_alert',obj1.id,student,message) + + # return render(request, "complaintModule/complaint_user.html", + # {'history': history, 'comp_id': comp_id }) + # next = request.POST.get('next', '/') + + messages.success(request,message) + # return HttpResponseRedirect('/complaint/user') + - for x in total_worker: - worker = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').get(id=x.id) - temp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(worker_id=worker).count() - worker.total_complaint = temp - complaint_assign_no.append(worker) + # for x in total_worker: + # worker = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').get(id=x.id) + # temp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(worker_id=worker).count() + # worker.total_complaint = temp + # complaint_assign_no.append(worker) notification = Notification.objects.filter(recipient=current_user.id) notification = notification.filter(data__exact={'url':'complaint:detail2','module':'Complaint System'}) - return render(request, "complaintModule/complaint_caretaker.html", - {'history': history, 'comp_id': y.id, - 'notification': notification, 'total_worker': - total_worker, 'complaint_assign_no': complaint_assign_no}) + + return HttpResponseRedirect('/complaint/caretaker') else: - y = ExtraInfo.objects.all().select_related('user','department').get(id=y.id) - a = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').get(staff_id=y) + # y = ExtraInfo.objects.all().select_related('user','department').get(id=y.id) + + a = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').get(staff_id=y.id) b = a.area history = [] - historytemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(location=b).order_by('-id') - total_worker = [] - total_workertemp = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').filter(caretaker_id=a) - j = 1 - for i in total_workertemp: - total_worker.append(i) - - complaint_assign_no = [] + + complaint_assign_no = [] - - for x in total_worker: - worker = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').get(id=x.id) - temp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(worker_id=worker).count() - worker.total_complaint = temp - complaint_assign_no.append(worker) - - overduecomplaint = [] - j = 1 - k = 1 - for i in historytemp: - history.append(i) - # if j%2 != 0: - # history.append(i) - # j=j+1 - for i in history: - i.serial_no = k - k = k + 1 - - if i.status != 2 and i.status !=3: - if i.complaint_finish < date.today(): - i.delay = date.today() - i.complaint_finish - overduecomplaint.append(i) + user_details=User.objects.get(id=y.user_id) notification = Notification.objects.filter(recipient=current_user.id) notification = notification.filter(data__exact={'url':'complaint:detail2','module':'Complaint System'}) + user_details=User.objects.get(id=y.user_id) + - + des=HoldsDesignation.objects.filter(user=user_details).all() + print("######") + print(user_details.username) + print(des[0].designation) + print("&&&&&") + outbox_files = view_outbox( + username=user_details.username, + designation=des[0].designation, + src_module="complaint" + ) + + outbox=[] + comp_list=set() + for i in outbox_files: + # print(i) + outbox.append(i) + + for i in outbox: + file_history = view_history(file_id=i['id']) + print(i['id']) + print("********") + comp=File.objects.filter(id=i['id']) + print(comp[0].src_object_id) + print("------") + complaint=StudentComplain.objects.all().filter(id=comp[0].src_object_id) + print(complaint[0].complainer.user.username) + + print("......") + if complaint[0].complainer.user.username== user_details.username : + comp_list.add(complaint) + + # break + complaint_final_list=[] + for i in comp_list: + complaint_final_list.append(i[0]) + sorted_history_out = sorted(complaint_final_list, key=attrgetter('complaint_date'), reverse=True) + + inbox_files = view_inbox( + username=user_details.username, + designation=des[0].designation, + src_module="complaint" + ) + print(inbox_files) + + inbox=[] + comp_list_in=set() + for i in inbox_files: + # print(i) + inbox.append(i) + file_history_list=[] + for i in inbox: + file_history = view_history(file_id=i['id']) + print(i['id']) + comp=File.objects.filter(id=i['id']) + print(comp[0].src_object_id) + complaint=StudentComplain.objects.all().filter(id=comp[0].src_object_id) + print(complaint) + comp_list_in.add(complaint) + + complaint_final_list_in=[] + for i in comp_list_in: + complaint_final_list_in.append(i[0]) + + # print(complaint_final_list_in) + sorted_history = sorted(complaint_final_list_in, key=attrgetter('complaint_date'), reverse=True) + return render(request, "complaintModule/complaint_caretaker.html", - { 'history': history, 'comp_id': y.id, 'total_worker': total_worker, - 'complaint_assign_no': total_worker, - 'notification':notification, - 'overduecomplaint': overduecomplaint, 'care_id': a}) + { 'history': sorted_history, + 'comp_id': y.id, + 'carehistory':sorted_history_out, + 'notification':notification, + 'care_id': a}) @login_required def remove_worker_from_complaint(request,complaint_id): """ - The function is used by caretaker to remove a worker + The function is used by secincharge to remove a worker already assigned to a complaint @param: request - trivial complaint_id - used to get complaint_id registered """ - complaint = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(complaint_id=complaint_id).update(worker_id='') + complaint = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(complaint_id=complaint_id).update(worker_id='') return HttpResponseRedirect('/complaint/caretaker/') @@ -698,23 +842,54 @@ def changestatus(request, complaint_id, status): context - Holds data needed to make necessary changes in the template. """ if status == '3': - StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(id=complaint_id).\ + StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=complaint_id).\ update(status=status, worker_id='') return HttpResponseRedirect('/complaint/caretaker/') elif status == '2': - StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(id=complaint_id).\ + StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=complaint_id).\ update(status=status, worker_id='') return HttpResponseRedirect('/complaint/caretaker/') else: - StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(id=complaint_id).\ + StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=complaint_id).\ update(status=status) return HttpResponseRedirect('/complaint/caretaker/') + + +@login_required +def changestatussuper(request, complaint_id, status): + """ + The function is used by caretaker to change the status of a complaint. + @param: + request - trivial. + complaint_id - used to get complaint_id registered. + status-used to get the current status of complaints + + @variables: + issue - The issue object. + supported - True if the user's intention is to support the issue. + support_count - Total supporters of the above issue. + context - Holds data needed to make necessary changes in the template. + """ + if status == '3': + StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(id=complaint_id).\ + update(status=status, worker_id='') + return HttpResponseRedirect('/complaint/supervisor/') + elif status == '2': + StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(id=complaint_id).\ + update(status=status, worker_id='') + return HttpResponseRedirect('/complaint/supervisor/') + else: + StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(id=complaint_id).\ + update(status=status) + return HttpResponseRedirect('/complaint/supervisor/') + + @login_required def removew(request, work_id): """ - The function is used by caretaker to remove workers. + The function is used by secincharge to remove workers. @param: request - trivial. work_id - id of the issue object which the user intends to support/unsupport. @@ -725,15 +900,18 @@ def removew(request, work_id): support_count - Total supporters of the above issue. context - Holds data needed to make necessary changes in the template. """ - worker = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').get(id=work_id) - temp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(worker_id=worker).count() + worker = Workers.objects.select_related('secincharge_id','secincharge_id__staff_id','secincharge_id__staff_id__user','secincharge_id__staff_id__department').get(id=work_id) + temp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(worker_id=worker).count() if temp == 0: worker.delete() - return HttpResponseRedirect('/complaint/caretaker/') + return HttpResponseRedirect('/complaint/secincharge/') else: return HttpResponse('

Worker is assign some complaint

') + + + @login_required def submitfeedback(request, complaint_id): """ @@ -752,9 +930,9 @@ def submitfeedback(request, complaint_id): if request.method == 'POST': feedback = request.POST.get('feedback', '') rating = request.POST.get('rating', '') - StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(id=complaint_id).\ + StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=complaint_id).\ update(feedback=feedback, flag=rating) - a = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(id=complaint_id).first() + a = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=complaint_id).first() care = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').filter(area=a.location).first() rate = care.rating newrate = 0 @@ -768,27 +946,26 @@ def submitfeedback(request, complaint_id): Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').filter(area=a.location).update(rating=newrate) return HttpResponseRedirect('/complaint/user/') - return render(request,"complaintModule/feedback.html",{'a' : a}) else: - a = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').get(id=complaint_id) + a = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').get(id=complaint_id) return render(request, "complaintModule/submit_feedback.html", {'a': a}) - - +#for SectionIncharge @login_required def deletecomplaint(request, comp_id1): """ function to delete complaint """ StudentComplain.objects.get(id=comp_id1).delete() - return HttpResponseRedirect('/complaint/caretaker/') + return HttpResponseRedirect('/complaint/secincharge/') + + def testEntry(): - # list1 = [('SKM','hall-1'),('HS','hall-3'),('PS','hall-4'),('MSR','Maa Saraswati Hostel'),('KKB','Maa Saraswati Hostel'), ('RP','Nagarjun Hostel'),('DS','Nagarjun Hostel'),('AV','Panini Hostel')] list1 = [('eecivil','NR2'),('eecivil','Rewa_Residency'),('eecivil','LHTC'),('eecivil','core_lab')] # to delete supervisors @@ -820,9 +997,11 @@ def supervisor(request): """ # print("--------------------------") # testEntry() + # print(request.type) + location = request.POST.get('Location', '') current_user = get_object_or_404(User, username=request.user.username) - y = ExtraInfo.objects.all().select_related('user','department').filter(user=current_user).first() + comp_id = y.id if request.method == 'POST' : try: y = ExtraInfo.objects.all().select_related('user','department').get(id=y.id) @@ -830,78 +1009,231 @@ def supervisor(request): except Exception as e: a = None y = None - all_caretaker = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').filter(area=a.area).order_by('-id') + all_caretaker = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').filter(area=location).order_by('-id') area = all_caretaker[0].area # ExtraInfo.objects.get(id=sup_id) all_complaint = [] - numtemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(location = area).filter(status = 0).count() + numtemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(location = area).filter(status = 0).count() num = int(numtemp/2+0.5) - all_complainttemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(location=a.area).order_by('-id') - j = 1 - for i in all_complainttemp: - all_complaint.append(i) - # if j%2 != 0: - # all_complaint.append(i) - # j = j + 1 - overduecomplaint = [] - for i in all_complaint: - if i.status != 2 and i.status != 3: - if i.complaint_finish < date.today(): - i.delay = date.today() - i.complaint_finish - overduecomplaint.append(i) + + + + + + + comp_type = request.POST.get('complaint_type', '') + location = request.POST.get('Location', '') + specific_location = request.POST.get('specific_location', '') + comp_file = request.FILES.get('myfile') + + details = request.POST.get('details', '') + status = 0 + # finish time is according to complaint type + complaint_finish = datetime.now() + timedelta(days=2) + if comp_type == 'Electricity': + complaint_finish = datetime.now() + timedelta(days=2) + elif comp_type == 'carpenter': + complaint_finish = datetime.now() + timedelta(days=2) + elif comp_type == 'plumber': + complaint_finish = datetime.now() + timedelta(days=2) + elif comp_type == 'garbage': + complaint_finish = datetime.now() + timedelta(days=1) + elif comp_type == 'dustbin': + complaint_finish = datetime.now() + timedelta(days=1) + elif comp_type == 'internet': + complaint_finish = datetime.now() + timedelta(days=4) + elif comp_type == 'other': + complaint_finish = datetime.now() + timedelta(days=3) + y = ExtraInfo.objects.all().select_related('user','department').get(id=comp_id) + #check if location given + if location!="": + # x = StudentComplain(complainer=y, + # complaint_type=comp_type, + # location=location, + # specific_location=specific_location, + # details=details, + # status=status, + # complaint_finish=complaint_finish, + # upload_complaint=comp_file) + + + # x.save() + obj1, created = StudentComplain.objects.get_or_create(complainer=y, + complaint_type=comp_type, + location=location, + specific_location=specific_location, + details=details, + status=status, + complaint_finish=complaint_finish, + upload_complaint=comp_file) + + + + if location == "hall-1": + dsgn ="hall1caretaker" + elif location =="hall-3": + dsgn ="hall3caretaker" + elif location =="hall-4": + dsgn ="hall4caretaker" + elif location =="CC1": + dsgn ="cc1convener" + elif location =="CC2": + dsgn ="CC2 convener" + elif location == "core_lab": + dsgn = "corelabcaretaker" + elif location =="LHTC": + dsgn ="lhtccaretaker" + elif location =="NR2": + dsgn ="nr2caretaker" + elif location =="Maa Saraswati Hostel": + dsgn ="mshcaretaker" + elif location =="Nagarjun Hostel": + dsgn ="nhcaretaker" + elif location =="Panini Hostel": + dsgn ="phcaretaker" + else: + dsgn = "rewacaretaker" + caretaker_name = HoldsDesignation.objects.select_related('user','working','designation').get(designation__name = dsgn) + user_details=User.objects.get(id=y.user_id) + # c2=Supervisor.objects.all().filter(area=location) + print(caretaker_name.user.username) + print(user_details.username) + print(caretaker_name.designation) + + # sup = HoldsDesignation.objects.select_related('user','working','designation').get(user = y.id) + # print(sup.designation) + + user_details=User.objects.get(id=y.user_id) + des=HoldsDesignation.objects.filter(user=user_details).all() + + + file_id = create_file(uploader=user_details.username, + uploader_designation=des[0].designation, + receiver=caretaker_name.user.username, + receiver_designation=str(caretaker_name.designation), + src_module="complaint", + src_object_id= str(obj1.id), + file_extra_JSON= {}, + attached_file = None) + + + # This is to allow the student + student = 1 + message = "A New Complaint has been lodged" + complaint_system_notif(request.user, caretaker_name.user,'lodge_comp_alert',obj1.id,student,message) + + # return render(request, "complaintModule/complaint_user.html", + # {'history': history, 'comp_id': comp_id }) + # next = request.POST.get('next', '/') + + messages.success(request,message) + # return HttpResponseRedirect('/complaint/user') + + return HttpResponseRedirect('/complaint/supervisor') - return render(request, "complaintModule/supervisor1.html", - {'all_caretaker': all_caretaker, 'all_complaint': all_complaint, - 'overduecomplaint': overduecomplaint, 'area': area,'num':num}) else: - print('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx') - y = ExtraInfo.objects.all().select_related('user','department').get(id=y.id) - try: - a = get_object_or_404(Supervisor, sup_id=y) - except : - return HttpResponseRedirect('/') - - #print(a) - # if(len(a)==0) : - # return render('../dashboard/') - a = Supervisor.objects.select_related('sup_id','sup_id__user','sup_id__department').get(sup_id=y) - all_caretaker = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').filter(area=a.area).order_by('-id') + + + all_caretaker = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').order_by('-id') area = all_caretaker[0].area + numtemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(location = area).filter(status = 0).count() num = int(numtemp/2+0.5) all_complaint = [] - all_complainttemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(location=a.area).order_by('-id') - j = 1 - for i in all_complainttemp: - all_complaint.append(i) - # if j%2 != 0: - # all_complaint.append(i) - # j = j + 1 - overduecomplaint = [] - for i in all_complaint: - if i.status != 2 and i.status != 3: - if i.complaint_finish < date.today(): - i.delay = date.today() - i.complaint_finish - overduecomplaint.append(i) + user_details=User.objects.get(id=y.user_id) + + + + + current_user = get_object_or_404(User, username=request.user.username) + y = ExtraInfo.objects.all().select_related('user','department').filter(user=current_user).first() + user_details=User.objects.get(id=y.user_id) + des=HoldsDesignation.objects.filter(user=user_details).all() + # print(y.user_id) + # print(user_details.username) + # print(des[0].user) + outbox_files = view_outbox( + username=user_details.username, + designation=des[0].designation, + src_module="complaint" + ) + + outbox=[] + comp_list=set() + for i in outbox_files: + # print(i) + outbox.append(i) + + for i in outbox: + file_history = view_history(file_id=i['id']) + print(i['id']) + comp=File.objects.filter(id=i['id']) + print(comp[0].src_object_id) + complaint=StudentComplain.objects.all().filter(id=comp[0].src_object_id) + print(complaint) + comp_list.add(complaint) + # file_history = view_history(file_id=i['id']) + + # comp=File.objects.filter(uploader=file_history[0]['current_id']) + # for j in comp: + # c=StudentComplain.objects.all().filter(id=j.src_object_id) + # comp_list.add(c) + # print(c[0]) + + # break + complaint_final_list=[] + for i in comp_list: + complaint_final_list.append(i[0]) + sorted_history_out = sorted(complaint_final_list, key=attrgetter('complaint_date'), reverse=True) + + inbox_files = view_inbox( + username=user_details.username, + designation=des[0].designation, + src_module="complaint" + ) + inbox=[] + comp_list_in=set() + for i in inbox_files: + inbox.append(i) + # print(inbox[0]['id']) + + for i in inbox: + file_history = view_history(file_id=i['id']) + print(i['id']) + comp=File.objects.filter(id=i['id']) + print(comp[0].src_object_id) + complaint=StudentComplain.objects.all().filter(id=comp[0].src_object_id) + print(complaint) + comp_list_in.add(complaint) + # print(complaint[0]) + # for j in comp: + # c=StudentComplain.objects.all().filter(id=j.src_object_id) + # comp_list_in.add(c) + # print(c[0]) + + # break + complaint_final_list_in=[] + for i in comp_list_in: + complaint_final_list_in.append(i[0]) + + sorted_history = sorted(complaint_final_list_in, key=attrgetter('complaint_date'), reverse=True) + print(complaint_final_list_in) return render(request, "complaintModule/supervisor1.html", - {'all_caretaker': all_caretaker, 'all_complaint': all_complaint, - 'overduecomplaint': overduecomplaint, 'area': area, 'num' : num}) + + {'history':sorted_history,'all_caretaker': all_caretaker, 'all_complaint': all_complaint,'outbox':sorted_history_out}) @login_required def caretaker_id_know_more(request,caretaker_id): this_caretaker = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').get(id = caretaker_id) - this_caretaker_area = this_caretaker.area; + this_caretaker_area = this_caretaker.area list_pending_complaints = [] - list_pending_complaintstemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(location = this_caretaker_area).filter(status = 0) + list_pending_complaintstemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(location = this_caretaker_area).filter(status = 0) j = 1 for i in list_pending_complaintstemp: list_pending_complaints.append(i) - # if j%2 != 0: - # list_pending_complaints.append(i) - # j = j + 1 + - # num = StudentComplain.objects.filter(location = this_caretaker_area).filter(status = 0).count(); num = len(list_pending_complaints) return render(request, "complaintModule/caretaker_id_know_more.html",{'this_caretaker':this_caretaker , 'list_pending_complaints':list_pending_complaints, 'num':num}) @@ -911,6 +1243,36 @@ def search_complaint(request): @login_required def resolvepending(request, cid): + a = get_object_or_404(User, username=request.user.username) + y = ExtraInfo.objects.all().select_related('user','department').filter(user=a).first() + thiscomplaint = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').get(id=cid) + if request.method == 'POST': + newstatus = request.POST.get('yesorno','') + comment = request.POST.get('comment') + intstatus = 0 + if newstatus == 'Yes': + intstatus = 2 + else: + intstatus = 3 + StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=cid).\ + update(status=intstatus) + StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=cid).\ + update(comment=comment) + complainer_details = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').get(id=cid) + student=0 + message = "Congrats! Your complaint has been resolved" + complaint_system_notif(request.user, complainer_details.complainer.user ,'comp_resolved_alert',complainer_details.id,student,message) + return HttpResponseRedirect("/complaint/caretaker/") + else: + # complainer_details = StudentComplain.objects.get(id=cid) + # complaint_system_notif(request.user, complainer_details.complainer.user ,'comp_resolved_alert') + return render(request,"complaintModule/resolve_pending.html",{"a" : a,"thiscomplaint" : thiscomplaint}) + + + + +@login_required +def resolvependingsuper(request, cid): a = get_object_or_404(User, username=request.user.username) y = ExtraInfo.objects.all().select_related('user','department').filter(user=a).first() thiscomplaint = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').get(id=cid) @@ -930,7 +1292,37 @@ def resolvepending(request, cid): student=0 message = "Congrats! Your complaint has been resolved" complaint_system_notif(request.user, complainer_details.complainer.user ,'comp_resolved_alert',complainer_details.id,student,message) - return HttpResponseRedirect("/complaint/caretaker/") + return HttpResponseRedirect("/complaint/supervisor/") + else: + # complainer_details = StudentComplain.objects.get(id=cid) + # complaint_system_notif(request.user, complainer_details.complainer.user ,'comp_resolved_alert') + return render(request,"complaintModule/resolve_pending.html",{"a" : a,"thiscomplaint" : thiscomplaint}) + + + + +@login_required +def resolvependingsuper(request, cid): + a = get_object_or_404(User, username=request.user.username) + y = ExtraInfo.objects.all().select_related('user','department').filter(user=a).first() + thiscomplaint = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').get(id=cid) + if request.method == 'POST': + newstatus = request.POST.get('yesorno','') + comment = request.POST.get('comment') + intstatus = 0 + if newstatus == 'Yes': + intstatus = 2 + else: + intstatus = 3 + StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=cid).\ + update(status=intstatus) + StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=cid).\ + update(comment=comment) + complainer_details = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').get(id=cid) + student=0 + message = "Congrats! Your complaint has been resolved" + complaint_system_notif(request.user, complainer_details.complainer.user ,'comp_resolved_alert',complainer_details.id,student,message) + return HttpResponseRedirect("/complaint/supervisor/") else: # complainer_details = StudentComplain.objects.get(id=cid) # complaint_system_notif(request.user, complainer_details.complainer.user ,'comp_resolved_alert') @@ -938,6 +1330,7 @@ def resolvepending(request, cid): + def login1(request): if request.method == 'POST': u = request.POST.get('username', '') @@ -956,10 +1349,10 @@ def login1(request): @login_required def feedback_super(request, feedcomp_id): - detail3 = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').get(id=feedcomp_id) + detail3 = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').get(id=feedcomp_id) a=User.objects.get(username=detail3.complainer.user.username) y=ExtraInfo.objects.all().select_related('user','department').get(user=a) - temp=StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(complainer=y).first() + temp=StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(complainer=y).first() comp_id=temp.id loc = detail3.location care = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').filter(area=loc).first() @@ -968,47 +1361,49 @@ def feedback_super(request, feedcomp_id): @login_required def feedback_care(request, feedcomp_id): - detail2 = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').get(id=feedcomp_id) + detail2 = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').get(id=feedcomp_id) a=User.objects.get(username=detail2.complainer.user.username) y=ExtraInfo.objects.all().select_related('user','department').get(user=a) - temp=StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(complainer=y).first() + temp=StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(complainer=y).first() comp_id=temp.id return render(request, "complaintModule/feedback_care.html", {"detail2": detail2,"comp_id":comp_id}) - - +#for complainaint and caretaker @login_required def detail(request, detailcomp_id1): """ function that shows detail about complaint """ - detail = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').get(id=detailcomp_id1) + detail = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').get(id=detailcomp_id1) if(detail.worker_id is None): worker_name = None worker_id = detail.worker_id else: worker_id = detail.worker_id.id - worker = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').get(id=worker_id) + worker = Workers.objects.select_related('secincharge_id','secincharge_id__staff_id','secincharge_id__staff_id__user','secincharge_id__staff_id__department').get(id=worker_id) worker_name = worker.name a=User.objects.get(username=detail.complainer.user.username) y=ExtraInfo.objects.all().select_related('user','department').get(user=a) num=0 if detail.upload_complaint != "": num = 1 - temp=StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(complainer=y).first() + temp=StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(complainer=y).first() comp_id=temp.id return render(request, "complaintModule/complaint_user_detail.html", {"detail": detail, "comp_id":detail.id,"num":num,"worker_name":worker_name}) + + +#for SectionIncharge @login_required def detail2(request, detailcomp_id1): - detail2 = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').get(id=detailcomp_id1) + detail2 = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').get(id=detailcomp_id1) if(detail2.worker_id is None): worker_name = None worker_id = detail2.worker_id else: worker_id = detail2.worker_id.id - worker = Workers.objects.select_related('caretaker_id','caretaker_id__staff_id','caretaker_id__staff_id__user','caretaker_id__staff_id__department').get(id=worker_id) + worker = Workers.objects.select_related('secincharge_id','secincharge_id__staff_id','secincharge_id__staff_id__user','secincharge_id__staff_id__department').get(id=worker_id) worker_name = worker.name a=User.objects.get(username=detail2.complainer.user.username) y=ExtraInfo.objects.all().select_related('user','department').get(user=a) @@ -1016,20 +1411,474 @@ def detail2(request, detailcomp_id1): if detail2.upload_complaint != "": num = 1 - temp=StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(complainer=y).first() + temp=StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(complainer=y).first() comp_id=temp.id - return render(request, "complaintModule/complaint_caretaker_detail.html", {"detail2": detail2, "comp_id":detail2.id,"num":num,"worker_name":worker_name,"wid":worker_id}) + return render(request, "complaintModule/complaint_secincharge_detail.html", {"detail2": detail2, "comp_id":detail2.id,"num":num,"worker_name":worker_name,"wid":worker_id}) + @login_required def detail3(request, detailcomp_id1): - detail3 = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').get(id=detailcomp_id1) + detail3 = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').get(id=detailcomp_id1) a=User.objects.get(username=detail3.complainer.user.username) y=ExtraInfo.objects.all().select_related('user','department').get(user=a) num=0 if detail3.upload_complaint != "": num = 1 - temp=StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(complainer=y).first() + temp=StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(complainer=y).first() comp_id=temp.id loc = detail3.location care = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').filter(area=loc).first() return render(request, "complaintModule/complaint_supervisor_detail.html", {"detail3": detail3,"comp_id":comp_id,"care":care,"num":num}) + + + + +@login_required + +def supervisorlodge(request): + """ + The function is used to register a complaint + @param: + request - trivial. + + + @variables: + issue - The issue object. + supported - True if the user's intention is to support the issue. + support_count - Total supporters of the above issue. + context - Holds data needed to make necessary changes in the template. + """ + a = get_object_or_404(User, username=request.user.username) + y = ExtraInfo.objects.all().select_related('user','department').filter(user=a).first() + num = 1 + comp_id = y.id + if request.method == 'POST': + comp_type = request.POST.get('complaint_type', '') + location = request.POST.get('Location', '') + specific_location = request.POST.get('specific_location', '') + comp_file = request.FILES.get('myfile') + + details = request.POST.get('details', '') + status = 0 + # finish time is according to complaint type + complaint_finish = datetime.now() + timedelta(days=2) + if comp_type == 'Electricity': + complaint_finish = datetime.now() + timedelta(days=2) + elif comp_type == 'carpenter': + complaint_finish = datetime.now() + timedelta(days=2) + elif comp_type == 'plumber': + complaint_finish = datetime.now() + timedelta(days=2) + elif comp_type == 'garbage': + complaint_finish = datetime.now() + timedelta(days=1) + elif comp_type == 'dustbin': + complaint_finish = datetime.now() + timedelta(days=1) + elif comp_type == 'internet': + complaint_finish = datetime.now() + timedelta(days=4) + elif comp_type == 'other': + complaint_finish = datetime.now() + timedelta(days=3) + y = ExtraInfo.objects.all().select_related('user','department').get(id=comp_id) + #check if location given + if location!="": + # x = StudentComplain(complainer=y, + # complaint_type=comp_type, + # location=location, + # specific_location=specific_location, + # details=details, + # status=status, + # complaint_finish=complaint_finish, + # upload_complaint=comp_file) + + + # x.save() + obj1, created = StudentComplain.objects.get_or_create(complainer=y, + complaint_type=comp_type, + location=location, + specific_location=specific_location, + details=details, + status=status, + complaint_finish=complaint_finish, + upload_complaint=comp_file) + + + historytemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(complainer=y).order_by('-id') + history = [] + j = 1 + k = 1 + for i in historytemp: + history.append(i) + # if j%2 != 0: + # history.append(i) + # j = j+1 + + + for h in history: + h.serial_no = k + k = k+1 + # if location == "hall1": + # dsgn = "hall1caretaker" + # elif location == "hall3": + # dsgn = "hall3caretaker" + # else : + # dsgn = "hall4caretaker" + if location == "hall-1": + dsgn ="hall1caretaker" + elif location =="hall-3": + dsgn ="hall3caretaker" + elif location =="hall-4": + dsgn ="hall4caretaker" + elif location =="CC1": + dsgn ="cc1convener" + elif location =="CC2": + dsgn ="CC2 convener" + elif location == "core_lab": + dsgn = "corelabcaretaker" + elif location =="LHTC": + dsgn ="lhtccaretaker" + elif location =="NR2": + dsgn ="nr2caretaker" + elif location =="Maa Saraswati Hostel": + dsgn ="mshcaretaker" + elif location =="Nagarjun Hostel": + dsgn ="nhcaretaker" + elif location =="Panini Hostel": + dsgn ="phcaretaker" + else: + dsgn = "rewacaretaker" + caretaker_name = HoldsDesignation.objects.select_related('user','working','designation').get(designation__name = dsgn) + + + # This is to allow the student + student = 1 + message = "A New Complaint has been lodged" + complaint_system_notif(request.user, caretaker_name.user,'lodge_comp_alert',obj1.id,student,message) + + # return render(request, "complaintModule/complaint_user.html", + # {'history': history, 'comp_id': comp_id }) + # next = request.POST.get('next', '/') + + messages.success(request,message) + return HttpResponseRedirect('/complaint/supervisor') + + else: + a = get_object_or_404(User, username=request.user.username) + y = ExtraInfo.objects.all().select_related('user','department').filter(user=a).first() + historytemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(complainer=y).order_by('-id') + history=[] + + notification = Notification.objects.filter(recipient=a.id) + notification = notification.filter(data__exact={'url':'complaint:detail','module':'Complaint System'}) + # notification_message = [] + # for notification in x: + # to = User.objects.get(id=notification.actor_object_id).username + # from django.utils.timesince import timesince as timesince_ + # duration = timesince_(notification.timestamp,None) + # notification_message.append(notification.verb+' by '+ to + ' ' + duration + ' ago ') + + + + + j = 1 + for i in historytemp: + history.append(i) + # if j%2 != 0: + # history.append(i) + # j = j+1 + + for i in history: + i.serial_no = j + j = j+1 + + # if location == "hall-1": + # dsgn ="hall1caretaker" + # elif location =="hall-3": + # dsgn ="hall3caretaker" + # elif location =="hall-4": + # dsgn ="hall4caretaker" + # elif location =="CC1": + # dsgn ="CC convenor" + # elif location =="CC2": + # dsgn ="CC2 convener" + # elif location == "core_lab": + # dsgn = "corelabcaretaker" + # elif location =="LHTC": + # dsgn ="lhtccaretaker" + # elif location =="NR2": + # dsgn ="nr2caretaker" + # else: + # dsgn = "rewacaretaker" + # caretaker_name = HoldsDesignation.objects.get(designation__name = dsgn) + + # complaint_system_notif(request.user, caretaker_name.user,'lodge_comp_alert') + return render(request, "complaintModule/supervisor1.html", + {'history': history,'notification':notification, 'comp_id': y.id}) + + return render(request, "complaintModule/complaint_user.html", + {'history': history, 'comp_id': comp_id }) + + + + +@login_required +def submitfeedbacksuper(request, complaint_id): + """ + The function is used by the complainant to enter feedback after the complaint has been resolved + @param: + request - trivial. + complaint_id - id of the registerd complaint. + + @variables: + issue - The issue object. + supported - True if the user's intention is to support the issue. + support_count - Total supporters of the above issue. + context - Holds data needed to make necessary changes in the template. + """ + + if request.method == 'POST': + feedback = request.POST.get('feedback', '') + rating = request.POST.get('rating', '') + StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=complaint_id).\ + update(feedback=feedback, flag=rating) + a = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=complaint_id).first() + care = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').filter(area=a.location).first() + rate = care.rating + newrate = 0 + if rate == 0: + newrate = rating + else: + a1 = int(rating) + b1 = int(rate) + c1 = int((a1+b1)/2) + newrate = c1 + + Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').filter(area=a.location).update(rating=newrate) + return HttpResponseRedirect('/complaint/supervisor/') + return render(request,"complaintModule/feedback.html",{'a' : a}) + + else: + a = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').get(id=complaint_id) + return render(request, "complaintModule/submit_feedback.html", {'a': a}) + + + +@login_required + +def caretakerlodge(request): + """ + The function is used to register a complaint + @param: + request - trivial. + + + @variables: + issue - The issue object. + supported - True if the user's intention is to support the issue. + support_count - Total supporters of the above issue. + context - Holds data needed to make necessary changes in the template. + """ + a = get_object_or_404(User, username=request.user.username) + y = ExtraInfo.objects.all().select_related('user','department').filter(user=a).first() + num = 1 + comp_id = y.id + if request.method == 'POST': + comp_type = request.POST.get('complaint_type', '') + location = request.POST.get('Location', '') + specific_location = request.POST.get('specific_location', '') + comp_file = request.FILES.get('myfile') + + details = request.POST.get('details', '') + status = 0 + # finish time is according to complaint type + complaint_finish = datetime.now() + timedelta(days=2) + if comp_type == 'Electricity': + complaint_finish = datetime.now() + timedelta(days=2) + elif comp_type == 'carpenter': + complaint_finish = datetime.now() + timedelta(days=2) + elif comp_type == 'plumber': + complaint_finish = datetime.now() + timedelta(days=2) + elif comp_type == 'garbage': + complaint_finish = datetime.now() + timedelta(days=1) + elif comp_type == 'dustbin': + complaint_finish = datetime.now() + timedelta(days=1) + elif comp_type == 'internet': + complaint_finish = datetime.now() + timedelta(days=4) + elif comp_type == 'other': + complaint_finish = datetime.now() + timedelta(days=3) + y = ExtraInfo.objects.all().select_related('user','department').get(id=comp_id) + #check if location given + if location!="": + # x = StudentComplain(complainer=y, + # complaint_type=comp_type, + # location=location, + # specific_location=specific_location, + # details=details, + # status=status, + # complaint_finish=complaint_finish, + # upload_complaint=comp_file) + + + # x.save() + obj1, created = StudentComplain.objects.get_or_create(complainer=y, + complaint_type=comp_type, + location=location, + specific_location=specific_location, + details=details, + status=status, + complaint_finish=complaint_finish, + upload_complaint=comp_file) + + + historytemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(complainer=y).order_by('-id') + history = [] + j = 1 + k = 1 + for i in historytemp: + history.append(i) + # if j%2 != 0: + # history.append(i) + # j = j+1 + + + for h in history: + h.serial_no = k + k = k+1 + # if location == "hall1": + # dsgn = "hall1caretaker" + # elif location == "hall3": + # dsgn = "hall3caretaker" + # else : + # dsgn = "hall4caretaker" + if location == "hall-1": + dsgn ="hall1caretaker" + elif location =="hall-3": + dsgn ="hall3caretaker" + elif location =="hall-4": + dsgn ="hall4caretaker" + elif location =="CC1": + dsgn ="cc1convener" + elif location =="CC2": + dsgn ="CC2 convener" + elif location == "core_lab": + dsgn = "corelabcaretaker" + elif location =="LHTC": + dsgn ="lhtccaretaker" + elif location =="NR2": + dsgn ="nr2caretaker" + elif location =="Maa Saraswati Hostel": + dsgn ="mshcaretaker" + elif location =="Nagarjun Hostel": + dsgn ="nhcaretaker" + elif location =="Panini Hostel": + dsgn ="phcaretaker" + else: + dsgn = "rewacaretaker" + caretaker_name = HoldsDesignation.objects.select_related('user','working','designation').get(designation__name = dsgn) + + + # This is to allow the student + student = 1 + message = "A New Complaint has been lodged" + complaint_system_notif(request.user, caretaker_name.user,'lodge_comp_alert',obj1.id,student,message) + + # return render(request, "complaintModule/complaint_user.html", + # {'history': history, 'comp_id': comp_id }) + # next = request.POST.get('next', '/') + + messages.success(request,message) + return HttpResponseRedirect('/complaint/caretaker') + + else: + a = get_object_or_404(User, username=request.user.username) + y = ExtraInfo.objects.all().select_related('user','department').filter(user=a).first() + historytemp = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department','worker_id','worker_id__caretaker_id__staff_id','worker_id__caretaker_id__staff_id__user','worker_id__caretaker_id__staff_id__department').filter(complainer=y).order_by('-id') + history=[] + + notification = Notification.objects.filter(recipient=a.id) + notification = notification.filter(data__exact={'url':'complaint:detail','module':'Complaint System'}) + # notification_message = [] + # for notification in x: + # to = User.objects.get(id=notification.actor_object_id).username + # from django.utils.timesince import timesince as timesince_ + # duration = timesince_(notification.timestamp,None) + # notification_message.append(notification.verb+' by '+ to + ' ' + duration + ' ago ') + + + + + j = 1 + for i in historytemp: + history.append(i) + # if j%2 != 0: + # history.append(i) + # j = j+1 + + for i in history: + i.serial_no = j + j = j+1 + + # if location == "hall-1": + # dsgn ="hall1caretaker" + # elif location =="hall-3": + # dsgn ="hall3caretaker" + # elif location =="hall-4": + # dsgn ="hall4caretaker" + # elif location =="CC1": + # dsgn ="CC convenor" + # elif location =="CC2": + # dsgn ="CC2 convener" + # elif location == "core_lab": + # dsgn = "corelabcaretaker" + # elif location =="LHTC": + # dsgn ="lhtccaretaker" + # elif location =="NR2": + # dsgn ="nr2caretaker" + # else: + # dsgn = "rewacaretaker" + # caretaker_name = HoldsDesignation.objects.get(designation__name = dsgn) + + # complaint_system_notif(request.user, caretaker_name.user,'lodge_comp_alert') + return render(request, "complaintModule/complaint_caretaker.html", + {'history': history,'notification':notification, 'comp_id': y.id}) + + return render(request, "complaintModule/complaint_user.html", + {'history': history, 'comp_id': comp_id }) + + +@login_required +def submitfeedbackcaretaker(request, complaint_id): + """ + The function is used by the complainant to enter feedback after the complaint has been resolved + @param: + request - trivial. + complaint_id - id of the registerd complaint. + + @variables: + issue - The issue object. + supported - True if the user's intention is to support the issue. + support_count - Total supporters of the above issue. + context - Holds data needed to make necessary changes in the template. + """ + + if request.method == 'POST': + feedback = request.POST.get('feedback', '') + rating = request.POST.get('rating', '') + StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=complaint_id).\ + update(feedback=feedback, flag=rating) + a = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').filter(id=complaint_id).first() + care = Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').filter(area=a.location).first() + rate = care.rating + newrate = 0 + if rate == 0: + newrate = rating + else: + a1 = int(rating) + b1 = int(rate) + c1 = int((a1+b1)/2) + newrate = c1 + + Caretaker.objects.select_related('staff_id','staff_id__user','staff_id__department').filter(area=a.location).update(rating=newrate) + return HttpResponseRedirect('/complaint/caretaker/') + return render(request,"complaintModule/feedback.html",{'a' : a}) + + else: + a = StudentComplain.objects.select_related('complainer','complainer__user','complainer__department').get(id=complaint_id) + return render(request, "complaintModule/submit_feedback.html", {'a': a}) \ No newline at end of file diff --git a/FusionIIIT/applications/eis/models.py b/FusionIIIT/applications/eis/models.py index e55712ab9..b43ae974e 100644 --- a/FusionIIIT/applications/eis/models.py +++ b/FusionIIIT/applications/eis/models.py @@ -26,7 +26,7 @@ def get_absolute_url(self): class emp_techtransfer(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True,null=True) - pf_no = models.IntegerField() + pf_no = models.CharField(max_length=20) details = models.CharField(max_length=500, default=" ") date_entry = models.DateField(null=True, blank=True, default=datetime.datetime.now) start_date = models.DateField(null=True,blank=True) @@ -35,7 +35,7 @@ class emp_techtransfer(models.Model): class emp_session_chair(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True,null=True) - pf_no = models.IntegerField() + pf_no = models.CharField(max_length=20) name = models.CharField(max_length=500, default=" ") event = models.TextField(max_length=2500, default=" ") YEAR_CHOICES = [] @@ -57,7 +57,7 @@ def __str__(self): class emp_research_projects(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True,null=True) - pf_no = models.IntegerField() + pf_no = models.CharField(max_length=20) ptype = models.CharField(max_length=100, default="Research") pi = models.CharField(max_length=1000, default=" ") co_pi = models.CharField(max_length=1500, default=" ") @@ -82,7 +82,7 @@ def __str__(self): class emp_research_papers(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True,null=True) - pf_no = models.IntegerField() + pf_no = models.CharField(max_length=20) R_TYPE_CHOICES = ( ('Journal', 'Journal'), ('Conference', 'Conference'), @@ -133,7 +133,7 @@ def __str__(self): class emp_published_books(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True,null=True) - pf_no = models.IntegerField() + pf_no = models.CharField(max_length=20) PTYPE_TYPE_CHOICES = ( ('Book', 'Book'), ('Monograph', 'Monograph'), @@ -158,7 +158,7 @@ def __str__(self): class emp_patents(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True,null=True) - pf_no = models.IntegerField() + pf_no = models.CharField(max_length=20) p_no = models.CharField(max_length=150) title = models.CharField(max_length=1500) earnings = models.IntegerField(default=0) @@ -186,7 +186,7 @@ def __str__(self): class emp_mtechphd_thesis(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True,null=True) - pf_no = models.IntegerField() + pf_no = models.CharField(max_length=20) degree_type = models.IntegerField(default=1) title = models.CharField(max_length=250) supervisors = models.CharField(max_length=250) @@ -219,7 +219,7 @@ def __str__(self): class emp_keynote_address(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True,null=True) - pf_no = models.IntegerField() + pf_no = models.CharField(max_length=20) KEYNOTE_TYPE_CHOICES = ( ('Keynote', 'Keynote'), ('Plenary Address', 'Plenary Address'), @@ -248,7 +248,7 @@ def __str__(self): class emp_expert_lectures(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True,null=True) - pf_no = models.IntegerField() + pf_no = models.CharField(max_length=20) LECTURE_TYPE_CHOICES = ( ('Expert Lecture', 'Expert Lecture'), ('Invited Talk', 'Invited Talk'), @@ -273,7 +273,7 @@ def __str__(self): class emp_event_organized(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True,null=True) - pf_no = models.IntegerField() + pf_no = models.CharField(max_length=20) TYPE_CHOICES = ( ('Training Program', 'Training Program'), ('Seminar', 'Seminar'), @@ -301,7 +301,7 @@ def __str__(self): class emp_consultancy_projects(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True,null=True) - pf_no = models.IntegerField() + pf_no = models.CharField(max_length=20) consultants = models.CharField(max_length=150) title = models.CharField(max_length=1000) client = models.CharField(max_length=1000) @@ -323,7 +323,7 @@ def __str__(self): class emp_confrence_organised(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True,null=True) - pf_no = models.IntegerField() + pf_no = models.CharField(max_length=20) name = models.CharField(max_length=500) venue = models.CharField(max_length=500) YEAR_CHOICES = [] @@ -353,7 +353,7 @@ def __str__(self): class emp_achievement(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True,null=True) - pf_no = models.IntegerField() + pf_no = models.CharField(max_length=20) A_TYPE_CHOICES = ( ('Award', 'Award'), ('Honour', 'Honour'), diff --git a/FusionIIIT/applications/eis/views.py b/FusionIIIT/applications/eis/views.py index 76a4532c2..656eee099 100644 --- a/FusionIIIT/applications/eis/views.py +++ b/FusionIIIT/applications/eis/views.py @@ -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() diff --git a/FusionIIIT/applications/feeds/views.py b/FusionIIIT/applications/feeds/views.py index 4ef9c62c9..fea8f5f42 100644 --- a/FusionIIIT/applications/feeds/views.py +++ b/FusionIIIT/applications/feeds/views.py @@ -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 diff --git a/FusionIIIT/applications/filetracking/admin.py b/FusionIIIT/applications/filetracking/admin.py index 82b78df95..144ac4e2a 100644 --- a/FusionIIIT/applications/filetracking/admin.py +++ b/FusionIIIT/applications/filetracking/admin.py @@ -1,7 +1,23 @@ from django.contrib import admin +from .models import File, Tracking -# Register your models here. -from applications.filetracking.models import File, Tracking -admin.site.register(File) -admin.site.register(Tracking) +class FileAdmin(admin.ModelAdmin): + list_display = ('uploader', 'designation', + 'subject', 'upload_date', 'is_read') + search_fields = ('uploader__user__username', 'subject', 'description') + list_filter = ('is_read',) + + +admin.site.register(File, FileAdmin) + + +class TrackingAdmin(admin.ModelAdmin): + list_display = ('file_id', 'current_id', 'receiver_id', + 'receive_date', 'forward_date', 'is_read') + search_fields = ('file_id__subject', + 'current_id__user__username', 'receiver_id__username') + list_filter = ('is_read',) + + +admin.site.register(Tracking, TrackingAdmin) diff --git a/FusionIIIT/applications/filetracking/api/serializers.py b/FusionIIIT/applications/filetracking/api/serializers.py new file mode 100644 index 000000000..bdae2024e --- /dev/null +++ b/FusionIIIT/applications/filetracking/api/serializers.py @@ -0,0 +1,24 @@ +from applications.filetracking.models import File, Tracking +from django.core.files import File as DjangoFile +from rest_framework import serializers + + +class FileSerializer(serializers.ModelSerializer): + class Meta: + model = File + fields = '__all__' + + +class TrackingSerializer(serializers.ModelSerializer): + class Meta: + model = Tracking + fields = '__all__' + + +class FileHeaderSerializer(serializers.ModelSerializer): + ''' + This serializes everything except the attachments of a file and whether it is read or not + ''' + class Meta: + model = File + exclude = ['upload_file', 'is_read'] diff --git a/FusionIIIT/applications/filetracking/api/urls.py b/FusionIIIT/applications/filetracking/api/urls.py new file mode 100644 index 000000000..139f965ff --- /dev/null +++ b/FusionIIIT/applications/filetracking/api/urls.py @@ -0,0 +1,24 @@ +from django.conf.urls import url +from .views import ( + CreateFileView, + ViewFileView, + ViewInboxView, + ViewOutboxView, + ViewHistoryView, + ForwardFileView, + DraftFileView, + CreateDraftFile, + GetDesignationsView, +) + +urlpatterns = [ + url(r'^file/$', CreateFileView.as_view(), name='create_file'), + url(r'^file/(?P\d+)/$', ViewFileView.as_view(), name='view_file'), + url(r'^inbox/$', ViewInboxView.as_view(), name='view_inbox'), + url(r'^outbox/$', ViewOutboxView.as_view(), name='view_outbox'), + url(r'^history/(?P\d+)/$', ViewHistoryView.as_view(), name='view_history'), + url(r'^forwardfile/(?P\d+)/$', ForwardFileView.as_view(), name='forward_file'), + url(r'^draft/$', DraftFileView.as_view(), name='view_drafts'), + url(r'^createdraft/$', CreateDraftFile.as_view(), name='create_draft'), + url(r'^designations/(?P\w+)/$', GetDesignationsView.as_view(), name='get_designations'), +] diff --git a/FusionIIIT/applications/filetracking/api/views.py b/FusionIIIT/applications/filetracking/api/views.py new file mode 100644 index 000000000..5f395ab41 --- /dev/null +++ b/FusionIIIT/applications/filetracking/api/views.py @@ -0,0 +1,247 @@ +import logging +from venv import logger +from django.forms import ValidationError +from rest_framework.views import APIView +from rest_framework.response import Response +from rest_framework import status, permissions +from rest_framework.authentication import TokenAuthentication +from ..models import File, Tracking +from ..sdk.methods import create_draft, create_file, view_drafts, view_file, delete_file, view_inbox, view_outbox, view_history, forward_file, get_designations + +class CreateFileView(APIView): + authentication_classes = [TokenAuthentication] + permission_classes = [permissions.IsAuthenticated] + + def post(self, request): + try: + current_user = request.user.username + current_designation = request.data.get('designation') + receiver_username = request.data.get('receiver_username') + receiver_designation = request.data.get('receiver_designation') + subject = request.data.get('subject') + description = request.data.get('description') + + if None in [current_designation, receiver_username, receiver_designation, subject, description]: + return Response({'error': 'One or more required fields are missing.'}, status=status.HTTP_400_BAD_REQUEST) + + file_id = create_file(uploader=current_user, uploader_designation=current_designation, + receiver=receiver_username, receiver_designation=receiver_designation, subject=subject, description=description) + + return Response({'file_id': file_id}, status=status.HTTP_201_CREATED) + except Exception as e: + return Response({'error': str(e)}, status=status.HTTP_400_BAD_REQUEST) + + +class ViewFileView(APIView): + authentication_classes = [TokenAuthentication] + permission_classes = [permissions.IsAuthenticated] + + def get(self, request, file_id): + try: + file_details = view_file(int(file_id)) + # print(file_details) + return Response(file_details, status=status.HTTP_200_OK) + except ValueError: + return Response({'error': 'Invalid file ID format.'}, status=status.HTTP_400_BAD_REQUEST) + except File.DoesNotExist: + return Response({'error': 'File not found.'}, status=status.HTTP_404_NOT_FOUND) + except Exception as e: + return Response({'error': str(e)}, status=status.HTTP_400_BAD_REQUEST) + + def delete(self, request, file_id): + try: + # file_details = view_file(int(file_id)) + # print(file_details) + success = delete_file(int(file_id)) + if success: + return Response({'message': 'File deleted successfully'}, + status=status.HTTP_204_NO_CONTENT) + else : + return + + except ValueError: + return Response({'error': 'Invalid file ID format'}, + status=status.HTTP_400_BAD_REQUEST) + except File.DoesNotExist: + return Response({'error': 'File not found'}, + status=status.HTTP_404_NOT_FOUND) + except ValidationError as e: + return Response(e.detail, status=status.HTTP_400_BAD_REQUEST) # Handle ValidationError specifically + except Exception as e: # Catch unexpected errors + logger.error(f"Unexpected error in DeleteFileView: {e}") + return Response({'error': 'An internal server error occurred'}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + + +class ViewInboxView(APIView): + authentication_classes = [TokenAuthentication] + permission_classes = [permissions.IsAuthenticated] + + def get(self, request): + """ + API endpoint to view inbox files. + + Expects query parameters: + - username (required): User requesting the inbox. + - designation (optional): Designation to filter files by. + - src_module (required): Source module to filter files by. + + Returns: + JSON response containing a list of serialized file data, including sender information. + """ + + username = request.query_params.get('username') + designation = request.query_params.get('designation') + src_module = request.query_params.get('src_module') + + + # if not username or not src_module: + # return Response({'error': 'Missing required query parameters: username and src_module.'}, status=400) + + inbox_files = view_inbox(username, designation, src_module) + return Response(inbox_files) + +class ViewOutboxView(APIView): + authentication_classes = [TokenAuthentication] + permission_classes = [permissions.IsAuthenticated] + + + def get(self, request): + """ + API endpoint to view outbox files. + + Expects query parameters: + - username (required): User requesting the outbox. + - designation (optional): Designation to filter files by. + - src_module (required): Source module to filter files by. + + Returns: + JSON response containing a paginated list of serialized file data. + """ + + username = request.query_params.get('username') + designation = request.query_params.get('designation') + src_module = request.query_params.get('src_module') + + + if not username or not src_module: + return Response({'error': 'Missing required query parameters: username and src_module.'}, status=400) + + outbox_files = view_outbox(username, designation, src_module) + return Response(outbox_files) + + +class ViewHistoryView(APIView): + authentication_classes = [TokenAuthentication] + permission_classes = [permissions.IsAuthenticated] + + def get(self, request, file_id): + """ + View history of a particular file with the given file_id. + + Args: + request (rest_framework.request.Request): The incoming request object. + file_id (int): Primary key of the file to retrieve history for. + + Returns: + rest_framework.response.Response: JSON response containing serialized tracking history. + """ + + try: + history = view_history(file_id) + return Response(history) + except Tracking.DoesNotExist: + return Response({'error': f'File with ID {file_id} not found.'}, status=404) + except Exception as e: + logger.error(f"An unexpected error occurred: {e}") + return Response({'error': 'Internal server error.'}, status=500) + +class ForwardFileView(APIView): +# # # Authentication and permission classes (adjust based on your needs) + authentication_classes = [TokenAuthentication] + permission_classes = [permissions.IsAuthenticated] + + def post(self, request, file_id): +# # Extract data from request.data + receiver = request.data.get('receiver') + receiver_designation = request.data.get('receiver_designation') + file_extra_JSON = request.data.get('file_extra_JSON', {}) + remarks = request.data.get('remarks', "") + + # Validate data + if not receiver or not receiver_designation: + raise ValidationError("Missing required fields: receiver and receiver_designation") + + # # Extract and validate file attachment (if present) + file_attachment = request.FILES.get('file_attachment') + if file_attachment: + if file_attachment.size > 10 * 1024 * 1024: # Adjust size limit as needed + raise ValidationError("File size exceeds limit (10 MB)") + + # Call forward_file function + try: + new_tracking_id = forward_file( + int(file_id), + receiver, + receiver_designation, + file_extra_JSON, + remarks, + file_attachment + ) + logging.info(f"Successfully forwarded file {file_id} with tracking ID: {new_tracking_id}") + except Exception as e: + logging.error(f"Error forwarding file {file_id}: {str(e)}") + raise ValidationError(str(e)) # Re-raise exception with a user-friendly message + + # Return response + return Response({'tracking_id': new_tracking_id}, status=status.HTTP_201_CREATED) + +class CreateDraftFile(APIView): + authentication_classes = [TokenAuthentication] + permission_classes = [permissions.IsAuthenticated] + + def post(self, request): + uploader = request.data.get('uploader') + uploader_designation = request.data.get('uploader_designation') + src_module = request.data.get('src_module', 'filetracking') + src_object_id = request.data.get('src_object_id', '') + file_extra_JSON = request.data.get('file_extra_JSON', {}) + attached_file = request.FILES.get('attached_file', None) + + try: + file_id = create_draft( + uploader=uploader, + uploader_designation=uploader_designation, + src_module=src_module, + src_object_id=src_object_id, + file_extra_JSON=file_extra_JSON, + attached_file=attached_file + ) + return Response({'file_id': file_id}, status=status.HTTP_201_CREATED) + except Exception as e: + return Response({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + +class DraftFileView(APIView): + authentication_classes = [TokenAuthentication] + permission_classes = [permissions.IsAuthenticated] + + def get(self, request): + username = request.query_params.get('username') + designation = request.query_params.get('designation') + src_module = request.query_params.get('src_module') + + try: + draft_files = view_drafts(username, designation, src_module) + print(draft_files) + return Response(draft_files, status=status.HTTP_200_OK) + except Exception as e: + return Response({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) + + + +class GetDesignationsView(APIView): + #authentication_classes = [TokenAuthentication] + #permission_classes = [permissions.IsAuthenticated] + + def get(self, request, username, *args, **kwargs): + user_designations = get_designations(username) + return Response({'designations': user_designations}) diff --git a/FusionIIIT/applications/filetracking/decorators.py b/FusionIIIT/applications/filetracking/decorators.py new file mode 100644 index 000000000..dd900730e --- /dev/null +++ b/FusionIIIT/applications/filetracking/decorators.py @@ -0,0 +1,51 @@ +from django.shortcuts import render, get_object_or_404 +from django.contrib.auth.models import User +from applications.globals.models import ExtraInfo, HoldsDesignation +from .sdk.methods import get_HoldsDesignation_obj + + +def user_check(request): + """ + This function is used to check if the user is a student or not. + Its return type is bool. + @param: + request - contains metadata about the requested page + + @Variables: + current_user - get user from request + user_details - extract details of the user from the database + desig_id - check for designation + student - designation for a student + final_user - final designation of the request(our user) + """ + try: + current_user = get_object_or_404(User, username=request.user.username) + user_details = ExtraInfo.objects.select_related('user','department').get(user=request.user) + des = HoldsDesignation.objects.all().select_related().filter(user=request.user).first() + if str(des.designation) == "student": + return True + else: + return False + except Exception as e: + return False + +def user_is_student(view_func): + def _wrapped_view(request, *args, **kwargs): + if user_check(request): + return render(request, 'filetracking/fileTrackingNotAllowed.html') + else: + return view_func(request, *args, **kwargs) + return _wrapped_view + +def dropdown_designation_valid(view_func): + def _wrapped_view(request, *args, **kwargs): + designation_name = request.session.get('currentDesignationSelected', 'default_value') #from dropdown + username = request.user + try: + designation_id = get_HoldsDesignation_obj( + username, designation_name).id + except: + return render(request, 'filetracking/invalid_designation.html', {'curr_des' : designation_name}) + else: + return view_func(request, *args, **kwargs) + return _wrapped_view diff --git a/FusionIIIT/applications/filetracking/models.py b/FusionIIIT/applications/filetracking/models.py index 5f9581a08..9d78b24c9 100644 --- a/FusionIIIT/applications/filetracking/models.py +++ b/FusionIIIT/applications/filetracking/models.py @@ -16,6 +16,11 @@ class File(models.Model): is_read = models.BooleanField(default = False) + # additions for API + src_module = models.CharField(max_length=100, default='filetracking') + src_object_id = models.CharField(max_length=100,null=True) + file_extra_JSON = models.JSONField(null=True) + class Meta: db_table = 'File' @@ -25,13 +30,11 @@ class Meta: class Tracking(models.Model): """ - This is File Tracing Table which contains the status of each indivisual file created by the user + This is File Tracing Table which contains the status of each individual file created by the user """ file_id = models.ForeignKey(File, on_delete=models.CASCADE, null=True) current_id = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE) current_design = models.ForeignKey(HoldsDesignation, null=True, on_delete=models.CASCADE) - # receiver_id = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE, related_name='receiver_id') - # receive_design = models.ForeignKey(HoldsDesignation, null=True, on_delete=models.CASCADE, related_name='rec_design') receiver_id = models.ForeignKey(User,null = True, on_delete=models.CASCADE, related_name='receiver_id') receive_design = models.ForeignKey(Designation, null=True, on_delete=models.CASCADE, related_name='rec_design') @@ -41,5 +44,8 @@ class Tracking(models.Model): upload_file = models.FileField(blank=True) is_read = models.BooleanField(default = False) + # additions for API + tracking_extra_JSON = models.JSONField(null=True) + class Meta: db_table = 'Tracking' diff --git a/FusionIIIT/applications/filetracking/sdk/methods.py b/FusionIIIT/applications/filetracking/sdk/methods.py new file mode 100644 index 000000000..0ea167fc6 --- /dev/null +++ b/FusionIIIT/applications/filetracking/sdk/methods.py @@ -0,0 +1,429 @@ +from amqp import NotFound +from django.contrib.auth.models import User +from applications.filetracking.models import Tracking, File +from applications.globals.models import Designation, HoldsDesignation, ExtraInfo +from applications.filetracking.api.serializers import FileSerializer, FileHeaderSerializer, TrackingSerializer +from django.core.exceptions import ValidationError +from typing import Any + + +def create_file( + uploader: str, + uploader_designation: str, + receiver: str, + receiver_designation: str, + subject: str = "", + description: str = "", + src_module: str = "filetracking", + src_object_id: str = "", + file_extra_JSON: dict = {}, + attached_file: Any = None) -> int: + ''' + This function is used to create a file object corresponding to any object of a module that needs to be tracked + ''' + + ''' + Functioning: + create base file with params + create tracking with params + if both complete then return id of file + else raise error + + also, delete file object if tracking isnt created + ''' + uploader_user_obj = get_user_object_from_username(uploader) + uploader_extrainfo_obj = get_ExtraInfo_object_from_username(uploader) + uploader_designation_obj = Designation.objects.get( + name=uploader_designation) + receiver_obj = get_user_object_from_username(receiver) + receiver_designation_obj = Designation.objects.get( + name=receiver_designation) + + new_file = File.objects.create( + uploader=uploader_extrainfo_obj, + subject=subject, + description=description, + designation=uploader_designation_obj, + src_module=src_module, + src_object_id=src_object_id, + file_extra_JSON=file_extra_JSON, + ) + + + if attached_file is not None: + new_file.upload_file.save(attached_file.name, attached_file, save=True) + + uploader_holdsdesignation_obj = HoldsDesignation.objects.get( + user=uploader_user_obj, designation=uploader_designation_obj) + + new_tracking = Tracking.objects.create( + file_id=new_file, + current_id=uploader_extrainfo_obj, + current_design=uploader_holdsdesignation_obj, + receiver_id=receiver_obj, + receive_design=receiver_designation_obj, + tracking_extra_JSON=file_extra_JSON, + remarks=f"File with id:{str(new_file.id)} created by {uploader} and sent to {receiver}" + # upload_file = None, dont add file for first tracking + ) + if new_tracking is None: + new_file.delete() + raise ValidationError('Tracking model data is incorrect') + else: + return new_file.id + + +def view_file(file_id: int) -> dict: + ''' + This function returns all the details of a given file + ''' + try: + requested_file = File.objects.get(id=file_id) + serializer = FileSerializer(requested_file) + file_details = serializer.data + return file_details + except File.DoesNotExist: + raise NotFound("File Not Found with provided ID") + + +def delete_file(file_id: int) -> bool: + ''' + This function is used to delete a file from being tracked, all the tracking history is deleted as well and returns true if the deletion was successful + ''' + try: + File.objects.filter(id=file_id).delete() + return True + except File.DoesNotExist: + return False + +# inbox and outbox could be sorted based on most recent linked tracking entry + +def view_inbox(username: str, designation: str, src_module: str) -> list: + ''' + This function is used to get all the files in the inbox of a particular user and designation + ''' + user_designation = Designation.objects.get(name=designation) + recipient_object = get_user_object_from_username(username) + received_files_tracking = Tracking.objects.select_related('file_id').filter( + receiver_id=recipient_object, + receive_design=user_designation, + file_id__src_module=src_module, + file_id__is_read=False).order_by('receive_date'); + received_files = [tracking.file_id for tracking in received_files_tracking] + + # remove duplicate file ids (from sending back and forth) + received_files_unique = uniqueList(received_files) + + received_files_serialized = list(FileHeaderSerializer( + received_files_unique, many=True).data) + + for file in received_files_serialized: + file['sent_by_user'] = get_last_file_sender(file['id']).username + file['sent_by_designation'] = get_last_file_sender_designation(file['id']).name + + return received_files_serialized + + +def view_outbox(username: str, designation: str, src_module: str) -> list: + ''' + This function is used to get all the files in the outbox of a particular user and designation + ''' + user_designation = get_designation_obj_from_name(designation=designation) + user_object = get_user_object_from_username(username) + user_HoldsDesignation_object = HoldsDesignation.objects.get( + user=user_object, designation=user_designation) + sender_ExtraInfo_object = get_ExtraInfo_object_from_username(username) + sent_files_tracking = Tracking.objects.select_related('file_id').filter( + current_id=sender_ExtraInfo_object, + current_design=user_HoldsDesignation_object, + file_id__src_module=src_module, + file_id__is_read=False).order_by('-receive_date') + sent_files = [tracking.file_id for tracking in sent_files_tracking] + + # remove duplicate file ids (from sending back and forth) + sent_files_unique = uniqueList(sent_files) + + sent_files_serialized = FileHeaderSerializer(sent_files_unique, many=True) + return sent_files_serialized.data + + + +def view_archived(username: str, designation: str, src_module: str) -> dict: + ''' + This function is used to get all the files in the archive of a particular user and designation + Archived file mean those which the user has ever interacted with, and are now finished or archived + ''' + user_designation = Designation.objects.get(name=designation) + user_object = get_user_object_from_username(username) + received_archived_tracking = Tracking.objects.select_related('file_id').filter( + receiver_id=user_object, + receive_design=user_designation, + file_id__src_module=src_module, + file_id__is_read=True) + + user_HoldsDesignation_object = HoldsDesignation.objects.get( + user=user_object, designation=user_designation) + sender_ExtraInfo_object = get_ExtraInfo_object_from_username(username) + sent_archived_tracking = Tracking.objects.select_related('file_id').filter( + current_id=sender_ExtraInfo_object, + current_design=user_HoldsDesignation_object, + file_id__src_module=src_module, + file_id__is_read=True) + + archived_tracking = received_archived_tracking | sent_archived_tracking + archived_files = [tracking.file_id for tracking in archived_tracking] + + # remove duplicate file ids (from sending back and forth) + archived_files_unique = uniqueList(archived_files) + + archived_files_serialized = FileHeaderSerializer(archived_files_unique, many=True) + return archived_files_serialized.data + + + +def archive_file(file_id: int) -> bool: + ''' + This function is used to archive a file and returns true if the archiving was successful + ''' + try: + File.objects.filter(id=file_id).update(is_read=True) + return True + except File.DoesNotExist: + return False + +def unarchive_file(file_id: int) -> bool: + ''' + This functions is used to unarchive a file and returns true if the unarchiving was successful + ''' + try: + File.objects.filter(id=file_id).update(is_read=False) + return True + except File.DoesNotExist: + return False + + + +def create_draft( + uploader: str, + uploader_designation: str, + src_module: str = "filetracking", + src_object_id: str = "", + file_extra_JSON: dict = {}, + attached_file: Any = None) -> int: + ''' + This function is used to create a draft file object corresponding to any object of a module that needs to be tracked + It is similar to create_file but is not sent to anyone + Later this file can be sent to someone by forward_file by using draft file_id + ''' + uploader_extrainfo_obj = get_ExtraInfo_object_from_username(uploader) + uploader_designation_obj = Designation.objects.get( + name=uploader_designation) + + new_file = File.objects.create( + uploader=uploader_extrainfo_obj, + designation=uploader_designation_obj, + src_module=src_module, + src_object_id=src_object_id, + file_extra_JSON=file_extra_JSON, + upload_file=attached_file + ) + return new_file.id + + +def view_drafts(username: str, designation: str, src_module: str) -> dict: + ''' + This function is used to get all the files in the drafts (has not been sent) of a particular user and designation + ''' + user_designation = Designation.objects.get(name=designation) + user_ExtraInfo_object = get_ExtraInfo_object_from_username(username) + draft_files = File.objects.filter( + tracking__isnull=True, uploader=user_ExtraInfo_object, designation=user_designation, src_module=src_module) + draft_files_serialized = FileHeaderSerializer(draft_files, many=True) + return draft_files_serialized.data + + + +def forward_file( + file_id: int, + receiver: str, + receiver_designation: str, + file_extra_JSON: dict, + remarks: str = "", + file_attachment: Any = None) -> int: + ''' + This function forwards the file and inserts a new tracking history into the file tracking table + Note that only the current owner(with appropriate designation) of the file has the ability to forward files + ''' + # HoldsDesignation and ExtraInfo object are used instead + # of Designation and User object because of the legacy code being that way + + current_owner = get_current_file_owner(file_id) + current_owner_designation = get_current_file_owner_designation(file_id) + current_owner_extra_info = ExtraInfo.objects.get(user=current_owner) + current_owner_holds_designation = HoldsDesignation.objects.get( + user=current_owner, designation=current_owner_designation) + receiver_obj = User.objects.get(username=receiver) + receiver_designation_obj = Designation.objects.get( + name=receiver_designation) + tracking_data = { + 'file_id': file_id, + 'current_id': current_owner_extra_info.id, + 'current_design': current_owner_holds_designation.id, + 'receiver_id': receiver_obj.id, + 'receive_design': receiver_designation_obj.id, + 'tracking_extra_JSON': file_extra_JSON, + 'remarks': remarks, + } + if file_attachment is not None: + tracking_data['upload_file'] = file_attachment + + tracking_entry = TrackingSerializer(data=tracking_data) + if tracking_entry.is_valid(): + tracking_entry.save() + return tracking_entry.instance.id + else: + raise ValidationError('forward data is incomplete') + + +def view_history(file_id: int) -> dict: + ''' + This function is used to get the history of a particular file with the given file_id + ''' + Tracking_history = Tracking.objects.filter( + file_id=file_id).order_by('-receive_date') + Tracking_history_serialized = TrackingSerializer( + Tracking_history, many=True) + return Tracking_history_serialized.data + + +# HELPER FUNCTIONS + +def get_current_file_owner(file_id: int) -> User: + ''' + This functions returns the current owner of the file. + The current owner is the latest recipient of the file + ''' + latest_tracking = Tracking.objects.filter( + file_id=file_id).order_by('-receive_date').first() + latest_recipient = latest_tracking.receiver_id + return latest_recipient + + +def get_current_file_owner_designation(file_id: int) -> Designation: + ''' + This function returns the designation of the current owner of the file. + The current owner is the latest recipient of the file + ''' + latest_tracking = Tracking.objects.filter( + file_id=file_id).order_by('-receive_date').first() + latest_recipient_designation = latest_tracking.receive_design + return latest_recipient_designation + +def get_last_file_sender(file_id: int) -> User: + ''' + This Function returns the last file sender, + one who has last forwarded/sent the file + ''' + latest_tracking = Tracking.objects.filter( + file_id=file_id).order_by('-receive_date').first() + latest_sender_extra_info = latest_tracking.current_id + return latest_sender_extra_info.user + +def get_last_file_sender_designation(file_id: int) -> Designation: + ''' + This Function returns the last file sender's Designation, + one who has last forwarded/sent the file + ''' + latest_tracking = Tracking.objects.filter( + file_id=file_id).order_by('receive_date').first() + latest_sender_holds_designation = latest_tracking.current_design + return latest_sender_holds_designation.designation + +def get_designations(username: str) -> list: + ''' + This function is used to return a list of all the designation names of a particular user + ''' + user = User.objects.get(username=username) + designations_held = HoldsDesignation.objects.filter(user=user) + designation_name = [hold_designation.designation.name for hold_designation in designations_held] + return designation_name + + +def get_user_object_from_username(username: str) -> User: + user = User.objects.get(username=username) + return user + +def get_ExtraInfo_object_from_username(username: str) -> ExtraInfo: + user = User.objects.get(username=username) + extrainfo = ExtraInfo.objects.get(user=user) + return extrainfo + +def uniqueList(l: list) -> list: + ''' + This function is used to return a list with unique elements + O(n) time and space + ''' + seen = set() + unique_list = [] + for item in l: + if item not in seen: + unique_list.append(item) + seen.add(item) + return unique_list + +def add_uploader_department_to_files_list(files: list) -> list: + ''' + This function is used to add the department of the uploader to the file + ''' + for file in files: + uploader_Extrainfo = file['uploader'] + if uploader_Extrainfo.department is None: + # for files created by staff or users that dont have department + file['uploader_department'] = 'FTS' + else: + file['uploader_department'] = ( + str(uploader_Extrainfo.department)).split(': ')[1] + + return files + +def get_designation_obj_from_name(designation: str) -> Designation: + des = Designation.objects.get(name = designation) + return des + +def get_HoldsDesignation_obj(username: str, designation:str) -> HoldsDesignation: + user_object = get_user_object_from_username(username=username) + user_designation = get_designation_obj_from_name(designation=designation) + obj = HoldsDesignation.objects.get( + user=user_object, designation=user_designation) + return obj + +def get_last_recv_tracking_for_user(file_id: int, username: str, designation: str)-> Tracking: + ''' + This returns the last tracking where username+designation recieved file_id + ''' + + recv_user_obj = get_user_object_from_username(username) + recv_design_obj = get_designation_obj_from_name(designation) + + last_tracking = Tracking.objects.filter(file_id=file_id, + receiver_id=recv_user_obj, + receive_design=recv_design_obj).order_by('-receive_date')[0] + return last_tracking + +def get_last_forw_tracking_for_user(file_id: int, username: str, designation: str) -> Tracking: + ''' + Returns the last tracking where the specified user forwarded the file. + ''' + + # Get user and designation objects + sender_user_obj = get_ExtraInfo_object_from_username(username) + sender_designation_obj = get_HoldsDesignation_obj(username=username, designation=designation) + + # Filter Tracking objects by file_id, sender_id, and sender_designation + last_tracking = Tracking.objects.filter(file_id=file_id, + current_id=sender_user_obj, + current_design=sender_designation_obj).order_by('-forward_date').first() + return last_tracking + +def get_extra_info_object_from_id(id: int): + return ExtraInfo.objects.get(id=id) diff --git a/FusionIIIT/applications/filetracking/tests.py b/FusionIIIT/applications/filetracking/tests.py index e9137c85e..a79ca8be5 100644 --- a/FusionIIIT/applications/filetracking/tests.py +++ b/FusionIIIT/applications/filetracking/tests.py @@ -1,3 +1,3 @@ -# from django.test import TestCase - -# Create your tests here. +# from django.test import TestCase + +# Create your tests here. diff --git a/FusionIIIT/applications/filetracking/urls.py b/FusionIIIT/applications/filetracking/urls.py index cb4a7563d..a451738de 100644 --- a/FusionIIIT/applications/filetracking/urls.py +++ b/FusionIIIT/applications/filetracking/urls.py @@ -1,31 +1,47 @@ -from django.conf.urls import url - -from . import views - -app_name = 'filetracking' - -urlpatterns = [ - - url(r'^$', views.filetracking, name='filetracking'), - url(r'^drafts/$', views.drafts, name='drafts'), - url(r'^fileview/(?P\d+)$', views.fileview, name='fileview'), - url(r'^fileview1/(?P\d+)$', views.fileview1, name='fileview1'), - url(r'^fileview2/(?P\d+)$', views.fileview2, name='fileview2'), - url(r'^outward/$', views.outward, name='outward'), - url(r'^inward/$', views.inward, name='inward'), - url(r'^confirmdelete/(?P\d+)$', views.confirmdelete, name='confirm_delete'), - url(r'^archive/(?P\d+)/$', views.archive, name='archive'), - url(r'^finish/(?P\d+)/$', views.finish, name='finish'), - url(r'^forward/(?P\d+)/$', views.forward, name='forward'), - url(r'^ajax/$', views.AjaxDropdown1, name='ajax_dropdown1'), - url(r'^ajax_dropdown/$', views.AjaxDropdown, name='ajax_dropdown'), - url(r'^test/$',views.test, name='test'), - url(r'^delete/(?P\d+)$',views.delete, name='delete'), - url(r'^forward_inward/(?P\d+)/$', views.forward_inward, name='forward_inward'), - - ## correction team 24 - url(r'^finish_design/$', views.finish_design, name='finish_design'), - url(r'^finish_fileview/(?P\d+)$', views.finish_fileview, name='finish_fileview'), - url(r'^archive_design/$', views.archive_design, name='archive_design'), - url(r'^archive_finish/(?P\d+)/$', views.archive_finish, name='archive_finish'), -] +from django.conf.urls import url, include + +from . import views +from .api import urls + +app_name = 'filetracking' + +urlpatterns = [ + + url(r'^$', views.filetracking, name='filetracking'), + url(r'^draftdesign/$', views.draft_design, name='draft_design'), + url(r'^drafts/(?P\d+)$', views.drafts_view, name='drafts_view'), + url(r'^outbox/(?P\d+)$', views.outbox_view, name='outbox_view'), + url(r'^inbox/(?P\d+)$', views.inbox_view, name='inbox_view'), + url(r'^outward/$', views.outward, name='outward'), + url(r'^inward/$', views.inward, name='inward'), + url(r'^confirmdelete/(?P\d+)$', + views.confirmdelete, name='confirm_delete'), + url(r'^archive/(?P\d+)/$', views.archive_view, name='archive_view'), + url(r'^finish/(?P\d+)/$', views.archive_file, name='finish_file'), + url(r'^viewfile/(?P\d+)/$', views.view_file, name='view_file_view'), + url(r'^forward/(?P\d+)/$', views.forward, name='forward'), + url(r'^ajax/$', views.AjaxDropdown1, name='ajax_dropdown1'), + url(r'^ajax_dropdown/$', views.AjaxDropdown, name='ajax_dropdown'), + url(r'^test/$', views.test, name='test'), + url(r'^delete/(?P\d+)$', views.delete, name='delete'), + url(r'^forward_inward/(?P\d+)/$', + views.forward_inward, name='forward_inward'), + + # correction team 24 + url(r'^finish_design/$', views.finish_design, name='finish_design'), + url(r'^finish_fileview/(?P\d+)$', + views.finish_fileview, + name='finish_fileview'), + url(r'^archive_design/$', views.archive_design, name='archive_design'), + url(r'^archive_finish/(?P\d+)/$', + views.archive_finish, name='archive_finish'), + url(r'unarchive/(?P\d+)/$', + views.unarchive_file, name='unarchive'), + url(r'^getdesignations/(?P\w+)/$', views.get_designations_view, name="get_user_designations"), + url(r'^editdraft/(?P\w+)/$', views.edit_draft_view, name="edit_draft"), + + # REST api urls + url(r'^api/', include(urls)) + +] + diff --git a/FusionIIIT/applications/filetracking/views.py b/FusionIIIT/applications/filetracking/views.py index ef5d8f347..a01d71ac1 100644 --- a/FusionIIIT/applications/filetracking/views.py +++ b/FusionIIIT/applications/filetracking/views.py @@ -8,12 +8,19 @@ from django.db import IntegrityError from django.core import serializers from django.contrib.auth.models import User +from django.http import JsonResponse from timeit import default_timer as time -from notification.views import office_module_notif,file_tracking_notif +from notification.views import office_module_notif, file_tracking_notif from .utils import * +from django.utils.dateparse import parse_datetime +from .sdk.methods import * +from .decorators import * +import json -@login_required(login_url = "/accounts/login/") +@login_required(login_url="/accounts/login/") +@user_is_student +@dropdown_designation_valid def filetracking(request): """ The function is used to create files by current user(employee). @@ -35,39 +42,50 @@ def filetracking(request): holdsdesignations - The HoldsDesignation object. context - Holds data needed to make necessary changes in the template. """ - if request.method =="POST": + + + 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) + designation = Designation.objects.get(id=HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').get(id=design).designation_id) upload_file = request.FILES.get('myfile') - if(upload_file.size / 1000 > 10240): - messages.error(request,"File should not be greater than 10MB") - return redirect("/filetracking") + if upload_file and upload_file.size / 1000 > 10240: + messages.error( + request, "File should not be greater than 10MB") + return redirect("/filetracking") + + extraJSON = { + 'remarks': request.POST.get('remarks'), + } File.objects.create( uploader=uploader, description=description, subject=subject, designation=designation, - upload_file=upload_file + upload_file=upload_file, + file_extra_JSON=extraJSON ) - messages.success(request,'File Draft Saved Successfully') + messages.success(request, 'File Draft Saved Successfully') if 'send' 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) + designation = Designation.objects.get(id=HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').get(id=design).designation_id) upload_file = request.FILES.get('myfile') - if(upload_file.size / 1000 > 10240): - messages.error(request,"File should not be greater than 10MB") + if upload_file and upload_file.size / 1000 > 10240: + messages.error( + request, "File should not be greater than 10MB") return redirect("/filetracking") file = File.objects.create( @@ -78,12 +96,12 @@ def filetracking(request): upload_file=upload_file ) - 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) + current_design = HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').get(id=sender) receiver = request.POST.get('receiver') try: @@ -91,8 +109,9 @@ def filetracking(request): except Exception as e: messages.error(request, 'Enter a valid Username') return redirect('/filetracking/') - receive = request.POST.get('recieve') + receive = request.POST.get('receive') try: + print(receive) receive_design = Designation.objects.get(name=receive) except Exception as e: messages.error(request, 'Enter a valid Designation') @@ -109,55 +128,61 @@ def filetracking(request): remarks=remarks, upload_file=upload_file, ) - #office_module_notif(request.user, receiver_id) - file_tracking_notif(request.user,receiver_id,subject) - messages.success(request,'File sent successfully') + # office_module_notif(request.user, receiver_id) + file_tracking_notif(request.user, receiver_id, subject) + messages.success(request, 'File sent successfully') except IntegrityError: message = "FileID Already Taken.!!" return HttpResponse(message) + 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() + designation_name = request.session.get('currentDesignationSelected', 'default_value') + all_available_designations = request.session.get( + 'allDesignations', 'default_value2') - 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 = get_designation(request.user) + + username = request.user + designation_id = get_HoldsDesignation_obj( + username, designation_name).id context = { 'file': file, 'extrainfo': extrainfo, 'holdsdesignations': holdsdesignations, - 'designations': designations, + 'designation_name': designation_name, + 'designation_id': designation_id, + 'notifications': request.user.notifications.all() } return render(request, 'filetracking/composefile.html', context) -@login_required(login_url = "/accounts/login") -def drafts(request): +@login_required(login_url="/accounts/login") +def draft_design(request): + """ + This function redirects the user to the drafts page of designation selected in dropdown + @param: + request - trivial. """ - The function is used to get the designation of the user and renders it on draft template. - - @param: - request - trivial. - @variables: - - - context - Holds data needed to make necessary changes in the template. - """ - designation = get_designation(request.user) - context = { - 'designation': designation, - } - return render(request, 'filetracking/drafts.html', context) + dropdown_design = request.session.get( + 'currentDesignationSelected', 'default_value') + username = request.user + dropdown_HoldsDesignation_obj = get_HoldsDesignation_obj( + username, dropdown_design) + return redirect('/filetracking/drafts/' + str(dropdown_HoldsDesignation_obj.id)) -@login_required(login_url = "/accounts/login") -def fileview(request,id): +@login_required(login_url="/accounts/login") +def drafts_view(request, id): """ - This function is used to veiw all all created files by the user ordered by upload date.it collects all the created files from File object. + This function is used to view all the drafts created by the user ordered by upload date.it collects all the created files from File object. @param: request - trivial @@ -166,45 +191,38 @@ def fileview(request,id): @parameters draft - file obeject containing all the files created by user context - holds data needed to render the template - - - """ - # draft = File.objects.select_related('uploader__user','uploader__department','designation').filter(uploader=request.user.extrainfo).order_by('-upload_date') - # extrainfo = ExtraInfo.objects.select_related('user','department').all() - extrainfo = ExtraInfo.objects.select_related('user','department').all() - - ids = File.objects.filter(uploader=request.user.extrainfo).order_by('-upload_date').values_list('id', flat=True) - draft_files_pk=[] - - for i in ids: - file_tracking_ids = Tracking.objects.filter(file_id=i).values_list('id', flat=True) - if(len(file_tracking_ids)==0): - draft_files_pk.append(i) - - draft_file_list=[] - for i in draft_files_pk: - draft_file_list.append(File.objects.get(pk=i)) + """ + user_HoldsDesignation_obj = HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').get(pk=id) + s = str(user_HoldsDesignation_obj).split(" - ") + designation = s[1] + draft_files = view_drafts( + username=user_HoldsDesignation_obj.user, + designation=user_HoldsDesignation_obj.designation, + src_module='filetracking' + ) + + # Correct upload_date type + for f in draft_files: + f['upload_date'] = parse_datetime(f['upload_date']) + f['uploader'] = get_extra_info_object_from_id(f['uploader']) + + draft_files = add_uploader_department_to_files_list(draft_files) - user_designation = HoldsDesignation.objects.select_related('user','working','designation').get(pk=id) - s = str(user_designation).split(" - ") - designations = s[1] context = { - - 'draft': draft_file_list, - 'extrainfo': extrainfo, - 'designations': designations, + 'draft_files': draft_files, + 'designations': designation, + 'notifications': request.user.notifications.all() } - return render(request, 'filetracking/fileview.html', context) - - + return render(request, 'filetracking/drafts.html', context) -@login_required(login_url = "/accounts/login") -def fileview1(request,id): +@login_required(login_url="/accounts/login") +def outbox_view(request, id): """ The function is used to get all the files sent by user(employee) to other employees which are filtered from Tracking(table) objects by current user i.e. current_id. @@ -216,97 +234,129 @@ def fileview1(request,id): id - user id @variables: - out - The Tracking object filtered by current_id i.e, present working user. + outward_files - File objects filtered by current_id i.e, present working user. context - Holds data needed to make necessary changes in the template. - - """ - outward_files = 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(current_id=request.user.extrainfo).order_by('-forward_date') - user_designation = HoldsDesignation.objects.select_related('user','working','designation').get(pk=id) + """ + user_HoldsDesignation_obj = HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').get(pk=id) + s = str(user_HoldsDesignation_obj).split(" - ") + designation = s[1] + + outward_files = view_outbox(username=user_HoldsDesignation_obj.user, + designation=user_HoldsDesignation_obj.designation, + src_module='filetracking') + + for f in outward_files: + last_forw_tracking = get_last_forw_tracking_for_user(file_id=f['id'], + username=user_HoldsDesignation_obj.user, + designation=user_HoldsDesignation_obj.designation) + f['sent_to_user'] = last_forw_tracking.receiver_id + f['sent_to_design'] = last_forw_tracking.receive_design + f['last_sent_date'] = last_forw_tracking.forward_date + + f['upload_date'] = parse_datetime(f['upload_date']) + f['uploader'] = get_extra_info_object_from_id(f['uploader']) + + outward_files = add_uploader_department_to_files_list(outward_files) + user_HoldsDesignation_obj = HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').get(pk=id) + s = str(user_HoldsDesignation_obj).split(" - ") + designation = s[1] context = { - - 'out': outward_files, - 'abcd': user_designation, + 'out_files': outward_files, + 'viewer_designation': designation, + 'notifications': request.user.notifications.all() } - return render(request, 'filetracking/fileview1.html', context) + return render(request, 'filetracking/outbox.html', context) -@login_required(login_url = "/accounts/login") -def fileview2(request,id): - +@login_required(login_url="/accounts/login") +def inbox_view(request, id): """ The function is used to fetch the files received by the user form other employees. These files are filtered by receiver id and ordered by receive date. @param: request - trivial. - id - user id + id - HoldsDesignation object id @variables: - inward_file - The Tracking object filtered by receiver_id i.e, present working user. + inward_files - File object with additional sent by information context - Holds data needed to make necessary changes in the template. """ - inward_file = 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(receiver_id=request.user).order_by('-receive_date') - user_designation = HoldsDesignation.objects.select_related('user','working','designation').get(pk=id) - s = str(user_designation).split(" - ") - designations = s[1] + user_HoldsDesignation_obj = HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').get(pk=id) + s = str(user_HoldsDesignation_obj).split(" - ") + designation = s[1] + inward_files = view_inbox( + username=user_HoldsDesignation_obj.user, + designation=user_HoldsDesignation_obj.designation, + src_module='filetracking' + ) + + # correct upload_date type and add recieve_date + for f in inward_files: + f['upload_date'] = parse_datetime(f['upload_date']) + + last_recv_tracking = get_last_recv_tracking_for_user(file_id=f['id'], + username=user_HoldsDesignation_obj.user, + designation=user_HoldsDesignation_obj.designation) + f['receive_date'] = last_recv_tracking.receive_date + f['uploader'] = get_extra_info_object_from_id(f['uploader']) + + inward_files = add_uploader_department_to_files_list(inward_files) context = { - - 'in_file': inward_file, - 'designations': designations, + 'in_file': inward_files, + 'designations': designation, + 'notifications': request.user.notifications.all() } - return render(request, 'filetracking/fileview2.html', context) + return render(request, 'filetracking/inbox.html', context) -@login_required(login_url = "/accounts/login") +@login_required(login_url="/accounts/login") def outward(request): """ - This function fetches the different designations of the user and renders it on outward template + This function redirects the user to the outbox page of designation selected in dropdown @param: request - trivial. - - @variables: - context - Holds the different designation data of the user - """ - designation = get_designation(request.user) - context = { - 'designation': designation, - } - return render( request, 'filetracking/outward.html', context) + dropdown_design = request.session.get( + 'currentDesignationSelected', 'default_value') + username = request.user + dropdown_HoldsDesignation_obj = get_HoldsDesignation_obj( + username, dropdown_design) + return redirect('/filetracking/outbox/' + str(dropdown_HoldsDesignation_obj.id)) -@login_required(login_url = "/accounts/login") -def inward(request): - """ - This function fetches the different designations of the user and renders it on inward template - + + +@login_required(login_url="/accounts/login") +def inward(request): + """ + This function redirects the user to the inbox page of designation selected in dropdown @param: request - trivial. - - @variables: - context - Holds the different designation data of the user """ - designation = get_designation(request.user) - context = { - - 'designation': designation, - } - return render(request, 'filetracking/inward.html', context) + + dropdown_design = request.session.get( + 'currentDesignationSelected', 'default_value') + username = request.user + dropdown_HoldsDesignation_obj = get_HoldsDesignation_obj( + username, dropdown_design) + + return redirect('/filetracking/inbox/' + str(dropdown_HoldsDesignation_obj.id)) @login_required(login_url = "/accounts/login") def confirmdelete(request,id): - """ The function is used to confirm the deletion of a file. @param: @@ -316,16 +366,87 @@ def confirmdelete(request,id): @variables: context - Holds data needed to make necessary changes in the template. """ - file = File.objects.select_related('uploader__user','uploader__department','designation').get(pk = id) + file = File.objects.select_related( + 'uploader__user', 'uploader__department', 'designation').get(pk=id) context = { 'j': file, } - return render(request, 'filetracking/confirmdelete.html',context) + return render(request, 'filetracking/confirmdelete.html', context) +@login_required(login_url="/accounts/login") +def view_file(request, id): + ''' + This function is used to view a particular file received by an employee from another. + This function also conditionally renders two forms 'forward_file' and 'archive_file' + based on if the user has necessary permissions or not. + The business permissions are as follows: + 1. User can forward file only if they are the last recipient of the file + 2. User can archive a file only if they have received it last and they are also the original owner of the file -@login_required(login_url = "/accounts/login") + To forward the file and to archive the file separate views with POST request are called + + It displays the details file of a File and remarks as well as the attachments of all the users + who have been involved till that point of the workflow. + + @param: + request - Trivial. + id - ID of the file object which the user intends to forward to another employee. + + @variables: + file - The File object. + track - The Tracking object. + designation - the designations of the user + ''' + + file = get_object_or_404(File, id=id) + 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).order_by('receive_date') + designations = get_designation(request.user) + + forward_enable = False + archive_enable = False + + current_owner = get_current_file_owner(file.id) + file_uploader = get_user_object_from_username(file.uploader.user.username) + + + if current_owner == request.user and file.is_read is False: + forward_enable = True + if current_owner == request.user and file_uploader == request.user and file.is_read is False: + archive_enable = True + + context = { + 'designations': designations, + 'file': file, + 'track': track, + 'forward_enable': forward_enable, + 'archive_enable': archive_enable, + 'notifications': request.user.notifications.all() + } + return render(request, 'filetracking/viewfile.html', context) + +@login_required(login_url="/accounts/login") +def archive_file(request, id): + '''This function is used to archive a file. + It returns unauthorized access if the user is not file uploader + and the current owner of the file + ''' + if request.method == "POST": + file = get_object_or_404(File, id=id); + current_owner = get_current_file_owner(file.id) + file_uploader = get_user_object_from_username(file.uploader.user.username) + if current_owner == request.user and file_uploader == request.user: + file.is_read = True + file.save() + messages.success(request, 'File Archived') + else: + messages.error(request, 'Unauthorized access') + + return render(request, 'filetracking/composefile.html') + +@login_required(login_url="/accounts/login") def forward(request, id): """ The function is used to forward files received by user(employee) from other @@ -351,198 +472,215 @@ def forward(request, id): holdsdesignations = HoldsDesignation objects. context - Holds data needed to make necessary changes in the template. """ - + file = get_object_or_404(File, id=id) - 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) - + 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).order_by('receive_date') + if request.method == "POST": - if 'finish' in request.POST: - file.complete_flag = True - file.save() + if 'finish' in request.POST: + file.is_read = True + file.save() + if 'send' in request.POST: + current_id = request.user.extrainfo + remarks = request.POST.get('remarks') + track.update(is_read=True) + + sender = request.POST.get('sender') + current_design = HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').get(id=sender) + + receiver = request.POST.get('receiver') + try: + receiver_id = User.objects.get(username=receiver) + except Exception as e: + messages.error(request, 'Enter a valid destination') + designations = HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').filter(user=request.user) + + context = { + + 'designations': designations, + 'file': file, + 'track': track, + } + return render(request, 'filetracking/forward.html', context) + receive = request.POST.get('receive') + try: + receive_design = Designation.objects.get(name=receive) + except Exception as e: + messages.error(request, 'Enter a valid Designation') + designations = get_designation(request.user) + + context = { + + 'designations': designations, + 'file': file, + 'track': track, + } + return render(request, 'filetracking/forward.html', context) + + upload_file = request.FILES.get('myfile') + + 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, 'File sent successfully') - if 'send' in request.POST: - current_id = request.user.extrainfo - remarks = request.POST.get('remarks') - track.update(is_read=True) + designations = get_designation(request.user) - sender = request.POST.get('sender') - current_design = HoldsDesignation.objects.select_related('user','working','designation').get(id=sender) + designation_name = request.session.get('currentDesignationSelected', 'default_value') + all_available_designations = request.session.get( + 'allDesignations', 'default_value2') - receiver = request.POST.get('receiver') - try: - receiver_id = User.objects.get(username=receiver) - except Exception as e: - messages.error(request, 'Enter a valid destination') - designations = HoldsDesignation.objects.select_related('user','working','designation').filter(user=request.user) - - context = { - - 'designations': designations, - 'file': file, - 'track': track, - } - return render(request, 'filetracking/forward.html', context) - receive = request.POST.get('recieve') - try: - receive_design = Designation.objects.get(name=receive) - except Exception as e: - messages.error(request, 'Enter a valid Designation') - designations = get_designation(request.user) + username = request.user + designation_id = get_HoldsDesignation_obj( + username, designation_name).id - context = { - - 'designations': designations, - 'file': file, - 'track': track, - } - return render(request, 'filetracking/forward.html', context) - - - upload_file = request.FILES.get('myfile') - - 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, 'File sent successfully') - - - designations = get_designation(request.user) context = { - - 'designations':designations, + 'designations': designations, 'file': file, 'track': track, + 'designation_name': designation_name, + 'designation_id': designation_id, + + 'notifications': request.user.notifications.all() } return render(request, 'filetracking/forward.html', context) -@login_required(login_url = "/accounts/login") +@login_required(login_url="/accounts/login") def archive_design(request): + """ + This function redirects the user to the archive page of designation selected in dropdown + @param: + request - trivial. + """ - designation = HoldsDesignation.objects.select_related('user','working','designation').filter(user=request.user) - - context = { - 'designation': designation, - } - return render( request, 'filetracking/archive_design.html', context) - - - + dropdown_design = request.session.get( + 'currentDesignationSelected', 'default_value') + username = request.user + dropdown_HoldsDesignation_obj = get_HoldsDesignation_obj( + username, dropdown_design) + return redirect('/filetracking/archive/' + str(dropdown_HoldsDesignation_obj.id)) -@login_required(login_url = "/accounts/login") -def archive(request , id): - draft = File.objects.select_related('uploader__user','uploader__department','designation').filter(is_read=True).order_by('-upload_date') +@login_required(login_url="/accounts/login") +def archive_view(request, id): + """ + The function is used to fetch the files in the user's archive + (those which have passed by user and been archived/finished) + @param: + request - trivial. + id - HoldsDesignation object id - extrainfo = ExtraInfo.objects.select_related('user','department').all() - # designations = Designation.objects.filter(upload_designation=extrainfo.id) - abcd = HoldsDesignation.objects.select_related('user','working','designation').get(pk=id) - s = str(abcd).split(" - ") - designations = s[1] - #designations = HoldsDesignation.objects.filter(user=request.user) - # for x in designations: - # if abcd==x: - # designations=abcd + @variables: + archive_files - File object with additional information + context - Holds data needed to make necessary changes in the template. - context = { + """ + user_HoldsDesignation_obj = HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').get(pk=id) + s = str(user_HoldsDesignation_obj).split(" - ") + designation = s[1] - 'draft': draft, - 'extrainfo': extrainfo, - 'designations': designations, - } + archive_files = view_archived( + username=user_HoldsDesignation_obj.user, + designation=user_HoldsDesignation_obj.designation, + src_module='filetracking' + ) + # correct upload_date type and add receive_date + for f in archive_files: + f['upload_date'] = parse_datetime(f['upload_date']) + f['designation'] = Designation.objects.get(id=f['designation']) + f['uploader'] = get_extra_info_object_from_id(f['uploader']) + archive_files = add_uploader_department_to_files_list(archive_files) + context = { + 'archive_files': archive_files, + 'designations': designation, + 'notifications': request.user.notifications.all() + } + return render(request, 'filetracking/archive.html', context) - return render(request, 'filetracking/archive.html' , context) -@login_required(login_url = "/accounts/login") +@login_required(login_url="/accounts/login") def archive_finish(request, id): - file1 = get_object_or_404(File, id=id) ##file = get_object_or_404(File, ref_id=id) + # file = get_object_or_404(File, ref_id=id) + file1 = get_object_or_404(File, id=id) track = Tracking.objects.filter(file_id=file1) - - return render(request, 'filetracking/archive_finish.html', {'file': file1, 'track': track}) - - -@login_required(login_url = "/accounts/login") +@login_required(login_url="/accounts/login") def finish_design(request): - designation = HoldsDesignation.objects.select_related('user','working','designation').filter(user=request.user) + designation = HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').filter(user=request.user) context = { 'designation': designation, + 'notifications': request.user.notifications.all() } - return render( request, 'filetracking/finish_design.html', context) + return render(request, 'filetracking/finish_design.html', context) -@login_required(login_url = "/accounts/login") +@login_required(login_url="/accounts/login") def finish_fileview(request, id): - out = 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__uploader=request.user.extrainfo, is_read=False).order_by('-forward_date') - - - - - abcd = HoldsDesignation.objects.select_related('user','working','designation').get(pk=id) + out = 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__uploader=request.user.extrainfo, is_read=False).order_by('-forward_date') + abcd = HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').get(pk=id) context = { 'out': out, 'abcd': abcd, + 'notifications': request.user.notifications.all() } return render(request, 'filetracking/finish_fileview.html', context) - - -@login_required(login_url = "/accounts/login") +@login_required(login_url="/accounts/login") def finish(request, id): - file1 = get_object_or_404(File, id=id) ##file = get_object_or_404(File, ref_id=id) + # file = get_object_or_404(File, ref_id=id) + file1 = get_object_or_404(File, id=id) track = Tracking.objects.filter(file_id=file1) - if request.method == "POST": - if 'Finished' in request.POST: - File.objects.filter(pk=id).update(is_read=True) - track.update(is_read=True) - messages.success(request,'File Archived') - - - - - - - - return render(request, 'filetracking/finish.html', {'file': file1, 'track': track,'fileid':id}) - + if 'Finished' in request.POST: + File.objects.filter(pk=id).update(is_read=True) + track.update(is_read=True) + messages.success(request, 'File Archived') + return render(request, 'filetracking/finish.html', {'file': file1, 'track': track, 'fileid': id, + 'notifications': request.user.notifications.all()}) def AjaxDropdown1(request): + """ This function returns the designation of receiver on the forward or compose file template. @param: request - trivial. - + @variables: context - return the httpresponce containing the matched designation of the user @@ -553,20 +691,19 @@ def AjaxDropdown1(request): hold = Designation.objects.filter(name__startswith=value) holds = serializers.serialize('json', list(hold)) context = { - 'holds' : holds + 'holds': holds } return HttpResponse(JsonResponse(context), content_type='application/json') def AjaxDropdown(request): - """ This function returns the usernames of receiver on the forward or compose file template. @param: request - trivial. - + @variables: context - return the httpresponce containing the matched username @@ -589,24 +726,20 @@ def test(request): @login_required(login_url = "/accounts/login") def delete(request,id): - """ The function is used the delete of a file and it returns to the drafts page. @param: request - trivial. id - id of the file that is going to be deleted - + """ - file = File.objects.get(pk = id) + file = File.objects.get(pk=id) file.delete() - return redirect('/filetracking/drafts/') - - + return redirect('/filetracking/draftdesign/') def forward_inward(request,id): - """ This function is used forward the files which are available in the inbox of the user . @param: @@ -617,21 +750,157 @@ def forward_inward(request,id): file - file object track - tracking object of the file context - necessary data to render - + """ file = get_object_or_404(File, id=id) file.is_read = True - 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) + 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) designations = get_designation(request.user) context = { - - 'designations':designations, + + 'designations': designations, 'file': file, 'track': track, + 'notifications': request.user.notifications.all() } return render(request, 'filetracking/forward.html', context) +def get_designations_view(request, username): + designations = get_designations(username) + return JsonResponse(designations, safe=False) + +def unarchive_file(request, id): + try: + file = get_object_or_404(File, id=id) + file.is_read = False + file.save() + messages.success(request, 'File unarchived') + except File.DoesNotExist: + messages.error(request, 'File does not exist') + except Exception as e: + messages.error(request, 'Unable to unarchive: {}'.format(str(e))) + + return render(request, 'filetracking/archive.html') + + +@login_required(login_url="/accounts/login") +def edit_draft_view(request, id, *args, **kwargs): + """ + The function is used to edit and send drafted files, and also alter their title and subject + along with their remarks and attachments + + @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. + """ + + file = get_object_or_404(File, id=id) + 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).order_by('receive_date') + + if request.method == "POST": + if 'send' in request.POST: + current_id = request.user.extrainfo + remarks = request.POST.get('remarks') + subject = request.POST.get('subject') + description = request.POST.get('description') + + file.subject = subject + file.description = description + file.save() + track.update(is_read=True) + + sender = request.POST.get('sender') + current_design = HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').get(id=sender) + + receiver = request.POST.get('receiver') + try: + receiver_id = User.objects.get(username=receiver) + except Exception as e: + messages.error(request, 'Enter a valid destination') + designations = HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').filter(user=request.user) + + context = { + + 'designations': designations, + 'file': file, + 'track': track, + 'notifications': request.user.notifications.all() + } + return render(request, 'filetracking/editdraft.html', context) + receive = request.POST.get('receive') + try: + receive_design = Designation.objects.get(name=receive) + except Exception as e: + messages.error(request, 'Enter a valid Designation') + designations = get_designation(request.user) + + context = { + + 'designations': designations, + 'file': file, + 'notifications': request.user.notifications.all() + } + return render(request, 'filetracking/editdraft.html', context) + + upload_file = request.FILES.get('myfile') + + 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, 'File sent successfully') + + designations = get_designation(request.user) + + designation_name = request.session.get('currentDesignationSelected', 'default_value') + all_available_designations = request.session.get( + 'allDesignations', 'default_value2') + + + username = request.user + designation_id = get_HoldsDesignation_obj( + username, designation_name).id + + remarks = None + receive = None + receiver = None + + if file.file_extra_JSON and file.file_extra_JSON['remarks']: + remarks = file.file_extra_JSON['remarks'] + + context = { + 'designations': designations, + 'file': file, + 'track': track, + 'designation_name': designation_name, + 'designation_id': designation_id, + 'remarks' : remarks, + 'notifications': request.user.notifications.all() + } + + return render(request, 'filetracking/editdraft.html', context) + + + diff --git a/FusionIIIT/applications/globals/api/urls.py b/FusionIIIT/applications/globals/api/urls.py index 72d32c89e..0199f7688 100644 --- a/FusionIIIT/applications/globals/api/urls.py +++ b/FusionIIIT/applications/globals/api/urls.py @@ -14,6 +14,8 @@ url(r'^profile_delete/(?P[0-9]+)/', views.profile_delete, name='delete-profile-api'), url(r'^dashboard/',views.dashboard,name='dashboard-api'), + url(r'^notification/',views.notification,name='notification'), url(r'^notification/read',views.NotificationRead,name='notifications-read') -] + +] \ No newline at end of file diff --git a/FusionIIIT/applications/globals/api/views.py b/FusionIIIT/applications/globals/api/views.py index 12d78e088..d6fc75321 100644 --- a/FusionIIIT/applications/globals/api/views.py +++ b/FusionIIIT/applications/globals/api/views.py @@ -17,7 +17,8 @@ from . import serializers - +from applications.globals.models import (ExtraInfo, Feedback, HoldsDesignation, + Issue, IssueImage, DepartmentInfo) from .utils import get_and_authenticate_user from notifications.models import Notification @@ -30,10 +31,33 @@ def login(request): serializer.is_valid(raise_exception=True) user = get_and_authenticate_user(**serializer.validated_data) data = serializers.AuthUserSerializer(user).data + print(user.id) + desig = list(HoldsDesignation.objects.select_related('user','working','designation').all().filter(working = user).values_list('designation')) + print(desig) + b = [i for sub in desig for i in sub] + design = HoldsDesignation.objects.select_related('user','designation').filter(working=user) + + designation=[] + + + + designation.append(str(user.extrainfo.user_type)) + for i in design: + if str(i.designation) != str(user.extrainfo.user_type): + print('-------') + print(i.designation) + print(user.extrainfo.user_type) + print('') + designation.append(str(i.designation)) + for i in designation: + print(i) + + resp = { 'success' : 'True', 'message' : 'User logged in successfully', - 'token' : data['auth_token'] + 'token' : data['auth_token'], + 'designations':designation } return Response(data=resp, status=status.HTTP_200_OK) @@ -71,6 +95,22 @@ def dashboard(request): return Response(data=resp,status=status.HTTP_200_OK) +@api_view(['GET']) +@permission_classes([IsAuthenticated]) +@authentication_classes([TokenAuthentication]) +def notification(request): + + print(request) + notifications=serializers.NotificationSerializer(request.user.notifications.all(),many=True).data + print("get") + print(notifications) + + resp={ + 'notifications':notifications, + } + + return Response(data=resp,status=status.HTTP_200_OK) + @api_view(['GET']) def profile(request, username=None): user = get_object_or_404(User, username=username) if username else request.user @@ -255,4 +295,4 @@ def NotificationRead(request): response ={ 'error':'Failed, notification is not marked as seen.' } - return Response(response,status=status.HTTP_404_NOT_FOUND) + return Response(response,status=status.HTTP_404_NOT_FOUND) \ No newline at end of file diff --git a/FusionIIIT/applications/globals/views.py b/FusionIIIT/applications/globals/views.py index 5b023abb5..96caff806 100644 --- a/FusionIIIT/applications/globals/views.py +++ b/FusionIIIT/applications/globals/views.py @@ -1,3 +1,4 @@ +from audioop import reverse import json from django.contrib.auth import logout @@ -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 @@ -1044,7 +1047,7 @@ def profile(request, username=None): return render(request, "globals/student_profile4.html", context) if 'achievementsubmit' in request.POST or 'deleteach' in request.POST: return render(request, "globals/student_profile5.html", context) - print("context",context) + # print("context",context) return render(request, "globals/student_profile.html", context) else: return redirect("/") diff --git a/FusionIIIT/applications/health_center/admin.py b/FusionIIIT/applications/health_center/admin.py index 0116b8a3e..7299eff00 100644 --- a/FusionIIIT/applications/health_center/admin.py +++ b/FusionIIIT/applications/health_center/admin.py @@ -1,8 +1,6 @@ from django.contrib import admin -from .models import (Ambulance_request, Appointment, Complaint, Counter, - Doctor, Expiry, Hospital, Hospital_admit, Medicine, - Prescribed_medicine, Prescription, Schedule, Stock) +from .models import * admin.site.register(Doctor) admin.site.register(Appointment) @@ -16,4 +14,8 @@ admin.site.register(Prescription) admin.site.register(Medicine) admin.site.register(Prescribed_medicine) -admin.site.register(Schedule) +admin.site.register(Doctors_Schedule) +admin.site.register(Pathologist_Schedule) +admin.site.register(Announcements) +admin.site.register(SpecialRequest) +admin.site.register(Pathologist) \ No newline at end of file diff --git a/FusionIIIT/applications/health_center/api/serializers.py b/FusionIIIT/applications/health_center/api/serializers.py index dfb72d68a..13aa9f049 100644 --- a/FusionIIIT/applications/health_center/api/serializers.py +++ b/FusionIIIT/applications/health_center/api/serializers.py @@ -41,10 +41,23 @@ class Meta: model=Expiry fields=('__all__') -class ScheduleSerializer(serializers.ModelSerializer): +class DoctorsScheduleSerializer(serializers.ModelSerializer): class Meta: - model=Schedule + model=Doctors_Schedule + fields=('__all__') +class PathologistScheduleSerializer(serializers.ModelSerializer): + + class Meta: + model=Pathologist_Schedule + fields=('__all__') + + + +class AnnouncementSerializer(serializers.ModelSerializer): + + class Meta: + model=Announcements fields=('__all__') diff --git a/FusionIIIT/applications/health_center/api/views.py b/FusionIIIT/applications/health_center/api/views.py index 41912ed50..f82665a69 100644 --- a/FusionIIIT/applications/health_center/api/views.py +++ b/FusionIIIT/applications/health_center/api/views.py @@ -5,7 +5,6 @@ from datetime import datetime, timedelta, time,date from django.db import transaction from notification.views import healthcare_center_notif - from rest_framework.permissions import IsAuthenticated from rest_framework.authentication import TokenAuthentication from rest_framework import status @@ -58,7 +57,7 @@ def student_request_api(request): doctor_id = request.data['doctor_id'] except: return Response({'message': 'Please enter doctor id'}, status=status.HTTP_404_NOT_FOUND) - request.data['schedule'] =get_object_or_404(Schedule,doctor_id=request.data['doctor_id'],day=day).id + request.data['schedule'] =get_object_or_404(Doctors_Schedule,doctor_id=request.data['doctor_id'],day=day).id comp_id = ExtraInfo.objects.filter(user_type='compounder') serializer = serializers.AppointmentSerializer(data=request.data) if serializer.is_valid(): @@ -110,7 +109,7 @@ def student_view_api(request): medicines = serializers.PrescribedMedicineSerializer(Prescribed_medicine.objects.all(),many=True).data complaints = serializers.ComplaintSerializer(Complaint.objects.filter(user_id=user_id).order_by('-date'),many=True).data days = Constants.DAYS_OF_WEEK - schedule=serializers.ScheduleSerializer(Schedule.objects.all().order_by('doctor_id'),many=True).data + schedule=serializers.ScheduleSerializer(Doctors_Schedule.objects.all().order_by('doctor_id'),many=True).data doctors=serializers.DoctorSerializer(Doctor.objects.filter(active=True),many=True).data count=Counter.objects.all() if count: @@ -171,11 +170,11 @@ def compounder_request_api(request): day = request.data['day'] except: return Response({'message': 'Please enter valid day'}, status=status.HTTP_404_NOT_FOUND) - sc = Schedule.objects.filter(doctor_id=doctor_id, day=day) + sc = Doctor.objects.filter(doctor_id=doctor_id, day=day) if sc.count() == 0: serializer = serializers.ScheduleSerializer(data=request.data) else: - sc = get_object_or_404(Schedule,doctor_id=doctor_id,day=day) + sc = get_object_or_404(Doctors_Schedule,doctor_id=doctor_id,day=day) serializer = serializers.ScheduleSerializer(sc,data=request.data,partial=True) if serializer.is_valid(): serializer.save() @@ -191,7 +190,7 @@ def compounder_request_api(request): day = request.data['day'] except: return Response({'message': 'Please enter valid day'}, status=status.HTTP_404_NOT_FOUND) - sc = get_object_or_404(Schedule,doctor_id=doctor_id,day=day) + sc = get_object_or_404(Doctors_Schedule,doctor_id=doctor_id,day=day) sc.delete() resp={'message':'Schedule Deleted successfully'} return Response(data=resp,status=status.HTTP_200_OK) @@ -327,7 +326,7 @@ def compounder_view_api(request): appointments_future= serializers.AppointmentSerializer(Appointment.objects.filter(date__gt=datetime.now()).order_by('date'),many=True).data stocks = serializers.StockSerializer(Stock.objects.all(),many=True).data days = Constants.DAYS_OF_WEEK - schedule= serializers.ScheduleSerializer(Schedule.objects.all().order_by('doctor_id'),many=True).data + schedule= serializers.ScheduleSerializer(Doctors_Schedule.objects.all().order_by('doctor_id'),many=True).data expired= serializers.ExpirySerializer(Expiry.objects.filter(expiry_date__lt=datetime.now(),returned=False).order_by('expiry_date'),many=True).data live_meds= serializers.ExpirySerializer(Expiry.objects.filter(returned=False).order_by('quantity'),many=True).data count= Counter.objects.all() @@ -339,7 +338,7 @@ def compounder_view_api(request): Counter.objects.create(count=0,fine=0) count= serializers.CounterSerializer(Counter.objects.get()).data hospitals=serializers.HospitalSerializer(Hospital.objects.all(),many=True).data - schedule= serializers.ScheduleSerializer(Schedule.objects.all().order_by('day','doctor_id'),many=True).data + schedule= serializers.ScheduleSerializer(Doctors_Schedule.objects.all().order_by('day','doctor_id'),many=True).data doctors= serializers.DoctorSerializer(Doctor.objects.filter(active=True).order_by('id'),many=True).data resp= {'days': days, 'count': count,'expired':expired, @@ -351,6 +350,4 @@ def compounder_view_api(request): else: resp = {'message': 'invalid request'} - return Response(data=resp,status=status.HTTP_404_NOT_FOUND) # compounder view ends - - + return Response(data=resp,status=status.HTTP_404_NOT_FOUND) # compounder view ends \ No newline at end of file diff --git a/FusionIIIT/applications/health_center/models.py b/FusionIIIT/applications/health_center/models.py index 4daaae0de..b22410cd4 100644 --- a/FusionIIIT/applications/health_center/models.py +++ b/FusionIIIT/applications/health_center/models.py @@ -1,4 +1,5 @@ from django.db import models +from datetime import date from applications.globals.models import ExtraInfo @@ -21,16 +22,32 @@ class Constants: (1, 'Dr.Vinay'), ) + + NAME_OF_PATHOLOGIST = ( + (0, 'Dr.Ajay'), + (1, 'Dr.Rahul'), + + ) class Doctor(models.Model): - doctor_name = models.IntegerField(choices=Constants.NAME_OF_DOCTOR) - doctor_phone = models.CharField(max_length=10) + doctor_name = models.CharField(choices=Constants.NAME_OF_DOCTOR, max_length=50) + doctor_phone = models.CharField(max_length=15) specialization = models.CharField(max_length=100) active = models.BooleanField(default=True) def __str__(self): return self.doctor_name +class Pathologist(models.Model): + pathologist_name = models.CharField(choices=Constants.NAME_OF_PATHOLOGIST, max_length=50) + pathologist_phone = models.CharField(max_length=15) + specialization = models.CharField(max_length=100) + active = models.BooleanField(default=True) + + def __str__(self): + return self.pathologist_name + + class Complaint(models.Model): user_id = models.ForeignKey(ExtraInfo,on_delete=models.CASCADE) feedback = models.CharField(max_length=100, null=True, blank=False) #This is the feedback given by the compounder @@ -65,7 +82,7 @@ class Hospital(models.Model): def __str__(self): return self.hospital_name - + class Expiry(models.Model): medicine_id=models.ForeignKey(Stock,on_delete=models.CASCADE) quantity = models.IntegerField(default=0) @@ -77,23 +94,39 @@ class Expiry(models.Model): def __str__(self): return self.medicine_id.medicine_name -class Schedule(models.Model): +class Doctors_Schedule(models.Model): doctor_id = models.ForeignKey(Doctor,on_delete=models.CASCADE) - day = models.IntegerField(choices=Constants.DAYS_OF_WEEK) + # pathologist_id = models.ForeignKey(Pathologist,on_delete=models.CASCADE, default=0) + day = models.CharField(choices=Constants.DAYS_OF_WEEK, max_length=10) + from_time = models.TimeField(null=True,blank=True) + to_time = models.TimeField(null=True,blank=True) + room = models.IntegerField() + date = models.DateField(auto_now=True) + +class Pathologist_Schedule(models.Model): + # doctor_id = models.ForeignKey(Doctor,on_delete=models.CASCADE) + pathologist_id = models.ForeignKey(Pathologist,on_delete=models.CASCADE) + day = models.CharField(choices=Constants.DAYS_OF_WEEK, max_length=10) from_time = models.TimeField(null=True,blank=True) to_time = models.TimeField(null=True,blank=True) room = models.IntegerField() date = models.DateField(auto_now=True) + + class Counter(models.Model): count=models.IntegerField(default=0) fine=models.IntegerField(default=0) doc_count=models.IntegerField(default=0) + patho_count=models.IntegerField(default=0) def doctor_count(self): self.doc_count+=1 return "" + def pathologist_count(self): + self.doc_count+=1 + return "" def increment(self): self.count+=1 return "" @@ -105,8 +138,12 @@ def range_count(self): dif=0 elif self.count<=4: dif=self.doc_count-self.count - else: + elif self.count<=4: dif=self.count-self.doc_count + elif self.count<=4: + dif=self.patho_count-self.count + else: + dif=self.count-self.patho_count return range(dif) def empty_fine(self): self.count=0 @@ -120,7 +157,7 @@ class Appointment(models.Model): user_id = models.ForeignKey(ExtraInfo,on_delete=models.CASCADE) doctor_id = models.ForeignKey(Doctor,on_delete=models.CASCADE) description = models.CharField(max_length=50) - schedule = models.ForeignKey(Schedule, on_delete=models.CASCADE,null=True, blank=True) + schedule = models.ForeignKey(Doctors_Schedule, on_delete=models.CASCADE,null=True, blank=True) date = models.DateField() def __str__(self): @@ -133,7 +170,7 @@ class Prescription(models.Model): details = models.CharField(max_length=100) date = models.DateField() test = models.CharField(max_length=200, null=True, blank=True) - appointment = models.ForeignKey(Appointment, on_delete=models.CASCADE,null=True, blank=True) + # appointment = models.ForeignKey(Appointment, on_delete=models.CASCADE,null=True, blank=True) def __str__(self): return self.details @@ -165,3 +202,28 @@ class Hospital_admit(models.Model): admission_date = models.DateField() discharge_date = models.DateField(null=True, blank=True) reason = models.CharField(max_length=50) + +class Announcements(models.Model): + anno_id = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE, related_name='announcements_made') + ann_date = models.DateTimeField(default="04-04-2021") + message = models.CharField(max_length=200) + batch = models.CharField(max_length=40,default="Year-1") + department = models.CharField(max_length=40,default="ALL") + programme = models.CharField(max_length=10) + upload_announcement = models.FileField(upload_to='health_center/upload_announcement', null=True, default=" ") + def __str__(self): + return str(self.anno_id.user.username) + + +class SpecialRequest(models.Model): + request_ann_maker = models.ForeignKey(ExtraInfo, on_delete=models.CASCADE, related_name='special_requests_made') + request_date = models.DateTimeField(default=date.today) + brief = models.CharField(max_length=20, default='--') + request_details = models.CharField(max_length=200) + upload_request = models.FileField(blank=True) + status = models.CharField(max_length=50,default='Pending') + remarks = models.CharField(max_length=300, default="--") + request_receiver = models.CharField(max_length=30, default="--") + + def __str__(self): + return str(self.request_ann_maker.user.username) \ No newline at end of file diff --git a/FusionIIIT/applications/health_center/urls.py b/FusionIIIT/applications/health_center/urls.py index b599cdd44..a3969188e 100644 --- a/FusionIIIT/applications/health_center/urls.py +++ b/FusionIIIT/applications/health_center/urls.py @@ -1,6 +1,7 @@ +from django import views from django.conf.urls import url,include -from .views import compounder_view, healthcenter, student_view, schedule_entry,doctor_entry,compounder_entry +from .views import compounder_view, healthcenter, student_view, schedule_entry,doctor_entry,compounder_entry,announcement app_name = 'healthcenter' @@ -12,12 +13,14 @@ #views url(r'^compounder/$', compounder_view, name='compounder_view'), url(r'^student/$', student_view, name='student_view'), + url(r'announcement/', announcement, name='announcement'), #database entry - url(r'^schedule_entry', schedule_entry, name='schedule_entry'), + + url(r'^doctor_entry', doctor_entry, name='doctor_entry'), url(r'^compounder_entry', compounder_entry, name='compounder_entry'), #api url(r'^api/',include('applications.health_center.api.urls')) -] +] \ No newline at end of file diff --git a/FusionIIIT/applications/health_center/utils.py b/FusionIIIT/applications/health_center/utils.py index f965c5f60..e0ec56c75 100644 --- a/FusionIIIT/applications/health_center/utils.py +++ b/FusionIIIT/applications/health_center/utils.py @@ -6,8 +6,8 @@ from notification.views import healthcare_center_notif from .models import (Ambulance_request, Appointment, Complaint, Doctor, Expiry, Hospital, Hospital_admit, Medicine, - Prescribed_medicine, Prescription, Schedule, - Stock) + Prescribed_medicine, Prescription, Doctors_Schedule,Pathologist_Schedule, + Stock, Announcements, SpecialRequest, Pathologist) def datetime_handler(date): ''' @@ -65,6 +65,31 @@ def compounder_view_handler(request): ) data={'status':1, 'doctor':doctor, 'specialization':specialization, 'phone':phone} return JsonResponse(data) + + # updating new pathologist info in db + elif 'add_pathologist' in request.POST: + doctor=request.POST.get('new_pathologist') + specialization=request.POST.get('specialization') + phone=request.POST.get('phone') + Pathologist.objects.create( + pathologist_name=doctor, + pathologist_phone=phone, + specialization=specialization, + active=True + ) + data={'status':1, 'pathologist_name':doctor, 'specialization':specialization, 'pathologist_phone':phone} + return JsonResponse(data) + + # making announcements from compounder + elif 'add' in request.POST: + ven=request.POST.get('venue') + announcement=request.POST.get('announcement') + Announcement.objects.create( + venue=ven, + announcement=announcement, + ) + data={ 'venue':ven, 'announcement':announcement } + return JsonResponse(data) # remove doctor by changing active status elif 'remove_doctor' in request.POST: @@ -73,6 +98,14 @@ def compounder_view_handler(request): doc=Doctor.objects.get(id=doctor).doctor_name data={'status':1, 'id':doctor, 'doc':doc} return JsonResponse(data) + + # remove pathologist by changing active status + elif 'remove_pathologist' in request.POST: + doctor=request.POST.get('pathologist_active') + Pathologist.objects.filter(id=doctor).update(active=False) + doc=Pathologist.objects.get(id=doctor).pathologist_name + data={'status':1, 'id':doctor, 'doc':doc} + return JsonResponse(data) # discharge patients elif 'discharge' in request.POST: @@ -106,31 +139,64 @@ def compounder_view_handler(request): return JsonResponse(data) # edit schedule for doctors - elif 'edit' in request.POST: + elif 'edit_1' in request.POST: doctor = request.POST.get('doctor') day = request.POST.get('day') time_in = request.POST.get('time_in') time_out = request.POST.get('time_out') room = request.POST.get('room') - schedule = Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor, day=day) + schedule = Doctors_Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor, day=day) doctor_id = Doctor.objects.get(id=doctor) if schedule.count() == 0: - Schedule.objects.create(doctor_id=doctor_id, day=day, room=room, + Doctors_Schedule.objects.create(doctor_id=doctor_id, day=day, room=room, from_time=time_in, to_time=time_out) else: - Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor_id, day=day).update(room=room) - Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor_id, day=day).update(from_time=time_in) - Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor_id, day=day).update(to_time=time_out) + Doctors_Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor_id, day=day).update(room=room) + Doctors_Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor_id, day=day).update(from_time=time_in) + Doctors_Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor_id, day=day).update(to_time=time_out) data={'status':1} return JsonResponse(data) + # remove schedule for a doctor elif 'rmv' in request.POST: doctor = request.POST.get('doctor') + + day = request.POST.get('day') + Doctors_Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor, day=day).delete() + data = {'status': 1} + return JsonResponse(data) + + + # edit schedule for pathologists + elif 'edit12' in request.POST: + doctor = request.POST.get('pathologist') + day = request.POST.get('day') + time_in = request.POST.get('time_in') + time_out = request.POST.get('time_out') + room = request.POST.get('room') + pathologist_id = Pathologist.objects.get(id=doctor) + schedule = Pathologist_Schedule.objects.select_related('pathologist_id').filter(pathologist_id=doctor, day=day) + if schedule.count() == 0: + Pathologist_Schedule.objects.create(pathologist_id=pathologist_id, day=day, room=room, + from_time=time_in, to_time=time_out) + else: + Pathologist_Schedule.objects.select_related('pathologist_id').filter(pathologist_id=pathologist_id, day=day).update(room=room) + Pathologist_Schedule.objects.select_related('pathologist_id').filter(pathologist_id=pathologist_id, day=day).update(from_time=time_in) + Pathologist_Schedule.objects.select_related('pathologist_id').filter(pathologist_id=pathologist_id, day=day).update(to_time=time_out) + data={'status':1} + return JsonResponse(data) + + + # remove schedule for a doctor + elif 'rmv1' in request.POST: + doctor = request.POST.get('pathologist') + day = request.POST.get('day') - Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor, day=day).delete() + Pathologist_Schedule.objects.select_related('pathologist_id').filter(pathologist_id=doctor, day=day).delete() data = {'status': 1} return JsonResponse(data) + elif 'add_medicine' in request.POST: medicine = request.POST.get('new_medicine') @@ -306,21 +372,21 @@ def compounder_view_handler(request): doctor = Doctor.objects.get(id=doctor_id) details = request.POST.get('details') tests = request.POST.get('tests') - app = Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').filter(user_id=user_id,date=datetime.now()) - if app: - appointment = Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').get(user_id=user_id,date=datetime.now()) - else: - appointment = None + # app = Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').filter(user_id=user_id,date=datetime.now()) + # if app: + # appointment = Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').get(user_id=user_id,date=datetime.now()) + # else: + # appointment = None Prescription.objects.create( user_id=user, doctor_id=doctor, details=details, date=datetime.now(), test=tests, - appointment=appointment + # appointment=appointment ) query = Medicine.objects.select_related('patient','patient__user','patient__department').filter(patient=user) - prescribe = Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','appointment','appointment__user_id','appointment__user_id__user','appointment__user_id__department','appointment__doctor_id','appointment__schedule','appointment__schedule__doctor_id').all().last() + prescribe = Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id').all().last() for medicine in query: medicine_id = medicine.medicine_id quantity = medicine.quantity @@ -365,7 +431,7 @@ def compounder_view_handler(request): return JsonResponse(data) elif 'cancel_presc' in request.POST: presc_id = request.POST.get('cancel_presc') - Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','appointment','appointment__user_id','appointment__user_id__user','appointment__user_id__department','appointment__doctor_id','appointment__schedule','appointment__schedule__doctor_id').filter(pk=presc_id).delete() + Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id').filter(pk=presc_id).delete() data = {'status': 1} return JsonResponse(data) elif 'medicine' in request.POST: @@ -422,12 +488,14 @@ def student_view_handler(request): healthcare_center_notif(request.user, cmp.user, 'appoint_req') return JsonResponse(data) + + elif 'doctor' in request.POST: doctor_id = request.POST.get('doctor') - days = Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor_id).values('day') + days =Dotors_Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor_id).values('day') today = datetime.today() time = datetime.today().time() - sch = Schedule.objects.select_related('doctor_id').filter(date__gte=today) + sch = Doctors_Schedule.objects.select_related('doctor_id').filter(date__gte=today) for day in days: for i in range(0, 7): @@ -436,12 +504,14 @@ def student_view_handler(request): d = day.get('day') if dayi == d: - Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor_id, day=dayi).update(date=date) + Doctors_Schedule.objects.select_related('doctor_id').filter(doctor_id=doctor_id, day=dayi).update(date=date) sch.filter(date=today, to_time__lt=time).delete() schedule = sch.filter(doctor_id=doctor_id).order_by('date') schedules = serializers.serialize('json', schedule) return HttpResponse(schedules, content_type='json') + + elif 'feed_submit' in request.POST: user_id = ExtraInfo.objects.select_related('user','department').get(user=request.user) feedback = request.POST.get('feedback') @@ -461,5 +531,4 @@ def student_view_handler(request): app_id = request.POST.get('cancel_app') Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').filter(pk=app_id).delete() data = {'status': 1} - return JsonResponse(data) - + return JsonResponse(data) \ No newline at end of file diff --git a/FusionIIIT/applications/health_center/views.py b/FusionIIIT/applications/health_center/views.py index cd2bba84f..8ded8b462 100644 --- a/FusionIIIT/applications/health_center/views.py +++ b/FusionIIIT/applications/health_center/views.py @@ -1,18 +1,19 @@ import json -from datetime import datetime, timedelta, time +from datetime import date, datetime, timedelta, time import xlrd import os from applications.globals.models import ExtraInfo, HoldsDesignation, Designation, DepartmentInfo +from django.views.decorators.csrf import csrf_exempt from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User from django.core import serializers from django.http import HttpResponse, HttpResponseRedirect, JsonResponse -from django.shortcuts import render +from django.shortcuts import get_object_or_404, render, redirect from notification.views import healthcare_center_notif from .models import (Ambulance_request, Appointment, Complaint, Constants, - Counter, Doctor, Expiry, Hospital, Hospital_admit, - Medicine, Prescribed_medicine, Prescription, Schedule, - Stock) + Counter, Doctor,Pathologist, Expiry, Hospital, Hospital_admit, + Medicine, Prescribed_medicine, Prescription, Doctors_Schedule,Pathologist_Schedule, + Stock,SpecialRequest,Announcements) from .utils import datetime_handler, compounder_view_handler, student_view_handler @@ -40,7 +41,7 @@ def healthcenter(request): def compounder_view(request): ''' - This function handles post reques for compounder and render pages accordingly + This function handles post requests for compounder and render pages accordingly @param: request - contains metadata about the requested page @@ -79,19 +80,23 @@ def compounder_view(request): users = ExtraInfo.objects.select_related('user','department').filter(user_type='student') stocks = Stock.objects.all() days = Constants.DAYS_OF_WEEK - schedule=Schedule.objects.select_related('doctor_id').all().order_by('doctor_id') + schedule=Doctors_Schedule.objects.select_related('doctor_id').all().order_by('doctor_id') + schedule1=Pathologist_Schedule.objects.select_related('pathologist_id').all().order_by('pathologist_id') expired=Expiry.objects.select_related('medicine_id').filter(expiry_date__lt=datetime.now(),returned=False).order_by('expiry_date') live_meds=Expiry.objects.select_related('medicine_id').filter(returned=False).order_by('quantity') count=Counter.objects.all() - presc_hist=Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','appointment','appointment__user_id','appointment__user_id__user','appointment__user_id__department','appointment__doctor_id','appointment__schedule','appointment__schedule__doctor_id').all().order_by('-date') - medicines_presc=Prescribed_medicine.objects.select_related('prescription_id','prescription_id__user_id','prescription_id__user_id__user','prescription_id__user_id__department','prescription_id__doctor_id','prescription_id__appointment','prescription_id__appointment__user_id','prescription_id__appointment__user_id__user','prescription_id__appointment__user_id__department','prescription_id__appointment__doctor_id','prescription_id__appointment__schedule','prescription_id__appointment__schedule__doctor_id','medicine_id').all() + presc_hist=Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id').all().order_by('-date') + medicines_presc=Prescribed_medicine.objects.select_related('prescription_id','prescription_id__user_id','prescription_id__user_id__user','prescription_id__user_id__department','prescription_id__doctor_id').all() if count: Counter.objects.all().delete() Counter.objects.create(count=0,fine=0) count=Counter.objects.get() hospitals=Hospital.objects.all() - schedule=Schedule.objects.select_related('doctor_id').all().order_by('day','doctor_id') + schedule=Doctors_Schedule.objects.select_related('doctor_id').all().order_by('day','doctor_id') + schedule1=Pathologist_Schedule.objects.select_related('pathologist_id').all().order_by('day','pathologist_id') + doctors=Doctor.objects.filter(active=True).order_by('id') + pathologists=Pathologist.objects.filter(active=True).order_by('id') doct= ["Dr. G S Sandhu", "Dr. Jyoti Garg", "Dr. Arvind Nath Gupta"] @@ -100,8 +105,8 @@ def compounder_view(request): {'days': days, 'users': users, 'count': count,'expired':expired, 'stocks': stocks, 'all_complaints': all_complaints, 'all_hospitals': all_hospitals, 'hospitals':hospitals, 'all_ambulances': all_ambulances, - 'appointments_today': appointments_today, 'doctors': doctors, 'doct': doct, - 'appointments_future': appointments_future, 'schedule': schedule, 'live_meds': live_meds, 'presc_hist': presc_hist, 'medicines_presc': medicines_presc, 'hospitals_list': hospitals_list}) + 'appointments_today': appointments_today, 'doctors': doctors, 'pathologists':pathologists, 'doct': doct, + 'appointments_future': appointments_future, 'schedule': schedule, 'schedule1': schedule1, 'live_meds': live_meds, 'presc_hist': presc_hist, 'medicines_presc': medicines_presc, 'hospitals_list': hospitals_list}) elif usertype == 'student': return HttpResponseRedirect("/healthcenter/student") # compounder view ends @@ -137,12 +142,15 @@ def student_view(request): hospitals = Hospital_admit.objects.select_related('user_id','user_id__user','user_id__department','doctor_id').filter(user_id=user_id).order_by('-admission_date') appointments = Appointment.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','schedule','schedule__doctor_id').filter(user_id=user_id).order_by('-date') ambulances = Ambulance_request.objects.select_related('user_id','user_id__user','user_id__department').filter(user_id=user_id).order_by('-date_request') - prescription = Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id','appointment','appointment__user_id','appointment__user_id__user','appointment__user_id__department','appointment__doctor_id','appointment__schedule','appointment__schedule__doctor_id').filter(user_id=user_id).order_by('-date') - medicines = Prescribed_medicine.objects.select_related('prescription_id','prescription_id__user_id','prescription_id__user_id__user','prescription_id__user_id__department','prescription_id__doctor_id','prescription_id__appointment','prescription_id__appointment__user_id','prescription_id__appointment__user_id__user','prescription_id__appointment__user_id__department','prescription_id__appointment__doctor_id','prescription_id__appointment__schedule','prescription_id__appointment__schedule__doctor_id','medicine_id').all() + prescription = Prescription.objects.select_related('user_id','user_id__user','user_id__department','doctor_id').filter(user_id=user_id).order_by('-date') + medicines = Prescribed_medicine.objects.select_related('prescription_id','prescription_id__user_id','prescription_id__user_id__user','prescription_id__user_id__department','prescription_id__doctor_id','medicine_id').all() complaints = Complaint.objects.select_related('user_id','user_id__user','user_id__department').filter(user_id=user_id).order_by('-date') days = Constants.DAYS_OF_WEEK - schedule=Schedule.objects.select_related('doctor_id').all().order_by('doctor_id') + schedule=Doctors_Schedule.objects.select_related('doctor_id').all().order_by('doctor_id') + schedule1=Pathologist_Schedule.objects.select_related('pathologist_id').all().order_by('pathologist_id') doctors=Doctor.objects.filter(active=True) + pathologists=Pathologist.objects.filter(active=True) + count=Counter.objects.all() if count: @@ -155,9 +163,9 @@ def student_view(request): return render(request, 'phcModule/phc_student.html', {'complaints': complaints, 'medicines': medicines, - 'ambulances': ambulances, 'doctors': doctors, 'days': days,'count':count, + 'ambulances': ambulances, 'doctors': doctors, 'pathologists':pathologists, 'days': days,'count':count, 'hospitals': hospitals, 'appointments': appointments, - 'prescription': prescription, 'schedule': schedule, 'users': users,'doct': doct, 'curr_date': datetime.now().date()}) + 'prescription': prescription, 'schedule': schedule, 'schedule1': schedule1,'users': users,'doct': doct, 'curr_date': datetime.now().date()}) elif usertype == 'compounder': return HttpResponseRedirect("/healthcenter/compounder") # student view ends @@ -238,6 +246,36 @@ def doctor_entry(request): pass return HttpResponse("Hello") +def pathologist_entry(request): + ''' + This function inputs new pathologist' details into Doctor class in database + @param: + request - contains metadata about the requested page + + ''' + excel = xlrd.open_workbook(os.path.join(os.getcwd(), 'dbinsertscripts/healthcenter/Pathologist-List.xlsx')) + z = excel.sheet_by_index(0) + + for i in range(1, 5): + try: + name = str(z.cell(i,0).value) + print(name) + phone = str(int(z.cell(i,1).value)) + print(phone) + spl = str(z.cell(i,2).value) + u = Pathologist.objects.create( + pathologist_name = name, + pathologist_phone = phone, + specialization=spl + ) + print("Pathologist done -> ") + except Exception as e: + print(e) + print(i) + pass + return HttpResponse("Hello") + + def compounder_entry(request): ''' This function inputs new compounder details into Doctor class in database @@ -310,4 +348,115 @@ def compounder_entry(request): print(e) print(i) pass - return HttpResponse("Hello") \ No newline at end of file + return HttpResponse("Hello") + +@login_required(login_url='/accounts/login') +def publish(request): + return render(request,'../templates/health_center/publish.html' ,{}) + + +def browse_announcements(): + """ + This function is used to browse Announcements Department-Wise + made by different faculties and admin. + + @variables: + cse_ann - Stores CSE Department Announcements + ece_ann - Stores ECE Department Announcements + me_ann - Stores ME Department Announcements + sm_ann - Stores SM Department Announcements + all_ann - Stores Announcements intended for all Departments + context - Dictionary for storing all above data + + """ + cse_ann = Announcements.objects.filter(department="CSE") + ece_ann = Announcements.objects.filter(department="ECE") + me_ann = Announcements.objects.filter(department="ME") + sm_ann = Announcements.objects.filter(department="SM") + all_ann = Announcements.objects.filter(department="ALL") + + context = { + "cse" : cse_ann, + "ece" : ece_ann, + "me" : me_ann, + "sm" : sm_ann, + "all" : all_ann + } + + return context + +def get_to_request(username): + """ + This function is used to get requests for the receiver + + @variables: + req - Contains request queryset + + """ + req = SpecialRequest.objects.filter(request_receiver=username) + return req + + + +@login_required(login_url='/accounts/login') +def announcement(request): + """ + This function is contains data for Requests and Announcement Related methods. + Data is added to Announcement Table using this function. + + @param: + request - contains metadata about the requested page + + @variables: + usrnm, user_info, ann_anno_id - Stores data needed for maker + batch, programme, message, upload_announcement, + department, ann_date, user_info - Gets and store data from FORM used for Announcements for Students. + + """ + usrnm = get_object_or_404(User, username=request.user.username) + user_info = ExtraInfo.objects.all().select_related('user','department').filter(user=usrnm).first() + num = 1 + ann_anno_id = user_info.id + requests_received = get_to_request(usrnm) + if request.method == 'POST': + formObject = Announcements() + # formObject.key = Projects.objects.get(id=request.session['projectId']) + user_info = ExtraInfo.objects.all().select_related('user','department').get(id=ann_anno_id) + getstudents = ExtraInfo.objects.select_related('user') + recipients = User.objects.filter(extrainfo__in=getstudents) + # formObject.anno_id=1 + formObject.anno_id=user_info + formObject.batch = request.POST['batch'] + formObject.programme = request.POST['programme'] + formObject.message = request.POST['announcement'] + formObject. upload_announcement = request.FILES.get('upload_announcement') + formObject.department = request.POST['department'] + formObject.ann_date = date.today() + #formObject.amount = request.POST['amount'] + formObject.save() + return redirect('../../compounder/') + + # batch = request.POST.get('batch', '') + # programme = request.POST.get('programme', '') + # message = request.POST.get('announcement', '') + # upload_announcement = request.FILES.get('upload_announcement') + # department = request.POST.get('department') + # ann_date = date.today() + # user_info = ExtraInfo.objects.all().select_related('user','department').get(id=ann_anno_id) + # getstudents = ExtraInfo.objects.select_related('user') + # recipients = User.objects.filter(extrainfo__in=getstudents) + + # obj1, created = Announcements.objects.get_or_create(anno_id=user_info, + # batch=batch, + # programme=programme, + # message=message, + # upload_announcement=upload_announcement, + # department = department, + # ann_date=ann_date) + # # department_notif(usrnm, recipients , message) + + context = browse_announcements() + return render(request, 'health_center/make_announce_comp.html', {"user_designation":user_info.user_type, + "announcements":context, + "request_to":requests_received + }) \ No newline at end of file diff --git a/FusionIIIT/applications/placement_cell/forms.py b/FusionIIIT/applications/placement_cell/forms.py index 54fb122ba..aea81b795 100644 --- a/FusionIIIT/applications/placement_cell/forms.py +++ b/FusionIIIT/applications/placement_cell/forms.py @@ -410,7 +410,7 @@ class SendInvite(forms.Form): company - name of company """ company = forms.ModelChoiceField(required=True, queryset=NotifyStudent.objects.all(), label="company") - rollno = forms.IntegerField(label="rollno", widget=forms.NumberInput(attrs={'min': 0}), required=False) + rollno = forms.CharField(label="rollno", widget=forms.TextInput(attrs={'min': 0}), required=False) programme = forms.ChoiceField(choices = Con.PROGRAMME, required=False, label="programme", widget=forms.Select(attrs={'style': "height:45px", 'onchange': "changeDeptForSend()", @@ -483,6 +483,7 @@ def clean_company_name(self): return company_name + def current_year(): return date.today().year @@ -545,6 +546,87 @@ class SearchPbiRecord(forms.Form): label="cname", required=False) + +class SendInvitation(forms.Form): + """ + The form is used to send invite to students about upcoming placement or pbi events. + @variables: + company - name of company + """ + company = forms.ModelChoiceField(required=True, queryset=NotifyStudent.objects.all(), label="company") + rollno = forms.IntegerField(label="rollno", widget=forms.NumberInput(attrs={'min': 0}), required=False) + programme = forms.ChoiceField(choices = Con.PROGRAMME, required=False, + label="programme", widget=forms.Select(attrs={'style': "height:45px", + 'onchange': "changeDeptForSend()", + 'id': "id_programme_send"})) + + dep_btech = forms.MultipleChoiceField(choices = Constants.BTECH_DEP, required=False, label="department", + widget=forms.CheckboxSelectMultiple) + dep_bdes = forms.MultipleChoiceField(choices = Constants.BDES_DEP, required=False, label="department", + widget=forms.CheckboxSelectMultiple) + dep_mtech = forms.MultipleChoiceField(choices = Constants.MTECH_DEP, required=False, label="department", + widget=forms.CheckboxSelectMultiple) + dep_mdes = forms.MultipleChoiceField(choices = Constants.MDES_DEP, required=False, label="department", + widget=forms.CheckboxSelectMultiple) + dep_phd = forms.MultipleChoiceField(choices = Constants.PHD_DEP, required=False, label="department", + widget=forms.CheckboxSelectMultiple) + cpi = forms.DecimalField(label="cpi", required=False) + no_of_days = forms.CharField(required=True, widget=forms.NumberInput(attrs={ 'min':0, + 'max':30, + 'max_length': 10, + 'class': 'form-control'})) + + +class AddPlacementSchedule(forms.Form): + """ + The form is used to placement or pbi schedule. + @variables: + time - time of placement activity + ctc - salary + company_name - name of company + placement_type - placement type (placement/pbi) + location - location of company + description - description of company + placement_date - date of placement activity + """ + time = forms.TimeField(label='time', widget=forms.widgets.TimeInput(attrs={'type': "time", + 'value':"00:00", + 'min':"0:00", + 'max':"24:00"})) + ctc = forms.DecimalField(label="ctc", widget=forms.NumberInput(attrs={ 'min':0, 'step': 0.25}) ) + company_name = forms.CharField(widget=forms.TextInput(attrs={'max_length': 100, + 'class': 'field', + 'list': 'company_dropdown1', + 'id': 'company_input'}), + label="company_name") + placement_type = forms.ChoiceField(widget=forms.Select(attrs={'style': "height:45px"}), label="placement_type", + choices=Constants.PLACEMENT_TYPE) + location = forms.CharField(widget=forms.TextInput(attrs={'max_length': 100, + 'class': 'field'}), + label="location") + description = forms.CharField(widget=forms.Textarea(attrs={'max_length': 1000, + 'class': 'form-control'}), + label="description", required=False) + attached_file = forms.FileField(required=False) + placement_date = forms.DateField(label='placement_date', widget=forms.DateInput(attrs={'class':'datepicker'})) + + def clean_ctc(self): + ctc = self.cleaned_data['ctc'] + # print('form validation \n\n\n\n', ctc) + if ctc <= 0: + raise forms.ValidationError("CTC must be positive value") + + return ctc + + def clean_company_name(self): + company_name = self.cleaned_data['company_name'] + # print('form validation \n\n\n\n', ctc) + if NotifyStudent.objects.filter(company_name=company_name): + raise forms.ValidationError("company_name must be unique") + + return company_name + + class SearchHigherRecord(forms.Form): """ The form is used to search from higher study record based on various parameters . @@ -589,7 +671,7 @@ class ManagePlacementRecord(forms.Form): stuname = forms.CharField(widget=forms.TextInput(attrs={'max_length': 100, 'class': 'field'}), label="stuname", required=False) - roll = forms.IntegerField(widget=forms.NumberInput(attrs={ 'min':0, + roll = forms.CharField(widget=forms.TextInput(attrs={ 'min':0, 'max_length': 10, 'class': 'form-control'}), label="roll", required=False) diff --git a/FusionIIIT/applications/placement_cell/models.py b/FusionIIIT/applications/placement_cell/models.py index d9837608e..53f8d8ea4 100644 --- a/FusionIIIT/applications/placement_cell/models.py +++ b/FusionIIIT/applications/placement_cell/models.py @@ -1,6 +1,4 @@ -# imports import datetime - from django.db import models from django.utils import timezone from django.utils.translation import gettext as _ @@ -56,6 +54,7 @@ class Constants: ('CSE', 'CSE'), ('ME','ME'), ('ECE','ECE'), + ('SM','SM'), ) BDES_DEP = ( diff --git a/FusionIIIT/applications/placement_cell/urls.py b/FusionIIIT/applications/placement_cell/urls.py index 9f3e77307..190638861 100644 --- a/FusionIIIT/applications/placement_cell/urls.py +++ b/FusionIIIT/applications/placement_cell/urls.py @@ -13,6 +13,7 @@ url(r'^student_records/$', views.student_records, name='student_records'), url(r'^manage_records/$', views.manage_records, name='manage_records'), url(r'^statistics/$', views.placement_statistics, name='placement_statistics'), + url(r'^delete_placement_statistics/$', views.delete_placement_statistics, name='delete_placement_statistics'), url(r'^cv/(?P[a-zA-Z0-9\.]{1,20})/$', views.cv, name="cv"), diff --git a/FusionIIIT/applications/placement_cell/views.py b/FusionIIIT/applications/placement_cell/views.py index 80c8f12d7..25ecadebd 100644 --- a/FusionIIIT/applications/placement_cell/views.py +++ b/FusionIIIT/applications/placement_cell/views.py @@ -29,6 +29,7 @@ from notification.views import placement_cell_notif from applications.globals.models import (DepartmentInfo, ExtraInfo, HoldsDesignation) +from applications.academic_information.models import Student from .forms import (AddAchievement, AddChairmanVisit, AddCourse, AddEducation, AddExperience, AddReference, AddPatent, AddProfile, AddProject, AddPublication, AddSchedule, AddSkill, ManageHigherRecord, @@ -143,123 +144,2826 @@ ''' logger = logging.getLogger('django.server') +@login_required +def placement__Statistics(request): + ''' + logic of the view shown under Placement Statistics tab + ''' + user = request.user -def get_reference_list(request): - if request.method == 'POST': - # arr = request.POST.getlist('arr[]') - # print(arr) - # print(type(arr)) - user = request.user - profile = get_object_or_404(ExtraInfo, Q(user=user)) - student = get_object_or_404(Student, Q(id=profile.id)) - print(student) - reference_objects = Reference.select_related('unique_id').objects.filter(unique_id=student) - reference_objects = serializers.serialize('json', list(reference_objects)) - context = { - 'reference_objs': reference_objects - } - return JsonResponse(context) + statistics_tab = 1 + strecord_tab=1 + delete_operation = 0 + pagination_placement = 0 + pagination_pbi = 0 + pagination_higher = 0 + is_disabled = 0 + paginator = '' + page_range = '' + officer_statistics_past_pbi_search = 0 + officer_statistics_past_higher_search = 0 + profile = get_object_or_404(ExtraInfo, Q(user=user)) + studentrecord = StudentRecord.objects.select_related('unique_id','record_id').all() -# Ajax for the company name dropdown for CompanyName when filling AddSchedule -def company_name_dropdown(request): - if request.method == 'POST': - current_value = request.POST.get('current_value') - company_names = CompanyDetails.objects.filter(Q(company_name__startswith=current_value)) - company_name = [] - for name in company_names: - company_name.append(name.company_name) + years = PlacementRecord.objects.filter(~Q(placement_type="HIGHER STUDIES")).values('year').annotate(Count('year')) + records = PlacementRecord.objects.values('name', 'year', 'ctc', 'placement_type').annotate(Count('name'), Count('year'), Count('placement_type'), Count('ctc')) - context = { - 'company_names': company_name - } - return JsonResponse(context) -# Ajax for all the roles in the dropdown -def checking_roles(request): - if request.method == 'POST': - current_value = request.POST.get('current_value') - all_roles = Role.objects.filter(Q(role__startswith=current_value)) - role_name = [] - for role in all_roles: - role_name.append(role.role) - return JsonResponse({'all_roles': role_name}) + #working here to fetch all placement record + all_records=PlacementRecord.objects.all() + print(all_records) -@login_required -def placement(request): - ''' - function include the functionality of first tab of UI - for student, placement officer & placement chairman - placement officer & placement chairman - - can add schedule - - can delete schedule - student - - accepted or declined schedule - ''' - user = request.user - profile = get_object_or_404(ExtraInfo, Q(user=user)) - schedule_tab = 1 - placementstatus = '' - form5 = AddSchedule(initial={}) + invitecheck=0 + for r in records: + r['name__count'] = 0 + r['year__count'] = 0 + r['placement_type__count'] = 0 + tcse = dict() + tece = dict() + tme = dict() + tadd = dict() + for y in years: + tcse[y['year']] = 0 + tece[y['year']] = 0 + tme[y['year']] = 0 + for r in records: + if r['year'] == y['year']: + if r['placement_type'] != "HIGHER STUDIES": + for z in studentrecord: + if z.record_id.name == r['name'] and z.record_id.year == r['year'] and z.unique_id.id.department.name == "CSE": + tcse[y['year']] = tcse[y['year']]+1 + r['name__count'] = r['name__count']+1 + if z.record_id.name == r['name'] and z.record_id.year == r['year'] and z.unique_id.id.department.name == "ECE": + tece[y['year']] = tece[y['year']]+1 + r['year__count'] = r['year__count']+1 + if z.record_id.name == r['name'] and z.record_id.year == r['year'] and z.unique_id.id.department.name == "ME": + tme[y['year']] = tme[y['year']]+1 + r['placement_type__count'] = r['placement_type__count']+1 + tadd[y['year']] = tcse[y['year']]+tece[y['year']]+tme[y['year']] + y['year__count'] = [tadd[y['year']], tcse[y['year']], tece[y['year']], tme[y['year']]] + + form2 = SearchPlacementRecord(initial={}) + form3 = SearchPbiRecord(initial={}) + form4 = SearchHigherRecord(initial={}) + + current1 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement chairman")) current2 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement officer")) current = HoldsDesignation.objects.filter(Q(working=user, designation__name="student")) - # If the user is Student - if current: - student = get_object_or_404(Student, Q(id=profile.id)) + if len(current1)!=0 or len(current2)!=0: + delete_operation = 1 + if len(current) == 0: + current = None + pbirecord= '' + placementrecord= '' + higherrecord= '' + total_query=0 + total_query1 = 0 + total_query2= 0 + p="" + p1="" + p2="" + placement_search_record=" " + pbi_search_record=" " + higher_search_record=" " + # results of the searched query under placement tab + if 'studentplacementrecordsubmit' in request.POST: + officer_statistics_past = 1 + form = SearchPlacementRecord(request.POST) + if form.is_valid(): - # Student view for showing accepted or declined schedule - if request.method == 'POST': - if 'studentapprovesubmit' in request.POST: - status = PlacementStatus.objects.select_related('unique_id','notify_id').filter( - pk=request.POST['studentapprovesubmit']).update( - invitation='ACCEPTED', - timestamp=timezone.now()) - if 'studentdeclinesubmit' in request.POST: - status = PlacementStatus.objects.select_related('unique_id','notify_id').filter( - Q(pk=request.POST['studentdeclinesubmit'])).update( - invitation='REJECTED', - timestamp=timezone.now()) - if 'educationsubmit' in request.POST: - form = AddEducation(request.POST) - if form.is_valid(): - institute = form.cleaned_data['institute'] - degree = form.cleaned_data['degree'] - grade = form.cleaned_data['grade'] - stream = form.cleaned_data['stream'] - sdate = form.cleaned_data['sdate'] - edate = form.cleaned_data['edate'] - education_obj = Education.objects.select_related('unique_id').create( - unique_id=student, degree=degree, - grade=grade, institute=institute, - stream=stream, sdate=sdate, edate=edate) - education_obj.save() - if 'profilesubmit' in request.POST: - about_me = request.POST.get('about') - age = request.POST.get('age') - address = request.POST.get('address') - contact = request.POST.get('contact') - pic = request.POST.get('pic') - # futu = request.POST.get('futu') - # print(studentplacement_obj.future_aspect) - # print('fut=', fut) - # print('futu=', futu) - # if studentplacement_obj.future_aspect == "HIGHER STUDIES": - # if futu == 2: - # studentplacement_obj.future_aspect = "PLACEMENT" - # elif studentplacement_obj.future_aspect == "PLACEMENT": - # if futu == None: - # studentplacement_obj.future_aspect = "HIGHER STUDIES" + + + print("IS VALID") + + + + #for student name + if form.cleaned_data['stuname']: + stuname = form.cleaned_data['stuname'] + try: + first_name = stuname.split(" ")[0] + last_name = stuname.split(" ")[1] + except Exception as e: + print("Error") + print(e) + first_name = stuname + last_name = '' + else: + stuname = '' + first_name = '' + last_name = '' + + + # for student CTC + if form.cleaned_data['ctc']: + ctc = form.cleaned_data['ctc'] + else: + ctc = 0 + + #for company name + if form.cleaned_data['cname']: + cname = form.cleaned_data['cname'] + else: + cname = '' + + #for student roll + if form.cleaned_data['roll']: + rollno = form.cleaned_data['roll'] + else: + rollno = '' + + #for admission year + if form.cleaned_data['year']: + year = form.cleaned_data['year'] + s = Student.objects.filter((Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + first_name__icontains=first_name, + last_name__icontains=last_name), + id__icontains=rollno)) + ))) + + p = PlacementRecord.objects.filter(Q(placement_type="PLACEMENT", name__icontains=stuname, ctc__icontains=ctc, year__icontains=year)) + + + + + """placementrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter( + Q(placement_type="PLACEMENT", name__icontains=cname, ctc__gte=ctc, year=year)), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + first_name__icontains=first_name, + last_name__icontains=last_name, + id__icontains=rollno)))))))) + #print("In if:", placementrecord) + else: + s = Student.objects.filter((Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + first_name__icontains=first_name, + last_name__icontains=last_name), + id__icontains=rollno)) + ))) + + p = PlacementRecord.objects.filter(Q(placement_type="PLACEMENT", name__icontains=cname, ctc__gte=ctc)) + print("Agein p:",p) + placementrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter( + Q(placement_type="PLACEMENT", name__icontains=cname, ctc__gte=ctc)), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + first_name__icontains=first_name, + last_name__icontains=last_name), + id__icontains=rollno))))))) + + request.session['first_name'] = first_name + request.session['last_name'] = last_name + request.session['ctc'] = ctc + request.session['cname'] = cname + request.session['rollno'] = rollno + request.session['year'] = form.cleaned_data['year']""" + + print(p) + + + total_query = p.count() + + if total_query > 30: + pagination_placement = 1 + paginator = Paginator(placementrecord, 30) + page = request.GET.get('page', 1) + placementrecord = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + pagination_placement = 0 + else: + if request.GET.get('page') != None: + try: + if request.session['year']: + s = Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno'])) + ))) + + p = PlacementRecord.objects.filter( + Q(placement_type="PLACEMENT", + name__icontains=request.session['cname'], + ctc__gte=request.session['ctc'], + year=request.session['year'])) + + + placementrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter( + Q(placement_type="PLACEMENT", + name__icontains=request.session['cname'], + ctc__gte=request.session['ctc'], + year=request.session['year'])), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno']))))))) + else: + s = Student.objects.filter((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno'])) + ))) + + p = PlacementRecord.objects.filter( + Q(placement_type="PLACEMENT", + name__icontains=request.session['cname'], + ctc__gte=request.session['ctc'])) + + placementrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter( + Q(placement_type="PLACEMENT", + name__icontains=request.session['cname'], + ctc__gte=request.session['ctc'])), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno']))))))) + except Exception as e: + print(e) + placementrecord = '' + + if placementrecord != '': + total_query = placementrecord.count() + else: + total_query = 0 + no_records=1 + print(placementrecord) + if total_query > 30: + pagination_placement = 1 + paginator = Paginator(placementrecord, 30) + page = request.GET.get('page', 1) + placementrecord = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + pagination_placement = 0 + else: + placementrecord = '' + + if total_query!=0: + placement_search_record=p + # results of the searched query under pbi tab + if 'studentpbirecordsubmit' in request.POST: + officer_statistics_past_pbi_search = 1 + form = SearchPbiRecord(request.POST) + if form.is_valid(): + if form.cleaned_data['stuname']: + stuname = form.cleaned_data['stuname'] + try: + first_name = stuname.split(" ")[0] + last_name = stuname.split(" ")[1] + except: + first_name = stuname + last_name = '' + else: + stuname = '' + first_name = '' + last_name = '' + if form.cleaned_data['ctc']: + ctc = form.cleaned_data['ctc'] + else: + ctc = 0 + if form.cleaned_data['cname']: + cname = form.cleaned_data['cname'] + else: + cname = '' + if form.cleaned_data['roll']: + rollno = form.cleaned_data['roll'] + else: + rollno = '' + if form.cleaned_data['year']: + year = form.cleaned_data['year'] + pbirecord = StudentRecord.objects.select_related('unique_id','record_id').filter(Q(record_id__in=PlacementRecord.objects.filter + (Q(placement_type="PBI", + name__icontains=cname, + ctc__gte=ctc, year=year)), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=first_name, + last_name__icontains=last_name)), + id__icontains=rollno)) + ))))) + p1 = PlacementRecord.objects.filter( + Q(placement_type="PBI", name__icontains=stuname, ctc__icontains=ctc, year__icontains=year)) + """else: + pbirecord = StudentRecord.objects.select_related('unique_id','record_id').filter(Q(record_id__in=PlacementRecord.objects.filter + (Q(placement_type="PBI", + name__icontains=cname, + ctc__gte=ctc)), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=first_name, + last_name__icontains=last_name)), + id__icontains=rollno)) + ))))) + request.session['first_name'] = first_name + request.session['last_name'] = last_name + request.session['ctc'] = ctc + request.session['cname'] = cname + request.session['rollno'] = rollno + request.session['year'] = form.cleaned_data['year'] +""" + total_query1 = p1.count() + + if total_query1 > 30: + pagination_pbi = 1 + paginator = Paginator(pbirecord, 30) + page = request.GET.get('page', 1) + pbirecord = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query1 > 30 and total_query1 <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + pagination_pbi = 0 + else: + if request.GET.get('page') != None: + try: + if request.session['year']: + pbirecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter( + Q(placement_type="PBI", + name__icontains=request.session['cname'], + ctc__gte=ctc, year=request.session['year'])), + unique_id__in=Student.objects.filter(( + Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno']))))))) + else: + pbirecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter(Q(placement_type="PBI", + name__icontains=request.session['cname'], + ctc__gte=request.session['ctc'])), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno']))))))) + except: + print('except') + pbirecord = '' + + if pbirecord != '': + total_query = pbirecord.count() + else: + total_query = 0 + + if total_query > 30: + pagination_pbi = 1 + paginator = Paginator(pbirecord, 30) + page = request.GET.get('page', 1) + pbirecord = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + pagination_pbi = 0 + else: + pbirecord = '' + if total_query1!=0: + pbi_search_record=p1 + + # results of the searched query under higher studies tab + if 'studenthigherrecordsubmit' in request.POST: + officer_statistics_past_higher_search = 1 + form = SearchHigherRecord(request.POST) + if form.is_valid(): + # getting all the variables send through form + if form.cleaned_data['stuname']: + stuname = form.cleaned_data['stuname'] + try: + first_name = stuname.split(" ")[0] + last_name = stuname.split(" ")[1] + except: + first_name = stuname + last_name = '' + else: + stuname = '' + first_name = '' + last_name = '' + if form.cleaned_data['test_type']: + test_type = form.cleaned_data['test_type'] + else: + test_type = '' + if form.cleaned_data['uname']: + uname = form.cleaned_data['uname'] + else: + uname = '' + if form.cleaned_data['test_score']: + test_score = form.cleaned_data['test_score'] + else: + test_score = 0 + if form.cleaned_data['roll']: + rollno = form.cleaned_data['roll'] + else: + rollno = '' + if form.cleaned_data['year']: + year = form.cleaned_data['year'] + # result of the query when year is given + higherrecord = StudentRecord.objects.select_related('unique_id','record_id').filter(Q(record_id__in=PlacementRecord.objects.filter + (Q(placement_type="HIGHER STUDIES", + test_type__icontains=test_type, + name__icontains=uname, year=year, + test_score__gte=test_score)), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=first_name, + last_name__icontains=last_name)), + id__icontains=rollno)) + ))))) + + p2 = PlacementRecord.objects.filter( + Q(placement_type="HIGHER STUDIES", name__icontains=stuname, year__icontains=year)) + + """else: + # result of the query when year is not given + higherrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter + (Q(placement_type="HIGHER STUDIES", + test_type__icontains=test_type, + name__icontains=uname, + test_score__gte=test_score)), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=first_name, + last_name__icontains=last_name)), + id__icontains=rollno)) + ))))) + request.session['first_name'] = first_name + request.session['last_name'] = last_name + request.session['test_score'] = test_score + request.session['uname'] = uname + request.session['test_type'] = test_type + request.session['rollno'] = rollno + request.session['year'] = form.cleaned_data['year']""" + + total_query2 = p2.count() + + if total_query2 > 30: + pagination_higher = 1 + paginator = Paginator(p2, 30) + page = request.GET.get('page', 1) + p2 = paginator.page(page) + page = int(page) + total_page = int(page+3) + + if page < (paginator.num_pages-3): + if total_query2 > 30 and total_query2 <= 60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(page-2, paginator.num_pages+1) + else: + pagination_higher = 0 + else: + if request.GET.get('page') != None: + try: + if request.session['year']: + higherrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter( + Q(placement_type="HIGHER STUDIES", + test_type__icontains=request.session['test_type'], + name__icontains=request.session['uname'], + year=request.session['year'], + test_score__gte=request.session['test_score'])), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno'])) + ))))) + else: + higherrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter( + Q(placement_type="HIGHER STUDIES", + test_type__icontains=request.session['test_type'], + name__icontains=request.session['uname'], + test_score__gte=request.session['test_score'])), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno'])) + ))))) + except: + higherrecord = '' + + if higherrecord != '': + total_query = higherrecord.count() + else: + total_query = 0 + + if total_query > 30: + no_pagination = 1 + paginator = Paginator(higherrecord, 30) + page = request.GET.get('page', 1) + higherrecord = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + no_pagination = 0 + else: + higherrecord = '' + if total_query2!=0: + higher_search_record=p2 + + context = { + 'form2' : form2, + 'form3' : form3, + 'form4' : form4, + 'current' : current, + 'current1' : current1, + 'current2' : current2, + + + 'all_records': all_records, #for flashing all placement Schedule + + 'placement_search_record': placement_search_record, + 'pbi_search_record': pbi_search_record, + 'higher_search_record': higher_search_record, + + + + 'statistics_tab' : statistics_tab, + 'pbirecord' : pbirecord, + 'placementrecord' : placementrecord, + 'higherrecord' : higherrecord, + 'years' : years, + 'records' : records, + 'delete_operation' : delete_operation, + 'page_range': page_range, + 'paginator': paginator, + 'pagination_placement': pagination_placement, + 'pagination_pbi': pagination_pbi, + 'pagination_higher': pagination_higher, + 'is_disabled': is_disabled, + 'officer_statistics_past_pbi_search': officer_statistics_past_pbi_search, + 'officer_statistics_past_higher_search': officer_statistics_past_higher_search + } + + return render(request, 'placementModule/placementstatistics.html', context) + + + +def get_reference_list(request): + if request.method == 'POST': + # arr = request.POST.getlist('arr[]') + # print(arr) + # print(type(arr)) + user = request.user + profile = get_object_or_404(ExtraInfo, Q(user=user)) + student = get_object_or_404(Student, Q(id=profile.id)) + print(student) + reference_objects = Reference.select_related('unique_id').objects.filter(unique_id=student) + reference_objects = serializers.serialize('json', list(reference_objects)) + + context = { + 'reference_objs': reference_objects + } + return JsonResponse(context) + + +# Ajax for the company name dropdown for CompanyName when filling AddSchedule +def company_name_dropdown(request): + if request.method == 'POST': + current_value = request.POST.get('current_value') + company_names = CompanyDetails.objects.filter(Q(company_name__startswith=current_value)) + company_name = [] + for name in company_names: + company_name.append(name.company_name) + + context = { + 'company_names': company_name + } + + return JsonResponse(context) + + +# Ajax for all the roles in the dropdown +def checking_roles(request): + if request.method == 'POST': + current_value = request.POST.get('current_value') + all_roles = Role.objects.filter(Q(role__startswith=current_value)) + role_name = [] + for role in all_roles: + role_name.append(role.role) + return JsonResponse({'all_roles': role_name}) + +@login_required +def Placement__Schedule(request): + ''' + function include the functionality of first tab of UI + for student, placement officer & placement chairman + + placement officer & placement chairman + - can add schedule + - can delete schedule + student + - accepted or declined schedule + + ''' + user = request.user + profile = get_object_or_404(ExtraInfo, Q(user=user)) + schedule_tab = 1 + placementstatus = '' + + + form5 = AddSchedule(initial={}) + current1 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement chairman")) + current2 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement officer")) + current = HoldsDesignation.objects.filter(Q(working=user, designation__name="student")) + print(current) + + # If the user is Student + if current: + student = get_object_or_404(Student, Q(id=profile.id)) + + # Student view for showing accepted or declined schedule + if request.method == 'POST': + if 'studentapprovesubmit' in request.POST: + status = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + pk=request.POST['studentapprovesubmit']).update( + invitation='ACCEPTED', + timestamp=timezone.now()) + if 'studentdeclinesubmit' in request.POST: + status = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + Q(pk=request.POST['studentdeclinesubmit'])).update( + invitation='REJECTED', + timestamp=timezone.now()) + + if 'educationsubmit' in request.POST: + form = AddEducation(request.POST) + if form.is_valid(): + institute = form.cleaned_data['institute'] + degree = form.cleaned_data['degree'] + grade = form.cleaned_data['grade'] + stream = form.cleaned_data['stream'] + sdate = form.cleaned_data['sdate'] + edate = form.cleaned_data['edate'] + education_obj = Education.objects.select_related('unique_id').create( + unique_id=student, degree=degree, + grade=grade, institute=institute, + stream=stream, sdate=sdate, edate=edate) + education_obj.save() + if 'profilesubmit' in request.POST: + about_me = request.POST.get('about') + age = request.POST.get('age') + address = request.POST.get('address') + contact = request.POST.get('contact') + pic = request.POST.get('pic') + # futu = request.POST.get('futu') + # print(studentplacement_obj.future_aspect) + # print('fut=', fut) + # print('futu=', futu) + # if studentplacement_obj.future_aspect == "HIGHER STUDIES": + # if futu == 2: + # studentplacement_obj.future_aspect = "PLACEMENT" + # elif studentplacement_obj.future_aspect == "PLACEMENT": + # if futu == None: + # studentplacement_obj.future_aspect = "HIGHER STUDIES" + extrainfo_obj = ExtraInfo.objects.get(user=user) + extrainfo_obj.about_me = about_me + extrainfo_obj.age = age + extrainfo_obj.address = address + extrainfo_obj.phone_no = contact + extrainfo_obj.profile_picture = pic + extrainfo_obj.save() + profile = get_object_or_404(ExtraInfo, Q(user=user)) + if 'skillsubmit' in request.POST: + form = AddSkill(request.POST) + if form.is_valid(): + skill = form.cleaned_data['skill'] + skill_rating = form.cleaned_data['skill_rating'] + has_obj = Has.objects.select_related('skill_id','unique_id').create(unique_id=student, + skill_id=Skill.objects.get(skill=skill), + skill_rating = skill_rating) + has_obj.save() + if 'achievementsubmit' in request.POST: + form = AddAchievement(request.POST) + if form.is_valid(): + achievement = form.cleaned_data['achievement'] + achievement_type = form.cleaned_data['achievement_type'] + description = form.cleaned_data['description'] + issuer = form.cleaned_data['issuer'] + date_earned = form.cleaned_data['date_earned'] + achievement_obj = Achievement.objects.select_related('unique_id').create(unique_id=student, + achievement=achievement, + achievement_type=achievement_type, + description=description, + issuer=issuer, + date_earned=date_earned) + achievement_obj.save() + if 'publicationsubmit' in request.POST: + form = AddPublication(request.POST) + if form.is_valid(): + publication_title = form.cleaned_data['publication_title'] + description = form.cleaned_data['description'] + publisher = form.cleaned_data['publisher'] + publication_date = form.cleaned_data['publication_date'] + publication_obj = Publication.objects.select_related('unique_id').create(unique_id=student, + publication_title= + publication_title, + publisher=publisher, + description=description, + publication_date=publication_date) + publication_obj.save() + if 'patentsubmit' in request.POST: + form = AddPatent(request.POST) + if form.is_valid(): + patent_name = form.cleaned_data['patent_name'] + description = form.cleaned_data['description'] + patent_office = form.cleaned_data['patent_office'] + patent_date = form.cleaned_data['patent_date'] + patent_obj = Patent.objects.select_related('unique_id').create(unique_id=student, patent_name=patent_name, + patent_office=patent_office, + description=description, + patent_date=patent_date) + patent_obj.save() + if 'coursesubmit' in request.POST: + form = AddCourse(request.POST) + if form.is_valid(): + course_name = form.cleaned_data['course_name'] + description = form.cleaned_data['description'] + license_no = form.cleaned_data['license_no'] + sdate = form.cleaned_data['sdate'] + edate = form.cleaned_data['edate'] + course_obj = Course.objects.select_related('unique_id').create(unique_id=student, course_name=course_name, + license_no=license_no, + description=description, + sdate=sdate, edate=edate) + course_obj.save() + if 'projectsubmit' in request.POST: + form = AddProject(request.POST) + if form.is_valid(): + project_name = form.cleaned_data['project_name'] + project_status = form.cleaned_data['project_status'] + summary = form.cleaned_data['summary'] + project_link = form.cleaned_data['project_link'] + sdate = form.cleaned_data['sdate'] + edate = form.cleaned_data['edate'] + project_obj = Project.objects.create(unique_id=student, summary=summary, + project_name=project_name, + project_status=project_status, + project_link=project_link, + sdate=sdate, edate=edate) + project_obj.save() + if 'experiencesubmit' in request.POST: + form = AddExperience(request.POST) + if form.is_valid(): + title = form.cleaned_data['title'] + status = form.cleaned_data['status'] + company = form.cleaned_data['company'] + location = form.cleaned_data['location'] + description = form.cleaned_data['description'] + sdate = form.cleaned_data['sdate'] + edate = form.cleaned_data['edate'] + experience_obj = Experience.objects.select_related('unique_id').create(unique_id=student, title=title, + company=company, location=location, + status=status, + description=description, + sdate=sdate, edate=edate) + experience_obj.save() + + if 'deleteskill' in request.POST: + hid = request.POST['deleteskill'] + hs = Has.objects.select_related('skill_id','unique_id').get(Q(pk=hid)) + hs.delete() + if 'deleteedu' in request.POST: + hid = request.POST['deleteedu'] + hs = Education.objects.select_related('unique_id').get(Q(pk=hid)) + hs.delete() + if 'deletecourse' in request.POST: + hid = request.POST['deletecourse'] + hs = Course.objects.get(Q(pk=hid)) + hs.delete() + if 'deleteexp' in request.POST: + hid = request.POST['deleteexp'] + hs = Experience.objects.get(Q(pk=hid)) + hs.delete() + if 'deletepro' in request.POST: + hid = request.POST['deletepro'] + hs = Project.objects.get(Q(pk=hid)) + hs.delete() + if 'deleteach' in request.POST: + hid = request.POST['deleteach'] + hs = Achievement.objects.get(Q(pk=hid)) + hs.delete() + if 'deletepub' in request.POST: + hid = request.POST['deletepub'] + hs = Publication.objects.select_related('unique_id').get(Q(pk=hid)) + hs.delete() + if 'deletepat' in request.POST: + hid = request.POST['deletepat'] + hs = Patent.objects.get(Q(pk=hid)) + hs.delete() + + placementschedule = PlacementSchedule.objects.select_related('notify_id').filter( + Q(placement_date__gte=date.today())).values_list('notify_id', flat=True) + + placementstatus = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + Q(unique_id=student, + notify_id__in=placementschedule)).order_by('-timestamp') + + + check_invitation_date(placementstatus) + + # facult and other staff view only statistics + if not (current or current1 or current2): + return redirect('/placement/statistics/') + + # delete the schedule + if 'deletesch' in request.POST: + delete_sch_key = request.POST['delete_sch_key'] + try: + placement_schedule = PlacementSchedule.objects.select_related('notify_id').get(pk = delete_sch_key) + NotifyStudent.objects.get(pk=placement_schedule.notify_id.id).delete() + placement_schedule.delete() + messages.success(request, 'Schedule Deleted Successfully') + except Exception as e: + messages.error(request, 'Problem Occurred for Schedule Delete!!!') + + # saving all the schedule details + if 'schedulesubmit' in request.POST: + form5 = AddSchedule(request.POST, request.FILES) + if form5.is_valid(): + company_name = form5.cleaned_data['company_name'] + placement_date = form5.cleaned_data['placement_date'] + location = form5.cleaned_data['location'] + ctc = form5.cleaned_data['ctc'] + time = form5.cleaned_data['time'] + attached_file = form5.cleaned_data['attached_file'] + placement_type = form5.cleaned_data['placement_type'] + role_offered = request.POST.get('role') + description = form5.cleaned_data['description'] + + try: + comp_name = CompanyDetails.objects.filter(company_name=company_name)[0] + except: + CompanyDetails.objects.create(company_name=company_name) + + try: + role = Role.objects.filter(role=role_offered)[0] + except: + role = Role.objects.create(role=role_offered) + role.save() + + + notify = NotifyStudent.objects.create(placement_type=placement_type, + company_name=company_name, + description=description, + ctc=ctc, + timestamp=timezone.now()) + + schedule = PlacementSchedule.objects.select_related('notify_id').create(notify_id=notify, + title=company_name, + description=description, + placement_date=placement_date, + attached_file = attached_file, + role=role, + location=location, time=time) + + notify.save() + schedule.save() + messages.success(request, "Schedule Added Successfull!!") + + + schedules = PlacementSchedule.objects.select_related('notify_id').all() + + + context = { + 'current': current, + 'current1': current1, + 'current2': current2, + 'schedule_tab': schedule_tab, + 'schedules': schedules, + 'placementstatus': placementstatus, + 'form5': form5, + } + + return render(request, 'placementModule/placement.html', context) + + + +def invite_status(request): + ''' + function to check the invitation status + ''' + user = request.user + strecord_tab = 1 + mnpbi_tab = 0 + mnplacement_post = 0 + mnpbi_post = 0 + invitation_status_tab = 1 + placementstatus_placement = [] + placementstatus_pbi = [] + mnplacement_tab = 1 + + no_pagination = 1 + is_disabled = 0 + paginator = '' + page_range = '' + placement_get_request = False + pbi_get_request = False + + # invitation status for placement + if 'studentplacementsearchsubmit' in request.POST: + mnplacement_post = 1 + mnpbi_post = 0 + form = ManagePlacementRecord(request.POST) + + if form.is_valid(): + if form.cleaned_data['stuname']: + stuname = form.cleaned_data['stuname'] + else: + stuname = '' + if form.cleaned_data['ctc']: + ctc = form.cleaned_data['ctc'] + else: + ctc = 0 + if form.cleaned_data['company']: + cname = form.cleaned_data['company'] + else: + cname = '' + if form.cleaned_data['roll']: + rollno = form.cleaned_data['roll'] + else: + rollno = '' + + request.session['mn_stuname'] = stuname + request.session['mn_ctc'] = ctc + request.session['mn_cname'] = cname + request.session['mn_rollno'] = rollno + + placementstatus_placement = PlacementStatus.objects.select_related('unique_id','notify_id').filter(Q(notify_id__in=NotifyStudent.objects.filter + (Q(placement_type="PLACEMENT", + company_name__icontains=cname, + ctc__gte=ctc)), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=stuname)), + id__icontains=rollno)) + ))))) + # pagination stuff starts from here + total_query = placementstatus_placement.count() + + if total_query > 30: + no_pagination = 1 + paginator = Paginator(placementstatus_placement, 30) + page = request.GET.get('page', 1) + placementstatus_placement = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + no_pagination = 0 + else: + # when the request from pagination with some page number + if request.GET.get('placement_page') != None: + mnplacement_post = 1 + mnpbi_post = 0 + no_pagination = 1 + try: + placementstatus_placement = PlacementStatus.objects.select_related('unique_id','notify_id').filter(Q(notify_id__in=NotifyStudent.objects.filter + (Q(placement_type="PLACEMENT", + company_name__icontains=request.session['mn_cname'], + ctc__gte=request.session['mn_ctc'])), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=request.session['mn_stuname'])), + id__icontains=request.session['mn_rollno'])) + ))))) + except: + placementstatus_placement = [] + + if placementstatus_placement != '': + total_query = placementstatus_placement.count() + else: + total_query = 0 + + if total_query > 30: + paginator = Paginator(placementstatus_placement, 30) + page = request.GET.get('placement_page', 1) + placementstatus_placement = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + no_pagination = 0 + + # invitation status for pbi + if 'studentpbisearchsubmit' in request.POST: + mnpbi_tab = 1 + mnpbi_post = 1 + mnplacement_post = 0 + form = ManagePbiRecord(request.POST) + if form.is_valid(): + if form.cleaned_data['stuname']: + stuname = form.cleaned_data['stuname'] + else: + stuname = '' + if form.cleaned_data['ctc']: + ctc = form.cleaned_data['ctc'] + else: + ctc = 0 + if form.cleaned_data['company']: + cname = form.cleaned_data['company'] + else: + cname = '' + if form.cleaned_data['roll']: + rollno = form.cleaned_data['roll'] + else: + rollno = '' + request.session['mn_pbi_stuname'] = stuname + request.session['mn_pbi_ctc'] = ctc + request.session['mn_pbi_cname'] = cname + request.session['mn_pbi_rollno'] = rollno + placementstatus_pbi = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + Q(notify_id__in=NotifyStudent.objects.filter( + Q(placement_type="PBI", + company_name__icontains=cname, + ctc__gte=ctc)), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=stuname)), + id__icontains=rollno))))))).order_by('id') + + total_query = placementstatus_pbi.count() + + if total_query > 30: + no_pagination = 1 + paginator = Paginator(placementstatus_pbi, 30) + page = request.GET.get('pbi_page', 1) + placementstatus_pbi = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + no_pagination = 0 + else: + if request.GET.get('pbi_page') != None: + mnpbi_tab = 1 + mnpbi_post = 1 + no_pagination = 1 + try: + placementstatus_pbi = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + Q(notify_id__in=NotifyStudent.objects.filter( + Q(placement_type="PBI", + company_name__icontains=request.session['mn_pbi_cname'], + ctc__gte=request.session['mn_pbi_ctc'])), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['mn_pbi_stuname'])), + id__icontains=request.session['mn_pbi_rollno'])) + ))))) + except: + placementstatus_pbi = '' + + if placementstatus_pbi != '': + total_query = placementstatus_pbi.count() + else: + total_query = 0 + if total_query > 30: + paginator = Paginator(placementstatus_pbi, 30) + page = request.GET.get('pbi_page', 1) + placementstatus_pbi = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + no_pagination = 0 + + + if 'pdf_gen_invitation_status' in request.POST: + + placementstatus = None + if 'pdf_gen_invitation_status_placement' in request.POST: + stuname = request.session['mn_stuname'] + ctc = request.session['mn_ctc'] + cname = request.session['mn_cname'] + rollno = request.session['mn_rollno'] + + placementstatus = PlacementStatus.objects.select_related('unique_id','notify_id').filter(Q(notify_id__in=NotifyStudent.objects.filter + (Q(placement_type="PLACEMENT", + company_name__icontains=cname, + ctc__gte=ctc)), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=stuname)), + id__icontains=rollno)) + ))))) + + if 'pdf_gen_invitation_status_pbi' in request.POST: + stuname = request.session['mn_pbi_stuname'] + ctc = request.session['mn_pbi_ctc'] + cname = request.session['mn_pbi_cname'] + rollno = request.session['mn_pbi_rollno'] + + placementstatus = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + Q(notify_id__in=NotifyStudent.objects.filter( + Q(placement_type="PBI", + company_name__icontains=cname, + ctc__gte=ctc)), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=stuname)), + id__icontains=rollno))))))).order_by('id') + + context = { + 'placementstatus' : placementstatus + } + + return render_to_pdf('placementModule/pdf_invitation_status.html', context) + + if 'excel_gen_invitation_status' in request.POST: + + placementstatus = None + if 'excel_gen_invitation_status_placement' in request.POST: + stuname = request.session['mn_stuname'] + ctc = request.session['mn_ctc'] + cname = request.session['mn_cname'] + rollno = request.session['mn_rollno'] + + placementstatus = PlacementStatus.objects.select_related('unique_id','notify_id').filter(Q(notify_id__in=NotifyStudent.objects.filter + (Q(placement_type="PLACEMENT", + company_name__icontains=cname, + ctc__gte=ctc)), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=stuname)), + id__icontains=rollno)) + ))))) + + if 'excel_gen_invitation_status_pbi' in request.POST: + stuname = request.session['mn_pbi_stuname'] + ctc = request.session['mn_pbi_ctc'] + cname = request.session['mn_pbi_cname'] + rollno = request.session['mn_pbi_rollno'] + + placementstatus = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + Q(notify_id__in=NotifyStudent.objects.filter( + Q(placement_type="PBI", + company_name__icontains=cname, + ctc__gte=ctc)), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=stuname)), + id__icontains=rollno))))))).order_by('id') + + context = { + 'placementstatus' : placementstatus + } + + + years = PlacementRecord.objects.filter(~Q(placement_type="HIGHER STUDIES")).values('year').annotate(Count('year')) + records = PlacementRecord.objects.values('name', 'year', 'ctc', 'placement_type').annotate(Count('name'), Count('year'), Count('placement_type'), Count('ctc')) + + + return export_to_xls_invitation_status(placementstatus) + + form1 = SearchStudentRecord(initial={}) + form9 = ManagePbiRecord(initial={}) + form11 = ManagePlacementRecord(initial={}) + form13 = SendInvite(initial={}) + current1 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement chairman")) + current2 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement officer")) + + context = { + 'form1': form1, + 'form9': form9, + 'form11': form11, + 'form13': form13, + 'invitation_status_tab': invitation_status_tab, + 'mnplacement_post': mnplacement_post, + 'mnpbi_tab': mnpbi_tab, + 'mnplacement_tab': mnplacement_tab, + 'placementstatus_placement': placementstatus_placement, + 'placementstatus_pbi': placementstatus_pbi, + 'current1': current1, + 'current2': current2, + 'strecord_tab': strecord_tab, + 'mnpbi_post': mnpbi_post, + 'page_range': page_range, + 'paginator': paginator, + 'no_pagination': no_pagination, + 'is_disabled': is_disabled, + } + + return render(request, 'placementModule/studentrecords.html', context) + + + + + + + + invitecheck=0 + for r in records: + r['name__count'] = 0 + r['year__count'] = 0 + r['placement_type__count'] = 0 + tcse = dict() + tece = dict() + tme = dict() + tadd = dict() + for y in years: + tcse[y['year']] = 0 + tece[y['year']] = 0 + tme[y['year']] = 0 + for r in records: + if r['year'] == y['year']: + if r['placement_type'] != "HIGHER STUDIES": + for z in studentrecord: + if z.record_id.name == r['name'] and z.record_id.year == r['year'] and z.unique_id.id.department.name == "CSE": + tcse[y['year']] = tcse[y['year']]+1 + r['name__count'] = r['name__count']+1 + if z.record_id.name == r['name'] and z.record_id.year == r['year'] and z.unique_id.id.department.name == "ECE": + tece[y['year']] = tece[y['year']]+1 + r['year__count'] = r['year__count']+1 + if z.record_id.name == r['name'] and z.record_id.year == r['year'] and z.unique_id.id.department.name == "ME": + tme[y['year']] = tme[y['year']]+1 + r['placement_type__count'] = r['placement_type__count']+1 + tadd[y['year']] = tcse[y['year']]+tece[y['year']]+tme[y['year']] + y['year__count'] = [tadd[y['year']], tcse[y['year']], tece[y['year']], tme[y['year']]] + + form2 = SearchPlacementRecord(initial={}) + form3 = SearchPbiRecord(initial={}) + form4 = SearchHigherRecord(initial={}) + + + current1 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement chairman")) + current2 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement officer")) + current = HoldsDesignation.objects.filter(Q(working=user, designation__name="student")) + print(current) + + if len(current1)!=0 or len(current2)!=0: + delete_operation = 1 + if len(current) == 0: + current = None + pbirecord= '' + placementrecord= '' + higherrecord= '' + total_query=0 + total_query1 = 0 + total_query2= 0 + p="" + p1="" + p2="" + placement_search_record=" " + pbi_search_record=" " + higher_search_record=" " + # results of the searched query under placement tab + if 'studentplacementrecordsubmit' in request.POST: + officer_statistics_past = 1 + form = SearchPlacementRecord(request.POST) + if form.is_valid(): + + + + + print("IS VALID") + + + + #for student name + if form.cleaned_data['stuname']: + stuname = form.cleaned_data['stuname'] + try: + first_name = stuname.split(" ")[0] + last_name = stuname.split(" ")[1] + except Exception as e: + print("Error") + print(e) + first_name = stuname + last_name = '' + else: + stuname = '' + first_name = '' + last_name = '' + + + # for student CTC + if form.cleaned_data['ctc']: + ctc = form.cleaned_data['ctc'] + else: + ctc = 0 + + #for company name + if form.cleaned_data['cname']: + cname = form.cleaned_data['cname'] + else: + cname = '' + + #for student roll + if form.cleaned_data['roll']: + rollno = form.cleaned_data['roll'] + else: + rollno = '' + + #for admission year + if form.cleaned_data['year']: + year = form.cleaned_data['year'] + s = Student.objects.filter((Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + first_name__icontains=first_name, + last_name__icontains=last_name), + id__icontains=rollno)) + ))) + + p = PlacementRecord.objects.filter(Q(placement_type="PLACEMENT", name__icontains=stuname, ctc__icontains=ctc, year__icontains=year)) + + + + + """placementrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter( + Q(placement_type="PLACEMENT", name__icontains=cname, ctc__gte=ctc, year=year)), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + first_name__icontains=first_name, + last_name__icontains=last_name, + id__icontains=rollno)))))))) + #print("In if:", placementrecord) + else: + s = Student.objects.filter((Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + first_name__icontains=first_name, + last_name__icontains=last_name), + id__icontains=rollno)) + ))) + + p = PlacementRecord.objects.filter(Q(placement_type="PLACEMENT", name__icontains=cname, ctc__gte=ctc)) + print("Agein p:",p) + placementrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter( + Q(placement_type="PLACEMENT", name__icontains=cname, ctc__gte=ctc)), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + first_name__icontains=first_name, + last_name__icontains=last_name), + id__icontains=rollno))))))) + + request.session['first_name'] = first_name + request.session['last_name'] = last_name + request.session['ctc'] = ctc + request.session['cname'] = cname + request.session['rollno'] = rollno + request.session['year'] = form.cleaned_data['year']""" + + print(p) + + + total_query = p.count() + + if total_query > 30: + pagination_placement = 1 + paginator = Paginator(placementrecord, 30) + page = request.GET.get('page', 1) + placementrecord = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + pagination_placement = 0 + else: + if request.GET.get('page') != None: + try: + if request.session['year']: + s = Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno'])) + ))) + + p = PlacementRecord.objects.filter( + Q(placement_type="PLACEMENT", + name__icontains=request.session['cname'], + ctc__gte=request.session['ctc'], + year=request.session['year'])) + + + placementrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter( + Q(placement_type="PLACEMENT", + name__icontains=request.session['cname'], + ctc__gte=request.session['ctc'], + year=request.session['year'])), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno']))))))) + else: + s = Student.objects.filter((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno'])) + ))) + + p = PlacementRecord.objects.filter( + Q(placement_type="PLACEMENT", + name__icontains=request.session['cname'], + ctc__gte=request.session['ctc'])) + + placementrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter( + Q(placement_type="PLACEMENT", + name__icontains=request.session['cname'], + ctc__gte=request.session['ctc'])), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno']))))))) + except Exception as e: + print(e) + placementrecord = '' + + if placementrecord != '': + total_query = placementrecord.count() + else: + total_query = 0 + no_records=1 + print(placementrecord) + if total_query > 30: + pagination_placement = 1 + paginator = Paginator(placementrecord, 30) + page = request.GET.get('page', 1) + placementrecord = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + pagination_placement = 0 + else: + placementrecord = '' + + if total_query!=0: + placement_search_record=p + # results of the searched query under pbi tab + if 'studentpbirecordsubmit' in request.POST: + officer_statistics_past_pbi_search = 1 + form = SearchPbiRecord(request.POST) + if form.is_valid(): + if form.cleaned_data['stuname']: + stuname = form.cleaned_data['stuname'] + try: + first_name = stuname.split(" ")[0] + last_name = stuname.split(" ")[1] + except: + first_name = stuname + last_name = '' + else: + stuname = '' + first_name = '' + last_name = '' + if form.cleaned_data['ctc']: + ctc = form.cleaned_data['ctc'] + else: + ctc = 0 + if form.cleaned_data['cname']: + cname = form.cleaned_data['cname'] + else: + cname = '' + if form.cleaned_data['roll']: + rollno = form.cleaned_data['roll'] + else: + rollno = '' + if form.cleaned_data['year']: + year = form.cleaned_data['year'] + pbirecord = StudentRecord.objects.select_related('unique_id','record_id').filter(Q(record_id__in=PlacementRecord.objects.filter + (Q(placement_type="PBI", + name__icontains=cname, + ctc__gte=ctc, year=year)), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=first_name, + last_name__icontains=last_name)), + id__icontains=rollno)) + ))))) + p1 = PlacementRecord.objects.filter( + Q(placement_type="PBI", name__icontains=stuname, ctc__icontains=ctc, year__icontains=year)) + """else: + pbirecord = StudentRecord.objects.select_related('unique_id','record_id').filter(Q(record_id__in=PlacementRecord.objects.filter + (Q(placement_type="PBI", + name__icontains=cname, + ctc__gte=ctc)), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=first_name, + last_name__icontains=last_name)), + id__icontains=rollno)) + ))))) + request.session['first_name'] = first_name + request.session['last_name'] = last_name + request.session['ctc'] = ctc + request.session['cname'] = cname + request.session['rollno'] = rollno + request.session['year'] = form.cleaned_data['year'] +""" + total_query1 = p1.count() + + if total_query1 > 30: + pagination_pbi = 1 + paginator = Paginator(pbirecord, 30) + page = request.GET.get('page', 1) + pbirecord = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query1 > 30 and total_query1 <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + pagination_pbi = 0 + else: + if request.GET.get('page') != None: + try: + if request.session['year']: + pbirecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter( + Q(placement_type="PBI", + name__icontains=request.session['cname'], + ctc__gte=ctc, year=request.session['year'])), + unique_id__in=Student.objects.filter(( + Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno']))))))) + else: + pbirecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter(Q(placement_type="PBI", + name__icontains=request.session['cname'], + ctc__gte=request.session['ctc'])), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno']))))))) + except: + print('except') + pbirecord = '' + + if pbirecord != '': + total_query = pbirecord.count() + else: + total_query = 0 + + if total_query > 30: + pagination_pbi = 1 + paginator = Paginator(pbirecord, 30) + page = request.GET.get('page', 1) + pbirecord = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + pagination_pbi = 0 + else: + pbirecord = '' + if total_query1!=0: + pbi_search_record=p1 + + # results of the searched query under higher studies tab + if 'studenthigherrecordsubmit' in request.POST: + officer_statistics_past_higher_search = 1 + form = SearchHigherRecord(request.POST) + if form.is_valid(): + # getting all the variables send through form + if form.cleaned_data['stuname']: + stuname = form.cleaned_data['stuname'] + try: + first_name = stuname.split(" ")[0] + last_name = stuname.split(" ")[1] + except: + first_name = stuname + last_name = '' + else: + stuname = '' + first_name = '' + last_name = '' + if form.cleaned_data['test_type']: + test_type = form.cleaned_data['test_type'] + else: + test_type = '' + if form.cleaned_data['uname']: + uname = form.cleaned_data['uname'] + else: + uname = '' + if form.cleaned_data['test_score']: + test_score = form.cleaned_data['test_score'] + else: + test_score = 0 + if form.cleaned_data['roll']: + rollno = form.cleaned_data['roll'] + else: + rollno = '' + if form.cleaned_data['year']: + year = form.cleaned_data['year'] + # result of the query when year is given + higherrecord = StudentRecord.objects.select_related('unique_id','record_id').filter(Q(record_id__in=PlacementRecord.objects.filter + (Q(placement_type="HIGHER STUDIES", + test_type__icontains=test_type, + name__icontains=uname, year=year, + test_score__gte=test_score)), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=first_name, + last_name__icontains=last_name)), + id__icontains=rollno)) + ))))) + + p2 = PlacementRecord.objects.filter( + Q(placement_type="HIGHER STUDIES", name__icontains=stuname, year__icontains=year)) + + """else: + # result of the query when year is not given + higherrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter + (Q(placement_type="HIGHER STUDIES", + test_type__icontains=test_type, + name__icontains=uname, + test_score__gte=test_score)), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=first_name, + last_name__icontains=last_name)), + id__icontains=rollno)) + ))))) + request.session['first_name'] = first_name + request.session['last_name'] = last_name + request.session['test_score'] = test_score + request.session['uname'] = uname + request.session['test_type'] = test_type + request.session['rollno'] = rollno + request.session['year'] = form.cleaned_data['year']""" + + total_query2 = p2.count() + + if total_query2 > 30: + pagination_higher = 1 + paginator = Paginator(p2, 30) + page = request.GET.get('page', 1) + p2 = paginator.page(page) + page = int(page) + total_page = int(page+3) + + if page < (paginator.num_pages-3): + if total_query2 > 30 and total_query2 <= 60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(page-2, paginator.num_pages+1) + else: + pagination_higher = 0 + else: + if request.GET.get('page') != None: + try: + if request.session['year']: + higherrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter( + Q(placement_type="HIGHER STUDIES", + test_type__icontains=request.session['test_type'], + name__icontains=request.session['uname'], + year=request.session['year'], + test_score__gte=request.session['test_score'])), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno'])) + ))))) + else: + higherrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( + Q(record_id__in=PlacementRecord.objects.filter( + Q(placement_type="HIGHER STUDIES", + test_type__icontains=request.session['test_type'], + name__icontains=request.session['uname'], + test_score__gte=request.session['test_score'])), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['first_name'], + last_name__icontains=request.session['last_name'])), + id__icontains=request.session['rollno'])) + ))))) + except: + higherrecord = '' + + if higherrecord != '': + total_query = higherrecord.count() + else: + total_query = 0 + + if total_query > 30: + no_pagination = 1 + paginator = Paginator(higherrecord, 30) + page = request.GET.get('page', 1) + higherrecord = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + no_pagination = 0 + else: + higherrecord = '' + if total_query2!=0: + higher_search_record=p2 + + context = { + 'form2' : form2, + 'form3' : form3, + 'form4' : form4, + 'current' : current, + 'current1' : current1, + 'current2' : current2, + + + 'all_records': all_records, #for flashing all placement Schedule + + 'placement_search_record': placement_search_record, + 'pbi_search_record': pbi_search_record, + 'higher_search_record': higher_search_record, + + + + 'statistics_tab' : statistics_tab, + 'pbirecord' : pbirecord, + 'placementrecord' : placementrecord, + 'higherrecord' : higherrecord, + 'years' : years, + 'records' : records, + 'delete_operation' : delete_operation, + 'page_range': page_range, + 'paginator': paginator, + 'pagination_placement': pagination_placement, + 'pagination_pbi': pagination_pbi, + 'pagination_higher': pagination_higher, + 'is_disabled': is_disabled, + 'officer_statistics_past_pbi_search': officer_statistics_past_pbi_search, + 'officer_statistics_past_higher_search': officer_statistics_past_higher_search + } + + return render(request, 'placementModule/placementstatistics.html', context) + + + +def get_reference_list(request): + if request.method == 'POST': + + user = request.user + profile = get_object_or_404(ExtraInfo, Q(user=user)) + student = get_object_or_404(Student, Q(id=profile.id)) + print(student) + reference_objects = Reference.select_related('unique_id').objects.filter(unique_id=student) + reference_objects = serializers.serialize('json', list(reference_objects)) + + context = { + 'reference_objs': reference_objects + } + return JsonResponse(context) + + +# Ajax for the company name dropdown for CompanyName when filling AddSchedule +def company_name_dropdown(request): + if request.method == 'POST': + current_value = request.POST.get('current_value') + company_names = CompanyDetails.objects.filter(Q(company_name__startswith=current_value)) + company_name = [] + for name in company_names: + company_name.append(name.company_name) + + context = { + 'company_names': company_name + } + + return JsonResponse(context) + + +# Ajax for all the roles in the dropdown +def checking_roles(request): + if request.method == 'POST': + current_value = request.POST.get('current_value') + all_roles = Role.objects.filter(Q(role__startswith=current_value)) + role_name = [] + for role in all_roles: + role_name.append(role.role) + return JsonResponse({'all_roles': role_name}) + +@login_required +def Placement__Schedule(request): + ''' + function include the functionality of first tab of UI + for student, placement officer & placement chairman + + placement officer & placement chairman + - can add schedule + - can delete schedule + student + - accepted or declined schedule + + ''' + user = request.user + profile = get_object_or_404(ExtraInfo, Q(user=user)) + schedule_tab = 1 + placementstatus = '' + + + form5 = AddSchedule(initial={}) + current1 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement chairman")) + current2 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement officer")) + current = HoldsDesignation.objects.filter(Q(working=user, designation__name="student")) + print(current) + + # If the user is Student + if current: + student = get_object_or_404(Student, Q(id=profile.id)) + + # Student view for showing accepted or declined schedule + if request.method == 'POST': + if 'studentapprovesubmit' in request.POST: + status = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + pk=request.POST['studentapprovesubmit']).update( + invitation='ACCEPTED', + timestamp=timezone.now()) + if 'studentdeclinesubmit' in request.POST: + status = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + Q(pk=request.POST['studentdeclinesubmit'])).update( + invitation='REJECTED', + timestamp=timezone.now()) + + if 'educationsubmit' in request.POST: + form = AddEducation(request.POST) + if form.is_valid(): + institute = form.cleaned_data['institute'] + degree = form.cleaned_data['degree'] + grade = form.cleaned_data['grade'] + stream = form.cleaned_data['stream'] + sdate = form.cleaned_data['sdate'] + edate = form.cleaned_data['edate'] + education_obj = Education.objects.select_related('unique_id').create( + unique_id=student, degree=degree, + grade=grade, institute=institute, + stream=stream, sdate=sdate, edate=edate) + education_obj.save() + if 'profilesubmit' in request.POST: + about_me = request.POST.get('about') + age = request.POST.get('age') + address = request.POST.get('address') + contact = request.POST.get('contact') + pic = request.POST.get('pic') + # futu = request.POST.get('futu') + # print(studentplacement_obj.future_aspect) + # print('fut=', fut) + # print('futu=', futu) + # if studentplacement_obj.future_aspect == "HIGHER STUDIES": + # if futu == 2: + # studentplacement_obj.future_aspect = "PLACEMENT" + # elif studentplacement_obj.future_aspect == "PLACEMENT": + # if futu == None: + # studentplacement_obj.future_aspect = "HIGHER STUDIES" + extrainfo_obj = ExtraInfo.objects.get(user=user) + extrainfo_obj.about_me = about_me + extrainfo_obj.age = age + extrainfo_obj.address = address + extrainfo_obj.phone_no = contact + extrainfo_obj.profile_picture = pic + extrainfo_obj.save() + profile = get_object_or_404(ExtraInfo, Q(user=user)) + if 'skillsubmit' in request.POST: + form = AddSkill(request.POST) + if form.is_valid(): + skill = form.cleaned_data['skill'] + skill_rating = form.cleaned_data['skill_rating'] + has_obj = Has.objects.select_related('skill_id','unique_id').create(unique_id=student, + skill_id=Skill.objects.get(skill=skill), + skill_rating = skill_rating) + has_obj.save() + if 'achievementsubmit' in request.POST: + form = AddAchievement(request.POST) + if form.is_valid(): + achievement = form.cleaned_data['achievement'] + achievement_type = form.cleaned_data['achievement_type'] + description = form.cleaned_data['description'] + issuer = form.cleaned_data['issuer'] + date_earned = form.cleaned_data['date_earned'] + achievement_obj = Achievement.objects.select_related('unique_id').create(unique_id=student, + achievement=achievement, + achievement_type=achievement_type, + description=description, + issuer=issuer, + date_earned=date_earned) + achievement_obj.save() + if 'publicationsubmit' in request.POST: + form = AddPublication(request.POST) + if form.is_valid(): + publication_title = form.cleaned_data['publication_title'] + description = form.cleaned_data['description'] + publisher = form.cleaned_data['publisher'] + publication_date = form.cleaned_data['publication_date'] + publication_obj = Publication.objects.select_related('unique_id').create(unique_id=student, + publication_title= + publication_title, + publisher=publisher, + description=description, + publication_date=publication_date) + publication_obj.save() + if 'patentsubmit' in request.POST: + form = AddPatent(request.POST) + if form.is_valid(): + patent_name = form.cleaned_data['patent_name'] + description = form.cleaned_data['description'] + patent_office = form.cleaned_data['patent_office'] + patent_date = form.cleaned_data['patent_date'] + patent_obj = Patent.objects.select_related('unique_id').create(unique_id=student, patent_name=patent_name, + patent_office=patent_office, + description=description, + patent_date=patent_date) + patent_obj.save() + if 'coursesubmit' in request.POST: + form = AddCourse(request.POST) + if form.is_valid(): + course_name = form.cleaned_data['course_name'] + description = form.cleaned_data['description'] + license_no = form.cleaned_data['license_no'] + sdate = form.cleaned_data['sdate'] + edate = form.cleaned_data['edate'] + course_obj = Course.objects.select_related('unique_id').create(unique_id=student, course_name=course_name, + license_no=license_no, + description=description, + sdate=sdate, edate=edate) + course_obj.save() + if 'projectsubmit' in request.POST: + form = AddProject(request.POST) + if form.is_valid(): + project_name = form.cleaned_data['project_name'] + project_status = form.cleaned_data['project_status'] + summary = form.cleaned_data['summary'] + project_link = form.cleaned_data['project_link'] + sdate = form.cleaned_data['sdate'] + edate = form.cleaned_data['edate'] + project_obj = Project.objects.create(unique_id=student, summary=summary, + project_name=project_name, + project_status=project_status, + project_link=project_link, + sdate=sdate, edate=edate) + project_obj.save() + if 'experiencesubmit' in request.POST: + form = AddExperience(request.POST) + if form.is_valid(): + title = form.cleaned_data['title'] + status = form.cleaned_data['status'] + company = form.cleaned_data['company'] + location = form.cleaned_data['location'] + description = form.cleaned_data['description'] + sdate = form.cleaned_data['sdate'] + edate = form.cleaned_data['edate'] + experience_obj = Experience.objects.select_related('unique_id').create(unique_id=student, title=title, + company=company, location=location, + status=status, + description=description, + sdate=sdate, edate=edate) + experience_obj.save() + + if 'deleteskill' in request.POST: + hid = request.POST['deleteskill'] + hs = Has.objects.select_related('skill_id','unique_id').get(Q(pk=hid)) + hs.delete() + if 'deleteedu' in request.POST: + hid = request.POST['deleteedu'] + hs = Education.objects.select_related('unique_id').get(Q(pk=hid)) + hs.delete() + if 'deletecourse' in request.POST: + hid = request.POST['deletecourse'] + hs = Course.objects.get(Q(pk=hid)) + hs.delete() + if 'deleteexp' in request.POST: + hid = request.POST['deleteexp'] + hs = Experience.objects.get(Q(pk=hid)) + hs.delete() + if 'deletepro' in request.POST: + hid = request.POST['deletepro'] + hs = Project.objects.get(Q(pk=hid)) + hs.delete() + if 'deleteach' in request.POST: + hid = request.POST['deleteach'] + hs = Achievement.objects.get(Q(pk=hid)) + hs.delete() + if 'deletepub' in request.POST: + hid = request.POST['deletepub'] + hs = Publication.objects.select_related('unique_id').get(Q(pk=hid)) + hs.delete() + if 'deletepat' in request.POST: + hid = request.POST['deletepat'] + hs = Patent.objects.get(Q(pk=hid)) + hs.delete() + + placementschedule = PlacementSchedule.objects.select_related('notify_id').filter( + Q(placement_date__gte=date.today())).values_list('notify_id', flat=True) + + placementstatus = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + Q(unique_id=student, + notify_id__in=placementschedule)).order_by('-timestamp') + + + check_invitation_date(placementstatus) + + # facult and other staff view only statistics + if not (current or current1 or current2): + return redirect('/placement/statistics/') + + # delete the schedule + if 'deletesch' in request.POST: + delete_sch_key = request.POST['delete_sch_key'] + try: + placement_schedule = PlacementSchedule.objects.select_related('notify_id').get(pk = delete_sch_key) + NotifyStudent.objects.get(pk=placement_schedule.notify_id.id).delete() + placement_schedule.delete() + messages.success(request, 'Schedule Deleted Successfully') + except Exception as e: + messages.error(request, 'Problem Occurred for Schedule Delete!!!') + + # saving all the schedule details + if 'schedulesubmit' in request.POST: + form5 = AddSchedule(request.POST, request.FILES) + if form5.is_valid(): + company_name = form5.cleaned_data['company_name'] + placement_date = form5.cleaned_data['placement_date'] + location = form5.cleaned_data['location'] + ctc = form5.cleaned_data['ctc'] + time = form5.cleaned_data['time'] + attached_file = form5.cleaned_data['attached_file'] + placement_type = form5.cleaned_data['placement_type'] + role_offered = request.POST.get('role') + description = form5.cleaned_data['description'] + + try: + comp_name = CompanyDetails.objects.filter(company_name=company_name)[0] + except: + CompanyDetails.objects.create(company_name=company_name) + + try: + role = Role.objects.filter(role=role_offered)[0] + except: + role = Role.objects.create(role=role_offered) + role.save() + + + notify = NotifyStudent.objects.create(placement_type=placement_type, + company_name=company_name, + description=description, + ctc=ctc, + timestamp=timezone.now()) + + schedule = PlacementSchedule.objects.select_related('notify_id').create(notify_id=notify, + title=company_name, + description=description, + placement_date=placement_date, + attached_file = attached_file, + role=role, + location=location, time=time) + + notify.save() + schedule.save() + messages.success(request, "Schedule Added Successfull!!") + + + schedules = PlacementSchedule.objects.select_related('notify_id').all() + + + context = { + 'current': current, + 'current1': current1, + 'current2': current2, + 'schedule_tab': schedule_tab, + 'schedules': schedules, + 'placementstatus': placementstatus, + 'form5': form5, + } + + return render(request, 'placementModule/placement.html', context) + + + +def invite_status(request): + ''' + function to check the invitation status + ''' + user = request.user + strecord_tab = 1 + mnpbi_tab = 0 + mnplacement_post = 0 + mnpbi_post = 0 + invitation_status_tab = 1 + placementstatus_placement = [] + placementstatus_pbi = [] + mnplacement_tab = 1 + + no_pagination = 1 + is_disabled = 0 + paginator = '' + page_range = '' + placement_get_request = False + pbi_get_request = False + + # invitation status for placement + if 'studentplacementsearchsubmit' in request.POST: + mnplacement_post = 1 + mnpbi_post = 0 + form = ManagePlacementRecord(request.POST) + + if form.is_valid(): + if form.cleaned_data['stuname']: + stuname = form.cleaned_data['stuname'] + else: + stuname = '' + if form.cleaned_data['ctc']: + ctc = form.cleaned_data['ctc'] + else: + ctc = 0 + if form.cleaned_data['company']: + cname = form.cleaned_data['company'] + else: + cname = '' + if form.cleaned_data['roll']: + rollno = form.cleaned_data['roll'] + else: + rollno = '' + + request.session['mn_stuname'] = stuname + request.session['mn_ctc'] = ctc + request.session['mn_cname'] = cname + request.session['mn_rollno'] = rollno + + placementstatus_placement = PlacementStatus.objects.select_related('unique_id','notify_id').filter(Q(notify_id__in=NotifyStudent.objects.filter + (Q(placement_type="PLACEMENT", + company_name__icontains=cname, + ctc__gte=ctc)), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=stuname)), + id__icontains=rollno)) + ))))) + # pagination stuff starts from here + total_query = placementstatus_placement.count() + + if total_query > 30: + no_pagination = 1 + paginator = Paginator(placementstatus_placement, 30) + page = request.GET.get('page', 1) + placementstatus_placement = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + no_pagination = 0 + else: + # when the request from pagination with some page number + if request.GET.get('placement_page') != None: + mnplacement_post = 1 + mnpbi_post = 0 + no_pagination = 1 + try: + placementstatus_placement = PlacementStatus.objects.select_related('unique_id','notify_id').filter(Q(notify_id__in=NotifyStudent.objects.filter + (Q(placement_type="PLACEMENT", + company_name__icontains=request.session['mn_cname'], + ctc__gte=request.session['mn_ctc'])), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=request.session['mn_stuname'])), + id__icontains=request.session['mn_rollno'])) + ))))) + except: + placementstatus_placement = [] + + if placementstatus_placement != '': + total_query = placementstatus_placement.count() + else: + total_query = 0 + + if total_query > 30: + paginator = Paginator(placementstatus_placement, 30) + page = request.GET.get('placement_page', 1) + placementstatus_placement = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + no_pagination = 0 + + # invitation status for pbi + if 'studentpbisearchsubmit' in request.POST: + mnpbi_tab = 1 + mnpbi_post = 1 + mnplacement_post = 0 + form = ManagePbiRecord(request.POST) + if form.is_valid(): + if form.cleaned_data['stuname']: + stuname = form.cleaned_data['stuname'] + else: + stuname = '' + if form.cleaned_data['ctc']: + ctc = form.cleaned_data['ctc'] + else: + ctc = 0 + if form.cleaned_data['company']: + cname = form.cleaned_data['company'] + else: + cname = '' + if form.cleaned_data['roll']: + rollno = form.cleaned_data['roll'] + else: + rollno = '' + request.session['mn_pbi_stuname'] = stuname + request.session['mn_pbi_ctc'] = ctc + request.session['mn_pbi_cname'] = cname + request.session['mn_pbi_rollno'] = rollno + placementstatus_pbi = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + Q(notify_id__in=NotifyStudent.objects.filter( + Q(placement_type="PBI", + company_name__icontains=cname, + ctc__gte=ctc)), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=stuname)), + id__icontains=rollno))))))).order_by('id') + + total_query = placementstatus_pbi.count() + + if total_query > 30: + no_pagination = 1 + paginator = Paginator(placementstatus_pbi, 30) + page = request.GET.get('pbi_page', 1) + placementstatus_pbi = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + no_pagination = 0 + else: + if request.GET.get('pbi_page') != None: + mnpbi_tab = 1 + mnpbi_post = 1 + no_pagination = 1 + try: + placementstatus_pbi = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + Q(notify_id__in=NotifyStudent.objects.filter( + Q(placement_type="PBI", + company_name__icontains=request.session['mn_pbi_cname'], + ctc__gte=request.session['mn_pbi_ctc'])), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=request.session['mn_pbi_stuname'])), + id__icontains=request.session['mn_pbi_rollno'])) + ))))) + except: + placementstatus_pbi = '' + + if placementstatus_pbi != '': + total_query = placementstatus_pbi.count() + else: + total_query = 0 + if total_query > 30: + paginator = Paginator(placementstatus_pbi, 30) + page = request.GET.get('pbi_page', 1) + placementstatus_pbi = paginator.page(page) + page = int(page) + total_page = int(page + 3) + + if page<(paginator.num_pages-3): + if total_query > 30 and total_query <=60: + page_range = range(1, 3) + else: + page_range = range(1, total_page+1) + + if page >= 5: + is_disabled = 1 + page_range = range(page-2, total_page) + else: + if page >= 5: + is_disabled = 1 + page_range = range(page-2, paginator.num_pages+1) + else: + page_range = range(1, paginator.num_pages+1) + else: + no_pagination = 0 + + + if 'pdf_gen_invitation_status' in request.POST: + + placementstatus = None + if 'pdf_gen_invitation_status_placement' in request.POST: + stuname = request.session['mn_stuname'] + ctc = request.session['mn_ctc'] + cname = request.session['mn_cname'] + rollno = request.session['mn_rollno'] + + placementstatus = PlacementStatus.objects.select_related('unique_id','notify_id').filter(Q(notify_id__in=NotifyStudent.objects.filter + (Q(placement_type="PLACEMENT", + company_name__icontains=cname, + ctc__gte=ctc)), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=stuname)), + id__icontains=rollno)) + ))))) + + if 'pdf_gen_invitation_status_pbi' in request.POST: + stuname = request.session['mn_pbi_stuname'] + ctc = request.session['mn_pbi_ctc'] + cname = request.session['mn_pbi_cname'] + rollno = request.session['mn_pbi_rollno'] + + placementstatus = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + Q(notify_id__in=NotifyStudent.objects.filter( + Q(placement_type="PBI", + company_name__icontains=cname, + ctc__gte=ctc)), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=stuname)), + id__icontains=rollno))))))).order_by('id') + + context = { + 'placementstatus' : placementstatus + } + + return render_to_pdf('placementModule/pdf_invitation_status.html', context) + + if 'excel_gen_invitation_status' in request.POST: + + placementstatus = None + if 'excel_gen_invitation_status_placement' in request.POST: + stuname = request.session['mn_stuname'] + ctc = request.session['mn_ctc'] + cname = request.session['mn_cname'] + rollno = request.session['mn_rollno'] + + placementstatus = PlacementStatus.objects.select_related('unique_id','notify_id').filter(Q(notify_id__in=NotifyStudent.objects.filter + (Q(placement_type="PLACEMENT", + company_name__icontains=cname, + ctc__gte=ctc)), + unique_id__in=Student.objects.filter + ((Q(id__in=ExtraInfo.objects.filter + (Q(user__in=User.objects.filter + (Q(first_name__icontains=stuname)), + id__icontains=rollno)) + ))))) + + if 'excel_gen_invitation_status_pbi' in request.POST: + stuname = request.session['mn_pbi_stuname'] + ctc = request.session['mn_pbi_ctc'] + cname = request.session['mn_pbi_cname'] + rollno = request.session['mn_pbi_rollno'] + + placementstatus = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + Q(notify_id__in=NotifyStudent.objects.filter( + Q(placement_type="PBI", + company_name__icontains=cname, + ctc__gte=ctc)), + unique_id__in=Student.objects.filter( + (Q(id__in=ExtraInfo.objects.filter( + Q(user__in=User.objects.filter( + Q(first_name__icontains=stuname)), + id__icontains=rollno))))))).order_by('id') + + context = { + 'placementstatus' : placementstatus + } + + + return export_to_xls_invitation_status(placementstatus) + + form1 = SearchStudentRecord(initial={}) + form9 = ManagePbiRecord(initial={}) + form11 = ManagePlacementRecord(initial={}) + form13 = SendInvite(initial={}) + current1 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement chairman")) + current2 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement officer")) + + context = { + 'form1': form1, + 'form9': form9, + 'form11': form11, + 'form13': form13, + 'invitation_status_tab': invitation_status_tab, + 'mnplacement_post': mnplacement_post, + 'mnpbi_tab': mnpbi_tab, + 'mnplacement_tab': mnplacement_tab, + 'placementstatus_placement': placementstatus_placement, + 'placementstatus_pbi': placementstatus_pbi, + 'current1': current1, + 'current2': current2, + 'strecord_tab': strecord_tab, + 'mnpbi_post': mnpbi_post, + 'page_range': page_range, + 'paginator': paginator, + 'no_pagination': no_pagination, + 'is_disabled': is_disabled, + } + + return render(request, 'placementModule/studentrecords.html', context) + + + +@login_required +def placement(request): + ''' + function include the functionality of first tab of UI + for student, placement officer & placement chairman + + placement officer & placement chairman + - can add schedule + - can delete schedule + student + - accepted or declined schedule + + ''' + user = request.user + profile = get_object_or_404(ExtraInfo, Q(user=user)) + schedule_tab = 1 + placementstatus = '' + + + form5 = AddSchedule(initial={}) + current1 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement chairman")) + current2 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement officer")) + current = HoldsDesignation.objects.filter(Q(working=user, designation__name="student")) + print(current) + + # If the user is Student + if current: + student = get_object_or_404(Student, Q(id=profile.id)) + + # Student view for showing accepted or declined schedule + if request.method == 'POST': + if 'studentapprovesubmit' in request.POST: + status = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + pk=request.POST['studentapprovesubmit']).update( + invitation='ACCEPTED', + timestamp=timezone.now()) + if 'studentdeclinesubmit' in request.POST: + status = PlacementStatus.objects.select_related('unique_id','notify_id').filter( + Q(pk=request.POST['studentdeclinesubmit'])).update( + invitation='REJECTED', + timestamp=timezone.now()) + + if 'educationsubmit' in request.POST: + form = AddEducation(request.POST) + if form.is_valid(): + institute = form.cleaned_data['institute'] + degree = form.cleaned_data['degree'] + grade = form.cleaned_data['grade'] + stream = form.cleaned_data['stream'] + sdate = form.cleaned_data['sdate'] + edate = form.cleaned_data['edate'] + education_obj = Education.objects.select_related('unique_id').create( + unique_id=student, degree=degree, + grade=grade, institute=institute, + stream=stream, sdate=sdate, edate=edate) + education_obj.save() + if 'profilesubmit' in request.POST: + about_me = request.POST.get('about') + age = request.POST.get('age') + address = request.POST.get('address') + contact = request.POST.get('contact') + pic = request.POST.get('pic') + extrainfo_obj = ExtraInfo.objects.get(user=user) extrainfo_obj.about_me = about_me extrainfo_obj.age = age @@ -1201,7 +3905,6 @@ def student_records(request): unique_id=student, no_of_days=no_of_days) for student in students] ) for st in students: - #print(request.user, '-----------------------', st.id.user,'-----------------') placement_cell_notif(request.user, st.id.user, "") students = '' @@ -1825,6 +4528,68 @@ def manage_records(request): +@login_required +def delete_invite_status(request): + ''' + function to delete the invitation that has been sent to the students + ''' + user = request.user + strecord_tab = 1 + mnpbi_tab = 0 + mnplacement_post = 0 + mnpbi_post = 0 + invitation_status_tab = 1 + placementstatus = [] + + no_pagination = 1 + is_disabled = 0 + paginator = '' + page_range = '' + + if 'deleteinvitationstatus' in request.POST: + delete_invit_status_key = request.POST['deleteinvitationstatus'] + + try: + PlacementStatus.objects.select_related('unique_id','notify_id').get(pk=delete_invit_status_key).delete() + messages.success(request, 'Invitation Deleted Successfully') + except Exception as e: + logger.error(e) + + if 'pbi_tab_active' in request.POST: + mnpbi_tab = 1 + else: + mnplacement_tab = 1 + + form1 = SearchStudentRecord(initial={}) + form9 = ManagePbiRecord(initial={}) + form11 = ManagePlacementRecord(initial={}) + form13 = SendInvite(initial={}) + current1 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement chairman")) + current2 = HoldsDesignation.objects.filter(Q(working=user, designation__name="placement officer")) + + context = { + 'form1': form1, + 'form9': form9, + 'form11': form11, + 'form13': form13, + 'invitation_status_tab': invitation_status_tab, + 'mnplacement_post': mnplacement_post, + 'mnpbi_tab': mnpbi_tab, + 'placementstatus': placementstatus, + # 'current':current, + 'current1': current1, + 'current2': current2, + 'strecord_tab': strecord_tab, + 'mnpbi_post': mnpbi_post, + 'page_range': page_range, + 'paginator': paginator, + 'no_pagination': no_pagination, + 'is_disabled': is_disabled, + } + + return render(request, 'placementModule/studentrecords.html', context) + + @login_required def placement_statistics(request): @@ -1975,47 +4740,7 @@ def placement_statistics(request): id__icontains=rollno)) ))) - p = PlacementRecord.objects.filter(Q(placement_type="PLACEMENT", name__icontains=stuname, ctc__icontains=ctc, year__icontains=year)) - - - - - """placementrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( - Q(record_id__in=PlacementRecord.objects.filter( - Q(placement_type="PLACEMENT", name__icontains=cname, ctc__gte=ctc, year=year)), - unique_id__in=Student.objects.filter( - (Q(id__in=ExtraInfo.objects.filter( - Q(user__in=User.objects.filter( - first_name__icontains=first_name, - last_name__icontains=last_name, - id__icontains=rollno)))))))) - #print("In if:", placementrecord) - else: - s = Student.objects.filter((Q(id__in=ExtraInfo.objects.filter( - Q(user__in=User.objects.filter( - first_name__icontains=first_name, - last_name__icontains=last_name), - id__icontains=rollno)) - ))) - - p = PlacementRecord.objects.filter(Q(placement_type="PLACEMENT", name__icontains=cname, ctc__gte=ctc)) - print("Agein p:",p) - placementrecord = StudentRecord.objects.select_related('unique_id','record_id').filter( - Q(record_id__in=PlacementRecord.objects.filter( - Q(placement_type="PLACEMENT", name__icontains=cname, ctc__gte=ctc)), - unique_id__in=Student.objects.filter( - (Q(id__in=ExtraInfo.objects.filter( - Q(user__in=User.objects.filter( - first_name__icontains=first_name, - last_name__icontains=last_name), - id__icontains=rollno))))))) - - request.session['first_name'] = first_name - request.session['last_name'] = last_name - request.session['ctc'] = ctc - request.session['cname'] = cname - request.session['rollno'] = rollno - request.session['year'] = form.cleaned_data['year']""" + p = PlacementRecord.objects.filter(Q(placement_type="PLACEMENT",name__icontains=stuname, ctc__icontains=ctc, year__icontains=year)) print(p) @@ -2605,20 +5330,20 @@ def cv(request, username): extracurricularcheck = '1' - # print(achievementcheck,' ',educationcheck,' ',publicationcheck,' ',patentcheck,' ',internshipcheck,' ',projectcheck,' \n\n\n') + user = get_object_or_404(User, Q(username=username)) profile = get_object_or_404(ExtraInfo, Q(user=user)) + student_info=get_object_or_404(Student,Q(id=user.username)) + + batch=student_info.batch + now = datetime.datetime.now() - if int(str(profile.id)[:2]) == 20: - if (now.month>4): - roll = 1+now.year-int(str(profile.id)[:4]) - else: - roll = now.year-int(str(profile.id)[:4]) + print("year----->",now.year) + if now.year-batch<=4: + roll=now.year-batch else: - if (now.month>4): - roll = 1+(now.year)-int("20"+str(profile.id)[0:2]) - else: - roll = (now.year)-int("20"+str(profile.id)[0:2]) + roll=4 + student = get_object_or_404(Student, Q(id=profile.id)) skills = Has.objects.select_related('skill_id','unique_id').filter(Q(unique_id=student)) @@ -2695,7 +5420,6 @@ def export_to_xls_std_records(qs): wb = xlwt.Workbook(encoding='utf-8') ws = wb.add_sheet('Report') - # Sheet header, first row row_num = 0 font_style = xlwt.XFStyle() @@ -2706,7 +5430,6 @@ def export_to_xls_std_records(qs): for col_num in range(len(columns)): ws.write(row_num, col_num, columns[col_num], font_style) - # Sheet body, remaining rows font_style = xlwt.XFStyle() for student in qs: @@ -2732,6 +5455,128 @@ def export_to_xls_std_records(qs): wb.save(response) return response +def resume(request, username): + # Retrieve data or whatever you need + """ + The function is used to generate the cv in the pdf format. + Embeds the data into the predefined template. + @param: + request - trivial + username - name of user whose cv is to be generated + @variables: + user = stores current user + profile = stores extrainfo of user + current = Stores all working students from HoldsDesignation for the respective degignation + achievementcheck = variable for achievementcheck in form for cv generation + educationcheck = variable for educationcheck in form for cv generation + publicationcheck = variable for publicationcheck in form for cv generation + patentcheck = variable for patentcheck in form for cv generation + internshipcheck = variable for internshipcheck in form for cv generation + projectcheck = variable for projectcheck in form for cv generation + coursecheck = variable for coursecheck in form for cv generation + skillcheck = variable for skillcheck in form for cv generation + user = get_object_or_404(User, Q(username=username)) + profile = get_object_or_404(ExtraInfo, Q(user=user)) + import datetime + now = stores current timestamp + roll = roll of the user + student = variable storing the profile data + studentplacement = variable storing the placement data + skills = variable storing the skills data + education = variable storing the education data + course = variable storing the course data + experience = variable storing the experience data + project = variable storing the project data + achievement = variable storing the achievement data + publication = variable storing the publication data + patent = variable storing the patent data + """ + user = request.user + profile = get_object_or_404(ExtraInfo, Q(user=user)) + + current = HoldsDesignation.objects.filter(Q(working=user, designation__name="student")) + if current: + if request.method == 'POST': + achievementcheck = request.POST.get('achievementcheck') + educationcheck = request.POST.get('educationcheck') + publicationcheck = request.POST.get('publicationcheck') + patentcheck = request.POST.get('patentcheck') + internshipcheck = request.POST.get('internshipcheck') + projectcheck = request.POST.get('projectcheck') + coursecheck = request.POST.get('coursecheck') + skillcheck = request.POST.get('skillcheck') + reference_list = request.POST.getlist('reference_checkbox_list') + extracurricularcheck = request.POST.get('extracurricularcheck') + conferencecheck = request.POST.get('conferencecheck') + else: + conferencecheck = '1' + achievementcheck = '1' + educationcheck = '1' + publicationcheck = '1' + patentcheck = '1' + internshipcheck = '1' + projectcheck = '1' + coursecheck = '1' + skillcheck = '1' + extracurricularcheck = '1' + + + # print(achievementcheck,' ',educationcheck,' ',publicationcheck,' ',patentcheck,' ',internshipcheck,' ',projectcheck,' \n\n\n') + user = get_object_or_404(User, Q(username=username)) + profile = get_object_or_404(ExtraInfo, Q(user=user)) + now = datetime.datetime.now() + if int(str(profile.id)[:2]) == 20: + if (now.month>4): + roll = 1+now.year-int(str(profile.id)[:4]) + else: + roll = now.year-int(str(profile.id)[:4]) + else: + if (now.month>4): + roll = 1+(now.year)-int("20"+str(profile.id)[0:2]) + else: + roll = (now.year)-int("20"+str(profile.id)[0:2]) + + student = get_object_or_404(Student, Q(id=profile.id)) + skills = Has.objects.select_related('skill_id','unique_id').filter(Q(unique_id=student)) + education = Education.objects.select_related('unique_id').filter(Q(unique_id=student)) + reference = Reference.objects.filter(id__in=reference_list) + course = Course.objects.select_related('unique_id').filter(Q(unique_id=student)) + experience = Experience.objects.select_related('unique_id').filter(Q(unique_id=student)) + project = Project.objects.select_related('unique_id').filter(Q(unique_id=student)) + achievement = Achievement.objects.select_related('unique_id').filter(Q(unique_id=student)) + extracurricular = Extracurricular.objects.select_related('unique_id').filter(Q(unique_id=student)) + conference = Conference.objects.select_related('unique_id').filter(Q(unique_id=student)) + publication = Publication.objects.select_related('unique_id').filter(Q(unique_id=student)) + patent = Patent.objects.select_related('unique_id').filter(Q(unique_id=student)) + today = datetime.date.today() + + if len(reference) == 0: + referencecheck = '0' + else: + referencecheck = '1' + + return render_to_pdf('placementModule/cv.html', {'pagesize': 'A4', 'user': user, 'references': reference, + 'profile': profile, 'projects': project, + 'skills': skills, 'educations': education, + 'courses': course, 'experiences': experience, + 'referencecheck': referencecheck, + 'achievements': achievement, + 'extracurriculars': extracurricular, + 'publications': publication, + 'patents': patent, 'roll': roll, + 'achievementcheck': achievementcheck, + 'extracurricularcheck': extracurricularcheck, + 'educationcheck': educationcheck, + 'publicationcheck': publicationcheck, + 'patentcheck': patentcheck, + 'conferencecheck': conferencecheck, + 'conferences': conference, + 'internshipcheck': internshipcheck, + 'projectcheck': projectcheck, + 'coursecheck': coursecheck, + 'skillcheck': skillcheck, + 'today':today}) + def export_to_xls_invitation_status(qs): @@ -2741,7 +5586,7 @@ def export_to_xls_invitation_status(qs): wb = xlwt.Workbook(encoding='utf-8') ws = wb.add_sheet('Report') - # Sheet header, first row + row_num = 0 font_style = xlwt.XFStyle() @@ -2752,7 +5597,7 @@ def export_to_xls_invitation_status(qs): for col_num in range(len(columns)): ws.write(row_num, col_num, columns[col_num], font_style) - # Sheet body, remaining rows + font_style = xlwt.XFStyle() for student in qs: @@ -2786,7 +5631,6 @@ def check_invitation_date(placementstatus): if ps.invitation=='PENDING': dt = ps.timestamp+datetime.timedelta(days=ps.no_of_days) if dt/',views.update_course_proposal_form,name='update_course_proposal_form'), path('faculty_view_all_courses/', views.faculty_view_all_courses, name='faculty_view_all_courses'), path('faculty_view_a_course//',views.faculty_view_a_course,name="faculty_view_a_course"), - path('head_view_a_course_proposal//', views.head_view_a_course_proposal, name='head_view_a_course_proposal'), - path('head_view_a_update_course_proposal//', views.head_view_a_update_course_proposal, name='head_view_a_update_course_proposal'), + path('reject_form//', views.reject_form, name='reject_form'), + path('new_course_proposal_file/',views.new_course_proposal_file,name='new_course_proposal_file'), + path('update_course_proposal_file//',views.update_course_proposal_file,name='update_course_proposal_file'), - path('forward_form/', views.forward_form, name='forward_form'), - path('reject_form/', views.reject_form, name='reject_form'), - # path('approve_form/', views.approve_form, name='approve_form'), - - path('forward_update_form//', views.forward_update_form, name='forward_update_form'), - path('reject_update_form/', views.reject_update_form, name='reject_update_form'), - # path('approve_update_form/', views.approve_update_form, name='approve_update_form'), + path('view_a_course_proposal_form//',views.view_a_course_proposal_form,name='view_a_course_proposal_form'), + path('filetracking//',views.filetracking,name='filetracking'), + path('inward_files/',views.inward_files,name='inward_files'), + path('forward_course_forms//',views.forward_course_forms,name='forward_course_forms'), + path('view_inward_files//',views.view_inward_files,name='view_inward_files'), + path('outward_files/',views.outward_files,name='outward_files'), ] diff --git a/FusionIIIT/applications/programme_curriculum/views.py b/FusionIIIT/applications/programme_curriculum/views.py index 5efb2314c..3c1fc5e3e 100644 --- a/FusionIIIT/applications/programme_curriculum/views.py +++ b/FusionIIIT/applications/programme_curriculum/views.py @@ -1,19 +1,19 @@ from django.db.models.query_utils import Q from django.http import request -from django.shortcuts import get_object_or_404, render, HttpResponse +from django.shortcuts import get_object_or_404, render, HttpResponse,redirect from django.http import HttpResponse, HttpResponseRedirect -import itertools +# import itertools from django.contrib import messages from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User -from .models import Programme, Discipline, Curriculum, Semester, Course, Batch, CourseSlot,CourseProposal,UpdateCourseProposal -from .forms import ProgrammeForm, DisciplineForm, CurriculumForm, SemesterForm, CourseForm, BatchForm, CourseSlotForm, ReplicateCurriculumForm,Course_Proposal,Update_Course_Proposal,CourseProposalForm +from .models import Programme, Discipline, Curriculum, Semester, Course, Batch, CourseSlot,NewProposalFile,Proposal_Tracking +from .forms import ProgrammeForm, DisciplineForm, CurriculumForm, SemesterForm, CourseForm, BatchForm, CourseSlotForm, ReplicateCurriculumForm,NewCourseProposalFile,CourseProposalTrackingFile from .filters import CourseFilter, BatchFilter, CurriculumFilter from django.db import IntegrityError +from django.utils import timezone # from applications.academic_information.models import Student -from applications.globals.models import (DepartmentInfo, Designation, - ExtraInfo, Faculty, HoldsDesignation) +from applications.globals.models import (DepartmentInfo, Designation,ExtraInfo, Faculty, HoldsDesignation) # ------------module-functions---------------# @@ -310,7 +310,6 @@ def admin_view_all_programmes(request): return render(request, 'programme_curriculum/acad_admin/admin_view_all_programmes.html', {'ug': ug, 'pg': pg, "phd": phd}) -@login_required(login_url='/accounts/login') def admin_view_curriculums_of_a_programme(request, programme_id): """ This function is used to Display Curriculum of a specific Programmes. @@ -344,7 +343,6 @@ def admin_view_curriculums_of_a_programme(request, programme_id): return render(request,'programme_curriculum/acad_admin/admin_view_curriculums_of_a_programme.html', {'program': program, 'past_curriculums': past_curriculums, 'working_curriculums': working_curriculums, 'curriculumfilter': curriculumfilter}) -@login_required(login_url='/accounts/login') def admin_view_all_working_curriculums(request): """ views all the working curriculums offered by the institute """ @@ -364,7 +362,6 @@ def admin_view_all_working_curriculums(request): return render(request,'programme_curriculum/acad_admin/admin_view_all_working_curriculums.html',{'curriculums':curriculums, 'curriculumfilter': curriculumfilter}) -@login_required(login_url='/accounts/login') def admin_view_semesters_of_a_curriculum(request, curriculum_id): """ gets all the semesters of a specfic curriculum """ @@ -410,7 +407,6 @@ def admin_view_semesters_of_a_curriculum(request, curriculum_id): return render(request, 'programme_curriculum/acad_admin/admin_view_semesters_of_a_curriculum.html', {'curriculum': curriculum, 'semesters': semesters, 'semester_slots': transpose_semester_slots, 'semester_credits': semester_credits, 'all_batches':all_batches}) -@login_required(login_url='/accounts/login') def admin_view_a_semester_of_a_curriculum(request, semester_id): """ This function is used to Display all Semester of a Curriculum. @@ -435,8 +431,6 @@ def admin_view_a_semester_of_a_curriculum(request, semester_id): return render(request, 'programme_curriculum/acad_admin/admin_view_a_semester_of_a_curriculum.html', {'semester': semester, 'course_slots': course_slots}) - -@login_required(login_url='/accounts/login') def admin_view_a_courseslot(request, courseslot_id): """ view a course slot """ @@ -455,7 +449,6 @@ def admin_view_a_courseslot(request, courseslot_id): return render(request, 'programme_curriculum/acad_admin/admin_view_a_courseslot.html', {'course_slot': course_slot}) -@login_required(login_url='/accounts/login') def admin_view_all_courses(request): """ views all the course slots of a specfic semester """ @@ -476,7 +469,6 @@ def admin_view_all_courses(request): return render(request, 'programme_curriculum/acad_admin/admin_view_all_courses.html', {'courses': courses, 'coursefilter': coursefilter}) -@login_required(login_url='/accounts/login') def admin_view_a_course(request, course_id): """ views the details of a Course """ @@ -491,7 +483,6 @@ def admin_view_a_course(request, course_id): return render(request, 'programme_curriculum/acad_admin/admin_view_a_course.html', {'course': course}) -@login_required(login_url='/accounts/login') def admin_view_all_discplines(request): """ views the details of a Course """ @@ -506,7 +497,6 @@ def admin_view_all_discplines(request): return render(request, 'programme_curriculum/acad_admin/admin_view_all_disciplines.html', {'disciplines': disciplines}) -@login_required(login_url='/accounts/login') def admin_view_all_batches(request): """ views the details of a Course """ @@ -531,7 +521,7 @@ def admin_view_all_batches(request): return render(request, 'programme_curriculum/acad_admin/admin_view_all_batches.html', {'batches': batches, 'finished_batches': finished_batches, 'batchfilter': batchfilter}) -@login_required(login_url='/accounts/login') + def add_discipline_form(request): user_details = ExtraInfo.objects.get(user = request.user) @@ -553,7 +543,6 @@ def add_discipline_form(request): return render(request, 'programme_curriculum/acad_admin/add_discipline_form.html',{'form':form}) -@login_required(login_url='/accounts/login') def edit_discipline_form(request, discipline_id): user_details = ExtraInfo.objects.get(user = request.user) @@ -576,7 +565,7 @@ def edit_discipline_form(request, discipline_id): return render(request, 'programme_curriculum/acad_admin/add_discipline_form.html',{'form':form}) -@login_required(login_url='/accounts/login') + def add_programme_form(request): user_details = ExtraInfo.objects.get(user = request.user) @@ -600,7 +589,7 @@ def add_programme_form(request): return render(request,'programme_curriculum/acad_admin/add_programme_form.html',{'form':form, 'submitbutton': submitbutton}) -@login_required(login_url='/accounts/login') + def edit_programme_form(request, programme_id): user_details = ExtraInfo.objects.get(user = request.user) @@ -623,7 +612,6 @@ def edit_programme_form(request, programme_id): return render(request, 'programme_curriculum/acad_admin/add_programme_form.html',{'form':form, 'submitbutton': submitbutton}) -@login_required(login_url='/accounts/login') def add_curriculum_form(request): """ This function is used to add Curriculum and Semester into Curriculum and Semester table. @@ -716,7 +704,6 @@ def edit_curriculum_form(request, curriculum_id): return render(request, 'programme_curriculum/acad_admin/add_curriculum_form.html',{'form':form, 'submitbutton': submitbutton}) -@login_required(login_url='/accounts/login') def add_course_form(request): user_details = ExtraInfo.objects.get(user = request.user) @@ -732,18 +719,18 @@ def add_course_form(request): if request.method == 'POST': form = CourseForm(request.POST) if form.is_valid(): - form.save() + new_course = form.save(commit=False) + new_course.version=1.0 + new_course.save() course = Course.objects.last() messages.success(request, "Added successful") return HttpResponseRedirect("/programme_curriculum/admin_course/" + str(course.id) + "/") - return render(request,'programme_curriculum/acad_admin/add_course_form.html',{'form':form}) + return render(request,'programme_curriculum/acad_admin/course_form.html',{'form':form,'submitbutton': submitbutton}) -@login_required(login_url='/accounts/login') def update_course_form(request, course_id): - #user_details = ExtraInfo.objects.get(user = request.user) des = HoldsDesignation.objects.all().filter(user = request.user).first() if request.session['currentDesignationSelected']== "student": # or request.session['currentDesignationSelected']== "Associate Professor" or request.session['currentDesignationSelected']== "Professor" or request.session['currentDesignationSelected']== "Assistant Professor" return HttpResponseRedirect('/programme_curriculum/programmes/') @@ -772,10 +759,9 @@ def update_course_form(request, course_id): else: version_error+=f'The version should be greater than {previous.version}' - return render(request,'programme_curriculum/acad_admin/update_course_form.html',{'course':course, 'form':form, 'submitbutton': submitbutton,'version_error':version_error}) + return render(request,'programme_curriculum/acad_admin/course_form.html',{'course':course, 'form':form, 'submitbutton': submitbutton,'version_error':version_error}) -@login_required(login_url='/accounts/login') def add_courseslot_form(request): user_details = ExtraInfo.objects.get(user = request.user) @@ -801,7 +787,6 @@ def add_courseslot_form(request): return render(request, 'programme_curriculum/acad_admin/add_courseslot_form.html',{'form':form, 'submitbutton': submitbutton, 'curriculum_id': curriculum_id}) -@login_required(login_url='/accounts/login') def edit_courseslot_form(request, courseslot_id): user_details = ExtraInfo.objects.get(user = request.user) @@ -847,7 +832,6 @@ def delete_courseslot(request, courseslot_id): return render(request, 'programme_curriculum/view_a_courseslot.html', {'course_slot': courseslot}) -@login_required(login_url='/accounts/login') def add_batch_form(request): user_details = ExtraInfo.objects.get(user = request.user) @@ -870,7 +854,6 @@ def add_batch_form(request): return render(request, 'programme_curriculum/acad_admin/add_batch_form.html',{'form':form, 'submitbutton': submitbutton}) -@login_required(login_url='/accounts/login') def edit_batch_form(request, batch_id): user_details = ExtraInfo.objects.get(user = request.user) @@ -897,7 +880,6 @@ def edit_batch_form(request, batch_id): return render(request,'programme_curriculum/acad_admin/add_batch_form.html',{'batch':batch, 'form':form, 'submitbutton':submitbutton}) -@login_required(login_url='/accounts/login') def instigate_semester(request, semester_id): """ This function is used to add the semester information. @@ -938,7 +920,6 @@ def instigate_semester(request, semester_id): return render(request,'programme_curriculum/acad_admin/instigate_semester_form.html',{'semester':semester, 'form':form, 'submitbutton':submitbutton, 'curriculum_id':curriculum_id}) -@login_required(login_url='/accounts/login') def replicate_curriculum(request, curriculum_id): """ This function is used to replicate the previous curriculum into a new curriculum. @@ -996,77 +977,22 @@ def replicate_curriculum(request, curriculum_id): return render(request, 'programme_curriculum/acad_admin/add_curriculum_form.html',{'form':form, 'submitbutton': submitbutton}) - - - - - - - - - - - - - - - #new @login_required(login_url='/accounts/login') -def course_proposal_form(request): +def view_course_proposal_forms(request): user_details = ExtraInfo.objects.get(user = request.user) - des = HoldsDesignation.objects.all().filter(user = request.user).first() - if request.session['currentDesignationSelected'] == "Associate Professor" or request.session['currentDesignationSelected'] == "Professor" or request.session['currentDesignationSelected'] == "Assistant Professor" : - pass - elif request.session['currentDesignationSelected'] == "acadadmin": - return HttpResponseRedirect('/programme_curriculum/admin_programmes') - faculty_id=user_details.user_id - details=User.objects.get(id=faculty_id) - faculty_name=details.first_name +' '+ details.last_name - + des = HoldsDesignation.objects.all().filter(user = request.user).last() + if request.session['currentDesignationSelected'] == "Associate Professor" or request.session['currentDesignationSelected'] == "Professor" or request.session['currentDesignationSelected'] == "Assistant Professor" : + pass + elif request.session['currentDesignationSelected'] == "acadadmin" or request.session['currentDesignationSelected'] == "student" : + return HttpResponseRedirect('/programme_curriculum/programmes/') - - form=Course_Proposal(initial={'faculty_name': faculty_name,'faculty_code':des.user}) - submitbutton= request.POST.get('Submit') - if submitbutton: - if request.method == 'POST': - form = Course_Proposal(request.POST) - if form.is_valid(): - new_course = form.save(commit=False) - new_course.status=0 - new_course.save() - messages.success(request, " Proposal Added successful") - return HttpResponseRedirect('/programme_curriculum/view_course_proposal_forms/') - - return render(request,'programme_curriculum/faculty/course_proposal_form.html',{'form':form,'submitbutton': submitbutton}) - - -# @login_required(login_url='/accounts/login') -# def update_course_proposal_form(request, course_id): - -# user_details = ExtraInfo.objects.get(user = request.user) -# des = HoldsDesignation.objects.all().filter(user = request.user).first() -# if request.session['currentDesignationSelected']== "student": -# return HttpResponseRedirect('/programme_curriculum/programmes/') -# elif str(request.user) == "acadadmin" : -# return HttpResponseRedirect('/programme_curriculum/admin_programmes') -# elif request.session['currentDesignationSelected']== "Associate Professor" or request.session['currentDesignationSelected']== "Professor" or request.session['currentDesignationSelected']== "Assistant Professor": -# pass + courseProposal = NewProposalFile.objects.filter(uploader=des.user,designation=request.session['currentDesignationSelected'],is_update=False) + updatecourseProposal = NewProposalFile.objects.filter(uploader=des.user,designation=request.session['currentDesignationSelected'],is_update=True) -# course = get_object_or_404(Course, Q(id=course_id)) -# form = Update_Course_Proposal(instance=course) -# submitbutton= request.POST.get('Submit') -# if submitbutton: -# if request.method == 'POST': -# form = Update_Course_Proposal(request.POST, instance=course) -# if form.is_valid(): -# form.save() -# messages.success(request, "Updated "+ course.name +" successful") -# return HttpResponseRedirect("/programme_curriculum//programme_curriculum/course_proposal_form//") - - # return render(request,'programme_curriculum/faculty/update_course_proposal_form.html',{'form':form,'submitbutton': submitbutton}) + return render(request, 'programme_curriculum/faculty/view_course_proposal_forms.html',{'courseProposals': courseProposal,'updateProposals':updatecourseProposal}) @login_required(login_url='/accounts/login') def faculty_view_all_courses(request): @@ -1081,10 +1007,6 @@ def faculty_view_all_courses(request): elif request.session['currentDesignationSelected'] == "Associate Professor" or request.session['currentDesignationSelected'] == "Professor" or request.session['currentDesignationSelected'] == "Assistant Professor": pass - # discipline=user_details.department - # courses = Course.objects.filter(disciplines=discipline) - - courses = Course.objects.all() coursefilter = CourseFilter(request.GET, queryset=courses) @@ -1094,7 +1016,6 @@ def faculty_view_all_courses(request): return render(request, 'programme_curriculum/faculty/faculty_view_all_courses.html', {'courses': courses, 'coursefilter': coursefilter}) -@login_required(login_url='/accounts/login') def faculty_view_a_course(request, course_id): """ views the details of a Course """ @@ -1110,203 +1031,110 @@ def faculty_view_a_course(request, course_id): return render(request, 'programme_curriculum/faculty/faculty_view_a_course.html', {'course': course}) +def view_a_course_proposal_form(request,CourseProposal_id): + user_details = ExtraInfo.objects.get(user = request.user) + des = HoldsDesignation.objects.all().filter(user = request.user).first() + if request.session['currentDesignationSelected'] == "Associate Professor" or request.session['currentDesignationSelected'] == "Professor" or request.session['currentDesignationSelected'] == "Assistant Professor": + pass + elif request.session['currentDesignationSelected'] == "acadadmin" : + return HttpResponseRedirect('/programme_curriculum/admin_programmes') + else: + return HttpResponseRedirect('/programme_curriculum/programmes') + user_details = ExtraInfo.objects.get(user = request.user) + des = HoldsDesignation.objects.all().filter(user = request.user).first() + proposalform = get_object_or_404(NewProposalFile, Q(id=CourseProposal_id)) + return render(request, 'programme_curriculum/faculty/view_a_course_proposal.html', {'proposal': proposalform}) -# ##new -# @login_required(login_url='/accounts/login') -# def head_view_a_course(request, proposal_id): -# """ views the details of a Course """ - -# user_details = ExtraInfo.objects.get(user = request.user) -# des = HoldsDesignation.objects.all().filter(user = request.user).last() -# if request.session['currentDesignationSelected']== "CSE HOD" : -# pass -# elif str(request.user) == "acadadmin" : -# return HttpResponseRedirect('/programme_curriculum/admin_programmes') -# elif request.session['currentDesignationSelected']== "Associate Professor" or request.session['currentDesignationSelected']== "Professor" or request.session['currentDesignationSelected']== "Assistant Professor" or str(des.designation)=="student" : -# return HttpResponseRedirect('/programme_curriculum/programmes') -# proposal = get_object_or_404(CourseProposal, Q(id=proposal_id)) -# return render(request, 'programme_curriculum/hod/head_view_a_course.html', {'proposal': proposal}) -def head_view_a_course_proposal(request,CourseProposal_id): - user_details = ExtraInfo.objects.get(user = request.user) +def new_course_proposal_file(request): des = HoldsDesignation.objects.all().filter(user = request.user).first() + # if request.session['currentDesignationSelected'] == "Associate Professor" or request.session['currentDesignationSelected'] == "Professor" or request.session['currentDesignationSelected'] == "Assistant Professor": + # pass + # elif request.session['currentDesignationSelected'] == "acadadmin" : + # return HttpResponseRedirect('/programme_curriculum/admin_programmes') + # else: + # return HttpResponseRedirect('/programme_curriculum/programmes') + + uploader = request.user.extrainfo + design=request.session['currentDesignationSelected'] + form=NewCourseProposalFile(initial={'uploader':des.user,'designation':design}) + + submitbutton= request.POST.get('Submit') + + if submitbutton: + if request.method == 'POST': + form = NewCourseProposalFile(request.POST) + if form.is_valid(): + new_course=form.save(commit=False) + new_course.is_read=False + new_course.save() + messages.success(request, "Added successful") - if request.session['currentDesignationSelected'] == "CSE HOD" : - pass - proposalform = get_object_or_404(CourseProposal, Q(id=CourseProposal_id)) + return HttpResponseRedirect('/programme_curriculum/view_course_proposal_forms/') - if (request.session['currentDesignationSelected'] == "Dean Academic"): - proposalform = get_object_or_404(CourseProposal, Q(id=CourseProposal_id)) - form = CourseProposalForm(instance=proposalform,initial={'version':1.0}) - submitbutton= request.POST.get('Submit') - if submitbutton: - if request.method == 'POST': - form = CourseProposalForm(request.POST) - if form.is_valid(): - proposalform.status = 3 - proposalform.save() - form.save() - course = get_object_or_404(Course, Q(code=proposalform.code)) - messages.success(request, "Updated "+ proposalform.name +" successful") - return HttpResponseRedirect("/programme_curriculum/course/" + str(course.id) + "/") - return render(request, 'programme_curriculum/faculty/dean_view_a_course_proposal.html', {'course': proposalform ,'form':form,'submitbutton': submitbutton}) - return render(request, 'programme_curriculum/faculty/head_view_a_course_proposal.html', {'proposal': proposalform}) + return render(request,'programme_curriculum/faculty/course_proposal_form.html',{'form':form,'submitbutton': submitbutton}) + + + +def filetracking(request,proposal_id): -def head_view_a_update_course_proposal(request,UpdateCourseProposal_id): - user_details = ExtraInfo.objects.get(user = request.user) des = HoldsDesignation.objects.all().filter(user = request.user).first() + # if request.session['currentDesignationSelected'] == "Associate Professor" or request.session['currentDesignationSelected'] == "Professor" or request.session['currentDesignationSelected'] == "Assistant Professor" : + # pass + # elif request.session['currentDesignationSelected'] == "acadadmin": + # return HttpResponseRedirect('/programme_curriculum/admin_programmes') + + uploader = request.user.extrainfo + design=request.session['currentDesignationSelected'] + file = get_object_or_404(NewProposalFile, Q(id=proposal_id)) + file_data=file.name+' '+file.code + form=CourseProposalTrackingFile(initial={'current_id':file.uploader,'current_design':file.designation,'file_id':int(proposal_id)}) + + submitbutton= request.POST.get('Submit') + + if submitbutton: + if request.method == 'POST': + form = CourseProposalTrackingFile(request.POST) + if form.is_valid(): + form.is_read=False + form.save() + messages.success(request, "Added successful") + return HttpResponseRedirect('/programme_curriculum/view_course_proposal_forms/') - if request.session['currentDesignationSelected'] == "CSE HOD" : - pass - proposalform = get_object_or_404(UpdateCourseProposal, Q(id=UpdateCourseProposal_id)) - if(request.session['currentDesignationSelected'] == "Dean Academic"): - - # course = get_object_or_404(Course, Q(code=proposalform.code)) - course =Course.objects.all().filter(code=proposalform.code).order_by('version').last() - previous = Course.objects.all().filter(code=course.code).order_by('version').last() - course.version=previous.version - version_error='' - form = CourseProposalForm(instance=proposalform,initial={'version':course.version}) - submitbutton= request.POST.get('Submit') - if submitbutton: - if request.method == 'POST': - form = CourseForm(request.POST) - if form.is_valid() : - previous.latest_version=False - previous.save() - form.latest_version=True - new_course = form.save(commit=False) - if(new_course.version>previous.version): - proposalform.status = 3 - proposalform.save() - form.save() - course = Course.objects.last() - messages.success(request, "Added successful") - return HttpResponseRedirect("/programme_curriculum/course/"+ str(course.id) + "/") - else: - version_error+=f'The version should be greater than {previous.version}' - return render(request, 'programme_curriculum/faculty/dean_view_update_a_course_proposal.html', {'course': proposalform ,'form':form,'submitbutton': submitbutton,'version_error':version_error}) - return render(request, 'programme_curriculum/faculty/head_view_update_a_course_proposal.html', {'proposal': proposalform}) - - #return render(request,'programme_curriculum/acad_admin/update_course_form.html',{'course':course, 'form':form, 'submitbutton': submitbutton,'version_error':version_error}) + return render(request,'programme_curriculum/faculty/filetracking.html',{'form':form,'submitbutton': submitbutton,'file_info':file_data}) - - - # submitbutton= request.POST.get('Submit') - # if submitbutton: - # if request.method == 'POST': - # form = CourseProposalForm(request.POST,instance=course) - # if form.is_valid(): - # proposalform.status = 3 - # proposalform.save() - # form.save() - # messages.success(request, "Updated "+ proposalform.name +" successful") - # return HttpResponseRedirect("/programme_curriculum/course/"+ str(course.id) + "/") - # return render(request, 'programme_curriculum/faculty/dean_view_update_a_course_proposal.html', {'course': proposalform ,'form':form,'submitbutton': submitbutton}) - # return render(request, 'programme_curriculum/faculty/head_view_update_a_course_proposal.html', {'proposal': proposalform}) - -def forward_form(request,CourseProposal_id): - proposalform = get_object_or_404(CourseProposal, Q(id=CourseProposal_id)) - proposalform.status =1 - proposalform.save() - courses = CourseProposal.objects.all() - Updatecourses = UpdateCourseProposal.objects.all() - return render(request, 'programme_curriculum/faculty/head_view_course_proposal_forms.html',{'courseProposals': courses,'updateProposals': Updatecourses}) - -def forward_update_form(request,UpdateCourseProposal_id): - proposalform = get_object_or_404(UpdateCourseProposal, Q(id=UpdateCourseProposal_id)) - proposalform.status =1 - proposalform.save() - Updatecourses = UpdateCourseProposal.objects.all() - courses = CourseProposal.objects.all() - # return HttpResponseRedirect('/programme_curriculum/head_view_a_update_course_proposal/'), - return render(request, 'programme_curriculum/faculty/head_view_course_proposal_forms.html',{'courseProposals': courses,'updateProposals': Updatecourses}) -@login_required(login_url='/accounts/login') -def reject_form(request,CourseProposal_id): +def inward_files(request): user_details = ExtraInfo.objects.get(user = request.user) des = HoldsDesignation.objects.all().filter(user = request.user).last() - if request.session['currentDesignationSelected'] == "CSE HOD" or request.session['currentDesignationSelected'] == "Dean Academic": + if request.session['currentDesignationSelected'] == "Associate Professor" or request.session['currentDesignationSelected'] == "Professor" or request.session['currentDesignationSelected'] == "Assistant Professor" : pass - elif request.session['currentDesignationSelected'] == "acadadmin" or request.session['currentDesignationSelected'] == "student" : + elif request.session['currentDesignationSelected'] == "acadadmin" or request.session['currentDesignationSelected'] == "student" : return HttpResponseRedirect('/programme_curriculum/programmes/') - proposalform = get_object_or_404(CourseProposal, Q(id=CourseProposal_id)) - proposalform.status = 2 - proposalform.save() - courses = CourseProposal.objects.all() - Updatecourses = UpdateCourseProposal.objects.all() - - if request.session['currentDesignationSelected'] == "CSE HOD": - proposalform = get_object_or_404(CourseProposal, Q(id=CourseProposal_id)) - proposalform.status = 2 - proposalform.save() - courses = CourseProposal.objects.all() - return render(request, 'programme_curriculum/faculty/head_view_course_proposal_forms.html',{'courseProposals': courses,'updateProposals': Updatecourses}) - if request.session['currentDesignationSelected'] == "Dean Academic" : - proposalform = get_object_or_404(CourseProposal, Q(id=CourseProposal_id)) - proposalform.status = 4 - proposalform.save() - courses = CourseProposal.objects.all() - Updatecourses = UpdateCourseProposal.objects.all() - - return render(request, 'programme_curriculum/faculty/dean_view_course_proposal_forms.html',{'courseProposals': courses,'updateProposals': Updatecourses}) + id=request.user + user_designation=HoldsDesignation.objects.select_related('user','working','designation').filter(user=request.user) + print(user_designation) -def reject_update_form(request,UpdateCourseProposal_id): - user_details = ExtraInfo.objects.get(user = request.user) - des = HoldsDesignation.objects.all().filter(user = request.user).last() + designation = Designation.objects.get(name=request.session['currentDesignationSelected']) + des_id = designation.id + print(des_id) - if request.session['currentDesignationSelected'] == "CSE HOD" or request.session['currentDesignationSelected'] == "Dean Academic": - pass - elif request.session['currentDesignationSelected'] == "acadadmin" or request.session['currentDesignationSelected'] == "student" : - return HttpResponseRedirect('/programme_curriculum/programmes/') + courseProposal = Proposal_Tracking.objects.filter(receive_design = des_id,receive_id= id) + print(courseProposal) + - proposalform = get_object_or_404(UpdateCourseProposal, Q(id=UpdateCourseProposal_id)) - proposalform.status = 2 - proposalform.save() - courses = UpdateCourseProposal.objects.all() - if request.session['currentDesignationSelected']== "CSE HOD": - proposalform = get_object_or_404(UpdateCourseProposal, Q(id=UpdateCourseProposal_id)) - proposalform.status = 2 - proposalform.save() - Updatecourses = UpdateCourseProposal.objects.all() - courses=CourseProposal.objects.all() - return render(request, 'programme_curriculum/faculty/head_view_course_proposal_forms.html',{'courseProposals': courses,'updateProposals': Updatecourses}) - if request.session['currentDesignationSelected']== "Dean Academic" : - proposalform = get_object_or_404(UpdateCourseProposal, Q(id=UpdateCourseProposal_id)) - proposalform.status = 4 - proposalform.save() - courses = CourseProposal.objects.all() - Updatecourses = UpdateCourseProposal.objects.all() - return render(request, 'programme_curriculum/faculty/dean_view_course_proposal_forms.html',{'courseProposals': courses,'updateProposals': Updatecourses}) - - -# def approve_form(request,CourseProposal_id): -# proposalform = get_object_or_404(CourseProposal, Q(id=CourseProposal_id)) -# proposalform.status = 3 -# proposalform.save() -# courses = CourseProposal.objects.all() -# Updatecourses = UpdateCourseProposal.objects.all() - -# return render(request, 'programme_curriculum/faculty/dean_view_course_proposal_forms.html',{'courseProposals': courses,'updateProposals': Updatecourses}) -# def approve_update_form(request,UpdateCourseProposal_id): -# proposalform = get_object_or_404(UpdateCourseProposal, Q(id=UpdateCourseProposal_id)) -# proposalform.status = 3 -# proposalform.save() -# courses = CourseProposal.objects.all() -# Updatecourses = UpdateCourseProposal.objects.all() - -# return render(request, 'programme_curriculum/faculty/dean_view_course_proposal_forms.html',{'courseProposals': courses,'updateProposals': Updatecourses}) + return render(request, 'programme_curriculum/faculty/inward_course_forms.html',{'courseProposals': courseProposal}) -@login_required(login_url='/accounts/login') -def view_course_proposal_forms(request): + +def outward_files(request): user_details = ExtraInfo.objects.get(user = request.user) des = HoldsDesignation.objects.all().filter(user = request.user).last() @@ -1315,49 +1143,167 @@ def view_course_proposal_forms(request): elif request.session['currentDesignationSelected'] == "acadadmin" or request.session['currentDesignationSelected'] == "student" : return HttpResponseRedirect('/programme_curriculum/programmes/') - courseProposal = CourseProposal.objects.filter(faculty_code=des.user) - coursefilter = CourseFilter(request.GET, queryset=courseProposal) + id=request.user + user_designation=HoldsDesignation.objects.select_related('user','working','designation').filter(user=request.user) + print(user_designation) + design=request.session['currentDesignationSelected'] - courses = CourseProposal.objects.all() - updatecourses=UpdateCourseProposal.objects.all() - updatecourseProposal = UpdateCourseProposal.objects.filter(faculty_code=des.user) + designation = Designation.objects.get(name=request.session['currentDesignationSelected']) + des_id = designation.id + print(des_id) - if(request.session['currentDesignationSelected'] == "CSE HOD"): - return render(request, 'programme_curriculum/faculty/head_view_course_proposal_forms.html',{'courseProposals': courses,'updateProposals':updatecourses}) - elif(request.session['currentDesignationSelected'] == "Dean Academic"): - return render(request, 'programme_curriculum/faculty/dean_view_course_proposal_forms.html',{'courseProposals': courses,'updateProposals':updatecourses}) - return render(request, 'programme_curriculum/faculty/view_course_proposal_forms.html',{'courseProposals': courseProposal,'updateProposals':updatecourseProposal}) - - - + courseProposal = Proposal_Tracking.objects.filter(current_design = design,current_id= des.user) + print(courseProposal) + + return render(request, 'programme_curriculum/faculty/outward_course_forms.html',{'courseProposals': courseProposal}) -@login_required(login_url='/accounts/login') -def update_course_proposal_form(request, course_id): - user_details = ExtraInfo.objects.get(user = request.user) +def update_course_proposal_file(request,course_id): des = HoldsDesignation.objects.all().filter(user = request.user).first() - if request.session['currentDesignationSelected'] == "student": - return HttpResponseRedirect('/programme_curriculum/programmes/') - elif request.session['currentDesignationSelected'] == "acadadmin" : - return HttpResponseRedirect('/programme_curriculum/admin_programmes/') - elif request.session['currentDesignationSelected'] == "Associate Professor" or request.session['currentDesignationSelected'] == "Professor" or request.session['currentDesignationSelected'] == "Assistant Professor" : + if request.session['currentDesignationSelected'] == "Associate Professor" or request.session['currentDesignationSelected'] == "Professor" or request.session['currentDesignationSelected'] == "Assistant Professor": pass + elif request.session['currentDesignationSelected'] == "acadadmin" : + return HttpResponseRedirect('/programme_curriculum/admin_programmes') + else: + return HttpResponseRedirect('/programme_curriculum/programmes') - faculty_id=user_details.user_id - details=User.objects.get(id=faculty_id) - faculty_name=details.first_name +' '+ details.last_name - faculty_details=Update_Course_Proposal(initial={'faculty_name': faculty_name,'faculty_code':des.user}) + uploader = request.user.extrainfo + design=request.session['currentDesignationSelected'] course = get_object_or_404(Course, Q(id=course_id)) - form = Update_Course_Proposal(instance=course) - + file_data=course.code+' - '+course.name + form = NewCourseProposalFile(initial={'uploader':des.user,'designation':design},instance=course) submitbutton= request.POST.get('Submit') + if submitbutton: if request.method == 'POST': - form = Update_Course_Proposal(request.POST) + form = NewCourseProposalFile(request.POST) if form.is_valid(): - form.save() - messages.success(request, "Updated "+ course.name +" successful") + new_course=form.save(commit=False) + new_course.is_read=False + new_course.is_update=True + new_course.save() + messages.success(request, "Added successful") return HttpResponseRedirect('/programme_curriculum/view_course_proposal_forms/') - return render(request,'programme_curriculum/faculty/update_course_proposal_form.html',{'faculty_details':faculty_details,'form':form, 'submitbutton': submitbutton}) \ No newline at end of file + + + return render(request,'programme_curriculum/faculty/course_proposal_form.html',{'form':form,'submitbutton': submitbutton,'file_info':file_data}) + + + + +def forward_course_forms(request,ProposalId): + de= ProposalId + des = HoldsDesignation.objects.all().filter(user = request.user).first() + + courseform = Proposal_Tracking.objects.all().filter(id=ProposalId) + + uploader = request.user.extrainfo + design=request.session['currentDesignationSelected'] + file = get_object_or_404(Proposal_Tracking, Q(id=ProposalId)) + file_id = int(file.file_id) + file2 = get_object_or_404(NewProposalFile, Q(id=file_id)) + Proposal_D = file.id + + if request.session['currentDesignationSelected'] == "Dean Academic" : + file = get_object_or_404(Proposal_Tracking, Q(id=ProposalId)) + file_id = int(file.file_id) + file2 = get_object_or_404(NewProposalFile, Q(id=file_id)) + + if(file2.is_update==True): + course =Course.objects.all().filter(code=file2.code).last() + previous = Course.objects.all().filter(code=course.code).order_by('version').last() + course.version=previous.version + version_error='' + + form = CourseForm(instance=course) + submitbutton= request.POST.get('Submit') + if submitbutton: + if request.method == 'POST': + form = CourseForm(request.POST) + if form.is_valid() : + previous.latest_version=False + previous.save() + file.is_added=True + file.is_submitted=True + file.save() + form.latest_version=True + new_course = form.save(commit=False) + if(new_course.version>previous.version): + form.save() + course = Course.objects.last() + messages.success(request, "Added successful") + return HttpResponseRedirect("/programme_curriculum/course/" + str(course.id) + "/") + else: + version_error+=f'The version should be greater than {previous.version}' + + return render(request,'programme_curriculum/faculty/dean_view_a_course_proposal.html',{'course':course, 'form':form, 'submitbutton': submitbutton,'version_error':version_error,'id':Proposal_D}) + else: + form = CourseForm(instance=file2,initial={'disciplines':file.disciplines}) + # course1 =Course.objects.filter(code=file2.code,name=file2.name,credit=file2.credit,lecture_hours=file2.lecture_hours,tutorial_hours=file2.tutorial_hours,pratical_hours=file2.pratical_hours,discussion_hours=file2.discussion_hours,project_hours=file2.project_hours,pre_requisits=file2.pre_requisits,syllabus=file2.syllabus,percent_quiz_1=file2.percent_quiz_1,percent_midsem=file2.percent_midsem,percent_quiz_2=file2.percent_quiz_2,percent_project=file2.percent_project,percent_endsem=file2.percent_endsem,percent_lab_evaluation=file2.percent_lab_evaluation,percent_course_attendance=file2.percent_course_attendance,ref_books=file2.ref_books) + submitbutton= request.POST.get('Submit') + + if submitbutton: + if request.method == 'POST': + form = CourseForm(request.POST) + if form.is_valid(): + file.is_added=True + file.is_submitted=True + file.save() + form.save() + course =Course.objects.all().filter(code=file2.code).last() + messages.success(request, "Updated "+ file2.name +" successful") + return HttpResponseRedirect("/programme_curriculum/course/" + str(course.id) + "/") + return render(request, 'programme_curriculum/faculty/dean_view_a_course_proposal.html', {'course': file2 ,'form':form,'submitbutton': submitbutton,'id':Proposal_D}) + + else: + + form=CourseProposalTrackingFile(initial={'current_id':des.user,'current_design':request.session['currentDesignationSelected'],'file_id':file.file_id,'disciplines':file.disciplines}) + + submitbutton= request.POST.get('Submit') + + if submitbutton: + if request.method == 'POST': + form = CourseProposalTrackingFile(request.POST) + if form.is_valid(): + file.is_submitted=True + file.save() + form.is_read=False + form.save() + messages.success(request, "Added successful") + return HttpResponseRedirect('/programme_curriculum/view_course_proposal_forms/') + + return render(request,'programme_curriculum/faculty/forward.html',{'form':form,'receive_date':file.receive_date,'proposal':file2,'submitbutton': submitbutton,'id':Proposal_D}) + + +def view_inward_files(request,ProposalId): + des = HoldsDesignation.objects.all().filter(user = request.user).first() + + uploader = request.user.extrainfo + design=request.session['currentDesignationSelected'] + file = get_object_or_404(Proposal_Tracking, Q(id=ProposalId)) + file_id = int(file.file_id) + file2 = get_object_or_404(NewProposalFile, Q(id=file_id)) + file_data='' + file_data2='' + + if(file.is_rejected): + file_data='"'+str(file2.name) + '"'+' Course Rejected by ' + str(file.receive_id) + ' - ' +str(file.receive_design) + if(file.is_added): + file_data2='"'+str(file2.code)+' - '+str(file2.name) +'" Course Added Succesfully' + + courseProposal = Proposal_Tracking.objects.filter(file_id=file.file_id,disciplines=file.disciplines) + print(courseProposal) + form=CourseProposalTrackingFile(initial={'current_id':des.user,'current_design':request.session['currentDesignationSelected'],'file_id':file.file_id,'disciplines':file.disciplines}) + + return render(request,'programme_curriculum/faculty/view_file.html',{'form':form,'receive_date':file.receive_date,'proposal':file2,'trackings':courseProposal,'file_info':file_data,'file_sucess':file_data2}) + +def reject_form(request,ProposalId): + track=get_object_or_404(Proposal_Tracking, Q(id=ProposalId)) + track.is_rejected=True + track.is_submitted=True + track.save() + messages.success(request, "Course Proposal Form Rejected") + return HttpResponseRedirect('/programme_curriculum/inward_files/') + \ No newline at end of file diff --git a/FusionIIIT/applications/scholarships/helpers.py b/FusionIIIT/applications/scholarships/helpers.py new file mode 100644 index 000000000..489f340a4 --- /dev/null +++ b/FusionIIIT/applications/scholarships/helpers.py @@ -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 \ No newline at end of file diff --git a/FusionIIIT/applications/scholarships/urls.py b/FusionIIIT/applications/scholarships/urls.py index fd5a3516f..77a292977 100755 --- a/FusionIIIT/applications/scholarships/urls.py +++ b/FusionIIIT/applications/scholarships/urls.py @@ -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'), ] diff --git a/FusionIIIT/applications/scholarships/views.py b/FusionIIIT/applications/scholarships/views.py index 5f547149f..0d95daa96 100755 --- a/FusionIIIT/applications/scholarships/views.py +++ b/FusionIIIT/applications/scholarships/views.py @@ -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 @@ -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') @@ -70,6 +75,8 @@ 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( @@ -77,8 +84,11 @@ 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') @@ -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 @@ -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: @@ -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) @@ -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) @@ -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() @@ -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 @@ -1012,7 +1063,6 @@ 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) @@ -1020,6 +1070,7 @@ def sendConvenerRenderRequest(request, additionalParams={}): def sendStudentRenderRequest(request, additionalParams={}): context = getCommonParams(request) + ch = Constants.BATCH time = Constants.TIME mother_occ = Constants.MOTHER_OCC_CHOICES @@ -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() @@ -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) diff --git a/FusionIIIT/applications/visitor_hostel/forms.py b/FusionIIIT/applications/visitor_hostel/forms.py index 32b915407..c506bc932 100644 --- a/FusionIIIT/applications/visitor_hostel/forms.py +++ b/FusionIIIT/applications/visitor_hostel/forms.py @@ -5,41 +5,37 @@ from applications.visitor_hostel.models import * -from .models import Inventory - #class booking_request(forms.Form): CHOICES = (('A', 'A',), ('B', 'B',), ('C', 'C',), ('D', 'D',)) class ViewBooking(forms.Form): - date_from = forms.DateField(initial=datetime.date.today) - date_to = forms.DateField(initial=datetime.date.today) + date_from = forms.DateField(initial=datetime.date.today) + date_to = forms.DateField(initial=datetime.date.today) -class MealBooking(ModelForm): - date = forms.DateField(initial=datetime.date.today) - class Meta: - model = MealRecord - exclude = ['meal_date'] class RoomAvailability(forms.Form): - date_from = forms.DateField(initial=datetime.date.today) - date_to = forms.DateField(initial=datetime.date.today) + date_from = forms.DateField(initial=datetime.date.today) + date_to = forms.DateField(initial=datetime.date.today) -class InventoryForm(forms.ModelForm): - class Meta: - model = Inventory - fields = ["item_name", "quantity", "consumable"] +# class InventoryForm(forms.Form): +# # class Meta: +# # model = Inventory +# # fields = ["item_name", "quantity"] +# item_name = forms.CharField(max_length=20) +# quantity = forms.IntegerField(min_value=0) +# consumable = forms.BooleanField(initial=False) +# # checkbox = ["consumable"] class Room_booking(forms.Form): - name = forms.CharField(max_length=100) - mob = forms.CharField(max_length=12) - email = forms.CharField(max_length=40) - address = forms.CharField(max_length=200) - country = forms.CharField(max_length=25) - category = forms.ChoiceField(widget=forms.RadioSelect, choices=CHOICES) - total_persons = forms.IntegerField() - purpose = forms.CharField(widget=forms.Textarea) - date_from = forms.DateField(initial=datetime.date.today) - date_to = forms.DateField(initial=datetime.date.today) - \ No newline at end of file + name = forms.CharField(max_length=100) + mob = forms.CharField(max_length=12) + email = forms.CharField(max_length=40) + address = forms.CharField(max_length=200) + country = forms.CharField(max_length=25) + category = forms.ChoiceField(widget=forms.RadioSelect, choices=CHOICES) + total_persons = forms.IntegerField() + purpose = forms.CharField(widget=forms.Textarea) + date_from = forms.DateField(initial=datetime.date.today) + date_to = forms.DateField(initial=datetime.date.today) diff --git a/FusionIIIT/applications/visitor_hostel/models.py b/FusionIIIT/applications/visitor_hostel/models.py index 508b2fa63..ffd49a1be 100644 --- a/FusionIIIT/applications/visitor_hostel/models.py +++ b/FusionIIIT/applications/visitor_hostel/models.py @@ -58,7 +58,6 @@ class VisitorDetail(models.Model): visitor_address = models.TextField(blank=True) nationality = models.CharField(max_length=20, blank=True) - def __str__(self): return '{} - {}'.format(self.id, self.visitor_name, self.visitor_email, self.visitor_organization, self.visitor_address, self.visitor_phone) @@ -71,7 +70,7 @@ class RoomDetail(models.Model): room_status = models.CharField(max_length=20, choices=ROOM_STATUS, default='Available') def __str__(self): - return self.room_number + return '{} - {}'.format(self.id, self.room_number , self.room_type, self.room_status, self.room_floor) class BookingDetail(models.Model): @@ -100,7 +99,7 @@ class BookingDetail(models.Model): number_of_rooms_alloted = models.IntegerField(default=1,null=True,blank=True) booking_date = models.DateField(auto_now_add=False, auto_now=False, default=timezone.now) bill_to_be_settled_by = models.CharField(max_length=15, choices=BILL_TO_BE_SETTLED_BY ,default ="Intender") - + def __str__(self): return '%s ----> %s - %s id is %s and category is %s' % (self.id, self.visitor, self.status, self.id, self.visitor_category) @@ -108,13 +107,12 @@ def __str__(self): class MealRecord(models.Model): booking = models.ForeignKey(BookingDetail, on_delete=models.CASCADE) visitor = models.ForeignKey(VisitorDetail, on_delete=models.CASCADE) - room = models.ForeignKey(RoomDetail, on_delete=models.CASCADE, default=0) meal_date = models.DateField() - morning_tea = models.BooleanField(default=False) - eve_tea = models.BooleanField(default=False) - breakfast = models.BooleanField(default=False) - lunch = models.BooleanField(default=False) - dinner = models.BooleanField(default=False) + morning_tea = models.IntegerField(default=0) + eve_tea = models.IntegerField(default=0) + breakfast = models.IntegerField(default=0) + lunch = models.IntegerField(default=0) + dinner = models.IntegerField(default=0) persons=models.IntegerField(default=0) @@ -125,6 +123,7 @@ class Bill(models.Model): meal_bill = models.IntegerField(default=0) room_bill = models.IntegerField(default=0) payment_status = models.BooleanField(default=False) + bill_date = models.DateField(default=timezone.now, blank=True) def __str__(self): return '%s ----> %s - %s id is %s' % (self.booking.id, self.meal_bill, self.room_bill, self.payment_status) @@ -154,5 +153,3 @@ class InventoryBill(models.Model): def __str__(self): return str(self.bill_number) - - diff --git a/FusionIIIT/applications/visitor_hostel/static/visitor_hostel/visitor-hostel.js b/FusionIIIT/applications/visitor_hostel/static/visitor_hostel/visitor-hostel.js index 3ecb7a431..5338efcbc 100644 --- a/FusionIIIT/applications/visitor_hostel/static/visitor_hostel/visitor-hostel.js +++ b/FusionIIIT/applications/visitor_hostel/static/visitor_hostel/visitor-hostel.js @@ -294,31 +294,41 @@ function request_booking (event) { // Meal Record -$('.bookameal-submit').click(function(event){ +function bookameal_submit(event, htmlElement){ + console.log('hii') event.preventDefault(); - var pk = $(this).attr('data-pk'); - var food = [] - $('input[name=food'+pk+']:checked').each(function(){ - food.push($(this).val()); - }); + var pk = $(htmlElement).attr('data-pk'); + var booking_id = $(htmlElement).attr('booking_id') + // 'numberofpeople': $('input[name="numberofpeople-meal"]').val(), + console.log(pk); + var jsondata = { + 'pk' : pk, + 'booking' : booking_id, + 'm_tea': $(`input[name="m_tea${booking_id}"]`).val(), + 'breakfast': $(`input[name="breakfast${booking_id}"]`).val(), + 'lunch': $(`input[name="lunch${booking_id}"]`).val(), + 'eve_tea': $(`input[name="eve_tea${booking_id}"]`).val(), + 'dinner': $(`input[name="dinner${booking_id}"]`).val(), + + 'csrfmiddlewaretoken': $('input[name="csrf"]').val(), + } + console.log(jsondata) $.ajax({ type: 'POST', url: '/visitorhostel/record-meal/', - data: { - 'pk' : pk, - 'booking' : $('input[name="meal-booking-id"]').val(), - 'numberofpeople': $('input[name="numberofpeople-meal"]').val(), - 'food':food, - 'csrfmiddlewaretoken': $('input[name="csrf"]').val(), - }, + data: jsondata, success: function(data) { alertModal('Great! Meals recorded successfully'); + setTimeout(function() { + location.reload(); + }, 1500); + }, - error: function(data, err) { - alertModal('Something missing! Please refill the form'); + error: function (data, err) { + alertModal('Something missing! Please refill the form '); } }); -}); +}; // Update Inventory @@ -356,49 +366,75 @@ function submit_inventory_form(id){ // Adding more items to inventory -$('#add-more-items-inventory').click(function(event){ +// $('#add-more-items-inventory').click(function(event){ +// $.ajax({ +// type: 'POST', +// url: '/visitorhostel/add-to-inventory/', +// data: { +// 'item' : $('.reset-this-form')[0].children[2].children[0].children[1].children[0].value, +// 'quantity' : $('.reset-this-form')[0].children[2].children[1].children[1].children[0].value, +// 'amount' : $('.reset-this-form')[0].children[2].children[2].children[1].children[0].value, +// 'consumable' : $('.reset-this-form')[0].children[2].children[3].children[1].children[0].value, +// 'csrfmiddlewaretoken': '{{csrf_token}}' +// }, +// success: function(data) { +// $('.reset-this-form')[0].children[2].children[0].children[1].children[0].value = ""; +// $('.reset-this-form')[0].children[2].children[1].children[1].children[0].value = ""; +// $('.reset-this-form')[0].children[2].children[2].children[1].children[0].value = ""; +// }, +// error: function(data, err) { +// alertModal('Something missing! Please refill the form'); +// } +// }); + +// }); + +function add_inventory_item(event) { + event.preventDefault(); + jsondata = { + 'csrfmiddlewaretoken': $('input[name="csrf"]').val(), + 'item_name' : $('input[name="item_name"]').val(), + 'quantity' : $('input[name="quantity_add"]').val(), + 'cost' : $('input[name="cost"]').val(), + 'consumable': ($('input[name="consumable"]:checked').val())?true:false, + 'bill_number' : $('input[name="bill_number"]').val() + } + console.log(jsondata) $.ajax({ type: 'POST', url: '/visitorhostel/add-to-inventory/', - data: { - 'item' : $('.reset-this-form')[0].children[2].children[0].children[1].children[0].value, - 'quantity' : $('.reset-this-form')[0].children[2].children[1].children[1].children[0].value, - 'amount' : $('.reset-this-form')[0].children[2].children[2].children[1].children[0].value, - 'consumable' : $('.reset-this-form')[0].children[2].children[3].children[1].children[0].value, - 'csrfmiddlewaretoken': '{{csrf_token}}' - }, + data: jsondata, success: function(data) { - $('.reset-this-form')[0].children[2].children[0].children[1].children[0].value = ""; - $('.reset-this-form')[0].children[2].children[1].children[1].children[0].value = ""; - $('.reset-this-form')[0].children[2].children[2].children[1].children[0].value = ""; + // $('.reset-this-form')[0].children[2].children[0].children[1].children[0].value = ""; + // $('.reset-this-form')[0].children[2].children[1].children[1].children[0].value = ""; + // $('.reset-this-form')[0].children[2].children[2].children[1].children[0].value = ""; + alertModal('Great! Item added successfully'); + setTimeout(function() { + location.reload(); + }, 1500); }, - error: function(data, err) { + error: function(xhr, data, err) { alertModal('Something missing! Please refill the form'); } - }); - -}); -$('#add-item-form-submit').click(function(event){ + }); +} +$('.add-item-form-submit').click(function(event){ event.preventDefault(); - if($('input[name="consumable"]:checked')){ - consumable = 'True'; - } - else{ - consumable = 'False'; - } + jsondata = { + 'csrfmiddlewaretoken': $('input[name="csrf"]').val(), + 'item_name' : $('input[name="item_name"]').val(), + 'quantity' : $('input[name="quantity_add"]').val(), + 'cost' : $('input[name="cost"]').val(), + 'consumable': ($('input[name="consumable"]:checked').val())?true:false, + 'bill_number' : $('input[name="bill_number"]').val() + } + console.log(jsondata) $.ajax({ type: 'POST', url: '/visitorhostel/add-to-inventory/', - data: { - 'csrfmiddlewaretoken': $('input[name="csrf"]').val(), - 'item_name' : $('input[name="item-name"]').val(), - 'quantity' : $('input[name="quantity_add"]').val(), - 'cost' : $('input[name="cost"]').val(), - 'consumable' : consumable, - 'bill_number' : $('input[name="bill_number"]').val() - }, + data: jsondata, success: function(data) { $('.reset-this-form')[0].children[2].children[0].children[1].children[0].value = ""; $('.reset-this-form')[0].children[2].children[1].children[1].children[0].value = ""; @@ -614,12 +650,20 @@ function forward_booking (id) { previous_category = $('input[name=category-'+id+']').val(); modified_category = $('input[name=modified-category-'+id+']').val(); rooms = $('select[name=alloted-rooms-'+id+']').val(); - + rem = $('input[name=cancellation-remarks-' + id + ']').val(); + console.log("TExt rem: ", rem); // if (previous_category == 0) { // alertModal("Please fill the category to confirm."); // return; // } + console.log("Rooms: ", rooms); + remark = ""; + for (x in rooms) { + remark += rooms[x] + " "; + } + remark += "can be alloted"; + console.log("remarks: ", remark); if (modified_category == 0) { modified_category = previous_category; } @@ -637,7 +681,8 @@ function forward_booking (id) { 'csrfmiddlewaretoken': csrfmiddlewaretoken, 'previous_category' : previous_category, 'modified_category' : modified_category, - 'rooms' : rooms, + 'rooms': rooms, + 'remark': remark, }, success: function(data) { alertModal("This booking has been forwarded"); @@ -684,28 +729,28 @@ function cancel_active_booking (id, booking_from) { // Edit Inventory -$("#edit-inventory").click(function(e){ - $(".inventory-item").slideToggle(); - $(".inventory-form").slideToggle(); - $("#update-inventory-submit").slideToggle(); -}); -$("#update-inventory-submit").click(function(e){ - event.preventDefault(); - $.ajax({ - type: 'POST', - url: '/visitorhostel/bookaroom/', - data: { - 'csrfmiddlewaretoken' : '{{csrf_token}}', - 'data' : data - }, - success: function(data) { - alertModal("Congratulations! Inventory is updated successfully"); - }, - error: function(data, err) { - alertModal('Something missing! PLease refill the form'); - } - }); -}); +// $("#edit-inventory").click(function(e){ +// $(".inventory-item").slideToggle(); +// $(".inventory-form").slideToggle(); +// $("#update-inventory-submit").slideToggle(); +// }); +// $("#update-inventory-submit").click(function(e){ +// event.preventDefault(); +// $.ajax({ +// type: 'POST', +// url: '/visitorhostel/bookaroom/', +// data: { +// 'csrfmiddlewaretoken' : '{{csrf_token}}', +// 'data' : data +// }, +// success: function(data) { +// alertModal("Congratulations! Inventory is updated successfully"); +// }, +// error: function(data, err) { +// alertModal('Something missing! PLease refill the form'); +// } +// }); +// }); // Submit Visitor Details @@ -787,7 +832,7 @@ function submit_visitor_details (id) { // Check Out -function check_out (id , mess_bill , room_bill) { +function check_out(id, mess_bill, room_bill) { $.ajax({ type: 'POST', url: '/visitorhostel/check-out/', @@ -813,10 +858,10 @@ function check_out (id , mess_bill , room_bill) { function bill_between_date_range() { - start_date = $('input[name=start').val(); - end_date = $('input[name=end]').val(); - - if(new Date(start_date)>new Date(end_date)) + start = $('input[name=start]').val(); + end = $('input[name=end]').val(); + + if(new Date(start)>new Date(end)) { alertModal('Please check start date and end date.') return; @@ -824,24 +869,21 @@ function bill_between_date_range() { $.ajax({ type: 'POST', - url: '/visitorhostel/bill_between_date_range/', + url: '/visitorhostel/bill_between_dates/', data: { 'csrfmiddlewaretoken' : $('input[name="csrf"]').val(), - 'start_date' : start_date, - 'end_date' : end_date, + 'start_date' : start, + 'end_date' : end, }, success: function(data) { $('#replace-this-div-booking-bw-dates').html(data); console.log("winning"); - console.log(start_date); // alert('Bookings Between range are ..'); }, error: function(data, err) { - alertModal ('Error !'); - console.log(start_date); - console.log(end_date); + alertModal ('Error !', data, err); // alertModal('Something missing! Please refill the form'); } }); @@ -850,14 +892,12 @@ function bill_between_date_range() { // finding available room's list between date range function find_available_rooms ( available_rooms ) { - start_date = $('input[name=start-date').val(); + start_date = $('input[name=start-date]').val(); end_date = $('input[name=end-date]').val(); if (new Date(start_date) > new Date(end_date)) { alertModal ('Please check start date and end date!'); return; } - console.log(start_date); - console.log(end_date); $.ajax({ type: 'POST', diff --git a/FusionIIIT/applications/visitor_hostel/urls.py b/FusionIIIT/applications/visitor_hostel/urls.py index fc352d646..1153e0d88 100644 --- a/FusionIIIT/applications/visitor_hostel/urls.py +++ b/FusionIIIT/applications/visitor_hostel/urls.py @@ -12,9 +12,9 @@ url(r'^get-booking-form/', views.get_booking_form, name='get_booking_form'), url(r'^request-booking/' , views.request_booking , name ='request_booking'), url(r'^confirm-booking/' , views.confirm_booking , name ='confirm_booking'), - url(r'^cancel-booking/', views.cancel_booking, name = 'cancel_booking'), - url(r'^cancel-booking-request/', views.cancel_booking_request, name = 'cancel_booking_request'), - url(r'^reject-booking/', views.reject_booking, name = 'reject_booking'), + url(r'^cancel-booking/', views.cancel_booking, name='cancel_booking'), + url(r'^cancel-booking-request/', views.cancel_booking_request,name='cancel_booking_request'), + url(r'^reject-booking/', views.reject_booking, name='reject_booking'), url(r'^check-in/', views.check_in, name = 'check_in'), url(r'^check-out/', views.check_out, name = 'check_out'), url(r'^record-meal/', views.record_meal, name = 'record_meal'), @@ -29,4 +29,3 @@ url(r'^booking-details/', views.booking_details, name = 'booking_details'), url(r'^forward-booking/', views.forward_booking, name = 'forward_booking'), ] - \ No newline at end of file diff --git a/FusionIIIT/applications/visitor_hostel/views.py b/FusionIIIT/applications/visitor_hostel/views.py index ab0711153..3419a7d14 100644 --- a/FusionIIIT/applications/visitor_hostel/views.py +++ b/FusionIIIT/applications/visitor_hostel/views.py @@ -25,7 +25,7 @@ import numpy as np from django.contrib.auth.models import User -from .forms import InventoryForm +# from .forms import InventoryForm # for notifications from notification.views import visitors_hostel_notif @@ -61,10 +61,14 @@ def visitorhostel(request): # bookings for intender view if (user_designation == "Intender"): - all_bookings = BookingDetail.objects.select_related('intender','caretaker').all().order_by('booking_from') - pending_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(Q(status="Pending") | Q(status="Forward"), booking_to__gte=datetime.datetime.today(), intender=user).order_by('booking_from') - active_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(status="CheckedIn", booking_to__gte=datetime.datetime.today(), intender=user).order_by('booking_from') - dashboard_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(Q(status = "Pending") | Q(status="Forward") | Q(status = "Confirmed") | Q(status = 'Rejected'), booking_to__gte=datetime.datetime.today(), intender=user).order_by('booking_from') + all_bookings = BookingDetail.objects.select_related( + 'intender', 'caretaker').all().order_by('booking_from') + pending_bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter(Q(status="Pending") | Q( + status="Forward"), booking_to__gte=datetime.datetime.today(), intender=user).order_by('booking_from') + active_bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter( + status="CheckedIn", booking_to__gte=datetime.datetime.today(), intender=user).order_by('booking_from') + dashboard_bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter(Q(status="Pending") | Q(status="Forward") | Q( + status="Confirmed") | Q(status='Rejected'), booking_to__gte=datetime.datetime.today(), intender=user).order_by('booking_from') # print(dashboard_bookings.booking_from) visitors = {} @@ -78,43 +82,55 @@ def visitorhostel(request): temp2 = range(1, booking.number_of_rooms_alloted) rooms[booking.id] = temp2 - complete_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(booking_to__lt=datetime.datetime.today(), intender=user).order_by('booking_from') - canceled_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(status="Canceled", intender=user).order_by('booking_from') - rejected_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(status='Rejected', intender=user).order_by('booking_from') - cancel_booking_requested = BookingDetail.objects.select_related('intender','caretaker').filter(status='CancelRequested', intender=user).order_by('booking_from') - + complete_bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter( + check_out__lt=datetime.datetime.today(), intender=user).order_by('booking_from').reverse() + canceled_bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter( + status="Canceled", intender=user).order_by('booking_from') + rejected_bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter( + status='Rejected', intender=user).order_by('booking_from') + cancel_booking_requested = BookingDetail.objects.select_related('intender', 'caretaker').filter( + status='CancelRequested', intender=user).order_by('booking_from') else: # booking for caretaker and incharge view - all_bookings = BookingDetail.objects.select_related('intender','caretaker').all().order_by('booking_from') - pending_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(Q(status="Pending") | Q(status="Forward"), booking_to__gte=datetime.datetime.today()).order_by('booking_from') - active_bookings = BookingDetail.objects.filter(Q(status="Confirmed") | Q(status="CheckedIn"), booking_to__gte=datetime.datetime.today()).select_related('intender','caretaker').order_by('booking_from') - cancel_booking_request = BookingDetail.objects.select_related('intender','caretaker').filter(status="CancelRequested", booking_to__gte=datetime.datetime.today()).order_by('booking_from') - dashboard_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(Q(status = "Pending") | Q(status="Forward") | Q(status = "Confirmed"), booking_to__gte=datetime.datetime.today()).order_by('booking_from') + all_bookings = BookingDetail.objects.select_related( + 'intender', 'caretaker').all().order_by('booking_from') + pending_bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter( + Q(status="Pending") | Q(status="Forward"), booking_to__gte=datetime.datetime.today()).order_by('booking_from') + active_bookings = BookingDetail.objects.filter(Q(status="Confirmed") | Q( + status="CheckedIn"), booking_to__gte=datetime.datetime.today()).select_related('intender', 'caretaker').order_by('booking_from') + cancel_booking_request = BookingDetail.objects.select_related('intender', 'caretaker').filter( + status="CancelRequested", booking_to__gte=datetime.datetime.today()).order_by('booking_from') + dashboard_bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter(Q(status="Pending") | Q( + status="Forward") | Q(status="Confirmed"), booking_to__gte=datetime.datetime.today()).order_by('booking_from') + print(dashboard_bookings) visitors = {} rooms = {} # x = BookingDetail.objects.all().annotate(rooms_count=Count('rooms')) - c_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(Q(status="Forward"), booking_to__gte=datetime.datetime.today()).order_by('booking_from') - + c_bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter( + Q(status="Forward"), booking_to__gte=datetime.datetime.today()).order_by('booking_from') + # number of visitors for booking in active_bookings: temp = range(2, booking.person_count + 1) visitors[booking.id] = temp - # rooms alloted to booking for booking in active_bookings: for room_no in booking.rooms.all(): temp2 = range(2, booking.number_of_rooms_alloted + 1) rooms[booking.id] = temp2 - #print(booking.rooms.all()) - + # print(booking.rooms.all()) - complete_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(Q(status="Canceled") | Q(status="Complete"), booking_to__lt=datetime.datetime.today()).select_related().order_by('booking_from') - canceled_bookings = BookingDetail.objects.filter(status="Canceled").select_related('intender','caretaker').order_by('booking_from') - cancel_booking_requested = BookingDetail.objects.select_related('intender','caretaker').filter(status='CancelRequested', booking_to__gte=datetime.datetime.today(), intender=user).order_by('booking_from') - rejected_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(status='Rejected').order_by('booking_from') + complete_bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter(Q(status="Canceled") | Q( + status="Complete"), check_out__lt=datetime.datetime.today()).select_related().order_by('booking_from').reverse() + canceled_bookings = BookingDetail.objects.filter(status="Canceled").select_related( + 'intender', 'caretaker').order_by('booking_from') + cancel_booking_requested = BookingDetail.objects.select_related('intender', 'caretaker').filter( + status='CancelRequested', booking_to__gte=datetime.datetime.today(), intender=user).order_by('booking_from') + rejected_bookings = BookingDetail.objects.select_related( + 'intender', 'caretaker').filter(status='Rejected').order_by('booking_from') # finding available room list for alloting rooms for booking in pending_bookings: @@ -122,17 +138,18 @@ def visitorhostel(request): booking_to = booking.booking_to temp1 = booking_details(booking_from, booking_to) available_rooms[booking.id] = temp1 - + # forwarded rooms details for booking in c_bookings: booking_from = booking.booking_from booking_to = booking.booking_to temp2 = forwarded_booking_details(booking_from, booking_to) forwarded_rooms[booking.id] = temp2 + # print(available_rooms) + # print(forwarded_rooms) # inventory data inventory = Inventory.objects.all() inventory_bill = InventoryBill.objects.select_related('item_name').all() - # completed booking bills completed_booking_bills = {} @@ -140,7 +157,8 @@ def visitorhostel(request): current_balance = 0 for bill in all_bills: - completed_booking_bills[bill.id] = {'intender': str(bill.booking.intender), 'booking_from': str(bill.booking.booking_from), 'booking_to': str(bill.booking.booking_to), 'total_bill': str(bill.meal_bill + bill.room_bill)} + completed_booking_bills[bill.id] = {'intender': str(bill.booking.intender), 'booking_from': str( + bill.booking.booking_from), 'booking_to': str(bill.booking.booking_to), 'total_bill': str(bill.meal_bill + bill.room_bill), 'bill_date': str(bill.bill_date)} current_balance = current_balance+bill.meal_bill + bill.room_bill for inv_bill in inventory_bill: @@ -166,7 +184,7 @@ def visitorhostel(request): category = booking.visitor_category person = booking.person_count - room_bill = 0 + room_bill = 100 if days == 0: days = 1 @@ -193,25 +211,23 @@ def visitorhostel(request): mess_bill = 0 for visitor in booking.visitor.all(): - meal = MealRecord.objects.select_related('booking__intender','booking__caretaker','visitor','room').filter(visitor=visitor) + meal = MealRecord.objects.select_related( + 'booking__intender', 'booking__caretaker', 'visitor').filter(booking_id=booking.id) mess_bill1 = 0 for m in meal: - if m.morning_tea == True: - mess_bill1 = mess_bill1+10 - if m.eve_tea == True: - mess_bill1 = mess_bill1+10 - if m.breakfast == True: - mess_bill1 = mess_bill1+50 - if m.lunch == True: - mess_bill1 = mess_bill1+100 - if m.dinner == True: - mess_bill1 = mess_bill1+100 - - if mess_bill1 == 270: - mess_bill = mess_bill+225 - else: - mess_bill = mess_bill + mess_bill1 + if m.morning_tea != 0: + mess_bill1 = mess_bill1+m.morning_tea*10 + if m.eve_tea != 0: + mess_bill1 = mess_bill1+m.eve_tea*10 + if m.breakfast != 0: + mess_bill1 = mess_bill1+m.breakfast*50 + if m.lunch != 0: + mess_bill1 = mess_bill1+m.lunch*100 + if m.dinner != 0: + mess_bill1 = mess_bill1+m.dinner*100 + + mess_bill = mess_bill + mess_bill1 total_bill = mess_bill + room_bill @@ -223,7 +239,7 @@ def visitorhostel(request): visitor_list = [] for b in dashboard_bookings: - count=1 + count = 1 b_visitor_list = b.visitor.all() for v in b_visitor_list: if count == 1: @@ -236,7 +252,7 @@ def visitorhostel(request): 'pending_bookings': pending_bookings, 'active_bookings': active_bookings, 'canceled_bookings': canceled_bookings, - 'dashboard_bookings' : dashboard_bookings, + 'dashboard_bookings': dashboard_bookings, 'bills': bills, # 'all_rooms_status' : all_rooms_status, @@ -251,7 +267,7 @@ def visitorhostel(request): 'intenders': intenders, 'user': user, 'visitors': visitors, - 'rooms' : rooms, + 'rooms': rooms, # 'num_rooms' : list(range(1, booking.number_of_rooms_alloted+1)), # 'num_rooms' :list(range(1, booking.number_of_rooms_alloted+1)), 'previous_visitors': previous_visitors, @@ -259,15 +275,17 @@ def visitorhostel(request): 'current_balance': current_balance, 'rejected_bookings': rejected_bookings, 'cancel_booking_request': cancel_booking_request, - 'cancel_booking_requested' : cancel_booking_requested, + 'cancel_booking_requested': cancel_booking_requested, 'user_designation': user_designation}) # Get methods for bookings + @login_required(login_url='/accounts/login/') def get_booking_requests(request): if request.method == 'POST': - pending_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(status="Pending") + pending_bookings = BookingDetail.objects.select_related( + 'intender', 'caretaker').filter(status="Pending") return render(request, "vhModule/visitorhostel.html", {'pending_bookings': pending_bookings}) else: @@ -275,10 +293,12 @@ def get_booking_requests(request): # getting active bookings + @login_required(login_url='/accounts/login/') def get_active_bookings(request): if request.method == 'POST': - active_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(status="Confirmed") + active_bookings = BookingDetail.objects.select_related( + 'intender', 'caretaker').filter(status="Confirmed") return render(request, "vhModule/visitorhostel.html", {'active_bookings': active_bookings}) else: @@ -287,8 +307,8 @@ def get_active_bookings(request): @login_required(login_url='/accounts/login/') def get_inactive_bookings(request): - if request.method == 'POST' : - inactive_bookings = BookingDetail.objects.select_related('intender','caretaker').filter( + if request.method == 'POST': + inactive_bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter( Q(status="Cancelled") | Q(status="Rejected") | Q(status="Complete")) return render(request, "vhModule/visitorhostel.html", {'inactive_bookings': inactive_bookings}) @@ -308,26 +328,27 @@ def get_booking_form(request): # request booking form action view starts here + @login_required(login_url='/accounts/login/') def request_booking(request): if request.method == 'POST': - flag=0 + flag = 0 # getting details from request form intender = request.POST.get('intender') user = User.objects.get(id=intender) print("jiihuhhih") print(user) - booking_id = request.POST.get('booking-id') + booking_id = request.POST.get('booking-id') category = request.POST.get('category') person_count = request.POST.get('number-of-people') bookingObject = [] - #if person_count and (int(person_count)<20): - # person_count = person_count + # if person_count and (int(person_count)<20): + # person_count = person_count - #else: - # flag = 1 # for error + # else: + # flag = 1 # for error # person_count = 1 purpose_of_visit = request.POST.get('purpose-of-visit') @@ -335,7 +356,8 @@ def request_booking(request): booking_to = request.POST.get('booking_to') booking_from_time = request.POST.get('booking_from_time') booking_to_time = request.POST.get('booking_to_time') - remarks_during_booking_request = request.POST.get('remarks_during_booking_request') + remarks_during_booking_request = request.POST.get( + 'remarks_during_booking_request') bill_to_be_settled_by = request.POST.get('bill_settlement') number_of_rooms = request.POST.get('number-of-rooms') caretaker = 'shailesh' @@ -344,27 +366,28 @@ def request_booking(request): # flag=1 # if flag ==0: - print(sys.getsizeof(booking_from_time)) - print(sys.getsizeof(booking_from)) - print(sys.getsizeof(purpose_of_visit)) - print(sys.getsizeof(bill_to_be_settled_by)) - + # print(sys.getsizeof(booking_from_time)) + # print(sys.getsizeof(booking_from)) + # print(sys.getsizeof(purpose_of_visit)) + # print(sys.getsizeof(bill_to_be_settled_by)) + # print("gfcfhcghv") care_taker = HoldsDesignation.objects.select_related('user','working','designation').filter(designation__name = "VhCaretaker") - care_taker = care_taker[1] + care_taker = care_taker[0] + # print(care_taker,"care_taker") care_taker = care_taker.user bookingObject = BookingDetail.objects.create( - caretaker = care_taker, - purpose=purpose_of_visit, - intender=user, - booking_from=booking_from, - booking_to=booking_to, - visitor_category=category, - person_count=person_count, - arrival_time=booking_from_time, - departure_time=booking_to_time, - #remark=remarks_during_booking_request, - number_of_rooms=number_of_rooms, - bill_to_be_settled_by=bill_to_be_settled_by) + caretaker=care_taker, + purpose=purpose_of_visit, + intender=user, + booking_from=booking_from, + booking_to=booking_to, + visitor_category=category, + person_count=person_count, + arrival_time=booking_from_time, + departure_time=booking_to_time, + # remark=remarks_during_booking_request, + number_of_rooms=number_of_rooms, + bill_to_be_settled_by=bill_to_be_settled_by) # visitor_hostel_caretaker_notif(request.user,care_taker,"Submitted") # print (bookingObject) # print("Hello") @@ -382,10 +405,11 @@ def request_booking(request): # in case of any attachment doc = request.FILES.get('files-during-booking-request') - remark=remarks_during_booking_request, + remark = remarks_during_booking_request, if doc: print("hello") - filename, file_extenstion = os.path.splitext(request.FILES.get('files-during-booking-request').booking_id) + filename, file_extenstion = os.path.splitext( + request.FILES.get('files-during-booking-request').booking_id) filename = booking_id full_path = settings.MEDIA_ROOT + "/VhImage/" url = settings.MEDIA_URL + filename + file_extenstion @@ -399,7 +423,7 @@ def request_booking(request): bookingObject.image = uploaded_file_url bookingObject.save() - # visitor datails from place request form + # visitor datails from place request form visitor_name = request.POST.get('name') visitor_phone = request.POST.get('phone') @@ -412,9 +436,8 @@ def request_booking(request): visitor_organization = ' ' visitor = VisitorDetail.objects.create( - visitor_phone=visitor_phone, visitor_name=visitor_name, visitor_email=visitor_email, visitor_address=visitor_address, visitor_organization=visitor_organization - , nationality=visitor_nationality - ) + visitor_phone=visitor_phone, visitor_name=visitor_name, visitor_email=visitor_email, visitor_address=visitor_address, visitor_organization=visitor_organization, nationality=visitor_nationality + ) # try: # bd = BookingDetail.objects.get(id=booking_id) @@ -423,13 +446,13 @@ def request_booking(request): bookingObject.save() # except: - #print("exception occured") - # return HttpResponse('/visitorhostel/') + # print("exception occured") + # return HttpResponse('/visitorhostel/') # for sending notification of booking request to caretaker - #caretaker_name = HoldsDesignation.objects.select_related('user','working','designation').get(designation__name = "VhCaretaker") - #visitors_hostel_notif(request.user, care_taker.user, 'booking_request') + # caretaker_name = HoldsDesignation.objects.select_related('user','working','designation').get(designation__name = "VhCaretaker") + # visitors_hostel_notif(request.user, care_taker.user, 'booking_request') return HttpResponseRedirect('/visitorhostel/') else: @@ -459,30 +482,33 @@ def update_booking(request): number_of_rooms = request.POST.get('number-of-rooms') # remark = request.POST.get('remark') - booking = BookingDetail.objects.select_related('intender','caretaker').get(id=booking_id) + booking = BookingDetail.objects.select_related( + 'intender', 'caretaker').get(id=booking_id) booking.person_count = person_count booking.number_of_rooms = number_of_rooms booking.booking_from = booking_from booking.booking_to = booking_to booking.purpose = purpose_of_visit booking.save() - + forwarded_rooms = {} # BookingDetail.objects.filter(id=booking_id).update(person_count=person_count, # purpose=purpose_of_visit, # booking_from=booking_from, # booking_to=booking_to, # number_of_rooms=number_of_rooms) - booking = BookingDetail.objects.select_related('intender','caretaker').get(id=booking_id) - c_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(Q(status="Forward"), booking_to__gte=datetime.datetime.today()).order_by('booking_from') + booking = BookingDetail.objects.select_related( + 'intender', 'caretaker').get(id=booking_id) + c_bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter( + Q(status="Forward"), booking_to__gte=datetime.datetime.today()).order_by('booking_from') for booking in c_bookings: booking_from = booking.booking_from booking_to = booking.booking_to temp2 = forwarded_booking_details(booking_from, booking_to) forwarded_rooms[booking.id] = temp2 return render(request, "visitorhostel/", - { - 'forwarded_rooms': forwarded_rooms}) - + { + 'forwarded_rooms': forwarded_rooms}) + else: return HttpResponseRedirect('/visitorhostel/') @@ -502,9 +528,11 @@ def confirm_booking(request): # rooms list rooms = request.POST.getlist('rooms[]') - #print(rooms) - booking = BookingDetail.objects.select_related('intender','caretaker').get(id=booking_id) - bd = BookingDetail.objects.select_related('intender','caretaker').get(id=booking_id) + # print(rooms) + booking = BookingDetail.objects.select_related( + 'intender', 'caretaker').get(id=booking_id) + bd = BookingDetail.objects.select_related( + 'intender', 'caretaker').get(id=booking_id) bd.status = 'Confirmed' bd.category = category @@ -513,8 +541,9 @@ def confirm_booking(request): bd.rooms.add(room_object) bd.save() - # notification of booking confirmation - visitors_hostel_notif(request.user, bd.intender, 'booking_confirmation') + # notification of booking confirmation + visitors_hostel_notif(request.user, bd.intender, + 'booking_confirmation') return HttpResponseRedirect('/visitorhostel/') else: return HttpResponseRedirect('/visitorhostel/') @@ -528,42 +557,51 @@ def cancel_booking(request): booking_id = request.POST.get('booking-id') remark = request.POST.get('remark') charges = request.POST.get('charges') - BookingDetail.objects.select_related('intender','caretaker').filter(id=booking_id).update( + BookingDetail.objects.select_related('intender', 'caretaker').filter(id=booking_id).update( status='Canceled', remark=remark) - booking = BookingDetail.objects.select_related('intender','caretaker').get(id=booking_id) + booking = BookingDetail.objects.select_related( + 'intender', 'caretaker').get(id=booking_id) # if no applicable charges then set charges to zero x = 0 if charges: - Bill.objects.create(booking=booking, meal_bill=x, room_bill=int(charges), caretaker=user, payment_status=True) + Bill.objects.create(booking=booking, meal_bill=x, room_bill=int( + charges), caretaker=user, payment_status=True) else: - Bill.objects.create(booking=booking, meal_bill=x, room_bill=x, caretaker=user, payment_status=True) + Bill.objects.create(booking=booking, meal_bill=x, + room_bill=x, caretaker=user, payment_status=True) + + complete_bookings = BookingDetail.objects.filter(Q(status="Canceled") | Q( + status="Complete"), booking_to__lt=datetime.datetime.today()).select_related('intender', 'caretaker').order_by('booking_from') - complete_bookings = BookingDetail.objects.filter(Q(status="Canceled") | Q(status="Complete"), booking_to__lt=datetime.datetime.today()).select_related('intender','caretaker').order_by('booking_from') - - # to notify the intender that his cancellation request has been confirmed - visitors_hostel_notif(request.user, booking.intender, 'booking_cancellation_request_accepted') + visitors_hostel_notif(request.user, booking.intender, + 'booking_cancellation_request_accepted') return HttpResponseRedirect('/visitorhostel/') else: return HttpResponseRedirect('/visitorhostel/') # cancel confirmed booing by intender + @login_required(login_url='/accounts/login/') def cancel_booking_request(request): if request.method == 'POST': - intender = request.user.holds_designations.filter(designation__name = 'VhIncharge') + intender = request.user.holds_designations.filter( + designation__name='VhIncharge') booking_id = request.POST.get('booking-id') remark = request.POST.get('remark') - BookingDetail.objects.select_related('intender','caretaker').filter(id=booking_id).update(status='CancelRequested', remark=remark) + BookingDetail.objects.select_related('intender', 'caretaker').filter( + id=booking_id).update(status='CancelRequested', remark=remark) - incharge_name = HoldsDesignation.objects.select_related('user','working','designation').filter(designation__name = "VhIncharge")[1] + incharge_name = HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').filter(designation__name="VhIncharge")[1] # to notify the VhIncharge about a new cancelltaion request - visitors_hostel_notif(request.user, incharge_name.user, 'cancellation_request_placed') + visitors_hostel_notif( + request.user, incharge_name.user, 'cancellation_request_placed') return HttpResponseRedirect('/visitorhostel/') else: return HttpResponseRedirect('/visitorhostel/') @@ -576,18 +614,19 @@ def reject_booking(request): if request.method == 'POST': booking_id = request.POST.get('booking-id') remark = request.POST.get('remark') - BookingDetail.objects.select_related('intender','caretaker').filter(id=booking_id).update( + BookingDetail.objects.select_related('intender', 'caretaker').filter(id=booking_id).update( status="Rejected", remark=remark) # to notify the intender that his request has been rejected - #visitors_hostel_notif(request.user, booking.intender, 'booking_rejected') + # visitors_hostel_notif(request.user, booking.intender, 'booking_rejected') return HttpResponseRedirect('/visitorhostel/') else: return HttpResponseRedirect('/visitorhostel/') # Guest check in view + @login_required(login_url='/accounts/login/') def check_in(request): if request.method == 'POST': @@ -602,7 +641,8 @@ def check_in(request): visitor = VisitorDetail.objects.create( visitor_phone=visitor_phone, visitor_name=visitor_name, visitor_email=visitor_email, visitor_address=visitor_address) try: - bd = BookingDetail.objects.select_related('intender','caretaker').get(id=booking_id) + bd = BookingDetail.objects.select_related( + 'intender', 'caretaker').get(id=booking_id) bd.status = "CheckedIn" bd.check_in = check_in_date bd.visitor.add(visitor) @@ -616,6 +656,7 @@ def check_in(request): # guest check out view + @login_required(login_url='/accounts/login/') def check_out(request): user = get_object_or_404(User, username=request.user.username) @@ -626,11 +667,14 @@ def check_out(request): id = request.POST.get('id') meal_bill = request.POST.get('mess_bill') room_bill = request.POST.get('room_bill') - BookingDetail.objects.select_related('intender','caretaker').filter(id=id).update( + checkout_date = datetime.date.today() + total_bill = int(meal_bill)+int(room_bill) + BookingDetail.objects.select_related('intender', 'caretaker').filter(id=id).update( check_out=datetime.datetime.today(), status="Complete") - booking = BookingDetail.objects.select_related('intender','caretaker').get(id=id) + booking = BookingDetail.objects.select_related( + 'intender', 'caretaker').get(id=id) Bill.objects.create(booking=booking, meal_bill=int(meal_bill), room_bill=int( - room_bill), caretaker=user, payment_status=True) + room_bill), caretaker=user, payment_status=True, bill_date=checkout_date) # for visitors in visitor_info: @@ -662,7 +706,6 @@ def check_out(request): return HttpResponseRedirect('/visitorhostel/') - @login_required(login_url='/accounts/login/') def record_meal(request): user = get_object_or_404(User, username=request.user.username) @@ -673,58 +716,40 @@ def record_meal(request): id = request.POST.get('pk') booking_id = request.POST.get('booking') - booking = BookingDetail.objects.select_related('intender','caretaker').get(id=booking_id) + booking = BookingDetail.objects.select_related( + 'intender', 'caretaker').get(id=booking_id) visitor = VisitorDetail.objects.get(id=id) date_1 = datetime.datetime.today() - food = request.POST.getlist('food[]') - if '1' in food: - m_tea = True - else: - m_tea = False - - if '4' in food: - e_tea = True - else: - e_tea = False - - if '2' in food: - breakfast = True - else: - breakfast = False - - if '3' in food: - lunch = True - else: - lunch = False - - if '5' in food: - dinner = True - else: - dinner = False - - if request.POST.get('numberofpeople'): - person = request.POST.get('numberofpeople') - else: - person = 1 - + print(id, booking_id, booking, visitor, date_1) + m_tea = request.POST.get("m_tea") + breakfast = request.POST.get("breakfast") + lunch = request.POST.get("lunch") + eve_tea = request.POST.get("eve_tea") + dinner = request.POST.get("dinner") + + person = 1 + print("bid: ", id) + try: - meal = MealRecord.objects.select_related('booking__intender','booking__caretaker','visitor','room').get( + meal = MealRecord.objects.select_related('booking__intender', 'booking__caretaker', 'visitor').get( visitor=visitor, booking=booking, meal_date=date_1) except: meal = False if meal: - meal.morning_tea = m_tea - meal.eve_tea = e_tea - meal.breakfast = breakfast - meal.lunch = lunch - meal.dinner = dinner + meal.morning_tea += int(m_tea) + meal.eve_tea += int(eve_tea) + meal.breakfast += int(breakfast) + meal.lunch += int(lunch) + meal.dinner += int(dinner) meal.save() + return HttpResponseRedirect('/visitorhostel/') + else: MealRecord.objects.create(visitor=visitor, booking=booking, morning_tea=m_tea, - eve_tea=e_tea, + eve_tea=eve_tea, meal_date=date_1, breakfast=breakfast, lunch=lunch, @@ -737,6 +762,7 @@ def record_meal(request): # generate bill records between date range + @login_required(login_url='/accounts/login/') def bill_generation(request): user = get_object_or_404(User, username=request.user.username) @@ -755,7 +781,8 @@ def bill_generation(request): st = False user = get_object_or_404(User, username=request.user.username) - c = ExtraInfo.objects.select_related('department').filter(user=user) + c = ExtraInfo.objects.select_related( + 'department').filter(user=user) visitor = Visitor.objects.filter(visitor_phone=v_id) visitor = visitor[0] visitor_bill = Visitor_bill.objects.create( @@ -768,6 +795,7 @@ def bill_generation(request): # get available rooms list between date range + @login_required(login_url='/accounts/login/') def room_availabity(request): if request.method == 'POST': @@ -775,7 +803,7 @@ def room_availabity(request): date_2 = request.POST.get('end_date') available_rooms_list = [] available_rooms_bw_dates = booking_details(date_1, date_2) - #print("Available rooms are ") + # print("Available rooms are ") for room in available_rooms_bw_dates: available_rooms_list.append(room.room_number) @@ -791,18 +819,21 @@ def add_to_inventory(request): if request.method == 'POST': item_name = request.POST.get('item_name') bill_number = request.POST.get('bill_number') - quantity = (request.POST.get('quantity')) - cost = request.POST.get('cost') + quantity = int((request.POST.get('quantity'))) + cost = int(request.POST.get('cost')) consumable = request.POST.get('consumable') - # if(Inventory.objects.get(item_name = item_name)): - # Inventory.objects.filter(item_name=item_name).update(quantity=quantity,consumable=consumable) - # else: - Inventory.objects.create( - item_name=item_name, quantity=quantity, consumable=consumable) - - item_name_key = Inventory.objects.get(item_name=item_name) + if consumable == 'false': + isConsumable = False + else: + isConsumable = True + print(isConsumable) + x = Inventory.objects.create( + item_name=item_name, quantity=quantity, consumable=isConsumable) + print(x.pk) + item = Inventory.objects.get(pk=x.pk) + item_id = item.pk InventoryBill.objects.create( - item_name=item_name_key, bill_number=bill_number, cost=cost) + bill_number=bill_number, cost=cost, item_name_id=item_id) return HttpResponseRedirect('/visitorhostel/') else: return HttpResponseRedirect('/visitorhostel/') @@ -812,9 +843,13 @@ def add_to_inventory(request): def update_inventory(request): if request.method == 'POST': id = request.POST.get('id') - quantity = request.POST.get('quantity') - - Inventory.objects.filter(id=id).update(quantity=quantity) + quantity = int(request.POST.get('quantity')) + if quantity < 0: + quantity = 1 + if quantity == 0: + Inventory.objects.filter(id=id).delete() + else: + Inventory.objects.filter(id=id).update(quantity=quantity) return HttpResponseRedirect('/visitorhostel/') else: return HttpResponseRedirect('/visitorhostel/') @@ -832,7 +867,6 @@ def edit_room_status(request): return HttpResponseRedirect('/visitorhostel/') - @login_required(login_url='/accounts/login/') def bill_between_dates(request): if request.method == 'POST': @@ -841,7 +875,7 @@ def bill_between_dates(request): bill_range_bw_dates = bill_range(date_1, date_2) meal_total = 0 room_total = 0 - individual_total =[] + individual_total = [] # calculating room and mess bill booking wise for i in bill_range_bw_dates: @@ -851,24 +885,22 @@ def bill_between_dates(request): total_bill = meal_total + room_total # zip(bill_range_bw_dates, individual_total) return render(request, "vhModule/booking_bw_dates.html", { - # 'booking_bw_dates': bill_range_bw_dates, - 'booking_bw_dates_length': bill_range_bw_dates, - 'meal_total' : meal_total, - 'room_total' :room_total, - 'total_bill' : total_bill, - 'individual_total' : individual_total, - 'booking_bw_dates': zip(bill_range_bw_dates, individual_total) - }) + # 'booking_bw_dates': bill_range_bw_dates, + 'booking_bw_dates_length': bill_range_bw_dates, + 'meal_total': meal_total, + 'room_total': room_total, + 'total_bill': total_bill, + 'individual_total': individual_total, + 'booking_bw_dates': zip(bill_range_bw_dates, individual_total) + }) else: return HttpResponseRedirect('/visitorhostel/') +def bill_range(date1, date2): -def bill_range(date1,date2): - - - bookings = BookingDetail.objects.select_related('intender','caretaker').filter(Q(booking_from__lte=date1, booking_to__gte=date1) | Q(booking_from__gte=date1, - booking_to__lte=date2) | Q(booking_from__lte=date2, booking_to__gte=date2) | Q(booking_from__lte=date1, booking_to__gte=date1) | Q(booking_from__gte=date1, booking_to__lte=date2) | Q(booking_from__lte=date2, booking_to__gte=date2)) + bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter(Q(booking_from__lte=date1, booking_to__gte=date1) | Q(booking_from__gte=date1, + booking_to__lte=date2) | Q(booking_from__lte=date2, booking_to__gte=date2) | Q(booking_from__lte=date1, booking_to__gte=date1) | Q(booking_from__gte=date1, booking_to__lte=date2) | Q(booking_from__lte=date2, booking_to__gte=date2)) # bill_details = Bill.objects.filter(Q(booking__booking_from__lte=date1, booking__booking_to__gte=date1, booking__status="Confirmed") | Q(booking__booking_from__gte=date1, # booking__booking_to__lte=date2, booking__status="Confirmed") | Q(booking__booking_from__lte=date2, booking__booking_to__gte=date2, status="Confirmed") | Q(booking_from__lte=date1, booking__booking_to__gte=date1, status="CheckedIn") | Q(booking__booking_from__gte=date1, booking__booking_to__lte=date2, booking__status="CheckedIn") | Q(booking__booking_from__lte=date2, booking__booking_to__gte=date2, booking__status="CheckedIn")) bookings_bw_dates = [] @@ -879,8 +911,9 @@ def bill_range(date1,date2): all_bill = Bill.objects.select_related('caretaker').all().order_by('-id') for b_id in booking_ids: - if Bill.objects.select_related('caretaker').filter(booking__pk=b_id).exists() : - bill_id = Bill.objects.select_related('caretaker').get(booking__pk=b_id) + if Bill.objects.select_related('caretaker').filter(booking__pk=b_id).exists(): + bill_id = Bill.objects.select_related( + 'caretaker').get(booking__pk=b_id) bookings_bw_dates.append(bill_id) return bookings_bw_dates @@ -888,9 +921,9 @@ def bill_range(date1,date2): def booking_details(date1, date2): - bookings = BookingDetail.objects.select_related('intender','caretaker').filter(Q(booking_from__lte=date1, booking_to__gte=date1, status="Confirmed") | Q(booking_from__gte=date1, - booking_to__lte=date2, status="Confirmed") | Q(booking_from__lte=date2, booking_to__gte=date2, status="Confirmed") | Q(booking_from__lte=date1, booking_to__gte=date1, status="Forward") | Q(booking_from__gte=date1, - booking_to__lte=date2, status="Forward") | Q(booking_from__lte=date2, booking_to__gte=date2, status="Forward") | Q(booking_from__lte=date1, booking_to__gte=date1, status="CheckedIn") | Q(booking_from__gte=date1, booking_to__lte=date2, status="CheckedIn") | Q(booking_from__lte=date2, booking_to__gte=date2, status="CheckedIn")) + bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter(Q(booking_from__lte=date1, booking_to__gte=date1, status="Confirmed") | Q(booking_from__gte=date1, + booking_to__lte=date2, status="Confirmed") | Q(booking_from__lte=date2, booking_to__gte=date2, status="Confirmed") | Q(booking_from__lte=date1, booking_to__gte=date1, status="Forward") | Q(booking_from__gte=date1, + booking_to__lte=date2, status="Forward") | Q(booking_from__lte=date2, booking_to__gte=date2, status="Forward") | Q(booking_from__lte=date1, booking_to__gte=date1, status="CheckedIn") | Q(booking_from__gte=date1, booking_to__lte=date2, status="CheckedIn") | Q(booking_from__lte=date2, booking_to__gte=date2, status="CheckedIn")) booked_rooms = [] for booking in bookings: @@ -907,12 +940,13 @@ def booking_details(date1, date2): # function for finding forwarded booking rooms + def forwarded_booking_details(date1, date2): - bookings = BookingDetail.objects.select_related('intender','caretaker').filter(Q(booking_from__lte=date1, booking_to__gte=date1, status="Confirmed") | Q(booking_from__gte=date1, - booking_to__lte=date2, status="Confirmed") | Q(booking_from__lte=date2, booking_to__gte=date2, status="Confirmed") | Q(booking_from__lte=date1, booking_to__gte=date1, status="CheckedIn") | Q(booking_from__gte=date1, booking_to__lte=date2, status="CheckedIn") | Q(booking_from__lte=date2, booking_to__gte=date2, status="CheckedIn")) - forwarded_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(Q(booking_from__lte=date1, booking_to__gte=date1, status="Forward") | Q(booking_from__gte=date1, - booking_to__lte=date2, status="Forward") | Q(booking_from__lte=date2, booking_to__gte=date2, status="Forward") ) + bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter(Q(booking_from__lte=date1, booking_to__gte=date1, status="Confirmed") | Q(booking_from__gte=date1, + booking_to__lte=date2, status="Confirmed") | Q(booking_from__lte=date2, booking_to__gte=date2, status="Confirmed") | Q(booking_from__lte=date1, booking_to__gte=date1, status="CheckedIn") | Q(booking_from__gte=date1, booking_to__lte=date2, status="CheckedIn") | Q(booking_from__lte=date2, booking_to__gte=date2, status="CheckedIn")) + forwarded_bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter(Q(booking_from__lte=date1, booking_to__gte=date1, status="Forward") | Q(booking_from__gte=date1, + booking_to__lte=date2, status="Forward") | Q(booking_from__lte=date2, booking_to__gte=date2, status="Forward")) booked_rooms = [] # Bookings for rooms which are forwarded but not yet approved @@ -935,10 +969,14 @@ def forward_booking(request): previous_category = request.POST.get('previous_category') modified_category = request.POST.get('modified_category') rooms = request.POST.getlist('rooms[]') + remark = request.POST.get('remark') print(rooms) - BookingDetail.objects.select_related('intender','caretaker').filter(id=booking_id).update(status="Forward") - booking = BookingDetail.objects.select_related('intender','caretaker').get(id=booking_id) - bd = BookingDetail.objects.select_related('intender','caretaker').get(id=booking_id) + BookingDetail.objects.select_related('intender', 'caretaker').filter( + id=booking_id).update(status="Forward", remark=remark) + booking = BookingDetail.objects.select_related( + 'intender', 'caretaker').get(id=booking_id) + bd = BookingDetail.objects.select_related( + 'intender', 'caretaker').get(id=booking_id) bd.modified_visitor_category = modified_category count_rooms = 0 @@ -949,14 +987,17 @@ def forward_booking(request): bd.number_of_rooms_alloted = count_rooms bd.save() - dashboard_bookings = BookingDetail.objects.select_related('intender','caretaker').filter(Q(status = "Pending") | Q(status="Forward") | Q(status = "Confirmed") | Q(status = 'Rejected'), booking_to__gte=datetime.datetime.today(), intender=user).order_by('booking_from') + dashboard_bookings = BookingDetail.objects.select_related('intender', 'caretaker').filter(Q(status="Pending") | Q(status="Forward") | Q( + status="Confirmed") | Q(status='Rejected'), booking_to__gte=datetime.datetime.today(), intender=user).order_by('booking_from') # return render(request, "vhModule/visitorhostel.html", # {'dashboard_bookings' : dashboard_bookings}) - incharge_name = HoldsDesignation.objects.select_related('user','working','designation').filter(designation__name = "VhIncharge")[1] + incharge_name = HoldsDesignation.objects.select_related( + 'user', 'working', 'designation').filter(designation__name="VhIncharge")[1] # notify incharge about forwarded booking - visitors_hostel_notif(request.user, incharge_name.user, 'booking_forwarded') + visitors_hostel_notif( + request.user, incharge_name.user, 'booking_forwarded') return HttpResponseRedirect('/visitorhostel/') else: - return HttpResponseRedirect('/visitorhostel/') \ No newline at end of file + return HttpResponseRedirect('/visitorhostel/') diff --git a/FusionIIIT/notification/views.py b/FusionIIIT/notification/views.py index 0480575b8..788b18ce9 100644 --- a/FusionIIIT/notification/views.py +++ b/FusionIIIT/notification/views.py @@ -85,7 +85,15 @@ def central_mess_notif(sender, recipient, type, message=None): verb = "You have been added to the mess committee. " notify.send(sender=sender, recipient=recipient, url=url, module=module, verb=verb) + +def placement_cellNotif(sender, recipient, type): + url = 'placement:placement' + module = 'Placement Cell' + sender = sender + recipient = recipient + verb = '' + notify.send(sender=sender, recipient=recipient, url=url, module=module, verb=verb) def visitors_hostel_notif(sender, recipient, type): url='visitorhostel:visitorhostel' @@ -148,6 +156,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 " diff --git a/FusionIIIT/templates/complaintModule/add_workers.html b/FusionIIIT/templates/complaintModule/add_workers.html index 842d4397a..969fad127 100644 --- a/FusionIIIT/templates/complaintModule/add_workers.html +++ b/FusionIIIT/templates/complaintModule/add_workers.html @@ -2,16 +2,16 @@ {% block lodgecomplaint %} {% comment %}The tab menu starts here!{% endcomment %} -