Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
9a25472
chore: update .gitignore
Jun 20, 2022
e335694
chore: remove __pycache__ directories
Jun 20, 2022
d0c1c47
feat: implement initial frontend (wip)
Jun 20, 2022
4b99949
feat: change white background
Jun 20, 2022
cec03ac
feat: add POST api
Jun 21, 2022
b44ffc3
Connected API to Frontend
ilnarkhasanov Jun 21, 2022
24eaf72
Improved event handler
ilnarkhasanov Jun 22, 2022
83b9a59
Opening sign in page on / and changed the background to white
ilnarkhasanov Jun 22, 2022
17a730c
Updated records in DB
ilnarkhasanov Jun 22, 2022
2556f3a
Fixed the views.py
ilnarkhasanov Jun 22, 2022
89bcdae
feat: add timedate forms
Jun 22, 2022
9deca60
feat: update remind before
Jun 22, 2022
b6738b1
add JS logic for events
Jun 22, 2022
6a77b03
chore: edit gitignore
Jun 22, 2022
b40867d
chore: untrack credentials.py
Jun 22, 2022
89ce95d
chore: update events.html
Jun 22, 2022
e8a0696
chore: remove deprecated tag in base.css
Jun 25, 2022
8abbee2
Added linter and pytest
ilnarkhasanov Jun 25, 2022
6c04553
Security updates: only GET responses in views.py are allowed
ilnarkhasanov Jun 25, 2022
ab2d089
Offed the debug mode
ilnarkhasanov Jun 25, 2022
bfc87cd
Fixed some issues according to linter
ilnarkhasanov Jun 25, 2022
5ae1a5f
Reformatted setting.py with black
ilnarkhasanov Jun 25, 2022
3b0c987
Added 3 tests
ilnarkhasanov Jun 25, 2022
022a2f3
Fixed imports
ilnarkhasanov Jun 25, 2022
69790b8
PEP8 fix in tests
ilnarkhasanov Jun 25, 2022
41c73dd
Fixed test_urls.py
ilnarkhasanov Jun 25, 2022
ed31727
Added stubs for Django
ilnarkhasanov Jun 25, 2022
59e4e68
Added Django tests to pytest.yaml
ilnarkhasanov Jun 25, 2022
686d0e6
Removed unnecessary print
ilnarkhasanov Jun 25, 2022
2acb8a7
Changed the structure of project
ilnarkhasanov Jun 26, 2022
e72c022
Added POST request for the DoE emails
ilnarkhasanov Jun 26, 2022
2209f5a
Added students to database
ilnarkhasanov Jun 26, 2022
0f135e8
Added sending mails to cc
ilnarkhasanov Jun 26, 2022
856b678
feat: edit group of recipients
Jun 27, 2022
a10040a
feat: change initial font to Helvetica
Jun 27, 2022
2f960e1
Merge branch 'Website' into DoE_emails
ilnarkhasanov Jun 27, 2022
56acc33
Merge pull request #31 from InnoSWP/DoE_emails
ilnarkhasanov Jun 27, 2022
4a526f0
feat: add sendEmail page, add events
Jun 28, 2022
45e9d0b
chore: add credentials to gitignore
Jun 28, 2022
2592dac
feat: changed create=event
Jun 28, 2022
39e30d2
feat: add login page and logo
Jun 30, 2022
c1c3d47
feat: add calendar page
Jun 30, 2022
158185c
Fixed WideEvents
ilnarkhasanov Jun 30, 2022
1726a8f
Added files for heroku
ilnarkhasanov Jul 2, 2022
623a553
Changed runtime.txt
ilnarkhasanov Jul 2, 2022
5cc3acf
Changed python to 3.8.1
ilnarkhasanov Jul 2, 2022
a300730
Changed settings.py
ilnarkhasanov Jul 2, 2022
eaae94c
Changed urls.py
ilnarkhasanov Jul 2, 2022
4487440
Added whitenoise and changes static root
ilnarkhasanov Jul 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
#################################
#################################
## Super Linter GitHub Actions ##
#################################
#################################
name: Lint Code Base

#
# Documentation:
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
#

#############################
# Start the job on all push #
#############################
on:
push:
branches-ignore: [master, main]
# Remove the line above to run when pushing to master
pull_request:
branches: [master, main]

###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Lint Code Base
# Set the agent to run on
runs-on: ubuntu-latest

##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v3
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0

################################
# Run Linter against code base #
################################
- name: Lint Code Base
uses: github/super-linter@v4
env:
VALIDATE_ALL_CODEBASE: false
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

47 changes: 47 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This is a basic workflow to help you get started with Actions

name: PyTest testing


# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: "3.9.13"

# Runs a single command using the runners shell
- name: Run a one-line script
run: pip install -r requirements.txt

# Runs a set of commands using the runners shell
- name: Run write test
run: pytest -s testing/databasewritetest.py

# Runs a set of commands using the runners shell
- name: Run read test
run: pytest -s testing/databasereadtest.py

# Runs a set of tests for Django
- name: Run Django tests
run: python manage.py test WideEvents

7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
REST_API/venv/
venv/
__pycache__/
credentials*

# Static files collected by Django
# CrosslinkTimetable/static/
3 changes: 3 additions & 0 deletions CrosslinkTimetable/Auth/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.
6 changes: 6 additions & 0 deletions CrosslinkTimetable/Auth/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class AuthConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'Auth'
3 changes: 3 additions & 0 deletions CrosslinkTimetable/Auth/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.
11 changes: 11 additions & 0 deletions CrosslinkTimetable/Auth/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.response import Response
import requests


class AuthAPIView(APIView):
def get(self, request):


return Response({'resp': 200})
134 changes: 134 additions & 0 deletions CrosslinkTimetable/CrosslinkTimetable/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
"""
Django settings for CrosslinkTimetable project.

Generated by 'django-admin startproject' using Django 4.0.5.

For more information on this file, see
https://docs.djangoproject.com/en/4.0/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.0/ref/settings/
"""

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

CORS_ALLOW_ALL_ORIGINS = True


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-^4ybu!ebl*q-8i6gps@(6&+r980mc0n*g8bef4u^cm8rjtyw+!"

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False

ALLOWED_HOSTS: list = ['synctimetables.herokuapp.com', '127.0.0.1']

# Application definition

INSTALLED_APPS = [
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"WideEvents.apps.WideeventsConfig",
"rest_framework",
"corsheaders",
]

MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware"
]

ROOT_URLCONF = "CrosslinkTimetable.urls"

TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [BASE_DIR / "templates"],
"APP_DIRS": True,
"OPTIONS": {
"context_processors": [
"django.template.context_processors.debug",
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
],
},
},
]

WSGI_APPLICATION = "CrosslinkTimetable.wsgi.application"


# Database
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases

DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}


# Password validation
# https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]


# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/

LANGUAGE_CODE = "en-us"

TIME_ZONE = "Europe/Moscow"

USE_I18N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/

STATIC_URL = "static/"
STATICFILES_DIRS = [
BASE_DIR / "static"
]
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
# STATIC_ROOT = BASE_DIR / "../static"

# Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
23 changes: 23 additions & 0 deletions CrosslinkTimetable/CrosslinkTimetable/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django.contrib import admin
from django.urls import path
from CrosslinkTimetable.WideEvents.views import EventAPIView, test_base_page, create_event, profile, events, calendar, loginPage, sendEmail
from CrosslinkTimetable.WideEvents.views import registerPage
from CrosslinkTimetable.DoE_emails.views import DoEEmailsAPIView
from CrosslinkTimetable.Auth.views import AuthAPIView

urlpatterns = [
path('', loginPage, name="login"),
path('login/auth', AuthAPIView.as_view(), name='auth'),
path('admin/', admin.site.urls, name="admin"),
path('WideEvents', EventAPIView.as_view(), name="WideEvents"),
path('DoE', DoEEmailsAPIView.as_view(), name="DoE"),
path('DoE/sendEmail', sendEmail, name="sendEmail"),
path('WideEvents/base', test_base_page, name="base"),
path('WideEvents/create-event', create_event, name="create-event"),
path('WideEvents/profile', profile, name="profile"),
path('WideEvents/events', events, name="events"),
# path('WideEvents/signin', signin, name="signin"),
path('login/', loginPage, name="login"),
path('register/', registerPage, name="register"),
path('WideEvents/calendar', calendar, name="calendar")
]
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'CrosslinkTimetable.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'CrosslinkTimetable.CrosslinkTimetable.settings')

application = get_wsgi_application()
Empty file.
3 changes: 3 additions & 0 deletions CrosslinkTimetable/DoE_emails/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.
6 changes: 6 additions & 0 deletions CrosslinkTimetable/DoE_emails/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class DoeEmailsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'DoE_emails'
Empty file.
3 changes: 3 additions & 0 deletions CrosslinkTimetable/DoE_emails/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 CrosslinkTimetable/DoE_emails/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.
52 changes: 52 additions & 0 deletions CrosslinkTimetable/DoE_emails/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.response import Response
from exchangelib import Message, Mailbox, Credentials, Account, DELEGATE
from credentials import login, password

from sqlite3 import connect


class DoEEmailsAPIView(APIView):
def post(self, request):
group_of_recipients = request.data['group_of_recipients']
group_of_recipients_cc = request.data['group_of_recipients_cc']

conn = connect('../CrosslinkTimetable/db.sqlite3')
cursor = conn.cursor()

if group_of_recipients == 'Students':
receiver = list(map(lambda x: x[0], cursor.execute("SELECT * FROM Students").fetchall()))
group_of_recipients = list(map(lambda x: Mailbox(email_address=x), receiver))
elif group_of_recipients == 'Teachers':
receiver = list(map(lambda x: x[0], cursor.execute("SELECT * FROM Teachers").fetchall()))
group_of_recipients = list(map(lambda x: Mailbox(email_address=x), receiver))

if group_of_recipients_cc == 'Students' and request.data['group_of_recipients'] != request.data['group_of_recipients_cc']:
receiver_cc = list(map(lambda x: x[0], cursor.execute("SELECT * FROM Students").fetchall()))
group_of_recipients_cc = list(map(lambda x: Mailbox(email_address=x), receiver_cc))
elif group_of_recipients_cc == 'Teachers' and request.data['group_of_recipients'] != request.data['group_of_recipients_cc']:
receiver_cc = list(map(lambda x: x[0], cursor.execute("SELECT * FROM Teachers").fetchall()))
group_of_recipients_cc = list(map(lambda x: Mailbox(email_address=x), receiver_cc))

conn.close()

subject = request.data['subject']
content = request.data['content']

creds = Credentials(username=login, password=password)
my_account = Account(
primary_smtp_address=login, credentials=creds,
autodiscover=True, access_type=DELEGATE
)

m = Message(
account=my_account,
subject=subject,
body=content,
to_recipients=group_of_recipients,
cc_recipients=group_of_recipients_cc,
)
m.send()

return Response({"resp": 200})
Empty file.
18 changes: 18 additions & 0 deletions CrosslinkTimetable/WideEvents/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django.forms import ModelForm
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
from django import forms


# from .models import Order


# class OrderForm(ModelForm):
# class Meta:
# model = Order
# fields = '__all__'

class CreateUserForm(UserCreationForm):
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2']
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading