diff --git a/CLI/oauth/index.html b/CLI/oauth/index.html index e84ea5f..774e6c5 100644 --- a/CLI/oauth/index.html +++ b/CLI/oauth/index.html @@ -14,7 +14,7 @@
- + Sign in with Ion diff --git a/CLI/server.py b/CLI/server.py index 0aef4c5..1cc095f 100644 --- a/CLI/server.py +++ b/CLI/server.py @@ -1,23 +1,23 @@ -from socket import * -from selenium import webdriver -import http.server -import socketserver -import threading +from http.server import HTTPServer +class HTTPServer(BaseHTTPServer.HTTPServer): -def create_server(): - port = 8000 - handler = http.server.SimpleHTTPRequestHandler - httpd = socketserver.TCPServer(("", port), handler) - print("serving at port:" + str(port)) - httpd.serve_forever() + _continue = True + def serve_until_shutdown(self): + while self._continue: + self.handle_request() -threading.Thread(target=create_server).start() + def shutdown(self): + self._continue = False + # We fire a last request at the server in order to take it out of the + # while loop in `self.serve_until_shutdown`. + try: + urllib2.urlopen( + 'http://%s:%s/' % (self.server_name, self.server_port)) + except urllib2.URLError: + # If the server is already shut down, we receive a socket error, + # which we ignore. + pass + self.server_close() -print("Server has started. Continuing..") - -browser = webdriver.Chrome() -browser.get("http://localhost:8000") - -assert "" in browser.page_source diff --git a/CLI/skoolos.py b/CLI/skoolos.py index 428415a..4ebc0cd 100644 --- a/CLI/skoolos.py +++ b/CLI/skoolos.py @@ -20,11 +20,12 @@ scope = ["read"] def main(): print("") - print(" SSSSS CCCCC HH HH OOOOO OOOOO LL OOOOO SSSSS ") - print("SS CC C HH HH OO OO OO OO LL OO OO SS ") - print(" SSSSS CC HHHHHHH OO OO OO OO LL OO OO SSSSS ") - print(" SS CC C HH HH OO OO OO OO LL OO OO SS") - print(" SSSSS CCCCC HH HH OOOO0 OOOO0 LLLLLLL OOOO0 SSSSS ") + print("░██████╗██╗░░██╗░█████╗░░█████╗░██╗░░░░░  ░█████╗░░██████╗") + print("██╔════╝██║░██╔╝██╔══██╗██╔══██╗██║░░░░░  ██╔══██╗██╔════╝") + print("╚█████╗░█████═╝░██║░░██║██║░░██║██║░░░░░  ██║░░██║╚█████╗░") + print("░╚═══██╗██╔═██╗░██║░░██║██║░░██║██║░░░░░  ██║░░██║░╚═══██╗") + print("██████╔╝██║░╚██╗╚█████╔╝╚█████╔╝███████╗  ╚█████╔╝██████╔╝") + print("╚═════╝░╚═╝░░╚═╝░╚════╝░░╚════╝░╚══════╝  ░╚════╝░╚═════╝░") print("") if not os.path.exists(".profile"): @@ -53,15 +54,14 @@ def authenticate(): template.close() index.close() - # server = Thread(target=create_server) - # server.daemon = True - # server.start() + server = Thread(target=create_server) + server.daemon = True + server.start() browser = webdriver.Chrome() browser.get("localhost:8000/") while "http://localhost:8000/?code" not in browser.current_url: - http.server. time.sleep(0.25) url = browser.current_url @@ -89,11 +89,12 @@ def authenticate(): first_name = profile['first_name'] last_name = profile['last_name'] + os.chdir("..") profileFile = open(".profile", "w") - profileFile.write(profile) + profileFile.write(profile.text()) profileFile.close() - # server.stop + # sys.exit def create_server(): diff --git a/Website/manage.py b/Website/manage.py index 063e014..f17dda4 100755 --- a/Website/manage.py +++ b/Website/manage.py @@ -5,7 +5,7 @@ import sys def main(): - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolsite.settings') + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolos.settings') try: from django.core.management import execute_from_command_line except ImportError as exc: diff --git a/Website/skoolsite/__init__.py b/Website/skoolos/__init__.py similarity index 100% rename from Website/skoolsite/__init__.py rename to Website/skoolos/__init__.py diff --git a/Website/skoolsite/asgi.py b/Website/skoolos/asgi.py similarity index 73% rename from Website/skoolsite/asgi.py rename to Website/skoolos/asgi.py index 805af95..9577b84 100644 --- a/Website/skoolsite/asgi.py +++ b/Website/skoolos/asgi.py @@ -1,5 +1,5 @@ """ -ASGI config for skoolsite project. +ASGI config for skoolos project. It exposes the ASGI callable as a module-level variable named ``application``. @@ -11,6 +11,6 @@ import os from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolsite.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolos.settings') application = get_asgi_application() diff --git a/Website/skoolsite/settings.py b/Website/skoolos/settings.py similarity index 93% rename from Website/skoolsite/settings.py rename to Website/skoolos/settings.py index b5bda98..b099675 100644 --- a/Website/skoolsite/settings.py +++ b/Website/skoolos/settings.py @@ -1,5 +1,5 @@ """ -Django settings for skoolsite project. +Django settings for skoolos project. Generated by 'django-admin startproject' using Django 3.0.7. @@ -31,6 +31,7 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ + 'users.apps.UsersConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -39,6 +40,8 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'rest_framework', 'api', + 'crispy_forms', + ] @@ -60,7 +63,7 @@ MIDDLEWARE = [ 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] -ROOT_URLCONF = 'skoolsite.urls' +ROOT_URLCONF = 'skoolos.urls' TEMPLATES = [ { @@ -78,7 +81,7 @@ TEMPLATES = [ }, ] -WSGI_APPLICATION = 'skoolsite.wsgi.application' +WSGI_APPLICATION = 'skoolos.wsgi.application' # Database @@ -129,3 +132,7 @@ USE_TZ = True # https://docs.djangoproject.com/en/3.0/howto/static-files/ STATIC_URL = '/static/' + +CRISPY_TEMPLATE_PACK = 'bootstrap4' + +LOGIN_REDIRECT_URL = '/' \ No newline at end of file diff --git a/Website/skoolos/urls.py b/Website/skoolos/urls.py new file mode 100644 index 0000000..9ee53ee --- /dev/null +++ b/Website/skoolos/urls.py @@ -0,0 +1,23 @@ +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) + + +# Wire up our API using automatic URL routing. +# Additionally, we include login URLs for the browsable API. +urlpatterns = [ + path('', 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"), name='login') +] \ No newline at end of file diff --git a/Website/skoolsite/wsgi.py b/Website/skoolos/wsgi.py similarity index 73% rename from Website/skoolsite/wsgi.py rename to Website/skoolos/wsgi.py index c3b05f8..f17107f 100644 --- a/Website/skoolsite/wsgi.py +++ b/Website/skoolos/wsgi.py @@ -1,5 +1,5 @@ """ -WSGI config for skoolsite project. +WSGI config for skoolos project. It exposes the WSGI callable as a module-level variable named ``application``. @@ -11,6 +11,6 @@ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolsite.settings') +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'skoolos.settings') application = get_wsgi_application() diff --git a/Website/skoolsite/urls.py b/Website/skoolsite/urls.py deleted file mode 100644 index 1c8f9f2..0000000 --- a/Website/skoolsite/urls.py +++ /dev/null @@ -1,22 +0,0 @@ -from django.urls import path -from rest_framework import routers -from api import views -from django.contrib import admin -from django.conf.urls import include - -router = routers.DefaultRouter() -router.register(r'students', views.StudentViewSet) -router.register(r'teachers', views.TeacherViewSet) -router.register(r'assignments', views.AssignmentViewSet) -router.register(r'classes', views.ClassesViewSet) -router.register(r'files', views.DefFilesViewSet) - - -# Wire up our API using automatic URL routing. -# Additionally, we include login URLs for the browsable API. -urlpatterns = [ - path('', include(router.urls)), - path('api-auth/', include('rest_framework.urls')), - path('admin/', admin.site.urls), - -] \ No newline at end of file diff --git a/Website/users/__init__.py b/Website/users/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Website/users/admin.py b/Website/users/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/Website/users/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/Website/users/apps.py b/Website/users/apps.py new file mode 100644 index 0000000..4ce1fab --- /dev/null +++ b/Website/users/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class UsersConfig(AppConfig): + name = 'users' diff --git a/Website/users/migrations/__init__.py b/Website/users/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/Website/users/models.py b/Website/users/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/Website/users/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/Website/users/static/users/styles.css b/Website/users/static/users/styles.css new file mode 100644 index 0000000..7aa3c45 --- /dev/null +++ b/Website/users/static/users/styles.css @@ -0,0 +1,104 @@ +@import url(https://fonts.googleapis.com/css?family=Roboto:300); + + + +.login-page { + width: 360px; + padding: 8% 0 0; + margin: auto; +} +.form { + position: relative; + z-index: 1; + background: #FFFFFF; + max-width: 360px; + height; 100vh; + margin: 0 auto 100px; + padding: 45px; + text-align: center; + box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24); +} +.form input { + font-family: "Roboto", sans-serif; + outline: 0; + background: #f2f2f2; + width: 100%; + border: 0; + margin: 0 0 15px; + padding: 15px; + box-sizing: border-box; + font-size: 14px; +} +.form button { + font-family: "Roboto", sans-serif; + text-transform: uppercase; + outline: 0; + background: #4CAF50; + width: 100%; + border: 0; + padding: 15px; + color: #FFFFFF; + font-size: 14px; + -webkit-transition: all 0.3 ease; + transition: all 0.3 ease; + cursor: pointer; +} +.form button:hover,.form button:active,.form button:focus { + background: #43A047; +} +.form .message { + margin: 15px 0 0; + color: #b3b3b3; + font-size: 12px; +} +.form .message a { + color: #4CAF50; + text-decoration: none; +} +.form .register-form { + display: none; +} +.container { + position: relative; + z-index: 1; + max-width: 300px; + margin: 0 auto; +} +.container:before, .container:after { + content: ""; + display: block; + clear: both; +} +.container .info { + margin: 50px auto; + text-align: center; +} +.container .info h1 { + margin: 0 0 15px; + padding: 0; + font-size: 36px; + font-weight: 300; + color: #1a1a1a; +} +.container .info span { + color: #4d4d4d; + font-size: 12px; +} +.container .info span a { + color: #000000; + text-decoration: none; +} +.container .info span .fa { + color: #EF3B3A; +} +body { + background: #fff url("black_on_white.png") repeat; + background-size: 512px; + font-family: "Roboto", sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.errorlist { + +} \ No newline at end of file diff --git a/Website/users/templates/users/base.html b/Website/users/templates/users/base.html new file mode 100644 index 0000000..f4dd9e6 --- /dev/null +++ b/Website/users/templates/users/base.html @@ -0,0 +1,27 @@ +{% 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 'users/styles.css' %}"> + + <title>SkoolOS + + + + {% block content %}{% endblock %} +a + + + + + + diff --git a/Website/users/templates/users/login.html b/Website/users/templates/users/login.html new file mode 100644 index 0000000..9f71406 --- /dev/null +++ b/Website/users/templates/users/login.html @@ -0,0 +1,16 @@ +{% extends "users/base.html" %} +{% load crispy_forms_tags %} + +{% block content %} +
+
+ +
+
+
+{% endblock %} \ No newline at end of file diff --git a/Website/users/templates/users/register.html b/Website/users/templates/users/register.html new file mode 100644 index 0000000..aefb3cb --- /dev/null +++ b/Website/users/templates/users/register.html @@ -0,0 +1,15 @@ +{% extends "users/base.html" %}\ + +{% block content %} +
+
+ +
+
+ +{% endblock %} \ No newline at end of file diff --git a/Website/users/tests.py b/Website/users/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/Website/users/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/Website/users/views.py b/Website/users/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/Website/users/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here.