Skip to content

Commit

Permalink
Merge branch 'ac-final' of github.com:FusionIIIT/Fusion into ac-7
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhatsuman committed Apr 17, 2024
2 parents 4956f20 + 29f6d2a commit b49e3a1
Show file tree
Hide file tree
Showing 574 changed files with 42,378 additions and 10,351 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ node_modules/

FusionIIIT/static/
package-lock.json


.DS_Store

5 changes: 5 additions & 0 deletions FusionIIIT/Fusion/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def global_vars(request):
return {
'global_var': request.session.get('currentDesignationSelected', 'default_value'),
'global_var2': request.session.get('allDesignations', 'default_value2'),
}
50 changes: 50 additions & 0 deletions FusionIIIT/Fusion/middleware/custom_middleware.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# custom_middleware.py
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)
from django.shortcuts import get_object_or_404, redirect, render

def user_logged_in_middleware(get_response):
@receiver(user_logged_in)
def user_logged_in_handler(sender, user, request, **kwargs):
if 'function_executed' not in request.session:
# Run the function only if the flag is not set
# Assuming user is a model with the desired data field, retrieve the data
# For example, if your User model has a field named 'custom_field', you can access it like:
if user.is_authenticated:
desig = list(HoldsDesignation.objects.select_related('user','working','designation').all().filter(working = request.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=request.user)

designation=[]
if str(user.extrainfo.user_type) == "student":
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)

request.session['currentDesignationSelected'] = designation[0]
request.session['allDesignations'] = designation
print("logged iN")

# Set the flag in the session to indicate that the function has bee+n executed
request.session['function_executed'] = True

def middleware(request):
if request.user.is_authenticated:
user_logged_in_handler(request.user, request.user, request)
response = get_response(request)
return response

return middleware
13 changes: 8 additions & 5 deletions FusionIIIT/Fusion/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
'django.contrib.staticfiles',
'django.contrib.sites',
'django.contrib.humanize',

'django_crontab',
'corsheaders',

'applications.eis',
Expand Down Expand Up @@ -164,21 +164,23 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'Fusion.middleware.custom_middleware.user_logged_in_middleware',
]

ROOT_URLCONF = 'Fusion.urls'

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': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'Fusion.context_processors.global_vars',
],
},
},
Expand Down Expand Up @@ -255,9 +257,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
Expand All @@ -278,5 +280,6 @@
YOUTUBE_DATA_API_KEY = 'api_key'



CORS_ORIGIN_ALLOW_ALL = True
ALLOW_PASS_RESET = True
ALLOW_PASS_RESET = True
12 changes: 11 additions & 1 deletion FusionIIIT/Fusion/settings/development.py
Original file line number Diff line number Diff line change
@@ -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 = ['*']
Expand All @@ -16,9 +16,11 @@
}
}


REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
Expand Down Expand Up @@ -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'),
]
1 change: 0 additions & 1 deletion FusionIIIT/applications/academic_information/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ class Curriculum_InstructorAdmin(admin.ModelAdmin):
admin.site.register(Holiday)
admin.site.register(Curriculum,CurriculumAdmin)

#Hello!
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class Meta:

class CurriculumSerializer(serializers.ModelSerializer):
course_id = CourseSerializer()

class Meta:
model = Curriculum
fields = ('curriculum_id','course_code','course_id','credits','course_type',
Expand Down
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-04-15 23:58

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

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

operations = [
Expand Down Expand Up @@ -117,8 +117,8 @@ class Migration(migrations.Migration):
('batch', models.IntegerField(default=2016)),
('cpi', models.FloatField(default=0)),
('category', models.CharField(choices=[('GEN', 'General'), ('SC', 'Scheduled Castes'), ('ST', 'Scheduled Tribes'), ('OBC', 'Other Backward Classes')], max_length=10)),
('father_name', models.CharField(default='', max_length=40)),
('mother_name', models.CharField(default='', max_length=40)),
('father_name', models.CharField(default='', max_length=40, null=True)),
('mother_name', models.CharField(default='', max_length=40, null=True)),
('hall_no', models.IntegerField(default=0)),
('room_no', models.CharField(blank=True, max_length=10, null=True)),
('specialization', models.CharField(choices=[('Power and Control', 'Power and Control'), ('Microwave and Communication Engineering', 'Microwave and Communication Engineering'), ('Micro-nano Electronics', 'Micro-nano Electronics'), ('CAD/CAM', 'CAD/CAM'), ('Design', 'Design'), ('Manufacturing', 'Manufacturing'), ('CSE', 'CSE'), ('Mechatronics', 'Mechatronics'), ('MDes', 'MDes'), ('None', 'None')], default='', max_length=40, null=True)),
Expand Down
26 changes: 23 additions & 3 deletions FusionIIIT/applications/academic_information/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,35 @@ class Constants:


class Student(models.Model):

'''
Current Purpose : To store information pertinent to a user who is also a student
ATTRIBUTES :
id(globals.ExtraInfo) - one to one unique reference to the nominal details of the student[not nullable]
program(char) - to store the programme (eg: Btech Mtech)
batch(Integer) - to store the batch year(eg 2019)
batch_id(programme_curriculum.Batch) - reference to the Batch collective details(foreign key, can be null)
cpi(Float) - to store the current CPI of the student
category - to store the details about category of a sutdent (General/OBC etc)[not nullable]
father_name(char) - father's name
mother_name(char) - mother's name
hall_no(integer) - the hostel number in which the student has been alloted a room
room_no(char) - the room.no of the student
specialization - to dentote the specialization for MTECH students[null is allowed]
cur_sem_no(integer) - the current semester of the student
'''
id = models.OneToOneField(ExtraInfo, on_delete=models.CASCADE, primary_key=True)
programme = models.CharField(max_length=10, choices=Constants.PROGRAMME)
batch = models.IntegerField(default=2016)
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='')
Expand Down
Loading

0 comments on commit b49e3a1

Please sign in to comment.