mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-04-16 02:10:19 -04:00
Merge branch 'development' of https://github.com/Rushilwiz/SkoolOS into development
This commit is contained in:
commit
7f3ca84458
|
@ -64,9 +64,6 @@ class Student(models.Model):
|
||||||
classes=models.CharField(max_length=100, default="", blank=True)
|
classes=models.CharField(max_length=100, default="", blank=True)
|
||||||
added_to=models.CharField(max_length=100, default="", blank=True)
|
added_to=models.CharField(max_length=100, default="", blank=True)
|
||||||
completed=models.TextField(default="", blank=True)
|
completed=models.TextField(default="", blank=True)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
return super(Student, self).save(*args, **kwargs)
|
return super(Student, self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
0
Website/config/__init__.py
Normal file
0
Website/config/__init__.py
Normal file
|
@ -11,6 +11,6 @@ import os
|
||||||
|
|
||||||
from django.core.asgi import get_asgi_application
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolos.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||||
|
|
||||||
application = get_asgi_application()
|
application = get_asgi_application()
|
|
@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
'skoolos.apps.SkoolosConfig',
|
||||||
'users.apps.UsersConfig',
|
'users.apps.UsersConfig',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
|
@ -64,7 +65,7 @@ MIDDLEWARE = [
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'skoolos.urls'
|
ROOT_URLCONF = 'config.urls'
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
|
@ -82,7 +83,7 @@ TEMPLATES = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
WSGI_APPLICATION = 'skoolos.wsgi.application'
|
WSGI_APPLICATION = 'config.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
|
@ -137,3 +138,5 @@ STATIC_URL = '/static/'
|
||||||
CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
CRISPY_TEMPLATE_PACK = 'bootstrap4'
|
||||||
|
|
||||||
LOGIN_REDIRECT_URL = '/'
|
LOGIN_REDIRECT_URL = '/'
|
||||||
|
|
||||||
|
LOGIN_URL = '/login'
|
31
Website/config/urls.py
Normal file
31
Website/config/urls.py
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
from django.urls import path
|
||||||
|
from rest_framework import routers
|
||||||
|
from api import views as api_views
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.conf.urls import include
|
||||||
|
from django.contrib.auth import views as auth_views
|
||||||
|
|
||||||
|
router = routers.DefaultRouter()
|
||||||
|
router.register(r'students', api_views.StudentViewSet)
|
||||||
|
router.register(r'teachers', api_views.TeacherViewSet)
|
||||||
|
router.register(r'assignments', api_views.AssignmentViewSet)
|
||||||
|
router.register(r'classes', api_views.ClassesViewSet)
|
||||||
|
# router.register(r'files', api_views.DefFilesViewSet)
|
||||||
|
router.register(r'users', api_views.UserViewSet)
|
||||||
|
|
||||||
|
from users import views as user_views
|
||||||
|
from users.forms import LoginForm
|
||||||
|
|
||||||
|
# Wire up our API using automatic URL routing.
|
||||||
|
# Additionally, we include login URLs for the browsable API.
|
||||||
|
urlpatterns = [
|
||||||
|
path('', include('skoolos.urls')),
|
||||||
|
path('api/', include(router.urls)),
|
||||||
|
path('api-auth/', include('rest_framework.urls')),
|
||||||
|
path('admin/', admin.site.urls),
|
||||||
|
path('login/', auth_views.LoginView.as_view(template_name='users/login.html', authentication_form=LoginForm), name='login'),
|
||||||
|
path('logout/', user_views.logout, name='logout'),
|
||||||
|
path('register/', user_views.register, name='register'),
|
||||||
|
path('create_account/', user_views.create_account, name='create_account'),
|
||||||
|
path('callback/', user_views.callback, name='callback'),
|
||||||
|
]
|
|
@ -11,6 +11,6 @@ import os
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolos.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||||
|
|
||||||
application = get_wsgi_application()
|
application = get_wsgi_application()
|
|
@ -5,7 +5,7 @@ import sys
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolos.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||||
try:
|
try:
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
|
|
3
Website/skoolos/admin.py
Normal file
3
Website/skoolos/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
5
Website/skoolos/apps.py
Normal file
5
Website/skoolos/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class SkoolosConfig(AppConfig):
|
||||||
|
name = 'skoolos'
|
0
Website/skoolos/migrations/__init__.py
Normal file
0
Website/skoolos/migrations/__init__.py
Normal file
3
Website/skoolos/models.py
Normal file
3
Website/skoolos/models.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
0
Website/skoolos/static/skoolos/styles.css
Normal file
0
Website/skoolos/static/skoolos/styles.css
Normal file
26
Website/skoolos/templates/skoolos/base.html
Normal file
26
Website/skoolos/templates/skoolos/base.html
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html lang="en" dir="ltr">
|
||||||
|
<head>
|
||||||
|
<!-- Required meta tags -->
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
|
||||||
|
<!-- Bootstrap CSS -->
|
||||||
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static 'skoolos/styles.css' %}">
|
||||||
|
|
||||||
|
<title>SkoolOS</title>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
<!-- Bootstrap JS -->
|
||||||
|
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
5
Website/skoolos/templates/skoolos/home.html
Normal file
5
Website/skoolos/templates/skoolos/home.html
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{% extends "skoolos/base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
<h1>welcome to skoolos</h1>
|
||||||
|
<h2>it's the future you've been waiting for</h2>
|
||||||
|
{% endblock content %}
|
3
Website/skoolos/tests.py
Normal file
3
Website/skoolos/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
|
@ -1,31 +1,6 @@
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from rest_framework import routers
|
|
||||||
from api import views as api_views
|
|
||||||
from users import views as user_views
|
|
||||||
from django.contrib import admin
|
|
||||||
from django.conf.urls import include
|
|
||||||
from django.contrib.auth import views as auth_views
|
|
||||||
|
|
||||||
router = routers.DefaultRouter()
|
|
||||||
router.register(r'students', api_views.StudentViewSet)
|
|
||||||
router.register(r'teachers', api_views.TeacherViewSet)
|
|
||||||
router.register(r'assignments', api_views.AssignmentViewSet)
|
|
||||||
router.register(r'classes', api_views.ClassesViewSet)
|
|
||||||
# router.register(r'files', api_views.DefFilesViewSet)
|
|
||||||
router.register(r'users', api_views.UserViewSet)
|
|
||||||
|
|
||||||
from users import views as user_views
|
|
||||||
from users.forms import LoginForm
|
|
||||||
|
|
||||||
# Wire up our API using automatic URL routing.
|
|
||||||
# Additionally, we include login URLs for the browsable API.
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# path('api/', include('api.urls')),
|
|
||||||
path('api/', include(router.urls)),
|
|
||||||
path('api-auth/', include('rest_framework.urls')),
|
|
||||||
path('admin/', admin.site.urls),
|
|
||||||
path('login/', auth_views.LoginView.as_view(template_name='users/login.html', authentication_form=LoginForm), name='login'),
|
|
||||||
path('', user_views.register, name='register'),
|
|
||||||
path('create_account/', user_views.create_account, name='create_account'),
|
|
||||||
path('callback/', user_views.callback, name='callback'),
|
|
||||||
]
|
]
|
||||||
|
|
8
Website/skoolos/views.py
Normal file
8
Website/skoolos/views.py
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
from django.contrib.auth.decorators import login_required
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
|
||||||
|
@login_required()
|
||||||
|
def home (request):
|
||||||
|
return render(request, "skoolos/home.html")
|
|
@ -1,7 +1,6 @@
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.contrib.auth.forms import AuthenticationForm
|
from django.contrib.auth.forms import AuthenticationForm
|
||||||
from django.db.models import Q
|
|
||||||
|
|
||||||
|
|
||||||
class LoginForm(AuthenticationForm):
|
class LoginForm(AuthenticationForm):
|
||||||
|
@ -10,10 +9,10 @@ class LoginForm(AuthenticationForm):
|
||||||
|
|
||||||
class UserCreationForm(forms.ModelForm):
|
class UserCreationForm(forms.ModelForm):
|
||||||
|
|
||||||
username = forms.CharField()
|
username = forms.CharField(disabled=True)
|
||||||
email = forms.EmailField()
|
email = forms.EmailField(disabled=True)
|
||||||
first_name = forms.CharField()
|
first_name = forms.CharField(disabled=True)
|
||||||
last_name = forms.CharField()
|
last_name = forms.CharField(disabled=True)
|
||||||
isStudent = forms.BooleanField(widget = forms.HiddenInput())
|
isStudent = forms.BooleanField(widget = forms.HiddenInput())
|
||||||
password = forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Password'}))
|
password = forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Password'}))
|
||||||
confirm_password = forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Confirm Password'}))
|
confirm_password = forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Confirm Password'}))
|
||||||
|
@ -31,7 +30,7 @@ class UserCreationForm(forms.ModelForm):
|
||||||
raise forms.ValidationError("Passwords do not match!")
|
raise forms.ValidationError("Passwords do not match!")
|
||||||
|
|
||||||
return cleaned_data
|
return cleaned_data
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = User
|
model = User
|
||||||
fields = ('username', 'email', 'first_name', 'last_name', 'password')
|
fields = ('username', 'email', 'first_name', 'last_name', 'password')
|
||||||
|
|
|
@ -18,4 +18,4 @@ class Token(models.Model):
|
||||||
return super(Token, self).save(*args, **kwargs)
|
return super(Token, self).save(*args, **kwargs)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.token;
|
return f"{self.username}'s Token";
|
||||||
|
|
|
@ -99,6 +99,10 @@ body {
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input:disabled {
|
||||||
|
background: #d9d9d9;
|
||||||
|
}
|
||||||
|
|
||||||
.errorlist {
|
.errorlist {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
a
|
|
||||||
<!-- Bootstrap JS -->
|
<!-- Bootstrap JS -->
|
||||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
||||||
|
|
|
@ -6,14 +6,29 @@
|
||||||
<div class="form">
|
<div class="form">
|
||||||
<form class="login-form" method="POST">
|
<form class="login-form" method="POST">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
{% if messages %}
|
||||||
|
{% for message in messages %}
|
||||||
|
<div class="alert alert-{{ message.tags }} alert-dismissible fade show">
|
||||||
|
{{ message }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% if form.errors %}
|
||||||
|
{% for field in form %}
|
||||||
|
{% for error in field.errors %}
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<strong>{{ error|escape }}</strong>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
{% for error in form.non_field_errors %}
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
<strong>{{ error|escape }}</strong>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
{% for field in form %}
|
{% for field in form %}
|
||||||
<div class="fieldWrapper">
|
{{ field }}
|
||||||
{{ field.errors }}
|
|
||||||
{{ field }}
|
|
||||||
{% if field.help_text %}
|
|
||||||
<p class="help">{{ field.help_text|safe }}</p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
<button type="submit">login</button>
|
<button type="submit">login</button>
|
||||||
<p class="message">Not registered? <a href="{% url 'register' %}">Create an account with Ion</a></p>
|
<p class="message">Not registered? <a href="{% url 'register' %}">Create an account with Ion</a></p>
|
||||||
|
|
|
@ -4,6 +4,13 @@
|
||||||
<div class="login-page">
|
<div class="login-page">
|
||||||
<div class="form">
|
<div class="form">
|
||||||
<div class="content-section">
|
<div class="content-section">
|
||||||
|
{% if messages %}
|
||||||
|
{% for message in messages %}
|
||||||
|
<div class="alert alert-{{ message.tags }} alert-dismissible fade show">
|
||||||
|
{{ message }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
<a href="{{ authorization_url }}" title="Ion" class="border border-dark p-3 btn btn-block btn-lg mx-auto" style="background: black; color: white;">
|
<a href="{{ authorization_url }}" title="Ion" class="border border-dark p-3 btn btn-block btn-lg mx-auto" style="background: black; color: white;">
|
||||||
<img src="https://ion.tjhsst.edu/static/img/favicon.png" style="filter: invert(1);">
|
<img src="https://ion.tjhsst.edu/static/img/favicon.png" style="filter: invert(1);">
|
||||||
Register with Ion
|
Register with Ion
|
||||||
|
|
|
@ -64,7 +64,7 @@ def callback (request):
|
||||||
|
|
||||||
|
|
||||||
messages.warning(request, "Invalid Callback Response")
|
messages.warning(request, "Invalid Callback Response")
|
||||||
return redirect('/login/')
|
return redirect('/register/')
|
||||||
|
|
||||||
|
|
||||||
def create_account (request):
|
def create_account (request):
|
||||||
|
@ -73,8 +73,8 @@ def create_account (request):
|
||||||
form = UserCreationForm(request.POST)
|
form = UserCreationForm(request.POST)
|
||||||
print(form.is_valid())
|
print(form.is_valid())
|
||||||
print(request.POST)
|
print(request.POST)
|
||||||
if form.is_valid():
|
cleaned_data = form.clean()
|
||||||
cleaned_data = form.cleaned_data
|
if cleaned_data.get('password') == cleaned_data.get('confirm_password'):
|
||||||
token = Token.objects.get(token=cleaned_data.get('token'))
|
token = Token.objects.get(token=cleaned_data.get('token'))
|
||||||
username = token.username
|
username = token.username
|
||||||
email = token.email
|
email = token.email
|
||||||
|
@ -91,16 +91,17 @@ def create_account (request):
|
||||||
user.save()
|
user.save()
|
||||||
token.delete()
|
token.delete()
|
||||||
print (user)
|
print (user)
|
||||||
|
messages.success(request, "Your SkoolOS account has successfully been created")
|
||||||
return redirect(f'/login/?username={username}')
|
return redirect(f'/login/?username={username}')
|
||||||
else:
|
else:
|
||||||
print(form.errors)
|
print(form.errors)
|
||||||
Token.objects.get(token=request.GET.get('token')).delete()
|
Token.objects.get(token=request.GET.get('token')).delete()
|
||||||
return redirect('/register/?error=password')
|
messages.warning(request, "Passwords did not match!")
|
||||||
|
return redirect('/register/')
|
||||||
|
|
||||||
if request.method == "GET" and Token.objects.filter(token=request.GET.get('token')).count() == 1:
|
if request.method == "GET" and Token.objects.filter(token=request.GET.get('token')).count() == 1:
|
||||||
print("GETGETGETGETGETGET")
|
print("GETGETGETGETGETGET")
|
||||||
token = Token.objects.get(token=request.GET.get('token'))
|
token = Token.objects.get(token=request.GET.get('token'))
|
||||||
tokenHash = request.GET.get('token')
|
|
||||||
username = token.username
|
username = token.username
|
||||||
email = token.email
|
email = token.email
|
||||||
first_name = token.first_name
|
first_name = token.first_name
|
||||||
|
@ -112,9 +113,17 @@ def create_account (request):
|
||||||
'first_name': first_name,
|
'first_name': first_name,
|
||||||
'last_name': last_name,
|
'last_name': last_name,
|
||||||
'isStudent': isStudent,
|
'isStudent': isStudent,
|
||||||
'token': token,
|
'token': token.token,
|
||||||
}
|
}
|
||||||
form = UserCreationForm(initial=initial)
|
form = UserCreationForm(initial=initial)
|
||||||
return render(request, 'users/create_account.html', {'form': form})
|
return render(request, 'users/create_account.html', {'form': form})
|
||||||
|
|
||||||
return redirect('/login/')
|
messages.warning(request, "Invalid token")
|
||||||
|
return redirect('/register/')
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def logout(request):
|
||||||
|
auth_logout(request)
|
||||||
|
messages.success(request, "You've been logged out! Have a good rest of your day!")
|
||||||
|
return redirect(request, "/login/")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user