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..3beed128 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,11 +1780,62 @@ 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) +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 + + context = { + 'mess_data': mess_data + } + + return render(request, "mess_info.html", context) + def studentDetails(request,id=None): option = get_base_template(request) if request.user.is_authenticated: @@ -2506,10 +2558,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() @@ -2517,6 +2570,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 = {} @@ -2531,7 +2586,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: @@ -2545,25 +2601,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
-
- - 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' %} diff --git a/swd/templates/mess_info.html b/swd/templates/mess_info.html new file mode 100644 index 00000000..d147ab97 --- /dev/null +++ b/swd/templates/mess_info.html @@ -0,0 +1,34 @@ +{% extends 'indexbase.html' %} + +{% block content %} +
+
+ {% for month_and_year, messoptions in mess_data.items reversed %} +

Mess Statistics for {{ month_and_year }}

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

+
+ {% endfor %} +
+
+ + +{% endblock %} \ No newline at end of file