Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions FusionIIIT/Fusion/middleware/custom_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.contrib.auth.signals import user_logged_in
from django.dispatch import receiver
from applications.globals.models import (ExtraInfo, Feedback, HoldsDesignation,
Issue, IssueImage, DepartmentInfo)
Issue, IssueImage, DepartmentInfo,ModuleAccess)
from django.shortcuts import get_object_or_404, redirect, render

def user_logged_in_middleware(get_response):
Expand Down Expand Up @@ -35,7 +35,19 @@ def user_logged_in_handler(sender, user, request, **kwargs):
print(i)

request.session['currentDesignationSelected'] = designation[0]
request.session['allDesignations'] = designation
request.session['allDesignations'] = designation
first_designation = designation[0]
module_access = ModuleAccess.objects.filter(designation=first_designation).first()

if module_access:
access_rights = {}

field_names = [field.name for field in ModuleAccess._meta.get_fields() if field.name not in ['id', 'designation']]

for field_name in field_names:
access_rights[field_name] = getattr(module_access, field_name)

request.session['moduleAccessRights'] = access_rights
print("logged iN")

# Set the flag in the session to indicate that the function has bee+n executed
Expand All @@ -47,4 +59,4 @@ def middleware(request):
response = get_response(request)
return response

return middleware
return middleware
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

from django.db import migrations, models
import django.db.models.deletion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

import datetime
from django.db import migrations, models
Expand All @@ -12,8 +12,8 @@ class Migration(migrations.Migration):

dependencies = [
('globals', '0001_initial'),
('programme_curriculum', '0001_initial'),
('academic_information', '0001_initial'),
('programme_curriculum', '0001_initial'),
]

operations = [
Expand Down
27 changes: 12 additions & 15 deletions FusionIIIT/applications/central_mess/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

import applications.central_mess.models
import datetime
Expand Down Expand Up @@ -149,6 +149,17 @@ class Migration(migrations.Migration):
('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')),
],
),
migrations.CreateModel(
name='Payments',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('amount_paid', models.IntegerField(default=0)),
('payment_month', models.CharField(default=applications.central_mess.models.current_month, max_length=20)),
('payment_year', models.IntegerField(default=applications.central_mess.models.current_year)),
('payment_date', models.DateField(default=datetime.date(2024, 6, 19))),
('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')),
],
),
migrations.CreateModel(
name='Mess_minutes',
fields=[
Expand Down Expand Up @@ -192,20 +203,6 @@ class Migration(migrations.Migration):
('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')),
],
),
migrations.CreateModel(
name='Payments',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('amount_paid', models.IntegerField(default=0)),
('payment_month', models.CharField(default=applications.central_mess.models.current_month, max_length=20)),
('payment_year', models.IntegerField(default=applications.central_mess.models.current_year)),
('payment_date', models.DateField(default=datetime.date(2024, 4, 27))),
('student_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='academic_information.student')),
],
options={
'unique_together': {('student_id', 'payment_date')},
},
),
migrations.CreateModel(
name='Monthly_bill',
fields=[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

from django.db import migrations, models
import django.db.models.deletion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

import datetime
from django.db import migrations, models
Expand All @@ -10,8 +10,8 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
('globals', '0001_initial'),
('academic_information', '0001_initial'),
('globals', '0001_initial'),
]

operations = [
Expand Down
15 changes: 13 additions & 2 deletions FusionIIIT/applications/department/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2023-03-15 18:53
# Generated by Django 3.1.5 on 2024-06-19 22:14

import datetime
from django.db import migrations, models
Expand Down Expand Up @@ -28,11 +28,22 @@ class Migration(migrations.Migration):
('request_maker', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='globals.extrainfo')),
],
),
migrations.CreateModel(
name='Information',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('phone_number', models.BigIntegerField()),
('email', models.CharField(max_length=200)),
('facilites', models.TextField()),
('labs', models.TextField()),
('department', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='globals.departmentinfo')),
],
),
migrations.CreateModel(
name='Announcements',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('ann_date', models.DateTimeField(default='04-04-2021')),
('ann_date', models.DateTimeField(auto_now_add=True)),
('message', models.CharField(max_length=200)),
('batch', models.CharField(default='Year-1', max_length=40)),
('department', models.CharField(default='ALL', max_length=40)),
Expand Down
2 changes: 1 addition & 1 deletion FusionIIIT/applications/eis/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

import datetime
from django.conf import settings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

from django.conf import settings
from django.db import migrations, models
Expand All @@ -10,8 +10,8 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
('globals', '0001_initial'),
('auth', '0012_alter_user_first_name_max_length'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

from django.conf import settings
from django.db import migrations, models
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

from django.db import migrations, models
import django.db.models.deletion
Expand Down
2 changes: 1 addition & 1 deletion FusionIIIT/applications/feeds/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

from django.conf import settings
from django.db import migrations, models
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

from django.conf import settings
from django.db import migrations, models
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

from django.db import migrations, models

Expand Down
30 changes: 28 additions & 2 deletions FusionIIIT/applications/globals/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

import applications.globals.models
import datetime
Expand Down Expand Up @@ -50,6 +50,32 @@ class Migration(migrations.Migration):
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
migrations.CreateModel(
name='ModuleAccess',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('designation', models.CharField(max_length=155)),
('program_and_curriculum', models.BooleanField(default=False)),
('course_registration', models.BooleanField(default=False)),
('course_management', models.BooleanField(default=False)),
('other_academics', models.BooleanField(default=False)),
('spacs', models.BooleanField(default=False)),
('department', models.BooleanField(default=False)),
('examinations', models.BooleanField(default=False)),
('hr', models.BooleanField(default=False)),
('iwd', models.BooleanField(default=False)),
('complaint_management', models.BooleanField(default=False)),
('fts', models.BooleanField(default=False)),
('purchase_and_store', models.BooleanField(default=False)),
('rspc', models.BooleanField(default=False)),
('hostel_management', models.BooleanField(default=False)),
('mess_management', models.BooleanField(default=False)),
('gymkhana', models.BooleanField(default=False)),
('placement_cell', models.BooleanField(default=False)),
('visitor_hostel', models.BooleanField(default=False)),
('phc', models.BooleanField(default=False)),
],
),
migrations.CreateModel(
name='Faculty',
fields=[
Expand Down Expand Up @@ -106,7 +132,7 @@ class Migration(migrations.Migration):
('working', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='current_designation', to=settings.AUTH_USER_MODEL)),
],
options={
'unique_together': {('user', 'designation'), ('working', 'designation')},
'unique_together': {('working', 'designation'), ('user', 'designation')},
},
),
]
27 changes: 27 additions & 0 deletions FusionIIIT/applications/globals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,30 @@ class Issue(models.Model):


""" End of feedback and bug report models"""



class ModuleAccess(models.Model):
designation = models.CharField(max_length=155)
program_and_curriculum = models.BooleanField(default=False)
course_registration = models.BooleanField(default=False)
course_management = models.BooleanField(default=False)
other_academics = models.BooleanField(default=False)
spacs = models.BooleanField(default=False)
department = models.BooleanField(default=False)
examinations = models.BooleanField(default=False)
hr = models.BooleanField(default=False)
iwd = models.BooleanField(default=False)
complaint_management = models.BooleanField(default=False)
fts = models.BooleanField(default=False)
purchase_and_store = models.BooleanField(default=False)
rspc = models.BooleanField(default=False)
hostel_management = models.BooleanField(default=False)
mess_management = models.BooleanField(default=False)
gymkhana = models.BooleanField(default=False)
placement_cell = models.BooleanField(default=False)
visitor_hostel = models.BooleanField(default=False)
phc = models.BooleanField(default=False)

def __str__(self):
return self.designation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 16 additions & 4 deletions FusionIIIT/applications/globals/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from applications.academic_information.models import Student
from applications.globals.forms import IssueForm, WebFeedbackForm
from applications.globals.models import (ExtraInfo, Feedback, HoldsDesignation,
Issue, IssueImage, DepartmentInfo)
Issue, IssueImage, DepartmentInfo,ModuleAccess)
from applications.gymkhana.views import coordinator_club
from applications.placement_cell.forms import (AddAchievement, AddCourse,
AddEducation, AddExperience,
Expand Down Expand Up @@ -745,7 +745,8 @@ def dashboard(request):
hall_warden_user = []
for warden in hall_wardens:
hall_warden_user.append(warden.faculty.id.user)

print("modules are")
print(request.session.get('moduleAccessRights'))
context={
'notifications':notifs,
'Curr_desig' : roll_,
Expand Down Expand Up @@ -1267,8 +1268,19 @@ def update_global_variable(request):
if request.method == 'POST':
selected_option = request.POST.get('dropdown')
request.session['currentDesignationSelected'] = selected_option
module_access = ModuleAccess.objects.filter(designation=selected_option).first()
if module_access:
access_rights = {}

field_names = [field.name for field in ModuleAccess._meta.get_fields() if field.name not in ['id', 'designation']]

for field_name in field_names:
access_rights[field_name] = getattr(module_access, field_name)

request.session['moduleAccessRights'] = access_rights

print(selected_option)
print(request.session['currentDesignationSelected'])
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/'))
return HttpResponseRedirect('/dashboard')
# Redirect to home if not a POST request or some issue occurs
return HttpResponseRedirect(reverse('home'))
return HttpResponseRedirect(reverse('home'))
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

from django.conf import settings
from django.db import migrations, models
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

import datetime
from django.db import migrations, models
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

from django.conf import settings
from django.db import migrations, models
Expand Down
2 changes: 1 addition & 1 deletion FusionIIIT/applications/hr2/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

from django.conf import settings
import django.core.validators
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

from django.db import migrations, models
import django.db.models.deletion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

import datetime
from django.db import migrations, models
Expand Down
4 changes: 2 additions & 2 deletions FusionIIIT/applications/leave/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

from django.conf import settings
from django.db import migrations, models
Expand All @@ -10,8 +10,8 @@ class Migration(migrations.Migration):
initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('globals', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.1.5 on 2024-04-27 23:48
# Generated by Django 3.1.5 on 2024-06-19 22:14

import datetime
from django.db import migrations, models
Expand All @@ -12,8 +12,8 @@ class Migration(migrations.Migration):
dependencies = [
('globals', '0001_initial'),
('academic_information', '0001_initial'),
('filetracking', '0001_initial'),
('leave', '0001_initial'),
('filetracking', '0001_initial'),
]

operations = [
Expand Down
Loading