├── Main_App ├── __init__.py ├── migrations │ ├── __init__.py │ ├── 0003_auto_20240620_0924.py │ ├── 0002_notes_result.py │ └── 0001_initial.py ├── tests.py ├── static │ └── Main_App │ │ ├── images │ │ └── logo.png │ │ ├── js │ │ └── index.js │ │ └── css │ │ └── mycss.css ├── apps.py ├── templates │ ├── student │ │ ├── s_base.html │ │ ├── s_sidebar.html │ │ ├── s_viewresult.html │ │ ├── s_viewnotification.html │ │ ├── s_home.html │ │ ├── s_viewnotes.html │ │ └── s_profile.html │ ├── teacher │ │ ├── t_base.html │ │ ├── t_viewnotification.html │ │ ├── t_addnotification.html │ │ ├── t_deletenotes.html │ │ ├── t_deleteresult.html │ │ ├── t_viewnotes.html │ │ ├── t_deletenotification.html │ │ ├── t_viewresult.html │ │ ├── t_viewstudent.html │ │ ├── t_addresult.html │ │ ├── t_addnotes.html │ │ ├── t_home.html │ │ ├── t_sidebar.html │ │ ├── t_profile.html │ │ └── t_addstudent.html │ ├── admin │ │ ├── a_base.html │ │ ├── a_addnotification.html │ │ ├── a_viewnotes.html │ │ ├── a_managenotification.html │ │ ├── a_viewresult.html │ │ ├── a_addteacher.html │ │ ├── a_addresult.html │ │ ├── a_addnotes.html │ │ ├── a_profile.html │ │ ├── a_manageteacher.html │ │ ├── a_managestudent.html │ │ ├── a_editteacher.html │ │ ├── a_addstudent.html │ │ ├── a_home.html │ │ ├── a_sidebar.html │ │ └── a_editstudent.html │ ├── base │ │ ├── footer.html │ │ ├── header.html │ │ └── base.html │ └── loginpage.html ├── admin.py ├── EmailAuthentication.py ├── views.py ├── restrictions.py ├── models.py ├── v_student.py ├── v_teacher.py └── v_admin.py ├── Student_Management ├── __init__.py ├── asgi.py ├── wsgi.py ├── urls.py └── settings.py ├── Procfile ├── .gitignore ├── requirements.txt ├── render.yaml ├── .github └── workflows │ ├── pylint.yml │ └── django.yml ├── manage.py └── README.md /Main_App/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Main_App/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Student_Management/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Main_App/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | # This file needed for heroku deployment 2 | web: gunicorn Student_Management.wsgi 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | *.pot 3 | *.pyc 4 | __pycache__ 5 | __pycache__/ 6 | local_settings.py 7 | db.sqlite3 8 | media 9 | staticfiles -------------------------------------------------------------------------------- /Main_App/static/Main_App/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ursmaheshj/Student_Management/HEAD/Main_App/static/Main_App/images/logo.png -------------------------------------------------------------------------------- /Main_App/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class MainAppConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'Main_App' 7 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Django==3.2.6 2 | # psycopg2==2.9.2 Uncomment this and comment 'psycopg2-binary' if running on linux 3 | psycopg2-binary 4 | pywin32-ctypes==0.2.0 5 | sqlparse==0.4.1 6 | gunicorn==20.1.0 7 | whitenoise==5.3.0 8 | -------------------------------------------------------------------------------- /Main_App/templates/student/s_base.html: -------------------------------------------------------------------------------- 1 | {% extends 'base/base.html' %} 2 | 3 | {% block base %} 4 |
5 | {% include 'student/s_sidebar.html' %} 6 | 7 |
8 | {% include 'base/header.html' %} 9 | {% block content %}{% endblock content %} 10 | {% include 'base/footer.html' %} 11 | 12 |
13 |
14 | {% endblock base %} 15 | -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_base.html: -------------------------------------------------------------------------------- 1 | {% extends 'base/base.html' %} 2 | 3 | {% block base %} 4 |
5 | {% include 'teacher/t_sidebar.html' %} 6 | 7 |
8 | {% include 'base/header.html' %} 9 | {% block content %}{% endblock content %} 10 | {% include 'base/footer.html' %} 11 |
12 | 13 |
14 | {% endblock base %} 15 | -------------------------------------------------------------------------------- /Main_App/templates/admin/a_base.html: -------------------------------------------------------------------------------- 1 | {% extends 'base/base.html' %} 2 | 3 | {% block base %} 4 |
5 | {% include 'admin/a_sidebar.html' %} 6 | 7 |
8 | {% include 'base/header.html' %} 9 | {% block content %}{% endblock content %} 10 | {% include 'base/footer.html' %} 11 | 12 |
13 |
14 | {% endblock base %} 15 | 16 | 17 | -------------------------------------------------------------------------------- /Main_App/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.contrib.auth.admin import UserAdmin 3 | 4 | from Main_App.models import MyUser,Admin,Teacher,Student,Notification 5 | 6 | class UserModel(UserAdmin): 7 | pass 8 | 9 | # Register your models here. 10 | admin.register(MyUser,UserModel) 11 | admin.register(Admin) 12 | admin.register(Teacher) 13 | admin.register(Student) 14 | admin.register(Notification) -------------------------------------------------------------------------------- /Student_Management/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for Student_Management project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Student_Management.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /Student_Management/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for Student_Management project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Student_Management.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /Main_App/EmailAuthentication.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth import get_user_model 2 | from django.contrib.auth.backends import ModelBackend, UserModel 3 | 4 | class EmailAuth(ModelBackend): 5 | def authenticate(self, username=None, password=None, **kwargs): 6 | UserModel=get_user_model() 7 | try : 8 | user = UserModel.objects.get(email=username) 9 | except UserModel.DoesNotExist: 10 | return None 11 | else : 12 | if user.check_password(password): 13 | return user 14 | return None 15 | -------------------------------------------------------------------------------- /render.yaml: -------------------------------------------------------------------------------- 1 | # This file is required for deploying application to Render 2 | databases: 3 | - name: mysite 4 | databaseName: mysite 5 | user: mysite 6 | 7 | services: 8 | - type: web 9 | name: mysite 10 | env: python 11 | buildCommand: "./build.sh" 12 | startCommand: "gunicorn Student_Management.wsgi.application" 13 | envVars: 14 | - key: DATABASE_URL 15 | fromDatabase: 16 | name: mysite 17 | property: connectionString 18 | - key: SECRET_KEY 19 | generateValue: true 20 | - key: WEB_CONCURRENCY 21 | value: 4 22 | -------------------------------------------------------------------------------- /.github/workflows/pylint.yml: -------------------------------------------------------------------------------- 1 | name: Pylint 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | strategy: 9 | matrix: 10 | python-version: ["3.8", "3.9", "3.10"] 11 | steps: 12 | - uses: actions/checkout@v2 13 | - name: Set up Python ${{ matrix.python-version }} 14 | uses: actions/setup-python@v2 15 | with: 16 | python-version: ${{ matrix.python-version }} 17 | - name: Install dependencies 18 | run: | 19 | python -m pip install --upgrade pip 20 | pip install pylint 21 | - name: Analysing the code with pylint 22 | run: | 23 | pylint `ls -R|grep .py$|xargs` 24 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Student_Management.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /.github/workflows/django.yml: -------------------------------------------------------------------------------- 1 | name: Django CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | strategy: 14 | max-parallel: 4 15 | matrix: 16 | python-version: [3.7, 3.8, 3.9] 17 | 18 | steps: 19 | - uses: actions/checkout@v2 20 | - name: Set up Python ${{ matrix.python-version }} 21 | uses: actions/setup-python@v2 22 | with: 23 | python-version: ${{ matrix.python-version }} 24 | - name: Install Dependencies 25 | run: | 26 | python -m pip install --upgrade pip 27 | pip install -r requirements.txt 28 | - name: Run Tests 29 | run: | 30 | python manage.py test 31 | -------------------------------------------------------------------------------- /Main_App/migrations/0003_auto_20240620_0924.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.6 on 2024-06-20 03:54 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('Main_App', '0002_notes_result'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='student', 15 | name='medium', 16 | field=models.CharField(choices=[('Marathi', 'Marathi'), ('SemiEng', 'SemiEng'), ('CBSE', 'CBSE'), ('Foundation', 'Foundation')], default='Marathi', max_length=15), 17 | ), 18 | migrations.AlterField( 19 | model_name='student', 20 | name='std', 21 | field=models.CharField(choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10)], max_length=10), 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /Main_App/templates/base/footer.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Main_App/views.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth import authenticate,login,logout 2 | from django.http.response import HttpResponse, HttpResponseRedirect 3 | from django.shortcuts import render 4 | 5 | from django.contrib import messages 6 | from Main_App.EmailAuthentication import EmailAuth 7 | 8 | # Create your views here. 9 | 10 | def loginpage(request): 11 | return render(request,'loginpage.html') 12 | 13 | def loginuser(request): 14 | if request.method != "POST": 15 | return HttpResponse("

Method not allowed

") 16 | else : 17 | user = EmailAuth.authenticate(request,username=request.POST.get('email'),password=request.POST.get('password')) 18 | if user!=None: 19 | login(request,user) 20 | if user.user_type=='1': 21 | return HttpResponseRedirect('/adminhome') 22 | elif user.user_type=='2': 23 | return HttpResponseRedirect('/teacherhome') 24 | elif user.user_type=='3' : 25 | return HttpResponseRedirect('/studenthome') 26 | else : 27 | return HttpResponse("Invalid user type") 28 | else : 29 | messages.error(request,"Invalid login details..!") 30 | return HttpResponseRedirect("/loginpage") 31 | 32 | def logoutuser(request): 33 | logout(request) 34 | return HttpResponseRedirect('/') -------------------------------------------------------------------------------- /Main_App/templates/base/header.html: -------------------------------------------------------------------------------- 1 | 2 | 39 | -------------------------------------------------------------------------------- /Main_App/templates/student/s_sidebar.html: -------------------------------------------------------------------------------- 1 | 49 | -------------------------------------------------------------------------------- /Main_App/templates/loginpage.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Login 12 | 13 | 14 |
15 |
16 | 17 |
18 | 19 |

Student Management

20 |
21 |
22 |

23 | {% if messages %} 24 | {% for message in messages %} 25 |
{{message}}
26 | {% endfor %} 27 | {% endif %} 28 | 29 | 30 |
31 | {% csrf_token %} 32 | 33 | 34 | 35 |
36 | 37 |
38 |
39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Main_App/restrictions.py: -------------------------------------------------------------------------------- 1 | from django.http import HttpResponse 2 | from django.shortcuts import redirect 3 | 4 | from Main_App.models import MyUser 5 | 6 | def is_authenticated(func): 7 | def wrapper(request,*args,**kwargs): 8 | if request.user.is_authenticated: 9 | return func(request,*args,**kwargs) 10 | else: 11 | return redirect('/loginpage') 12 | return wrapper 13 | 14 | def is_admin(func): 15 | def wrapper(request,*args,**kwargs): 16 | try: 17 | user = MyUser.objects.get(id=request.user.id) 18 | if user.user_type == '1': 19 | return func(request,*args,**kwargs) 20 | else: 21 | return HttpResponse("

You are not authorised to view this page

") 22 | except: 23 | return HttpResponse("

You are not authorised to view this page.

") 24 | return wrapper 25 | 26 | def is_teacher(func): 27 | def wrapper(request,*args,**kwargs): 28 | try: 29 | user = MyUser.objects.get(id=request.user.id) 30 | if user.user_type == '2': 31 | return func(request,*args,**kwargs) 32 | else: 33 | return HttpResponse("

You are not authorised to view this page

") 34 | except: 35 | return HttpResponse("

You are not authorised to view this page.

") 36 | return wrapper 37 | 38 | def is_student(func): 39 | def wrapper(request,*args,**kwargs): 40 | try: 41 | user = MyUser.objects.get(id=request.user.id) 42 | if user.user_type == '3': 43 | return func(request,*args,**kwargs) 44 | else: 45 | return HttpResponse("

Log in as student to view this page

") 46 | except: 47 | return HttpResponse("

Log in as student to view this page.

") 48 | return wrapper -------------------------------------------------------------------------------- /Main_App/templates/student/s_viewresult.html: -------------------------------------------------------------------------------- 1 | {% extends 'student/s_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

View Result

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | {% for result in results %} 42 | 43 | 44 | 45 | 46 | 47 | 48 | {% endfor %} 49 | 50 |
TitleCreated ByCreated AtFile
{{result.title}}{{result.created_by}}{{result.created_at}}download
51 |
52 |
53 |
54 |
55 | 56 | 57 |
58 | 59 | 60 | 61 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/student/s_viewnotification.html: -------------------------------------------------------------------------------- 1 | {% extends 'student/s_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Notifications

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 | 31 |
32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | {% for notification in notifications %} 43 | 44 | 45 | 46 | 47 | 48 | 49 | {% endfor %} 50 | 51 |
HeadingMessageCreated byCreated At
{{notification.heading}}{{notification.message}}{{notification.created_by}}{{notification.created_at}}
52 |
53 |
54 |
55 |
56 | 57 |
58 | 59 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_viewnotification.html: -------------------------------------------------------------------------------- 1 | {% extends 'teacher/t_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

View all Notifications

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | {% for notification in notifications %} 42 | 43 | 44 | 45 | 46 | 47 | 48 | {% endfor %} 49 | 50 |
HeadingMessageCreated AtCreated By
{{notification.heading}}{{notification.message}}{{notification.created_at}}{{notification.created_by}}
51 |
52 |
53 |
54 |
55 | 56 | 57 |
58 | 59 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/admin/a_addnotification.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin/a_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Add Notification for Students and Teacher

9 | 10 |
11 |
12 | 13 | {% if messages %} 14 | 29 | {% endif %} 30 | 31 |
32 |
33 |
34 | {% csrf_token %} 35 |
36 | 37 | 38 |
39 |
40 | 41 | 42 |
43 |
44 | 45 |
46 |
47 |
48 |
49 | 50 |
51 | 52 |
53 | 54 | 55 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/migrations/0002_notes_result.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.6 on 2022-01-19 06:46 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('Main_App', '0001_initial'), 10 | ] 11 | 12 | operations = [ 13 | migrations.CreateModel( 14 | name='Notes', 15 | fields=[ 16 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 17 | ('title', models.CharField(max_length=50)), 18 | ('file', models.FileField(upload_to='')), 19 | ('std', models.CharField(choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10)], max_length=10)), 20 | ('medium', models.CharField(choices=[('Marathi', 'Marathi'), ('SemiEng', 'SemiEng'), ('CBSE', 'CBSE'), ('Foundation', 'Foundation')], max_length=15)), 21 | ('created_at', models.DateTimeField(auto_now_add=True)), 22 | ('created_by', models.TextField()), 23 | ], 24 | ), 25 | migrations.CreateModel( 26 | name='Result', 27 | fields=[ 28 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 29 | ('title', models.CharField(max_length=50)), 30 | ('file', models.FileField(upload_to='')), 31 | ('std', models.CharField(choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10)], max_length=10)), 32 | ('medium', models.CharField(choices=[('Marathi', 'Marathi'), ('SemiEng', 'SemiEng'), ('CBSE', 'CBSE'), ('Foundation', 'Foundation')], max_length=15)), 33 | ('created_at', models.DateTimeField(auto_now_add=True)), 34 | ('created_by', models.TextField()), 35 | ], 36 | ), 37 | ] 38 | -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_addnotification.html: -------------------------------------------------------------------------------- 1 | {% extends 'teacher/t_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Add Notification for Students and Teachers

9 | 10 |
11 |
12 | 13 | {% if messages %} 14 | 29 | {% endif %} 30 | 31 |
32 |
33 |
34 | {% csrf_token %} 35 |
36 | 37 | 38 |
39 |
40 | 41 | 42 |
43 |
44 | 45 |
46 |
47 |
48 |
49 | 50 |
51 | 52 |
53 | 54 | 55 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_deletenotes.html: -------------------------------------------------------------------------------- 1 | {% extends 'teacher/t_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Delete Notes

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | {% for note in notes %} 43 | 44 | 45 | 46 | 47 | 48 | 51 | 52 | {% endfor %} 53 | 54 |
TitleClassMediumCreated AtRemove
{{note.title}}{{note.std}}{{note.medium}}{{note.created_at}} 49 | 50 |
55 |
56 |
57 |
58 |
59 | 60 | 61 |
62 | 63 | 64 | 65 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/static/Main_App/js/index.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Start Bootstrap - Creative v7.0.5 (https://startbootstrap.com/theme/creative) 3 | * Copyright 2013-2021 Start Bootstrap 4 | * Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-creative/blob/master/LICENSE) 5 | */ 6 | // 7 | // Scripts 8 | // 9 | 10 | window.addEventListener('DOMContentLoaded', event => { 11 | 12 | // Navbar shrink function 13 | var navbarShrink = function () { 14 | const navbarCollapsible = document.body.querySelector('#mainNav'); 15 | if (!navbarCollapsible) { 16 | return; 17 | } 18 | if (window.scrollY === 0) { 19 | navbarCollapsible.classList.remove('navbar-shrink') 20 | } else { 21 | navbarCollapsible.classList.add('navbar-shrink') 22 | } 23 | 24 | }; 25 | 26 | // Shrink the navbar 27 | navbarShrink(); 28 | 29 | // Shrink the navbar when page is scrolled 30 | document.addEventListener('scroll', navbarShrink); 31 | 32 | // Activate Bootstrap scrollspy on the main nav element 33 | const mainNav = document.body.querySelector('#mainNav'); 34 | if (mainNav) { 35 | new bootstrap.ScrollSpy(document.body, { 36 | target: '#mainNav', 37 | offset: 74, 38 | }); 39 | }; 40 | 41 | // Collapse responsive navbar when toggler is visible 42 | const navbarToggler = document.body.querySelector('.navbar-toggler'); 43 | const responsiveNavItems = [].slice.call( 44 | document.querySelectorAll('#navbarResponsive .nav-link') 45 | ); 46 | responsiveNavItems.map(function (responsiveNavItem) { 47 | responsiveNavItem.addEventListener('click', () => { 48 | if (window.getComputedStyle(navbarToggler).display !== 'none') { 49 | navbarToggler.click(); 50 | } 51 | }); 52 | }); 53 | 54 | // Activate SimpleLightbox plugin for portfolio items 55 | new SimpleLightbox({ 56 | elements: '#portfolio a.portfolio-box' 57 | }); 58 | 59 | }); 60 | -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_deleteresult.html: -------------------------------------------------------------------------------- 1 | {% extends 'teacher/t_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Delete result

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | {% for result in results %} 43 | 44 | 45 | 46 | 47 | 48 | 51 | 52 | {% endfor %} 53 | 54 |
TitleClassMediumCreated AtAction
{{result.title}}{{result.std}}{{result.medium}}{{result.created_at}} 49 | 50 |
55 |
56 |
57 |
58 |
59 | 60 | 61 |
62 | 63 | 64 | 65 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/student/s_home.html: -------------------------------------------------------------------------------- 1 | {% extends 'student/s_base.html' %} 2 | 3 | {% block content %} 4 |
5 |
6 | 7 |
8 |
9 |

Student Dashboard

10 |
11 | 12 | 13 |
14 |
15 |
16 |
17 |
18 |
19 |
Marathi
20 |

{{marathi_count}}

21 |
22 |
23 |
24 |
25 |
26 |
27 |
Semi-Eng
28 |

{{semi_count}}

29 |
30 |
31 |
32 |
33 |
34 |
35 |
CBSE
36 |

{{cbse_count}}

37 |
38 |
39 |
40 |
41 |
42 |
43 |
Foundation
44 |

{{foundation_count}}

45 |
46 |
47 |
48 |
49 |
50 | 51 |
52 |
53 |
54 |
55 | 56 |
Standardwise Student distribution
57 |
58 |
59 |
60 | 61 |
62 |
63 |
64 |
65 |
66 | 67 |
68 |
69 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/student/s_viewnotes.html: -------------------------------------------------------------------------------- 1 | {% extends 'student/s_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

View notes

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | {% for note in notes %} 44 | 45 | 46 | 47 | 48 | 49 | 50 | 53 | 54 | {% endfor %} 55 | 56 |
TitleClassMediumCreated ByCreated AtFile
{{note.title}}{{note.std}}{{note.medium}}{{note.created_by}}{{note.created_at}} 51 | download 52 |
57 |
58 |
59 |
60 |
61 | 62 | 63 |
64 | 65 | 66 | 67 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_viewnotes.html: -------------------------------------------------------------------------------- 1 | {% extends 'teacher/t_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

View all Notes

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | {% for note in notes %} 44 | 45 | 46 | 47 | 48 | 49 | 50 | 53 | 54 | {% endfor %} 55 | 56 |
TitleClassMediumCreated ByCreated AtFile
{{note.title}}{{note.std}}{{note.medium}}{{note.created_by}}{{note.created_at}} 51 | download 52 |
57 |
58 |
59 |
60 |
61 | 62 | 63 |
64 | 65 | 66 | 67 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_deletenotification.html: -------------------------------------------------------------------------------- 1 | {% extends 'teacher/t_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Delete Notification

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | {% for notification in notifications %} 42 | 43 | 44 | 45 | 46 | 49 | 50 | {% endfor %} 51 | 52 |
HeadingMessageCreated AtAction
{{notification.heading}}{{notification.message}}{{notification.created_at}} 47 | 48 |
53 |
54 |
55 |
56 |
57 | 58 | 59 |
60 | 61 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_viewresult.html: -------------------------------------------------------------------------------- 1 | {% extends 'teacher/t_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

View all results

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | {% for result in results %} 44 | 45 | 46 | 47 | 48 | 49 | 50 | 53 | 54 | {% endfor %} 55 | 56 |
TitleClassMediumCreated ByCreated AtFile
{{result.title}}{{result.std}}{{result.medium}}{{result.created_by}}{{result.created_at}} 51 | download 52 |
57 |
58 |
59 |
60 |
61 | 62 | 63 |
64 | 65 | 66 | 67 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/admin/a_viewnotes.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin/a_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

View all Notes

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | {% for note in notes %} 45 | 46 | 47 | 48 | 49 | 50 | 51 | 54 | 57 | 58 | {% endfor %} 59 | 60 |
TitleClassMediumCreated ByCreated AtDownloadRemove
{{note.title}}{{note.std}}{{note.medium}}{{note.created_by}}{{note.created_at}} 52 | download 53 | 55 | 56 |
61 |
62 |
63 |
64 |
65 | 66 | 67 |
68 | 69 | 70 | 71 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/admin/a_managenotification.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin/a_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Manage Notifications

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | {% for notification in notifications %} 44 | 45 | 46 | 47 | 48 | 49 | 50 | 53 | 54 | {% endfor %} 55 | 56 |
IDHeadingMessageCreated byCreated AtAction
{{notification.id}}{{notification.heading}}{{notification.message}}{{notification.created_by}}{{notification.created_at}} 51 | 52 |
57 |
58 |
59 |
60 |
61 | 62 | 63 |
64 | 65 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/admin/a_viewresult.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin/a_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Manage Result

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | {% for result in results %} 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 55 | 56 | {% endfor %} 57 | 58 |
TitleClassMediumCreated ByCreated AtFileAction
{{result.title}}{{result.std}}{{result.medium}}{{result.created_by}}{{result.created_at}} 53 | 54 |
59 |
60 |
61 |
62 |
63 | 64 | 65 |
66 | 67 | 68 | 69 | {% endblock %} -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | **

Student Management Site

** 2 |

3 | Made with Django and ❤️... 4 |

5 | 17 |

18 | Report Bug 19 | · 20 | Request feature 21 | · 22 | Initiate Idea 23 |

24 |
25 | 26 | ## 🛠️ Installation Steps 27 | 28 | > How to download and install : 29 | - To start you should atleast have python and django installed. 30 | - clone this repo using : git clone https://github.com/ursmaheshj/Student_Management.git 31 | - create virtual environment and install packages (pip install -r requirements.txt) 32 | - run migrate command (python manage.py migrate) 33 | - run collectstatic command (python manage.py collectstatic) 34 | - after database creation create one superuser (please give email also). 35 | - now after login with admin you can add teachers and students. 36 | 37 | ## 🧐 Features 38 | - Userfriendly design 39 | - Simple and Elegant UI 40 | - Provided with Admin, Teacher and Student portfolios 41 | - Default Authentication 42 | 43 | ## 💻 Built with 44 | - Django 45 | - Adminlte 46 | - Bootstrap 47 | - Heroku 48 | 49 | ## 🍰 Contributing 50 | 51 | Please contribute using [GitHub Flow](https://guides.github.com/introduction/flow); Create a branch, add commits, and [open a pull request](https://github.com/ursmaheshj/Student_Management/compare). 52 | 53 | ## 🙏 Support 54 | Dont hesitate to [fork](https://github.com/login?return_to=%2Fursmaheshj%2FStudent_Management) this repository and give a [star](https://github.com/login?return_to=%2Fursmaheshj%2FStudent_Management) if you like it.. 55 | 56 |
57 | -------------------------------------------------------------------------------- /Main_App/templates/admin/a_addteacher.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin/a_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Add Teacher

9 | 10 |
11 |
12 | 13 | {% if messages %} 14 | 29 | {% endif %} 30 | 31 |
32 |
33 |
34 | {% csrf_token %} 35 |
36 | 37 | 38 |
39 |
40 | 41 | 42 |
43 |
44 | 45 | 46 |
47 |
48 | 49 | 55 |
56 |
57 | 58 | 59 |
60 |
61 | 62 |
63 |
64 |
65 |
66 | 67 |
68 | 69 |
70 | 71 | 72 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_viewstudent.html: -------------------------------------------------------------------------------- 1 | {% extends 'teacher/t_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

View Students

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | {% for student in students %} 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 63 | 64 | {% endfor %} 65 | 66 |
First NameLast NameStudent CodeEmailGenderClassMediumAddressCreated AtUpdated AtReset Pass
{{student.admin.first_name}}{{student.admin.last_name}}{{student.admin.username}}{{student.admin.email}}{{student.gender}}{{student.std}}{{student.medium}}{{student.address}}{{student.created_at}}{{student.updated_at}} 61 | 62 |
67 |
68 |
69 |
70 |
71 | 72 | 73 |
74 | 75 | 76 | 77 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/admin/a_addresult.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin/a_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Upload Result

9 | 10 |
11 |
12 | 13 | {% if messages %} 14 | 29 | {% endif %} 30 | 31 |
32 |
33 |
34 | {% csrf_token %} 35 |
36 | 37 | 38 |
39 |
40 | 41 | 47 |
48 |
49 | 50 | 56 |
57 | 58 |
59 | 60 | 61 | Upload result here. 62 |
63 |
64 | 65 |
66 |
67 |
68 |
69 | 70 |
71 | 72 |
73 | 74 | 75 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_addresult.html: -------------------------------------------------------------------------------- 1 | {% extends 'teacher/t_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Upload Result

9 | 10 |
11 |
12 | 13 | {% if messages %} 14 | 29 | {% endif %} 30 | 31 |
32 |
33 |
34 | {% csrf_token %} 35 |
36 | 37 | 38 |
39 |
40 | 41 | 47 |
48 |
49 | 50 | 56 |
57 | 58 |
59 | 60 | 61 | Upload result here. 62 |
63 |
64 | 65 |
66 |
67 |
68 |
69 | 70 |
71 | 72 |
73 | 74 | 75 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/admin/a_addnotes.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin/a_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Add study material

9 | 10 |
11 |
12 | 13 | {% if messages %} 14 | 29 | {% endif %} 30 | 31 |
32 | 33 |
34 |
35 | {% csrf_token %} 36 |
37 | 38 | 39 |
40 |
41 | 42 | 48 |
49 |
50 | 51 | 57 |
58 | 59 |
60 | 61 | 62 | Upload study material here. 63 |
64 |
65 | 66 |
67 |
68 |
69 |
70 | 71 |
72 | 73 |
74 | 75 | 76 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_addnotes.html: -------------------------------------------------------------------------------- 1 | {% extends 'teacher/t_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Add study material

9 | 10 |
11 |
12 | 13 | {% if messages %} 14 | 29 | {% endif %} 30 | 31 |
32 | 33 |
34 |
35 | {% csrf_token %} 36 |
37 | 38 | 39 |
40 |
41 | 42 | 48 |
49 |
50 | 51 | 57 |
58 | 59 |
60 | 61 | 62 | Upload study material here. 63 |
64 |
65 | 66 |
67 |
68 |
69 |
70 | 71 |
72 | 73 |
74 | 75 | 76 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/admin/a_profile.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin/a_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 |
8 |
9 |

Edit Profile

10 |
11 | 12 |
13 | 18 |
19 |
20 | 21 |
22 |
23 | 24 | 25 | {% if messages %} 26 | 41 | {% endif %} 42 | 43 |
44 |
45 |
46 | {% csrf_token %} 47 |
48 | 49 | 50 |
51 | 52 |
53 | 54 | 55 | 56 |
57 |
58 | 59 | 60 |
61 |
62 | 63 | 64 |
65 |
66 | 67 | 68 |
69 |
70 | 71 |
72 |
73 |
74 |
75 | 76 |
77 | 78 |
79 | 80 | 81 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/admin/a_manageteacher.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin/a_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Manage Teachers

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | {% for teacher in teachers %} 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 63 | 66 | 67 | {% endfor %} 68 | 69 |
IDFirst NameLast NameTeacher CodeEmailGenderAddressCreated AtUpdated AtActionRemove
{{teacher.admin.id}}{{teacher.admin.first_name}}{{teacher.admin.last_name}}{{teacher.admin.username}}{{teacher.admin.email}}{{teacher.gender}}{{teacher.address}}{{teacher.created_at}}{{teacher.updated_at}} 60 | 61 | 62 | 64 | 65 |
70 |
71 |
72 |
73 |
74 | 75 | 76 |
77 | 78 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/base/base.html: -------------------------------------------------------------------------------- 1 | {% load static %} 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Student Management Site 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | {% block base %}{% endblock base %} 25 | 26 | 27 | 28 | 29 | 30 | 58 | 102 | -------------------------------------------------------------------------------- /Main_App/templates/admin/a_managestudent.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin/a_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Manage Students

9 |
10 | 11 | {% if messages %} 12 | 27 | {% endif %} 28 | 29 |
30 |
31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {% for student in students %} 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 67 | 70 | 71 | {% endfor %} 72 | 73 |
IDFirst NameLast NameStudent CodeEmailGenderClassMediumAddressCreated AtUpdated AtActionRemove
{{student.admin.id}}{{student.admin.first_name}}{{student.admin.last_name}}{{student.admin.username}}{{student.admin.email}}{{student.gender}}{{student.std}}{{student.medium}}{{student.address}}{{student.created_at}}{{student.updated_at}} 64 | 65 | 66 | 68 | 69 |
74 |
75 |
76 |
77 |
78 | 79 | 80 |
81 | 82 | 83 | 84 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_home.html: -------------------------------------------------------------------------------- 1 | {% extends 'teacher/t_base.html' %} 2 | 3 | {% block content %} 4 |
5 |
6 | 7 |
8 |
9 |

Teacher Dashboard

10 |
11 | 12 | 13 |
14 |
15 |
16 |
17 |
18 |
19 |
Marathi
20 |

{{marathi_count}}

21 |
22 |
23 |
24 |
25 |
26 |
27 |
Semi-Eng
28 |

{{semi_count}}

29 |
30 |
31 |
32 |
33 |
34 |
35 |
CBSE
36 |

{{cbse_count}}

37 |
38 |
39 |
40 |
41 |
42 |
43 |
Foundation
44 |

{{foundation_count}}

45 |
46 |
47 |
48 |
49 |
50 | 51 |
52 |
53 |
54 |
55 |
Genderwise Student distribution
56 |
57 |
58 |
59 |
60 |
61 | 62 |
63 |
64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 |
Male{{male_count}}
Female{{female_count}}
Other{{other_count}}
81 |
82 |
83 |
84 |
85 |
86 | 87 |
88 |
89 |
90 |
91 | 92 |
Standardwise Student distribution
93 |
94 |
95 |
96 | 97 |
98 |
99 |
100 |
101 |
102 | 103 |
104 |
105 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/admin/a_editteacher.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin/a_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 |
8 |
9 |

Update {{teacher.admin.first_name}}

10 |
11 | 12 |
13 | 18 |
19 |
20 | 21 |
22 |
23 | 24 | {% if messages %} 25 | 40 | {% endif %} 41 | 42 |
43 |
44 |
45 | {% csrf_token %} 46 |
47 | 48 | 49 | 50 |
51 |
52 | 53 | 54 |
55 |
56 | 57 | 58 |
59 |
60 | 61 | 67 |
68 |
69 | 70 | 71 |
72 |
73 | 74 |
75 |
76 |
77 |
78 | 79 |
80 | 81 |
82 | 83 | 84 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_sidebar.html: -------------------------------------------------------------------------------- 1 | 75 | -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_profile.html: -------------------------------------------------------------------------------- 1 | {% extends 'teacher/t_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 |
8 |
9 |

Edit Profile

10 |
11 |
12 | 13 |
14 |
15 | 16 | {% if messages %} 17 | 32 | {% endif %} 33 | 34 |
35 |
36 |
37 | {% csrf_token %} 38 |
39 | 40 | 41 |
42 | 43 |
44 | 45 | 46 | 47 |
48 |
49 | 50 | 51 |
52 |
53 | 54 | 55 |
56 |
57 | 58 | 64 |
65 |
66 | 67 | 68 |
69 |
70 | 71 | 72 |
73 |
74 | 75 |
76 |
77 |
78 |
79 | 80 |
81 | 82 |
83 | 84 | 85 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/teacher/t_addstudent.html: -------------------------------------------------------------------------------- 1 | {% extends 'teacher/t_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Add Student

9 | 10 |
11 |
12 | 13 | {% if messages %} 14 | 29 | {% endif %} 30 | 31 |
32 |
33 |
34 | {% csrf_token %} 35 |
36 | 37 | 38 |
39 |
40 | 41 | 42 |
43 |
44 | 45 | 46 |
47 |
48 | 49 | 55 |
56 |
57 | 58 | 64 |
65 |
66 | 67 | 73 |
74 |
75 | 76 | 77 |
78 |
79 | 80 |
81 |
82 |
83 |
84 | 85 |
86 | 87 |
88 | 89 | 90 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/admin/a_addstudent.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin/a_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |

Add Student

9 | 10 |
11 |
12 | 13 | {% if messages %} 14 | 29 | {% endif %} 30 | 31 |
32 |
33 |
34 | {% csrf_token %} 35 |
36 | 37 | 38 |
39 |
40 | 41 | 42 |
43 |
44 | 45 | 46 |
47 |
48 | 49 | 55 |
56 |
57 | 58 | 64 |
65 |
66 | 67 | 73 |
74 |
75 | 76 | 77 |
78 |
79 | 80 |
81 |
82 |
83 |
84 | 85 |
86 | 87 |
88 | 89 | 90 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/admin/a_home.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin/a_base.html' %} 2 | 3 | {% block content %} 4 |
5 |
6 | 7 |
8 |
9 |

Admin Dashboard

10 |
11 | 12 | 13 |
14 |
15 |
16 |
17 |
18 |
19 |
Marathi
20 |

{{marathi_count}}

21 |
22 |
23 |
24 |
25 |
26 |
27 |
Semi-Eng
28 |

{{semi_count}}

29 |
30 |
31 |
32 |
33 |
34 |
35 |
CBSE
36 |

{{cbse_count}}

37 |
38 |
39 |
40 |
41 |
42 |
43 |
Foundation
44 |

{{foundation_count}}

45 |
46 |
47 |
48 |
49 |
50 | 51 |
52 |
53 |
54 |
55 |
Genderwise Student distribution
56 |
57 |
58 |
59 |
60 |
61 | 62 |
63 |
64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 |
Male{{male_count}}
Female{{female_count}}
Other{{other_count}}
81 |
82 |
83 |
84 |
85 |
86 | 87 |
88 |
89 |
90 |
91 | 92 |
Standardwise Student distribution
93 |
94 |
95 |
96 | 97 |
98 |
99 |
100 |
101 |
102 | 103 |
104 |
105 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/admin/a_sidebar.html: -------------------------------------------------------------------------------- 1 | 74 | -------------------------------------------------------------------------------- /Main_App/templates/student/s_profile.html: -------------------------------------------------------------------------------- 1 | {% extends 'student/s_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 |
8 |
9 |

Edit Profile

10 |
11 |
12 | 13 |
14 |
15 | 16 | {% if messages %} 17 | 32 | {% endif %} 33 | 34 |
35 |
36 |
37 | {% csrf_token %} 38 |
39 | 40 | 41 |
42 |
43 | 44 | 45 |
46 |
47 | 48 | 49 |
50 |
51 | 52 | 53 | 54 |
55 |
56 | 57 | 58 |
59 |
60 | 61 | 62 |
63 |
64 | 65 | 71 |
72 |
73 | 74 | 75 |
76 |
77 | 78 | 79 |
80 |
81 | 82 |
83 |
84 |
85 |
86 | 87 |
88 | 89 |
90 | 91 | 92 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/templates/admin/a_editstudent.html: -------------------------------------------------------------------------------- 1 | {% extends 'admin/a_base.html' %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 | 8 |
9 |
10 |

Update {{student.admin.first_name}}

11 |
12 | 13 |
14 | 19 |
20 |
21 | 22 |
23 |
24 | 25 | {% if messages %} 26 | 41 | {% endif %} 42 | 43 |
44 |
45 |
46 | {% csrf_token %} 47 |
48 | 49 | 50 | 51 |
52 |
53 | 54 | 55 |
56 |
57 | 58 | 59 |
60 |
61 | 62 | 68 |
69 |
70 | 71 | 77 |
78 |
79 | 80 | 86 |
87 |
88 | 89 | 90 |
91 |
92 | 93 |
94 |
95 |
96 |
97 | 98 |
99 | 100 |
101 | 102 | 103 | {% endblock %} -------------------------------------------------------------------------------- /Main_App/models.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.contrib.auth.models import AbstractUser 3 | from django.db import models 4 | from django.db.models.signals import post_save 5 | from django.dispatch import receiver 6 | 7 | # Create your models here. 8 | 9 | class MyUser(AbstractUser): 10 | user_types = ((1,'Admin'),(2,'Teacher'),(3,'Student')) 11 | user_type = models.CharField(default=1,choices=user_types,max_length=10) 12 | 13 | class Admin(models.Model): 14 | id = models.AutoField(primary_key=True) 15 | admin = models.OneToOneField(MyUser,on_delete=models.CASCADE) 16 | created_at = models.DateTimeField(auto_now_add=True) 17 | updated_at = models.DateTimeField(auto_now=True) 18 | objects = models.Manager() 19 | 20 | class Teacher(models.Model): 21 | gender_choices = (('Male','Male'),('Female','Female'),('Other','Other')) 22 | id = models.AutoField(primary_key=True) 23 | admin = models.OneToOneField(MyUser,on_delete=models.CASCADE) 24 | gender = models.CharField(max_length=15,choices=gender_choices,default='Other') 25 | address = models.TextField() 26 | created_at = models.DateTimeField(auto_now_add=True) 27 | updated_at = models.DateTimeField(auto_now=True) 28 | objects = models.Manager() 29 | 30 | class Student(models.Model): 31 | medium_choices = (('Marathi','Marathi'),('SemiEng','SemiEng'),('CBSE','CBSE'),('Foundation','Foundation')) 32 | gender_choices = (('Male','Male'),('Female','Female'),('Other','Other')) 33 | std_choices = ((1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10)) 34 | id = models.AutoField(primary_key=True) 35 | admin = models.OneToOneField(MyUser,on_delete=models.CASCADE) 36 | gender = models.CharField(max_length=15,choices=gender_choices,default='Other') 37 | std = models.CharField(max_length=10,choices=std_choices) 38 | medium = models.CharField(max_length=15 ,choices=medium_choices, default='Marathi') 39 | address = models.TextField() 40 | created_at = models.DateTimeField(auto_now_add=True) 41 | updated_at = models.DateTimeField(auto_now=True) 42 | objects = models.Manager() 43 | 44 | class Notification(models.Model): 45 | id = models.AutoField(primary_key=True) 46 | heading = models.CharField(max_length=150) 47 | message = models.TextField() 48 | created_at = models.DateTimeField(auto_now_add=True) 49 | created_by = models.CharField(max_length=20) 50 | updated_at = models.DateTimeField(auto_now=True) 51 | objects = models.Manager() 52 | 53 | class Result(models.Model): 54 | std_choices = ((1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10)) 55 | medium_choices = (('Marathi','Marathi'),('SemiEng','SemiEng'),('CBSE','CBSE'),('Foundation','Foundation')) 56 | title = models.CharField(max_length=50) 57 | file = models.FileField() 58 | std = models.CharField(max_length=10,choices=std_choices) 59 | medium = models.CharField(max_length=15 ,choices=medium_choices) 60 | created_at = models.DateTimeField(auto_now_add=True) 61 | created_by = models.TextField() 62 | 63 | class Notes(models.Model): 64 | std_choices = ((1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10)) 65 | medium_choices = (('Marathi','Marathi'),('SemiEng','SemiEng'),('CBSE','CBSE'),('Foundation','Foundation')) 66 | title = models.CharField(max_length=50) 67 | file = models.FileField() 68 | std = models.CharField(max_length=10,choices=std_choices) 69 | medium = models.CharField(max_length=15 ,choices=medium_choices) 70 | created_at = models.DateTimeField(auto_now_add=True) 71 | created_by = models.TextField() 72 | 73 | @receiver(post_save,sender=MyUser) 74 | def user_create(sender,instance,created,**kwargs): 75 | if created: 76 | if instance.user_type == 1: 77 | Admin.objects.create(admin=instance) 78 | if instance.user_type == 2: 79 | Teacher.objects.create(admin=instance) 80 | if instance.user_type == 3: 81 | Student.objects.create(admin=instance) 82 | 83 | @receiver(post_save,sender=MyUser) 84 | def user_save(sender,instance,**kwargs): 85 | if instance.user_type == 1: 86 | instance.admin.save() 87 | if instance.user_type == 2: 88 | instance.teacher.save() 89 | if instance.user_type == 3: 90 | instance.student.save() -------------------------------------------------------------------------------- /Main_App/v_student.py: -------------------------------------------------------------------------------- 1 | from django.contrib import messages 2 | from django.http.response import HttpResponse, HttpResponseRedirect 3 | from django.shortcuts import render 4 | 5 | from Main_App.models import MyUser, Notes, Notification, Result, Student 6 | from Main_App.restrictions import is_authenticated, is_student 7 | 8 | @is_authenticated 9 | @is_student 10 | def s_home(request): 11 | marathi_count = Student.objects.filter(medium='Marathi').count() 12 | semi_count = Student.objects.filter(medium='SemiEng').count() 13 | cbse_count = Student.objects.filter(medium='CBSE').count() 14 | foundation_count = Student.objects.filter(medium='Foundation').count() 15 | 16 | count_1 = Student.objects.filter(std=1).count() 17 | count_2 = Student.objects.filter(std=2).count() 18 | count_3 = Student.objects.filter(std=3).count() 19 | count_4 = Student.objects.filter(std=4).count() 20 | count_5 = Student.objects.filter(std=5).count() 21 | count_6 = Student.objects.filter(std=6).count() 22 | count_7 = Student.objects.filter(std=7).count() 23 | count_8 = Student.objects.filter(std=8).count() 24 | count_9 = Student.objects.filter(std=9).count() 25 | count_10 = Student.objects.filter(std=10).count() 26 | 27 | context = { 28 | "marathi_count":marathi_count, 29 | "semi_count":semi_count, 30 | "cbse_count":cbse_count, 31 | "foundation_count":foundation_count, 32 | 33 | "count_1":count_1, 34 | "count_2":count_2, 35 | "count_3":count_3, 36 | "count_4":count_4, 37 | "count_5":count_5, 38 | "count_6":count_6, 39 | "count_7":count_7, 40 | "count_8":count_8, 41 | "count_9":count_9, 42 | "count_10":count_10, 43 | } 44 | 45 | return render(request,'student/s_home.html',context) 46 | 47 | @is_authenticated 48 | @is_student 49 | def s_profile(request): 50 | return render(request,'student/s_profile.html') 51 | 52 | @is_authenticated 53 | @is_student 54 | def s_saveprofile(request): 55 | if request.method != "POST": 56 | return HttpResponse("Method not Allowed..!") 57 | else : 58 | student_id = request.POST.get('student_id') 59 | firstname = request.POST.get('firstname') 60 | lastname = request.POST.get('lastname') 61 | email = request.POST.get('email') 62 | address = request.POST.get('address') 63 | gender = request.POST.get('gender') 64 | password = request.POST.get('password') 65 | try : 66 | user = MyUser.objects.get(id=student_id) 67 | user.first_name=firstname 68 | user.last_name=lastname 69 | user.email=email 70 | if password != None and password != "": 71 | user.set_password(password) 72 | user.save() 73 | 74 | student = Student.objects.get(admin=student_id) 75 | student.address=address 76 | student.gender=gender 77 | student.save() 78 | messages.success(request,"Profile updated successfully") 79 | return HttpResponseRedirect('/studentprofile') 80 | except : 81 | messages.error(request,"Failed to update profile") 82 | return HttpResponseRedirect('/studentprofile') 83 | 84 | @is_authenticated 85 | @is_student 86 | def s_viewresult(request): 87 | try: 88 | s = Student.objects.get(admin=request.user.id) 89 | results = Result.objects.filter(std=s.std,medium=s.medium) 90 | return render(request,'student/s_viewresult.html',{'results':results}) 91 | except: 92 | return HttpResponse('

You need to login first

') 93 | 94 | @is_authenticated 95 | @is_student 96 | def s_viewnotification(request): 97 | notifications = Notification.objects.all() 98 | return render(request,'student/s_viewnotification.html',{'notifications':notifications}) 99 | 100 | @is_authenticated 101 | @is_student 102 | def s_viewnotes(request): 103 | try: 104 | s = Student.objects.get(admin=request.user.id) 105 | notes = Notes.objects.filter(std=s.std,medium=s.medium) 106 | return render(request,'student/s_viewnotes.html',{'notes':notes}) 107 | except: 108 | return HttpResponse('

You need to login first

') -------------------------------------------------------------------------------- /Student_Management/urls.py: -------------------------------------------------------------------------------- 1 | """Student_Management URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/3.2/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path,include 18 | from Student_Management import settings 19 | from django.conf.urls.static import static 20 | 21 | from Main_App import views,v_admin,v_student,v_teacher 22 | 23 | urlpatterns = [ 24 | #Common URL's 25 | path('admin/', admin.site.urls), 26 | path('', views.loginpage), 27 | path('loginuser',views.loginuser), 28 | path('logoutuser',views.logoutuser), 29 | 30 | #Admin URL's 31 | path('adminhome/', v_admin.a_home,name='adminhome'), 32 | path('adminprofile/',v_admin.adminprofile,name='adminprofile'), 33 | path('addteacher/',v_admin.addteacher,name='addteacher'), 34 | path('saveteacher',v_admin.saveteacher), 35 | path('addstudent/',v_admin.addstudent,name='addstudent'), 36 | path('savestudent',v_admin.savestudent), 37 | path('manageteacher/',v_admin.manageteacher,name='manageteacher'), 38 | path('deleteteacher/',v_admin.deleteteacher), 39 | path('resetteacherpass/',v_admin.resetteacherpass), 40 | path('managestudent/',v_admin.managestudent,name='managestudent'), 41 | path('deletestudent/',v_admin.deletestudent), 42 | path('resetstudentpass/',v_admin.resetstudentpass), 43 | path('editteacher/',v_admin.editteacher,name='editteacher'), 44 | path('saveeditteacher',v_admin.saveeditteacher), 45 | path('editstudent/',v_admin.editstudent,name='editstudent'), 46 | path('saveeditstudent',v_admin.saveeditstudent), 47 | path('a_addnotification/',v_admin.a_addnotification,name="a_addnotification"), 48 | path('a_savenotification',v_admin.a_savenotification), 49 | path('managenotification/',v_admin.managenotification,name='managenotification'), 50 | path('a_deletenotification/',v_admin.a_deletenotification,name='deletenotification'), 51 | path('a_addresult/',v_admin.a_addresult), 52 | path('a_saveresult',v_admin.a_saveresult), 53 | path('a_viewresult/',v_admin.a_viewresult), 54 | path('a_removeresult/',v_admin.a_removeresult), 55 | path('a_addnotes/',v_admin.a_addnotes), 56 | path('a_savenotes',v_admin.a_savenotes), 57 | path('a_viewnotes/',v_admin.a_viewnotes), 58 | path('a_removenotes/',v_admin.a_removenotes), 59 | 60 | #Teacher URL's 61 | path('teacherhome/', v_teacher.t_home), 62 | path('teacherprofile/',v_teacher.t_profile), 63 | path('t_saveprofile',v_teacher.t_saveprofile), 64 | path('t_addstudent/', v_teacher.t_addstudent), 65 | path('t_savestudent',v_teacher.t_savestudent), 66 | path('t_viewstudent/', v_teacher.t_viewstudent), 67 | path('t_resetspass/', v_teacher.t_resetspass), 68 | path('t_addnotification/', v_teacher.t_addnotification), 69 | path('t_savenotification',v_teacher.t_savenotification), 70 | path('t_deletenotification/',v_teacher.t_deletenotification), 71 | path('t_removenotification/',v_teacher.t_removenotification), 72 | path('t_viewnotification/',v_teacher.t_viewnotification), 73 | path('t_addresult/',v_teacher.t_addresult), 74 | path('t_saveresult',v_teacher.t_saveresult), 75 | path('t_deleteresult/',v_teacher.t_deleteresult), 76 | path('t_removeresult/',v_teacher.t_removeresult), 77 | path('t_viewresult/',v_teacher.t_viewresult), 78 | path('t_addnotes/',v_teacher.t_addnotes), 79 | path('t_savenotes',v_teacher.t_savenotes), 80 | path('t_deletenotes/',v_teacher.t_deletenotes), 81 | path('t_removenotes/',v_teacher.t_removenotes), 82 | path('t_viewnotes/',v_teacher.t_viewnotes), 83 | 84 | #Student URL's 85 | path('studenthome/', v_student.s_home), 86 | path('studentprofile/',v_student.s_profile), 87 | path('s_saveprofile',v_student.s_saveprofile), 88 | path('s_viewresult/',v_student.s_viewresult), 89 | path('s_viewnotification/',v_student.s_viewnotification), 90 | path('s_viewnotes/', v_student.s_viewnotes), 91 | 92 | ] 93 | if settings.DEBUG: 94 | urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) 95 | urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) 96 | -------------------------------------------------------------------------------- /Student_Management/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for Student_Management project. 3 | 4 | Generated by 'django-admin startproject' using Django 3.2.6. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.2/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/3.2/ref/settings/ 11 | """ 12 | 13 | from pathlib import Path 14 | 15 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 16 | BASE_DIR = Path(__file__).resolve().parent.parent 17 | 18 | 19 | # Quick-start development settings - unsuitable for production 20 | # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ 21 | 22 | # SECURITY WARNING: keep the secret key used in production secret! 23 | SECRET_KEY = 'django-insecure-vs(wz%xrdk1uixb^(aq7i0nmh^m=n)+-x(s1!nmdt(a15i1i@3' 24 | 25 | # SECURITY WARNING: don't run with debug turned on in production! 26 | DEBUG = False 27 | 28 | ALLOWED_HOSTS = ['*'] 29 | 30 | 31 | # Application definition 32 | 33 | INSTALLED_APPS = [ 34 | 'django.contrib.admin', 35 | 'django.contrib.auth', 36 | 'django.contrib.contenttypes', 37 | 'django.contrib.sessions', 38 | 'django.contrib.messages', 39 | 'django.contrib.staticfiles', 40 | 41 | 'Main_App', 42 | ] 43 | 44 | MIDDLEWARE = [ 45 | 'django.middleware.security.SecurityMiddleware', 46 | 'whitenoise.middleware.WhiteNoiseMiddleware', #Used to serve static files on production 47 | 'django.contrib.sessions.middleware.SessionMiddleware', 48 | 'django.middleware.common.CommonMiddleware', 49 | 'django.middleware.csrf.CsrfViewMiddleware', 50 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 51 | 'django.contrib.messages.middleware.MessageMiddleware', 52 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 53 | ] 54 | 55 | ROOT_URLCONF = 'Student_Management.urls' 56 | 57 | TEMPLATES = [ 58 | { 59 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 60 | 'DIRS': [], 61 | 'APP_DIRS': True, 62 | 'OPTIONS': { 63 | 'context_processors': [ 64 | 'django.template.context_processors.debug', 65 | 'django.template.context_processors.request', 66 | 'django.contrib.auth.context_processors.auth', 67 | 'django.contrib.messages.context_processors.messages', 68 | ], 69 | }, 70 | }, 71 | ] 72 | 73 | WSGI_APPLICATION = 'Student_Management.wsgi.application' 74 | 75 | 76 | # Database 77 | # https://docs.djangoproject.com/en/3.2/ref/settings/#databases 78 | 79 | DATABASES = { 80 | 'default': { 81 | 'ENGINE': 'django.db.backends.sqlite3', 82 | 'NAME': BASE_DIR / 'db.sqlite3', 83 | } 84 | } 85 | 86 | 87 | #Below setting is used for postgresql database 88 | # DATABASES = { 89 | # 'default': { 90 | # 'ENGINE': 'django.db.backends.postgresql', 91 | # 'NAME': 'dpgup5gq4e5rsrt34', 92 | # 'USER': 'xfdtxpsdfkzouroxc', 93 | # 'PASSWORD': '0129cdd455dsfsdfe3bb02447f9a25506d4bea6393e7d0cd2559ad70b3cae9e651d21c', 94 | # 'HOST': 'ec2-170-129-37-144.compute-1.amazonaws.com', 95 | # 'PORT': '5432', 96 | # } 97 | # } 98 | 99 | # Password validation 100 | # https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators 101 | 102 | AUTH_PASSWORD_VALIDATORS = [ 103 | { 104 | 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 105 | }, 106 | { 107 | 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 108 | }, 109 | { 110 | 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 111 | }, 112 | { 113 | 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 114 | }, 115 | ] 116 | 117 | 118 | # Internationalization 119 | # https://docs.djangoproject.com/en/3.2/topics/i18n/ 120 | 121 | LANGUAGE_CODE = 'en-us' 122 | 123 | TIME_ZONE = 'UTC' 124 | 125 | USE_I18N = True 126 | 127 | USE_L10N = True 128 | 129 | USE_TZ = True 130 | 131 | 132 | # Static files (CSS, JavaScript, Images) 133 | # https://docs.djangoproject.com/en/3.2/howto/static-files/ 134 | 135 | STATIC_URL = '/static/' 136 | STATIC_ROOT = BASE_DIR / 'staticfiles' 137 | 138 | MEDIA_URL = '/media/' 139 | MEDIA_ROOT = BASE_DIR / 'media' 140 | 141 | STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage' 142 | 143 | # Auth User Model 144 | AUTH_USER_MODEL = "Main_App.MyUser" 145 | 146 | # Authentication Backend 147 | 148 | AUTHENTICATION_BACKENDS = ['Main_App.EmailAuthentication.EmailAuth'] 149 | 150 | # Default primary key field type 151 | # https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field 152 | 153 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 154 | 155 | try: 156 | from .local_settings import * 157 | except ImportError: 158 | print('You are on production server') -------------------------------------------------------------------------------- /Main_App/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.6 on 2021-11-07 04:54 2 | 3 | from django.conf import settings 4 | import django.contrib.auth.models 5 | import django.contrib.auth.validators 6 | from django.db import migrations, models 7 | import django.db.models.deletion 8 | import django.utils.timezone 9 | 10 | 11 | class Migration(migrations.Migration): 12 | 13 | initial = True 14 | 15 | dependencies = [ 16 | ('auth', '0012_alter_user_first_name_max_length'), 17 | ] 18 | 19 | operations = [ 20 | migrations.CreateModel( 21 | name='Notification', 22 | fields=[ 23 | ('id', models.AutoField(primary_key=True, serialize=False)), 24 | ('heading', models.CharField(max_length=150)), 25 | ('message', models.TextField()), 26 | ('created_at', models.DateTimeField(auto_now_add=True)), 27 | ('created_by', models.CharField(max_length=20)), 28 | ('updated_at', models.DateTimeField(auto_now=True)), 29 | ], 30 | ), 31 | migrations.CreateModel( 32 | name='MyUser', 33 | fields=[ 34 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 35 | ('password', models.CharField(max_length=128, verbose_name='password')), 36 | ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), 37 | ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), 38 | ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), 39 | ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')), 40 | ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), 41 | ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), 42 | ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), 43 | ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), 44 | ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), 45 | ('user_type', models.CharField(choices=[(1, 'Admin'), (2, 'Teacher'), (3, 'Student')], default=1, max_length=10)), 46 | ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), 47 | ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), 48 | ], 49 | options={ 50 | 'verbose_name': 'user', 51 | 'verbose_name_plural': 'users', 52 | 'abstract': False, 53 | }, 54 | managers=[ 55 | ('objects', django.contrib.auth.models.UserManager()), 56 | ], 57 | ), 58 | migrations.CreateModel( 59 | name='Teacher', 60 | fields=[ 61 | ('id', models.AutoField(primary_key=True, serialize=False)), 62 | ('gender', models.CharField(choices=[('Male', 'Male'), ('Female', 'Female'), ('Other', 'Other')], default='Other', max_length=15)), 63 | ('address', models.TextField()), 64 | ('created_at', models.DateTimeField(auto_now_add=True)), 65 | ('updated_at', models.DateTimeField(auto_now=True)), 66 | ('admin', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), 67 | ], 68 | ), 69 | migrations.CreateModel( 70 | name='Student', 71 | fields=[ 72 | ('id', models.AutoField(primary_key=True, serialize=False)), 73 | ('gender', models.CharField(choices=[('Male', 'Male'), ('Female', 'Female'), ('Other', 'Other')], default='Other', max_length=15)), 74 | ('std', models.CharField(choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6)], max_length=10)), 75 | ('medium', models.CharField(choices=[('Marathi', 'Marathi'), ('Semi Eng', 'Semi Eng'), ('CBSE', 'CBSE')], default='Marathi', max_length=15)), 76 | ('address', models.TextField()), 77 | ('created_at', models.DateTimeField(auto_now_add=True)), 78 | ('updated_at', models.DateTimeField(auto_now=True)), 79 | ('admin', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), 80 | ], 81 | ), 82 | migrations.CreateModel( 83 | name='Admin', 84 | fields=[ 85 | ('id', models.AutoField(primary_key=True, serialize=False)), 86 | ('created_at', models.DateTimeField(auto_now_add=True)), 87 | ('updated_at', models.DateTimeField(auto_now=True)), 88 | ('admin', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), 89 | ], 90 | ), 91 | ] 92 | -------------------------------------------------------------------------------- /Main_App/static/Main_App/css/mycss.css: -------------------------------------------------------------------------------- 1 | /* -------------------------- login CSS ---------------------------- */ 2 | 3 | 4 | /* BASIC */ 5 | 6 | html { 7 | background-color: #56baed; 8 | } 9 | 10 | body { 11 | font-family: "Poppins", sans-serif; 12 | height: 100vh; 13 | } 14 | 15 | a { 16 | color: #92badd; 17 | display:inline-block; 18 | text-decoration: none; 19 | font-weight: 400; 20 | } 21 | 22 | h2 { 23 | text-align: center; 24 | font-size: 16px; 25 | font-weight: 600; 26 | text-transform: uppercase; 27 | display:inline-block; 28 | margin: 40px 8px 10px 8px; 29 | color: #cccccc; 30 | } 31 | 32 | 33 | 34 | /* STRUCTURE */ 35 | 36 | .wrapper { 37 | display: flex; 38 | align-items: center; 39 | flex-direction: column; 40 | justify-content: center; 41 | width: 100%; 42 | min-height: 100%; 43 | padding: 20px; 44 | } 45 | 46 | #error{ 47 | text-align: center; 48 | font-size: 16px; 49 | font-weight: 600; 50 | display:inline-block; 51 | margin: 10px 8px 10px 8px; 52 | color: #fff; 53 | } 54 | 55 | #formContent { 56 | -webkit-border-radius: 10px 10px 10px 10px; 57 | border-radius: 10px 10px 10px 10px; 58 | background: rgb(153, 56, 56); 59 | padding: 40px; 60 | width: 90%; 61 | max-width: 450px; 62 | position: relative; 63 | padding: 0px; 64 | -webkit-box-shadow: 0 30px 60px 0 rgba(0,0,0,0.3); 65 | box-shadow: 0 30px 60px 0 rgba(0,0,0,0.3); 66 | text-align: center; 67 | } 68 | 69 | #formHeader { 70 | background-color: #f8fafc79; 71 | border-top: 1px solid #dce8f1; 72 | padding: 25px; 73 | text-align: center; 74 | -webkit-border-radius: 10px 10px 0px 0px; 75 | border-radius: 10px 10px 0 0; 76 | } 77 | 78 | 79 | 80 | /* TABS */ 81 | 82 | h2.inactive { 83 | color: #cccccc; 84 | } 85 | 86 | h2.active { 87 | color: #0d0d0d; 88 | border-bottom: 2px solid #5fbae9; 89 | } 90 | 91 | 92 | 93 | /* FORM TYPOGRAPHY*/ 94 | 95 | input[type=submit] { 96 | background-color: #56baed; 97 | border: none; 98 | color: white; 99 | padding: 15px 80px; 100 | text-align: center; 101 | text-decoration: none; 102 | display: inline-block; 103 | text-transform: uppercase; 104 | font-size: 13px; 105 | -webkit-box-shadow: 0 10px 30px 0 rgba(95,186,233,0.4); 106 | box-shadow: 0 10px 30px 0 rgba(95,186,233,0.4); 107 | -webkit-border-radius: 5px 5px 5px 5px; 108 | border-radius: 5px 5px 5px 5px; 109 | margin: 5px 20px 20px 20px; 110 | -webkit-transition: all 0.3s ease-in-out; 111 | -moz-transition: all 0.3s ease-in-out; 112 | -ms-transition: all 0.3s ease-in-out; 113 | -o-transition: all 0.3s ease-in-out; 114 | transition: all 0.3s ease-in-out; 115 | } 116 | 117 | input[type=button]:hover, input[type=submit]:hover, input[type=reset]:hover { 118 | background-color: #39ace7; 119 | } 120 | 121 | input[type=button]:active, input[type=submit]:active, input[type=reset]:active { 122 | -moz-transform: scale(0.95); 123 | -webkit-transform: scale(0.95); 124 | -o-transform: scale(0.95); 125 | -ms-transform: scale(0.95); 126 | transform: scale(0.95); 127 | } 128 | 129 | input[type=email],input[type=password]{ 130 | background-color: #f6f6f6; 131 | border: none; 132 | color: #0d0d0d; 133 | padding: 15px 32px; 134 | text-align: center; 135 | text-decoration: none; 136 | display: inline-block; 137 | font-size: 16px; 138 | margin: 5px; 139 | width: 85%; 140 | border: 2px solid #f6f6f6; 141 | -webkit-transition: all 0.5s ease-in-out; 142 | -moz-transition: all 0.5s ease-in-out; 143 | -ms-transition: all 0.5s ease-in-out; 144 | -o-transition: all 0.5s ease-in-out; 145 | transition: all 0.5s ease-in-out; 146 | -webkit-border-radius: 5px 5px 5px 5px; 147 | border-radius: 5px 5px 5px 5px; 148 | } 149 | 150 | input[type=email]:focus,input[type=password]:focus { 151 | background-color: #fff; 152 | border-bottom: 2px solid #5fbae9; 153 | } 154 | 155 | input[type=email]:placeholder,input[type=password]:placeholder{ 156 | color: #cccccc; 157 | } 158 | 159 | 160 | 161 | /* ANIMATIONS */ 162 | 163 | /* Simple CSS3 Fade-in-down Animation */ 164 | .fadeInDown { 165 | -webkit-animation-name: fadeInDown; 166 | animation-name: fadeInDown; 167 | -webkit-animation-duration: 1s; 168 | animation-duration: 1s; 169 | -webkit-animation-fill-mode: both; 170 | animation-fill-mode: both; 171 | } 172 | 173 | @-webkit-keyframes fadeInDown { 174 | 0% { 175 | opacity: 0; 176 | -webkit-transform: translate3d(0, -100%, 0); 177 | transform: translate3d(0, -100%, 0); 178 | } 179 | 100% { 180 | opacity: 1; 181 | -webkit-transform: none; 182 | transform: none; 183 | } 184 | } 185 | 186 | @keyframes fadeInDown { 187 | 0% { 188 | opacity: 0; 189 | -webkit-transform: translate3d(0, -100%, 0); 190 | transform: translate3d(0, -100%, 0); 191 | } 192 | 100% { 193 | opacity: 1; 194 | -webkit-transform: none; 195 | transform: none; 196 | } 197 | } 198 | 199 | /* Simple CSS3 Fade-in Animation */ 200 | @-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } } 201 | @-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } } 202 | @keyframes fadeIn { from { opacity:0; } to { opacity:1; } } 203 | 204 | .fadeIn { 205 | opacity:0; 206 | -webkit-animation:fadeIn ease-in 1; 207 | -moz-animation:fadeIn ease-in 1; 208 | animation:fadeIn ease-in 1; 209 | 210 | -webkit-animation-fill-mode:forwards; 211 | -moz-animation-fill-mode:forwards; 212 | animation-fill-mode:forwards; 213 | 214 | -webkit-animation-duration:1s; 215 | -moz-animation-duration:1s; 216 | animation-duration:1s; 217 | } 218 | 219 | .fadeIn.first { 220 | -webkit-animation-delay: 0.4s; 221 | -moz-animation-delay: 0.4s; 222 | animation-delay: 0.4s; 223 | } 224 | 225 | .fadeIn.second { 226 | -webkit-animation-delay: 0.6s; 227 | -moz-animation-delay: 0.6s; 228 | animation-delay: 0.6s; 229 | } 230 | 231 | .fadeIn.third { 232 | -webkit-animation-delay: 0.8s; 233 | -moz-animation-delay: 0.8s; 234 | animation-delay: 0.8s; 235 | } 236 | 237 | .fadeIn.fourth { 238 | -webkit-animation-delay: 1s; 239 | -moz-animation-delay: 1s; 240 | animation-delay: 1s; 241 | } 242 | 243 | /* OTHERS */ 244 | 245 | *:focus { 246 | outline: none; 247 | } 248 | 249 | #icon { 250 | width:60%; 251 | } 252 | -------------------------------------------------------------------------------- /Main_App/v_teacher.py: -------------------------------------------------------------------------------- 1 | from datetime import date 2 | from random import randint 3 | from django.contrib import messages 4 | from django.http.response import HttpResponse, HttpResponseRedirect 5 | from django.shortcuts import render 6 | 7 | from django.conf import settings 8 | from django.core.mail.message import EmailMessage 9 | from django.template.loader import render_to_string 10 | 11 | from Main_App.models import MyUser, Notes, Notification, Student ,Result, Teacher 12 | from Main_App.restrictions import is_authenticated, is_teacher 13 | 14 | @is_authenticated 15 | @is_teacher 16 | def t_home(request): 17 | marathi_count = Student.objects.filter(medium='Marathi').count() 18 | semi_count = Student.objects.filter(medium='SemiEng').count() 19 | cbse_count = Student.objects.filter(medium='CBSE').count() 20 | foundation_count = Student.objects.filter(medium='Foundation').count() 21 | 22 | male_count = Student.objects.filter(gender="Male").count() 23 | female_count = Student.objects.filter(gender="Female").count() 24 | other_count = Student.objects.filter(gender="Other").count() 25 | 26 | count_1 = Student.objects.filter(std=1).count() 27 | count_2 = Student.objects.filter(std=2).count() 28 | count_3 = Student.objects.filter(std=3).count() 29 | count_4 = Student.objects.filter(std=4).count() 30 | count_5 = Student.objects.filter(std=5).count() 31 | count_6 = Student.objects.filter(std=6).count() 32 | count_7 = Student.objects.filter(std=7).count() 33 | count_8 = Student.objects.filter(std=8).count() 34 | count_9 = Student.objects.filter(std=9).count() 35 | count_10 = Student.objects.filter(std=10).count() 36 | 37 | context = { 38 | "marathi_count":marathi_count, 39 | "semi_count":semi_count, 40 | "cbse_count":cbse_count, 41 | "foundation_count":foundation_count, 42 | 43 | "male_count":male_count, 44 | "female_count":female_count, 45 | "other_count":other_count, 46 | 47 | "count_1":count_1, 48 | "count_2":count_2, 49 | "count_3":count_3, 50 | "count_4":count_4, 51 | "count_5":count_5, 52 | "count_6":count_6, 53 | "count_7":count_7, 54 | "count_8":count_8, 55 | "count_9":count_9, 56 | "count_10":count_10, 57 | } 58 | return render(request,'teacher/t_home.html',context) 59 | 60 | @is_authenticated 61 | @is_teacher 62 | def t_profile(request): 63 | return render(request,'teacher/t_profile.html') 64 | 65 | @is_authenticated 66 | @is_teacher 67 | def t_saveprofile(request): 68 | if request.method != "POST": 69 | return HttpResponse("Method not Allowed..!") 70 | else : 71 | teacher_id = request.POST.get('teacher_id') 72 | firstname = request.POST.get('firstname') 73 | lastname = request.POST.get('lastname') 74 | email = request.POST.get('email') 75 | address = request.POST.get('address') 76 | gender = request.POST.get('gender') 77 | password = request.POST.get('password') 78 | try : 79 | user = MyUser.objects.get(id=teacher_id) 80 | user.first_name=firstname 81 | user.last_name=lastname 82 | user.email=email 83 | if password != None and password != "": 84 | user.set_password(password) 85 | user.save() 86 | 87 | teacher = Teacher.objects.get(admin=teacher_id) 88 | teacher.address=address 89 | teacher.gender=gender 90 | teacher.save() 91 | messages.success(request,"Profile Updated successfully") 92 | return HttpResponseRedirect('/teacherprofile') 93 | except : 94 | messages.error(request,"Failed to Update Profile") 95 | return HttpResponseRedirect('/teacherprofile') 96 | 97 | @is_authenticated 98 | @is_teacher 99 | def t_addstudent(request): 100 | genders = Student.gender_choices 101 | stds = Student.std_choices 102 | mediums = Student.medium_choices 103 | return render(request,'teacher/t_addstudent.html',{'genders':genders,'stds':stds,'mediums':mediums}) 104 | 105 | @is_authenticated 106 | @is_teacher 107 | def t_savestudent(request): 108 | if request.method != "POST": 109 | return HttpResponse("Method not Allowed..!") 110 | else : 111 | firstname = request.POST.get('firstname') 112 | lastname = request.POST.get('lastname') 113 | email = request.POST.get('email') 114 | address = request.POST.get('address') 115 | gender = request.POST.get('gender') 116 | medium = request.POST.get('medium') 117 | std = request.POST.get('std') 118 | password = "Student@100" 119 | def random_username(): 120 | r=randint(1000,9999) 121 | username = "SC"+str(date.today().year)+str(r) 122 | try: 123 | if MyUser.objects.filter(username=username).exists(): 124 | return random_username() 125 | else : 126 | return username 127 | except : 128 | messages.error(request,"Student code failure") 129 | return HttpResponseRedirect("/addstudent") 130 | try : 131 | username = random_username() 132 | user = MyUser.objects.create_user(username=username,password=password,email=email,first_name=firstname,last_name=lastname,user_type=3) 133 | user.student.address=address 134 | user.student.gender=gender 135 | user.student.medium=medium 136 | user.student.std=std 137 | user.save() 138 | 139 | # template = render_to_string('base/email_template.html',{'name':firstname,'username':username,'password':password}) 140 | # email = EmailMessage( 141 | # 'Your account created successfully!', 142 | # template, 143 | # settings.EMAIL_HOST_USER, 144 | # [email] 145 | # ) 146 | # email.fail_silently = False 147 | # email.send() 148 | 149 | messages.success(request,"Student added successfully") 150 | return HttpResponseRedirect("/t_addstudent") 151 | except : 152 | messages.error(request,"Failed to add student") 153 | return HttpResponseRedirect("/t_addstudent") 154 | 155 | @is_authenticated 156 | @is_teacher 157 | def t_viewstudent(request): 158 | students = Student.objects.all() 159 | return render(request,'teacher/t_viewstudent.html',{'students':students}) 160 | 161 | @is_authenticated 162 | @is_teacher 163 | def t_resetspass(request,student_id): 164 | try: 165 | user = MyUser.objects.get(id=student_id) 166 | user.set_password("Student@100") 167 | messages.success(request,"Password reset successfully to Student@100") 168 | return HttpResponseRedirect("/t_viewstudent") 169 | except : 170 | messages.error(request,"Failed to reset password") 171 | return HttpResponseRedirect("/t_viewstudent") 172 | 173 | @is_authenticated 174 | @is_teacher 175 | def t_addnotification(request): 176 | return render(request,'teacher/t_addnotification.html') 177 | 178 | @is_authenticated 179 | @is_teacher 180 | def t_savenotification(request): 181 | if request.method != "POST": 182 | return HttpResponse("Method not Allowed..!") 183 | else : 184 | 185 | try : 186 | heading = request.POST.get('heading') 187 | message = request.POST.get('message') 188 | created_by = request.user.username 189 | 190 | notification = Notification.objects.create(heading=heading,message=message,created_by=created_by) 191 | notification.save() 192 | 193 | messages.success(request,"Notification added successfully") 194 | return HttpResponseRedirect("/t_addnotification") 195 | except : 196 | messages.error(request,"Failed to add Notification") 197 | return HttpResponseRedirect("/t_addnotification") 198 | 199 | @is_authenticated 200 | @is_teacher 201 | def t_deletenotification(request): 202 | try: 203 | notifications = Notification.objects.filter(created_by=request.user.username) 204 | return render(request,'teacher/t_deletenotification.html',{'notifications':notifications}) 205 | except: 206 | return render(request,'teacher/t_deletenotification.html') 207 | 208 | @is_authenticated 209 | @is_teacher 210 | def t_removenotification(request,notification_id): 211 | notification = Notification.objects.get(id=notification_id) 212 | try: 213 | notification.delete() 214 | messages.success(request,"Notification deleted successfully") 215 | return HttpResponseRedirect("/t_deletenotification") 216 | except : 217 | messages.error(request,"Failed to delete Notification") 218 | return HttpResponseRedirect("/t_deletenotification") 219 | 220 | @is_authenticated 221 | @is_teacher 222 | def t_viewnotification(request): 223 | try: 224 | notifications = Notification.objects.all() 225 | return render(request,'teacher/t_viewnotification.html',{'notifications':notifications}) 226 | except: 227 | return render(request,'teacher/t_viewnotification.html') 228 | 229 | @is_authenticated 230 | @is_teacher 231 | def t_addresult(request): 232 | stds = Result.std_choices 233 | mediums = Result.medium_choices 234 | return render(request,'teacher/t_addresult.html',{'stds':stds,'mediums':mediums}) 235 | 236 | @is_authenticated 237 | @is_teacher 238 | def t_saveresult(request): 239 | if request.method != "POST": 240 | return HttpResponse("Method not Allowed..!") 241 | else : 242 | try : 243 | title = request.POST.get('title') 244 | medium = request.POST.get('medium') 245 | std = request.POST.get('std') 246 | resultfile = request.FILES['resultfile'] 247 | created_by = request.user.username 248 | 249 | result = Result.objects.create(title=title,file=resultfile,medium=medium,std=std,created_by=created_by) 250 | result.save() 251 | 252 | messages.success(request,"Result uploaded successfully") 253 | return HttpResponseRedirect("/t_addresult") 254 | except : 255 | messages.error(request,"Failed to upload result") 256 | return HttpResponseRedirect("/t_addresult") 257 | 258 | @is_authenticated 259 | @is_teacher 260 | def t_deleteresult(request): 261 | try: 262 | results = Result.objects.filter(created_by=request.user.username) 263 | return render(request,'teacher/t_deleteresult.html',{'results':results}) 264 | except: 265 | return render(request,'teacher/t_deleteresult.html') 266 | 267 | @is_authenticated 268 | @is_teacher 269 | def t_removeresult(request,result_id): 270 | result = Result.objects.get(id=result_id) 271 | try: 272 | result.file.delete() 273 | result.delete() 274 | messages.success(request,"result deleted successfully") 275 | return HttpResponseRedirect("/t_deleteresult") 276 | except : 277 | messages.error(request,"Failed to delete result") 278 | return HttpResponseRedirect("/t_deleteresult") 279 | 280 | @is_authenticated 281 | @is_teacher 282 | def t_viewresult(request): 283 | results = Result.objects.all() 284 | return render(request,'teacher/t_viewresult.html',{'results':results}) 285 | 286 | @is_authenticated 287 | @is_teacher 288 | def t_addnotes(request): 289 | stds = Result.std_choices 290 | mediums = Result.medium_choices 291 | return render(request,'teacher/t_addnotes.html',{'stds':stds,'mediums':mediums}) 292 | 293 | @is_authenticated 294 | @is_teacher 295 | def t_savenotes(request): 296 | if request.method != "POST": 297 | return HttpResponse("Method not Allowed..!") 298 | else : 299 | try : 300 | title = request.POST.get('title') 301 | medium = request.POST.get('medium') 302 | std = request.POST.get('std') 303 | file = request.FILES['notes'] 304 | created_by = request.user.username 305 | 306 | notes = Notes.objects.create(title=title,file=file,medium=medium,std=std,created_by=created_by) 307 | notes.save() 308 | 309 | messages.success(request,"Notes uploaded successfully") 310 | return HttpResponseRedirect("/t_addnotes") 311 | except : 312 | messages.error(request,"Failed to upload Notes") 313 | return HttpResponseRedirect("/t_addnotes") 314 | 315 | @is_authenticated 316 | @is_teacher 317 | def t_deletenotes(request): 318 | try: 319 | notes = Notes.objects.filter(created_by=request.user.username) 320 | return render(request,'teacher/t_deletenotes.html',{'notes':notes}) 321 | except: 322 | return render(request,'teacher/t_deletenotes.html') 323 | 324 | @is_authenticated 325 | @is_teacher 326 | def t_removenotes(request,notes_id): 327 | notes = Notes.objects.get(id=notes_id) 328 | try: 329 | notes.file.delete() 330 | notes.delete() 331 | messages.success(request,"Note deleted successfully") 332 | return HttpResponseRedirect("/t_deletenotes") 333 | except : 334 | messages.error(request,"Failed to delete Note") 335 | return HttpResponseRedirect("/t_deletenotes") 336 | 337 | @is_authenticated 338 | @is_teacher 339 | def t_viewnotes(request): 340 | notes = Notes.objects.all() 341 | return render(request,'teacher/t_viewnotes.html',{'notes':notes}) 342 | -------------------------------------------------------------------------------- /Main_App/v_admin.py: -------------------------------------------------------------------------------- 1 | #from django.contrib.auth import authenticate,login,logout 2 | from django.contrib import admin, messages 3 | from django.http.response import HttpResponse, HttpResponseRedirect 4 | from django.shortcuts import render 5 | from random import randint 6 | from datetime import date 7 | 8 | from django.core.mail import EmailMessage 9 | from django.conf import settings 10 | from django.template.loader import render_to_string 11 | 12 | from Main_App.restrictions import is_admin, is_authenticated 13 | from Main_App.models import MyUser, Notes, Notification, Result,Teacher, Student 14 | 15 | 16 | # Create your views here. 17 | @is_authenticated 18 | @is_admin 19 | def a_home(request): 20 | 21 | marathi_count = Student.objects.filter(medium='Marathi').count() 22 | semi_count = Student.objects.filter(medium='SemiEng').count() 23 | cbse_count = Student.objects.filter(medium='CBSE').count() 24 | foundation_count = Student.objects.filter(medium='Foundation').count() 25 | 26 | male_count = Student.objects.filter(gender="Male").count() 27 | female_count = Student.objects.filter(gender="Female").count() 28 | other_count = Student.objects.filter(gender="Other").count() 29 | 30 | count_1 = Student.objects.filter(std=1).count() 31 | count_2 = Student.objects.filter(std=2).count() 32 | count_3 = Student.objects.filter(std=3).count() 33 | count_4 = Student.objects.filter(std=4).count() 34 | count_5 = Student.objects.filter(std=5).count() 35 | count_6 = Student.objects.filter(std=6).count() 36 | count_7 = Student.objects.filter(std=7).count() 37 | count_8 = Student.objects.filter(std=8).count() 38 | count_9 = Student.objects.filter(std=9).count() 39 | count_10 = Student.objects.filter(std=10).count() 40 | 41 | context = { 42 | "marathi_count":marathi_count, 43 | "semi_count":semi_count, 44 | "cbse_count":cbse_count, 45 | "foundation_count":foundation_count, 46 | 47 | "male_count":male_count, 48 | "female_count":female_count, 49 | "other_count":other_count, 50 | 51 | "count_1":count_1, 52 | "count_2":count_2, 53 | "count_3":count_3, 54 | "count_4":count_4, 55 | "count_5":count_5, 56 | "count_6":count_6, 57 | "count_7":count_7, 58 | "count_8":count_8, 59 | "count_9":count_9, 60 | "count_10":count_10, 61 | } 62 | 63 | return render(request,'admin/a_home.html',context) 64 | 65 | @is_authenticated 66 | @is_admin 67 | def adminprofile(request): 68 | return render(request,'admin/a_profile.html') 69 | 70 | @is_authenticated 71 | @is_admin 72 | def addteacher(request): 73 | genders = Teacher.gender_choices 74 | return render(request,'admin/a_addteacher.html',{'genders':genders}) 75 | 76 | @is_authenticated 77 | @is_admin 78 | def saveteacher(request): 79 | if request.method != "POST": 80 | return HttpResponse("Method not Allowed..!") 81 | else : 82 | firstname = request.POST.get('firstname') 83 | lastname = request.POST.get('lastname') 84 | email = request.POST.get('email') 85 | address = request.POST.get('address') 86 | gender = request.POST.get('gender') 87 | password = "Teacher@100" 88 | 89 | def random_username(): 90 | r=randint(1000,9999) 91 | 92 | username = "TC"+str(date.today().year)+str(r) 93 | 94 | try: 95 | Teacher.objects.get(username=username) 96 | return random_username() 97 | except : 98 | return username; 99 | 100 | try : 101 | username = random_username() 102 | user = MyUser.objects.create_user(username=username,password=password,email=email,first_name=firstname,last_name=lastname,user_type=2) 103 | user.teacher.address=address 104 | user.teacher.gender=gender 105 | user.save() 106 | 107 | # template = render_to_string('base/email_template.html',{'name':firstname,'username':username,'password':password}) 108 | # email = EmailMessage( 109 | # 'Your account created successfully!', 110 | # template, 111 | # settings.EMAIL_HOST_USER, 112 | # [email] 113 | # ) 114 | # email.fail_silently = False 115 | # email.send() 116 | 117 | messages.success(request,"Teacher added successfully") 118 | return HttpResponseRedirect("/addteacher") 119 | except : 120 | messages.error(request,"Failed to add teacher") 121 | return HttpResponseRedirect("/addteacher") 122 | 123 | @is_authenticated 124 | @is_admin 125 | def manageteacher(request): 126 | teachers = Teacher.objects.all() 127 | return render(request,'admin/a_manageteacher.html',{'teachers':teachers}) 128 | 129 | @is_authenticated 130 | @is_admin 131 | def deleteteacher(request,teacher_id): 132 | try: 133 | customuser = MyUser.objects.get(id=teacher_id) 134 | customuser.delete() 135 | messages.success(request,"Teacher deleted successfully") 136 | return HttpResponseRedirect("/manageteacher") 137 | except : 138 | messages.error(request,"Failed to delete Teacher") 139 | return HttpResponseRedirect("/manageteacher") 140 | 141 | @is_authenticated 142 | @is_admin 143 | def resetteacherpass(request,teacher_id): 144 | try: 145 | password = "Teacher@100" 146 | user = MyUser.objects.get(id=teacher_id) 147 | 148 | user.set_password(password) 149 | user.save() 150 | messages.success(request,"Password reset successfully to Teacher@100") 151 | return HttpResponseRedirect("/manageteacher") 152 | except : 153 | messages.error(request,"Failed to reset password") 154 | return HttpResponseRedirect("/manageteacher") 155 | 156 | @is_authenticated 157 | @is_admin 158 | def editteacher(request,teacher_id): 159 | teacher = Teacher.objects.get(admin=teacher_id) 160 | return render(request,'admin/a_editteacher.html',{'teacher':teacher}) 161 | 162 | @is_authenticated 163 | @is_admin 164 | def saveeditteacher(request): 165 | if request.method != "POST": 166 | return HttpResponse("Method not Allowed..!") 167 | else : 168 | teacher_id = request.POST.get('teacher_id') 169 | firstname = request.POST.get('firstname') 170 | lastname = request.POST.get('lastname') 171 | email = request.POST.get('email') 172 | address = request.POST.get('address') 173 | gender = request.POST.get('gender') 174 | try : 175 | user = MyUser.objects.get(id=teacher_id) 176 | #create_user(username=username,email=email,first_name=firstname,last_name=lastname,user_type=2) 177 | user.first_name=firstname 178 | user.last_name=lastname 179 | user.email=email 180 | user.save() 181 | 182 | teacher = Teacher.objects.get(admin=teacher_id) 183 | teacher.address=address 184 | teacher.gender=gender 185 | teacher.save() 186 | messages.success(request,"Teacher Updated successfully") 187 | return HttpResponseRedirect("/editteacher/"+teacher_id) 188 | except : 189 | messages.error(request,"Failed to Update teacher") 190 | return HttpResponseRedirect("/editteacher"+teacher_id) 191 | 192 | 193 | @is_authenticated 194 | @is_admin 195 | def addstudent(request): 196 | genders = Student.gender_choices 197 | stds = Student.std_choices 198 | mediums = Student.medium_choices 199 | return render(request,'admin/a_addstudent.html',{'genders':genders,'stds':stds,'mediums':mediums}) 200 | 201 | @is_authenticated 202 | @is_admin 203 | def savestudent(request): 204 | if request.method != "POST": 205 | return HttpResponse("Method not Allowed..!") 206 | else : 207 | firstname = request.POST.get('firstname') 208 | lastname = request.POST.get('lastname') 209 | email = request.POST.get('email') 210 | address = request.POST.get('address') 211 | gender = request.POST.get('gender') 212 | medium = request.POST.get('medium') 213 | std = request.POST.get('std') 214 | password = "Student@100" 215 | def random_username(): 216 | r=randint(1000,9999) 217 | username = "SC"+str(date.today().year)+str(r) 218 | try: 219 | if MyUser.objects.filter(username=username).exists(): 220 | return random_username() 221 | else : 222 | return username 223 | except : 224 | messages.error(request,"Student code failure") 225 | return HttpResponseRedirect("/addstudent") 226 | try : 227 | username = random_username() 228 | user = MyUser.objects.create_user(username=username,password=password,email=email,first_name=firstname,last_name=lastname,user_type=3) 229 | user.student.address=address 230 | user.student.gender=gender 231 | user.student.medium=medium 232 | user.student.std=std 233 | user.save() 234 | 235 | # template = render_to_string('base/email_template.html',{'name':firstname,'username':username,'password':password}) 236 | # email = EmailMessage( 237 | # 'Kagne Coaching account creation!', 238 | # template, 239 | # settings.EMAIL_HOST_USER, 240 | # [email] 241 | # ) 242 | # email.fail_silently = False 243 | # email.send() 244 | 245 | messages.success(request,"Student added successfully") 246 | return HttpResponseRedirect("/addstudent") 247 | except : 248 | messages.error(request,"Failed to add student") 249 | return HttpResponseRedirect("/addstudent") 250 | 251 | 252 | @is_authenticated 253 | @is_admin 254 | def managestudent(request): 255 | students = Student.objects.all() 256 | return render(request,'admin/a_managestudent.html',{'students':students}) 257 | 258 | @is_authenticated 259 | @is_admin 260 | def deletestudent(request,student_id): 261 | try: 262 | customuser = MyUser.objects.get(id=student_id) 263 | customuser.delete() 264 | messages.success(request,"Student deleted successfully") 265 | return HttpResponseRedirect("/managestudent") 266 | except : 267 | messages.error(request,"Failed to delete Student") 268 | return HttpResponseRedirect("/managestudent") 269 | 270 | @is_authenticated 271 | @is_admin 272 | def resetstudentpass(request,student_id): 273 | try: 274 | password = "Student@100" 275 | user = MyUser.objects.get(id=student_id) 276 | user.set_password(password) 277 | user.save() 278 | messages.success(request,"Password reset successfully to Student@100") 279 | return HttpResponseRedirect("/managestudent") 280 | except : 281 | messages.error(request,"Failed to reset password") 282 | return HttpResponseRedirect("/managestudent") 283 | 284 | @is_authenticated 285 | @is_admin 286 | def editstudent(request,student_id): 287 | student = Student.objects.get(admin=student_id) 288 | return render(request,'admin/a_editstudent.html',{'student':student}) 289 | 290 | @is_authenticated 291 | @is_admin 292 | def saveeditstudent(request): 293 | if request.method != "POST": 294 | return HttpResponse("Method not Allowed..!") 295 | else : 296 | student_id = request.POST.get('student_id') 297 | firstname = request.POST.get('firstname') 298 | lastname = request.POST.get('lastname') 299 | email = request.POST.get('email') 300 | address = request.POST.get('address') 301 | gender = request.POST.get('gender') 302 | medium = request.POST.get('medium') 303 | std = request.POST.get('std') 304 | try : 305 | user = MyUser.objects.get(id=student_id) 306 | user.email=email 307 | user.first_name=firstname 308 | user.last_name=lastname 309 | user.save() 310 | 311 | student = Student.objects.get(admin=student_id) 312 | student.address=address 313 | student.gender=gender 314 | student.medium=medium 315 | student.std=std 316 | student.save() 317 | 318 | messages.success(request,"Student upadated successfully") 319 | return HttpResponseRedirect("/editstudent/"+student_id) 320 | except : 321 | messages.error(request,"Failed to update student") 322 | return HttpResponseRedirect("/editstudent/"+student_id) 323 | 324 | @is_authenticated 325 | @is_admin 326 | def a_addnotification(request): 327 | return render(request,'admin/a_addnotification.html') 328 | 329 | @is_authenticated 330 | @is_admin 331 | def a_savenotification(request): 332 | if request.method != "POST": 333 | return HttpResponse("Method not Allowed..!") 334 | else : 335 | 336 | try : 337 | heading = request.POST.get('heading') 338 | message = request.POST.get('message') 339 | created_by = request.user.username 340 | 341 | notification = Notification.objects.create(heading=heading,message=message,created_by=created_by) 342 | notification.save() 343 | 344 | messages.success(request,"Notification added successfully") 345 | return HttpResponseRedirect("/a_addnotification") 346 | except : 347 | messages.error(request,"Failed to add Notification") 348 | return HttpResponseRedirect("/a_addnotification") 349 | 350 | @is_authenticated 351 | @is_admin 352 | def managenotification(request): 353 | notifications = Notification.objects.all() 354 | return render(request,'admin/a_managenotification.html',{'notifications':notifications}) 355 | 356 | @is_authenticated 357 | @is_admin 358 | def a_deletenotification(request,notification_id): 359 | notification = Notification.objects.get(id=notification_id) 360 | try: 361 | notification.delete() 362 | messages.success(request,"Notification deleted successfully") 363 | return HttpResponseRedirect("/managenotification") 364 | except : 365 | messages.error(request,"Failed to delete Notification") 366 | return HttpResponseRedirect("/managenotification") 367 | 368 | @is_authenticated 369 | @is_admin 370 | def a_addresult(request): 371 | stds = Result.std_choices 372 | mediums = Result.medium_choices 373 | return render(request,'admin/a_addresult.html',{'stds':stds,'mediums':mediums}) 374 | 375 | @is_authenticated 376 | @is_admin 377 | def a_saveresult(request): 378 | if request.method != "POST": 379 | return HttpResponse("Method not Allowed..!") 380 | else : 381 | try : 382 | title = request.POST.get('title') 383 | medium = request.POST.get('medium') 384 | std = request.POST.get('std') 385 | resultfile = request.FILES['resultfile'] 386 | created_by = request.user.username 387 | 388 | result = Result.objects.create(title=title,file=resultfile,medium=medium,std=std,created_by=created_by) 389 | result.save() 390 | 391 | messages.success(request,"Result uploaded successfully") 392 | return HttpResponseRedirect("/a_addresult") 393 | except : 394 | messages.error(request,"Failed to upload result") 395 | return HttpResponseRedirect("/a_addresult") 396 | 397 | @is_authenticated 398 | @is_admin 399 | def a_viewresult(request): 400 | results = Result.objects.all() 401 | return render(request,'admin/a_viewresult.html',{'results':results}) 402 | 403 | @is_authenticated 404 | @is_admin 405 | def a_removeresult(request,result_id): 406 | result = Result.objects.get(id=result_id) 407 | try: 408 | result.file.delete() 409 | result.delete() 410 | messages.success(request,"Result deleted successfully") 411 | return HttpResponseRedirect("/a_viewresult") 412 | except : 413 | messages.error(request,"Failed to delete result") 414 | return HttpResponseRedirect("/a_viewresult") 415 | 416 | @is_authenticated 417 | @is_admin 418 | def a_addnotes(request): 419 | stds = Result.std_choices 420 | mediums = Result.medium_choices 421 | return render(request,'admin/a_addnotes.html',{'stds':stds,'mediums':mediums}) 422 | 423 | @is_authenticated 424 | @is_admin 425 | def a_savenotes(request): 426 | if request.method != "POST": 427 | return HttpResponse("Method not Allowed..!") 428 | else : 429 | try : 430 | title = request.POST.get('title') 431 | medium = request.POST.get('medium') 432 | std = request.POST.get('std') 433 | notesfile = request.FILES['notesfile'] 434 | created_by = request.user.username 435 | 436 | note = Notes.objects.create(title=title,file=notesfile,medium=medium,std=std,created_by=created_by) 437 | note.save() 438 | 439 | messages.success(request,"Notes uploaded successfully") 440 | return HttpResponseRedirect("/a_addnotes") 441 | except : 442 | messages.error(request,"Failed to upload notes") 443 | return HttpResponseRedirect("/a_addnotes") 444 | 445 | @is_authenticated 446 | @is_admin 447 | def a_viewnotes(request): 448 | notes = Notes.objects.all() 449 | return render(request,'admin/a_viewnotes.html',{'notes':notes}) 450 | 451 | @is_authenticated 452 | @is_admin 453 | def a_removenotes(request,notes_id): 454 | notes = Notes.objects.get(id=notes_id) 455 | try: 456 | notes.file.delete() 457 | notes.delete() 458 | messages.success(request,"Note deleted successfully") 459 | return HttpResponseRedirect("/a_viewnotes") 460 | except : 461 | messages.error(request,"Failed to delete note") 462 | return HttpResponseRedirect("/a_viewnotes") --------------------------------------------------------------------------------