From 26f1574ec9f9f598b858c52ee6bee52514a0ffbf Mon Sep 17 00:00:00 2001 From: robo-mop Date: Tue, 20 Sep 2022 13:48:21 +0530 Subject: [PATCH 1/9] Create Dashboard Popup Added a popup to be shown on students' dashboards telling them to check notices --- swd/templates/dashboard.html | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/swd/templates/dashboard.html b/swd/templates/dashboard.html index 267edd2a..07e023ec 100644 --- a/swd/templates/dashboard.html +++ b/swd/templates/dashboard.html @@ -3,7 +3,37 @@ {% block content %} + +
+
+ REMINDER
+ Regularly check SWD notices and documents - late emails and missed deadlines are unacceptable +

Recent Notices

{% include 'notice.html' %} {% include 'storeitems.html' %} From 90de4776c24d73925761cac13b34dc6e5028e878 Mon Sep 17 00:00:00 2001 From: amod Date: Fri, 23 Sep 2022 03:20:56 +0530 Subject: [PATCH 2/9] Added mess stats --- swd/main/urls.py | 2 +- swd/main/views.py | 24 ++++++++++++++++++++++++ swd/templates/mess_info.html | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 swd/templates/mess_info.html diff --git a/swd/main/urls.py b/swd/main/urls.py index 4feabfdb..b97abcc0 100644 --- a/swd/main/urls.py +++ b/swd/main/urls.py @@ -57,7 +57,7 @@ url(r'address_dashboard/', views.address_approval_dashboard, name='address_approval_dashboard'), url(r'^admin/import_cgpa/', views.import_cgpa, name='import_cgpa'), - + url(r'^admin/mess_info/',views.mess_info, name='mess_info'), url(r'^admin/add_new_students/', views.add_new_students, name='add_new_students'), url(r'^admin/add_new_wardens/', views.add_wardens, name='add_wardens'), url(r'^admin/add_new_superintendents/', views.add_superintendents, name='add_superintendents'), diff --git a/swd/main/views.py b/swd/main/views.py index a0c4036f..ae2f3773 100644 --- a/swd/main/views.py +++ b/swd/main/views.py @@ -1782,6 +1782,30 @@ def contact(request): } return render(request,"contact.html",context) +def mess_info(request): + + months = {} + students=MessOption.objects.all() + + for st in students: + m=st.monthYear.strftime('%B') + y=st.monthYear.strftime('%Y') + months[f"{m} {y}"]=[0,0,0] + for st in students: + m=st.monthYear.strftime('%B') + y=st.monthYear.strftime('%Y') + if st.mess=="A": + months[f"{m} {y}"][0]+=1 + elif st.mess=="D": + months[f"{m} {y}"][1]+=1 + elif st.mess=="C": + months[f"{m} {y}"][2]+=1 + context = { + 'months':months + } + print(months) + return render(request,"mess_info.html",context) + def studentDetails(request,id=None): option = get_base_template(request) if request.user.is_authenticated: diff --git a/swd/templates/mess_info.html b/swd/templates/mess_info.html new file mode 100644 index 00000000..d34a55fe --- /dev/null +++ b/swd/templates/mess_info.html @@ -0,0 +1,36 @@ +{% extends 'indexbase.html' %} {% block content %} + +
+ + +
+ {% for k,v in months.items %} +

Mess Statistics for {{k}}

+
+ + + + + + + + + + + + + + + + + + +
MessEnrolled
A mess{{v.0}}
C mess{{v.1}}
D mess{{v.2}}

+
+ {% endfor %} +
+ +
+ + +{% endblock %} \ No newline at end of file From c1891a7fb6c8c90325ca015e1fbb91f2055919fa Mon Sep 17 00:00:00 2001 From: amod Date: Fri, 23 Sep 2022 03:20:56 +0530 Subject: [PATCH 3/9] Added mess stats --- swd/main/urls.py | 2 +- swd/main/views.py | 24 ++++++++++++++++++++++++ swd/templates/mess_info.html | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 swd/templates/mess_info.html diff --git a/swd/main/urls.py b/swd/main/urls.py index 4feabfdb..b97abcc0 100644 --- a/swd/main/urls.py +++ b/swd/main/urls.py @@ -57,7 +57,7 @@ url(r'address_dashboard/', views.address_approval_dashboard, name='address_approval_dashboard'), url(r'^admin/import_cgpa/', views.import_cgpa, name='import_cgpa'), - + url(r'^admin/mess_info/',views.mess_info, name='mess_info'), url(r'^admin/add_new_students/', views.add_new_students, name='add_new_students'), url(r'^admin/add_new_wardens/', views.add_wardens, name='add_wardens'), url(r'^admin/add_new_superintendents/', views.add_superintendents, name='add_superintendents'), diff --git a/swd/main/views.py b/swd/main/views.py index a0c4036f..ae2f3773 100644 --- a/swd/main/views.py +++ b/swd/main/views.py @@ -1782,6 +1782,30 @@ def contact(request): } return render(request,"contact.html",context) +def mess_info(request): + + months = {} + students=MessOption.objects.all() + + for st in students: + m=st.monthYear.strftime('%B') + y=st.monthYear.strftime('%Y') + months[f"{m} {y}"]=[0,0,0] + for st in students: + m=st.monthYear.strftime('%B') + y=st.monthYear.strftime('%Y') + if st.mess=="A": + months[f"{m} {y}"][0]+=1 + elif st.mess=="D": + months[f"{m} {y}"][1]+=1 + elif st.mess=="C": + months[f"{m} {y}"][2]+=1 + context = { + 'months':months + } + print(months) + return render(request,"mess_info.html",context) + def studentDetails(request,id=None): option = get_base_template(request) if request.user.is_authenticated: diff --git a/swd/templates/mess_info.html b/swd/templates/mess_info.html new file mode 100644 index 00000000..d34a55fe --- /dev/null +++ b/swd/templates/mess_info.html @@ -0,0 +1,36 @@ +{% extends 'indexbase.html' %} {% block content %} + +
+ + +
+ {% for k,v in months.items %} +

Mess Statistics for {{k}}

+
+ + + + + + + + + + + + + + + + + + +
MessEnrolled
A mess{{v.0}}
C mess{{v.1}}
D mess{{v.2}}

+
+ {% endfor %} +
+ +
+ + +{% endblock %} \ No newline at end of file From aae0aa4f1c92a5cbee65a4e82f049f0b79e422ae Mon Sep 17 00:00:00 2001 From: robo-mop Date: Fri, 23 Sep 2022 22:09:02 +0530 Subject: [PATCH 4/9] Refactoring + Readability --- swd/main/views.py | 46 +++++++++++++++++++++--------------- swd/templates/mess_info.html | 16 ++++++------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/swd/main/views.py b/swd/main/views.py index ae2f3773..d5f74b5f 100644 --- a/swd/main/views.py +++ b/swd/main/views.py @@ -1783,28 +1783,36 @@ def contact(request): return render(request,"contact.html",context) def mess_info(request): + """ + Renders 'mess_info.html' at 'admin/mess_info/' + """ + + mess_data = {} + messoptions = MessOption.objects.all() + + # Count students per mess per month + for messoption in messoptions: + month_name = messoption.monthYear.strftime('%B') + year = messoption.monthYear.strftime('%Y') + + month_year = f"{month_name}, {year}" + + # If there is no entry for this month+year, create a blank one + if not month_year in mess_data: + mess_data[month_year] = [0, 0, 0] + + if messoption.mess == "A": + mess_data[month_year][0] += 1 + elif messoption.mess=="D": + mess_data[month_year][1] += 1 + elif messoption.mess=="C": + mess_data[month_year][2] += 1 - months = {} - students=MessOption.objects.all() - - for st in students: - m=st.monthYear.strftime('%B') - y=st.monthYear.strftime('%Y') - months[f"{m} {y}"]=[0,0,0] - for st in students: - m=st.monthYear.strftime('%B') - y=st.monthYear.strftime('%Y') - if st.mess=="A": - months[f"{m} {y}"][0]+=1 - elif st.mess=="D": - months[f"{m} {y}"][1]+=1 - elif st.mess=="C": - months[f"{m} {y}"][2]+=1 context = { - 'months':months + 'mess_data': mess_data } - print(months) - return render(request,"mess_info.html",context) + + return render(request, "mess_info.html", context) def studentDetails(request,id=None): option = get_base_template(request) diff --git a/swd/templates/mess_info.html b/swd/templates/mess_info.html index d34a55fe..d147ab97 100644 --- a/swd/templates/mess_info.html +++ b/swd/templates/mess_info.html @@ -1,11 +1,10 @@ -{% extends 'indexbase.html' %} {% block content %} +{% extends 'indexbase.html' %} +{% block content %}
- -
- {% for k,v in months.items %} -

Mess Statistics for {{k}}

+ {% for month_and_year, messoptions in mess_data.items reversed %} +

Mess Statistics for {{ month_and_year }}

@@ -15,21 +14,20 @@ - + - + - +
A mess{{v.0}}{{ messoptions.0 }}
C mess{{v.1}}{{ messoptions.1 }}
D mess{{v.2}}{{ messoptions.2 }}

{% endfor %}
-
From 0cc558f92cf4a6daf0f1bc0d3ce588159ee1b24e Mon Sep 17 00:00:00 2001 From: amod Date: Sun, 9 Oct 2022 14:50:02 +0530 Subject: [PATCH 5/9] mess info + contact page --- swd/main/views.py | 84 +++++++++++--- swd/templates/contact.html | 219 ++++++++++++------------------------- 2 files changed, 136 insertions(+), 167 deletions(-) diff --git a/swd/main/views.py b/swd/main/views.py index ae2f3773..a74819e3 100644 --- a/swd/main/views.py +++ b/swd/main/views.py @@ -1,3 +1,4 @@ +from unicodedata import name from django.shortcuts import render, redirect from django.http import HttpResponse, HttpResponseForbidden from django.contrib.auth import authenticate, login, logout @@ -1777,8 +1778,27 @@ def sac(request): return render(request,"sac.html",{}) def contact(request): + sid = HostelSuperintendent.objects.all() + wa = Warden.objects.all() + sup=[] + asup=[] + bw=[] + gw=[] + for s in sid: + if s.chamber[1:2]=="H": + sup.append(s) + else: + asup.append(s) + for w in wa: + if w.hostel != "CH4" and w.hostel != "CH7" and w.hostel != "CH5": + bw.append(w) + else: + gw.append(w) context = { - 'warden' : Warden.objects.all() + 'sup': sup, + 'asup': asup, + 'bw':bw, + 'gw':gw } return render(request,"contact.html",context) @@ -2528,10 +2548,11 @@ def add_wardens(request): extension = xl_file.name.rsplit('.', 1)[1] if ('xls' != extension): if ('xlsx' != extension): - messages.error(request, "Please upload .xls or .xlsx file only") + messages.error( + request, "Please upload .xls or .xlsx file only") messages.add_message(request, - message_tag, - message_str) + message_tag, + message_str) return render(request, "add_students.html", {'header': "Add new wardens"}) fd, tmp = tempfile.mkstemp() @@ -2539,6 +2560,8 @@ def add_wardens(request): out.write(xl_file.read()) workbook = xlrd.open_workbook(tmp) + count_created = 0 + created = False count = 0 idx = 1 header = {} @@ -2553,7 +2576,8 @@ def add_wardens(request): idx = 0 continue # create User model first then Student model - emailID = row[header['Email:@goa.bits-pilani.ac.in']].value + "@goa.bits-pilani.ac.in" + emailID = row[header['Email:@goa.bits-pilani.ac.in'] + ].value + "@goa.bits-pilani.ac.in" username = emailID.split('@', 1)[0] password = User.objects.make_random_password() try: @@ -2567,25 +2591,49 @@ def add_wardens(request): email=emailID, password=password) - - warden = Warden.objects.create( - user=user, - name=row[header['Name']].value, - phone_off=str(int(row[header['Tel:(Off.)']].value)), - phone_res=str(int(row[header['Tel:(Res.)']].value)), - email=emailID, - chamber=row[header['Chamber No.']].value, - hostel=row[header['Function']].value, - ) - count = count + 1 + try: + updated_vals = { + 'name': row[header['Name']].value, + 'phone_off': str(int(row[header['Tel:(Off.)']].value)), + 'phone_res': str(int(row[header['Tel:(Res.)']].value)), + 'email': emailID, + 'chamber': row[header['Chamber No.']].value, + 'hostel': row[header['Function']].value, + } + try: + obj = Warden.objects.get(user=user) + for key, value in updated_vals.items(): + #print(f"{key}, {value}") + if (value): + setattr(obj, key, value) + obj.save() + except Warden.DoesNotExist: + obj = Warden( + user=user, + name=row[header['Name']].value, + phone_off=str( + int(row[header['Tel:(Off.)']].value)), + phone_res=str( + int(row[header['Tel:(Res.)']].value)), + email=emailID, + chamber=row[header['Chamber No.']].value, + hostel=row[header['Function']].value,) + obj.save() + created = True + if created: + count_created = count_created + 1 + else: + count = count + 1 + except Exception: + message_str + name + " failed" message_str = str(count) + " new wardens added." else: message_str = "No File Uploaded." if message_str is not '': messages.add_message(request, - message_tag, - message_str) + message_tag, + message_str) return render(request, "add_students.html", {'header': "Add new wardens"}) @user_passes_test(lambda u: u.is_superuser) diff --git a/swd/templates/contact.html b/swd/templates/contact.html index 6bd2da3a..f3d9bfe2 100644 --- a/swd/templates/contact.html +++ b/swd/templates/contact.html @@ -23,176 +23,97 @@

Faculty Incharge

- - - - - - - - +
Name Function Email:@goa.bits-pilani.ac.in Chamber No.Tel:(Off.)
- - - - - + + + - - - - - + + + +
Prof. Angshuman SarkarAssociate Dean, Student Welfare Divisionad.swdB-2132580261Associate Dean, Student Welfare Division

Name: Prof. Angshuman Sarkar
+ Email: ad.swd@goa.bits-pilani.ac.in
+ Contact No. (Office): +91 08322580149

Prof. Sukanta MondalChief WardenchiefwardenB-1112580149Chief Warden

Name: Prof. Sukanta Mondal
+ Email: chiefwarden@goa.bits-pilani.ac.in
+ Contact No. (Office): +91 08322580149


Superintendents

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
Name Function Email:@goa.bits-pilani.ac.in Chamber No.Tel:(Off.)Tel:(Res.)
Mr. S.Y.MuralidharaSenior Office SuperintendentsymuralidharaB-21725801472580715
Mrs. Sonali Malik Hostel SuperintendentsmallikB-21625801462580756
Mr. Viren DhamaskarAssistant Hostel SuperintendentvirendAH1-15425806222580527
Mr. Shridhar PatilAssistant Hostel SuperintendentshridharpAH4-10125806212580528
Mr. Ajay SharmaAssistant Hostel SuperintendentajaysDH625806242580529
Mrs. Savy PalAssistant Hostel SuperintendentsavypCH725806232580526
+ {% for w in sup|dictsort:"hostel" %} + + + + + + {% endfor %} +
{{ w.hostel }}

Name: {{ w.name }}
+ Email: {{ w.email }}
+ Contact No: (O):{{ w.phone_off|floatformat }}, (R):{{ w.phone_res|floatformat }}
+ Chamber: {{ w.chamber }}


+ +
+

Assistant Superintendents

+
+ + + {% for w in asup|dictsort:"hostel" %} + + + + + + {% endfor %} + +
{{ w.hostel }}

Name: {{ w.name }}
+ Email: {{ w.email }}
+ Contact No: (O):{{ w.phone_off|floatformat }}, (R):{{ w.phone_res|floatformat }}
+ Chamber: {{ w.chamber }}


+ +
+

Boys Hostel Wardens

+
+ + + + {% for w in bw|dictsort:"hostel" %} + + + + + {% endfor %}
{{ w.hostel }}

Name: {{ w.name }}
+ Email: {{ w.email }}
+ Contact No: (O):{{ w.phone_off|floatformat }}, (R):{{ w.phone_res|floatformat }}
+ Chamber: {{ w.chamber }}


-
-

Wardens

+ +
+

Girls Hostel Wardens

- - - - - - - - - +
Name Function EmailChamber No.Tel:(Off.)Tel:(Res.)
- {% for w in warden.all|dictsort:"hostel" %} - - - - - - - + {% for w in gw|dictsort:"hostel" %} + + + + {% endfor %} -
{{ w.name }}{{ w.hostel }}{{ w.email }}{{ w.chamber }}{{ w.phone_off|floatformat }}{{ w.phone_res|floatformat }}
{{ w.hostel }}

Name: {{ w.name }}
+ Email: {{ w.email }}
+ Contact No: (O):{{ w.phone_off|floatformat }}, (R):{{ w.phone_res|floatformat }}
+ Chamber: {{ w.chamber }}


-

Staff Members

- Email: swd@goa.bits-pilani.ac.in - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name Help/QueriesOffice No.Tel:(Off.)
Ms.Namrata SawantRefund, Dues.B-1022580148
Ms.Kalpita DesaiFees Receipts, Dup Id Card.B-1022580148
Ms.Sonali NaikScholarship, Migration.B-1022580157
Ms.Sunita PrabhudesaiCertificates, Semester Fees.B-1022580157
Mr.Santosh Kumar BiswalGeneral, Lost & FoundB-102+91 8956271338
-
- -
From 9175d80bd76a848101959e433eebfe7546f96adc Mon Sep 17 00:00:00 2001 From: robo-mop Date: Tue, 20 Sep 2022 13:48:21 +0530 Subject: [PATCH 6/9] Create Dashboard Popup Added a popup to be shown on students' dashboards telling them to check notices --- swd/templates/dashboard.html | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/swd/templates/dashboard.html b/swd/templates/dashboard.html index 267edd2a..07e023ec 100644 --- a/swd/templates/dashboard.html +++ b/swd/templates/dashboard.html @@ -3,7 +3,37 @@ {% block content %} + +
+
+ REMINDER
+ Regularly check SWD notices and documents - late emails and missed deadlines are unacceptable +

Recent Notices

{% include 'notice.html' %} {% include 'storeitems.html' %} From d865ec78f3820c003b97f2522a501d84409d0a0c Mon Sep 17 00:00:00 2001 From: amod Date: Fri, 23 Sep 2022 03:20:56 +0530 Subject: [PATCH 7/9] Added mess stats --- swd/main/urls.py | 2 +- swd/main/views.py | 24 ++++++++++++++++++++++++ swd/templates/mess_info.html | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 swd/templates/mess_info.html diff --git a/swd/main/urls.py b/swd/main/urls.py index 4feabfdb..b97abcc0 100644 --- a/swd/main/urls.py +++ b/swd/main/urls.py @@ -57,7 +57,7 @@ url(r'address_dashboard/', views.address_approval_dashboard, name='address_approval_dashboard'), url(r'^admin/import_cgpa/', views.import_cgpa, name='import_cgpa'), - + url(r'^admin/mess_info/',views.mess_info, name='mess_info'), url(r'^admin/add_new_students/', views.add_new_students, name='add_new_students'), url(r'^admin/add_new_wardens/', views.add_wardens, name='add_wardens'), url(r'^admin/add_new_superintendents/', views.add_superintendents, name='add_superintendents'), diff --git a/swd/main/views.py b/swd/main/views.py index 58611956..bb441cc4 100644 --- a/swd/main/views.py +++ b/swd/main/views.py @@ -1784,6 +1784,30 @@ def contact(request): } return render(request,"contact.html",context) +def mess_info(request): + + months = {} + students=MessOption.objects.all() + + for st in students: + m=st.monthYear.strftime('%B') + y=st.monthYear.strftime('%Y') + months[f"{m} {y}"]=[0,0,0] + for st in students: + m=st.monthYear.strftime('%B') + y=st.monthYear.strftime('%Y') + if st.mess=="A": + months[f"{m} {y}"][0]+=1 + elif st.mess=="D": + months[f"{m} {y}"][1]+=1 + elif st.mess=="C": + months[f"{m} {y}"][2]+=1 + context = { + 'months':months + } + print(months) + return render(request,"mess_info.html",context) + def studentDetails(request,id=None): option = get_base_template(request) if request.user.is_authenticated: diff --git a/swd/templates/mess_info.html b/swd/templates/mess_info.html new file mode 100644 index 00000000..d34a55fe --- /dev/null +++ b/swd/templates/mess_info.html @@ -0,0 +1,36 @@ +{% extends 'indexbase.html' %} {% block content %} + +
+ + +
+ {% for k,v in months.items %} +

Mess Statistics for {{k}}

+
+ + + + + + + + + + + + + + + + + + +
MessEnrolled
A mess{{v.0}}
C mess{{v.1}}
D mess{{v.2}}

+
+ {% endfor %} +
+ +
+ + +{% endblock %} \ No newline at end of file From a1ae4ee4ffe0bcf91e036ce65122bd270e647acc Mon Sep 17 00:00:00 2001 From: amod Date: Sun, 9 Oct 2022 14:50:02 +0530 Subject: [PATCH 8/9] mess info + contact page --- swd/main/views.py | 84 +++++++++++--- swd/templates/contact.html | 219 ++++++++++++------------------------- 2 files changed, 136 insertions(+), 167 deletions(-) diff --git a/swd/main/views.py b/swd/main/views.py index bb441cc4..fe423003 100644 --- a/swd/main/views.py +++ b/swd/main/views.py @@ -1,3 +1,4 @@ +from unicodedata import name from django.shortcuts import render, redirect from django.http import HttpResponse, HttpResponseForbidden from django.contrib.auth import authenticate, login, logout @@ -1779,8 +1780,27 @@ def sac(request): return render(request,"sac.html",{}) def contact(request): + sid = HostelSuperintendent.objects.all() + wa = Warden.objects.all() + sup=[] + asup=[] + bw=[] + gw=[] + for s in sid: + if s.chamber[1:2]=="H": + sup.append(s) + else: + asup.append(s) + for w in wa: + if w.hostel != "CH4" and w.hostel != "CH7" and w.hostel != "CH5": + bw.append(w) + else: + gw.append(w) context = { - 'warden' : Warden.objects.all() + 'sup': sup, + 'asup': asup, + 'bw':bw, + 'gw':gw } return render(request,"contact.html",context) @@ -2530,10 +2550,11 @@ def add_wardens(request): extension = xl_file.name.rsplit('.', 1)[1] if ('xls' != extension): if ('xlsx' != extension): - messages.error(request, "Please upload .xls or .xlsx file only") + messages.error( + request, "Please upload .xls or .xlsx file only") messages.add_message(request, - message_tag, - message_str) + message_tag, + message_str) return render(request, "add_students.html", {'header': "Add new wardens"}) fd, tmp = tempfile.mkstemp() @@ -2541,6 +2562,8 @@ def add_wardens(request): out.write(xl_file.read()) workbook = xlrd.open_workbook(tmp) + count_created = 0 + created = False count = 0 idx = 1 header = {} @@ -2555,7 +2578,8 @@ def add_wardens(request): idx = 0 continue # create User model first then Student model - emailID = row[header['Email:@goa.bits-pilani.ac.in']].value + "@goa.bits-pilani.ac.in" + emailID = row[header['Email:@goa.bits-pilani.ac.in'] + ].value + "@goa.bits-pilani.ac.in" username = emailID.split('@', 1)[0] password = User.objects.make_random_password() try: @@ -2569,25 +2593,49 @@ def add_wardens(request): email=emailID, password=password) - - warden = Warden.objects.create( - user=user, - name=row[header['Name']].value, - phone_off=str(int(row[header['Tel:(Off.)']].value)), - phone_res=str(int(row[header['Tel:(Res.)']].value)), - email=emailID, - chamber=row[header['Chamber No.']].value, - hostel=row[header['Function']].value, - ) - count = count + 1 + try: + updated_vals = { + 'name': row[header['Name']].value, + 'phone_off': str(int(row[header['Tel:(Off.)']].value)), + 'phone_res': str(int(row[header['Tel:(Res.)']].value)), + 'email': emailID, + 'chamber': row[header['Chamber No.']].value, + 'hostel': row[header['Function']].value, + } + try: + obj = Warden.objects.get(user=user) + for key, value in updated_vals.items(): + #print(f"{key}, {value}") + if (value): + setattr(obj, key, value) + obj.save() + except Warden.DoesNotExist: + obj = Warden( + user=user, + name=row[header['Name']].value, + phone_off=str( + int(row[header['Tel:(Off.)']].value)), + phone_res=str( + int(row[header['Tel:(Res.)']].value)), + email=emailID, + chamber=row[header['Chamber No.']].value, + hostel=row[header['Function']].value,) + obj.save() + created = True + if created: + count_created = count_created + 1 + else: + count = count + 1 + except Exception: + message_str + name + " failed" message_str = str(count) + " new wardens added." else: message_str = "No File Uploaded." if message_str is not '': messages.add_message(request, - message_tag, - message_str) + message_tag, + message_str) return render(request, "add_students.html", {'header': "Add new wardens"}) @user_passes_test(lambda u: u.is_superuser) diff --git a/swd/templates/contact.html b/swd/templates/contact.html index 6bd2da3a..f3d9bfe2 100644 --- a/swd/templates/contact.html +++ b/swd/templates/contact.html @@ -23,176 +23,97 @@

Faculty Incharge

- - - - - - - - +
Name Function Email:@goa.bits-pilani.ac.in Chamber No.Tel:(Off.)
- - - - - + + + - - - - - + + + +
Prof. Angshuman SarkarAssociate Dean, Student Welfare Divisionad.swdB-2132580261Associate Dean, Student Welfare Division

Name: Prof. Angshuman Sarkar
+ Email: ad.swd@goa.bits-pilani.ac.in
+ Contact No. (Office): +91 08322580149

Prof. Sukanta MondalChief WardenchiefwardenB-1112580149Chief Warden

Name: Prof. Sukanta Mondal
+ Email: chiefwarden@goa.bits-pilani.ac.in
+ Contact No. (Office): +91 08322580149


Superintendents

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
Name Function Email:@goa.bits-pilani.ac.in Chamber No.Tel:(Off.)Tel:(Res.)
Mr. S.Y.MuralidharaSenior Office SuperintendentsymuralidharaB-21725801472580715
Mrs. Sonali Malik Hostel SuperintendentsmallikB-21625801462580756
Mr. Viren DhamaskarAssistant Hostel SuperintendentvirendAH1-15425806222580527
Mr. Shridhar PatilAssistant Hostel SuperintendentshridharpAH4-10125806212580528
Mr. Ajay SharmaAssistant Hostel SuperintendentajaysDH625806242580529
Mrs. Savy PalAssistant Hostel SuperintendentsavypCH725806232580526
+ {% for w in sup|dictsort:"hostel" %} + + + + + + {% endfor %} +
{{ w.hostel }}

Name: {{ w.name }}
+ Email: {{ w.email }}
+ Contact No: (O):{{ w.phone_off|floatformat }}, (R):{{ w.phone_res|floatformat }}
+ Chamber: {{ w.chamber }}


+ +
+

Assistant Superintendents

+
+ + + {% for w in asup|dictsort:"hostel" %} + + + + + + {% endfor %} + +
{{ w.hostel }}

Name: {{ w.name }}
+ Email: {{ w.email }}
+ Contact No: (O):{{ w.phone_off|floatformat }}, (R):{{ w.phone_res|floatformat }}
+ Chamber: {{ w.chamber }}


+ +
+

Boys Hostel Wardens

+
+ + + + {% for w in bw|dictsort:"hostel" %} + + + + + {% endfor %}
{{ w.hostel }}

Name: {{ w.name }}
+ Email: {{ w.email }}
+ Contact No: (O):{{ w.phone_off|floatformat }}, (R):{{ w.phone_res|floatformat }}
+ Chamber: {{ w.chamber }}


-
-

Wardens

+ +
+

Girls Hostel Wardens

- - - - - - - - - +
Name Function EmailChamber No.Tel:(Off.)Tel:(Res.)
- {% for w in warden.all|dictsort:"hostel" %} - - - - - - - + {% for w in gw|dictsort:"hostel" %} + + + + {% endfor %} -
{{ w.name }}{{ w.hostel }}{{ w.email }}{{ w.chamber }}{{ w.phone_off|floatformat }}{{ w.phone_res|floatformat }}
{{ w.hostel }}

Name: {{ w.name }}
+ Email: {{ w.email }}
+ Contact No: (O):{{ w.phone_off|floatformat }}, (R):{{ w.phone_res|floatformat }}
+ Chamber: {{ w.chamber }}


-

Staff Members

- Email: swd@goa.bits-pilani.ac.in - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Name Help/QueriesOffice No.Tel:(Off.)
Ms.Namrata SawantRefund, Dues.B-1022580148
Ms.Kalpita DesaiFees Receipts, Dup Id Card.B-1022580148
Ms.Sonali NaikScholarship, Migration.B-1022580157
Ms.Sunita PrabhudesaiCertificates, Semester Fees.B-1022580157
Mr.Santosh Kumar BiswalGeneral, Lost & FoundB-102+91 8956271338
-
- -
From ed4c0b61961e9309cf5da2ed0f16827693496495 Mon Sep 17 00:00:00 2001 From: robo-mop Date: Fri, 23 Sep 2022 22:09:02 +0530 Subject: [PATCH 9/9] Refactoring + Readability --- swd/main/views.py | 46 +++++++++++++++++++++--------------- swd/templates/mess_info.html | 16 ++++++------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/swd/main/views.py b/swd/main/views.py index fe423003..3beed128 100644 --- a/swd/main/views.py +++ b/swd/main/views.py @@ -1805,28 +1805,36 @@ def contact(request): return render(request,"contact.html",context) def mess_info(request): + """ + Renders 'mess_info.html' at 'admin/mess_info/' + """ + + mess_data = {} + messoptions = MessOption.objects.all() + + # Count students per mess per month + for messoption in messoptions: + month_name = messoption.monthYear.strftime('%B') + year = messoption.monthYear.strftime('%Y') + + month_year = f"{month_name}, {year}" + + # If there is no entry for this month+year, create a blank one + if not month_year in mess_data: + mess_data[month_year] = [0, 0, 0] + + if messoption.mess == "A": + mess_data[month_year][0] += 1 + elif messoption.mess=="D": + mess_data[month_year][1] += 1 + elif messoption.mess=="C": + mess_data[month_year][2] += 1 - months = {} - students=MessOption.objects.all() - - for st in students: - m=st.monthYear.strftime('%B') - y=st.monthYear.strftime('%Y') - months[f"{m} {y}"]=[0,0,0] - for st in students: - m=st.monthYear.strftime('%B') - y=st.monthYear.strftime('%Y') - if st.mess=="A": - months[f"{m} {y}"][0]+=1 - elif st.mess=="D": - months[f"{m} {y}"][1]+=1 - elif st.mess=="C": - months[f"{m} {y}"][2]+=1 context = { - 'months':months + 'mess_data': mess_data } - print(months) - return render(request,"mess_info.html",context) + + return render(request, "mess_info.html", context) def studentDetails(request,id=None): option = get_base_template(request) diff --git a/swd/templates/mess_info.html b/swd/templates/mess_info.html index d34a55fe..d147ab97 100644 --- a/swd/templates/mess_info.html +++ b/swd/templates/mess_info.html @@ -1,11 +1,10 @@ -{% extends 'indexbase.html' %} {% block content %} +{% extends 'indexbase.html' %} +{% block content %}
- -
- {% for k,v in months.items %} -

Mess Statistics for {{k}}

+ {% for month_and_year, messoptions in mess_data.items reversed %} +

Mess Statistics for {{ month_and_year }}

@@ -15,21 +14,20 @@ - + - + - +
A mess{{v.0}}{{ messoptions.0 }}
C mess{{v.1}}{{ messoptions.1 }}
D mess{{v.2}}{{ messoptions.2 }}

{% endfor %}
-