From bf36bb6e264ce3f6ce1679848f108a7d78753b9c Mon Sep 17 00:00:00 2001 From: amod Date: Wed, 27 Jul 2022 15:10:14 +0530 Subject: [PATCH 1/2] changed add_wardens to add_or_update --- swd/main/views.py | 48 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/swd/main/views.py b/swd/main/views.py index 57141775..93a2c810 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 @@ -2502,6 +2503,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 = {} @@ -2530,17 +2533,40 @@ 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." From 0f5bf952680e4552d3989112ed8cc49aeef70d7c Mon Sep 17 00:00:00 2001 From: amod Date: Fri, 29 Jul 2022 01:55:15 +0530 Subject: [PATCH 2/2] modified html and css to the new format --- swd/main/views.py | 3 +- swd/templates/contact.html | 223 ++++++++++++------------------------- 2 files changed, 71 insertions(+), 155 deletions(-) diff --git a/swd/main/views.py b/swd/main/views.py index 93a2c810..b1fb55ae 100644 --- a/swd/main/views.py +++ b/swd/main/views.py @@ -1766,7 +1766,8 @@ def sac(request): def contact(request): context = { - 'warden' : Warden.objects.all() + 'warden' : Warden.objects.all(), + 'sid': HostelSuperintendent.objects.all() } return render(request,"contact.html",context) diff --git a/swd/templates/contact.html b/swd/templates/contact.html index 6bd2da3a..c0621203 100644 --- a/swd/templates/contact.html +++ b/swd/templates/contact.html @@ -5,192 +5,107 @@
-

Contacts

-
- - - - - - - - - - - -
Country Code STD Code
91 0832
-
-

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.)
- - - - - - - - - - - - - - - - - - - - - - - - - - + {% for w in sid.all|dictsort:"hostel" %} + {% if w.chamber|slice:"1:2" == "H" %} + + + + + {% endif %} + {% endfor %} - - - - - - - - +
Mr. S.Y.MuralidharaSenior Office SuperintendentsymuralidharaB-21725801472580715
Mrs. Sonali Malik Hostel SuperintendentsmallikB-21625801462580756
Mr. Viren DhamaskarAssistant Hostel SuperintendentvirendAH1-15425806222580527
{{ w.hostel }}

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

Mr. Shridhar PatilAssistant Hostel SuperintendentshridharpAH4-10125806212580528

- - Mr. Ajay Sharma - Assistant Hostel Superintendent - ajays - DH6 - 2580624 - 2580529 - +
+

Assistant Superintendents

+
+ - - - - - - - + {% for w in sid.all|dictsort:"hostel" %} + {% if w.chamber|slice:"1:2" != "H" %} + + + + + {% endif %} + {% endfor %}
Mrs. Savy PalAssistant Hostel SuperintendentsavypCH725806232580526
{{ w.hostel }}

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


-

Wardens

+

Boys Hostel Wardens

- - - - - - - - - +
Name Function EmailChamber No.Tel:(Off.)Tel:(Res.)
{% for w in warden.all|dictsort:"hostel" %} - - - - - - - + {% if w.hostel != "CH4" and w.hostel != "CH7" and w.hostel != "CH5" %} + + + + + {% endif %} {% 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
+

Girls Hostel Wardens

+
+
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
+ + {% for w in warden.all|dictsort:"hostel" %} + {% if w.hostel == "CH4" or w.hostel == "CH7" or w.hostel == "CH5" %} + + + + + {% endif %} + {% endfor %} - - - - - - -
{{ w.hostel }}

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

Mr.Santosh Kumar BiswalGeneral, Lost & FoundB-102+91 8956271338
- -
+
+
+