Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add school management system #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
141 changes: 141 additions & 0 deletions School-Management-System/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@

# Created by https://www.gitignore.io/api/django
# Edit at https://www.gitignore.io/?templates=django

### Django ###
*.log
*.pot
*.pyc
__pycache__/
local_settings.py
db.sqlite3
/media
venv
/photos

# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
# <django-project-name>/staticfiles/

### Django.Python Stack ###
# Byte-compiled / optimized / DLL files
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo

# Django stuff:
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# End of https://www.gitignore.io/api/django
1 change: 1 addition & 0 deletions School-Management-System/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# School-Management-System
Empty file.
3 changes: 3 additions & 0 deletions School-Management-System/accounts/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions School-Management-System/accounts/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class AccountsConfig(AppConfig):
name = 'accounts'
6 changes: 6 additions & 0 deletions School-Management-System/accounts/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django import forms

class UserLoginForm(forms.Form):
username = forms.CharField(widget=forms.TextInput(attrs={"class": "form-control", "placeholder": "Username"}))
password = forms.CharField(widget=forms.PasswordInput(attrs={"class": "form-control", "placeholder": "Password"}))

Empty file.
3 changes: 3 additions & 0 deletions School-Management-System/accounts/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
3 changes: 3 additions & 0 deletions School-Management-System/accounts/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
8 changes: 8 additions & 0 deletions School-Management-System/accounts/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.urls import path
from . import views

urlpatterns = [
path('login/', views.user_login, name='login'),
path('logout/', views.user_logout, name='logout'),
]

32 changes: 32 additions & 0 deletions School-Management-System/accounts/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login, logout
from django.contrib import messages
from .forms import UserLoginForm

# Create your views here.
def user_login(request):
forms = UserLoginForm()
if request.method == "POST":
forms = UserLoginForm(request.POST)
if forms.is_valid():
username = forms.cleaned_data["username"]
password = forms.cleaned_data["password"]

user = authenticate(username=username, password=password)

if user:
login(request, user)
return redirect("home")
else:
messages.error(request, "Invalid User or Password")
return redirect("login")

context = {
"forms": forms
}
return render(request, "accounts/login.html", context)

def user_logout(request):
logout(request)
return redirect("login")

Empty file.
6 changes: 6 additions & 0 deletions School-Management-System/api/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.contrib import admin
from .models import *

# Register your models here.
admin.site.register(Result)

5 changes: 5 additions & 0 deletions School-Management-System/api/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class ApiConfig(AppConfig):
name = 'api'
23 changes: 23 additions & 0 deletions School-Management-System/api/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.2.2 on 2019-08-04 05:50

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Result',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('board', models.CharField(max_length=255)),
('roll', models.IntegerField()),
('gpa', models.IntegerField()),
],
),
]
Empty file.
10 changes: 10 additions & 0 deletions School-Management-System/api/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.db import models

# Create your models here.
class Result(models.Model):
board = models.CharField(max_length=255)
roll = models.IntegerField()
gpa = models.IntegerField()

def __str__(self):
return str(self.roll)
12 changes: 12 additions & 0 deletions School-Management-System/api/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from rest_framework import serializers
from students.models import StudentShiftInfo

class ResultInfoSerializer(serializers.Serializer):
board = serializers.CharField(max_length=12)
roll = serializers.IntegerField()


class StudentInfoSerializer(serializers.ModelSerializer):
class Meta:
model = StudentShiftInfo
fields = '__all__'
3 changes: 3 additions & 0 deletions School-Management-System/api/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
9 changes: 9 additions & 0 deletions School-Management-System/api/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.urls import path
from . import views

urlpatterns = [
path('attendance/<student_class>/<student_id>', views.StudentAttendance.as_view(), name='student_attendance'),
path('result', views.ResultInfo.as_view(), name='result'),
path('student/create', views.CreateStudentInfo.as_view()),
]

57 changes: 57 additions & 0 deletions School-Management-System/api/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from django.shortcuts import render
from students.models import Attendance
from rest_framework.decorators import api_view
from rest_framework.response import Response
from rest_framework import status
from rest_framework.views import APIView
from rest_framework.permissions import IsAuthenticated
from .serializers import ResultInfoSerializer, StudentInfoSerializer
from .models import Result
from students.models import StudentInfo

# Create your views here.
@api_view()
def student_attendance(request, student_class, student_id):
try:
Attendance.objects.create_attendance(student_class, student_id)
return Response({"Status": "Atendance Counted Successfully"}, status=status.HTTP_200_OK)
except Exception as err:
print(err)
return Response({"Status": "Attendance already has taken"}, status=status.HTTP_400_BAD_REQUEST)


# Class Based View (CBV)
class StudentAttendance(APIView):
def get(self, request, student_class, student_id):
try:
Attendance.objects.create_attendance(student_class, student_id)
return Response({"Status": "Atendance Counted Successfully"}, status=status.HTTP_200_OK)
except Exception as err:
print(err)
return Response({"Status": "Attendance already has taken"}, status=status.HTTP_400_BAD_REQUEST)


class ResultInfo(APIView):
permission_classes = (IsAuthenticated,)
def post(self, request):
result_serializer = ResultInfoSerializer(data=request.data)
if result_serializer.is_valid():
board = result_serializer.validated_data["board"]
roll = result_serializer.validated_data["roll"]
result_obj = Result.objects.get(board=board, roll=roll)
return Response({"Result": result_obj.gpa})

return Response(result_serializer.errors)


class CreateStudentInfo(APIView):
permission_classes = (IsAuthenticated,)
def post(self, request):
create_student_serializer = StudentInfoSerializer(data=request.data)
if create_student_serializer.is_valid():
create_student_serializer.save()
return Response({"Status": "Success"}, status=status.HTTP_200_OK)
else:
return Response({"Status": create_student_serializer.errors}, status=status.HTTP_400_BAD_REQUEST)


Empty file.
7 changes: 7 additions & 0 deletions School-Management-System/employee/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.contrib import admin
from .models import OfficialInfo, PersonalInfo

# Register your models here.
admin.site.register(OfficialInfo)
admin.site.register(PersonalInfo)

5 changes: 5 additions & 0 deletions School-Management-System/employee/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class EmployeeConfig(AppConfig):
name = 'employee'
13 changes: 13 additions & 0 deletions School-Management-System/employee/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django import forms

class OfficialInfoForm(forms.Form):
official_register_number = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'LM10'}))
official_register_date = forms.CharField(widget=forms.DateInput(attrs={'placeholder': '22-07-1990'}))


class PersonalInfo(forms.Form):
full_name = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'John Doe'}))
dob = forms.CharField(widget=forms.DateInput(attrs={'placeholder': '22-07-1990'}))
another_fullname = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'John Doe'}))
national_id = forms.CharField(widget=forms.NumberInput(attrs={'placeholder': ''}))
employee_avatar = forms.CharField(widget=forms.FileInput(attrs={'placeholder': ''}))
Loading